Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 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> |
| 18 | #include <linux/a.out.h> |
| 19 | #include <linux/tty.h> |
| 20 | #include <linux/delay.h> |
| 21 | #include <linux/config.h> |
| 22 | #include <linux/fs.h> |
| 23 | #include <linux/seq_file.h> |
| 24 | #include <linux/syscalls.h> |
| 25 | #include <linux/kdev_t.h> |
| 26 | #include <linux/major.h> |
| 27 | #include <linux/string.h> |
| 28 | #include <linux/init.h> |
| 29 | #include <linux/inet.h> |
| 30 | #include <linux/console.h> |
| 31 | #include <linux/root_dev.h> |
| 32 | #include <linux/interrupt.h> |
| 33 | #include <linux/cpu.h> |
| 34 | #include <linux/initrd.h> |
| 35 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 36 | #include <asm/system.h> |
| 37 | #include <asm/io.h> |
| 38 | #include <asm/processor.h> |
| 39 | #include <asm/oplib.h> |
| 40 | #include <asm/page.h> |
| 41 | #include <asm/pgtable.h> |
| 42 | #include <asm/idprom.h> |
| 43 | #include <asm/head.h> |
| 44 | #include <asm/starfire.h> |
| 45 | #include <asm/mmu_context.h> |
| 46 | #include <asm/timer.h> |
| 47 | #include <asm/sections.h> |
| 48 | #include <asm/setup.h> |
| 49 | #include <asm/mmu.h> |
| 50 | |
| 51 | #ifdef CONFIG_IP_PNP |
| 52 | #include <net/ipconfig.h> |
| 53 | #endif |
| 54 | |
| 55 | struct screen_info screen_info = { |
| 56 | 0, 0, /* orig-x, orig-y */ |
| 57 | 0, /* unused */ |
| 58 | 0, /* orig-video-page */ |
| 59 | 0, /* orig-video-mode */ |
| 60 | 128, /* orig-video-cols */ |
| 61 | 0, 0, 0, /* unused, ega_bx, unused */ |
| 62 | 54, /* orig-video-lines */ |
| 63 | 0, /* orig-video-isVGA */ |
| 64 | 16 /* orig-video-points */ |
| 65 | }; |
| 66 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 67 | void (*prom_palette)(int); |
| 68 | void (*prom_keyboard)(void); |
| 69 | |
| 70 | static void |
| 71 | prom_console_write(struct console *con, const char *s, unsigned n) |
| 72 | { |
| 73 | prom_write(s, n); |
| 74 | } |
| 75 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 76 | unsigned int boot_flags = 0; |
| 77 | #define BOOTME_DEBUG 0x1 |
| 78 | #define BOOTME_SINGLE 0x2 |
| 79 | |
| 80 | /* Exported for mm/init.c:paging_init. */ |
| 81 | unsigned long cmdline_memory_size = 0; |
| 82 | |
| 83 | static struct console prom_debug_console = { |
| 84 | .name = "debug", |
| 85 | .write = prom_console_write, |
| 86 | .flags = CON_PRINTBUFFER, |
| 87 | .index = -1, |
| 88 | }; |
| 89 | |
| 90 | /* XXX Implement this at some point... */ |
| 91 | void kernel_enter_debugger(void) |
| 92 | { |
| 93 | } |
| 94 | |
| 95 | int obp_system_intr(void) |
| 96 | { |
| 97 | if (boot_flags & BOOTME_DEBUG) { |
| 98 | printk("OBP: system interrupted\n"); |
| 99 | prom_halt(); |
| 100 | return 1; |
| 101 | } |
| 102 | return 0; |
| 103 | } |
| 104 | |
| 105 | /* |
| 106 | * Process kernel command line switches that are specific to the |
| 107 | * SPARC or that require special low-level processing. |
| 108 | */ |
| 109 | static void __init process_switch(char c) |
| 110 | { |
| 111 | switch (c) { |
| 112 | case 'd': |
| 113 | boot_flags |= BOOTME_DEBUG; |
| 114 | break; |
| 115 | case 's': |
| 116 | boot_flags |= BOOTME_SINGLE; |
| 117 | break; |
| 118 | case 'h': |
| 119 | prom_printf("boot_flags_init: Halt!\n"); |
| 120 | prom_halt(); |
| 121 | break; |
| 122 | case 'p': |
| 123 | /* Use PROM debug console. */ |
| 124 | register_console(&prom_debug_console); |
| 125 | break; |
David S. Miller | 816242d | 2005-05-23 15:52:08 -0700 | [diff] [blame] | 126 | case 'P': |
| 127 | /* Force UltraSPARC-III P-Cache on. */ |
| 128 | if (tlb_type != cheetah) { |
| 129 | printk("BOOT: Ignoring P-Cache force option.\n"); |
| 130 | break; |
| 131 | } |
| 132 | cheetah_pcache_forced_on = 1; |
| 133 | add_taint(TAINT_MACHINE_CHECK); |
| 134 | cheetah_enable_pcache(); |
| 135 | break; |
| 136 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 137 | default: |
| 138 | printk("Unknown boot switch (-%c)\n", c); |
| 139 | break; |
| 140 | } |
| 141 | } |
| 142 | |
| 143 | static void __init process_console(char *commands) |
| 144 | { |
| 145 | serial_console = 0; |
| 146 | commands += 8; |
| 147 | /* Linux-style serial */ |
| 148 | if (!strncmp(commands, "ttyS", 4)) |
| 149 | serial_console = simple_strtoul(commands + 4, NULL, 10) + 1; |
| 150 | else if (!strncmp(commands, "tty", 3)) { |
| 151 | char c = *(commands + 3); |
| 152 | /* Solaris-style serial */ |
| 153 | if (c == 'a' || c == 'b') { |
| 154 | serial_console = c - 'a' + 1; |
| 155 | prom_printf ("Using /dev/tty%c as console.\n", c); |
| 156 | } |
| 157 | /* else Linux-style fbcon, not serial */ |
| 158 | } |
| 159 | #if defined(CONFIG_PROM_CONSOLE) |
| 160 | if (!strncmp(commands, "prom", 4)) { |
| 161 | char *p; |
| 162 | |
| 163 | for (p = commands - 8; *p && *p != ' '; p++) |
| 164 | *p = ' '; |
| 165 | conswitchp = &prom_con; |
| 166 | } |
| 167 | #endif |
| 168 | } |
| 169 | |
| 170 | static void __init boot_flags_init(char *commands) |
| 171 | { |
| 172 | while (*commands) { |
| 173 | /* Move to the start of the next "argument". */ |
| 174 | while (*commands && *commands == ' ') |
| 175 | commands++; |
| 176 | |
| 177 | /* Process any command switches, otherwise skip it. */ |
| 178 | if (*commands == '\0') |
| 179 | break; |
| 180 | if (*commands == '-') { |
| 181 | commands++; |
| 182 | while (*commands && *commands != ' ') |
| 183 | process_switch(*commands++); |
| 184 | continue; |
| 185 | } |
| 186 | if (!strncmp(commands, "console=", 8)) { |
| 187 | process_console(commands); |
| 188 | } else if (!strncmp(commands, "mem=", 4)) { |
| 189 | /* |
| 190 | * "mem=XXX[kKmM]" overrides the PROM-reported |
| 191 | * memory size. |
| 192 | */ |
| 193 | cmdline_memory_size = simple_strtoul(commands + 4, |
| 194 | &commands, 0); |
| 195 | if (*commands == 'K' || *commands == 'k') { |
| 196 | cmdline_memory_size <<= 10; |
| 197 | commands++; |
| 198 | } else if (*commands=='M' || *commands=='m') { |
| 199 | cmdline_memory_size <<= 20; |
| 200 | commands++; |
| 201 | } |
| 202 | } |
| 203 | while (*commands && *commands != ' ') |
| 204 | commands++; |
| 205 | } |
| 206 | } |
| 207 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 208 | extern void panic_setup(char *, int *); |
| 209 | |
| 210 | extern unsigned short root_flags; |
| 211 | extern unsigned short root_dev; |
| 212 | extern unsigned short ram_flags; |
| 213 | #define RAMDISK_IMAGE_START_MASK 0x07FF |
| 214 | #define RAMDISK_PROMPT_FLAG 0x8000 |
| 215 | #define RAMDISK_LOAD_FLAG 0x4000 |
| 216 | |
| 217 | extern int root_mountflags; |
| 218 | |
| 219 | char reboot_command[COMMAND_LINE_SIZE]; |
| 220 | |
| 221 | static struct pt_regs fake_swapper_regs = { { 0, }, 0, 0, 0, 0 }; |
| 222 | |
David S. Miller | 92704a1 | 2006-02-26 23:27:19 -0800 | [diff] [blame] | 223 | static void __init per_cpu_patch(void) |
| 224 | { |
David S. Miller | 92704a1 | 2006-02-26 23:27:19 -0800 | [diff] [blame] | 225 | struct cpuid_patch_entry *p; |
| 226 | unsigned long ver; |
| 227 | int is_jbus; |
| 228 | |
| 229 | if (tlb_type == spitfire && !this_is_starfire) |
| 230 | return; |
| 231 | |
David S. Miller | d82ace7 | 2006-02-09 02:52:44 -0800 | [diff] [blame] | 232 | is_jbus = 0; |
| 233 | if (tlb_type != hypervisor) { |
| 234 | __asm__ ("rdpr %%ver, %0" : "=r" (ver)); |
David S. Miller | ebd8c56 | 2006-02-17 08:38:06 -0800 | [diff] [blame] | 235 | is_jbus = ((ver >> 32UL) == __JALAPENO_ID || |
| 236 | (ver >> 32UL) == __SERRANO_ID); |
David S. Miller | d82ace7 | 2006-02-09 02:52:44 -0800 | [diff] [blame] | 237 | } |
David S. Miller | 92704a1 | 2006-02-26 23:27:19 -0800 | [diff] [blame] | 238 | |
| 239 | p = &__cpuid_patch; |
| 240 | while (p < &__cpuid_patch_end) { |
| 241 | unsigned long addr = p->addr; |
| 242 | unsigned int *insns; |
| 243 | |
| 244 | switch (tlb_type) { |
| 245 | case spitfire: |
| 246 | insns = &p->starfire[0]; |
| 247 | break; |
| 248 | case cheetah: |
| 249 | case cheetah_plus: |
| 250 | if (is_jbus) |
| 251 | insns = &p->cheetah_jbus[0]; |
| 252 | else |
| 253 | insns = &p->cheetah_safari[0]; |
| 254 | break; |
David S. Miller | d96b815 | 2006-02-04 15:40:53 -0800 | [diff] [blame] | 255 | case hypervisor: |
| 256 | insns = &p->sun4v[0]; |
| 257 | break; |
David S. Miller | 92704a1 | 2006-02-26 23:27:19 -0800 | [diff] [blame] | 258 | default: |
| 259 | prom_printf("Unknown cpu type, halting.\n"); |
| 260 | prom_halt(); |
| 261 | }; |
| 262 | |
| 263 | *(unsigned int *) (addr + 0) = insns[0]; |
David S. Miller | 840aaef | 2006-02-06 15:52:05 -0800 | [diff] [blame] | 264 | wmb(); |
David S. Miller | 92704a1 | 2006-02-26 23:27:19 -0800 | [diff] [blame] | 265 | __asm__ __volatile__("flush %0" : : "r" (addr + 0)); |
| 266 | |
| 267 | *(unsigned int *) (addr + 4) = insns[1]; |
David S. Miller | 840aaef | 2006-02-06 15:52:05 -0800 | [diff] [blame] | 268 | wmb(); |
David S. Miller | 92704a1 | 2006-02-26 23:27:19 -0800 | [diff] [blame] | 269 | __asm__ __volatile__("flush %0" : : "r" (addr + 4)); |
| 270 | |
| 271 | *(unsigned int *) (addr + 8) = insns[2]; |
David S. Miller | 840aaef | 2006-02-06 15:52:05 -0800 | [diff] [blame] | 272 | wmb(); |
David S. Miller | 92704a1 | 2006-02-26 23:27:19 -0800 | [diff] [blame] | 273 | __asm__ __volatile__("flush %0" : : "r" (addr + 8)); |
| 274 | |
| 275 | *(unsigned int *) (addr + 12) = insns[3]; |
David S. Miller | 840aaef | 2006-02-06 15:52:05 -0800 | [diff] [blame] | 276 | wmb(); |
David S. Miller | 92704a1 | 2006-02-26 23:27:19 -0800 | [diff] [blame] | 277 | __asm__ __volatile__("flush %0" : : "r" (addr + 12)); |
| 278 | |
| 279 | p++; |
| 280 | } |
David S. Miller | 92704a1 | 2006-02-26 23:27:19 -0800 | [diff] [blame] | 281 | } |
| 282 | |
David S. Miller | df7d6ae | 2006-02-07 00:00:16 -0800 | [diff] [blame] | 283 | static void __init sun4v_patch(void) |
David S. Miller | 936f482 | 2006-02-05 21:29:28 -0800 | [diff] [blame] | 284 | { |
David S. Miller | df7d6ae | 2006-02-07 00:00:16 -0800 | [diff] [blame] | 285 | struct sun4v_1insn_patch_entry *p1; |
| 286 | struct sun4v_2insn_patch_entry *p2; |
David S. Miller | 936f482 | 2006-02-05 21:29:28 -0800 | [diff] [blame] | 287 | |
| 288 | if (tlb_type != hypervisor) |
| 289 | return; |
| 290 | |
David S. Miller | df7d6ae | 2006-02-07 00:00:16 -0800 | [diff] [blame] | 291 | p1 = &__sun4v_1insn_patch; |
| 292 | while (p1 < &__sun4v_1insn_patch_end) { |
David S. Miller | 45fec05 | 2006-02-05 22:27:28 -0800 | [diff] [blame] | 293 | unsigned long addr = p1->addr; |
David S. Miller | 936f482 | 2006-02-05 21:29:28 -0800 | [diff] [blame] | 294 | |
David S. Miller | 45fec05 | 2006-02-05 22:27:28 -0800 | [diff] [blame] | 295 | *(unsigned int *) (addr + 0) = p1->insn; |
David S. Miller | 840aaef | 2006-02-06 15:52:05 -0800 | [diff] [blame] | 296 | wmb(); |
David S. Miller | 936f482 | 2006-02-05 21:29:28 -0800 | [diff] [blame] | 297 | __asm__ __volatile__("flush %0" : : "r" (addr + 0)); |
| 298 | |
David S. Miller | 45fec05 | 2006-02-05 22:27:28 -0800 | [diff] [blame] | 299 | p1++; |
| 300 | } |
| 301 | |
David S. Miller | df7d6ae | 2006-02-07 00:00:16 -0800 | [diff] [blame] | 302 | p2 = &__sun4v_2insn_patch; |
| 303 | while (p2 < &__sun4v_2insn_patch_end) { |
David S. Miller | 45fec05 | 2006-02-05 22:27:28 -0800 | [diff] [blame] | 304 | unsigned long addr = p2->addr; |
| 305 | |
| 306 | *(unsigned int *) (addr + 0) = p2->insns[0]; |
David S. Miller | 840aaef | 2006-02-06 15:52:05 -0800 | [diff] [blame] | 307 | wmb(); |
David S. Miller | 45fec05 | 2006-02-05 22:27:28 -0800 | [diff] [blame] | 308 | __asm__ __volatile__("flush %0" : : "r" (addr + 0)); |
| 309 | |
David S. Miller | fd05068 | 2006-02-11 11:05:52 -0800 | [diff] [blame] | 310 | *(unsigned int *) (addr + 4) = p2->insns[1]; |
David S. Miller | 840aaef | 2006-02-06 15:52:05 -0800 | [diff] [blame] | 311 | wmb(); |
David S. Miller | 45fec05 | 2006-02-05 22:27:28 -0800 | [diff] [blame] | 312 | __asm__ __volatile__("flush %0" : : "r" (addr + 4)); |
| 313 | |
| 314 | p2++; |
David S. Miller | 936f482 | 2006-02-05 21:29:28 -0800 | [diff] [blame] | 315 | } |
| 316 | } |
| 317 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 318 | void __init setup_arch(char **cmdline_p) |
| 319 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 320 | /* Initialize PROM console and command line. */ |
| 321 | *cmdline_p = prom_getbootargs(); |
| 322 | strcpy(saved_command_line, *cmdline_p); |
| 323 | |
David S. Miller | 3a8c069 | 2006-02-09 02:54:54 -0800 | [diff] [blame] | 324 | if (tlb_type == hypervisor) |
| 325 | printk("ARCH: SUN4V\n"); |
| 326 | else |
| 327 | printk("ARCH: SUN4U\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 328 | |
| 329 | #ifdef CONFIG_DUMMY_CONSOLE |
| 330 | conswitchp = &dummy_con; |
| 331 | #elif defined(CONFIG_PROM_CONSOLE) |
| 332 | conswitchp = &prom_con; |
| 333 | #endif |
| 334 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 335 | /* Work out if we are starfire early on */ |
| 336 | check_if_starfire(); |
| 337 | |
David S. Miller | 92704a1 | 2006-02-26 23:27:19 -0800 | [diff] [blame] | 338 | /* Now we know enough to patch the get_cpuid sequences |
| 339 | * used by trap code. |
David S. Miller | 56fb4df | 2006-02-26 23:24:22 -0800 | [diff] [blame] | 340 | */ |
| 341 | per_cpu_patch(); |
| 342 | |
David S. Miller | df7d6ae | 2006-02-07 00:00:16 -0800 | [diff] [blame] | 343 | sun4v_patch(); |
David S. Miller | 936f482 | 2006-02-05 21:29:28 -0800 | [diff] [blame] | 344 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 345 | boot_flags_init(*cmdline_p); |
| 346 | |
| 347 | idprom_init(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 348 | |
| 349 | if (!root_flags) |
| 350 | root_mountflags &= ~MS_RDONLY; |
| 351 | ROOT_DEV = old_decode_dev(root_dev); |
Andrew Morton | 467418f | 2006-03-19 12:46:55 -0800 | [diff] [blame^] | 352 | #ifdef CONFIG_BLK_DEV_RAM |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 353 | rd_image_start = ram_flags & RAMDISK_IMAGE_START_MASK; |
| 354 | rd_prompt = ((ram_flags & RAMDISK_PROMPT_FLAG) != 0); |
| 355 | rd_doload = ((ram_flags & RAMDISK_LOAD_FLAG) != 0); |
| 356 | #endif |
| 357 | |
Al Viro | f316964 | 2006-01-12 01:05:42 -0800 | [diff] [blame] | 358 | task_thread_info(&init_task)->kregs = &fake_swapper_regs; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 359 | |
| 360 | #ifdef CONFIG_IP_PNP |
| 361 | if (!ic_set_manually) { |
| 362 | int chosen = prom_finddevice ("/chosen"); |
| 363 | u32 cl, sv, gw; |
| 364 | |
| 365 | cl = prom_getintdefault (chosen, "client-ip", 0); |
| 366 | sv = prom_getintdefault (chosen, "server-ip", 0); |
| 367 | gw = prom_getintdefault (chosen, "gateway-ip", 0); |
| 368 | if (cl && sv) { |
| 369 | ic_myaddr = cl; |
| 370 | ic_servaddr = sv; |
| 371 | if (gw) |
| 372 | ic_gateway = gw; |
| 373 | #if defined(CONFIG_IP_PNP_BOOTP) || defined(CONFIG_IP_PNP_RARP) |
| 374 | ic_proto_enabled = 0; |
| 375 | #endif |
| 376 | } |
| 377 | } |
| 378 | #endif |
| 379 | |
David S. Miller | 7abea92 | 2006-02-25 13:39:56 -0800 | [diff] [blame] | 380 | smp_setup_cpu_possible_map(); |
| 381 | |
David S. Miller | 56fb4df | 2006-02-26 23:24:22 -0800 | [diff] [blame] | 382 | /* Get boot processor trap_block[] setup. */ |
David S. Miller | 72aff53 | 2006-02-17 01:29:17 -0800 | [diff] [blame] | 383 | init_cur_cpu_trap(current_thread_info()); |
David S. Miller | 52845cd | 2006-02-26 23:32:33 -0800 | [diff] [blame] | 384 | |
| 385 | paging_init(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 386 | } |
| 387 | |
| 388 | static int __init set_preferred_console(void) |
| 389 | { |
| 390 | int idev, odev; |
| 391 | |
| 392 | /* The user has requested a console so this is already set up. */ |
| 393 | if (serial_console >= 0) |
| 394 | return -EBUSY; |
| 395 | |
| 396 | idev = prom_query_input_device(); |
| 397 | odev = prom_query_output_device(); |
| 398 | if (idev == PROMDEV_IKBD && odev == PROMDEV_OSCREEN) { |
| 399 | serial_console = 0; |
| 400 | } else if (idev == PROMDEV_ITTYA && odev == PROMDEV_OTTYA) { |
| 401 | serial_console = 1; |
| 402 | } else if (idev == PROMDEV_ITTYB && odev == PROMDEV_OTTYB) { |
| 403 | serial_console = 2; |
Eddie C. Dost | c126cf8 | 2006-01-18 14:54:31 -0800 | [diff] [blame] | 404 | } else if (idev == PROMDEV_IRSC && odev == PROMDEV_ORSC) { |
| 405 | serial_console = 3; |
David S. Miller | 1a7a242 | 2006-02-11 23:24:30 -0800 | [diff] [blame] | 406 | } else if (idev == PROMDEV_IVCONS && odev == PROMDEV_OVCONS) { |
| 407 | /* sunhv_console_init() doesn't check the serial_console |
| 408 | * value anyways... |
| 409 | */ |
| 410 | serial_console = 4; |
David S. Miller | d5a2aa2 | 2006-02-13 21:28:40 -0800 | [diff] [blame] | 411 | return add_preferred_console("ttyHV", 0, NULL); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 412 | } else { |
| 413 | prom_printf("Inconsistent console: " |
| 414 | "input %d, output %d\n", |
| 415 | idev, odev); |
| 416 | prom_halt(); |
| 417 | } |
| 418 | |
| 419 | if (serial_console) |
| 420 | return add_preferred_console("ttyS", serial_console - 1, NULL); |
| 421 | |
| 422 | return -ENODEV; |
| 423 | } |
| 424 | console_initcall(set_preferred_console); |
| 425 | |
| 426 | /* BUFFER is PAGE_SIZE bytes long. */ |
| 427 | |
| 428 | extern char *sparc_cpu_type; |
| 429 | extern char *sparc_fpu_type; |
| 430 | |
| 431 | extern void smp_info(struct seq_file *); |
| 432 | extern void smp_bogo(struct seq_file *); |
| 433 | extern void mmu_info(struct seq_file *); |
| 434 | |
David S. Miller | 80dc0d6 | 2005-09-26 00:32:17 -0700 | [diff] [blame] | 435 | unsigned int dcache_parity_tl1_occurred; |
| 436 | unsigned int icache_parity_tl1_occurred; |
| 437 | |
David S. Miller | 4d45cba | 2005-11-11 12:48:56 -0800 | [diff] [blame] | 438 | static int ncpus_probed; |
| 439 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 440 | static int show_cpuinfo(struct seq_file *m, void *__unused) |
| 441 | { |
| 442 | seq_printf(m, |
| 443 | "cpu\t\t: %s\n" |
| 444 | "fpu\t\t: %s\n" |
David S. Miller | 90a6646 | 2006-03-08 17:18:19 -0800 | [diff] [blame] | 445 | "prom\t\t: %s\n" |
| 446 | "type\t\t: %s\n" |
David S. Miller | 4d45cba | 2005-11-11 12:48:56 -0800 | [diff] [blame] | 447 | "ncpus probed\t: %d\n" |
| 448 | "ncpus active\t: %d\n" |
David S. Miller | 80dc0d6 | 2005-09-26 00:32:17 -0700 | [diff] [blame] | 449 | "D$ parity tl1\t: %u\n" |
| 450 | "I$ parity tl1\t: %u\n" |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 451 | #ifndef CONFIG_SMP |
| 452 | "Cpu0Bogo\t: %lu.%02lu\n" |
| 453 | "Cpu0ClkTck\t: %016lx\n" |
| 454 | #endif |
| 455 | , |
| 456 | sparc_cpu_type, |
| 457 | sparc_fpu_type, |
David S. Miller | 90a6646 | 2006-03-08 17:18:19 -0800 | [diff] [blame] | 458 | prom_version, |
| 459 | ((tlb_type == hypervisor) ? |
| 460 | "sun4v" : |
| 461 | "sun4u"), |
David S. Miller | 4d45cba | 2005-11-11 12:48:56 -0800 | [diff] [blame] | 462 | ncpus_probed, |
| 463 | num_online_cpus(), |
David S. Miller | 80dc0d6 | 2005-09-26 00:32:17 -0700 | [diff] [blame] | 464 | dcache_parity_tl1_occurred, |
| 465 | icache_parity_tl1_occurred |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 466 | #ifndef CONFIG_SMP |
| 467 | , cpu_data(0).udelay_val/(500000/HZ), |
| 468 | (cpu_data(0).udelay_val/(5000/HZ)) % 100, |
| 469 | cpu_data(0).clock_tick |
| 470 | #endif |
| 471 | ); |
| 472 | #ifdef CONFIG_SMP |
| 473 | smp_bogo(m); |
| 474 | #endif |
| 475 | mmu_info(m); |
| 476 | #ifdef CONFIG_SMP |
| 477 | smp_info(m); |
| 478 | #endif |
| 479 | return 0; |
| 480 | } |
| 481 | |
| 482 | static void *c_start(struct seq_file *m, loff_t *pos) |
| 483 | { |
| 484 | /* The pointer we are returning is arbitrary, |
| 485 | * it just has to be non-NULL and not IS_ERR |
| 486 | * in the success case. |
| 487 | */ |
| 488 | return *pos == 0 ? &c_start : NULL; |
| 489 | } |
| 490 | |
| 491 | static void *c_next(struct seq_file *m, void *v, loff_t *pos) |
| 492 | { |
| 493 | ++*pos; |
| 494 | return c_start(m, pos); |
| 495 | } |
| 496 | |
| 497 | static void c_stop(struct seq_file *m, void *v) |
| 498 | { |
| 499 | } |
| 500 | |
| 501 | struct seq_operations cpuinfo_op = { |
| 502 | .start =c_start, |
| 503 | .next = c_next, |
| 504 | .stop = c_stop, |
| 505 | .show = show_cpuinfo, |
| 506 | }; |
| 507 | |
| 508 | extern int stop_a_enabled; |
| 509 | |
| 510 | void sun_do_break(void) |
| 511 | { |
| 512 | if (!stop_a_enabled) |
| 513 | return; |
| 514 | |
| 515 | prom_printf("\n"); |
| 516 | flush_user_windows(); |
| 517 | |
| 518 | prom_cmdline(); |
| 519 | } |
| 520 | |
| 521 | int serial_console = -1; |
| 522 | int stop_a_enabled = 1; |
| 523 | |
| 524 | static int __init topology_init(void) |
| 525 | { |
| 526 | int i, err; |
| 527 | |
| 528 | err = -ENOMEM; |
David S. Miller | 4d45cba | 2005-11-11 12:48:56 -0800 | [diff] [blame] | 529 | |
| 530 | /* Count the number of physically present processors in |
| 531 | * the machine, even on uniprocessor, so that /proc/cpuinfo |
| 532 | * output is consistent with 2.4.x |
| 533 | */ |
| 534 | ncpus_probed = 0; |
| 535 | while (!cpu_find_by_instance(ncpus_probed, NULL, NULL)) |
| 536 | ncpus_probed++; |
| 537 | |
Eric Sesterhenn | 9132983 | 2006-03-06 13:48:40 -0800 | [diff] [blame] | 538 | for_each_cpu(i) { |
| 539 | struct cpu *p = kzalloc(sizeof(*p), GFP_KERNEL); |
| 540 | if (p) { |
| 541 | register_cpu(p, i, NULL); |
| 542 | err = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 543 | } |
| 544 | } |
| 545 | |
| 546 | return err; |
| 547 | } |
| 548 | |
| 549 | subsys_initcall(topology_init); |