setup_64.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711
  1. // SPDX-License-Identifier: GPL-2.0
  2. /*
  3. * linux/arch/sparc64/kernel/setup.c
  4. *
  5. * Copyright (C) 1995,1996 David S. Miller ([email protected])
  6. * Copyright (C) 1997 Jakub Jelinek ([email protected])
  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/memblock.h>
  35. #include <uapi/linux/mount.h>
  36. #include <asm/io.h>
  37. #include <asm/processor.h>
  38. #include <asm/oplib.h>
  39. #include <asm/page.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 void __init per_cpu_patch(void)
  151. {
  152. struct cpuid_patch_entry *p;
  153. unsigned long ver;
  154. int is_jbus;
  155. if (tlb_type == spitfire && !this_is_starfire)
  156. return;
  157. is_jbus = 0;
  158. if (tlb_type != hypervisor) {
  159. __asm__ ("rdpr %%ver, %0" : "=r" (ver));
  160. is_jbus = ((ver >> 32UL) == __JALAPENO_ID ||
  161. (ver >> 32UL) == __SERRANO_ID);
  162. }
  163. p = &__cpuid_patch;
  164. while (p < &__cpuid_patch_end) {
  165. unsigned long addr = p->addr;
  166. unsigned int *insns;
  167. switch (tlb_type) {
  168. case spitfire:
  169. insns = &p->starfire[0];
  170. break;
  171. case cheetah:
  172. case cheetah_plus:
  173. if (is_jbus)
  174. insns = &p->cheetah_jbus[0];
  175. else
  176. insns = &p->cheetah_safari[0];
  177. break;
  178. case hypervisor:
  179. insns = &p->sun4v[0];
  180. break;
  181. default:
  182. prom_printf("Unknown cpu type, halting.\n");
  183. prom_halt();
  184. }
  185. *(unsigned int *) (addr + 0) = insns[0];
  186. wmb();
  187. __asm__ __volatile__("flush %0" : : "r" (addr + 0));
  188. *(unsigned int *) (addr + 4) = insns[1];
  189. wmb();
  190. __asm__ __volatile__("flush %0" : : "r" (addr + 4));
  191. *(unsigned int *) (addr + 8) = insns[2];
  192. wmb();
  193. __asm__ __volatile__("flush %0" : : "r" (addr + 8));
  194. *(unsigned int *) (addr + 12) = insns[3];
  195. wmb();
  196. __asm__ __volatile__("flush %0" : : "r" (addr + 12));
  197. p++;
  198. }
  199. }
  200. void sun4v_patch_1insn_range(struct sun4v_1insn_patch_entry *start,
  201. struct sun4v_1insn_patch_entry *end)
  202. {
  203. while (start < end) {
  204. unsigned long addr = start->addr;
  205. *(unsigned int *) (addr + 0) = start->insn;
  206. wmb();
  207. __asm__ __volatile__("flush %0" : : "r" (addr + 0));
  208. start++;
  209. }
  210. }
  211. void sun4v_patch_2insn_range(struct sun4v_2insn_patch_entry *start,
  212. struct sun4v_2insn_patch_entry *end)
  213. {
  214. while (start < end) {
  215. unsigned long addr = start->addr;
  216. *(unsigned int *) (addr + 0) = start->insns[0];
  217. wmb();
  218. __asm__ __volatile__("flush %0" : : "r" (addr + 0));
  219. *(unsigned int *) (addr + 4) = start->insns[1];
  220. wmb();
  221. __asm__ __volatile__("flush %0" : : "r" (addr + 4));
  222. start++;
  223. }
  224. }
  225. void sun_m7_patch_2insn_range(struct sun4v_2insn_patch_entry *start,
  226. struct sun4v_2insn_patch_entry *end)
  227. {
  228. while (start < end) {
  229. unsigned long addr = start->addr;
  230. *(unsigned int *) (addr + 0) = start->insns[0];
  231. wmb();
  232. __asm__ __volatile__("flush %0" : : "r" (addr + 0));
  233. *(unsigned int *) (addr + 4) = start->insns[1];
  234. wmb();
  235. __asm__ __volatile__("flush %0" : : "r" (addr + 4));
  236. start++;
  237. }
  238. }
  239. static void __init sun4v_patch(void)
  240. {
  241. extern void sun4v_hvapi_init(void);
  242. if (tlb_type != hypervisor)
  243. return;
  244. sun4v_patch_1insn_range(&__sun4v_1insn_patch,
  245. &__sun4v_1insn_patch_end);
  246. sun4v_patch_2insn_range(&__sun4v_2insn_patch,
  247. &__sun4v_2insn_patch_end);
  248. switch (sun4v_chip_type) {
  249. case SUN4V_CHIP_SPARC_M7:
  250. case SUN4V_CHIP_SPARC_M8:
  251. case SUN4V_CHIP_SPARC_SN:
  252. sun4v_patch_1insn_range(&__sun_m7_1insn_patch,
  253. &__sun_m7_1insn_patch_end);
  254. sun_m7_patch_2insn_range(&__sun_m7_2insn_patch,
  255. &__sun_m7_2insn_patch_end);
  256. break;
  257. default:
  258. break;
  259. }
  260. if (sun4v_chip_type != SUN4V_CHIP_NIAGARA1) {
  261. sun4v_patch_1insn_range(&__fast_win_ctrl_1insn_patch,
  262. &__fast_win_ctrl_1insn_patch_end);
  263. }
  264. sun4v_hvapi_init();
  265. }
  266. static void __init popc_patch(void)
  267. {
  268. struct popc_3insn_patch_entry *p3;
  269. struct popc_6insn_patch_entry *p6;
  270. p3 = &__popc_3insn_patch;
  271. while (p3 < &__popc_3insn_patch_end) {
  272. unsigned long i, addr = p3->addr;
  273. for (i = 0; i < 3; i++) {
  274. *(unsigned int *) (addr + (i * 4)) = p3->insns[i];
  275. wmb();
  276. __asm__ __volatile__("flush %0"
  277. : : "r" (addr + (i * 4)));
  278. }
  279. p3++;
  280. }
  281. p6 = &__popc_6insn_patch;
  282. while (p6 < &__popc_6insn_patch_end) {
  283. unsigned long i, addr = p6->addr;
  284. for (i = 0; i < 6; i++) {
  285. *(unsigned int *) (addr + (i * 4)) = p6->insns[i];
  286. wmb();
  287. __asm__ __volatile__("flush %0"
  288. : : "r" (addr + (i * 4)));
  289. }
  290. p6++;
  291. }
  292. }
  293. static void __init pause_patch(void)
  294. {
  295. struct pause_patch_entry *p;
  296. p = &__pause_3insn_patch;
  297. while (p < &__pause_3insn_patch_end) {
  298. unsigned long i, addr = p->addr;
  299. for (i = 0; i < 3; i++) {
  300. *(unsigned int *) (addr + (i * 4)) = p->insns[i];
  301. wmb();
  302. __asm__ __volatile__("flush %0"
  303. : : "r" (addr + (i * 4)));
  304. }
  305. p++;
  306. }
  307. }
  308. void __init start_early_boot(void)
  309. {
  310. int cpu;
  311. check_if_starfire();
  312. per_cpu_patch();
  313. sun4v_patch();
  314. smp_init_cpu_poke();
  315. cpu = hard_smp_processor_id();
  316. if (cpu >= NR_CPUS) {
  317. prom_printf("Serious problem, boot cpu id (%d) >= NR_CPUS (%d)\n",
  318. cpu, NR_CPUS);
  319. prom_halt();
  320. }
  321. current_thread_info()->cpu = cpu;
  322. time_init_early();
  323. prom_init_report();
  324. start_kernel();
  325. }
  326. /* On Ultra, we support all of the v8 capabilities. */
  327. unsigned long sparc64_elf_hwcap = (HWCAP_SPARC_FLUSH | HWCAP_SPARC_STBAR |
  328. HWCAP_SPARC_SWAP | HWCAP_SPARC_MULDIV |
  329. HWCAP_SPARC_V9);
  330. EXPORT_SYMBOL(sparc64_elf_hwcap);
  331. static const char *hwcaps[] = {
  332. "flush", "stbar", "swap", "muldiv", "v9",
  333. "ultra3", "blkinit", "n2",
  334. /* These strings are as they appear in the machine description
  335. * 'hwcap-list' property for cpu nodes.
  336. */
  337. "mul32", "div32", "fsmuld", "v8plus", "popc", "vis", "vis2",
  338. "ASIBlkInit", "fmaf", "vis3", "hpc", "random", "trans", "fjfmau",
  339. "ima", "cspare", "pause", "cbcond", NULL /*reserved for crypto */,
  340. "adp",
  341. };
  342. static const char *crypto_hwcaps[] = {
  343. "aes", "des", "kasumi", "camellia", "md5", "sha1", "sha256",
  344. "sha512", "mpmul", "montmul", "montsqr", "crc32c",
  345. };
  346. void cpucap_info(struct seq_file *m)
  347. {
  348. unsigned long caps = sparc64_elf_hwcap;
  349. int i, printed = 0;
  350. seq_puts(m, "cpucaps\t\t: ");
  351. for (i = 0; i < ARRAY_SIZE(hwcaps); i++) {
  352. unsigned long bit = 1UL << i;
  353. if (hwcaps[i] && (caps & bit)) {
  354. seq_printf(m, "%s%s",
  355. printed ? "," : "", hwcaps[i]);
  356. printed++;
  357. }
  358. }
  359. if (caps & HWCAP_SPARC_CRYPTO) {
  360. unsigned long cfr;
  361. __asm__ __volatile__("rd %%asr26, %0" : "=r" (cfr));
  362. for (i = 0; i < ARRAY_SIZE(crypto_hwcaps); i++) {
  363. unsigned long bit = 1UL << i;
  364. if (cfr & bit) {
  365. seq_printf(m, "%s%s",
  366. printed ? "," : "", crypto_hwcaps[i]);
  367. printed++;
  368. }
  369. }
  370. }
  371. seq_putc(m, '\n');
  372. }
  373. static void __init report_one_hwcap(int *printed, const char *name)
  374. {
  375. if ((*printed) == 0)
  376. printk(KERN_INFO "CPU CAPS: [");
  377. printk(KERN_CONT "%s%s",
  378. (*printed) ? "," : "", name);
  379. if (++(*printed) == 8) {
  380. printk(KERN_CONT "]\n");
  381. *printed = 0;
  382. }
  383. }
  384. static void __init report_crypto_hwcaps(int *printed)
  385. {
  386. unsigned long cfr;
  387. int i;
  388. __asm__ __volatile__("rd %%asr26, %0" : "=r" (cfr));
  389. for (i = 0; i < ARRAY_SIZE(crypto_hwcaps); i++) {
  390. unsigned long bit = 1UL << i;
  391. if (cfr & bit)
  392. report_one_hwcap(printed, crypto_hwcaps[i]);
  393. }
  394. }
  395. static void __init report_hwcaps(unsigned long caps)
  396. {
  397. int i, printed = 0;
  398. for (i = 0; i < ARRAY_SIZE(hwcaps); i++) {
  399. unsigned long bit = 1UL << i;
  400. if (hwcaps[i] && (caps & bit))
  401. report_one_hwcap(&printed, hwcaps[i]);
  402. }
  403. if (caps & HWCAP_SPARC_CRYPTO)
  404. report_crypto_hwcaps(&printed);
  405. if (printed != 0)
  406. printk(KERN_CONT "]\n");
  407. }
  408. static unsigned long __init mdesc_cpu_hwcap_list(void)
  409. {
  410. struct mdesc_handle *hp;
  411. unsigned long caps = 0;
  412. const char *prop;
  413. int len;
  414. u64 pn;
  415. hp = mdesc_grab();
  416. if (!hp)
  417. return 0;
  418. pn = mdesc_node_by_name(hp, MDESC_NODE_NULL, "cpu");
  419. if (pn == MDESC_NODE_NULL)
  420. goto out;
  421. prop = mdesc_get_property(hp, pn, "hwcap-list", &len);
  422. if (!prop)
  423. goto out;
  424. while (len) {
  425. int i, plen;
  426. for (i = 0; i < ARRAY_SIZE(hwcaps); i++) {
  427. unsigned long bit = 1UL << i;
  428. if (hwcaps[i] && !strcmp(prop, hwcaps[i])) {
  429. caps |= bit;
  430. break;
  431. }
  432. }
  433. for (i = 0; i < ARRAY_SIZE(crypto_hwcaps); i++) {
  434. if (!strcmp(prop, crypto_hwcaps[i]))
  435. caps |= HWCAP_SPARC_CRYPTO;
  436. }
  437. plen = strlen(prop) + 1;
  438. prop += plen;
  439. len -= plen;
  440. }
  441. out:
  442. mdesc_release(hp);
  443. return caps;
  444. }
  445. /* This yields a mask that user programs can use to figure out what
  446. * instruction set this cpu supports.
  447. */
  448. static void __init init_sparc64_elf_hwcap(void)
  449. {
  450. unsigned long cap = sparc64_elf_hwcap;
  451. unsigned long mdesc_caps;
  452. if (tlb_type == cheetah || tlb_type == cheetah_plus)
  453. cap |= HWCAP_SPARC_ULTRA3;
  454. else if (tlb_type == hypervisor) {
  455. if (sun4v_chip_type == SUN4V_CHIP_NIAGARA1 ||
  456. sun4v_chip_type == SUN4V_CHIP_NIAGARA2 ||
  457. sun4v_chip_type == SUN4V_CHIP_NIAGARA3 ||
  458. sun4v_chip_type == SUN4V_CHIP_NIAGARA4 ||
  459. sun4v_chip_type == SUN4V_CHIP_NIAGARA5 ||
  460. sun4v_chip_type == SUN4V_CHIP_SPARC_M6 ||
  461. sun4v_chip_type == SUN4V_CHIP_SPARC_M7 ||
  462. sun4v_chip_type == SUN4V_CHIP_SPARC_M8 ||
  463. sun4v_chip_type == SUN4V_CHIP_SPARC_SN ||
  464. sun4v_chip_type == SUN4V_CHIP_SPARC64X)
  465. cap |= HWCAP_SPARC_BLKINIT;
  466. if (sun4v_chip_type == SUN4V_CHIP_NIAGARA2 ||
  467. sun4v_chip_type == SUN4V_CHIP_NIAGARA3 ||
  468. sun4v_chip_type == SUN4V_CHIP_NIAGARA4 ||
  469. sun4v_chip_type == SUN4V_CHIP_NIAGARA5 ||
  470. sun4v_chip_type == SUN4V_CHIP_SPARC_M6 ||
  471. sun4v_chip_type == SUN4V_CHIP_SPARC_M7 ||
  472. sun4v_chip_type == SUN4V_CHIP_SPARC_M8 ||
  473. sun4v_chip_type == SUN4V_CHIP_SPARC_SN ||
  474. sun4v_chip_type == SUN4V_CHIP_SPARC64X)
  475. cap |= HWCAP_SPARC_N2;
  476. }
  477. cap |= (AV_SPARC_MUL32 | AV_SPARC_DIV32 | AV_SPARC_V8PLUS);
  478. mdesc_caps = mdesc_cpu_hwcap_list();
  479. if (!mdesc_caps) {
  480. if (tlb_type == spitfire)
  481. cap |= AV_SPARC_VIS;
  482. if (tlb_type == cheetah || tlb_type == cheetah_plus)
  483. cap |= AV_SPARC_VIS | AV_SPARC_VIS2;
  484. if (tlb_type == cheetah_plus) {
  485. unsigned long impl, ver;
  486. __asm__ __volatile__("rdpr %%ver, %0" : "=r" (ver));
  487. impl = ((ver >> 32) & 0xffff);
  488. if (impl == PANTHER_IMPL)
  489. cap |= AV_SPARC_POPC;
  490. }
  491. if (tlb_type == hypervisor) {
  492. if (sun4v_chip_type == SUN4V_CHIP_NIAGARA1)
  493. cap |= AV_SPARC_ASI_BLK_INIT;
  494. if (sun4v_chip_type == SUN4V_CHIP_NIAGARA2 ||
  495. sun4v_chip_type == SUN4V_CHIP_NIAGARA3 ||
  496. sun4v_chip_type == SUN4V_CHIP_NIAGARA4 ||
  497. sun4v_chip_type == SUN4V_CHIP_NIAGARA5 ||
  498. sun4v_chip_type == SUN4V_CHIP_SPARC_M6 ||
  499. sun4v_chip_type == SUN4V_CHIP_SPARC_M7 ||
  500. sun4v_chip_type == SUN4V_CHIP_SPARC_M8 ||
  501. sun4v_chip_type == SUN4V_CHIP_SPARC_SN ||
  502. sun4v_chip_type == SUN4V_CHIP_SPARC64X)
  503. cap |= (AV_SPARC_VIS | AV_SPARC_VIS2 |
  504. AV_SPARC_ASI_BLK_INIT |
  505. AV_SPARC_POPC);
  506. if (sun4v_chip_type == SUN4V_CHIP_NIAGARA3 ||
  507. sun4v_chip_type == SUN4V_CHIP_NIAGARA4 ||
  508. sun4v_chip_type == SUN4V_CHIP_NIAGARA5 ||
  509. sun4v_chip_type == SUN4V_CHIP_SPARC_M6 ||
  510. sun4v_chip_type == SUN4V_CHIP_SPARC_M7 ||
  511. sun4v_chip_type == SUN4V_CHIP_SPARC_M8 ||
  512. sun4v_chip_type == SUN4V_CHIP_SPARC_SN ||
  513. sun4v_chip_type == SUN4V_CHIP_SPARC64X)
  514. cap |= (AV_SPARC_VIS3 | AV_SPARC_HPC |
  515. AV_SPARC_FMAF);
  516. }
  517. }
  518. sparc64_elf_hwcap = cap | mdesc_caps;
  519. report_hwcaps(sparc64_elf_hwcap);
  520. if (sparc64_elf_hwcap & AV_SPARC_POPC)
  521. popc_patch();
  522. if (sparc64_elf_hwcap & AV_SPARC_PAUSE)
  523. pause_patch();
  524. }
  525. void __init alloc_irqstack_bootmem(void)
  526. {
  527. unsigned int i, node;
  528. for_each_possible_cpu(i) {
  529. node = cpu_to_node(i);
  530. softirq_stack[i] = memblock_alloc_node(THREAD_SIZE,
  531. THREAD_SIZE, node);
  532. if (!softirq_stack[i])
  533. panic("%s: Failed to allocate %lu bytes align=%lx nid=%d\n",
  534. __func__, THREAD_SIZE, THREAD_SIZE, node);
  535. hardirq_stack[i] = memblock_alloc_node(THREAD_SIZE,
  536. THREAD_SIZE, node);
  537. if (!hardirq_stack[i])
  538. panic("%s: Failed to allocate %lu bytes align=%lx nid=%d\n",
  539. __func__, THREAD_SIZE, THREAD_SIZE, node);
  540. }
  541. }
  542. void __init setup_arch(char **cmdline_p)
  543. {
  544. /* Initialize PROM console and command line. */
  545. *cmdline_p = prom_getbootargs();
  546. strlcpy(boot_command_line, *cmdline_p, COMMAND_LINE_SIZE);
  547. parse_early_param();
  548. boot_flags_init(*cmdline_p);
  549. #ifdef CONFIG_EARLYFB
  550. if (btext_find_display())
  551. #endif
  552. register_console(&prom_early_console);
  553. if (tlb_type == hypervisor)
  554. pr_info("ARCH: SUN4V\n");
  555. else
  556. pr_info("ARCH: SUN4U\n");
  557. idprom_init();
  558. if (!root_flags)
  559. root_mountflags &= ~MS_RDONLY;
  560. ROOT_DEV = old_decode_dev(root_dev);
  561. #ifdef CONFIG_BLK_DEV_RAM
  562. rd_image_start = ram_flags & RAMDISK_IMAGE_START_MASK;
  563. #endif
  564. #ifdef CONFIG_IP_PNP
  565. if (!ic_set_manually) {
  566. phandle chosen = prom_finddevice("/chosen");
  567. u32 cl, sv, gw;
  568. cl = prom_getintdefault (chosen, "client-ip", 0);
  569. sv = prom_getintdefault (chosen, "server-ip", 0);
  570. gw = prom_getintdefault (chosen, "gateway-ip", 0);
  571. if (cl && sv) {
  572. ic_myaddr = cl;
  573. ic_servaddr = sv;
  574. if (gw)
  575. ic_gateway = gw;
  576. #if defined(CONFIG_IP_PNP_BOOTP) || defined(CONFIG_IP_PNP_RARP)
  577. ic_proto_enabled = 0;
  578. #endif
  579. }
  580. }
  581. #endif
  582. /* Get boot processor trap_block[] setup. */
  583. init_cur_cpu_trap(current_thread_info());
  584. paging_init();
  585. init_sparc64_elf_hwcap();
  586. smp_fill_in_cpu_possible_map();
  587. /*
  588. * Once the OF device tree and MDESC have been setup and nr_cpus has
  589. * been parsed, we know the list of possible cpus. Therefore we can
  590. * allocate the IRQ stacks.
  591. */
  592. alloc_irqstack_bootmem();
  593. }
  594. extern int stop_a_enabled;
  595. void sun_do_break(void)
  596. {
  597. if (!stop_a_enabled)
  598. return;
  599. prom_printf("\n");
  600. flush_user_windows();
  601. prom_cmdline();
  602. }
  603. EXPORT_SYMBOL(sun_do_break);
  604. int stop_a_enabled = 1;
  605. EXPORT_SYMBOL(stop_a_enabled);