1 /* 2 * init.c: PROM library initialisation code. 3 * 4 * Copyright (C) 1998 Harald Koerfgen 5 * Copyright (C) 2002, 2004 Maciej W. Rozycki 6 */ 7 #include <linux/config.h> 8 #include <linux/init.h> 9 #include <linux/smp.h> 10 #include <linux/string.h> 11 #include <linux/types.h> 12 13 #include <asm/bootinfo.h> 14 #include <asm/cpu.h> 15 #include <asm/processor.h> 16 17 #include <asm/dec/prom.h> 18 19 20 int (*__rex_bootinit)(void); 21 int (*__rex_bootread)(void); 22 int (*__rex_getbitmap)(memmap *); 23 unsigned long *(*__rex_slot_address)(int); 24 void *(*__rex_gettcinfo)(void); 25 int (*__rex_getsysid)(void); 26 void (*__rex_clear_cache)(void); 27 28 int (*__prom_getchar)(void); 29 char *(*__prom_getenv)(char *); 30 int (*__prom_printf)(char *, ...); 31 32 int (*__pmax_open)(char*, int); 33 int (*__pmax_lseek)(int, long, int); 34 int (*__pmax_read)(int, void *, int); 35 int (*__pmax_close)(int); 36 37 38 /* 39 * Detect which PROM the DECSTATION has, and set the callback vectors 40 * appropriately. 41 */ 42 void __init which_prom(s32 magic, s32 *prom_vec) 43 { 44 /* 45 * No sign of the REX PROM's magic number means we assume a non-REX 46 * machine (i.e. we're on a DS2100/3100, DS5100 or DS5000/2xx) 47 */ 48 if (prom_is_rex(magic)) { 49 /* 50 * Set up prom abstraction structure with REX entry points. 51 */ 52 __rex_bootinit = 53 (void *)(long)*(prom_vec + REX_PROM_BOOTINIT); 54 __rex_bootread = 55 (void *)(long)*(prom_vec + REX_PROM_BOOTREAD); 56 __rex_getbitmap = 57 (void *)(long)*(prom_vec + REX_PROM_GETBITMAP); 58 __prom_getchar = 59 (void *)(long)*(prom_vec + REX_PROM_GETCHAR); 60 __prom_getenv = 61 (void *)(long)*(prom_vec + REX_PROM_GETENV); 62 __rex_getsysid = 63 (void *)(long)*(prom_vec + REX_PROM_GETSYSID); 64 __rex_gettcinfo = 65 (void *)(long)*(prom_vec + REX_PROM_GETTCINFO); 66 __prom_printf = 67 (void *)(long)*(prom_vec + REX_PROM_PRINTF); 68 __rex_slot_address = 69 (void *)(long)*(prom_vec + REX_PROM_SLOTADDR); 70 __rex_clear_cache = 71 (void *)(long)*(prom_vec + REX_PROM_CLEARCACHE); 72 } else { 73 /* 74 * Set up prom abstraction structure with non-REX entry points. 75 */ 76 __prom_getchar = (void *)PMAX_PROM_GETCHAR; 77 __prom_getenv = (void *)PMAX_PROM_GETENV; 78 __prom_printf = (void *)PMAX_PROM_PRINTF; 79 __pmax_open = (void *)PMAX_PROM_OPEN; 80 __pmax_lseek = (void *)PMAX_PROM_LSEEK; 81 __pmax_read = (void *)PMAX_PROM_READ; 82 __pmax_close = (void *)PMAX_PROM_CLOSE; 83 } 84 } 85 86 void __init prom_init(void) 87 { 88 extern void dec_machine_halt(void); 89 static char cpu_msg[] __initdata = 90 "Sorry, this kernel is compiled for a wrong CPU type!\n"; 91 static char r3k_msg[] __initdata = 92 "Please recompile with \"CONFIG_CPU_R3000 = y\".\n"; 93 static char r4k_msg[] __initdata = 94 "Please recompile with \"CONFIG_CPU_R4x00 = y\".\n"; 95 s32 argc = fw_arg0; 96 s32 argv = fw_arg1; 97 u32 magic = fw_arg2; 98 s32 prom_vec = fw_arg3; 99 100 /* 101 * Determine which PROM we have 102 * (and therefore which machine we're on!) 103 */ 104 which_prom(magic, prom_vec); 105 106 if (prom_is_rex(magic)) 107 rex_clear_cache(); 108 109 /* Register the early console. */ 110 register_prom_console(); 111 112 /* Were we compiled with the right CPU option? */ 113 #if defined(CONFIG_CPU_R3000) 114 if ((current_cpu_data.cputype == CPU_R4000SC) || 115 (current_cpu_data.cputype == CPU_R4400SC)) { 116 printk(cpu_msg); 117 printk(r4k_msg); 118 dec_machine_halt(); 119 } 120 #endif 121 122 #if defined(CONFIG_CPU_R4X00) 123 if ((current_cpu_data.cputype == CPU_R3000) || 124 (current_cpu_data.cputype == CPU_R3000A)) { 125 printk(cpu_msg); 126 printk(r3k_msg); 127 dec_machine_halt(); 128 } 129 #endif 130 131 prom_meminit(magic); 132 prom_identify_arch(magic); 133 prom_init_cmdline(argc, argv, magic); 134 } 135