]>
Commit | Line | Data |
---|---|---|
1da177e4 LT |
1 | /* $Id: setup.c,v 1.72 2002/02/09 19:49:30 davem Exp $ |
2 | * linux/arch/sparc64/kernel/setup.c | |
3 | * | |
4 | * Copyright (C) 1995,1996 David S. Miller (davem@caip.rutgers.edu) | |
5 | * Copyright (C) 1997 Jakub Jelinek (jj@sunsite.mff.cuni.cz) | |
6 | */ | |
7 | ||
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/a.out.h> | |
894673ee | 19 | #include <linux/screen_info.h> |
1da177e4 | 20 | #include <linux/delay.h> |
1da177e4 LT |
21 | #include <linux/fs.h> |
22 | #include <linux/seq_file.h> | |
23 | #include <linux/syscalls.h> | |
24 | #include <linux/kdev_t.h> | |
25 | #include <linux/major.h> | |
26 | #include <linux/string.h> | |
27 | #include <linux/init.h> | |
28 | #include <linux/inet.h> | |
29 | #include <linux/console.h> | |
30 | #include <linux/root_dev.h> | |
31 | #include <linux/interrupt.h> | |
32 | #include <linux/cpu.h> | |
33 | #include <linux/initrd.h> | |
34 | ||
1da177e4 LT |
35 | #include <asm/system.h> |
36 | #include <asm/io.h> | |
37 | #include <asm/processor.h> | |
38 | #include <asm/oplib.h> | |
39 | #include <asm/page.h> | |
40 | #include <asm/pgtable.h> | |
41 | #include <asm/idprom.h> | |
42 | #include <asm/head.h> | |
43 | #include <asm/starfire.h> | |
44 | #include <asm/mmu_context.h> | |
45 | #include <asm/timer.h> | |
46 | #include <asm/sections.h> | |
47 | #include <asm/setup.h> | |
48 | #include <asm/mmu.h> | |
49 | ||
50 | #ifdef CONFIG_IP_PNP | |
51 | #include <net/ipconfig.h> | |
52 | #endif | |
53 | ||
54 | struct screen_info screen_info = { | |
55 | 0, 0, /* orig-x, orig-y */ | |
56 | 0, /* unused */ | |
57 | 0, /* orig-video-page */ | |
58 | 0, /* orig-video-mode */ | |
59 | 128, /* orig-video-cols */ | |
60 | 0, 0, 0, /* unused, ega_bx, unused */ | |
61 | 54, /* orig-video-lines */ | |
62 | 0, /* orig-video-isVGA */ | |
63 | 16 /* orig-video-points */ | |
64 | }; | |
65 | ||
1da177e4 LT |
66 | void (*prom_palette)(int); |
67 | void (*prom_keyboard)(void); | |
68 | ||
69 | static void | |
70 | prom_console_write(struct console *con, const char *s, unsigned n) | |
71 | { | |
72 | prom_write(s, n); | |
73 | } | |
74 | ||
1da177e4 LT |
75 | unsigned int boot_flags = 0; |
76 | #define BOOTME_DEBUG 0x1 | |
1da177e4 LT |
77 | |
78 | /* Exported for mm/init.c:paging_init. */ | |
79 | unsigned long cmdline_memory_size = 0; | |
80 | ||
81 | static struct console prom_debug_console = { | |
82 | .name = "debug", | |
83 | .write = prom_console_write, | |
84 | .flags = CON_PRINTBUFFER, | |
85 | .index = -1, | |
86 | }; | |
87 | ||
88 | /* XXX Implement this at some point... */ | |
89 | void kernel_enter_debugger(void) | |
90 | { | |
91 | } | |
92 | ||
1da177e4 LT |
93 | /* |
94 | * Process kernel command line switches that are specific to the | |
95 | * SPARC or that require special low-level processing. | |
96 | */ | |
97 | static void __init process_switch(char c) | |
98 | { | |
99 | switch (c) { | |
100 | case 'd': | |
101 | boot_flags |= BOOTME_DEBUG; | |
102 | break; | |
103 | case 's': | |
1da177e4 LT |
104 | break; |
105 | case 'h': | |
106 | prom_printf("boot_flags_init: Halt!\n"); | |
107 | prom_halt(); | |
108 | break; | |
109 | case 'p': | |
110 | /* Use PROM debug console. */ | |
111 | register_console(&prom_debug_console); | |
112 | break; | |
816242da DM |
113 | case 'P': |
114 | /* Force UltraSPARC-III P-Cache on. */ | |
115 | if (tlb_type != cheetah) { | |
116 | printk("BOOT: Ignoring P-Cache force option.\n"); | |
117 | break; | |
118 | } | |
119 | cheetah_pcache_forced_on = 1; | |
120 | add_taint(TAINT_MACHINE_CHECK); | |
121 | cheetah_enable_pcache(); | |
122 | break; | |
123 | ||
1da177e4 LT |
124 | default: |
125 | printk("Unknown boot switch (-%c)\n", c); | |
126 | break; | |
127 | } | |
128 | } | |
129 | ||
130 | static void __init process_console(char *commands) | |
131 | { | |
132 | serial_console = 0; | |
133 | commands += 8; | |
134 | /* Linux-style serial */ | |
135 | if (!strncmp(commands, "ttyS", 4)) | |
136 | serial_console = simple_strtoul(commands + 4, NULL, 10) + 1; | |
137 | else if (!strncmp(commands, "tty", 3)) { | |
138 | char c = *(commands + 3); | |
139 | /* Solaris-style serial */ | |
140 | if (c == 'a' || c == 'b') { | |
141 | serial_console = c - 'a' + 1; | |
142 | prom_printf ("Using /dev/tty%c as console.\n", c); | |
143 | } | |
144 | /* else Linux-style fbcon, not serial */ | |
145 | } | |
146 | #if defined(CONFIG_PROM_CONSOLE) | |
147 | if (!strncmp(commands, "prom", 4)) { | |
148 | char *p; | |
149 | ||
150 | for (p = commands - 8; *p && *p != ' '; p++) | |
151 | *p = ' '; | |
152 | conswitchp = &prom_con; | |
153 | } | |
154 | #endif | |
155 | } | |
156 | ||
157 | static void __init boot_flags_init(char *commands) | |
158 | { | |
159 | while (*commands) { | |
160 | /* Move to the start of the next "argument". */ | |
161 | while (*commands && *commands == ' ') | |
162 | commands++; | |
163 | ||
164 | /* Process any command switches, otherwise skip it. */ | |
165 | if (*commands == '\0') | |
166 | break; | |
167 | if (*commands == '-') { | |
168 | commands++; | |
169 | while (*commands && *commands != ' ') | |
170 | process_switch(*commands++); | |
171 | continue; | |
172 | } | |
173 | if (!strncmp(commands, "console=", 8)) { | |
174 | process_console(commands); | |
175 | } else if (!strncmp(commands, "mem=", 4)) { | |
176 | /* | |
177 | * "mem=XXX[kKmM]" overrides the PROM-reported | |
178 | * memory size. | |
179 | */ | |
180 | cmdline_memory_size = simple_strtoul(commands + 4, | |
181 | &commands, 0); | |
182 | if (*commands == 'K' || *commands == 'k') { | |
183 | cmdline_memory_size <<= 10; | |
184 | commands++; | |
185 | } else if (*commands=='M' || *commands=='m') { | |
186 | cmdline_memory_size <<= 20; | |
187 | commands++; | |
188 | } | |
189 | } | |
190 | while (*commands && *commands != ' ') | |
191 | commands++; | |
192 | } | |
193 | } | |
194 | ||
1da177e4 LT |
195 | extern void panic_setup(char *, int *); |
196 | ||
197 | extern unsigned short root_flags; | |
198 | extern unsigned short root_dev; | |
199 | extern unsigned short ram_flags; | |
200 | #define RAMDISK_IMAGE_START_MASK 0x07FF | |
201 | #define RAMDISK_PROMPT_FLAG 0x8000 | |
202 | #define RAMDISK_LOAD_FLAG 0x4000 | |
203 | ||
204 | extern int root_mountflags; | |
205 | ||
206 | char reboot_command[COMMAND_LINE_SIZE]; | |
207 | ||
208 | static struct pt_regs fake_swapper_regs = { { 0, }, 0, 0, 0, 0 }; | |
209 | ||
951bc82c | 210 | void __init per_cpu_patch(void) |
92704a1c | 211 | { |
92704a1c DM |
212 | struct cpuid_patch_entry *p; |
213 | unsigned long ver; | |
214 | int is_jbus; | |
215 | ||
216 | if (tlb_type == spitfire && !this_is_starfire) | |
217 | return; | |
218 | ||
d82ace7d DM |
219 | is_jbus = 0; |
220 | if (tlb_type != hypervisor) { | |
221 | __asm__ ("rdpr %%ver, %0" : "=r" (ver)); | |
ebd8c56c DM |
222 | is_jbus = ((ver >> 32UL) == __JALAPENO_ID || |
223 | (ver >> 32UL) == __SERRANO_ID); | |
d82ace7d | 224 | } |
92704a1c DM |
225 | |
226 | p = &__cpuid_patch; | |
227 | while (p < &__cpuid_patch_end) { | |
228 | unsigned long addr = p->addr; | |
229 | unsigned int *insns; | |
230 | ||
231 | switch (tlb_type) { | |
232 | case spitfire: | |
233 | insns = &p->starfire[0]; | |
234 | break; | |
235 | case cheetah: | |
236 | case cheetah_plus: | |
237 | if (is_jbus) | |
238 | insns = &p->cheetah_jbus[0]; | |
239 | else | |
240 | insns = &p->cheetah_safari[0]; | |
241 | break; | |
d96b8153 DM |
242 | case hypervisor: |
243 | insns = &p->sun4v[0]; | |
244 | break; | |
92704a1c DM |
245 | default: |
246 | prom_printf("Unknown cpu type, halting.\n"); | |
247 | prom_halt(); | |
248 | }; | |
249 | ||
250 | *(unsigned int *) (addr + 0) = insns[0]; | |
840aaef8 | 251 | wmb(); |
92704a1c DM |
252 | __asm__ __volatile__("flush %0" : : "r" (addr + 0)); |
253 | ||
254 | *(unsigned int *) (addr + 4) = insns[1]; | |
840aaef8 | 255 | wmb(); |
92704a1c DM |
256 | __asm__ __volatile__("flush %0" : : "r" (addr + 4)); |
257 | ||
258 | *(unsigned int *) (addr + 8) = insns[2]; | |
840aaef8 | 259 | wmb(); |
92704a1c DM |
260 | __asm__ __volatile__("flush %0" : : "r" (addr + 8)); |
261 | ||
262 | *(unsigned int *) (addr + 12) = insns[3]; | |
840aaef8 | 263 | wmb(); |
92704a1c DM |
264 | __asm__ __volatile__("flush %0" : : "r" (addr + 12)); |
265 | ||
266 | p++; | |
267 | } | |
92704a1c DM |
268 | } |
269 | ||
951bc82c | 270 | void __init sun4v_patch(void) |
936f482a | 271 | { |
c7754d46 | 272 | extern void sun4v_hvapi_init(void); |
df7d6aec DM |
273 | struct sun4v_1insn_patch_entry *p1; |
274 | struct sun4v_2insn_patch_entry *p2; | |
936f482a DM |
275 | |
276 | if (tlb_type != hypervisor) | |
277 | return; | |
278 | ||
df7d6aec DM |
279 | p1 = &__sun4v_1insn_patch; |
280 | while (p1 < &__sun4v_1insn_patch_end) { | |
45fec05f | 281 | unsigned long addr = p1->addr; |
936f482a | 282 | |
45fec05f | 283 | *(unsigned int *) (addr + 0) = p1->insn; |
840aaef8 | 284 | wmb(); |
936f482a DM |
285 | __asm__ __volatile__("flush %0" : : "r" (addr + 0)); |
286 | ||
45fec05f DM |
287 | p1++; |
288 | } | |
289 | ||
df7d6aec DM |
290 | p2 = &__sun4v_2insn_patch; |
291 | while (p2 < &__sun4v_2insn_patch_end) { | |
45fec05f DM |
292 | unsigned long addr = p2->addr; |
293 | ||
294 | *(unsigned int *) (addr + 0) = p2->insns[0]; | |
840aaef8 | 295 | wmb(); |
45fec05f DM |
296 | __asm__ __volatile__("flush %0" : : "r" (addr + 0)); |
297 | ||
fd05068d | 298 | *(unsigned int *) (addr + 4) = p2->insns[1]; |
840aaef8 | 299 | wmb(); |
45fec05f DM |
300 | __asm__ __volatile__("flush %0" : : "r" (addr + 4)); |
301 | ||
302 | p2++; | |
936f482a | 303 | } |
c7754d46 DM |
304 | |
305 | sun4v_hvapi_init(); | |
936f482a DM |
306 | } |
307 | ||
951bc82c DM |
308 | #ifdef CONFIG_SMP |
309 | void __init boot_cpu_id_too_large(int cpu) | |
310 | { | |
311 | prom_printf("Serious problem, boot cpu id (%d) >= NR_CPUS (%d)\n", | |
312 | cpu, NR_CPUS); | |
313 | prom_halt(); | |
314 | } | |
315 | #endif | |
316 | ||
1da177e4 LT |
317 | void __init setup_arch(char **cmdline_p) |
318 | { | |
1da177e4 LT |
319 | /* Initialize PROM console and command line. */ |
320 | *cmdline_p = prom_getbootargs(); | |
383464c0 | 321 | strcpy(boot_command_line, *cmdline_p); |
1da177e4 | 322 | |
3a8c069d DM |
323 | if (tlb_type == hypervisor) |
324 | printk("ARCH: SUN4V\n"); | |
325 | else | |
326 | printk("ARCH: SUN4U\n"); | |
1da177e4 LT |
327 | |
328 | #ifdef CONFIG_DUMMY_CONSOLE | |
329 | conswitchp = &dummy_con; | |
330 | #elif defined(CONFIG_PROM_CONSOLE) | |
331 | conswitchp = &prom_con; | |
332 | #endif | |
333 | ||
1da177e4 LT |
334 | boot_flags_init(*cmdline_p); |
335 | ||
336 | idprom_init(); | |
1da177e4 LT |
337 | |
338 | if (!root_flags) | |
339 | root_mountflags &= ~MS_RDONLY; | |
340 | ROOT_DEV = old_decode_dev(root_dev); | |
467418f3 | 341 | #ifdef CONFIG_BLK_DEV_RAM |
1da177e4 LT |
342 | rd_image_start = ram_flags & RAMDISK_IMAGE_START_MASK; |
343 | rd_prompt = ((ram_flags & RAMDISK_PROMPT_FLAG) != 0); | |
344 | rd_doload = ((ram_flags & RAMDISK_LOAD_FLAG) != 0); | |
345 | #endif | |
346 | ||
f3169641 | 347 | task_thread_info(&init_task)->kregs = &fake_swapper_regs; |
1da177e4 LT |
348 | |
349 | #ifdef CONFIG_IP_PNP | |
350 | if (!ic_set_manually) { | |
351 | int chosen = prom_finddevice ("/chosen"); | |
352 | u32 cl, sv, gw; | |
353 | ||
354 | cl = prom_getintdefault (chosen, "client-ip", 0); | |
355 | sv = prom_getintdefault (chosen, "server-ip", 0); | |
356 | gw = prom_getintdefault (chosen, "gateway-ip", 0); | |
357 | if (cl && sv) { | |
358 | ic_myaddr = cl; | |
359 | ic_servaddr = sv; | |
360 | if (gw) | |
361 | ic_gateway = gw; | |
362 | #if defined(CONFIG_IP_PNP_BOOTP) || defined(CONFIG_IP_PNP_RARP) | |
363 | ic_proto_enabled = 0; | |
364 | #endif | |
365 | } | |
366 | } | |
367 | #endif | |
368 | ||
56fb4df6 | 369 | /* Get boot processor trap_block[] setup. */ |
72aff53f | 370 | init_cur_cpu_trap(current_thread_info()); |
52845cdb DM |
371 | |
372 | paging_init(); | |
765b5f32 DM |
373 | |
374 | smp_setup_cpu_possible_map(); | |
1da177e4 LT |
375 | } |
376 | ||
377 | static int __init set_preferred_console(void) | |
378 | { | |
379 | int idev, odev; | |
380 | ||
381 | /* The user has requested a console so this is already set up. */ | |
382 | if (serial_console >= 0) | |
383 | return -EBUSY; | |
384 | ||
385 | idev = prom_query_input_device(); | |
386 | odev = prom_query_output_device(); | |
387 | if (idev == PROMDEV_IKBD && odev == PROMDEV_OSCREEN) { | |
388 | serial_console = 0; | |
389 | } else if (idev == PROMDEV_ITTYA && odev == PROMDEV_OTTYA) { | |
390 | serial_console = 1; | |
391 | } else if (idev == PROMDEV_ITTYB && odev == PROMDEV_OTTYB) { | |
392 | serial_console = 2; | |
c126cf80 ED |
393 | } else if (idev == PROMDEV_IRSC && odev == PROMDEV_ORSC) { |
394 | serial_console = 3; | |
1a7a242c DM |
395 | } else if (idev == PROMDEV_IVCONS && odev == PROMDEV_OVCONS) { |
396 | /* sunhv_console_init() doesn't check the serial_console | |
397 | * value anyways... | |
398 | */ | |
399 | serial_console = 4; | |
d5a2aa24 | 400 | return add_preferred_console("ttyHV", 0, NULL); |
1da177e4 LT |
401 | } else { |
402 | prom_printf("Inconsistent console: " | |
403 | "input %d, output %d\n", | |
404 | idev, odev); | |
405 | prom_halt(); | |
406 | } | |
407 | ||
408 | if (serial_console) | |
409 | return add_preferred_console("ttyS", serial_console - 1, NULL); | |
410 | ||
411 | return -ENODEV; | |
412 | } | |
413 | console_initcall(set_preferred_console); | |
414 | ||
415 | /* BUFFER is PAGE_SIZE bytes long. */ | |
416 | ||
417 | extern char *sparc_cpu_type; | |
418 | extern char *sparc_fpu_type; | |
419 | ||
420 | extern void smp_info(struct seq_file *); | |
421 | extern void smp_bogo(struct seq_file *); | |
422 | extern void mmu_info(struct seq_file *); | |
423 | ||
80dc0d6b DM |
424 | unsigned int dcache_parity_tl1_occurred; |
425 | unsigned int icache_parity_tl1_occurred; | |
426 | ||
4d45cbac DM |
427 | static int ncpus_probed; |
428 | ||
1da177e4 LT |
429 | static int show_cpuinfo(struct seq_file *m, void *__unused) |
430 | { | |
431 | seq_printf(m, | |
432 | "cpu\t\t: %s\n" | |
433 | "fpu\t\t: %s\n" | |
90a6646b DM |
434 | "prom\t\t: %s\n" |
435 | "type\t\t: %s\n" | |
4d45cbac DM |
436 | "ncpus probed\t: %d\n" |
437 | "ncpus active\t: %d\n" | |
80dc0d6b DM |
438 | "D$ parity tl1\t: %u\n" |
439 | "I$ parity tl1\t: %u\n" | |
1da177e4 LT |
440 | #ifndef CONFIG_SMP |
441 | "Cpu0Bogo\t: %lu.%02lu\n" | |
442 | "Cpu0ClkTck\t: %016lx\n" | |
443 | #endif | |
444 | , | |
445 | sparc_cpu_type, | |
446 | sparc_fpu_type, | |
90a6646b DM |
447 | prom_version, |
448 | ((tlb_type == hypervisor) ? | |
449 | "sun4v" : | |
450 | "sun4u"), | |
4d45cbac DM |
451 | ncpus_probed, |
452 | num_online_cpus(), | |
80dc0d6b DM |
453 | dcache_parity_tl1_occurred, |
454 | icache_parity_tl1_occurred | |
1da177e4 LT |
455 | #ifndef CONFIG_SMP |
456 | , cpu_data(0).udelay_val/(500000/HZ), | |
457 | (cpu_data(0).udelay_val/(5000/HZ)) % 100, | |
458 | cpu_data(0).clock_tick | |
459 | #endif | |
460 | ); | |
461 | #ifdef CONFIG_SMP | |
462 | smp_bogo(m); | |
463 | #endif | |
464 | mmu_info(m); | |
465 | #ifdef CONFIG_SMP | |
466 | smp_info(m); | |
467 | #endif | |
468 | return 0; | |
469 | } | |
470 | ||
471 | static void *c_start(struct seq_file *m, loff_t *pos) | |
472 | { | |
473 | /* The pointer we are returning is arbitrary, | |
474 | * it just has to be non-NULL and not IS_ERR | |
475 | * in the success case. | |
476 | */ | |
477 | return *pos == 0 ? &c_start : NULL; | |
478 | } | |
479 | ||
480 | static void *c_next(struct seq_file *m, void *v, loff_t *pos) | |
481 | { | |
482 | ++*pos; | |
483 | return c_start(m, pos); | |
484 | } | |
485 | ||
486 | static void c_stop(struct seq_file *m, void *v) | |
487 | { | |
488 | } | |
489 | ||
490 | struct seq_operations cpuinfo_op = { | |
491 | .start =c_start, | |
492 | .next = c_next, | |
493 | .stop = c_stop, | |
494 | .show = show_cpuinfo, | |
495 | }; | |
496 | ||
497 | extern int stop_a_enabled; | |
498 | ||
499 | void sun_do_break(void) | |
500 | { | |
501 | if (!stop_a_enabled) | |
502 | return; | |
503 | ||
504 | prom_printf("\n"); | |
505 | flush_user_windows(); | |
506 | ||
507 | prom_cmdline(); | |
508 | } | |
509 | ||
510 | int serial_console = -1; | |
511 | int stop_a_enabled = 1; | |
512 | ||
513 | static int __init topology_init(void) | |
514 | { | |
515 | int i, err; | |
516 | ||
517 | err = -ENOMEM; | |
4d45cbac DM |
518 | |
519 | /* Count the number of physically present processors in | |
520 | * the machine, even on uniprocessor, so that /proc/cpuinfo | |
521 | * output is consistent with 2.4.x | |
522 | */ | |
523 | ncpus_probed = 0; | |
524 | while (!cpu_find_by_instance(ncpus_probed, NULL, NULL)) | |
525 | ncpus_probed++; | |
526 | ||
a283a525 | 527 | for_each_possible_cpu(i) { |
9132983a ES |
528 | struct cpu *p = kzalloc(sizeof(*p), GFP_KERNEL); |
529 | if (p) { | |
76b67ed9 | 530 | register_cpu(p, i); |
9132983a | 531 | err = 0; |
1da177e4 LT |
532 | } |
533 | } | |
534 | ||
535 | return err; | |
536 | } | |
537 | ||
538 | subsys_initcall(topology_init); |