Paul Mackerras | 03501da | 2005-10-26 17:11:18 +1000 | [diff] [blame] | 1 | /* |
| 2 | * Common boot and setup code for both 32-bit and 64-bit. |
| 3 | * Extracted from arch/powerpc/kernel/setup_64.c. |
| 4 | * |
| 5 | * Copyright (C) 2001 PPC64 Team, IBM Corp |
| 6 | * |
| 7 | * This program is free software; you can redistribute it and/or |
| 8 | * modify it under the terms of the GNU General Public License |
| 9 | * as published by the Free Software Foundation; either version |
| 10 | * 2 of the License, or (at your option) any later version. |
| 11 | */ |
| 12 | #include <linux/config.h> |
| 13 | #include <linux/module.h> |
| 14 | #include <linux/string.h> |
| 15 | #include <linux/sched.h> |
| 16 | #include <linux/init.h> |
| 17 | #include <linux/kernel.h> |
| 18 | #include <linux/reboot.h> |
| 19 | #include <linux/delay.h> |
| 20 | #include <linux/initrd.h> |
| 21 | #include <linux/ide.h> |
| 22 | #include <linux/seq_file.h> |
| 23 | #include <linux/ioport.h> |
| 24 | #include <linux/console.h> |
| 25 | #include <linux/utsname.h> |
| 26 | #include <linux/tty.h> |
| 27 | #include <linux/root_dev.h> |
| 28 | #include <linux/notifier.h> |
| 29 | #include <linux/cpu.h> |
| 30 | #include <linux/unistd.h> |
| 31 | #include <linux/serial.h> |
| 32 | #include <linux/serial_8250.h> |
| 33 | #include <asm/io.h> |
| 34 | #include <asm/prom.h> |
| 35 | #include <asm/processor.h> |
Benjamin Herrenschmidt | a7f290d | 2005-11-11 21:15:21 +1100 | [diff] [blame] | 36 | #include <asm/vdso_datapage.h> |
Paul Mackerras | 03501da | 2005-10-26 17:11:18 +1000 | [diff] [blame] | 37 | #include <asm/pgtable.h> |
Paul Mackerras | 03501da | 2005-10-26 17:11:18 +1000 | [diff] [blame] | 38 | #include <asm/smp.h> |
| 39 | #include <asm/elf.h> |
| 40 | #include <asm/machdep.h> |
| 41 | #include <asm/time.h> |
| 42 | #include <asm/cputable.h> |
| 43 | #include <asm/sections.h> |
| 44 | #include <asm/btext.h> |
| 45 | #include <asm/nvram.h> |
| 46 | #include <asm/setup.h> |
| 47 | #include <asm/system.h> |
| 48 | #include <asm/rtas.h> |
| 49 | #include <asm/iommu.h> |
| 50 | #include <asm/serial.h> |
| 51 | #include <asm/cache.h> |
| 52 | #include <asm/page.h> |
| 53 | #include <asm/mmu.h> |
| 54 | #include <asm/lmb.h> |
Paul Mackerras | fca5dcd | 2005-11-08 22:55:08 +1100 | [diff] [blame] | 55 | #include <asm/xmon.h> |
Paul Mackerras | 03501da | 2005-10-26 17:11:18 +1000 | [diff] [blame] | 56 | |
Stephen Rothwell | 66ba135 | 2005-11-09 11:01:06 +1100 | [diff] [blame] | 57 | #include "setup.h" |
| 58 | |
Paul Mackerras | 03501da | 2005-10-26 17:11:18 +1000 | [diff] [blame] | 59 | #undef DEBUG |
| 60 | |
| 61 | #ifdef DEBUG |
Michael Ellerman | f9e4ec5 | 2005-11-15 15:16:38 +1100 | [diff] [blame^] | 62 | #include <asm/udbg.h> |
Paul Mackerras | 03501da | 2005-10-26 17:11:18 +1000 | [diff] [blame] | 63 | #define DBG(fmt...) udbg_printf(fmt) |
| 64 | #else |
| 65 | #define DBG(fmt...) |
| 66 | #endif |
| 67 | |
Paul Mackerras | 799d604 | 2005-11-10 13:37:51 +1100 | [diff] [blame] | 68 | #ifdef CONFIG_PPC_MULTIPLATFORM |
| 69 | int _machine = 0; |
| 70 | EXPORT_SYMBOL(_machine); |
| 71 | #endif |
| 72 | |
Paul Mackerras | 49b0985 | 2005-11-10 15:53:40 +1100 | [diff] [blame] | 73 | unsigned long klimit = (unsigned long) _end; |
| 74 | |
Paul Mackerras | 03501da | 2005-10-26 17:11:18 +1000 | [diff] [blame] | 75 | /* |
| 76 | * This still seems to be needed... -- paulus |
| 77 | */ |
| 78 | struct screen_info screen_info = { |
| 79 | .orig_x = 0, |
| 80 | .orig_y = 25, |
| 81 | .orig_video_cols = 80, |
| 82 | .orig_video_lines = 25, |
| 83 | .orig_video_isVGA = 1, |
| 84 | .orig_video_points = 16 |
| 85 | }; |
| 86 | |
| 87 | #ifdef __DO_IRQ_CANON |
| 88 | /* XXX should go elsewhere eventually */ |
| 89 | int ppc_do_canonicalize_irqs; |
| 90 | EXPORT_SYMBOL(ppc_do_canonicalize_irqs); |
| 91 | #endif |
| 92 | |
| 93 | /* also used by kexec */ |
| 94 | void machine_shutdown(void) |
| 95 | { |
| 96 | if (ppc_md.nvram_sync) |
| 97 | ppc_md.nvram_sync(); |
| 98 | } |
| 99 | |
| 100 | void machine_restart(char *cmd) |
| 101 | { |
| 102 | machine_shutdown(); |
| 103 | ppc_md.restart(cmd); |
| 104 | #ifdef CONFIG_SMP |
| 105 | smp_send_stop(); |
| 106 | #endif |
| 107 | printk(KERN_EMERG "System Halted, OK to turn off power\n"); |
| 108 | local_irq_disable(); |
| 109 | while (1) ; |
| 110 | } |
| 111 | |
| 112 | void machine_power_off(void) |
| 113 | { |
| 114 | machine_shutdown(); |
| 115 | ppc_md.power_off(); |
| 116 | #ifdef CONFIG_SMP |
| 117 | smp_send_stop(); |
| 118 | #endif |
| 119 | printk(KERN_EMERG "System Halted, OK to turn off power\n"); |
| 120 | local_irq_disable(); |
| 121 | while (1) ; |
| 122 | } |
| 123 | /* Used by the G5 thermal driver */ |
| 124 | EXPORT_SYMBOL_GPL(machine_power_off); |
| 125 | |
| 126 | void (*pm_power_off)(void) = machine_power_off; |
| 127 | EXPORT_SYMBOL_GPL(pm_power_off); |
| 128 | |
| 129 | void machine_halt(void) |
| 130 | { |
| 131 | machine_shutdown(); |
| 132 | ppc_md.halt(); |
| 133 | #ifdef CONFIG_SMP |
| 134 | smp_send_stop(); |
| 135 | #endif |
| 136 | printk(KERN_EMERG "System Halted, OK to turn off power\n"); |
| 137 | local_irq_disable(); |
| 138 | while (1) ; |
| 139 | } |
| 140 | |
| 141 | |
| 142 | #ifdef CONFIG_TAU |
| 143 | extern u32 cpu_temp(unsigned long cpu); |
| 144 | extern u32 cpu_temp_both(unsigned long cpu); |
| 145 | #endif /* CONFIG_TAU */ |
| 146 | |
| 147 | #ifdef CONFIG_SMP |
| 148 | DEFINE_PER_CPU(unsigned int, pvr); |
| 149 | #endif |
| 150 | |
| 151 | static int show_cpuinfo(struct seq_file *m, void *v) |
| 152 | { |
| 153 | unsigned long cpu_id = (unsigned long)v - 1; |
| 154 | unsigned int pvr; |
| 155 | unsigned short maj; |
| 156 | unsigned short min; |
| 157 | |
| 158 | if (cpu_id == NR_CPUS) { |
| 159 | #if defined(CONFIG_SMP) && defined(CONFIG_PPC32) |
| 160 | unsigned long bogosum = 0; |
| 161 | int i; |
| 162 | for (i = 0; i < NR_CPUS; ++i) |
| 163 | if (cpu_online(i)) |
| 164 | bogosum += loops_per_jiffy; |
| 165 | seq_printf(m, "total bogomips\t: %lu.%02lu\n", |
| 166 | bogosum/(500000/HZ), bogosum/(5000/HZ) % 100); |
| 167 | #endif /* CONFIG_SMP && CONFIG_PPC32 */ |
| 168 | seq_printf(m, "timebase\t: %lu\n", ppc_tb_freq); |
| 169 | |
| 170 | if (ppc_md.show_cpuinfo != NULL) |
| 171 | ppc_md.show_cpuinfo(m); |
| 172 | |
| 173 | return 0; |
| 174 | } |
| 175 | |
| 176 | /* We only show online cpus: disable preempt (overzealous, I |
| 177 | * knew) to prevent cpu going down. */ |
| 178 | preempt_disable(); |
| 179 | if (!cpu_online(cpu_id)) { |
| 180 | preempt_enable(); |
| 181 | return 0; |
| 182 | } |
| 183 | |
| 184 | #ifdef CONFIG_SMP |
Paul Mackerras | 03501da | 2005-10-26 17:11:18 +1000 | [diff] [blame] | 185 | pvr = per_cpu(pvr, cpu_id); |
| 186 | #else |
Paul Mackerras | 03501da | 2005-10-26 17:11:18 +1000 | [diff] [blame] | 187 | pvr = mfspr(SPRN_PVR); |
| 188 | #endif |
| 189 | maj = (pvr >> 8) & 0xFF; |
| 190 | min = pvr & 0xFF; |
| 191 | |
| 192 | seq_printf(m, "processor\t: %lu\n", cpu_id); |
| 193 | seq_printf(m, "cpu\t\t: "); |
| 194 | |
| 195 | if (cur_cpu_spec->pvr_mask) |
| 196 | seq_printf(m, "%s", cur_cpu_spec->cpu_name); |
| 197 | else |
| 198 | seq_printf(m, "unknown (%08x)", pvr); |
| 199 | |
| 200 | #ifdef CONFIG_ALTIVEC |
| 201 | if (cpu_has_feature(CPU_FTR_ALTIVEC)) |
| 202 | seq_printf(m, ", altivec supported"); |
| 203 | #endif /* CONFIG_ALTIVEC */ |
| 204 | |
| 205 | seq_printf(m, "\n"); |
| 206 | |
| 207 | #ifdef CONFIG_TAU |
| 208 | if (cur_cpu_spec->cpu_features & CPU_FTR_TAU) { |
| 209 | #ifdef CONFIG_TAU_AVERAGE |
| 210 | /* more straightforward, but potentially misleading */ |
| 211 | seq_printf(m, "temperature \t: %u C (uncalibrated)\n", |
Paul Mackerras | bccfd58 | 2005-11-02 15:06:22 +1100 | [diff] [blame] | 212 | cpu_temp(cpu_id)); |
Paul Mackerras | 03501da | 2005-10-26 17:11:18 +1000 | [diff] [blame] | 213 | #else |
| 214 | /* show the actual temp sensor range */ |
| 215 | u32 temp; |
Paul Mackerras | bccfd58 | 2005-11-02 15:06:22 +1100 | [diff] [blame] | 216 | temp = cpu_temp_both(cpu_id); |
Paul Mackerras | 03501da | 2005-10-26 17:11:18 +1000 | [diff] [blame] | 217 | seq_printf(m, "temperature \t: %u-%u C (uncalibrated)\n", |
| 218 | temp & 0xff, temp >> 16); |
| 219 | #endif |
| 220 | } |
| 221 | #endif /* CONFIG_TAU */ |
| 222 | |
| 223 | /* |
| 224 | * Assume here that all clock rates are the same in a |
| 225 | * smp system. -- Cort |
| 226 | */ |
| 227 | if (ppc_proc_freq) |
| 228 | seq_printf(m, "clock\t\t: %lu.%06luMHz\n", |
| 229 | ppc_proc_freq / 1000000, ppc_proc_freq % 1000000); |
| 230 | |
| 231 | if (ppc_md.show_percpuinfo != NULL) |
| 232 | ppc_md.show_percpuinfo(m, cpu_id); |
| 233 | |
| 234 | /* If we are a Freescale core do a simple check so |
| 235 | * we dont have to keep adding cases in the future */ |
| 236 | if (PVR_VER(pvr) & 0x8000) { |
| 237 | maj = PVR_MAJ(pvr); |
| 238 | min = PVR_MIN(pvr); |
| 239 | } else { |
| 240 | switch (PVR_VER(pvr)) { |
| 241 | case 0x0020: /* 403 family */ |
| 242 | maj = PVR_MAJ(pvr) + 1; |
| 243 | min = PVR_MIN(pvr); |
| 244 | break; |
| 245 | case 0x1008: /* 740P/750P ?? */ |
| 246 | maj = ((pvr >> 8) & 0xFF) - 1; |
| 247 | min = pvr & 0xFF; |
| 248 | break; |
| 249 | default: |
| 250 | maj = (pvr >> 8) & 0xFF; |
| 251 | min = pvr & 0xFF; |
| 252 | break; |
| 253 | } |
| 254 | } |
| 255 | |
| 256 | seq_printf(m, "revision\t: %hd.%hd (pvr %04x %04x)\n", |
| 257 | maj, min, PVR_VER(pvr), PVR_REV(pvr)); |
| 258 | |
| 259 | #ifdef CONFIG_PPC32 |
| 260 | seq_printf(m, "bogomips\t: %lu.%02lu\n", |
| 261 | loops_per_jiffy / (500000/HZ), |
| 262 | (loops_per_jiffy / (5000/HZ)) % 100); |
| 263 | #endif |
| 264 | |
| 265 | #ifdef CONFIG_SMP |
| 266 | seq_printf(m, "\n"); |
| 267 | #endif |
| 268 | |
| 269 | preempt_enable(); |
| 270 | return 0; |
| 271 | } |
| 272 | |
| 273 | static void *c_start(struct seq_file *m, loff_t *pos) |
| 274 | { |
| 275 | unsigned long i = *pos; |
| 276 | |
| 277 | return i <= NR_CPUS ? (void *)(i + 1) : NULL; |
| 278 | } |
| 279 | |
| 280 | static void *c_next(struct seq_file *m, void *v, loff_t *pos) |
| 281 | { |
| 282 | ++*pos; |
| 283 | return c_start(m, pos); |
| 284 | } |
| 285 | |
| 286 | static void c_stop(struct seq_file *m, void *v) |
| 287 | { |
| 288 | } |
| 289 | |
| 290 | struct seq_operations cpuinfo_op = { |
| 291 | .start =c_start, |
| 292 | .next = c_next, |
| 293 | .stop = c_stop, |
| 294 | .show = show_cpuinfo, |
| 295 | }; |
| 296 | |
| 297 | #ifdef CONFIG_PPC_MULTIPLATFORM |
| 298 | static int __init set_preferred_console(void) |
| 299 | { |
| 300 | struct device_node *prom_stdout = NULL; |
| 301 | char *name; |
| 302 | u32 *spd; |
| 303 | int offset = 0; |
| 304 | |
| 305 | DBG(" -> set_preferred_console()\n"); |
| 306 | |
| 307 | /* The user has requested a console so this is already set up. */ |
| 308 | if (strstr(saved_command_line, "console=")) { |
| 309 | DBG(" console was specified !\n"); |
| 310 | return -EBUSY; |
| 311 | } |
| 312 | |
| 313 | if (!of_chosen) { |
| 314 | DBG(" of_chosen is NULL !\n"); |
| 315 | return -ENODEV; |
| 316 | } |
| 317 | /* We are getting a weird phandle from OF ... */ |
| 318 | /* ... So use the full path instead */ |
| 319 | name = (char *)get_property(of_chosen, "linux,stdout-path", NULL); |
| 320 | if (name == NULL) { |
| 321 | DBG(" no linux,stdout-path !\n"); |
| 322 | return -ENODEV; |
| 323 | } |
| 324 | prom_stdout = of_find_node_by_path(name); |
| 325 | if (!prom_stdout) { |
| 326 | DBG(" can't find stdout package %s !\n", name); |
| 327 | return -ENODEV; |
| 328 | } |
| 329 | DBG("stdout is %s\n", prom_stdout->full_name); |
| 330 | |
| 331 | name = (char *)get_property(prom_stdout, "name", NULL); |
| 332 | if (!name) { |
| 333 | DBG(" stdout package has no name !\n"); |
| 334 | goto not_found; |
| 335 | } |
| 336 | spd = (u32 *)get_property(prom_stdout, "current-speed", NULL); |
| 337 | |
| 338 | if (0) |
| 339 | ; |
| 340 | #ifdef CONFIG_SERIAL_8250_CONSOLE |
| 341 | else if (strcmp(name, "serial") == 0) { |
| 342 | int i; |
| 343 | u32 *reg = (u32 *)get_property(prom_stdout, "reg", &i); |
| 344 | if (i > 8) { |
| 345 | switch (reg[1]) { |
| 346 | case 0x3f8: |
| 347 | offset = 0; |
| 348 | break; |
| 349 | case 0x2f8: |
| 350 | offset = 1; |
| 351 | break; |
| 352 | case 0x898: |
| 353 | offset = 2; |
| 354 | break; |
| 355 | case 0x890: |
| 356 | offset = 3; |
| 357 | break; |
| 358 | default: |
| 359 | /* We dont recognise the serial port */ |
| 360 | goto not_found; |
| 361 | } |
| 362 | } |
| 363 | } |
| 364 | #endif /* CONFIG_SERIAL_8250_CONSOLE */ |
| 365 | #ifdef CONFIG_PPC_PSERIES |
| 366 | else if (strcmp(name, "vty") == 0) { |
| 367 | u32 *reg = (u32 *)get_property(prom_stdout, "reg", NULL); |
| 368 | char *compat = (char *)get_property(prom_stdout, "compatible", NULL); |
| 369 | |
| 370 | if (reg && compat && (strcmp(compat, "hvterm-protocol") == 0)) { |
| 371 | /* Host Virtual Serial Interface */ |
Paul Mackerras | 03501da | 2005-10-26 17:11:18 +1000 | [diff] [blame] | 372 | switch (reg[0]) { |
| 373 | case 0x30000000: |
| 374 | offset = 0; |
| 375 | break; |
| 376 | case 0x30000001: |
| 377 | offset = 1; |
| 378 | break; |
| 379 | default: |
| 380 | goto not_found; |
| 381 | } |
| 382 | of_node_put(prom_stdout); |
| 383 | DBG("Found hvsi console at offset %d\n", offset); |
| 384 | return add_preferred_console("hvsi", offset, NULL); |
| 385 | } else { |
| 386 | /* pSeries LPAR virtual console */ |
| 387 | of_node_put(prom_stdout); |
| 388 | DBG("Found hvc console\n"); |
| 389 | return add_preferred_console("hvc", 0, NULL); |
| 390 | } |
| 391 | } |
| 392 | #endif /* CONFIG_PPC_PSERIES */ |
| 393 | #ifdef CONFIG_SERIAL_PMACZILOG_CONSOLE |
| 394 | else if (strcmp(name, "ch-a") == 0) |
| 395 | offset = 0; |
| 396 | else if (strcmp(name, "ch-b") == 0) |
| 397 | offset = 1; |
| 398 | #endif /* CONFIG_SERIAL_PMACZILOG_CONSOLE */ |
| 399 | else |
| 400 | goto not_found; |
| 401 | of_node_put(prom_stdout); |
| 402 | |
| 403 | DBG("Found serial console at ttyS%d\n", offset); |
| 404 | |
| 405 | if (spd) { |
| 406 | static char __initdata opt[16]; |
| 407 | sprintf(opt, "%d", *spd); |
| 408 | return add_preferred_console("ttyS", offset, opt); |
| 409 | } else |
| 410 | return add_preferred_console("ttyS", offset, NULL); |
| 411 | |
| 412 | not_found: |
| 413 | DBG("No preferred console found !\n"); |
| 414 | of_node_put(prom_stdout); |
| 415 | return -ENODEV; |
| 416 | } |
| 417 | console_initcall(set_preferred_console); |
| 418 | #endif /* CONFIG_PPC_MULTIPLATFORM */ |
Paul Mackerras | 5ad5707 | 2005-11-05 10:33:55 +1100 | [diff] [blame] | 419 | |
David Woodhouse | a82765b | 2005-11-02 22:34:20 +0000 | [diff] [blame] | 420 | void __init check_for_initrd(void) |
| 421 | { |
| 422 | #ifdef CONFIG_BLK_DEV_INITRD |
| 423 | unsigned long *prop; |
| 424 | |
| 425 | DBG(" -> check_for_initrd()\n"); |
| 426 | |
| 427 | if (of_chosen) { |
| 428 | prop = (unsigned long *)get_property(of_chosen, |
| 429 | "linux,initrd-start", NULL); |
| 430 | if (prop != NULL) { |
| 431 | initrd_start = (unsigned long)__va(*prop); |
| 432 | prop = (unsigned long *)get_property(of_chosen, |
| 433 | "linux,initrd-end", NULL); |
| 434 | if (prop != NULL) { |
| 435 | initrd_end = (unsigned long)__va(*prop); |
| 436 | initrd_below_start_ok = 1; |
| 437 | } else |
| 438 | initrd_start = 0; |
| 439 | } |
| 440 | } |
| 441 | |
| 442 | /* If we were passed an initrd, set the ROOT_DEV properly if the values |
| 443 | * look sensible. If not, clear initrd reference. |
| 444 | */ |
| 445 | if (initrd_start >= KERNELBASE && initrd_end >= KERNELBASE && |
| 446 | initrd_end > initrd_start) |
| 447 | ROOT_DEV = Root_RAM0; |
David Woodhouse | 6761c4a | 2005-11-11 08:07:11 +0000 | [diff] [blame] | 448 | else |
David Woodhouse | a82765b | 2005-11-02 22:34:20 +0000 | [diff] [blame] | 449 | initrd_start = initrd_end = 0; |
David Woodhouse | a82765b | 2005-11-02 22:34:20 +0000 | [diff] [blame] | 450 | |
| 451 | if (initrd_start) |
| 452 | printk("Found initrd at 0x%lx:0x%lx\n", initrd_start, initrd_end); |
| 453 | |
| 454 | DBG(" <- check_for_initrd()\n"); |
| 455 | #endif /* CONFIG_BLK_DEV_INITRD */ |
| 456 | } |
| 457 | |
Paul Mackerras | 5ad5707 | 2005-11-05 10:33:55 +1100 | [diff] [blame] | 458 | #ifdef CONFIG_SMP |
| 459 | |
| 460 | /** |
| 461 | * setup_cpu_maps - initialize the following cpu maps: |
| 462 | * cpu_possible_map |
| 463 | * cpu_present_map |
| 464 | * cpu_sibling_map |
| 465 | * |
| 466 | * Having the possible map set up early allows us to restrict allocations |
| 467 | * of things like irqstacks to num_possible_cpus() rather than NR_CPUS. |
| 468 | * |
| 469 | * We do not initialize the online map here; cpus set their own bits in |
| 470 | * cpu_online_map as they come up. |
| 471 | * |
| 472 | * This function is valid only for Open Firmware systems. finish_device_tree |
| 473 | * must be called before using this. |
| 474 | * |
| 475 | * While we're here, we may as well set the "physical" cpu ids in the paca. |
| 476 | */ |
| 477 | void __init smp_setup_cpu_maps(void) |
| 478 | { |
| 479 | struct device_node *dn = NULL; |
| 480 | int cpu = 0; |
| 481 | int swap_cpuid = 0; |
| 482 | |
| 483 | while ((dn = of_find_node_by_type(dn, "cpu")) && cpu < NR_CPUS) { |
| 484 | int *intserv; |
| 485 | int j, len = sizeof(u32), nthreads = 1; |
| 486 | |
| 487 | intserv = (int *)get_property(dn, "ibm,ppc-interrupt-server#s", |
| 488 | &len); |
| 489 | if (intserv) |
| 490 | nthreads = len / sizeof(int); |
| 491 | else { |
| 492 | intserv = (int *) get_property(dn, "reg", NULL); |
| 493 | if (!intserv) |
| 494 | intserv = &cpu; /* assume logical == phys */ |
| 495 | } |
| 496 | |
| 497 | for (j = 0; j < nthreads && cpu < NR_CPUS; j++) { |
| 498 | cpu_set(cpu, cpu_present_map); |
| 499 | set_hard_smp_processor_id(cpu, intserv[j]); |
| 500 | |
| 501 | if (intserv[j] == boot_cpuid_phys) |
| 502 | swap_cpuid = cpu; |
| 503 | cpu_set(cpu, cpu_possible_map); |
| 504 | cpu++; |
| 505 | } |
| 506 | } |
| 507 | |
| 508 | /* Swap CPU id 0 with boot_cpuid_phys, so we can always assume that |
| 509 | * boot cpu is logical 0. |
| 510 | */ |
| 511 | if (boot_cpuid_phys != get_hard_smp_processor_id(0)) { |
| 512 | u32 tmp; |
| 513 | tmp = get_hard_smp_processor_id(0); |
| 514 | set_hard_smp_processor_id(0, boot_cpuid_phys); |
| 515 | set_hard_smp_processor_id(swap_cpuid, tmp); |
| 516 | } |
| 517 | |
| 518 | #ifdef CONFIG_PPC64 |
| 519 | /* |
| 520 | * On pSeries LPAR, we need to know how many cpus |
| 521 | * could possibly be added to this partition. |
| 522 | */ |
Paul Mackerras | 799d604 | 2005-11-10 13:37:51 +1100 | [diff] [blame] | 523 | if (_machine == PLATFORM_PSERIES_LPAR && |
| 524 | (dn = of_find_node_by_path("/rtas"))) { |
Paul Mackerras | 5ad5707 | 2005-11-05 10:33:55 +1100 | [diff] [blame] | 525 | int num_addr_cell, num_size_cell, maxcpus; |
| 526 | unsigned int *ireg; |
| 527 | |
| 528 | num_addr_cell = prom_n_addr_cells(dn); |
| 529 | num_size_cell = prom_n_size_cells(dn); |
| 530 | |
| 531 | ireg = (unsigned int *) |
| 532 | get_property(dn, "ibm,lrdr-capacity", NULL); |
| 533 | |
| 534 | if (!ireg) |
| 535 | goto out; |
| 536 | |
| 537 | maxcpus = ireg[num_addr_cell + num_size_cell]; |
| 538 | |
| 539 | /* Double maxcpus for processors which have SMT capability */ |
| 540 | if (cpu_has_feature(CPU_FTR_SMT)) |
| 541 | maxcpus *= 2; |
| 542 | |
| 543 | if (maxcpus > NR_CPUS) { |
| 544 | printk(KERN_WARNING |
| 545 | "Partition configured for %d cpus, " |
| 546 | "operating system maximum is %d.\n", |
| 547 | maxcpus, NR_CPUS); |
| 548 | maxcpus = NR_CPUS; |
| 549 | } else |
| 550 | printk(KERN_INFO "Partition configured for %d cpus.\n", |
| 551 | maxcpus); |
| 552 | |
| 553 | for (cpu = 0; cpu < maxcpus; cpu++) |
| 554 | cpu_set(cpu, cpu_possible_map); |
| 555 | out: |
| 556 | of_node_put(dn); |
| 557 | } |
| 558 | |
| 559 | /* |
| 560 | * Do the sibling map; assume only two threads per processor. |
| 561 | */ |
| 562 | for_each_cpu(cpu) { |
| 563 | cpu_set(cpu, cpu_sibling_map[cpu]); |
| 564 | if (cpu_has_feature(CPU_FTR_SMT)) |
| 565 | cpu_set(cpu ^ 0x1, cpu_sibling_map[cpu]); |
| 566 | } |
| 567 | |
Benjamin Herrenschmidt | a7f290d | 2005-11-11 21:15:21 +1100 | [diff] [blame] | 568 | vdso_data->processorCount = num_present_cpus(); |
Paul Mackerras | 5ad5707 | 2005-11-05 10:33:55 +1100 | [diff] [blame] | 569 | #endif /* CONFIG_PPC64 */ |
| 570 | } |
| 571 | #endif /* CONFIG_SMP */ |
Paul Mackerras | fca5dcd | 2005-11-08 22:55:08 +1100 | [diff] [blame] | 572 | |
| 573 | #ifdef CONFIG_XMON |
| 574 | static int __init early_xmon(char *p) |
| 575 | { |
| 576 | /* ensure xmon is enabled */ |
| 577 | if (p) { |
| 578 | if (strncmp(p, "on", 2) == 0) |
| 579 | xmon_init(1); |
| 580 | if (strncmp(p, "off", 3) == 0) |
| 581 | xmon_init(0); |
| 582 | if (strncmp(p, "early", 5) != 0) |
| 583 | return 0; |
| 584 | } |
| 585 | xmon_init(1); |
| 586 | debugger(NULL); |
| 587 | |
| 588 | return 0; |
| 589 | } |
| 590 | early_param("xmon", early_xmon); |
| 591 | #endif |