setup_64.c 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436
  1. /*
  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/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 <asm/system.h>
  33. #include <asm/io.h>
  34. #include <asm/processor.h>
  35. #include <asm/oplib.h>
  36. #include <asm/page.h>
  37. #include <asm/pgtable.h>
  38. #include <asm/idprom.h>
  39. #include <asm/head.h>
  40. #include <asm/starfire.h>
  41. #include <asm/mmu_context.h>
  42. #include <asm/timer.h>
  43. #include <asm/sections.h>
  44. #include <asm/setup.h>
  45. #include <asm/mmu.h>
  46. #include <asm/ns87303.h>
  47. #include <asm/btext.h>
  48. #ifdef CONFIG_IP_PNP
  49. #include <net/ipconfig.h>
  50. #endif
  51. #include "entry.h"
  52. #include "kernel.h"
  53. /* Used to synchronize accesses to NatSemi SUPER I/O chip configure
  54. * operations in asm/ns87303.h
  55. */
  56. DEFINE_SPINLOCK(ns87303_lock);
  57. EXPORT_SYMBOL(ns87303_lock);
  58. struct screen_info screen_info = {
  59. 0, 0, /* orig-x, orig-y */
  60. 0, /* unused */
  61. 0, /* orig-video-page */
  62. 0, /* orig-video-mode */
  63. 128, /* orig-video-cols */
  64. 0, 0, 0, /* unused, ega_bx, unused */
  65. 54, /* orig-video-lines */
  66. 0, /* orig-video-isVGA */
  67. 16 /* orig-video-points */
  68. };
  69. static void
  70. prom_console_write(struct console *con, const char *s, unsigned n)
  71. {
  72. prom_write(s, n);
  73. }
  74. /* Exported for mm/init.c:paging_init. */
  75. unsigned long cmdline_memory_size = 0;
  76. static struct console prom_early_console = {
  77. .name = "earlyprom",
  78. .write = prom_console_write,
  79. .flags = CON_PRINTBUFFER | CON_BOOT | CON_ANYTIME,
  80. .index = -1,
  81. };
  82. /*
  83. * Process kernel command line switches that are specific to the
  84. * SPARC or that require special low-level processing.
  85. */
  86. static void __init process_switch(char c)
  87. {
  88. switch (c) {
  89. case 'd':
  90. case 's':
  91. break;
  92. case 'h':
  93. prom_printf("boot_flags_init: Halt!\n");
  94. prom_halt();
  95. break;
  96. case 'p':
  97. /* Just ignore, this behavior is now the default. */
  98. break;
  99. case 'P':
  100. /* Force UltraSPARC-III P-Cache on. */
  101. if (tlb_type != cheetah) {
  102. printk("BOOT: Ignoring P-Cache force option.\n");
  103. break;
  104. }
  105. cheetah_pcache_forced_on = 1;
  106. add_taint(TAINT_MACHINE_CHECK);
  107. cheetah_enable_pcache();
  108. break;
  109. default:
  110. printk("Unknown boot switch (-%c)\n", c);
  111. break;
  112. }
  113. }
  114. static void __init boot_flags_init(char *commands)
  115. {
  116. while (*commands) {
  117. /* Move to the start of the next "argument". */
  118. while (*commands && *commands == ' ')
  119. commands++;
  120. /* Process any command switches, otherwise skip it. */
  121. if (*commands == '\0')
  122. break;
  123. if (*commands == '-') {
  124. commands++;
  125. while (*commands && *commands != ' ')
  126. process_switch(*commands++);
  127. continue;
  128. }
  129. if (!strncmp(commands, "mem=", 4)) {
  130. /*
  131. * "mem=XXX[kKmM]" overrides the PROM-reported
  132. * memory size.
  133. */
  134. cmdline_memory_size = simple_strtoul(commands + 4,
  135. &commands, 0);
  136. if (*commands == 'K' || *commands == 'k') {
  137. cmdline_memory_size <<= 10;
  138. commands++;
  139. } else if (*commands=='M' || *commands=='m') {
  140. cmdline_memory_size <<= 20;
  141. commands++;
  142. }
  143. }
  144. while (*commands && *commands != ' ')
  145. commands++;
  146. }
  147. }
  148. extern unsigned short root_flags;
  149. extern unsigned short root_dev;
  150. extern unsigned short ram_flags;
  151. #define RAMDISK_IMAGE_START_MASK 0x07FF
  152. #define RAMDISK_PROMPT_FLAG 0x8000
  153. #define RAMDISK_LOAD_FLAG 0x4000
  154. extern int root_mountflags;
  155. char reboot_command[COMMAND_LINE_SIZE];
  156. static struct pt_regs fake_swapper_regs = { { 0, }, 0, 0, 0, 0 };
  157. void __init per_cpu_patch(void)
  158. {
  159. struct cpuid_patch_entry *p;
  160. unsigned long ver;
  161. int is_jbus;
  162. if (tlb_type == spitfire && !this_is_starfire)
  163. return;
  164. is_jbus = 0;
  165. if (tlb_type != hypervisor) {
  166. __asm__ ("rdpr %%ver, %0" : "=r" (ver));
  167. is_jbus = ((ver >> 32UL) == __JALAPENO_ID ||
  168. (ver >> 32UL) == __SERRANO_ID);
  169. }
  170. p = &__cpuid_patch;
  171. while (p < &__cpuid_patch_end) {
  172. unsigned long addr = p->addr;
  173. unsigned int *insns;
  174. switch (tlb_type) {
  175. case spitfire:
  176. insns = &p->starfire[0];
  177. break;
  178. case cheetah:
  179. case cheetah_plus:
  180. if (is_jbus)
  181. insns = &p->cheetah_jbus[0];
  182. else
  183. insns = &p->cheetah_safari[0];
  184. break;
  185. case hypervisor:
  186. insns = &p->sun4v[0];
  187. break;
  188. default:
  189. prom_printf("Unknown cpu type, halting.\n");
  190. prom_halt();
  191. };
  192. *(unsigned int *) (addr + 0) = insns[0];
  193. wmb();
  194. __asm__ __volatile__("flush %0" : : "r" (addr + 0));
  195. *(unsigned int *) (addr + 4) = insns[1];
  196. wmb();
  197. __asm__ __volatile__("flush %0" : : "r" (addr + 4));
  198. *(unsigned int *) (addr + 8) = insns[2];
  199. wmb();
  200. __asm__ __volatile__("flush %0" : : "r" (addr + 8));
  201. *(unsigned int *) (addr + 12) = insns[3];
  202. wmb();
  203. __asm__ __volatile__("flush %0" : : "r" (addr + 12));
  204. p++;
  205. }
  206. }
  207. void __init sun4v_patch(void)
  208. {
  209. extern void sun4v_hvapi_init(void);
  210. struct sun4v_1insn_patch_entry *p1;
  211. struct sun4v_2insn_patch_entry *p2;
  212. if (tlb_type != hypervisor)
  213. return;
  214. p1 = &__sun4v_1insn_patch;
  215. while (p1 < &__sun4v_1insn_patch_end) {
  216. unsigned long addr = p1->addr;
  217. *(unsigned int *) (addr + 0) = p1->insn;
  218. wmb();
  219. __asm__ __volatile__("flush %0" : : "r" (addr + 0));
  220. p1++;
  221. }
  222. p2 = &__sun4v_2insn_patch;
  223. while (p2 < &__sun4v_2insn_patch_end) {
  224. unsigned long addr = p2->addr;
  225. *(unsigned int *) (addr + 0) = p2->insns[0];
  226. wmb();
  227. __asm__ __volatile__("flush %0" : : "r" (addr + 0));
  228. *(unsigned int *) (addr + 4) = p2->insns[1];
  229. wmb();
  230. __asm__ __volatile__("flush %0" : : "r" (addr + 4));
  231. p2++;
  232. }
  233. sun4v_hvapi_init();
  234. }
  235. #ifdef CONFIG_SMP
  236. void __init boot_cpu_id_too_large(int cpu)
  237. {
  238. prom_printf("Serious problem, boot cpu id (%d) >= NR_CPUS (%d)\n",
  239. cpu, NR_CPUS);
  240. prom_halt();
  241. }
  242. #endif
  243. void __init setup_arch(char **cmdline_p)
  244. {
  245. /* Initialize PROM console and command line. */
  246. *cmdline_p = prom_getbootargs();
  247. strcpy(boot_command_line, *cmdline_p);
  248. parse_early_param();
  249. boot_flags_init(*cmdline_p);
  250. #ifdef CONFIG_EARLYFB
  251. if (btext_find_display())
  252. #endif
  253. register_console(&prom_early_console);
  254. if (tlb_type == hypervisor)
  255. printk("ARCH: SUN4V\n");
  256. else
  257. printk("ARCH: SUN4U\n");
  258. #ifdef CONFIG_DUMMY_CONSOLE
  259. conswitchp = &dummy_con;
  260. #endif
  261. idprom_init();
  262. if (!root_flags)
  263. root_mountflags &= ~MS_RDONLY;
  264. ROOT_DEV = old_decode_dev(root_dev);
  265. #ifdef CONFIG_BLK_DEV_RAM
  266. rd_image_start = ram_flags & RAMDISK_IMAGE_START_MASK;
  267. rd_prompt = ((ram_flags & RAMDISK_PROMPT_FLAG) != 0);
  268. rd_doload = ((ram_flags & RAMDISK_LOAD_FLAG) != 0);
  269. #endif
  270. task_thread_info(&init_task)->kregs = &fake_swapper_regs;
  271. #ifdef CONFIG_IP_PNP
  272. if (!ic_set_manually) {
  273. int chosen = prom_finddevice ("/chosen");
  274. u32 cl, sv, gw;
  275. cl = prom_getintdefault (chosen, "client-ip", 0);
  276. sv = prom_getintdefault (chosen, "server-ip", 0);
  277. gw = prom_getintdefault (chosen, "gateway-ip", 0);
  278. if (cl && sv) {
  279. ic_myaddr = cl;
  280. ic_servaddr = sv;
  281. if (gw)
  282. ic_gateway = gw;
  283. #if defined(CONFIG_IP_PNP_BOOTP) || defined(CONFIG_IP_PNP_RARP)
  284. ic_proto_enabled = 0;
  285. #endif
  286. }
  287. }
  288. #endif
  289. /* Get boot processor trap_block[] setup. */
  290. init_cur_cpu_trap(current_thread_info());
  291. paging_init();
  292. }
  293. /* BUFFER is PAGE_SIZE bytes long. */
  294. extern void smp_info(struct seq_file *);
  295. extern void smp_bogo(struct seq_file *);
  296. extern void mmu_info(struct seq_file *);
  297. unsigned int dcache_parity_tl1_occurred;
  298. unsigned int icache_parity_tl1_occurred;
  299. int ncpus_probed;
  300. static int show_cpuinfo(struct seq_file *m, void *__unused)
  301. {
  302. seq_printf(m,
  303. "cpu\t\t: %s\n"
  304. "fpu\t\t: %s\n"
  305. "pmu\t\t: %s\n"
  306. "prom\t\t: %s\n"
  307. "type\t\t: %s\n"
  308. "ncpus probed\t: %d\n"
  309. "ncpus active\t: %d\n"
  310. "D$ parity tl1\t: %u\n"
  311. "I$ parity tl1\t: %u\n"
  312. #ifndef CONFIG_SMP
  313. "Cpu0ClkTck\t: %016lx\n"
  314. #endif
  315. ,
  316. sparc_cpu_type,
  317. sparc_fpu_type,
  318. sparc_pmu_type,
  319. prom_version,
  320. ((tlb_type == hypervisor) ?
  321. "sun4v" :
  322. "sun4u"),
  323. ncpus_probed,
  324. num_online_cpus(),
  325. dcache_parity_tl1_occurred,
  326. icache_parity_tl1_occurred
  327. #ifndef CONFIG_SMP
  328. , cpu_data(0).clock_tick
  329. #endif
  330. );
  331. #ifdef CONFIG_SMP
  332. smp_bogo(m);
  333. #endif
  334. mmu_info(m);
  335. #ifdef CONFIG_SMP
  336. smp_info(m);
  337. #endif
  338. return 0;
  339. }
  340. static void *c_start(struct seq_file *m, loff_t *pos)
  341. {
  342. /* The pointer we are returning is arbitrary,
  343. * it just has to be non-NULL and not IS_ERR
  344. * in the success case.
  345. */
  346. return *pos == 0 ? &c_start : NULL;
  347. }
  348. static void *c_next(struct seq_file *m, void *v, loff_t *pos)
  349. {
  350. ++*pos;
  351. return c_start(m, pos);
  352. }
  353. static void c_stop(struct seq_file *m, void *v)
  354. {
  355. }
  356. const struct seq_operations cpuinfo_op = {
  357. .start =c_start,
  358. .next = c_next,
  359. .stop = c_stop,
  360. .show = show_cpuinfo,
  361. };
  362. extern int stop_a_enabled;
  363. void sun_do_break(void)
  364. {
  365. if (!stop_a_enabled)
  366. return;
  367. prom_printf("\n");
  368. flush_user_windows();
  369. prom_cmdline();
  370. }
  371. EXPORT_SYMBOL(sun_do_break);
  372. int stop_a_enabled = 1;
  373. EXPORT_SYMBOL(stop_a_enabled);