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>
49 #include <asm/ns87303.h>
52 #include <net/ipconfig.h>
55 /* Used to synchronize accesses to NatSemi SUPER I/O chip configure
56 * operations in asm/ns87303.h
58 DEFINE_SPINLOCK(ns87303_lock
);
60 struct screen_info screen_info
= {
61 0, 0, /* orig-x, orig-y */
63 0, /* orig-video-page */
64 0, /* orig-video-mode */
65 128, /* orig-video-cols */
66 0, 0, 0, /* unused, ega_bx, unused */
67 54, /* orig-video-lines */
68 0, /* orig-video-isVGA */
69 16 /* orig-video-points */
72 void (*prom_palette
)(int);
73 void (*prom_keyboard
)(void);
76 prom_console_write(struct console
*con
, const char *s
, unsigned n
)
81 unsigned int boot_flags
= 0;
82 #define BOOTME_DEBUG 0x1
84 /* Exported for mm/init.c:paging_init. */
85 unsigned long cmdline_memory_size
= 0;
87 static struct console prom_debug_console
= {
89 .write
= prom_console_write
,
90 .flags
= CON_PRINTBUFFER
,
94 /* XXX Implement this at some point... */
95 void kernel_enter_debugger(void)
100 * Process kernel command line switches that are specific to the
101 * SPARC or that require special low-level processing.
103 static void __init
process_switch(char c
)
107 boot_flags
|= BOOTME_DEBUG
;
112 prom_printf("boot_flags_init: Halt!\n");
116 /* Use PROM debug console. */
117 register_console(&prom_debug_console
);
120 /* Force UltraSPARC-III P-Cache on. */
121 if (tlb_type
!= cheetah
) {
122 printk("BOOT: Ignoring P-Cache force option.\n");
125 cheetah_pcache_forced_on
= 1;
126 add_taint(TAINT_MACHINE_CHECK
);
127 cheetah_enable_pcache();
131 printk("Unknown boot switch (-%c)\n", c
);
136 static void __init
process_console(char *commands
)
140 /* Linux-style serial */
141 if (!strncmp(commands
, "ttyS", 4))
142 serial_console
= simple_strtoul(commands
+ 4, NULL
, 10) + 1;
143 else if (!strncmp(commands
, "tty", 3)) {
144 char c
= *(commands
+ 3);
145 /* Solaris-style serial */
146 if (c
== 'a' || c
== 'b') {
147 serial_console
= c
- 'a' + 1;
148 prom_printf ("Using /dev/tty%c as console.\n", c
);
150 /* else Linux-style fbcon, not serial */
152 #if defined(CONFIG_PROM_CONSOLE)
153 if (!strncmp(commands
, "prom", 4)) {
156 for (p
= commands
- 8; *p
&& *p
!= ' '; p
++)
158 conswitchp
= &prom_con
;
163 static void __init
boot_flags_init(char *commands
)
166 /* Move to the start of the next "argument". */
167 while (*commands
&& *commands
== ' ')
170 /* Process any command switches, otherwise skip it. */
171 if (*commands
== '\0')
173 if (*commands
== '-') {
175 while (*commands
&& *commands
!= ' ')
176 process_switch(*commands
++);
179 if (!strncmp(commands
, "console=", 8)) {
180 process_console(commands
);
181 } else if (!strncmp(commands
, "mem=", 4)) {
183 * "mem=XXX[kKmM]" overrides the PROM-reported
186 cmdline_memory_size
= simple_strtoul(commands
+ 4,
188 if (*commands
== 'K' || *commands
== 'k') {
189 cmdline_memory_size
<<= 10;
191 } else if (*commands
=='M' || *commands
=='m') {
192 cmdline_memory_size
<<= 20;
196 while (*commands
&& *commands
!= ' ')
201 extern void panic_setup(char *, int *);
203 extern unsigned short root_flags
;
204 extern unsigned short root_dev
;
205 extern unsigned short ram_flags
;
206 #define RAMDISK_IMAGE_START_MASK 0x07FF
207 #define RAMDISK_PROMPT_FLAG 0x8000
208 #define RAMDISK_LOAD_FLAG 0x4000
210 extern int root_mountflags
;
212 char reboot_command
[COMMAND_LINE_SIZE
];
214 static struct pt_regs fake_swapper_regs
= { { 0, }, 0, 0, 0, 0 };
216 void __init
per_cpu_patch(void)
218 struct cpuid_patch_entry
*p
;
222 if (tlb_type
== spitfire
&& !this_is_starfire
)
226 if (tlb_type
!= hypervisor
) {
227 __asm__ ("rdpr %%ver, %0" : "=r" (ver
));
228 is_jbus
= ((ver
>> 32UL) == __JALAPENO_ID
||
229 (ver
>> 32UL) == __SERRANO_ID
);
233 while (p
< &__cpuid_patch_end
) {
234 unsigned long addr
= p
->addr
;
239 insns
= &p
->starfire
[0];
244 insns
= &p
->cheetah_jbus
[0];
246 insns
= &p
->cheetah_safari
[0];
249 insns
= &p
->sun4v
[0];
252 prom_printf("Unknown cpu type, halting.\n");
256 *(unsigned int *) (addr
+ 0) = insns
[0];
258 __asm__
__volatile__("flush %0" : : "r" (addr
+ 0));
260 *(unsigned int *) (addr
+ 4) = insns
[1];
262 __asm__
__volatile__("flush %0" : : "r" (addr
+ 4));
264 *(unsigned int *) (addr
+ 8) = insns
[2];
266 __asm__
__volatile__("flush %0" : : "r" (addr
+ 8));
268 *(unsigned int *) (addr
+ 12) = insns
[3];
270 __asm__
__volatile__("flush %0" : : "r" (addr
+ 12));
276 void __init
sun4v_patch(void)
278 extern void sun4v_hvapi_init(void);
279 struct sun4v_1insn_patch_entry
*p1
;
280 struct sun4v_2insn_patch_entry
*p2
;
282 if (tlb_type
!= hypervisor
)
285 p1
= &__sun4v_1insn_patch
;
286 while (p1
< &__sun4v_1insn_patch_end
) {
287 unsigned long addr
= p1
->addr
;
289 *(unsigned int *) (addr
+ 0) = p1
->insn
;
291 __asm__
__volatile__("flush %0" : : "r" (addr
+ 0));
296 p2
= &__sun4v_2insn_patch
;
297 while (p2
< &__sun4v_2insn_patch_end
) {
298 unsigned long addr
= p2
->addr
;
300 *(unsigned int *) (addr
+ 0) = p2
->insns
[0];
302 __asm__
__volatile__("flush %0" : : "r" (addr
+ 0));
304 *(unsigned int *) (addr
+ 4) = p2
->insns
[1];
306 __asm__
__volatile__("flush %0" : : "r" (addr
+ 4));
315 void __init
boot_cpu_id_too_large(int cpu
)
317 prom_printf("Serious problem, boot cpu id (%d) >= NR_CPUS (%d)\n",
323 void __init
setup_arch(char **cmdline_p
)
325 /* Initialize PROM console and command line. */
326 *cmdline_p
= prom_getbootargs();
327 strcpy(boot_command_line
, *cmdline_p
);
329 if (tlb_type
== hypervisor
)
330 printk("ARCH: SUN4V\n");
332 printk("ARCH: SUN4U\n");
334 #ifdef CONFIG_DUMMY_CONSOLE
335 conswitchp
= &dummy_con
;
336 #elif defined(CONFIG_PROM_CONSOLE)
337 conswitchp
= &prom_con
;
340 boot_flags_init(*cmdline_p
);
345 root_mountflags
&= ~MS_RDONLY
;
346 ROOT_DEV
= old_decode_dev(root_dev
);
347 #ifdef CONFIG_BLK_DEV_RAM
348 rd_image_start
= ram_flags
& RAMDISK_IMAGE_START_MASK
;
349 rd_prompt
= ((ram_flags
& RAMDISK_PROMPT_FLAG
) != 0);
350 rd_doload
= ((ram_flags
& RAMDISK_LOAD_FLAG
) != 0);
353 task_thread_info(&init_task
)->kregs
= &fake_swapper_regs
;
356 if (!ic_set_manually
) {
357 int chosen
= prom_finddevice ("/chosen");
360 cl
= prom_getintdefault (chosen
, "client-ip", 0);
361 sv
= prom_getintdefault (chosen
, "server-ip", 0);
362 gw
= prom_getintdefault (chosen
, "gateway-ip", 0);
368 #if defined(CONFIG_IP_PNP_BOOTP) || defined(CONFIG_IP_PNP_RARP)
369 ic_proto_enabled
= 0;
375 /* Get boot processor trap_block[] setup. */
376 init_cur_cpu_trap(current_thread_info());
381 static int __init
set_preferred_console(void)
385 /* The user has requested a console so this is already set up. */
386 if (serial_console
>= 0)
389 idev
= prom_query_input_device();
390 odev
= prom_query_output_device();
391 if (idev
== PROMDEV_IKBD
&& odev
== PROMDEV_OSCREEN
) {
393 } else if (idev
== PROMDEV_ITTYA
&& odev
== PROMDEV_OTTYA
) {
395 } else if (idev
== PROMDEV_ITTYB
&& odev
== PROMDEV_OTTYB
) {
397 } else if (idev
== PROMDEV_IRSC
&& odev
== PROMDEV_ORSC
) {
399 } else if (idev
== PROMDEV_IVCONS
&& odev
== PROMDEV_OVCONS
) {
400 /* sunhv_console_init() doesn't check the serial_console
404 return add_preferred_console("ttyHV", 0, NULL
);
406 prom_printf("Inconsistent console: "
407 "input %d, output %d\n",
413 return add_preferred_console("ttyS", serial_console
- 1, NULL
);
417 console_initcall(set_preferred_console
);
419 /* BUFFER is PAGE_SIZE bytes long. */
421 extern char *sparc_cpu_type
;
422 extern char *sparc_fpu_type
;
424 extern void smp_info(struct seq_file
*);
425 extern void smp_bogo(struct seq_file
*);
426 extern void mmu_info(struct seq_file
*);
428 unsigned int dcache_parity_tl1_occurred
;
429 unsigned int icache_parity_tl1_occurred
;
433 static int show_cpuinfo(struct seq_file
*m
, void *__unused
)
440 "ncpus probed\t: %d\n"
441 "ncpus active\t: %d\n"
442 "D$ parity tl1\t: %u\n"
443 "I$ parity tl1\t: %u\n"
445 "Cpu0Bogo\t: %lu.%02lu\n"
446 "Cpu0ClkTck\t: %016lx\n"
452 ((tlb_type
== hypervisor
) ?
457 dcache_parity_tl1_occurred
,
458 icache_parity_tl1_occurred
460 , cpu_data(0).udelay_val
/(500000/HZ
),
461 (cpu_data(0).udelay_val
/(5000/HZ
)) % 100,
462 cpu_data(0).clock_tick
475 static void *c_start(struct seq_file
*m
, loff_t
*pos
)
477 /* The pointer we are returning is arbitrary,
478 * it just has to be non-NULL and not IS_ERR
479 * in the success case.
481 return *pos
== 0 ? &c_start
: NULL
;
484 static void *c_next(struct seq_file
*m
, void *v
, loff_t
*pos
)
487 return c_start(m
, pos
);
490 static void c_stop(struct seq_file
*m
, void *v
)
494 struct seq_operations cpuinfo_op
= {
498 .show
= show_cpuinfo
,
501 extern int stop_a_enabled
;
503 void sun_do_break(void)
509 flush_user_windows();
514 int serial_console
= -1;
515 int stop_a_enabled
= 1;