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/screen_info.h>
19 #include <linux/delay.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>
36 #include <asm/processor.h>
37 #include <asm/oplib.h>
39 #include <asm/pgtable.h>
40 #include <asm/idprom.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>
48 #include <asm/ns87303.h>
49 #include <asm/btext.h>
52 #include <net/ipconfig.h>
58 /* Used to synchronize accesses to NatSemi SUPER I/O chip configure
59 * operations in asm/ns87303.h
61 DEFINE_SPINLOCK(ns87303_lock
);
62 EXPORT_SYMBOL(ns87303_lock
);
64 struct screen_info screen_info
= {
65 0, 0, /* orig-x, orig-y */
67 0, /* orig-video-page */
68 0, /* orig-video-mode */
69 128, /* orig-video-cols */
70 0, 0, 0, /* unused, ega_bx, unused */
71 54, /* orig-video-lines */
72 0, /* orig-video-isVGA */
73 16 /* orig-video-points */
77 prom_console_write(struct console
*con
, const char *s
, unsigned n
)
82 /* Exported for mm/init.c:paging_init. */
83 unsigned long cmdline_memory_size
= 0;
85 static struct console prom_early_console
= {
87 .write
= prom_console_write
,
88 .flags
= CON_PRINTBUFFER
| CON_BOOT
| CON_ANYTIME
,
93 * Process kernel command line switches that are specific to the
94 * SPARC or that require special low-level processing.
96 static void __init
process_switch(char c
)
103 prom_printf("boot_flags_init: Halt!\n");
107 /* Just ignore, this behavior is now the default. */
110 /* Force UltraSPARC-III P-Cache on. */
111 if (tlb_type
!= cheetah
) {
112 printk("BOOT: Ignoring P-Cache force option.\n");
115 cheetah_pcache_forced_on
= 1;
116 add_taint(TAINT_MACHINE_CHECK
);
117 cheetah_enable_pcache();
121 printk("Unknown boot switch (-%c)\n", c
);
126 static void __init
boot_flags_init(char *commands
)
129 /* Move to the start of the next "argument". */
130 while (*commands
&& *commands
== ' ')
133 /* Process any command switches, otherwise skip it. */
134 if (*commands
== '\0')
136 if (*commands
== '-') {
138 while (*commands
&& *commands
!= ' ')
139 process_switch(*commands
++);
142 if (!strncmp(commands
, "mem=", 4)) {
144 * "mem=XXX[kKmM]" overrides the PROM-reported
147 cmdline_memory_size
= simple_strtoul(commands
+ 4,
149 if (*commands
== 'K' || *commands
== 'k') {
150 cmdline_memory_size
<<= 10;
152 } else if (*commands
=='M' || *commands
=='m') {
153 cmdline_memory_size
<<= 20;
157 while (*commands
&& *commands
!= ' ')
162 extern unsigned short root_flags
;
163 extern unsigned short root_dev
;
164 extern unsigned short ram_flags
;
165 #define RAMDISK_IMAGE_START_MASK 0x07FF
166 #define RAMDISK_PROMPT_FLAG 0x8000
167 #define RAMDISK_LOAD_FLAG 0x4000
169 extern int root_mountflags
;
171 char reboot_command
[COMMAND_LINE_SIZE
];
173 static struct pt_regs fake_swapper_regs
= { { 0, }, 0, 0, 0, 0 };
175 void __init
per_cpu_patch(void)
177 struct cpuid_patch_entry
*p
;
181 if (tlb_type
== spitfire
&& !this_is_starfire
)
185 if (tlb_type
!= hypervisor
) {
186 __asm__ ("rdpr %%ver, %0" : "=r" (ver
));
187 is_jbus
= ((ver
>> 32UL) == __JALAPENO_ID
||
188 (ver
>> 32UL) == __SERRANO_ID
);
192 while (p
< &__cpuid_patch_end
) {
193 unsigned long addr
= p
->addr
;
198 insns
= &p
->starfire
[0];
203 insns
= &p
->cheetah_jbus
[0];
205 insns
= &p
->cheetah_safari
[0];
208 insns
= &p
->sun4v
[0];
211 prom_printf("Unknown cpu type, halting.\n");
215 *(unsigned int *) (addr
+ 0) = insns
[0];
217 __asm__
__volatile__("flush %0" : : "r" (addr
+ 0));
219 *(unsigned int *) (addr
+ 4) = insns
[1];
221 __asm__
__volatile__("flush %0" : : "r" (addr
+ 4));
223 *(unsigned int *) (addr
+ 8) = insns
[2];
225 __asm__
__volatile__("flush %0" : : "r" (addr
+ 8));
227 *(unsigned int *) (addr
+ 12) = insns
[3];
229 __asm__
__volatile__("flush %0" : : "r" (addr
+ 12));
235 void __init
sun4v_patch(void)
237 extern void sun4v_hvapi_init(void);
238 struct sun4v_1insn_patch_entry
*p1
;
239 struct sun4v_2insn_patch_entry
*p2
;
241 if (tlb_type
!= hypervisor
)
244 p1
= &__sun4v_1insn_patch
;
245 while (p1
< &__sun4v_1insn_patch_end
) {
246 unsigned long addr
= p1
->addr
;
248 *(unsigned int *) (addr
+ 0) = p1
->insn
;
250 __asm__
__volatile__("flush %0" : : "r" (addr
+ 0));
255 p2
= &__sun4v_2insn_patch
;
256 while (p2
< &__sun4v_2insn_patch_end
) {
257 unsigned long addr
= p2
->addr
;
259 *(unsigned int *) (addr
+ 0) = p2
->insns
[0];
261 __asm__
__volatile__("flush %0" : : "r" (addr
+ 0));
263 *(unsigned int *) (addr
+ 4) = p2
->insns
[1];
265 __asm__
__volatile__("flush %0" : : "r" (addr
+ 4));
274 void __init
boot_cpu_id_too_large(int cpu
)
276 prom_printf("Serious problem, boot cpu id (%d) >= NR_CPUS (%d)\n",
282 void __init
setup_arch(char **cmdline_p
)
284 /* Initialize PROM console and command line. */
285 *cmdline_p
= prom_getbootargs();
286 strcpy(boot_command_line
, *cmdline_p
);
289 boot_flags_init(*cmdline_p
);
290 #ifdef CONFIG_EARLYFB
291 if (btext_find_display())
293 register_console(&prom_early_console
);
295 if (tlb_type
== hypervisor
)
296 printk("ARCH: SUN4V\n");
298 printk("ARCH: SUN4U\n");
300 #ifdef CONFIG_DUMMY_CONSOLE
301 conswitchp
= &dummy_con
;
307 root_mountflags
&= ~MS_RDONLY
;
308 ROOT_DEV
= old_decode_dev(root_dev
);
309 #ifdef CONFIG_BLK_DEV_RAM
310 rd_image_start
= ram_flags
& RAMDISK_IMAGE_START_MASK
;
311 rd_prompt
= ((ram_flags
& RAMDISK_PROMPT_FLAG
) != 0);
312 rd_doload
= ((ram_flags
& RAMDISK_LOAD_FLAG
) != 0);
315 task_thread_info(&init_task
)->kregs
= &fake_swapper_regs
;
318 if (!ic_set_manually
) {
319 int chosen
= prom_finddevice ("/chosen");
322 cl
= prom_getintdefault (chosen
, "client-ip", 0);
323 sv
= prom_getintdefault (chosen
, "server-ip", 0);
324 gw
= prom_getintdefault (chosen
, "gateway-ip", 0);
330 #if defined(CONFIG_IP_PNP_BOOTP) || defined(CONFIG_IP_PNP_RARP)
331 ic_proto_enabled
= 0;
337 /* Get boot processor trap_block[] setup. */
338 init_cur_cpu_trap(current_thread_info());
343 /* BUFFER is PAGE_SIZE bytes long. */
345 extern void smp_info(struct seq_file
*);
346 extern void smp_bogo(struct seq_file
*);
347 extern void mmu_info(struct seq_file
*);
349 unsigned int dcache_parity_tl1_occurred
;
350 unsigned int icache_parity_tl1_occurred
;
354 static int show_cpuinfo(struct seq_file
*m
, void *__unused
)
362 "ncpus probed\t: %d\n"
363 "ncpus active\t: %d\n"
364 "D$ parity tl1\t: %u\n"
365 "I$ parity tl1\t: %u\n"
367 "Cpu0ClkTck\t: %016lx\n"
374 ((tlb_type
== hypervisor
) ?
379 dcache_parity_tl1_occurred
,
380 icache_parity_tl1_occurred
382 , cpu_data(0).clock_tick
395 static void *c_start(struct seq_file
*m
, loff_t
*pos
)
397 /* The pointer we are returning is arbitrary,
398 * it just has to be non-NULL and not IS_ERR
399 * in the success case.
401 return *pos
== 0 ? &c_start
: NULL
;
404 static void *c_next(struct seq_file
*m
, void *v
, loff_t
*pos
)
407 return c_start(m
, pos
);
410 static void c_stop(struct seq_file
*m
, void *v
)
414 const struct seq_operations cpuinfo_op
= {
418 .show
= show_cpuinfo
,
421 extern int stop_a_enabled
;
423 void sun_do_break(void)
429 flush_user_windows();
433 EXPORT_SYMBOL(sun_do_break
);
435 int stop_a_enabled
= 1;
436 EXPORT_SYMBOL(stop_a_enabled
);