setup.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731
  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/segment.h>
  35. #include <asm/system.h>
  36. #include <asm/io.h>
  37. #include <asm/processor.h>
  38. #include <asm/oplib.h>
  39. #include <asm/page.h>
  40. #include <asm/pgtable.h>
  41. #include <asm/idprom.h>
  42. #include <asm/head.h>
  43. #include <asm/starfire.h>
  44. #include <asm/mmu_context.h>
  45. #include <asm/timer.h>
  46. #include <asm/sections.h>
  47. #include <asm/setup.h>
  48. #include <asm/mmu.h>
  49. #ifdef CONFIG_IP_PNP
  50. #include <net/ipconfig.h>
  51. #endif
  52. struct screen_info screen_info = {
  53. 0, 0, /* orig-x, orig-y */
  54. 0, /* unused */
  55. 0, /* orig-video-page */
  56. 0, /* orig-video-mode */
  57. 128, /* orig-video-cols */
  58. 0, 0, 0, /* unused, ega_bx, unused */
  59. 54, /* orig-video-lines */
  60. 0, /* orig-video-isVGA */
  61. 16 /* orig-video-points */
  62. };
  63. /* Typing sync at the prom prompt calls the function pointed to by
  64. * the sync callback which I set to the following function.
  65. * This should sync all filesystems and return, for now it just
  66. * prints out pretty messages and returns.
  67. */
  68. void (*prom_palette)(int);
  69. void (*prom_keyboard)(void);
  70. static void
  71. prom_console_write(struct console *con, const char *s, unsigned n)
  72. {
  73. prom_write(s, n);
  74. }
  75. static struct console prom_console = {
  76. .name = "prom",
  77. .write = prom_console_write,
  78. .flags = CON_CONSDEV | CON_ENABLED,
  79. .index = -1,
  80. };
  81. #define PROM_TRUE -1
  82. #define PROM_FALSE 0
  83. /* Pretty sick eh? */
  84. int prom_callback(long *args)
  85. {
  86. struct console *cons, *saved_console = NULL;
  87. unsigned long flags;
  88. char *cmd;
  89. extern spinlock_t prom_entry_lock;
  90. if (!args)
  91. return -1;
  92. if (!(cmd = (char *)args[0]))
  93. return -1;
  94. /*
  95. * The callback can be invoked on the cpu that first dropped
  96. * into prom_cmdline after taking the serial interrupt, or on
  97. * a slave processor that was smp_captured() if the
  98. * administrator has done a switch-cpu inside obp. In either
  99. * case, the cpu is marked as in-interrupt. Drop IRQ locks.
  100. */
  101. irq_exit();
  102. /* XXX Revisit the locking here someday. This is a debugging
  103. * XXX feature so it isnt all that critical. -DaveM
  104. */
  105. local_irq_save(flags);
  106. spin_unlock(&prom_entry_lock);
  107. cons = console_drivers;
  108. while (cons) {
  109. unregister_console(cons);
  110. cons->flags &= ~(CON_PRINTBUFFER);
  111. cons->next = saved_console;
  112. saved_console = cons;
  113. cons = console_drivers;
  114. }
  115. register_console(&prom_console);
  116. if (!strcmp(cmd, "sync")) {
  117. prom_printf("PROM `%s' command...\n", cmd);
  118. show_free_areas();
  119. if (current->pid != 0) {
  120. local_irq_enable();
  121. sys_sync();
  122. local_irq_disable();
  123. }
  124. args[2] = 0;
  125. args[args[1] + 3] = -1;
  126. prom_printf("Returning to PROM\n");
  127. } else if (!strcmp(cmd, "va>tte-data")) {
  128. unsigned long ctx, va;
  129. unsigned long tte = 0;
  130. long res = PROM_FALSE;
  131. ctx = args[3];
  132. va = args[4];
  133. if (ctx) {
  134. /*
  135. * Find process owning ctx, lookup mapping.
  136. */
  137. struct task_struct *p;
  138. struct mm_struct *mm = NULL;
  139. pgd_t *pgdp;
  140. pud_t *pudp;
  141. pmd_t *pmdp;
  142. pte_t *ptep;
  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. if (pte_present(*ptep)) {
  165. tte = pte_val(*ptep);
  166. res = PROM_TRUE;
  167. }
  168. pte_unmap(ptep);
  169. goto done;
  170. }
  171. if ((va >= KERNBASE) && (va < (KERNBASE + (4 * 1024 * 1024)))) {
  172. unsigned long kernel_pctx = 0;
  173. if (tlb_type == cheetah_plus)
  174. kernel_pctx |= (CTX_CHEETAH_PLUS_NUC |
  175. CTX_CHEETAH_PLUS_CTX0);
  176. /* Spitfire Errata #32 workaround */
  177. __asm__ __volatile__("stxa %0, [%1] %2\n\t"
  178. "flush %%g6"
  179. : /* No outputs */
  180. : "r" (kernel_pctx),
  181. "r" (PRIMARY_CONTEXT),
  182. "i" (ASI_DMMU));
  183. /*
  184. * Locked down tlb entry.
  185. */
  186. if (tlb_type == spitfire)
  187. tte = spitfire_get_dtlb_data(SPITFIRE_HIGHEST_LOCKED_TLBENT);
  188. else if (tlb_type == cheetah || tlb_type == cheetah_plus)
  189. tte = cheetah_get_ldtlb_data(CHEETAH_HIGHEST_LOCKED_TLBENT);
  190. res = PROM_TRUE;
  191. goto done;
  192. }
  193. if (va < PGDIR_SIZE) {
  194. /*
  195. * vmalloc or prom_inherited mapping.
  196. */
  197. pgd_t *pgdp;
  198. pud_t *pudp;
  199. pmd_t *pmdp;
  200. pte_t *ptep;
  201. int error;
  202. if ((va >= LOW_OBP_ADDRESS) && (va < HI_OBP_ADDRESS)) {
  203. tte = prom_virt_to_phys(va, &error);
  204. if (!error)
  205. res = PROM_TRUE;
  206. goto done;
  207. }
  208. pgdp = pgd_offset_k(va);
  209. if (pgd_none(*pgdp))
  210. goto done;
  211. pudp = pud_offset(pgdp, va);
  212. if (pud_none(*pudp))
  213. goto done;
  214. pmdp = pmd_offset(pudp, va);
  215. if (pmd_none(*pmdp))
  216. goto done;
  217. /* Preemption implicitly disabled by virtue of
  218. * being called from inside OBP.
  219. */
  220. ptep = pte_offset_kernel(pmdp, va);
  221. if (pte_present(*ptep)) {
  222. tte = pte_val(*ptep);
  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. default:
  344. printk("Unknown boot switch (-%c)\n", c);
  345. break;
  346. }
  347. }
  348. static void __init process_console(char *commands)
  349. {
  350. serial_console = 0;
  351. commands += 8;
  352. /* Linux-style serial */
  353. if (!strncmp(commands, "ttyS", 4))
  354. serial_console = simple_strtoul(commands + 4, NULL, 10) + 1;
  355. else if (!strncmp(commands, "tty", 3)) {
  356. char c = *(commands + 3);
  357. /* Solaris-style serial */
  358. if (c == 'a' || c == 'b') {
  359. serial_console = c - 'a' + 1;
  360. prom_printf ("Using /dev/tty%c as console.\n", c);
  361. }
  362. /* else Linux-style fbcon, not serial */
  363. }
  364. #if defined(CONFIG_PROM_CONSOLE)
  365. if (!strncmp(commands, "prom", 4)) {
  366. char *p;
  367. for (p = commands - 8; *p && *p != ' '; p++)
  368. *p = ' ';
  369. conswitchp = &prom_con;
  370. }
  371. #endif
  372. }
  373. static void __init boot_flags_init(char *commands)
  374. {
  375. while (*commands) {
  376. /* Move to the start of the next "argument". */
  377. while (*commands && *commands == ' ')
  378. commands++;
  379. /* Process any command switches, otherwise skip it. */
  380. if (*commands == '\0')
  381. break;
  382. if (*commands == '-') {
  383. commands++;
  384. while (*commands && *commands != ' ')
  385. process_switch(*commands++);
  386. continue;
  387. }
  388. if (!strncmp(commands, "console=", 8)) {
  389. process_console(commands);
  390. } else if (!strncmp(commands, "mem=", 4)) {
  391. /*
  392. * "mem=XXX[kKmM]" overrides the PROM-reported
  393. * memory size.
  394. */
  395. cmdline_memory_size = simple_strtoul(commands + 4,
  396. &commands, 0);
  397. if (*commands == 'K' || *commands == 'k') {
  398. cmdline_memory_size <<= 10;
  399. commands++;
  400. } else if (*commands=='M' || *commands=='m') {
  401. cmdline_memory_size <<= 20;
  402. commands++;
  403. }
  404. }
  405. while (*commands && *commands != ' ')
  406. commands++;
  407. }
  408. }
  409. extern int prom_probe_memory(void);
  410. extern unsigned long start, end;
  411. extern void panic_setup(char *, int *);
  412. extern unsigned short root_flags;
  413. extern unsigned short root_dev;
  414. extern unsigned short ram_flags;
  415. #define RAMDISK_IMAGE_START_MASK 0x07FF
  416. #define RAMDISK_PROMPT_FLAG 0x8000
  417. #define RAMDISK_LOAD_FLAG 0x4000
  418. extern int root_mountflags;
  419. char reboot_command[COMMAND_LINE_SIZE];
  420. static struct pt_regs fake_swapper_regs = { { 0, }, 0, 0, 0, 0 };
  421. void register_prom_callbacks(void)
  422. {
  423. prom_setcallback(prom_callback);
  424. prom_feval(": linux-va>tte-data 2 \" va>tte-data\" $callback drop ; "
  425. "' linux-va>tte-data to va>tte-data");
  426. prom_feval(": linux-.soft1 1 \" .soft1\" $callback 2drop ; "
  427. "' linux-.soft1 to .soft1");
  428. prom_feval(": linux-.soft2 1 \" .soft2\" $callback 2drop ; "
  429. "' linux-.soft2 to .soft2");
  430. }
  431. extern void paging_init(void);
  432. void __init setup_arch(char **cmdline_p)
  433. {
  434. unsigned long highest_paddr;
  435. int i;
  436. /* Initialize PROM console and command line. */
  437. *cmdline_p = prom_getbootargs();
  438. strcpy(saved_command_line, *cmdline_p);
  439. printk("ARCH: SUN4U\n");
  440. #ifdef CONFIG_DUMMY_CONSOLE
  441. conswitchp = &dummy_con;
  442. #elif defined(CONFIG_PROM_CONSOLE)
  443. conswitchp = &prom_con;
  444. #endif
  445. #ifdef CONFIG_SMP
  446. i = (unsigned long)&irq_stat[1] - (unsigned long)&irq_stat[0];
  447. if ((i == SMP_CACHE_BYTES) || (i == (2 * SMP_CACHE_BYTES))) {
  448. extern unsigned int irqsz_patchme[1];
  449. irqsz_patchme[0] |= ((i == SMP_CACHE_BYTES) ? SMP_CACHE_BYTES_SHIFT : \
  450. SMP_CACHE_BYTES_SHIFT + 1);
  451. flushi((long)&irqsz_patchme[0]);
  452. } else {
  453. prom_printf("Unexpected size of irq_stat[] elements\n");
  454. prom_halt();
  455. }
  456. #endif
  457. /* Work out if we are starfire early on */
  458. check_if_starfire();
  459. boot_flags_init(*cmdline_p);
  460. idprom_init();
  461. (void) prom_probe_memory();
  462. /* In paging_init() we tip off this value to see if we need
  463. * to change init_mm.pgd to point to the real alias mapping.
  464. */
  465. phys_base = 0xffffffffffffffffUL;
  466. highest_paddr = 0UL;
  467. for (i = 0; sp_banks[i].num_bytes != 0; i++) {
  468. unsigned long top;
  469. if (sp_banks[i].base_addr < phys_base)
  470. phys_base = sp_banks[i].base_addr;
  471. top = sp_banks[i].base_addr +
  472. sp_banks[i].num_bytes;
  473. if (highest_paddr < top)
  474. highest_paddr = top;
  475. }
  476. pfn_base = phys_base >> PAGE_SHIFT;
  477. switch (tlb_type) {
  478. default:
  479. case spitfire:
  480. kern_base = spitfire_get_itlb_data(sparc64_highest_locked_tlbent());
  481. kern_base &= _PAGE_PADDR_SF;
  482. break;
  483. case cheetah:
  484. case cheetah_plus:
  485. kern_base = cheetah_get_litlb_data(sparc64_highest_locked_tlbent());
  486. kern_base &= _PAGE_PADDR;
  487. break;
  488. };
  489. kern_size = (unsigned long)&_end - (unsigned long)KERNBASE;
  490. if (!root_flags)
  491. root_mountflags &= ~MS_RDONLY;
  492. ROOT_DEV = old_decode_dev(root_dev);
  493. #ifdef CONFIG_BLK_DEV_INITRD
  494. rd_image_start = ram_flags & RAMDISK_IMAGE_START_MASK;
  495. rd_prompt = ((ram_flags & RAMDISK_PROMPT_FLAG) != 0);
  496. rd_doload = ((ram_flags & RAMDISK_LOAD_FLAG) != 0);
  497. #endif
  498. init_task.thread_info->kregs = &fake_swapper_regs;
  499. #ifdef CONFIG_IP_PNP
  500. if (!ic_set_manually) {
  501. int chosen = prom_finddevice ("/chosen");
  502. u32 cl, sv, gw;
  503. cl = prom_getintdefault (chosen, "client-ip", 0);
  504. sv = prom_getintdefault (chosen, "server-ip", 0);
  505. gw = prom_getintdefault (chosen, "gateway-ip", 0);
  506. if (cl && sv) {
  507. ic_myaddr = cl;
  508. ic_servaddr = sv;
  509. if (gw)
  510. ic_gateway = gw;
  511. #if defined(CONFIG_IP_PNP_BOOTP) || defined(CONFIG_IP_PNP_RARP)
  512. ic_proto_enabled = 0;
  513. #endif
  514. }
  515. }
  516. #endif
  517. paging_init();
  518. }
  519. static int __init set_preferred_console(void)
  520. {
  521. int idev, odev;
  522. /* The user has requested a console so this is already set up. */
  523. if (serial_console >= 0)
  524. return -EBUSY;
  525. idev = prom_query_input_device();
  526. odev = prom_query_output_device();
  527. if (idev == PROMDEV_IKBD && odev == PROMDEV_OSCREEN) {
  528. serial_console = 0;
  529. } else if (idev == PROMDEV_ITTYA && odev == PROMDEV_OTTYA) {
  530. serial_console = 1;
  531. } else if (idev == PROMDEV_ITTYB && odev == PROMDEV_OTTYB) {
  532. serial_console = 2;
  533. } else {
  534. prom_printf("Inconsistent console: "
  535. "input %d, output %d\n",
  536. idev, odev);
  537. prom_halt();
  538. }
  539. if (serial_console)
  540. return add_preferred_console("ttyS", serial_console - 1, NULL);
  541. return -ENODEV;
  542. }
  543. console_initcall(set_preferred_console);
  544. /* BUFFER is PAGE_SIZE bytes long. */
  545. extern char *sparc_cpu_type;
  546. extern char *sparc_fpu_type;
  547. extern void smp_info(struct seq_file *);
  548. extern void smp_bogo(struct seq_file *);
  549. extern void mmu_info(struct seq_file *);
  550. static int show_cpuinfo(struct seq_file *m, void *__unused)
  551. {
  552. seq_printf(m,
  553. "cpu\t\t: %s\n"
  554. "fpu\t\t: %s\n"
  555. "promlib\t\t: Version 3 Revision %d\n"
  556. "prom\t\t: %d.%d.%d\n"
  557. "type\t\t: sun4u\n"
  558. "ncpus probed\t: %ld\n"
  559. "ncpus active\t: %ld\n"
  560. #ifndef CONFIG_SMP
  561. "Cpu0Bogo\t: %lu.%02lu\n"
  562. "Cpu0ClkTck\t: %016lx\n"
  563. #endif
  564. ,
  565. sparc_cpu_type,
  566. sparc_fpu_type,
  567. prom_rev,
  568. prom_prev >> 16,
  569. (prom_prev >> 8) & 0xff,
  570. prom_prev & 0xff,
  571. (long)num_possible_cpus(),
  572. (long)num_online_cpus()
  573. #ifndef CONFIG_SMP
  574. , cpu_data(0).udelay_val/(500000/HZ),
  575. (cpu_data(0).udelay_val/(5000/HZ)) % 100,
  576. cpu_data(0).clock_tick
  577. #endif
  578. );
  579. #ifdef CONFIG_SMP
  580. smp_bogo(m);
  581. #endif
  582. mmu_info(m);
  583. #ifdef CONFIG_SMP
  584. smp_info(m);
  585. #endif
  586. return 0;
  587. }
  588. static void *c_start(struct seq_file *m, loff_t *pos)
  589. {
  590. /* The pointer we are returning is arbitrary,
  591. * it just has to be non-NULL and not IS_ERR
  592. * in the success case.
  593. */
  594. return *pos == 0 ? &c_start : NULL;
  595. }
  596. static void *c_next(struct seq_file *m, void *v, loff_t *pos)
  597. {
  598. ++*pos;
  599. return c_start(m, pos);
  600. }
  601. static void c_stop(struct seq_file *m, void *v)
  602. {
  603. }
  604. struct seq_operations cpuinfo_op = {
  605. .start =c_start,
  606. .next = c_next,
  607. .stop = c_stop,
  608. .show = show_cpuinfo,
  609. };
  610. extern int stop_a_enabled;
  611. void sun_do_break(void)
  612. {
  613. if (!stop_a_enabled)
  614. return;
  615. prom_printf("\n");
  616. flush_user_windows();
  617. prom_cmdline();
  618. }
  619. int serial_console = -1;
  620. int stop_a_enabled = 1;
  621. static int __init topology_init(void)
  622. {
  623. int i, err;
  624. err = -ENOMEM;
  625. for (i = 0; i < NR_CPUS; i++) {
  626. if (cpu_possible(i)) {
  627. struct cpu *p = kmalloc(sizeof(*p), GFP_KERNEL);
  628. if (p) {
  629. memset(p, 0, sizeof(*p));
  630. register_cpu(p, i, NULL);
  631. err = 0;
  632. }
  633. }
  634. }
  635. return err;
  636. }
  637. subsys_initcall(topology_init);