Merge git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6
[wrt350n-kernel.git] / arch / sparc64 / kernel / setup.c
blob208e60294fd013126f1b75226be1312a9d157da2
1 /* $Id: setup.c,v 1.72 2002/02/09 19:49:30 davem Exp $
2 * linux/arch/sparc64/kernel/setup.c
4 * Copyright (C) 1995,1996 David S. Miller (davem@caip.rutgers.edu)
5 * Copyright (C) 1997 Jakub Jelinek (jj@sunsite.mff.cuni.cz)
6 */
8 #include <linux/errno.h>
9 #include <linux/sched.h>
10 #include <linux/kernel.h>
11 #include <linux/mm.h>
12 #include <linux/stddef.h>
13 #include <linux/unistd.h>
14 #include <linux/ptrace.h>
15 #include <linux/slab.h>
16 #include <asm/smp.h>
17 #include <linux/user.h>
18 #include <linux/screen_info.h>
19 #include <linux/delay.h>
20 #include <linux/fs.h>
21 #include <linux/seq_file.h>
22 #include <linux/syscalls.h>
23 #include <linux/kdev_t.h>
24 #include <linux/major.h>
25 #include <linux/string.h>
26 #include <linux/init.h>
27 #include <linux/inet.h>
28 #include <linux/console.h>
29 #include <linux/root_dev.h>
30 #include <linux/interrupt.h>
31 #include <linux/cpu.h>
32 #include <linux/initrd.h>
34 #include <asm/system.h>
35 #include <asm/io.h>
36 #include <asm/processor.h>
37 #include <asm/oplib.h>
38 #include <asm/page.h>
39 #include <asm/pgtable.h>
40 #include <asm/idprom.h>
41 #include <asm/head.h>
42 #include <asm/starfire.h>
43 #include <asm/mmu_context.h>
44 #include <asm/timer.h>
45 #include <asm/sections.h>
46 #include <asm/setup.h>
47 #include <asm/mmu.h>
48 #include <asm/ns87303.h>
50 #ifdef CONFIG_IP_PNP
51 #include <net/ipconfig.h>
52 #endif
54 /* Used to synchronize accesses to NatSemi SUPER I/O chip configure
55 * operations in asm/ns87303.h
57 DEFINE_SPINLOCK(ns87303_lock);
59 struct screen_info screen_info = {
60 0, 0, /* orig-x, orig-y */
61 0, /* unused */
62 0, /* orig-video-page */
63 0, /* orig-video-mode */
64 128, /* orig-video-cols */
65 0, 0, 0, /* unused, ega_bx, unused */
66 54, /* orig-video-lines */
67 0, /* orig-video-isVGA */
68 16 /* orig-video-points */
71 <<<<<<< HEAD:arch/sparc64/kernel/setup.c
72 void (*prom_palette)(int);
73 void (*prom_keyboard)(void);
75 =======
76 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a:arch/sparc64/kernel/setup.c
77 static void
78 prom_console_write(struct console *con, const char *s, unsigned n)
80 prom_write(s, n);
83 <<<<<<< HEAD:arch/sparc64/kernel/setup.c
84 unsigned int boot_flags = 0;
85 #define BOOTME_DEBUG 0x1
87 =======
88 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a:arch/sparc64/kernel/setup.c
89 /* Exported for mm/init.c:paging_init. */
90 unsigned long cmdline_memory_size = 0;
92 <<<<<<< HEAD:arch/sparc64/kernel/setup.c
93 static struct console prom_debug_console = {
94 .name = "debug",
95 =======
96 static struct console prom_early_console = {
97 .name = "earlyprom",
98 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a:arch/sparc64/kernel/setup.c
99 .write = prom_console_write,
100 <<<<<<< HEAD:arch/sparc64/kernel/setup.c
101 .flags = CON_PRINTBUFFER,
102 =======
103 .flags = CON_PRINTBUFFER | CON_BOOT,
104 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a:arch/sparc64/kernel/setup.c
105 .index = -1,
108 <<<<<<< HEAD:arch/sparc64/kernel/setup.c
109 /* XXX Implement this at some point... */
110 void kernel_enter_debugger(void)
114 =======
115 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a:arch/sparc64/kernel/setup.c
117 * Process kernel command line switches that are specific to the
118 * SPARC or that require special low-level processing.
120 static void __init process_switch(char c)
122 switch (c) {
123 case 'd':
124 <<<<<<< HEAD:arch/sparc64/kernel/setup.c
125 boot_flags |= BOOTME_DEBUG;
126 break;
127 =======
128 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a:arch/sparc64/kernel/setup.c
129 case 's':
130 break;
131 case 'h':
132 prom_printf("boot_flags_init: Halt!\n");
133 prom_halt();
134 break;
135 case 'p':
136 <<<<<<< HEAD:arch/sparc64/kernel/setup.c
137 /* Use PROM debug console. */
138 register_console(&prom_debug_console);
139 =======
140 /* Just ignore, this behavior is now the default. */
141 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a:arch/sparc64/kernel/setup.c
142 break;
143 case 'P':
144 /* Force UltraSPARC-III P-Cache on. */
145 if (tlb_type != cheetah) {
146 printk("BOOT: Ignoring P-Cache force option.\n");
147 break;
149 cheetah_pcache_forced_on = 1;
150 add_taint(TAINT_MACHINE_CHECK);
151 cheetah_enable_pcache();
152 break;
154 default:
155 printk("Unknown boot switch (-%c)\n", c);
156 break;
160 static void __init boot_flags_init(char *commands)
162 while (*commands) {
163 /* Move to the start of the next "argument". */
164 while (*commands && *commands == ' ')
165 commands++;
167 /* Process any command switches, otherwise skip it. */
168 if (*commands == '\0')
169 break;
170 if (*commands == '-') {
171 commands++;
172 while (*commands && *commands != ' ')
173 process_switch(*commands++);
174 continue;
176 if (!strncmp(commands, "mem=", 4)) {
178 * "mem=XXX[kKmM]" overrides the PROM-reported
179 * memory size.
181 cmdline_memory_size = simple_strtoul(commands + 4,
182 &commands, 0);
183 if (*commands == 'K' || *commands == 'k') {
184 cmdline_memory_size <<= 10;
185 commands++;
186 } else if (*commands=='M' || *commands=='m') {
187 cmdline_memory_size <<= 20;
188 commands++;
191 while (*commands && *commands != ' ')
192 commands++;
196 <<<<<<< HEAD:arch/sparc64/kernel/setup.c
197 extern void panic_setup(char *, int *);
199 =======
200 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a:arch/sparc64/kernel/setup.c
201 extern unsigned short root_flags;
202 extern unsigned short root_dev;
203 extern unsigned short ram_flags;
204 #define RAMDISK_IMAGE_START_MASK 0x07FF
205 #define RAMDISK_PROMPT_FLAG 0x8000
206 #define RAMDISK_LOAD_FLAG 0x4000
208 extern int root_mountflags;
210 char reboot_command[COMMAND_LINE_SIZE];
212 static struct pt_regs fake_swapper_regs = { { 0, }, 0, 0, 0, 0 };
214 void __init per_cpu_patch(void)
216 struct cpuid_patch_entry *p;
217 unsigned long ver;
218 int is_jbus;
220 if (tlb_type == spitfire && !this_is_starfire)
221 return;
223 is_jbus = 0;
224 if (tlb_type != hypervisor) {
225 __asm__ ("rdpr %%ver, %0" : "=r" (ver));
226 is_jbus = ((ver >> 32UL) == __JALAPENO_ID ||
227 (ver >> 32UL) == __SERRANO_ID);
230 p = &__cpuid_patch;
231 while (p < &__cpuid_patch_end) {
232 unsigned long addr = p->addr;
233 unsigned int *insns;
235 switch (tlb_type) {
236 case spitfire:
237 insns = &p->starfire[0];
238 break;
239 case cheetah:
240 case cheetah_plus:
241 if (is_jbus)
242 insns = &p->cheetah_jbus[0];
243 else
244 insns = &p->cheetah_safari[0];
245 break;
246 case hypervisor:
247 insns = &p->sun4v[0];
248 break;
249 default:
250 prom_printf("Unknown cpu type, halting.\n");
251 prom_halt();
254 *(unsigned int *) (addr + 0) = insns[0];
255 wmb();
256 __asm__ __volatile__("flush %0" : : "r" (addr + 0));
258 *(unsigned int *) (addr + 4) = insns[1];
259 wmb();
260 __asm__ __volatile__("flush %0" : : "r" (addr + 4));
262 *(unsigned int *) (addr + 8) = insns[2];
263 wmb();
264 __asm__ __volatile__("flush %0" : : "r" (addr + 8));
266 *(unsigned int *) (addr + 12) = insns[3];
267 wmb();
268 __asm__ __volatile__("flush %0" : : "r" (addr + 12));
270 p++;
274 void __init sun4v_patch(void)
276 extern void sun4v_hvapi_init(void);
277 struct sun4v_1insn_patch_entry *p1;
278 struct sun4v_2insn_patch_entry *p2;
280 if (tlb_type != hypervisor)
281 return;
283 p1 = &__sun4v_1insn_patch;
284 while (p1 < &__sun4v_1insn_patch_end) {
285 unsigned long addr = p1->addr;
287 *(unsigned int *) (addr + 0) = p1->insn;
288 wmb();
289 __asm__ __volatile__("flush %0" : : "r" (addr + 0));
291 p1++;
294 p2 = &__sun4v_2insn_patch;
295 while (p2 < &__sun4v_2insn_patch_end) {
296 unsigned long addr = p2->addr;
298 *(unsigned int *) (addr + 0) = p2->insns[0];
299 wmb();
300 __asm__ __volatile__("flush %0" : : "r" (addr + 0));
302 *(unsigned int *) (addr + 4) = p2->insns[1];
303 wmb();
304 __asm__ __volatile__("flush %0" : : "r" (addr + 4));
306 p2++;
309 sun4v_hvapi_init();
312 #ifdef CONFIG_SMP
313 void __init boot_cpu_id_too_large(int cpu)
315 prom_printf("Serious problem, boot cpu id (%d) >= NR_CPUS (%d)\n",
316 cpu, NR_CPUS);
317 prom_halt();
319 #endif
321 void __init setup_arch(char **cmdline_p)
323 /* Initialize PROM console and command line. */
324 *cmdline_p = prom_getbootargs();
325 strcpy(boot_command_line, *cmdline_p);
327 <<<<<<< HEAD:arch/sparc64/kernel/setup.c
328 =======
329 boot_flags_init(*cmdline_p);
330 register_console(&prom_early_console);
332 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a:arch/sparc64/kernel/setup.c
333 if (tlb_type == hypervisor)
334 printk("ARCH: SUN4V\n");
335 else
336 printk("ARCH: SUN4U\n");
338 #ifdef CONFIG_DUMMY_CONSOLE
339 conswitchp = &dummy_con;
340 #elif defined(CONFIG_PROM_CONSOLE)
341 conswitchp = &prom_con;
342 #endif
344 <<<<<<< HEAD:arch/sparc64/kernel/setup.c
345 boot_flags_init(*cmdline_p);
347 =======
348 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a:arch/sparc64/kernel/setup.c
349 idprom_init();
351 if (!root_flags)
352 root_mountflags &= ~MS_RDONLY;
353 ROOT_DEV = old_decode_dev(root_dev);
354 #ifdef CONFIG_BLK_DEV_RAM
355 rd_image_start = ram_flags & RAMDISK_IMAGE_START_MASK;
356 rd_prompt = ((ram_flags & RAMDISK_PROMPT_FLAG) != 0);
357 rd_doload = ((ram_flags & RAMDISK_LOAD_FLAG) != 0);
358 #endif
360 task_thread_info(&init_task)->kregs = &fake_swapper_regs;
362 #ifdef CONFIG_IP_PNP
363 if (!ic_set_manually) {
364 int chosen = prom_finddevice ("/chosen");
365 u32 cl, sv, gw;
367 cl = prom_getintdefault (chosen, "client-ip", 0);
368 sv = prom_getintdefault (chosen, "server-ip", 0);
369 gw = prom_getintdefault (chosen, "gateway-ip", 0);
370 if (cl && sv) {
371 ic_myaddr = cl;
372 ic_servaddr = sv;
373 if (gw)
374 ic_gateway = gw;
375 #if defined(CONFIG_IP_PNP_BOOTP) || defined(CONFIG_IP_PNP_RARP)
376 ic_proto_enabled = 0;
377 #endif
380 #endif
382 /* Get boot processor trap_block[] setup. */
383 init_cur_cpu_trap(current_thread_info());
385 paging_init();
388 /* BUFFER is PAGE_SIZE bytes long. */
390 extern char *sparc_cpu_type;
391 extern char *sparc_fpu_type;
393 extern void smp_info(struct seq_file *);
394 extern void smp_bogo(struct seq_file *);
395 extern void mmu_info(struct seq_file *);
397 unsigned int dcache_parity_tl1_occurred;
398 unsigned int icache_parity_tl1_occurred;
400 int ncpus_probed;
402 static int show_cpuinfo(struct seq_file *m, void *__unused)
404 seq_printf(m,
405 "cpu\t\t: %s\n"
406 "fpu\t\t: %s\n"
407 "prom\t\t: %s\n"
408 "type\t\t: %s\n"
409 "ncpus probed\t: %d\n"
410 "ncpus active\t: %d\n"
411 "D$ parity tl1\t: %u\n"
412 "I$ parity tl1\t: %u\n"
413 #ifndef CONFIG_SMP
414 "Cpu0ClkTck\t: %016lx\n"
415 #endif
417 sparc_cpu_type,
418 sparc_fpu_type,
419 prom_version,
420 ((tlb_type == hypervisor) ?
421 "sun4v" :
422 "sun4u"),
423 ncpus_probed,
424 num_online_cpus(),
425 dcache_parity_tl1_occurred,
426 icache_parity_tl1_occurred
427 #ifndef CONFIG_SMP
428 , cpu_data(0).clock_tick
429 #endif
431 #ifdef CONFIG_SMP
432 smp_bogo(m);
433 #endif
434 mmu_info(m);
435 #ifdef CONFIG_SMP
436 smp_info(m);
437 #endif
438 return 0;
441 static void *c_start(struct seq_file *m, loff_t *pos)
443 /* The pointer we are returning is arbitrary,
444 * it just has to be non-NULL and not IS_ERR
445 * in the success case.
447 return *pos == 0 ? &c_start : NULL;
450 static void *c_next(struct seq_file *m, void *v, loff_t *pos)
452 ++*pos;
453 return c_start(m, pos);
456 static void c_stop(struct seq_file *m, void *v)
460 const struct seq_operations cpuinfo_op = {
461 .start =c_start,
462 .next = c_next,
463 .stop = c_stop,
464 .show = show_cpuinfo,
467 extern int stop_a_enabled;
469 void sun_do_break(void)
471 if (!stop_a_enabled)
472 return;
474 prom_printf("\n");
475 flush_user_windows();
477 prom_cmdline();
480 int stop_a_enabled = 1;