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)
8 #include <linux/errno.h>
9 #include <linux/sched.h>
10 #include <linux/kernel.h>
12 #include <linux/stddef.h>
13 #include <linux/unistd.h>
14 #include <linux/ptrace.h>
15 #include <linux/slab.h>
17 #include <linux/user.h>
18 #include <linux/a.out.h>
19 #include <linux/screen_info.h>
20 #include <linux/delay.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>
35 #include <asm/system.h>
37 #include <asm/processor.h>
38 #include <asm/oplib.h>
40 #include <asm/pgtable.h>
41 #include <asm/idprom.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>
51 #include <net/ipconfig.h>
54 struct screen_info screen_info
= {
55 0, 0, /* orig-x, orig-y */
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 */
66 void (*prom_palette
)(int);
67 void (*prom_keyboard
)(void);
70 prom_console_write(struct console
*con
, const char *s
, unsigned n
)
75 unsigned int boot_flags
= 0;
76 #define BOOTME_DEBUG 0x1
77 #define BOOTME_SINGLE 0x2
79 /* Exported for mm/init.c:paging_init. */
80 unsigned long cmdline_memory_size
= 0;
82 static struct console prom_debug_console
= {
84 .write
= prom_console_write
,
85 .flags
= CON_PRINTBUFFER
,
89 /* XXX Implement this at some point... */
90 void kernel_enter_debugger(void)
94 int obp_system_intr(void)
96 if (boot_flags
& BOOTME_DEBUG
) {
97 printk("OBP: system interrupted\n");
105 * Process kernel command line switches that are specific to the
106 * SPARC or that require special low-level processing.
108 static void __init
process_switch(char c
)
112 boot_flags
|= BOOTME_DEBUG
;
115 boot_flags
|= BOOTME_SINGLE
;
118 prom_printf("boot_flags_init: Halt!\n");
122 /* Use PROM debug console. */
123 register_console(&prom_debug_console
);
126 /* Force UltraSPARC-III P-Cache on. */
127 if (tlb_type
!= cheetah
) {
128 printk("BOOT: Ignoring P-Cache force option.\n");
131 cheetah_pcache_forced_on
= 1;
132 add_taint(TAINT_MACHINE_CHECK
);
133 cheetah_enable_pcache();
137 printk("Unknown boot switch (-%c)\n", c
);
142 static void __init
process_console(char *commands
)
146 /* Linux-style serial */
147 if (!strncmp(commands
, "ttyS", 4))
148 serial_console
= simple_strtoul(commands
+ 4, NULL
, 10) + 1;
149 else if (!strncmp(commands
, "tty", 3)) {
150 char c
= *(commands
+ 3);
151 /* Solaris-style serial */
152 if (c
== 'a' || c
== 'b') {
153 serial_console
= c
- 'a' + 1;
154 prom_printf ("Using /dev/tty%c as console.\n", c
);
156 /* else Linux-style fbcon, not serial */
158 #if defined(CONFIG_PROM_CONSOLE)
159 if (!strncmp(commands
, "prom", 4)) {
162 for (p
= commands
- 8; *p
&& *p
!= ' '; p
++)
164 conswitchp
= &prom_con
;
169 static void __init
boot_flags_init(char *commands
)
172 /* Move to the start of the next "argument". */
173 while (*commands
&& *commands
== ' ')
176 /* Process any command switches, otherwise skip it. */
177 if (*commands
== '\0')
179 if (*commands
== '-') {
181 while (*commands
&& *commands
!= ' ')
182 process_switch(*commands
++);
185 if (!strncmp(commands
, "console=", 8)) {
186 process_console(commands
);
187 } else if (!strncmp(commands
, "mem=", 4)) {
189 * "mem=XXX[kKmM]" overrides the PROM-reported
192 cmdline_memory_size
= simple_strtoul(commands
+ 4,
194 if (*commands
== 'K' || *commands
== 'k') {
195 cmdline_memory_size
<<= 10;
197 } else if (*commands
=='M' || *commands
=='m') {
198 cmdline_memory_size
<<= 20;
202 while (*commands
&& *commands
!= ' ')
207 extern void panic_setup(char *, int *);
209 extern unsigned short root_flags
;
210 extern unsigned short root_dev
;
211 extern unsigned short ram_flags
;
212 #define RAMDISK_IMAGE_START_MASK 0x07FF
213 #define RAMDISK_PROMPT_FLAG 0x8000
214 #define RAMDISK_LOAD_FLAG 0x4000
216 extern int root_mountflags
;
218 char reboot_command
[COMMAND_LINE_SIZE
];
220 static struct pt_regs fake_swapper_regs
= { { 0, }, 0, 0, 0, 0 };
222 void __init
per_cpu_patch(void)
224 struct cpuid_patch_entry
*p
;
228 if (tlb_type
== spitfire
&& !this_is_starfire
)
232 if (tlb_type
!= hypervisor
) {
233 __asm__ ("rdpr %%ver, %0" : "=r" (ver
));
234 is_jbus
= ((ver
>> 32UL) == __JALAPENO_ID
||
235 (ver
>> 32UL) == __SERRANO_ID
);
239 while (p
< &__cpuid_patch_end
) {
240 unsigned long addr
= p
->addr
;
245 insns
= &p
->starfire
[0];
250 insns
= &p
->cheetah_jbus
[0];
252 insns
= &p
->cheetah_safari
[0];
255 insns
= &p
->sun4v
[0];
258 prom_printf("Unknown cpu type, halting.\n");
262 *(unsigned int *) (addr
+ 0) = insns
[0];
264 __asm__
__volatile__("flush %0" : : "r" (addr
+ 0));
266 *(unsigned int *) (addr
+ 4) = insns
[1];
268 __asm__
__volatile__("flush %0" : : "r" (addr
+ 4));
270 *(unsigned int *) (addr
+ 8) = insns
[2];
272 __asm__
__volatile__("flush %0" : : "r" (addr
+ 8));
274 *(unsigned int *) (addr
+ 12) = insns
[3];
276 __asm__
__volatile__("flush %0" : : "r" (addr
+ 12));
282 void __init
sun4v_patch(void)
284 struct sun4v_1insn_patch_entry
*p1
;
285 struct sun4v_2insn_patch_entry
*p2
;
287 if (tlb_type
!= hypervisor
)
290 p1
= &__sun4v_1insn_patch
;
291 while (p1
< &__sun4v_1insn_patch_end
) {
292 unsigned long addr
= p1
->addr
;
294 *(unsigned int *) (addr
+ 0) = p1
->insn
;
296 __asm__
__volatile__("flush %0" : : "r" (addr
+ 0));
301 p2
= &__sun4v_2insn_patch
;
302 while (p2
< &__sun4v_2insn_patch_end
) {
303 unsigned long addr
= p2
->addr
;
305 *(unsigned int *) (addr
+ 0) = p2
->insns
[0];
307 __asm__
__volatile__("flush %0" : : "r" (addr
+ 0));
309 *(unsigned int *) (addr
+ 4) = p2
->insns
[1];
311 __asm__
__volatile__("flush %0" : : "r" (addr
+ 4));
318 void __init
boot_cpu_id_too_large(int cpu
)
320 prom_printf("Serious problem, boot cpu id (%d) >= NR_CPUS (%d)\n",
326 void __init
setup_arch(char **cmdline_p
)
328 /* Initialize PROM console and command line. */
329 *cmdline_p
= prom_getbootargs();
330 strcpy(saved_command_line
, *cmdline_p
);
332 if (tlb_type
== hypervisor
)
333 printk("ARCH: SUN4V\n");
335 printk("ARCH: SUN4U\n");
337 #ifdef CONFIG_DUMMY_CONSOLE
338 conswitchp
= &dummy_con
;
339 #elif defined(CONFIG_PROM_CONSOLE)
340 conswitchp
= &prom_con
;
343 boot_flags_init(*cmdline_p
);
348 root_mountflags
&= ~MS_RDONLY
;
349 ROOT_DEV
= old_decode_dev(root_dev
);
350 #ifdef CONFIG_BLK_DEV_RAM
351 rd_image_start
= ram_flags
& RAMDISK_IMAGE_START_MASK
;
352 rd_prompt
= ((ram_flags
& RAMDISK_PROMPT_FLAG
) != 0);
353 rd_doload
= ((ram_flags
& RAMDISK_LOAD_FLAG
) != 0);
356 task_thread_info(&init_task
)->kregs
= &fake_swapper_regs
;
359 if (!ic_set_manually
) {
360 int chosen
= prom_finddevice ("/chosen");
363 cl
= prom_getintdefault (chosen
, "client-ip", 0);
364 sv
= prom_getintdefault (chosen
, "server-ip", 0);
365 gw
= prom_getintdefault (chosen
, "gateway-ip", 0);
371 #if defined(CONFIG_IP_PNP_BOOTP) || defined(CONFIG_IP_PNP_RARP)
372 ic_proto_enabled
= 0;
378 /* Get boot processor trap_block[] setup. */
379 init_cur_cpu_trap(current_thread_info());
383 smp_setup_cpu_possible_map();
386 static int __init
set_preferred_console(void)
390 /* The user has requested a console so this is already set up. */
391 if (serial_console
>= 0)
394 idev
= prom_query_input_device();
395 odev
= prom_query_output_device();
396 if (idev
== PROMDEV_IKBD
&& odev
== PROMDEV_OSCREEN
) {
398 } else if (idev
== PROMDEV_ITTYA
&& odev
== PROMDEV_OTTYA
) {
400 } else if (idev
== PROMDEV_ITTYB
&& odev
== PROMDEV_OTTYB
) {
402 } else if (idev
== PROMDEV_IRSC
&& odev
== PROMDEV_ORSC
) {
404 } else if (idev
== PROMDEV_IVCONS
&& odev
== PROMDEV_OVCONS
) {
405 /* sunhv_console_init() doesn't check the serial_console
409 return add_preferred_console("ttyHV", 0, NULL
);
411 prom_printf("Inconsistent console: "
412 "input %d, output %d\n",
418 return add_preferred_console("ttyS", serial_console
- 1, NULL
);
422 console_initcall(set_preferred_console
);
424 /* BUFFER is PAGE_SIZE bytes long. */
426 extern char *sparc_cpu_type
;
427 extern char *sparc_fpu_type
;
429 extern void smp_info(struct seq_file
*);
430 extern void smp_bogo(struct seq_file
*);
431 extern void mmu_info(struct seq_file
*);
433 unsigned int dcache_parity_tl1_occurred
;
434 unsigned int icache_parity_tl1_occurred
;
436 static int ncpus_probed
;
438 static int show_cpuinfo(struct seq_file
*m
, void *__unused
)
445 "ncpus probed\t: %d\n"
446 "ncpus active\t: %d\n"
447 "D$ parity tl1\t: %u\n"
448 "I$ parity tl1\t: %u\n"
450 "Cpu0Bogo\t: %lu.%02lu\n"
451 "Cpu0ClkTck\t: %016lx\n"
457 ((tlb_type
== hypervisor
) ?
462 dcache_parity_tl1_occurred
,
463 icache_parity_tl1_occurred
465 , cpu_data(0).udelay_val
/(500000/HZ
),
466 (cpu_data(0).udelay_val
/(5000/HZ
)) % 100,
467 cpu_data(0).clock_tick
480 static void *c_start(struct seq_file
*m
, loff_t
*pos
)
482 /* The pointer we are returning is arbitrary,
483 * it just has to be non-NULL and not IS_ERR
484 * in the success case.
486 return *pos
== 0 ? &c_start
: NULL
;
489 static void *c_next(struct seq_file
*m
, void *v
, loff_t
*pos
)
492 return c_start(m
, pos
);
495 static void c_stop(struct seq_file
*m
, void *v
)
499 struct seq_operations cpuinfo_op
= {
503 .show
= show_cpuinfo
,
506 extern int stop_a_enabled
;
508 void sun_do_break(void)
514 flush_user_windows();
519 int serial_console
= -1;
520 int stop_a_enabled
= 1;
522 static int __init
topology_init(void)
528 /* Count the number of physically present processors in
529 * the machine, even on uniprocessor, so that /proc/cpuinfo
530 * output is consistent with 2.4.x
533 while (!cpu_find_by_instance(ncpus_probed
, NULL
, NULL
))
536 for_each_possible_cpu(i
) {
537 struct cpu
*p
= kzalloc(sizeof(*p
), GFP_KERNEL
);
547 subsys_initcall(topology_init
);