setup_64.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715
  1. // SPDX-License-Identifier: GPL-2.0
  2. /*
  3. * linux/arch/sparc64/kernel/setup.c
  4. *
  5. * Copyright (C) 1995,1996 David S. Miller (davem@caip.rutgers.edu)
  6. * Copyright (C) 1997 Jakub Jelinek (jj@sunsite.mff.cuni.cz)
  7. */
  8. #include <linux/errno.h>
  9. #include <linux/sched.h>
  10. #include <linux/kernel.h>
  11. #include <linux/mm.h>
  12. #include <linux/stddef.h>
  13. #include <linux/unistd.h>
  14. #include <linux/ptrace.h>
  15. #include <asm/smp.h>
  16. #include <linux/user.h>
  17. #include <linux/screen_info.h>
  18. #include <linux/delay.h>
  19. #include <linux/fs.h>
  20. #include <linux/seq_file.h>
  21. #include <linux/syscalls.h>
  22. #include <linux/kdev_t.h>
  23. #include <linux/major.h>
  24. #include <linux/string.h>
  25. #include <linux/init.h>
  26. #include <linux/inet.h>
  27. #include <linux/console.h>
  28. #include <linux/root_dev.h>
  29. #include <linux/interrupt.h>
  30. #include <linux/cpu.h>
  31. #include <linux/initrd.h>
  32. #include <linux/module.h>
  33. #include <linux/start_kernel.h>
  34. #include <linux/bootmem.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. #include <asm/ns87303.h>
  49. #include <asm/btext.h>
  50. #include <asm/elf.h>
  51. #include <asm/mdesc.h>
  52. #include <asm/cacheflush.h>
  53. #include <asm/dma.h>
  54. #include <asm/irq.h>
  55. #ifdef CONFIG_IP_PNP
  56. #include <net/ipconfig.h>
  57. #endif
  58. #include "entry.h"
  59. #include "kernel.h"
  60. /* Used to synchronize accesses to NatSemi SUPER I/O chip configure
  61. * operations in asm/ns87303.h
  62. */
  63. DEFINE_SPINLOCK(ns87303_lock);
  64. EXPORT_SYMBOL(ns87303_lock);
  65. struct screen_info screen_info = {
  66. 0, 0, /* orig-x, orig-y */
  67. 0, /* unused */
  68. 0, /* orig-video-page */
  69. 0, /* orig-video-mode */
  70. 128, /* orig-video-cols */
  71. 0, 0, 0, /* unused, ega_bx, unused */
  72. 54, /* orig-video-lines */
  73. 0, /* orig-video-isVGA */
  74. 16 /* orig-video-points */
  75. };
  76. static void
  77. prom_console_write(struct console *con, const char *s, unsigned int n)
  78. {
  79. prom_write(s, n);
  80. }
  81. /* Exported for mm/init.c:paging_init. */
  82. unsigned long cmdline_memory_size = 0;
  83. static struct console prom_early_console = {
  84. .name = "earlyprom",
  85. .write = prom_console_write,
  86. .flags = CON_PRINTBUFFER | CON_BOOT | CON_ANYTIME,
  87. .index = -1,
  88. };
  89. /*
  90. * Process kernel command line switches that are specific to the
  91. * SPARC or that require special low-level processing.
  92. */
  93. static void __init process_switch(char c)
  94. {
  95. switch (c) {
  96. case 'd':
  97. case 's':
  98. break;
  99. case 'h':
  100. prom_printf("boot_flags_init: Halt!\n");
  101. prom_halt();
  102. break;
  103. case 'p':
  104. prom_early_console.flags &= ~CON_BOOT;
  105. break;
  106. case 'P':
  107. /* Force UltraSPARC-III P-Cache on. */
  108. if (tlb_type != cheetah) {
  109. printk("BOOT: Ignoring P-Cache force option.\n");
  110. break;
  111. }
  112. cheetah_pcache_forced_on = 1;
  113. add_taint(TAINT_MACHINE_CHECK, LOCKDEP_NOW_UNRELIABLE);
  114. cheetah_enable_pcache();
  115. break;
  116. default:
  117. printk("Unknown boot switch (-%c)\n", c);
  118. break;
  119. }
  120. }
  121. static void __init boot_flags_init(char *commands)
  122. {
  123. while (*commands) {
  124. /* Move to the start of the next "argument". */
  125. while (*commands == ' ')
  126. commands++;
  127. /* Process any command switches, otherwise skip it. */
  128. if (*commands == '\0')
  129. break;
  130. if (*commands == '-') {
  131. commands++;
  132. while (*commands && *commands != ' ')
  133. process_switch(*commands++);
  134. continue;
  135. }
  136. if (!strncmp(commands, "mem=", 4))
  137. cmdline_memory_size = memparse(commands + 4, &commands);
  138. while (*commands && *commands != ' ')
  139. commands++;
  140. }
  141. }
  142. extern unsigned short root_flags;
  143. extern unsigned short root_dev;
  144. extern unsigned short ram_flags;
  145. #define RAMDISK_IMAGE_START_MASK 0x07FF
  146. #define RAMDISK_PROMPT_FLAG 0x8000
  147. #define RAMDISK_LOAD_FLAG 0x4000
  148. extern int root_mountflags;
  149. char reboot_command[COMMAND_LINE_SIZE];
  150. static struct pt_regs fake_swapper_regs = { { 0, }, 0, 0, 0, 0 };
  151. static void __init per_cpu_patch(void)
  152. {
  153. struct cpuid_patch_entry *p;
  154. unsigned long ver;
  155. int is_jbus;
  156. if (tlb_type == spitfire && !this_is_starfire)
  157. return;
  158. is_jbus = 0;
  159. if (tlb_type != hypervisor) {
  160. __asm__ ("rdpr %%ver, %0" : "=r" (ver));
  161. is_jbus = ((ver >> 32UL) == __JALAPENO_ID ||
  162. (ver >> 32UL) == __SERRANO_ID);
  163. }
  164. p = &__cpuid_patch;
  165. while (p < &__cpuid_patch_end) {
  166. unsigned long addr = p->addr;
  167. unsigned int *insns;
  168. switch (tlb_type) {
  169. case spitfire:
  170. insns = &p->starfire[0];
  171. break;
  172. case cheetah:
  173. case cheetah_plus:
  174. if (is_jbus)
  175. insns = &p->cheetah_jbus[0];
  176. else
  177. insns = &p->cheetah_safari[0];
  178. break;
  179. case hypervisor:
  180. insns = &p->sun4v[0];
  181. break;
  182. default:
  183. prom_printf("Unknown cpu type, halting.\n");
  184. prom_halt();
  185. }
  186. *(unsigned int *) (addr + 0) = insns[0];
  187. wmb();
  188. __asm__ __volatile__("flush %0" : : "r" (addr + 0));
  189. *(unsigned int *) (addr + 4) = insns[1];
  190. wmb();
  191. __asm__ __volatile__("flush %0" : : "r" (addr + 4));
  192. *(unsigned int *) (addr + 8) = insns[2];
  193. wmb();
  194. __asm__ __volatile__("flush %0" : : "r" (addr + 8));
  195. *(unsigned int *) (addr + 12) = insns[3];
  196. wmb();
  197. __asm__ __volatile__("flush %0" : : "r" (addr + 12));
  198. p++;
  199. }
  200. }
  201. void sun4v_patch_1insn_range(struct sun4v_1insn_patch_entry *start,
  202. struct sun4v_1insn_patch_entry *end)
  203. {
  204. while (start < end) {
  205. unsigned long addr = start->addr;
  206. *(unsigned int *) (addr + 0) = start->insn;
  207. wmb();
  208. __asm__ __volatile__("flush %0" : : "r" (addr + 0));
  209. start++;
  210. }
  211. }
  212. void sun4v_patch_2insn_range(struct sun4v_2insn_patch_entry *start,
  213. struct sun4v_2insn_patch_entry *end)
  214. {
  215. while (start < end) {
  216. unsigned long addr = start->addr;
  217. *(unsigned int *) (addr + 0) = start->insns[0];
  218. wmb();
  219. __asm__ __volatile__("flush %0" : : "r" (addr + 0));
  220. *(unsigned int *) (addr + 4) = start->insns[1];
  221. wmb();
  222. __asm__ __volatile__("flush %0" : : "r" (addr + 4));
  223. start++;
  224. }
  225. }
  226. void sun_m7_patch_2insn_range(struct sun4v_2insn_patch_entry *start,
  227. struct sun4v_2insn_patch_entry *end)
  228. {
  229. while (start < end) {
  230. unsigned long addr = start->addr;
  231. *(unsigned int *) (addr + 0) = start->insns[0];
  232. wmb();
  233. __asm__ __volatile__("flush %0" : : "r" (addr + 0));
  234. *(unsigned int *) (addr + 4) = start->insns[1];
  235. wmb();
  236. __asm__ __volatile__("flush %0" : : "r" (addr + 4));
  237. start++;
  238. }
  239. }
  240. static void __init sun4v_patch(void)
  241. {
  242. extern void sun4v_hvapi_init(void);
  243. if (tlb_type != hypervisor)
  244. return;
  245. sun4v_patch_1insn_range(&__sun4v_1insn_patch,
  246. &__sun4v_1insn_patch_end);
  247. sun4v_patch_2insn_range(&__sun4v_2insn_patch,
  248. &__sun4v_2insn_patch_end);
  249. switch (sun4v_chip_type) {
  250. case SUN4V_CHIP_SPARC_M7:
  251. case SUN4V_CHIP_SPARC_M8:
  252. case SUN4V_CHIP_SPARC_SN:
  253. sun_m7_patch_2insn_range(&__sun_m7_2insn_patch,
  254. &__sun_m7_2insn_patch_end);
  255. break;
  256. default:
  257. break;
  258. }
  259. if (sun4v_chip_type != SUN4V_CHIP_NIAGARA1) {
  260. sun4v_patch_1insn_range(&__fast_win_ctrl_1insn_patch,
  261. &__fast_win_ctrl_1insn_patch_end);
  262. }
  263. sun4v_hvapi_init();
  264. }
  265. static void __init popc_patch(void)
  266. {
  267. struct popc_3insn_patch_entry *p3;
  268. struct popc_6insn_patch_entry *p6;
  269. p3 = &__popc_3insn_patch;
  270. while (p3 < &__popc_3insn_patch_end) {
  271. unsigned long i, addr = p3->addr;
  272. for (i = 0; i < 3; i++) {
  273. *(unsigned int *) (addr + (i * 4)) = p3->insns[i];
  274. wmb();
  275. __asm__ __volatile__("flush %0"
  276. : : "r" (addr + (i * 4)));
  277. }
  278. p3++;
  279. }
  280. p6 = &__popc_6insn_patch;
  281. while (p6 < &__popc_6insn_patch_end) {
  282. unsigned long i, addr = p6->addr;
  283. for (i = 0; i < 6; i++) {
  284. *(unsigned int *) (addr + (i * 4)) = p6->insns[i];
  285. wmb();
  286. __asm__ __volatile__("flush %0"
  287. : : "r" (addr + (i * 4)));
  288. }
  289. p6++;
  290. }
  291. }
  292. static void __init pause_patch(void)
  293. {
  294. struct pause_patch_entry *p;
  295. p = &__pause_3insn_patch;
  296. while (p < &__pause_3insn_patch_end) {
  297. unsigned long i, addr = p->addr;
  298. for (i = 0; i < 3; i++) {
  299. *(unsigned int *) (addr + (i * 4)) = p->insns[i];
  300. wmb();
  301. __asm__ __volatile__("flush %0"
  302. : : "r" (addr + (i * 4)));
  303. }
  304. p++;
  305. }
  306. }
  307. void __init start_early_boot(void)
  308. {
  309. int cpu;
  310. check_if_starfire();
  311. per_cpu_patch();
  312. sun4v_patch();
  313. smp_init_cpu_poke();
  314. cpu = hard_smp_processor_id();
  315. if (cpu >= NR_CPUS) {
  316. prom_printf("Serious problem, boot cpu id (%d) >= NR_CPUS (%d)\n",
  317. cpu, NR_CPUS);
  318. prom_halt();
  319. }
  320. current_thread_info()->cpu = cpu;
  321. time_init_early();
  322. prom_init_report();
  323. start_kernel();
  324. }
  325. /* On Ultra, we support all of the v8 capabilities. */
  326. unsigned long sparc64_elf_hwcap = (HWCAP_SPARC_FLUSH | HWCAP_SPARC_STBAR |
  327. HWCAP_SPARC_SWAP | HWCAP_SPARC_MULDIV |
  328. HWCAP_SPARC_V9);
  329. EXPORT_SYMBOL(sparc64_elf_hwcap);
  330. static const char *hwcaps[] = {
  331. "flush", "stbar", "swap", "muldiv", "v9",
  332. "ultra3", "blkinit", "n2",
  333. /* These strings are as they appear in the machine description
  334. * 'hwcap-list' property for cpu nodes.
  335. */
  336. "mul32", "div32", "fsmuld", "v8plus", "popc", "vis", "vis2",
  337. "ASIBlkInit", "fmaf", "vis3", "hpc", "random", "trans", "fjfmau",
  338. "ima", "cspare", "pause", "cbcond", NULL /*reserved for crypto */,
  339. "adp",
  340. };
  341. static const char *crypto_hwcaps[] = {
  342. "aes", "des", "kasumi", "camellia", "md5", "sha1", "sha256",
  343. "sha512", "mpmul", "montmul", "montsqr", "crc32c",
  344. };
  345. void cpucap_info(struct seq_file *m)
  346. {
  347. unsigned long caps = sparc64_elf_hwcap;
  348. int i, printed = 0;
  349. seq_puts(m, "cpucaps\t\t: ");
  350. for (i = 0; i < ARRAY_SIZE(hwcaps); i++) {
  351. unsigned long bit = 1UL << i;
  352. if (hwcaps[i] && (caps & bit)) {
  353. seq_printf(m, "%s%s",
  354. printed ? "," : "", hwcaps[i]);
  355. printed++;
  356. }
  357. }
  358. if (caps & HWCAP_SPARC_CRYPTO) {
  359. unsigned long cfr;
  360. __asm__ __volatile__("rd %%asr26, %0" : "=r" (cfr));
  361. for (i = 0; i < ARRAY_SIZE(crypto_hwcaps); i++) {
  362. unsigned long bit = 1UL << i;
  363. if (cfr & bit) {
  364. seq_printf(m, "%s%s",
  365. printed ? "," : "", crypto_hwcaps[i]);
  366. printed++;
  367. }
  368. }
  369. }
  370. seq_putc(m, '\n');
  371. }
  372. static void __init report_one_hwcap(int *printed, const char *name)
  373. {
  374. if ((*printed) == 0)
  375. printk(KERN_INFO "CPU CAPS: [");
  376. printk(KERN_CONT "%s%s",
  377. (*printed) ? "," : "", name);
  378. if (++(*printed) == 8) {
  379. printk(KERN_CONT "]\n");
  380. *printed = 0;
  381. }
  382. }
  383. static void __init report_crypto_hwcaps(int *printed)
  384. {
  385. unsigned long cfr;
  386. int i;
  387. __asm__ __volatile__("rd %%asr26, %0" : "=r" (cfr));
  388. for (i = 0; i < ARRAY_SIZE(crypto_hwcaps); i++) {
  389. unsigned long bit = 1UL << i;
  390. if (cfr & bit)
  391. report_one_hwcap(printed, crypto_hwcaps[i]);
  392. }
  393. }
  394. static void __init report_hwcaps(unsigned long caps)
  395. {
  396. int i, printed = 0;
  397. for (i = 0; i < ARRAY_SIZE(hwcaps); i++) {
  398. unsigned long bit = 1UL << i;
  399. if (hwcaps[i] && (caps & bit))
  400. report_one_hwcap(&printed, hwcaps[i]);
  401. }
  402. if (caps & HWCAP_SPARC_CRYPTO)
  403. report_crypto_hwcaps(&printed);
  404. if (printed != 0)
  405. printk(KERN_CONT "]\n");
  406. }
  407. static unsigned long __init mdesc_cpu_hwcap_list(void)
  408. {
  409. struct mdesc_handle *hp;
  410. unsigned long caps = 0;
  411. const char *prop;
  412. int len;
  413. u64 pn;
  414. hp = mdesc_grab();
  415. if (!hp)
  416. return 0;
  417. pn = mdesc_node_by_name(hp, MDESC_NODE_NULL, "cpu");
  418. if (pn == MDESC_NODE_NULL)
  419. goto out;
  420. prop = mdesc_get_property(hp, pn, "hwcap-list", &len);
  421. if (!prop)
  422. goto out;
  423. while (len) {
  424. int i, plen;
  425. for (i = 0; i < ARRAY_SIZE(hwcaps); i++) {
  426. unsigned long bit = 1UL << i;
  427. if (hwcaps[i] && !strcmp(prop, hwcaps[i])) {
  428. caps |= bit;
  429. break;
  430. }
  431. }
  432. for (i = 0; i < ARRAY_SIZE(crypto_hwcaps); i++) {
  433. if (!strcmp(prop, crypto_hwcaps[i]))
  434. caps |= HWCAP_SPARC_CRYPTO;
  435. }
  436. plen = strlen(prop) + 1;
  437. prop += plen;
  438. len -= plen;
  439. }
  440. out:
  441. mdesc_release(hp);
  442. return caps;
  443. }
  444. /* This yields a mask that user programs can use to figure out what
  445. * instruction set this cpu supports.
  446. */
  447. static void __init init_sparc64_elf_hwcap(void)
  448. {
  449. unsigned long cap = sparc64_elf_hwcap;
  450. unsigned long mdesc_caps;
  451. if (tlb_type == cheetah || tlb_type == cheetah_plus)
  452. cap |= HWCAP_SPARC_ULTRA3;
  453. else if (tlb_type == hypervisor) {
  454. if (sun4v_chip_type == SUN4V_CHIP_NIAGARA1 ||
  455. sun4v_chip_type == SUN4V_CHIP_NIAGARA2 ||
  456. sun4v_chip_type == SUN4V_CHIP_NIAGARA3 ||
  457. sun4v_chip_type == SUN4V_CHIP_NIAGARA4 ||
  458. sun4v_chip_type == SUN4V_CHIP_NIAGARA5 ||
  459. sun4v_chip_type == SUN4V_CHIP_SPARC_M6 ||
  460. sun4v_chip_type == SUN4V_CHIP_SPARC_M7 ||
  461. sun4v_chip_type == SUN4V_CHIP_SPARC_M8 ||
  462. sun4v_chip_type == SUN4V_CHIP_SPARC_SN ||
  463. sun4v_chip_type == SUN4V_CHIP_SPARC64X)
  464. cap |= HWCAP_SPARC_BLKINIT;
  465. if (sun4v_chip_type == SUN4V_CHIP_NIAGARA2 ||
  466. sun4v_chip_type == SUN4V_CHIP_NIAGARA3 ||
  467. sun4v_chip_type == SUN4V_CHIP_NIAGARA4 ||
  468. sun4v_chip_type == SUN4V_CHIP_NIAGARA5 ||
  469. sun4v_chip_type == SUN4V_CHIP_SPARC_M6 ||
  470. sun4v_chip_type == SUN4V_CHIP_SPARC_M7 ||
  471. sun4v_chip_type == SUN4V_CHIP_SPARC_M8 ||
  472. sun4v_chip_type == SUN4V_CHIP_SPARC_SN ||
  473. sun4v_chip_type == SUN4V_CHIP_SPARC64X)
  474. cap |= HWCAP_SPARC_N2;
  475. }
  476. cap |= (AV_SPARC_MUL32 | AV_SPARC_DIV32 | AV_SPARC_V8PLUS);
  477. mdesc_caps = mdesc_cpu_hwcap_list();
  478. if (!mdesc_caps) {
  479. if (tlb_type == spitfire)
  480. cap |= AV_SPARC_VIS;
  481. if (tlb_type == cheetah || tlb_type == cheetah_plus)
  482. cap |= AV_SPARC_VIS | AV_SPARC_VIS2;
  483. if (tlb_type == cheetah_plus) {
  484. unsigned long impl, ver;
  485. __asm__ __volatile__("rdpr %%ver, %0" : "=r" (ver));
  486. impl = ((ver >> 32) & 0xffff);
  487. if (impl == PANTHER_IMPL)
  488. cap |= AV_SPARC_POPC;
  489. }
  490. if (tlb_type == hypervisor) {
  491. if (sun4v_chip_type == SUN4V_CHIP_NIAGARA1)
  492. cap |= AV_SPARC_ASI_BLK_INIT;
  493. if (sun4v_chip_type == SUN4V_CHIP_NIAGARA2 ||
  494. sun4v_chip_type == SUN4V_CHIP_NIAGARA3 ||
  495. sun4v_chip_type == SUN4V_CHIP_NIAGARA4 ||
  496. sun4v_chip_type == SUN4V_CHIP_NIAGARA5 ||
  497. sun4v_chip_type == SUN4V_CHIP_SPARC_M6 ||
  498. sun4v_chip_type == SUN4V_CHIP_SPARC_M7 ||
  499. sun4v_chip_type == SUN4V_CHIP_SPARC_M8 ||
  500. sun4v_chip_type == SUN4V_CHIP_SPARC_SN ||
  501. sun4v_chip_type == SUN4V_CHIP_SPARC64X)
  502. cap |= (AV_SPARC_VIS | AV_SPARC_VIS2 |
  503. AV_SPARC_ASI_BLK_INIT |
  504. AV_SPARC_POPC);
  505. if (sun4v_chip_type == SUN4V_CHIP_NIAGARA3 ||
  506. sun4v_chip_type == SUN4V_CHIP_NIAGARA4 ||
  507. sun4v_chip_type == SUN4V_CHIP_NIAGARA5 ||
  508. sun4v_chip_type == SUN4V_CHIP_SPARC_M6 ||
  509. sun4v_chip_type == SUN4V_CHIP_SPARC_M7 ||
  510. sun4v_chip_type == SUN4V_CHIP_SPARC_M8 ||
  511. sun4v_chip_type == SUN4V_CHIP_SPARC_SN ||
  512. sun4v_chip_type == SUN4V_CHIP_SPARC64X)
  513. cap |= (AV_SPARC_VIS3 | AV_SPARC_HPC |
  514. AV_SPARC_FMAF);
  515. }
  516. }
  517. sparc64_elf_hwcap = cap | mdesc_caps;
  518. report_hwcaps(sparc64_elf_hwcap);
  519. if (sparc64_elf_hwcap & AV_SPARC_POPC)
  520. popc_patch();
  521. if (sparc64_elf_hwcap & AV_SPARC_PAUSE)
  522. pause_patch();
  523. }
  524. void __init alloc_irqstack_bootmem(void)
  525. {
  526. unsigned int i, node;
  527. for_each_possible_cpu(i) {
  528. node = cpu_to_node(i);
  529. softirq_stack[i] = __alloc_bootmem_node(NODE_DATA(node),
  530. THREAD_SIZE,
  531. THREAD_SIZE, 0);
  532. hardirq_stack[i] = __alloc_bootmem_node(NODE_DATA(node),
  533. THREAD_SIZE,
  534. THREAD_SIZE, 0);
  535. }
  536. }
  537. void __init setup_arch(char **cmdline_p)
  538. {
  539. /* Initialize PROM console and command line. */
  540. *cmdline_p = prom_getbootargs();
  541. strlcpy(boot_command_line, *cmdline_p, COMMAND_LINE_SIZE);
  542. parse_early_param();
  543. boot_flags_init(*cmdline_p);
  544. #ifdef CONFIG_EARLYFB
  545. if (btext_find_display())
  546. #endif
  547. register_console(&prom_early_console);
  548. if (tlb_type == hypervisor)
  549. printk("ARCH: SUN4V\n");
  550. else
  551. printk("ARCH: SUN4U\n");
  552. #ifdef CONFIG_DUMMY_CONSOLE
  553. conswitchp = &dummy_con;
  554. #endif
  555. idprom_init();
  556. if (!root_flags)
  557. root_mountflags &= ~MS_RDONLY;
  558. ROOT_DEV = old_decode_dev(root_dev);
  559. #ifdef CONFIG_BLK_DEV_RAM
  560. rd_image_start = ram_flags & RAMDISK_IMAGE_START_MASK;
  561. rd_prompt = ((ram_flags & RAMDISK_PROMPT_FLAG) != 0);
  562. rd_doload = ((ram_flags & RAMDISK_LOAD_FLAG) != 0);
  563. #endif
  564. task_thread_info(&init_task)->kregs = &fake_swapper_regs;
  565. #ifdef CONFIG_IP_PNP
  566. if (!ic_set_manually) {
  567. phandle chosen = prom_finddevice("/chosen");
  568. u32 cl, sv, gw;
  569. cl = prom_getintdefault (chosen, "client-ip", 0);
  570. sv = prom_getintdefault (chosen, "server-ip", 0);
  571. gw = prom_getintdefault (chosen, "gateway-ip", 0);
  572. if (cl && sv) {
  573. ic_myaddr = cl;
  574. ic_servaddr = sv;
  575. if (gw)
  576. ic_gateway = gw;
  577. #if defined(CONFIG_IP_PNP_BOOTP) || defined(CONFIG_IP_PNP_RARP)
  578. ic_proto_enabled = 0;
  579. #endif
  580. }
  581. }
  582. #endif
  583. /* Get boot processor trap_block[] setup. */
  584. init_cur_cpu_trap(current_thread_info());
  585. paging_init();
  586. init_sparc64_elf_hwcap();
  587. smp_fill_in_cpu_possible_map();
  588. /*
  589. * Once the OF device tree and MDESC have been setup and nr_cpus has
  590. * been parsed, we know the list of possible cpus. Therefore we can
  591. * allocate the IRQ stacks.
  592. */
  593. alloc_irqstack_bootmem();
  594. }
  595. extern int stop_a_enabled;
  596. void sun_do_break(void)
  597. {
  598. if (!stop_a_enabled)
  599. return;
  600. prom_printf("\n");
  601. flush_user_windows();
  602. prom_cmdline();
  603. }
  604. EXPORT_SYMBOL(sun_do_break);
  605. int stop_a_enabled = 1;
  606. EXPORT_SYMBOL(stop_a_enabled);