setup.c 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824
  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. if (tlb_type == spitfire) {
  174. extern unsigned long sparc64_kern_pri_context;
  175. /* Spitfire Errata #32 workaround */
  176. __asm__ __volatile__(
  177. "stxa %0, [%1] %2\n\t"
  178. "flush %%g6"
  179. : /* No outputs */
  180. : "r" (sparc64_kern_pri_context),
  181. "r" (PRIMARY_CONTEXT),
  182. "i" (ASI_DMMU));
  183. }
  184. /*
  185. * Locked down tlb entry.
  186. */
  187. if (tlb_type == spitfire) {
  188. tte = spitfire_get_dtlb_data(SPITFIRE_HIGHEST_LOCKED_TLBENT);
  189. res = PROM_TRUE;
  190. } else if (tlb_type == cheetah || tlb_type == cheetah_plus) {
  191. tte = cheetah_get_ldtlb_data(CHEETAH_HIGHEST_LOCKED_TLBENT);
  192. res = PROM_TRUE;
  193. }
  194. goto done;
  195. }
  196. if (va < PGDIR_SIZE) {
  197. /*
  198. * vmalloc or prom_inherited mapping.
  199. */
  200. pgd_t *pgdp;
  201. pud_t *pudp;
  202. pmd_t *pmdp;
  203. pte_t *ptep;
  204. pte_t pte;
  205. int error;
  206. if ((va >= LOW_OBP_ADDRESS) && (va < HI_OBP_ADDRESS)) {
  207. tte = prom_virt_to_phys(va, &error);
  208. if (!error)
  209. res = PROM_TRUE;
  210. goto done;
  211. }
  212. pgdp = pgd_offset_k(va);
  213. if (pgd_none(*pgdp))
  214. goto done;
  215. pudp = pud_offset(pgdp, va);
  216. if (pud_none(*pudp))
  217. goto done;
  218. pmdp = pmd_offset(pudp, va);
  219. if (pmd_none(*pmdp))
  220. goto done;
  221. /* Preemption implicitly disabled by virtue of
  222. * being called from inside OBP.
  223. */
  224. ptep = pte_offset_kernel(pmdp, va);
  225. pte = *ptep;
  226. if (pte_present(pte)) {
  227. tte = pte_val(pte);
  228. res = PROM_TRUE;
  229. }
  230. goto done;
  231. }
  232. if (va < PAGE_OFFSET) {
  233. /*
  234. * No mappings here.
  235. */
  236. goto done;
  237. }
  238. if (va & (1UL << 40)) {
  239. /*
  240. * I/O page.
  241. */
  242. tte = (__pa(va) & _PAGE_PADDR) |
  243. _PAGE_VALID | _PAGE_SZ4MB |
  244. _PAGE_E | _PAGE_P | _PAGE_W;
  245. res = PROM_TRUE;
  246. goto done;
  247. }
  248. /*
  249. * Normal page.
  250. */
  251. tte = (__pa(va) & _PAGE_PADDR) |
  252. _PAGE_VALID | _PAGE_SZ4MB |
  253. _PAGE_CP | _PAGE_CV | _PAGE_P | _PAGE_W;
  254. res = PROM_TRUE;
  255. done:
  256. if (res == PROM_TRUE) {
  257. args[2] = 3;
  258. args[args[1] + 3] = 0;
  259. args[args[1] + 4] = res;
  260. args[args[1] + 5] = tte;
  261. } else {
  262. args[2] = 2;
  263. args[args[1] + 3] = 0;
  264. args[args[1] + 4] = res;
  265. }
  266. } else if (!strcmp(cmd, ".soft1")) {
  267. unsigned long tte;
  268. tte = args[3];
  269. prom_printf("%lx:\"%s%s%s%s%s\" ",
  270. (tte & _PAGE_SOFT) >> 7,
  271. tte & _PAGE_MODIFIED ? "M" : "-",
  272. tte & _PAGE_ACCESSED ? "A" : "-",
  273. tte & _PAGE_READ ? "W" : "-",
  274. tte & _PAGE_WRITE ? "R" : "-",
  275. tte & _PAGE_PRESENT ? "P" : "-");
  276. args[2] = 2;
  277. args[args[1] + 3] = 0;
  278. args[args[1] + 4] = PROM_TRUE;
  279. } else if (!strcmp(cmd, ".soft2")) {
  280. unsigned long tte;
  281. tte = args[3];
  282. prom_printf("%lx ", (tte & 0x07FC000000000000UL) >> 50);
  283. args[2] = 2;
  284. args[args[1] + 3] = 0;
  285. args[args[1] + 4] = PROM_TRUE;
  286. } else {
  287. prom_printf("unknown PROM `%s' command...\n", cmd);
  288. }
  289. unregister_console(&prom_console);
  290. while (saved_console) {
  291. cons = saved_console;
  292. saved_console = cons->next;
  293. register_console(cons);
  294. }
  295. spin_lock(&prom_entry_lock);
  296. local_irq_restore(flags);
  297. /*
  298. * Restore in-interrupt status for a resume from obp.
  299. */
  300. irq_enter();
  301. return 0;
  302. }
  303. unsigned int boot_flags = 0;
  304. #define BOOTME_DEBUG 0x1
  305. #define BOOTME_SINGLE 0x2
  306. /* Exported for mm/init.c:paging_init. */
  307. unsigned long cmdline_memory_size = 0;
  308. static struct console prom_debug_console = {
  309. .name = "debug",
  310. .write = prom_console_write,
  311. .flags = CON_PRINTBUFFER,
  312. .index = -1,
  313. };
  314. /* XXX Implement this at some point... */
  315. void kernel_enter_debugger(void)
  316. {
  317. }
  318. int obp_system_intr(void)
  319. {
  320. if (boot_flags & BOOTME_DEBUG) {
  321. printk("OBP: system interrupted\n");
  322. prom_halt();
  323. return 1;
  324. }
  325. return 0;
  326. }
  327. /*
  328. * Process kernel command line switches that are specific to the
  329. * SPARC or that require special low-level processing.
  330. */
  331. static void __init process_switch(char c)
  332. {
  333. switch (c) {
  334. case 'd':
  335. boot_flags |= BOOTME_DEBUG;
  336. break;
  337. case 's':
  338. boot_flags |= BOOTME_SINGLE;
  339. break;
  340. case 'h':
  341. prom_printf("boot_flags_init: Halt!\n");
  342. prom_halt();
  343. break;
  344. case 'p':
  345. /* Use PROM debug console. */
  346. register_console(&prom_debug_console);
  347. break;
  348. case 'P':
  349. /* Force UltraSPARC-III P-Cache on. */
  350. if (tlb_type != cheetah) {
  351. printk("BOOT: Ignoring P-Cache force option.\n");
  352. break;
  353. }
  354. cheetah_pcache_forced_on = 1;
  355. add_taint(TAINT_MACHINE_CHECK);
  356. cheetah_enable_pcache();
  357. break;
  358. default:
  359. printk("Unknown boot switch (-%c)\n", c);
  360. break;
  361. }
  362. }
  363. static void __init process_console(char *commands)
  364. {
  365. serial_console = 0;
  366. commands += 8;
  367. /* Linux-style serial */
  368. if (!strncmp(commands, "ttyS", 4))
  369. serial_console = simple_strtoul(commands + 4, NULL, 10) + 1;
  370. else if (!strncmp(commands, "tty", 3)) {
  371. char c = *(commands + 3);
  372. /* Solaris-style serial */
  373. if (c == 'a' || c == 'b') {
  374. serial_console = c - 'a' + 1;
  375. prom_printf ("Using /dev/tty%c as console.\n", c);
  376. }
  377. /* else Linux-style fbcon, not serial */
  378. }
  379. #if defined(CONFIG_PROM_CONSOLE)
  380. if (!strncmp(commands, "prom", 4)) {
  381. char *p;
  382. for (p = commands - 8; *p && *p != ' '; p++)
  383. *p = ' ';
  384. conswitchp = &prom_con;
  385. }
  386. #endif
  387. }
  388. static void __init boot_flags_init(char *commands)
  389. {
  390. while (*commands) {
  391. /* Move to the start of the next "argument". */
  392. while (*commands && *commands == ' ')
  393. commands++;
  394. /* Process any command switches, otherwise skip it. */
  395. if (*commands == '\0')
  396. break;
  397. if (*commands == '-') {
  398. commands++;
  399. while (*commands && *commands != ' ')
  400. process_switch(*commands++);
  401. continue;
  402. }
  403. if (!strncmp(commands, "console=", 8)) {
  404. process_console(commands);
  405. } else if (!strncmp(commands, "mem=", 4)) {
  406. /*
  407. * "mem=XXX[kKmM]" overrides the PROM-reported
  408. * memory size.
  409. */
  410. cmdline_memory_size = simple_strtoul(commands + 4,
  411. &commands, 0);
  412. if (*commands == 'K' || *commands == 'k') {
  413. cmdline_memory_size <<= 10;
  414. commands++;
  415. } else if (*commands=='M' || *commands=='m') {
  416. cmdline_memory_size <<= 20;
  417. commands++;
  418. }
  419. }
  420. while (*commands && *commands != ' ')
  421. commands++;
  422. }
  423. }
  424. extern void panic_setup(char *, int *);
  425. extern unsigned short root_flags;
  426. extern unsigned short root_dev;
  427. extern unsigned short ram_flags;
  428. #define RAMDISK_IMAGE_START_MASK 0x07FF
  429. #define RAMDISK_PROMPT_FLAG 0x8000
  430. #define RAMDISK_LOAD_FLAG 0x4000
  431. extern int root_mountflags;
  432. char reboot_command[COMMAND_LINE_SIZE];
  433. static struct pt_regs fake_swapper_regs = { { 0, }, 0, 0, 0, 0 };
  434. void register_prom_callbacks(void)
  435. {
  436. prom_setcallback(prom_callback);
  437. prom_feval(": linux-va>tte-data 2 \" va>tte-data\" $callback drop ; "
  438. "' linux-va>tte-data to va>tte-data");
  439. prom_feval(": linux-.soft1 1 \" .soft1\" $callback 2drop ; "
  440. "' linux-.soft1 to .soft1");
  441. prom_feval(": linux-.soft2 1 \" .soft2\" $callback 2drop ; "
  442. "' linux-.soft2 to .soft2");
  443. }
  444. static void __init per_cpu_patch(void)
  445. {
  446. #ifdef CONFIG_SMP
  447. struct cpuid_patch_entry *p;
  448. unsigned long ver;
  449. int is_jbus;
  450. if (tlb_type == spitfire && !this_is_starfire)
  451. return;
  452. is_jbus = 0;
  453. if (tlb_type != hypervisor) {
  454. __asm__ ("rdpr %%ver, %0" : "=r" (ver));
  455. is_jbus = ((ver >> 32) == __JALAPENO_ID ||
  456. (ver >> 32) == __SERRANO_ID);
  457. }
  458. p = &__cpuid_patch;
  459. while (p < &__cpuid_patch_end) {
  460. unsigned long addr = p->addr;
  461. unsigned int *insns;
  462. switch (tlb_type) {
  463. case spitfire:
  464. insns = &p->starfire[0];
  465. break;
  466. case cheetah:
  467. case cheetah_plus:
  468. if (is_jbus)
  469. insns = &p->cheetah_jbus[0];
  470. else
  471. insns = &p->cheetah_safari[0];
  472. break;
  473. case hypervisor:
  474. insns = &p->sun4v[0];
  475. break;
  476. default:
  477. prom_printf("Unknown cpu type, halting.\n");
  478. prom_halt();
  479. };
  480. *(unsigned int *) (addr + 0) = insns[0];
  481. wmb();
  482. __asm__ __volatile__("flush %0" : : "r" (addr + 0));
  483. *(unsigned int *) (addr + 4) = insns[1];
  484. wmb();
  485. __asm__ __volatile__("flush %0" : : "r" (addr + 4));
  486. *(unsigned int *) (addr + 8) = insns[2];
  487. wmb();
  488. __asm__ __volatile__("flush %0" : : "r" (addr + 8));
  489. *(unsigned int *) (addr + 12) = insns[3];
  490. wmb();
  491. __asm__ __volatile__("flush %0" : : "r" (addr + 12));
  492. p++;
  493. }
  494. #endif
  495. }
  496. static void __init sun4v_patch(void)
  497. {
  498. struct sun4v_1insn_patch_entry *p1;
  499. struct sun4v_2insn_patch_entry *p2;
  500. if (tlb_type != hypervisor)
  501. return;
  502. p1 = &__sun4v_1insn_patch;
  503. while (p1 < &__sun4v_1insn_patch_end) {
  504. unsigned long addr = p1->addr;
  505. *(unsigned int *) (addr + 0) = p1->insn;
  506. wmb();
  507. __asm__ __volatile__("flush %0" : : "r" (addr + 0));
  508. p1++;
  509. }
  510. p2 = &__sun4v_2insn_patch;
  511. while (p2 < &__sun4v_2insn_patch_end) {
  512. unsigned long addr = p2->addr;
  513. *(unsigned int *) (addr + 0) = p2->insns[0];
  514. wmb();
  515. __asm__ __volatile__("flush %0" : : "r" (addr + 0));
  516. *(unsigned int *) (addr + 4) = p2->insns[1];
  517. wmb();
  518. __asm__ __volatile__("flush %0" : : "r" (addr + 4));
  519. p2++;
  520. }
  521. }
  522. void __init setup_arch(char **cmdline_p)
  523. {
  524. /* Initialize PROM console and command line. */
  525. *cmdline_p = prom_getbootargs();
  526. strcpy(saved_command_line, *cmdline_p);
  527. if (tlb_type == hypervisor)
  528. printk("ARCH: SUN4V\n");
  529. else
  530. printk("ARCH: SUN4U\n");
  531. #ifdef CONFIG_DUMMY_CONSOLE
  532. conswitchp = &dummy_con;
  533. #elif defined(CONFIG_PROM_CONSOLE)
  534. conswitchp = &prom_con;
  535. #endif
  536. /* Work out if we are starfire early on */
  537. check_if_starfire();
  538. /* Now we know enough to patch the get_cpuid sequences
  539. * used by trap code.
  540. */
  541. per_cpu_patch();
  542. sun4v_patch();
  543. boot_flags_init(*cmdline_p);
  544. idprom_init();
  545. if (!root_flags)
  546. root_mountflags &= ~MS_RDONLY;
  547. ROOT_DEV = old_decode_dev(root_dev);
  548. #ifdef CONFIG_BLK_DEV_INITRD
  549. rd_image_start = ram_flags & RAMDISK_IMAGE_START_MASK;
  550. rd_prompt = ((ram_flags & RAMDISK_PROMPT_FLAG) != 0);
  551. rd_doload = ((ram_flags & RAMDISK_LOAD_FLAG) != 0);
  552. #endif
  553. task_thread_info(&init_task)->kregs = &fake_swapper_regs;
  554. #ifdef CONFIG_IP_PNP
  555. if (!ic_set_manually) {
  556. int chosen = prom_finddevice ("/chosen");
  557. u32 cl, sv, gw;
  558. cl = prom_getintdefault (chosen, "client-ip", 0);
  559. sv = prom_getintdefault (chosen, "server-ip", 0);
  560. gw = prom_getintdefault (chosen, "gateway-ip", 0);
  561. if (cl && sv) {
  562. ic_myaddr = cl;
  563. ic_servaddr = sv;
  564. if (gw)
  565. ic_gateway = gw;
  566. #if defined(CONFIG_IP_PNP_BOOTP) || defined(CONFIG_IP_PNP_RARP)
  567. ic_proto_enabled = 0;
  568. #endif
  569. }
  570. }
  571. #endif
  572. smp_setup_cpu_possible_map();
  573. paging_init();
  574. /* Get boot processor trap_block[] setup. */
  575. init_cur_cpu_trap();
  576. }
  577. static int __init set_preferred_console(void)
  578. {
  579. int idev, odev;
  580. /* The user has requested a console so this is already set up. */
  581. if (serial_console >= 0)
  582. return -EBUSY;
  583. idev = prom_query_input_device();
  584. odev = prom_query_output_device();
  585. if (idev == PROMDEV_IKBD && odev == PROMDEV_OSCREEN) {
  586. serial_console = 0;
  587. } else if (idev == PROMDEV_ITTYA && odev == PROMDEV_OTTYA) {
  588. serial_console = 1;
  589. } else if (idev == PROMDEV_ITTYB && odev == PROMDEV_OTTYB) {
  590. serial_console = 2;
  591. } else if (idev == PROMDEV_IRSC && odev == PROMDEV_ORSC) {
  592. serial_console = 3;
  593. } else {
  594. prom_printf("Inconsistent console: "
  595. "input %d, output %d\n",
  596. idev, odev);
  597. prom_halt();
  598. }
  599. if (serial_console)
  600. return add_preferred_console("ttyS", serial_console - 1, NULL);
  601. return -ENODEV;
  602. }
  603. console_initcall(set_preferred_console);
  604. /* BUFFER is PAGE_SIZE bytes long. */
  605. extern char *sparc_cpu_type;
  606. extern char *sparc_fpu_type;
  607. extern void smp_info(struct seq_file *);
  608. extern void smp_bogo(struct seq_file *);
  609. extern void mmu_info(struct seq_file *);
  610. unsigned int dcache_parity_tl1_occurred;
  611. unsigned int icache_parity_tl1_occurred;
  612. static int ncpus_probed;
  613. static int show_cpuinfo(struct seq_file *m, void *__unused)
  614. {
  615. seq_printf(m,
  616. "cpu\t\t: %s\n"
  617. "fpu\t\t: %s\n"
  618. "promlib\t\t: Version 3 Revision %d\n"
  619. "prom\t\t: %d.%d.%d\n"
  620. "type\t\t: sun4u\n"
  621. "ncpus probed\t: %d\n"
  622. "ncpus active\t: %d\n"
  623. "D$ parity tl1\t: %u\n"
  624. "I$ parity tl1\t: %u\n"
  625. #ifndef CONFIG_SMP
  626. "Cpu0Bogo\t: %lu.%02lu\n"
  627. "Cpu0ClkTck\t: %016lx\n"
  628. #endif
  629. ,
  630. sparc_cpu_type,
  631. sparc_fpu_type,
  632. prom_rev,
  633. prom_prev >> 16,
  634. (prom_prev >> 8) & 0xff,
  635. prom_prev & 0xff,
  636. ncpus_probed,
  637. num_online_cpus(),
  638. dcache_parity_tl1_occurred,
  639. icache_parity_tl1_occurred
  640. #ifndef CONFIG_SMP
  641. , cpu_data(0).udelay_val/(500000/HZ),
  642. (cpu_data(0).udelay_val/(5000/HZ)) % 100,
  643. cpu_data(0).clock_tick
  644. #endif
  645. );
  646. #ifdef CONFIG_SMP
  647. smp_bogo(m);
  648. #endif
  649. mmu_info(m);
  650. #ifdef CONFIG_SMP
  651. smp_info(m);
  652. #endif
  653. return 0;
  654. }
  655. static void *c_start(struct seq_file *m, loff_t *pos)
  656. {
  657. /* The pointer we are returning is arbitrary,
  658. * it just has to be non-NULL and not IS_ERR
  659. * in the success case.
  660. */
  661. return *pos == 0 ? &c_start : NULL;
  662. }
  663. static void *c_next(struct seq_file *m, void *v, loff_t *pos)
  664. {
  665. ++*pos;
  666. return c_start(m, pos);
  667. }
  668. static void c_stop(struct seq_file *m, void *v)
  669. {
  670. }
  671. struct seq_operations cpuinfo_op = {
  672. .start =c_start,
  673. .next = c_next,
  674. .stop = c_stop,
  675. .show = show_cpuinfo,
  676. };
  677. extern int stop_a_enabled;
  678. void sun_do_break(void)
  679. {
  680. if (!stop_a_enabled)
  681. return;
  682. prom_printf("\n");
  683. flush_user_windows();
  684. prom_cmdline();
  685. }
  686. int serial_console = -1;
  687. int stop_a_enabled = 1;
  688. static int __init topology_init(void)
  689. {
  690. int i, err;
  691. err = -ENOMEM;
  692. /* Count the number of physically present processors in
  693. * the machine, even on uniprocessor, so that /proc/cpuinfo
  694. * output is consistent with 2.4.x
  695. */
  696. ncpus_probed = 0;
  697. while (!cpu_find_by_instance(ncpus_probed, NULL, NULL))
  698. ncpus_probed++;
  699. for (i = 0; i < NR_CPUS; i++) {
  700. if (cpu_possible(i)) {
  701. struct cpu *p = kmalloc(sizeof(*p), GFP_KERNEL);
  702. if (p) {
  703. memset(p, 0, sizeof(*p));
  704. register_cpu(p, i, NULL);
  705. err = 0;
  706. }
  707. }
  708. }
  709. return err;
  710. }
  711. subsys_initcall(topology_init);