setup_64.c 16 KB

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