setup.c 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814
  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. static void __init per_cpu_patch(void)
  440. {
  441. #ifdef CONFIG_SMP
  442. struct cpuid_patch_entry *p;
  443. unsigned long ver;
  444. int is_jbus;
  445. if (tlb_type == spitfire && !this_is_starfire)
  446. return;
  447. __asm__ ("rdpr %%ver, %0" : "=r" (ver));
  448. is_jbus = ((ver >> 32) == __JALAPENO_ID ||
  449. (ver >> 32) == __SERRANO_ID);
  450. p = &__cpuid_patch;
  451. while (p < &__cpuid_patch_end) {
  452. unsigned long addr = p->addr;
  453. unsigned int *insns;
  454. switch (tlb_type) {
  455. case spitfire:
  456. insns = &p->starfire[0];
  457. break;
  458. case cheetah:
  459. case cheetah_plus:
  460. if (is_jbus)
  461. insns = &p->cheetah_jbus[0];
  462. else
  463. insns = &p->cheetah_safari[0];
  464. break;
  465. case hypervisor:
  466. insns = &p->sun4v[0];
  467. break;
  468. default:
  469. prom_printf("Unknown cpu type, halting.\n");
  470. prom_halt();
  471. };
  472. *(unsigned int *) (addr + 0) = insns[0];
  473. wmb();
  474. __asm__ __volatile__("flush %0" : : "r" (addr + 0));
  475. *(unsigned int *) (addr + 4) = insns[1];
  476. wmb();
  477. __asm__ __volatile__("flush %0" : : "r" (addr + 4));
  478. *(unsigned int *) (addr + 8) = insns[2];
  479. wmb();
  480. __asm__ __volatile__("flush %0" : : "r" (addr + 8));
  481. *(unsigned int *) (addr + 12) = insns[3];
  482. wmb();
  483. __asm__ __volatile__("flush %0" : : "r" (addr + 12));
  484. p++;
  485. }
  486. #endif
  487. }
  488. static void __init gl_patch(void)
  489. {
  490. struct gl_1insn_patch_entry *p1;
  491. struct gl_2insn_patch_entry *p2;
  492. if (tlb_type != hypervisor)
  493. return;
  494. p1 = &__gl_1insn_patch;
  495. while (p1 < &__gl_1insn_patch_end) {
  496. unsigned long addr = p1->addr;
  497. *(unsigned int *) (addr + 0) = p1->insn;
  498. wmb();
  499. __asm__ __volatile__("flush %0" : : "r" (addr + 0));
  500. p1++;
  501. }
  502. p2 = &__gl_2insn_patch;
  503. while (p2 < &__gl_2insn_patch_end) {
  504. unsigned long addr = p2->addr;
  505. *(unsigned int *) (addr + 0) = p2->insns[0];
  506. wmb();
  507. __asm__ __volatile__("flush %0" : : "r" (addr + 0));
  508. *(unsigned int *) (addr + 3) = p2->insns[1];
  509. wmb();
  510. __asm__ __volatile__("flush %0" : : "r" (addr + 4));
  511. p2++;
  512. }
  513. }
  514. void __init setup_arch(char **cmdline_p)
  515. {
  516. /* Initialize PROM console and command line. */
  517. *cmdline_p = prom_getbootargs();
  518. strcpy(saved_command_line, *cmdline_p);
  519. printk("ARCH: SUN4U\n");
  520. #ifdef CONFIG_DUMMY_CONSOLE
  521. conswitchp = &dummy_con;
  522. #elif defined(CONFIG_PROM_CONSOLE)
  523. conswitchp = &prom_con;
  524. #endif
  525. /* Work out if we are starfire early on */
  526. check_if_starfire();
  527. /* Now we know enough to patch the get_cpuid sequences
  528. * used by trap code.
  529. */
  530. per_cpu_patch();
  531. gl_patch();
  532. boot_flags_init(*cmdline_p);
  533. idprom_init();
  534. if (!root_flags)
  535. root_mountflags &= ~MS_RDONLY;
  536. ROOT_DEV = old_decode_dev(root_dev);
  537. #ifdef CONFIG_BLK_DEV_INITRD
  538. rd_image_start = ram_flags & RAMDISK_IMAGE_START_MASK;
  539. rd_prompt = ((ram_flags & RAMDISK_PROMPT_FLAG) != 0);
  540. rd_doload = ((ram_flags & RAMDISK_LOAD_FLAG) != 0);
  541. #endif
  542. task_thread_info(&init_task)->kregs = &fake_swapper_regs;
  543. #ifdef CONFIG_IP_PNP
  544. if (!ic_set_manually) {
  545. int chosen = prom_finddevice ("/chosen");
  546. u32 cl, sv, gw;
  547. cl = prom_getintdefault (chosen, "client-ip", 0);
  548. sv = prom_getintdefault (chosen, "server-ip", 0);
  549. gw = prom_getintdefault (chosen, "gateway-ip", 0);
  550. if (cl && sv) {
  551. ic_myaddr = cl;
  552. ic_servaddr = sv;
  553. if (gw)
  554. ic_gateway = gw;
  555. #if defined(CONFIG_IP_PNP_BOOTP) || defined(CONFIG_IP_PNP_RARP)
  556. ic_proto_enabled = 0;
  557. #endif
  558. }
  559. }
  560. #endif
  561. smp_setup_cpu_possible_map();
  562. paging_init();
  563. /* Get boot processor trap_block[] setup. */
  564. init_cur_cpu_trap();
  565. }
  566. static int __init set_preferred_console(void)
  567. {
  568. int idev, odev;
  569. /* The user has requested a console so this is already set up. */
  570. if (serial_console >= 0)
  571. return -EBUSY;
  572. idev = prom_query_input_device();
  573. odev = prom_query_output_device();
  574. if (idev == PROMDEV_IKBD && odev == PROMDEV_OSCREEN) {
  575. serial_console = 0;
  576. } else if (idev == PROMDEV_ITTYA && odev == PROMDEV_OTTYA) {
  577. serial_console = 1;
  578. } else if (idev == PROMDEV_ITTYB && odev == PROMDEV_OTTYB) {
  579. serial_console = 2;
  580. } else if (idev == PROMDEV_IRSC && odev == PROMDEV_ORSC) {
  581. serial_console = 3;
  582. } else {
  583. prom_printf("Inconsistent console: "
  584. "input %d, output %d\n",
  585. idev, odev);
  586. prom_halt();
  587. }
  588. if (serial_console)
  589. return add_preferred_console("ttyS", serial_console - 1, NULL);
  590. return -ENODEV;
  591. }
  592. console_initcall(set_preferred_console);
  593. /* BUFFER is PAGE_SIZE bytes long. */
  594. extern char *sparc_cpu_type;
  595. extern char *sparc_fpu_type;
  596. extern void smp_info(struct seq_file *);
  597. extern void smp_bogo(struct seq_file *);
  598. extern void mmu_info(struct seq_file *);
  599. unsigned int dcache_parity_tl1_occurred;
  600. unsigned int icache_parity_tl1_occurred;
  601. static int ncpus_probed;
  602. static int show_cpuinfo(struct seq_file *m, void *__unused)
  603. {
  604. seq_printf(m,
  605. "cpu\t\t: %s\n"
  606. "fpu\t\t: %s\n"
  607. "promlib\t\t: Version 3 Revision %d\n"
  608. "prom\t\t: %d.%d.%d\n"
  609. "type\t\t: sun4u\n"
  610. "ncpus probed\t: %d\n"
  611. "ncpus active\t: %d\n"
  612. "D$ parity tl1\t: %u\n"
  613. "I$ parity tl1\t: %u\n"
  614. #ifndef CONFIG_SMP
  615. "Cpu0Bogo\t: %lu.%02lu\n"
  616. "Cpu0ClkTck\t: %016lx\n"
  617. #endif
  618. ,
  619. sparc_cpu_type,
  620. sparc_fpu_type,
  621. prom_rev,
  622. prom_prev >> 16,
  623. (prom_prev >> 8) & 0xff,
  624. prom_prev & 0xff,
  625. ncpus_probed,
  626. num_online_cpus(),
  627. dcache_parity_tl1_occurred,
  628. icache_parity_tl1_occurred
  629. #ifndef CONFIG_SMP
  630. , cpu_data(0).udelay_val/(500000/HZ),
  631. (cpu_data(0).udelay_val/(5000/HZ)) % 100,
  632. cpu_data(0).clock_tick
  633. #endif
  634. );
  635. #ifdef CONFIG_SMP
  636. smp_bogo(m);
  637. #endif
  638. mmu_info(m);
  639. #ifdef CONFIG_SMP
  640. smp_info(m);
  641. #endif
  642. return 0;
  643. }
  644. static void *c_start(struct seq_file *m, loff_t *pos)
  645. {
  646. /* The pointer we are returning is arbitrary,
  647. * it just has to be non-NULL and not IS_ERR
  648. * in the success case.
  649. */
  650. return *pos == 0 ? &c_start : NULL;
  651. }
  652. static void *c_next(struct seq_file *m, void *v, loff_t *pos)
  653. {
  654. ++*pos;
  655. return c_start(m, pos);
  656. }
  657. static void c_stop(struct seq_file *m, void *v)
  658. {
  659. }
  660. struct seq_operations cpuinfo_op = {
  661. .start =c_start,
  662. .next = c_next,
  663. .stop = c_stop,
  664. .show = show_cpuinfo,
  665. };
  666. extern int stop_a_enabled;
  667. void sun_do_break(void)
  668. {
  669. if (!stop_a_enabled)
  670. return;
  671. prom_printf("\n");
  672. flush_user_windows();
  673. prom_cmdline();
  674. }
  675. int serial_console = -1;
  676. int stop_a_enabled = 1;
  677. static int __init topology_init(void)
  678. {
  679. int i, err;
  680. err = -ENOMEM;
  681. /* Count the number of physically present processors in
  682. * the machine, even on uniprocessor, so that /proc/cpuinfo
  683. * output is consistent with 2.4.x
  684. */
  685. ncpus_probed = 0;
  686. while (!cpu_find_by_instance(ncpus_probed, NULL, NULL))
  687. ncpus_probed++;
  688. for (i = 0; i < NR_CPUS; i++) {
  689. if (cpu_possible(i)) {
  690. struct cpu *p = kmalloc(sizeof(*p), GFP_KERNEL);
  691. if (p) {
  692. memset(p, 0, sizeof(*p));
  693. register_cpu(p, i, NULL);
  694. err = 0;
  695. }
  696. }
  697. }
  698. return err;
  699. }
  700. subsys_initcall(topology_init);