1 /* $Id: setup.c,v 1.126 2001/11/13 00:49:27 davem Exp $
2 * linux/arch/sparc/kernel/setup.c
4 * Copyright (C) 1995 David S. Miller (davem@caip.rutgers.edu)
5 * Copyright (C) 2000 Anton Blanchard (anton@samba.org)
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/tty.h>
20 #include <linux/delay.h>
21 #include <linux/config.h>
23 #include <linux/seq_file.h>
24 #include <linux/kdev_t.h>
25 #include <linux/major.h>
26 #include <linux/string.h>
27 #include <linux/blk.h>
28 #include <linux/init.h>
29 #include <linux/interrupt.h>
30 #include <linux/console.h>
31 #include <linux/spinlock.h>
33 #include <asm/segment.h>
34 #include <asm/system.h>
37 #include <asm/processor.h>
38 #include <asm/oplib.h>
40 #include <asm/pgtable.h>
41 #include <asm/traps.h>
42 #include <asm/vaddrs.h>
43 #include <asm/kdebug.h>
45 #include <asm/idprom.h>
46 #include <asm/softirq.h>
47 #include <asm/hardirq.h>
48 #include <asm/machines.h>
50 struct screen_info screen_info = {
51 0, 0, /* orig-x, orig-y */
53 0, /* orig-video-page */
54 0, /* orig-video-mode */
55 128, /* orig-video-cols */
56 0,0,0, /* ega_ax, ega_bx, ega_cx */
57 54, /* orig-video-lines */
58 0, /* orig-video-isVGA */
59 16 /* orig-video-points */
62 /* Typing sync at the prom prompt calls the function pointed to by
63 * romvec->pv_synchook which I set to the following function.
64 * This should sync all filesystems and return, for now it just
65 * prints out pretty messages and returns.
68 extern unsigned long trapbase;
69 extern int serial_console;
70 extern void breakpoint(void);
71 #if CONFIG_SUN_CONSOLE
72 void (*prom_palette)(int);
74 asmlinkage void sys_sync(void); /* it's really int */
77 void prom_sync_me(void)
79 unsigned long prom_tbr, flags;
81 /* XXX Badly broken. FIX! - Anton */
83 __asm__ __volatile__("rd %%tbr, %0\n\t" : "=r" (prom_tbr));
84 __asm__ __volatile__("wr %0, 0x0, %%tbr\n\t"
87 "nop\n\t" : : "r" (&trapbase));
89 #ifdef CONFIG_SUN_CONSOLE
93 prom_printf("PROM SYNC COMMAND...\n");
95 if(current->pid != 0) {
100 prom_printf("Returning to prom\n");
102 __asm__ __volatile__("wr %0, 0x0, %%tbr\n\t"
105 "nop\n\t" : : "r" (prom_tbr));
106 restore_flags(flags);
111 extern void rs_kgdb_hook(int tty_num); /* sparc/serial.c */
113 unsigned int boot_flags __initdata = 0;
114 #define BOOTME_DEBUG 0x1
115 #define BOOTME_SINGLE 0x2
116 #define BOOTME_KGDBA 0x4
117 #define BOOTME_KGDBB 0x8
118 #define BOOTME_KGDB 0xc
120 #ifdef CONFIG_SUN_CONSOLE
121 static int console_fb __initdata = 0;
124 /* Exported for mm/init.c:paging_init. */
125 unsigned long cmdline_memory_size __initdata = 0;
127 void kernel_enter_debugger(void)
129 if (boot_flags & BOOTME_KGDB) {
130 printk("KGDB: Entered\n");
136 prom_console_write(struct console *con, const char *s, unsigned n)
138 prom_printf("%s", s);
141 static struct console prom_debug_console = {
143 write: prom_console_write,
144 flags: CON_PRINTBUFFER,
148 int obp_system_intr(void)
150 if (boot_flags & BOOTME_KGDB) {
151 printk("KGDB: system interrupted\n");
155 if (boot_flags & BOOTME_DEBUG) {
156 printk("OBP: system interrupted\n");
164 * Process kernel command line switches that are specific to the
165 * SPARC or that require special low-level processing.
167 static void __init process_switch(char c)
171 boot_flags |= BOOTME_DEBUG;
174 boot_flags |= BOOTME_SINGLE;
177 prom_printf("boot_flags_init: Halt!\n");
181 /* Use PROM debug console. */
182 register_console(&prom_debug_console);
185 printk("Unknown boot switch (-%c)\n", c);
190 static void __init boot_flags_init(char *commands)
193 /* Move to the start of the next "argument". */
194 while (*commands && *commands == ' ')
197 /* Process any command switches, otherwise skip it. */
198 if (*commands == '\0')
200 else if (*commands == '-') {
202 while (*commands && *commands != ' ')
203 process_switch(*commands++);
204 } else if (strlen(commands) >= 9
205 && !strncmp(commands, "kgdb=tty", 8)) {
206 switch (commands[8]) {
207 #ifdef CONFIG_SUN_SERIAL
209 boot_flags |= BOOTME_KGDBA;
210 prom_printf("KGDB: Using serial line /dev/ttya.\n");
213 boot_flags |= BOOTME_KGDBB;
214 prom_printf("KGDB: Using serial line /dev/ttyb.\n");
218 printk("KGDB: Unknown tty line.\n");
223 #if CONFIG_SUN_CONSOLE
224 if (!strncmp(commands, "console=", 8)) {
226 if (!strncmp (commands, "ttya", 4)) {
228 prom_printf ("Using /dev/ttya as console.\n");
229 } else if (!strncmp (commands, "ttyb", 4)) {
231 prom_printf ("Using /dev/ttyb as console.\n");
232 #if defined(CONFIG_PROM_CONSOLE)
233 } else if (!strncmp (commands, "prom", 4)) {
236 for (p = commands - 8; *p && *p != ' '; p++)
238 conswitchp = &prom_con;
246 if (!strncmp(commands, "mem=", 4)) {
248 * "mem=XXX[kKmM] overrides the PROM-reported
251 cmdline_memory_size = simple_strtoul(commands + 4,
253 if (*commands == 'K' || *commands == 'k') {
254 cmdline_memory_size <<= 10;
256 } else if (*commands=='M' || *commands=='m') {
257 cmdline_memory_size <<= 20;
261 while (*commands && *commands != ' ')
267 /* This routine will in the future do all the nasty prom stuff
268 * to probe for the mmu type and its parameters, etc. This will
269 * also be where SMP things happen plus the Sparc specific memory
270 * physical memory probe as on the alpha.
273 extern int prom_probe_memory(void);
274 extern void sun4c_probe_vac(void);
275 extern char cputypval;
276 extern unsigned long start, end;
277 extern void panic_setup(char *, int *);
278 extern void srmmu_end_memory(unsigned long, unsigned long *);
279 extern void sun_serial_setup(void);
281 extern unsigned short root_flags;
282 extern unsigned short root_dev;
283 extern unsigned short ram_flags;
284 #define RAMDISK_IMAGE_START_MASK 0x07FF
285 #define RAMDISK_PROMPT_FLAG 0x8000
286 #define RAMDISK_LOAD_FLAG 0x4000
288 extern int root_mountflags;
290 char saved_command_line[256];
291 char reboot_command[256];
292 enum sparc_cpu sparc_cpu_model;
294 struct tt_entry *sparc_ttable;
296 struct pt_regs fake_swapper_regs;
298 extern void paging_init(void);
300 void __init setup_arch(char **cmdline_p)
303 unsigned long highest_paddr;
305 sparc_ttable = (struct tt_entry *) &start;
307 /* Initialize PROM console and command line. */
308 *cmdline_p = prom_getbootargs();
309 strcpy(saved_command_line, *cmdline_p);
311 /* Set sparc_cpu_model */
312 sparc_cpu_model = sun_unknown;
313 if(!strcmp(&cputypval,"sun4 ")) { sparc_cpu_model=sun4; }
314 if(!strcmp(&cputypval,"sun4c")) { sparc_cpu_model=sun4c; }
315 if(!strcmp(&cputypval,"sun4m")) { sparc_cpu_model=sun4m; }
316 if(!strcmp(&cputypval,"sun4s")) { sparc_cpu_model=sun4m; } /* CP-1200 with PROM 2.30 -E */
317 if(!strcmp(&cputypval,"sun4d")) { sparc_cpu_model=sun4d; }
318 if(!strcmp(&cputypval,"sun4e")) { sparc_cpu_model=sun4e; }
319 if(!strcmp(&cputypval,"sun4u")) { sparc_cpu_model=sun4u; }
322 if (sparc_cpu_model != sun4) {
323 prom_printf("This kernel is for Sun4 architecture only.\n");
328 switch(sparc_cpu_model) {
348 printk("UNKNOWN!\n");
352 #ifdef CONFIG_DUMMY_CONSOLE
353 conswitchp = &dummy_con;
354 #elif defined(CONFIG_PROM_CONSOLE)
355 conswitchp = &prom_con;
357 boot_flags_init(*cmdline_p);
363 (void) prom_probe_memory();
365 phys_base = 0xffffffffUL;
367 for (i = 0; sp_banks[i].num_bytes != 0; i++) {
370 if (sp_banks[i].base_addr < phys_base)
371 phys_base = sp_banks[i].base_addr;
372 top = sp_banks[i].base_addr +
373 sp_banks[i].num_bytes;
374 if (highest_paddr < top)
379 root_mountflags &= ~MS_RDONLY;
380 ROOT_DEV = to_kdev_t(root_dev);
381 #ifdef CONFIG_BLK_DEV_INITRD
382 rd_image_start = ram_flags & RAMDISK_IMAGE_START_MASK;
383 rd_prompt = ((ram_flags & RAMDISK_PROMPT_FLAG) != 0);
384 rd_doload = ((ram_flags & RAMDISK_LOAD_FLAG) != 0);
387 prom_setsync(prom_sync_me);
390 #if !CONFIG_SUN_SERIAL
393 switch (console_fb) {
394 case 0: /* Let get our io devices from prom */
396 int idev = prom_query_input_device();
397 int odev = prom_query_output_device();
398 if (idev == PROMDEV_IKBD && odev == PROMDEV_OSCREEN) {
400 } else if (idev == PROMDEV_ITTYA && odev == PROMDEV_OTTYA) {
402 } else if (idev == PROMDEV_ITTYB && odev == PROMDEV_OTTYB) {
404 } else if (idev == PROMDEV_I_UNK && odev == PROMDEV_OTTYA) {
405 prom_printf("MrCoffee ttya\n");
407 } else if (idev == PROMDEV_I_UNK && odev == PROMDEV_OSCREEN) {
409 prom_printf("MrCoffee keyboard\n");
411 prom_printf("Inconsistent or unknown console\n");
412 prom_printf("You cannot mix serial and non serial input/output devices\n");
417 case 1: serial_console = 0; break; /* Force one of the framebuffers as console */
418 case 2: serial_console = 1; break; /* Force ttya as console */
419 case 3: serial_console = 2; break; /* Force ttyb as console */
424 if ((boot_flags & BOOTME_KGDBA)) {
427 if ((boot_flags & BOOTME_KGDBB)) {
431 if((boot_flags&BOOTME_DEBUG) && (linux_dbvec!=0) &&
432 ((*(short *)linux_dbvec) != -1)) {
433 printk("Booted under KADB. Syncing trap table.\n");
434 (*(linux_dbvec->teach_debugger))();
436 if((boot_flags & BOOTME_KGDB)) {
438 prom_printf ("Breakpoint!\n");
442 init_mm.context = (unsigned long) NO_CONTEXT;
443 init_task.thread.kregs = &fake_swapper_regs;
451 asmlinkage int sys_ioperm(unsigned long from, unsigned long num, int on)
456 extern char *sparc_cpu_type[];
457 extern char *sparc_fpu_type[];
459 static int show_cpuinfo(struct seq_file *m, void *__unused)
461 int cpuid = hard_smp_processor_id();
466 "promlib\t\t: Version %d Revision %d\n"
469 "ncpus probed\t: %d\n"
470 "ncpus active\t: %d\n"
472 "BogoMips\t: %lu.%02lu\n"
475 sparc_cpu_type[cpuid] ? : "undetermined",
476 sparc_fpu_type[cpuid] ? : "undetermined",
479 romvec->pv_printrev >> 16,
480 (short) romvec->pv_printrev,
485 , loops_per_jiffy/(500000/HZ),
486 (loops_per_jiffy/(5000/HZ)) % 100
500 static void *c_start(struct seq_file *m, loff_t *pos)
502 /* The pointer we are returning is arbitrary,
503 * it just has to be non-NULL and not IS_ERR
504 * in the success case.
506 return *pos == 0 ? &c_start : NULL;
509 static void *c_next(struct seq_file *m, void *v, loff_t *pos)
512 return c_start(m, pos);
515 static void c_stop(struct seq_file *m, void *v)
519 struct seq_operations cpuinfo_op = {