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