setup.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708
  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. #include <linux/errno.h>
  8. #include <linux/sched.h>
  9. #include <linux/kernel.h>
  10. #include <linux/mm.h>
  11. #include <linux/stddef.h>
  12. #include <linux/unistd.h>
  13. #include <linux/ptrace.h>
  14. #include <linux/slab.h>
  15. #include <asm/smp.h>
  16. #include <linux/user.h>
  17. #include <linux/a.out.h>
  18. #include <linux/tty.h>
  19. #include <linux/delay.h>
  20. #include <linux/config.h>
  21. #include <linux/fs.h>
  22. #include <linux/seq_file.h>
  23. #include <linux/syscalls.h>
  24. #include <linux/kdev_t.h>
  25. #include <linux/major.h>
  26. #include <linux/string.h>
  27. #include <linux/init.h>
  28. #include <linux/inet.h>
  29. #include <linux/console.h>
  30. #include <linux/root_dev.h>
  31. #include <linux/interrupt.h>
  32. #include <linux/cpu.h>
  33. #include <linux/initrd.h>
  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>
  48. #ifdef CONFIG_IP_PNP
  49. #include <net/ipconfig.h>
  50. #endif
  51. struct screen_info screen_info = {
  52. 0, 0, /* orig-x, orig-y */
  53. 0, /* unused */
  54. 0, /* orig-video-page */
  55. 0, /* orig-video-mode */
  56. 128, /* orig-video-cols */
  57. 0, 0, 0, /* unused, ega_bx, unused */
  58. 54, /* orig-video-lines */
  59. 0, /* orig-video-isVGA */
  60. 16 /* orig-video-points */
  61. };
  62. /* Typing sync at the prom prompt calls the function pointed to by
  63. * the sync callback 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.
  66. */
  67. void (*prom_palette)(int);
  68. void (*prom_keyboard)(void);
  69. static void
  70. prom_console_write(struct console *con, const char *s, unsigned n)
  71. {
  72. prom_write(s, n);
  73. }
  74. static struct console prom_console = {
  75. .name = "prom",
  76. .write = prom_console_write,
  77. .flags = CON_CONSDEV | CON_ENABLED,
  78. .index = -1,
  79. };
  80. #define PROM_TRUE -1
  81. #define PROM_FALSE 0
  82. /* Pretty sick eh? */
  83. int prom_callback(long *args)
  84. {
  85. struct console *cons, *saved_console = NULL;
  86. unsigned long flags;
  87. char *cmd;
  88. extern spinlock_t prom_entry_lock;
  89. if (!args)
  90. return -1;
  91. if (!(cmd = (char *)args[0]))
  92. return -1;
  93. /*
  94. * The callback can be invoked on the cpu that first dropped
  95. * into prom_cmdline after taking the serial interrupt, or on
  96. * a slave processor that was smp_captured() if the
  97. * administrator has done a switch-cpu inside obp. In either
  98. * case, the cpu is marked as in-interrupt. Drop IRQ locks.
  99. */
  100. irq_exit();
  101. /* XXX Revisit the locking here someday. This is a debugging
  102. * XXX feature so it isnt all that critical. -DaveM
  103. */
  104. local_irq_save(flags);
  105. spin_unlock(&prom_entry_lock);
  106. cons = console_drivers;
  107. while (cons) {
  108. unregister_console(cons);
  109. cons->flags &= ~(CON_PRINTBUFFER);
  110. cons->next = saved_console;
  111. saved_console = cons;
  112. cons = console_drivers;
  113. }
  114. register_console(&prom_console);
  115. if (!strcmp(cmd, "sync")) {
  116. prom_printf("PROM `%s' command...\n", cmd);
  117. show_free_areas();
  118. if (current->pid != 0) {
  119. local_irq_enable();
  120. sys_sync();
  121. local_irq_disable();
  122. }
  123. args[2] = 0;
  124. args[args[1] + 3] = -1;
  125. prom_printf("Returning to PROM\n");
  126. } else if (!strcmp(cmd, "va>tte-data")) {
  127. unsigned long ctx, va;
  128. unsigned long tte = 0;
  129. long res = PROM_FALSE;
  130. ctx = args[3];
  131. va = args[4];
  132. if (ctx) {
  133. /*
  134. * Find process owning ctx, lookup mapping.
  135. */
  136. struct task_struct *p;
  137. struct mm_struct *mm = NULL;
  138. pgd_t *pgdp;
  139. pud_t *pudp;
  140. pmd_t *pmdp;
  141. pte_t *ptep;
  142. pte_t pte;
  143. for_each_process(p) {
  144. mm = p->mm;
  145. if (CTX_NRBITS(mm->context) == ctx)
  146. break;
  147. }
  148. if (!mm ||
  149. CTX_NRBITS(mm->context) != ctx)
  150. goto done;
  151. pgdp = pgd_offset(mm, va);
  152. if (pgd_none(*pgdp))
  153. goto done;
  154. pudp = pud_offset(pgdp, va);
  155. if (pud_none(*pudp))
  156. goto done;
  157. pmdp = pmd_offset(pudp, va);
  158. if (pmd_none(*pmdp))
  159. goto done;
  160. /* Preemption implicitly disabled by virtue of
  161. * being called from inside OBP.
  162. */
  163. ptep = pte_offset_map(pmdp, va);
  164. pte = *ptep;
  165. if (pte_present(pte)) {
  166. tte = pte_val(pte);
  167. res = PROM_TRUE;
  168. }
  169. pte_unmap(ptep);
  170. goto done;
  171. }
  172. if ((va >= KERNBASE) && (va < (KERNBASE + (4 * 1024 * 1024)))) {
  173. extern unsigned long sparc64_kern_pri_context;
  174. /* Spitfire Errata #32 workaround */
  175. __asm__ __volatile__("stxa %0, [%1] %2\n\t"
  176. "flush %%g6"
  177. : /* No outputs */
  178. : "r" (sparc64_kern_pri_context),
  179. "r" (PRIMARY_CONTEXT),
  180. "i" (ASI_DMMU));
  181. /*
  182. * Locked down tlb entry.
  183. */
  184. if (tlb_type == spitfire)
  185. tte = spitfire_get_dtlb_data(SPITFIRE_HIGHEST_LOCKED_TLBENT);
  186. else if (tlb_type == cheetah || tlb_type == cheetah_plus)
  187. tte = cheetah_get_ldtlb_data(CHEETAH_HIGHEST_LOCKED_TLBENT);
  188. res = PROM_TRUE;
  189. goto done;
  190. }
  191. if (va < PGDIR_SIZE) {
  192. /*
  193. * vmalloc or prom_inherited mapping.
  194. */
  195. pgd_t *pgdp;
  196. pud_t *pudp;
  197. pmd_t *pmdp;
  198. pte_t *ptep;
  199. pte_t pte;
  200. int error;
  201. if ((va >= LOW_OBP_ADDRESS) && (va < HI_OBP_ADDRESS)) {
  202. tte = prom_virt_to_phys(va, &error);
  203. if (!error)
  204. res = PROM_TRUE;
  205. goto done;
  206. }
  207. pgdp = pgd_offset_k(va);
  208. if (pgd_none(*pgdp))
  209. goto done;
  210. pudp = pud_offset(pgdp, va);
  211. if (pud_none(*pudp))
  212. goto done;
  213. pmdp = pmd_offset(pudp, va);
  214. if (pmd_none(*pmdp))
  215. goto done;
  216. /* Preemption implicitly disabled by virtue of
  217. * being called from inside OBP.
  218. */
  219. ptep = pte_offset_kernel(pmdp, va);
  220. pte = *ptep;
  221. if (pte_present(pte)) {
  222. tte = pte_val(pte);
  223. res = PROM_TRUE;
  224. }
  225. goto done;
  226. }
  227. if (va < PAGE_OFFSET) {
  228. /*
  229. * No mappings here.
  230. */
  231. goto done;
  232. }
  233. if (va & (1UL << 40)) {
  234. /*
  235. * I/O page.
  236. */
  237. tte = (__pa(va) & _PAGE_PADDR) |
  238. _PAGE_VALID | _PAGE_SZ4MB |
  239. _PAGE_E | _PAGE_P | _PAGE_W;
  240. res = PROM_TRUE;
  241. goto done;
  242. }
  243. /*
  244. * Normal page.
  245. */
  246. tte = (__pa(va) & _PAGE_PADDR) |
  247. _PAGE_VALID | _PAGE_SZ4MB |
  248. _PAGE_CP | _PAGE_CV | _PAGE_P | _PAGE_W;
  249. res = PROM_TRUE;
  250. done:
  251. if (res == PROM_TRUE) {
  252. args[2] = 3;
  253. args[args[1] + 3] = 0;
  254. args[args[1] + 4] = res;
  255. args[args[1] + 5] = tte;
  256. } else {
  257. args[2] = 2;
  258. args[args[1] + 3] = 0;
  259. args[args[1] + 4] = res;
  260. }
  261. } else if (!strcmp(cmd, ".soft1")) {
  262. unsigned long tte;
  263. tte = args[3];
  264. prom_printf("%lx:\"%s%s%s%s%s\" ",
  265. (tte & _PAGE_SOFT) >> 7,
  266. tte & _PAGE_MODIFIED ? "M" : "-",
  267. tte & _PAGE_ACCESSED ? "A" : "-",
  268. tte & _PAGE_READ ? "W" : "-",
  269. tte & _PAGE_WRITE ? "R" : "-",
  270. tte & _PAGE_PRESENT ? "P" : "-");
  271. args[2] = 2;
  272. args[args[1] + 3] = 0;
  273. args[args[1] + 4] = PROM_TRUE;
  274. } else if (!strcmp(cmd, ".soft2")) {
  275. unsigned long tte;
  276. tte = args[3];
  277. prom_printf("%lx ", (tte & 0x07FC000000000000UL) >> 50);
  278. args[2] = 2;
  279. args[args[1] + 3] = 0;
  280. args[args[1] + 4] = PROM_TRUE;
  281. } else {
  282. prom_printf("unknown PROM `%s' command...\n", cmd);
  283. }
  284. unregister_console(&prom_console);
  285. while (saved_console) {
  286. cons = saved_console;
  287. saved_console = cons->next;
  288. register_console(cons);
  289. }
  290. spin_lock(&prom_entry_lock);
  291. local_irq_restore(flags);
  292. /*
  293. * Restore in-interrupt status for a resume from obp.
  294. */
  295. irq_enter();
  296. return 0;
  297. }
  298. unsigned int boot_flags = 0;
  299. #define BOOTME_DEBUG 0x1
  300. #define BOOTME_SINGLE 0x2
  301. /* Exported for mm/init.c:paging_init. */
  302. unsigned long cmdline_memory_size = 0;
  303. static struct console prom_debug_console = {
  304. .name = "debug",
  305. .write = prom_console_write,
  306. .flags = CON_PRINTBUFFER,
  307. .index = -1,
  308. };
  309. /* XXX Implement this at some point... */
  310. void kernel_enter_debugger(void)
  311. {
  312. }
  313. int obp_system_intr(void)
  314. {
  315. if (boot_flags & BOOTME_DEBUG) {
  316. printk("OBP: system interrupted\n");
  317. prom_halt();
  318. return 1;
  319. }
  320. return 0;
  321. }
  322. /*
  323. * Process kernel command line switches that are specific to the
  324. * SPARC or that require special low-level processing.
  325. */
  326. static void __init process_switch(char c)
  327. {
  328. switch (c) {
  329. case 'd':
  330. boot_flags |= BOOTME_DEBUG;
  331. break;
  332. case 's':
  333. boot_flags |= BOOTME_SINGLE;
  334. break;
  335. case 'h':
  336. prom_printf("boot_flags_init: Halt!\n");
  337. prom_halt();
  338. break;
  339. case 'p':
  340. /* Use PROM debug console. */
  341. register_console(&prom_debug_console);
  342. break;
  343. case 'P':
  344. /* Force UltraSPARC-III P-Cache on. */
  345. if (tlb_type != cheetah) {
  346. printk("BOOT: Ignoring P-Cache force option.\n");
  347. break;
  348. }
  349. cheetah_pcache_forced_on = 1;
  350. add_taint(TAINT_MACHINE_CHECK);
  351. cheetah_enable_pcache();
  352. break;
  353. default:
  354. printk("Unknown boot switch (-%c)\n", c);
  355. break;
  356. }
  357. }
  358. static void __init process_console(char *commands)
  359. {
  360. serial_console = 0;
  361. commands += 8;
  362. /* Linux-style serial */
  363. if (!strncmp(commands, "ttyS", 4))
  364. serial_console = simple_strtoul(commands + 4, NULL, 10) + 1;
  365. else if (!strncmp(commands, "tty", 3)) {
  366. char c = *(commands + 3);
  367. /* Solaris-style serial */
  368. if (c == 'a' || c == 'b') {
  369. serial_console = c - 'a' + 1;
  370. prom_printf ("Using /dev/tty%c as console.\n", c);
  371. }
  372. /* else Linux-style fbcon, not serial */
  373. }
  374. #if defined(CONFIG_PROM_CONSOLE)
  375. if (!strncmp(commands, "prom", 4)) {
  376. char *p;
  377. for (p = commands - 8; *p && *p != ' '; p++)
  378. *p = ' ';
  379. conswitchp = &prom_con;
  380. }
  381. #endif
  382. }
  383. static void __init boot_flags_init(char *commands)
  384. {
  385. while (*commands) {
  386. /* Move to the start of the next "argument". */
  387. while (*commands && *commands == ' ')
  388. commands++;
  389. /* Process any command switches, otherwise skip it. */
  390. if (*commands == '\0')
  391. break;
  392. if (*commands == '-') {
  393. commands++;
  394. while (*commands && *commands != ' ')
  395. process_switch(*commands++);
  396. continue;
  397. }
  398. if (!strncmp(commands, "console=", 8)) {
  399. process_console(commands);
  400. } else if (!strncmp(commands, "mem=", 4)) {
  401. /*
  402. * "mem=XXX[kKmM]" overrides the PROM-reported
  403. * memory size.
  404. */
  405. cmdline_memory_size = simple_strtoul(commands + 4,
  406. &commands, 0);
  407. if (*commands == 'K' || *commands == 'k') {
  408. cmdline_memory_size <<= 10;
  409. commands++;
  410. } else if (*commands=='M' || *commands=='m') {
  411. cmdline_memory_size <<= 20;
  412. commands++;
  413. }
  414. }
  415. while (*commands && *commands != ' ')
  416. commands++;
  417. }
  418. }
  419. extern void panic_setup(char *, int *);
  420. extern unsigned short root_flags;
  421. extern unsigned short root_dev;
  422. extern unsigned short ram_flags;
  423. #define RAMDISK_IMAGE_START_MASK 0x07FF
  424. #define RAMDISK_PROMPT_FLAG 0x8000
  425. #define RAMDISK_LOAD_FLAG 0x4000
  426. extern int root_mountflags;
  427. char reboot_command[COMMAND_LINE_SIZE];
  428. static struct pt_regs fake_swapper_regs = { { 0, }, 0, 0, 0, 0 };
  429. void register_prom_callbacks(void)
  430. {
  431. prom_setcallback(prom_callback);
  432. prom_feval(": linux-va>tte-data 2 \" va>tte-data\" $callback drop ; "
  433. "' linux-va>tte-data to va>tte-data");
  434. prom_feval(": linux-.soft1 1 \" .soft1\" $callback 2drop ; "
  435. "' linux-.soft1 to .soft1");
  436. prom_feval(": linux-.soft2 1 \" .soft2\" $callback 2drop ; "
  437. "' linux-.soft2 to .soft2");
  438. }
  439. void __init setup_arch(char **cmdline_p)
  440. {
  441. /* Initialize PROM console and command line. */
  442. *cmdline_p = prom_getbootargs();
  443. strcpy(saved_command_line, *cmdline_p);
  444. printk("ARCH: SUN4U\n");
  445. #ifdef CONFIG_DUMMY_CONSOLE
  446. conswitchp = &dummy_con;
  447. #elif defined(CONFIG_PROM_CONSOLE)
  448. conswitchp = &prom_con;
  449. #endif
  450. /* Work out if we are starfire early on */
  451. check_if_starfire();
  452. boot_flags_init(*cmdline_p);
  453. idprom_init();
  454. if (!root_flags)
  455. root_mountflags &= ~MS_RDONLY;
  456. ROOT_DEV = old_decode_dev(root_dev);
  457. #ifdef CONFIG_BLK_DEV_INITRD
  458. rd_image_start = ram_flags & RAMDISK_IMAGE_START_MASK;
  459. rd_prompt = ((ram_flags & RAMDISK_PROMPT_FLAG) != 0);
  460. rd_doload = ((ram_flags & RAMDISK_LOAD_FLAG) != 0);
  461. #endif
  462. task_thread_info(&init_task)->kregs = &fake_swapper_regs;
  463. #ifdef CONFIG_IP_PNP
  464. if (!ic_set_manually) {
  465. int chosen = prom_finddevice ("/chosen");
  466. u32 cl, sv, gw;
  467. cl = prom_getintdefault (chosen, "client-ip", 0);
  468. sv = prom_getintdefault (chosen, "server-ip", 0);
  469. gw = prom_getintdefault (chosen, "gateway-ip", 0);
  470. if (cl && sv) {
  471. ic_myaddr = cl;
  472. ic_servaddr = sv;
  473. if (gw)
  474. ic_gateway = gw;
  475. #if defined(CONFIG_IP_PNP_BOOTP) || defined(CONFIG_IP_PNP_RARP)
  476. ic_proto_enabled = 0;
  477. #endif
  478. }
  479. }
  480. #endif
  481. paging_init();
  482. }
  483. static int __init set_preferred_console(void)
  484. {
  485. int idev, odev;
  486. /* The user has requested a console so this is already set up. */
  487. if (serial_console >= 0)
  488. return -EBUSY;
  489. idev = prom_query_input_device();
  490. odev = prom_query_output_device();
  491. if (idev == PROMDEV_IKBD && odev == PROMDEV_OSCREEN) {
  492. serial_console = 0;
  493. } else if (idev == PROMDEV_ITTYA && odev == PROMDEV_OTTYA) {
  494. serial_console = 1;
  495. } else if (idev == PROMDEV_ITTYB && odev == PROMDEV_OTTYB) {
  496. serial_console = 2;
  497. } else if (idev == PROMDEV_IRSC && odev == PROMDEV_ORSC) {
  498. serial_console = 3;
  499. } else {
  500. prom_printf("Inconsistent console: "
  501. "input %d, output %d\n",
  502. idev, odev);
  503. prom_halt();
  504. }
  505. if (serial_console)
  506. return add_preferred_console("ttyS", serial_console - 1, NULL);
  507. return -ENODEV;
  508. }
  509. console_initcall(set_preferred_console);
  510. /* BUFFER is PAGE_SIZE bytes long. */
  511. extern char *sparc_cpu_type;
  512. extern char *sparc_fpu_type;
  513. extern void smp_info(struct seq_file *);
  514. extern void smp_bogo(struct seq_file *);
  515. extern void mmu_info(struct seq_file *);
  516. unsigned int dcache_parity_tl1_occurred;
  517. unsigned int icache_parity_tl1_occurred;
  518. static int ncpus_probed;
  519. static int show_cpuinfo(struct seq_file *m, void *__unused)
  520. {
  521. seq_printf(m,
  522. "cpu\t\t: %s\n"
  523. "fpu\t\t: %s\n"
  524. "promlib\t\t: Version 3 Revision %d\n"
  525. "prom\t\t: %d.%d.%d\n"
  526. "type\t\t: sun4u\n"
  527. "ncpus probed\t: %d\n"
  528. "ncpus active\t: %d\n"
  529. "D$ parity tl1\t: %u\n"
  530. "I$ parity tl1\t: %u\n"
  531. #ifndef CONFIG_SMP
  532. "Cpu0Bogo\t: %lu.%02lu\n"
  533. "Cpu0ClkTck\t: %016lx\n"
  534. #endif
  535. ,
  536. sparc_cpu_type,
  537. sparc_fpu_type,
  538. prom_rev,
  539. prom_prev >> 16,
  540. (prom_prev >> 8) & 0xff,
  541. prom_prev & 0xff,
  542. ncpus_probed,
  543. num_online_cpus(),
  544. dcache_parity_tl1_occurred,
  545. icache_parity_tl1_occurred
  546. #ifndef CONFIG_SMP
  547. , cpu_data(0).udelay_val/(500000/HZ),
  548. (cpu_data(0).udelay_val/(5000/HZ)) % 100,
  549. cpu_data(0).clock_tick
  550. #endif
  551. );
  552. #ifdef CONFIG_SMP
  553. smp_bogo(m);
  554. #endif
  555. mmu_info(m);
  556. #ifdef CONFIG_SMP
  557. smp_info(m);
  558. #endif
  559. return 0;
  560. }
  561. static void *c_start(struct seq_file *m, loff_t *pos)
  562. {
  563. /* The pointer we are returning is arbitrary,
  564. * it just has to be non-NULL and not IS_ERR
  565. * in the success case.
  566. */
  567. return *pos == 0 ? &c_start : NULL;
  568. }
  569. static void *c_next(struct seq_file *m, void *v, loff_t *pos)
  570. {
  571. ++*pos;
  572. return c_start(m, pos);
  573. }
  574. static void c_stop(struct seq_file *m, void *v)
  575. {
  576. }
  577. struct seq_operations cpuinfo_op = {
  578. .start =c_start,
  579. .next = c_next,
  580. .stop = c_stop,
  581. .show = show_cpuinfo,
  582. };
  583. extern int stop_a_enabled;
  584. void sun_do_break(void)
  585. {
  586. if (!stop_a_enabled)
  587. return;
  588. prom_printf("\n");
  589. flush_user_windows();
  590. prom_cmdline();
  591. }
  592. int serial_console = -1;
  593. int stop_a_enabled = 1;
  594. static int __init topology_init(void)
  595. {
  596. int i, err;
  597. err = -ENOMEM;
  598. /* Count the number of physically present processors in
  599. * the machine, even on uniprocessor, so that /proc/cpuinfo
  600. * output is consistent with 2.4.x
  601. */
  602. ncpus_probed = 0;
  603. while (!cpu_find_by_instance(ncpus_probed, NULL, NULL))
  604. ncpus_probed++;
  605. for (i = 0; i < NR_CPUS; i++) {
  606. if (cpu_possible(i)) {
  607. struct cpu *p = kmalloc(sizeof(*p), GFP_KERNEL);
  608. if (p) {
  609. memset(p, 0, sizeof(*p));
  610. register_cpu(p, i, NULL);
  611. err = 0;
  612. }
  613. }
  614. }
  615. return err;
  616. }
  617. subsys_initcall(topology_init);