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