[SPARC64]: Adjust {TLBTEMP,TSBMAP}_BASE.
[deliverable/linux.git] / arch / sparc64 / kernel / setup.c
CommitLineData
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>
894673ee 18#include <linux/screen_info.h>
1da177e4 19#include <linux/delay.h>
1da177e4
LT
20#include <linux/fs.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>
33
1da177e4
LT
34#include <asm/system.h>
35#include <asm/io.h>
36#include <asm/processor.h>
37#include <asm/oplib.h>
38#include <asm/page.h>
39#include <asm/pgtable.h>
40#include <asm/idprom.h>
41#include <asm/head.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>
47#include <asm/mmu.h>
5cbc3073 48#include <asm/ns87303.h>
1da177e4
LT
49
50#ifdef CONFIG_IP_PNP
51#include <net/ipconfig.h>
52#endif
53
5cbc3073
DM
54/* Used to synchronize accesses to NatSemi SUPER I/O chip configure
55 * operations in asm/ns87303.h
56 */
57DEFINE_SPINLOCK(ns87303_lock);
58
1da177e4
LT
59struct screen_info screen_info = {
60 0, 0, /* orig-x, orig-y */
61 0, /* unused */
62 0, /* orig-video-page */
63 0, /* orig-video-mode */
64 128, /* orig-video-cols */
65 0, 0, 0, /* unused, ega_bx, unused */
66 54, /* orig-video-lines */
67 0, /* orig-video-isVGA */
68 16 /* orig-video-points */
69};
70
1da177e4
LT
71static void
72prom_console_write(struct console *con, const char *s, unsigned n)
73{
74 prom_write(s, n);
75}
76
1da177e4
LT
77/* Exported for mm/init.c:paging_init. */
78unsigned long cmdline_memory_size = 0;
79
3c62a2d3
DM
80static struct console prom_early_console = {
81 .name = "earlyprom",
1da177e4 82 .write = prom_console_write,
3c62a2d3 83 .flags = CON_PRINTBUFFER | CON_BOOT,
1da177e4
LT
84 .index = -1,
85};
86
1da177e4
LT
87/*
88 * Process kernel command line switches that are specific to the
89 * SPARC or that require special low-level processing.
90 */
91static void __init process_switch(char c)
92{
93 switch (c) {
94 case 'd':
1da177e4 95 case 's':
1da177e4
LT
96 break;
97 case 'h':
98 prom_printf("boot_flags_init: Halt!\n");
99 prom_halt();
100 break;
101 case 'p':
3c62a2d3 102 /* Just ignore, this behavior is now the default. */
1da177e4 103 break;
816242da
DM
104 case 'P':
105 /* Force UltraSPARC-III P-Cache on. */
106 if (tlb_type != cheetah) {
107 printk("BOOT: Ignoring P-Cache force option.\n");
108 break;
109 }
110 cheetah_pcache_forced_on = 1;
111 add_taint(TAINT_MACHINE_CHECK);
112 cheetah_enable_pcache();
113 break;
114
1da177e4
LT
115 default:
116 printk("Unknown boot switch (-%c)\n", c);
117 break;
118 }
119}
120
1da177e4
LT
121static void __init boot_flags_init(char *commands)
122{
123 while (*commands) {
124 /* Move to the start of the next "argument". */
125 while (*commands && *commands == ' ')
126 commands++;
127
128 /* Process any command switches, otherwise skip it. */
129 if (*commands == '\0')
130 break;
131 if (*commands == '-') {
132 commands++;
133 while (*commands && *commands != ' ')
134 process_switch(*commands++);
135 continue;
136 }
c73fcc84 137 if (!strncmp(commands, "mem=", 4)) {
1da177e4
LT
138 /*
139 * "mem=XXX[kKmM]" overrides the PROM-reported
140 * memory size.
141 */
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++;
150 }
151 }
152 while (*commands && *commands != ' ')
153 commands++;
154 }
155}
156
1da177e4
LT
157extern unsigned short root_flags;
158extern unsigned short root_dev;
159extern unsigned short ram_flags;
160#define RAMDISK_IMAGE_START_MASK 0x07FF
161#define RAMDISK_PROMPT_FLAG 0x8000
162#define RAMDISK_LOAD_FLAG 0x4000
163
164extern int root_mountflags;
165
166char reboot_command[COMMAND_LINE_SIZE];
167
168static struct pt_regs fake_swapper_regs = { { 0, }, 0, 0, 0, 0 };
169
951bc82c 170void __init per_cpu_patch(void)
92704a1c 171{
92704a1c
DM
172 struct cpuid_patch_entry *p;
173 unsigned long ver;
174 int is_jbus;
175
176 if (tlb_type == spitfire && !this_is_starfire)
177 return;
178
d82ace7d
DM
179 is_jbus = 0;
180 if (tlb_type != hypervisor) {
181 __asm__ ("rdpr %%ver, %0" : "=r" (ver));
ebd8c56c
DM
182 is_jbus = ((ver >> 32UL) == __JALAPENO_ID ||
183 (ver >> 32UL) == __SERRANO_ID);
d82ace7d 184 }
92704a1c
DM
185
186 p = &__cpuid_patch;
187 while (p < &__cpuid_patch_end) {
188 unsigned long addr = p->addr;
189 unsigned int *insns;
190
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;
d96b8153
DM
202 case hypervisor:
203 insns = &p->sun4v[0];
204 break;
92704a1c
DM
205 default:
206 prom_printf("Unknown cpu type, halting.\n");
207 prom_halt();
208 };
209
210 *(unsigned int *) (addr + 0) = insns[0];
840aaef8 211 wmb();
92704a1c
DM
212 __asm__ __volatile__("flush %0" : : "r" (addr + 0));
213
214 *(unsigned int *) (addr + 4) = insns[1];
840aaef8 215 wmb();
92704a1c
DM
216 __asm__ __volatile__("flush %0" : : "r" (addr + 4));
217
218 *(unsigned int *) (addr + 8) = insns[2];
840aaef8 219 wmb();
92704a1c
DM
220 __asm__ __volatile__("flush %0" : : "r" (addr + 8));
221
222 *(unsigned int *) (addr + 12) = insns[3];
840aaef8 223 wmb();
92704a1c
DM
224 __asm__ __volatile__("flush %0" : : "r" (addr + 12));
225
226 p++;
227 }
92704a1c
DM
228}
229
951bc82c 230void __init sun4v_patch(void)
936f482a 231{
c7754d46 232 extern void sun4v_hvapi_init(void);
df7d6aec
DM
233 struct sun4v_1insn_patch_entry *p1;
234 struct sun4v_2insn_patch_entry *p2;
936f482a
DM
235
236 if (tlb_type != hypervisor)
237 return;
238
df7d6aec
DM
239 p1 = &__sun4v_1insn_patch;
240 while (p1 < &__sun4v_1insn_patch_end) {
45fec05f 241 unsigned long addr = p1->addr;
936f482a 242
45fec05f 243 *(unsigned int *) (addr + 0) = p1->insn;
840aaef8 244 wmb();
936f482a
DM
245 __asm__ __volatile__("flush %0" : : "r" (addr + 0));
246
45fec05f
DM
247 p1++;
248 }
249
df7d6aec
DM
250 p2 = &__sun4v_2insn_patch;
251 while (p2 < &__sun4v_2insn_patch_end) {
45fec05f
DM
252 unsigned long addr = p2->addr;
253
254 *(unsigned int *) (addr + 0) = p2->insns[0];
840aaef8 255 wmb();
45fec05f
DM
256 __asm__ __volatile__("flush %0" : : "r" (addr + 0));
257
fd05068d 258 *(unsigned int *) (addr + 4) = p2->insns[1];
840aaef8 259 wmb();
45fec05f
DM
260 __asm__ __volatile__("flush %0" : : "r" (addr + 4));
261
262 p2++;
936f482a 263 }
c7754d46
DM
264
265 sun4v_hvapi_init();
936f482a
DM
266}
267
951bc82c
DM
268#ifdef CONFIG_SMP
269void __init boot_cpu_id_too_large(int cpu)
270{
271 prom_printf("Serious problem, boot cpu id (%d) >= NR_CPUS (%d)\n",
272 cpu, NR_CPUS);
273 prom_halt();
274}
275#endif
276
1da177e4
LT
277void __init setup_arch(char **cmdline_p)
278{
1da177e4
LT
279 /* Initialize PROM console and command line. */
280 *cmdline_p = prom_getbootargs();
383464c0 281 strcpy(boot_command_line, *cmdline_p);
1da177e4 282
3c62a2d3
DM
283 boot_flags_init(*cmdline_p);
284 register_console(&prom_early_console);
285
3a8c069d
DM
286 if (tlb_type == hypervisor)
287 printk("ARCH: SUN4V\n");
288 else
289 printk("ARCH: SUN4U\n");
1da177e4
LT
290
291#ifdef CONFIG_DUMMY_CONSOLE
292 conswitchp = &dummy_con;
293#elif defined(CONFIG_PROM_CONSOLE)
294 conswitchp = &prom_con;
295#endif
296
1da177e4 297 idprom_init();
1da177e4
LT
298
299 if (!root_flags)
300 root_mountflags &= ~MS_RDONLY;
301 ROOT_DEV = old_decode_dev(root_dev);
467418f3 302#ifdef CONFIG_BLK_DEV_RAM
1da177e4
LT
303 rd_image_start = ram_flags & RAMDISK_IMAGE_START_MASK;
304 rd_prompt = ((ram_flags & RAMDISK_PROMPT_FLAG) != 0);
305 rd_doload = ((ram_flags & RAMDISK_LOAD_FLAG) != 0);
306#endif
307
f3169641 308 task_thread_info(&init_task)->kregs = &fake_swapper_regs;
1da177e4
LT
309
310#ifdef CONFIG_IP_PNP
311 if (!ic_set_manually) {
312 int chosen = prom_finddevice ("/chosen");
313 u32 cl, sv, gw;
314
315 cl = prom_getintdefault (chosen, "client-ip", 0);
316 sv = prom_getintdefault (chosen, "server-ip", 0);
317 gw = prom_getintdefault (chosen, "gateway-ip", 0);
318 if (cl && sv) {
319 ic_myaddr = cl;
320 ic_servaddr = sv;
321 if (gw)
322 ic_gateway = gw;
323#if defined(CONFIG_IP_PNP_BOOTP) || defined(CONFIG_IP_PNP_RARP)
324 ic_proto_enabled = 0;
325#endif
326 }
327 }
328#endif
329
56fb4df6 330 /* Get boot processor trap_block[] setup. */
72aff53f 331 init_cur_cpu_trap(current_thread_info());
52845cdb
DM
332
333 paging_init();
1da177e4
LT
334}
335
1da177e4
LT
336/* BUFFER is PAGE_SIZE bytes long. */
337
338extern char *sparc_cpu_type;
339extern char *sparc_fpu_type;
340
341extern void smp_info(struct seq_file *);
342extern void smp_bogo(struct seq_file *);
343extern void mmu_info(struct seq_file *);
344
80dc0d6b
DM
345unsigned int dcache_parity_tl1_occurred;
346unsigned int icache_parity_tl1_occurred;
347
5cbc3073 348int ncpus_probed;
4d45cbac 349
1da177e4
LT
350static int show_cpuinfo(struct seq_file *m, void *__unused)
351{
352 seq_printf(m,
353 "cpu\t\t: %s\n"
354 "fpu\t\t: %s\n"
90a6646b
DM
355 "prom\t\t: %s\n"
356 "type\t\t: %s\n"
4d45cbac
DM
357 "ncpus probed\t: %d\n"
358 "ncpus active\t: %d\n"
80dc0d6b
DM
359 "D$ parity tl1\t: %u\n"
360 "I$ parity tl1\t: %u\n"
1da177e4 361#ifndef CONFIG_SMP
1da177e4
LT
362 "Cpu0ClkTck\t: %016lx\n"
363#endif
364 ,
365 sparc_cpu_type,
366 sparc_fpu_type,
90a6646b
DM
367 prom_version,
368 ((tlb_type == hypervisor) ?
369 "sun4v" :
370 "sun4u"),
4d45cbac
DM
371 ncpus_probed,
372 num_online_cpus(),
80dc0d6b 373 dcache_parity_tl1_occurred,
3ac66e33 374 icache_parity_tl1_occurred
1da177e4 375#ifndef CONFIG_SMP
3ac66e33 376 , cpu_data(0).clock_tick
1da177e4
LT
377#endif
378 );
379#ifdef CONFIG_SMP
380 smp_bogo(m);
381#endif
382 mmu_info(m);
383#ifdef CONFIG_SMP
384 smp_info(m);
385#endif
386 return 0;
387}
388
389static void *c_start(struct seq_file *m, loff_t *pos)
390{
391 /* The pointer we are returning is arbitrary,
392 * it just has to be non-NULL and not IS_ERR
393 * in the success case.
394 */
395 return *pos == 0 ? &c_start : NULL;
396}
397
398static void *c_next(struct seq_file *m, void *v, loff_t *pos)
399{
400 ++*pos;
401 return c_start(m, pos);
402}
403
404static void c_stop(struct seq_file *m, void *v)
405{
406}
407
872e2be7 408const struct seq_operations cpuinfo_op = {
1da177e4
LT
409 .start =c_start,
410 .next = c_next,
411 .stop = c_stop,
412 .show = show_cpuinfo,
413};
414
415extern int stop_a_enabled;
416
417void sun_do_break(void)
418{
419 if (!stop_a_enabled)
420 return;
421
422 prom_printf("\n");
423 flush_user_windows();
424
425 prom_cmdline();
426}
427
1da177e4 428int stop_a_enabled = 1;
This page took 1.737168 seconds and 5 git commands to generate.