GUI: Fix Tomato RAF theme for all builds. Compilation typo.
[tomato.git] / release / src-rt-6.x.4708 / linux / linux-2.6.36 / arch / sparc / kernel / setup_64.c
blob72b3a1929971bb1083167d70d82d882ae38910ef
1 /*
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 <asm/smp.h>
16 #include <linux/user.h>
17 #include <linux/screen_info.h>
18 #include <linux/delay.h>
19 #include <linux/fs.h>
20 #include <linux/seq_file.h>
21 #include <linux/syscalls.h>
22 #include <linux/kdev_t.h>
23 #include <linux/major.h>
24 #include <linux/string.h>
25 #include <linux/init.h>
26 #include <linux/inet.h>
27 #include <linux/console.h>
28 #include <linux/root_dev.h>
29 #include <linux/interrupt.h>
30 #include <linux/cpu.h>
31 #include <linux/initrd.h>
33 #include <asm/system.h>
34 #include <asm/io.h>
35 #include <asm/processor.h>
36 #include <asm/oplib.h>
37 #include <asm/page.h>
38 #include <asm/pgtable.h>
39 #include <asm/idprom.h>
40 #include <asm/head.h>
41 #include <asm/starfire.h>
42 #include <asm/mmu_context.h>
43 #include <asm/timer.h>
44 #include <asm/sections.h>
45 #include <asm/setup.h>
46 #include <asm/mmu.h>
47 #include <asm/ns87303.h>
48 #include <asm/btext.h>
50 #ifdef CONFIG_IP_PNP
51 #include <net/ipconfig.h>
52 #endif
54 #include "entry.h"
55 #include "kernel.h"
57 /* Used to synchronize accesses to NatSemi SUPER I/O chip configure
58 * operations in asm/ns87303.h
60 DEFINE_SPINLOCK(ns87303_lock);
61 EXPORT_SYMBOL(ns87303_lock);
63 struct screen_info screen_info = {
64 0, 0, /* orig-x, orig-y */
65 0, /* unused */
66 0, /* orig-video-page */
67 0, /* orig-video-mode */
68 128, /* orig-video-cols */
69 0, 0, 0, /* unused, ega_bx, unused */
70 54, /* orig-video-lines */
71 0, /* orig-video-isVGA */
72 16 /* orig-video-points */
75 static void
76 prom_console_write(struct console *con, const char *s, unsigned n)
78 prom_write(s, n);
81 /* Exported for mm/init.c:paging_init. */
82 unsigned long cmdline_memory_size = 0;
84 static struct console prom_early_console = {
85 .name = "earlyprom",
86 .write = prom_console_write,
87 .flags = CON_PRINTBUFFER | CON_BOOT | CON_ANYTIME,
88 .index = -1,
91 /*
92 * Process kernel command line switches that are specific to the
93 * SPARC or that require special low-level processing.
95 static void __init process_switch(char c)
97 switch (c) {
98 case 'd':
99 case 's':
100 break;
101 case 'h':
102 prom_printf("boot_flags_init: Halt!\n");
103 prom_halt();
104 break;
105 case 'p':
106 /* Just ignore, this behavior is now the default. */
107 break;
108 case 'P':
109 /* Force UltraSPARC-III P-Cache on. */
110 if (tlb_type != cheetah) {
111 printk("BOOT: Ignoring P-Cache force option.\n");
112 break;
114 cheetah_pcache_forced_on = 1;
115 add_taint(TAINT_MACHINE_CHECK);
116 cheetah_enable_pcache();
117 break;
119 default:
120 printk("Unknown boot switch (-%c)\n", c);
121 break;
125 static void __init boot_flags_init(char *commands)
127 while (*commands) {
128 /* Move to the start of the next "argument". */
129 while (*commands && *commands == ' ')
130 commands++;
132 /* Process any command switches, otherwise skip it. */
133 if (*commands == '\0')
134 break;
135 if (*commands == '-') {
136 commands++;
137 while (*commands && *commands != ' ')
138 process_switch(*commands++);
139 continue;
141 if (!strncmp(commands, "mem=", 4)) {
142 cmdline_memory_size = simple_strtoul(commands + 4,
143 &commands, 0);
144 if (*commands == 'K' || *commands == 'k') {
145 cmdline_memory_size <<= 10;
146 commands++;
147 } else if (*commands=='M' || *commands=='m') {
148 cmdline_memory_size <<= 20;
149 commands++;
152 while (*commands && *commands != ' ')
153 commands++;
157 extern unsigned short root_flags;
158 extern unsigned short root_dev;
159 extern unsigned short ram_flags;
160 #define RAMDISK_IMAGE_START_MASK 0x07FF
161 #define RAMDISK_PROMPT_FLAG 0x8000
162 #define RAMDISK_LOAD_FLAG 0x4000
164 extern int root_mountflags;
166 char reboot_command[COMMAND_LINE_SIZE];
168 static struct pt_regs fake_swapper_regs = { { 0, }, 0, 0, 0, 0 };
170 void __init per_cpu_patch(void)
172 struct cpuid_patch_entry *p;
173 unsigned long ver;
174 int is_jbus;
176 if (tlb_type == spitfire && !this_is_starfire)
177 return;
179 is_jbus = 0;
180 if (tlb_type != hypervisor) {
181 __asm__ ("rdpr %%ver, %0" : "=r" (ver));
182 is_jbus = ((ver >> 32UL) == __JALAPENO_ID ||
183 (ver >> 32UL) == __SERRANO_ID);
186 p = &__cpuid_patch;
187 while (p < &__cpuid_patch_end) {
188 unsigned long addr = p->addr;
189 unsigned int *insns;
191 switch (tlb_type) {
192 case spitfire:
193 insns = &p->starfire[0];
194 break;
195 case cheetah:
196 case cheetah_plus:
197 if (is_jbus)
198 insns = &p->cheetah_jbus[0];
199 else
200 insns = &p->cheetah_safari[0];
201 break;
202 case hypervisor:
203 insns = &p->sun4v[0];
204 break;
205 default:
206 prom_printf("Unknown cpu type, halting.\n");
207 prom_halt();
210 *(unsigned int *) (addr + 0) = insns[0];
211 wmb();
212 __asm__ __volatile__("flush %0" : : "r" (addr + 0));
214 *(unsigned int *) (addr + 4) = insns[1];
215 wmb();
216 __asm__ __volatile__("flush %0" : : "r" (addr + 4));
218 *(unsigned int *) (addr + 8) = insns[2];
219 wmb();
220 __asm__ __volatile__("flush %0" : : "r" (addr + 8));
222 *(unsigned int *) (addr + 12) = insns[3];
223 wmb();
224 __asm__ __volatile__("flush %0" : : "r" (addr + 12));
226 p++;
230 void __init sun4v_patch(void)
232 extern void sun4v_hvapi_init(void);
233 struct sun4v_1insn_patch_entry *p1;
234 struct sun4v_2insn_patch_entry *p2;
236 if (tlb_type != hypervisor)
237 return;
239 p1 = &__sun4v_1insn_patch;
240 while (p1 < &__sun4v_1insn_patch_end) {
241 unsigned long addr = p1->addr;
243 *(unsigned int *) (addr + 0) = p1->insn;
244 wmb();
245 __asm__ __volatile__("flush %0" : : "r" (addr + 0));
247 p1++;
250 p2 = &__sun4v_2insn_patch;
251 while (p2 < &__sun4v_2insn_patch_end) {
252 unsigned long addr = p2->addr;
254 *(unsigned int *) (addr + 0) = p2->insns[0];
255 wmb();
256 __asm__ __volatile__("flush %0" : : "r" (addr + 0));
258 *(unsigned int *) (addr + 4) = p2->insns[1];
259 wmb();
260 __asm__ __volatile__("flush %0" : : "r" (addr + 4));
262 p2++;
265 sun4v_hvapi_init();
268 #ifdef CONFIG_SMP
269 void __init boot_cpu_id_too_large(int cpu)
271 prom_printf("Serious problem, boot cpu id (%d) >= NR_CPUS (%d)\n",
272 cpu, NR_CPUS);
273 prom_halt();
275 #endif
277 void __init setup_arch(char **cmdline_p)
279 /* Initialize PROM console and command line. */
280 *cmdline_p = prom_getbootargs();
281 strcpy(boot_command_line, *cmdline_p);
282 parse_early_param();
284 boot_flags_init(*cmdline_p);
285 #ifdef CONFIG_EARLYFB
286 if (btext_find_display())
287 #endif
288 register_console(&prom_early_console);
290 if (tlb_type == hypervisor)
291 printk("ARCH: SUN4V\n");
292 else
293 printk("ARCH: SUN4U\n");
295 #ifdef CONFIG_DUMMY_CONSOLE
296 conswitchp = &dummy_con;
297 #endif
299 idprom_init();
301 if (!root_flags)
302 root_mountflags &= ~MS_RDONLY;
303 ROOT_DEV = old_decode_dev(root_dev);
304 #ifdef CONFIG_BLK_DEV_RAM
305 rd_image_start = ram_flags & RAMDISK_IMAGE_START_MASK;
306 rd_prompt = ((ram_flags & RAMDISK_PROMPT_FLAG) != 0);
307 rd_doload = ((ram_flags & RAMDISK_LOAD_FLAG) != 0);
308 #endif
310 task_thread_info(&init_task)->kregs = &fake_swapper_regs;
312 #ifdef CONFIG_IP_PNP
313 if (!ic_set_manually) {
314 int chosen = prom_finddevice ("/chosen");
315 u32 cl, sv, gw;
317 cl = prom_getintdefault (chosen, "client-ip", 0);
318 sv = prom_getintdefault (chosen, "server-ip", 0);
319 gw = prom_getintdefault (chosen, "gateway-ip", 0);
320 if (cl && sv) {
321 ic_myaddr = cl;
322 ic_servaddr = sv;
323 if (gw)
324 ic_gateway = gw;
325 #if defined(CONFIG_IP_PNP_BOOTP) || defined(CONFIG_IP_PNP_RARP)
326 ic_proto_enabled = 0;
327 #endif
330 #endif
332 /* Get boot processor trap_block[] setup. */
333 init_cur_cpu_trap(current_thread_info());
335 paging_init();
338 /* BUFFER is PAGE_SIZE bytes long. */
340 extern void smp_info(struct seq_file *);
341 extern void smp_bogo(struct seq_file *);
342 extern void mmu_info(struct seq_file *);
344 unsigned int dcache_parity_tl1_occurred;
345 unsigned int icache_parity_tl1_occurred;
347 int ncpus_probed;
349 static int show_cpuinfo(struct seq_file *m, void *__unused)
351 seq_printf(m,
352 "cpu\t\t: %s\n"
353 "fpu\t\t: %s\n"
354 "pmu\t\t: %s\n"
355 "prom\t\t: %s\n"
356 "type\t\t: %s\n"
357 "ncpus probed\t: %d\n"
358 "ncpus active\t: %d\n"
359 "D$ parity tl1\t: %u\n"
360 "I$ parity tl1\t: %u\n"
361 #ifndef CONFIG_SMP
362 "Cpu0ClkTck\t: %016lx\n"
363 #endif
365 sparc_cpu_type,
366 sparc_fpu_type,
367 sparc_pmu_type,
368 prom_version,
369 ((tlb_type == hypervisor) ?
370 "sun4v" :
371 "sun4u"),
372 ncpus_probed,
373 num_online_cpus(),
374 dcache_parity_tl1_occurred,
375 icache_parity_tl1_occurred
376 #ifndef CONFIG_SMP
377 , cpu_data(0).clock_tick
378 #endif
380 #ifdef CONFIG_SMP
381 smp_bogo(m);
382 #endif
383 mmu_info(m);
384 #ifdef CONFIG_SMP
385 smp_info(m);
386 #endif
387 return 0;
390 static void *c_start(struct seq_file *m, loff_t *pos)
392 /* The pointer we are returning is arbitrary,
393 * it just has to be non-NULL and not IS_ERR
394 * in the success case.
396 return *pos == 0 ? &c_start : NULL;
399 static void *c_next(struct seq_file *m, void *v, loff_t *pos)
401 ++*pos;
402 return c_start(m, pos);
405 static void c_stop(struct seq_file *m, void *v)
409 const struct seq_operations cpuinfo_op = {
410 .start =c_start,
411 .next = c_next,
412 .stop = c_stop,
413 .show = show_cpuinfo,
416 extern int stop_a_enabled;
418 void sun_do_break(void)
420 if (!stop_a_enabled)
421 return;
423 prom_printf("\n");
424 flush_user_windows();
426 prom_cmdline();
428 EXPORT_SYMBOL(sun_do_break);
430 int stop_a_enabled = 1;
431 EXPORT_SYMBOL(stop_a_enabled);