setup_64.c 9.1 KB

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