setup_mm.c 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533
  1. /*
  2. * linux/arch/m68k/kernel/setup.c
  3. *
  4. * Copyright (C) 1995 Hamish Macdonald
  5. */
  6. /*
  7. * This file handles the architecture-dependent parts of system setup
  8. */
  9. #include <linux/kernel.h>
  10. #include <linux/mm.h>
  11. #include <linux/sched.h>
  12. #include <linux/delay.h>
  13. #include <linux/interrupt.h>
  14. #include <linux/fs.h>
  15. #include <linux/console.h>
  16. #include <linux/genhd.h>
  17. #include <linux/errno.h>
  18. #include <linux/string.h>
  19. #include <linux/init.h>
  20. #include <linux/bootmem.h>
  21. #include <linux/proc_fs.h>
  22. #include <linux/seq_file.h>
  23. #include <linux/module.h>
  24. #include <linux/initrd.h>
  25. #include <asm/bootinfo.h>
  26. #include <asm/sections.h>
  27. #include <asm/setup.h>
  28. #include <asm/fpu.h>
  29. #include <asm/irq.h>
  30. #include <asm/io.h>
  31. #include <asm/machdep.h>
  32. #ifdef CONFIG_AMIGA
  33. #include <asm/amigahw.h>
  34. #endif
  35. #ifdef CONFIG_ATARI
  36. #include <asm/atarihw.h>
  37. #include <asm/atari_stram.h>
  38. #endif
  39. #ifdef CONFIG_SUN3X
  40. #include <asm/dvma.h>
  41. #endif
  42. #include <asm/natfeat.h>
  43. #if !FPSTATESIZE || !NR_IRQS
  44. #warning No CPU/platform type selected, your kernel will not work!
  45. #warning Are you building an allnoconfig kernel?
  46. #endif
  47. unsigned long m68k_machtype;
  48. EXPORT_SYMBOL(m68k_machtype);
  49. unsigned long m68k_cputype;
  50. EXPORT_SYMBOL(m68k_cputype);
  51. unsigned long m68k_fputype;
  52. unsigned long m68k_mmutype;
  53. EXPORT_SYMBOL(m68k_mmutype);
  54. #ifdef CONFIG_VME
  55. unsigned long vme_brdtype;
  56. EXPORT_SYMBOL(vme_brdtype);
  57. #endif
  58. int m68k_is040or060;
  59. EXPORT_SYMBOL(m68k_is040or060);
  60. extern unsigned long availmem;
  61. int m68k_num_memory;
  62. EXPORT_SYMBOL(m68k_num_memory);
  63. int m68k_realnum_memory;
  64. EXPORT_SYMBOL(m68k_realnum_memory);
  65. unsigned long m68k_memoffset;
  66. struct mem_info m68k_memory[NUM_MEMINFO];
  67. EXPORT_SYMBOL(m68k_memory);
  68. struct mem_info m68k_ramdisk;
  69. static char m68k_command_line[CL_SIZE];
  70. void (*mach_sched_init) (irq_handler_t handler) __initdata = NULL;
  71. /* machine dependent irq functions */
  72. void (*mach_init_IRQ) (void) __initdata = NULL;
  73. void (*mach_get_model) (char *model);
  74. void (*mach_get_hardware_list) (struct seq_file *m);
  75. /* machine dependent timer functions */
  76. unsigned long (*mach_gettimeoffset) (void);
  77. int (*mach_hwclk) (int, struct rtc_time*);
  78. EXPORT_SYMBOL(mach_hwclk);
  79. int (*mach_set_clock_mmss) (unsigned long);
  80. unsigned int (*mach_get_ss)(void);
  81. int (*mach_get_rtc_pll)(struct rtc_pll_info *);
  82. int (*mach_set_rtc_pll)(struct rtc_pll_info *);
  83. EXPORT_SYMBOL(mach_get_ss);
  84. EXPORT_SYMBOL(mach_get_rtc_pll);
  85. EXPORT_SYMBOL(mach_set_rtc_pll);
  86. void (*mach_reset)( void );
  87. void (*mach_halt)( void );
  88. void (*mach_power_off)( void );
  89. long mach_max_dma_address = 0x00ffffff; /* default set to the lower 16MB */
  90. #ifdef CONFIG_HEARTBEAT
  91. void (*mach_heartbeat) (int);
  92. EXPORT_SYMBOL(mach_heartbeat);
  93. #endif
  94. #ifdef CONFIG_M68K_L2_CACHE
  95. void (*mach_l2_flush) (int);
  96. #endif
  97. #if defined(CONFIG_INPUT_M68K_BEEP) || defined(CONFIG_INPUT_M68K_BEEP_MODULE)
  98. void (*mach_beep)(unsigned int, unsigned int);
  99. EXPORT_SYMBOL(mach_beep);
  100. #endif
  101. #if defined(CONFIG_ISA) && defined(MULTI_ISA)
  102. int isa_type;
  103. int isa_sex;
  104. EXPORT_SYMBOL(isa_type);
  105. EXPORT_SYMBOL(isa_sex);
  106. #endif
  107. extern int amiga_parse_bootinfo(const struct bi_record *);
  108. extern int atari_parse_bootinfo(const struct bi_record *);
  109. extern int mac_parse_bootinfo(const struct bi_record *);
  110. extern int q40_parse_bootinfo(const struct bi_record *);
  111. extern int bvme6000_parse_bootinfo(const struct bi_record *);
  112. extern int mvme16x_parse_bootinfo(const struct bi_record *);
  113. extern int mvme147_parse_bootinfo(const struct bi_record *);
  114. extern int hp300_parse_bootinfo(const struct bi_record *);
  115. extern int apollo_parse_bootinfo(const struct bi_record *);
  116. extern void config_amiga(void);
  117. extern void config_atari(void);
  118. extern void config_mac(void);
  119. extern void config_sun3(void);
  120. extern void config_apollo(void);
  121. extern void config_mvme147(void);
  122. extern void config_mvme16x(void);
  123. extern void config_bvme6000(void);
  124. extern void config_hp300(void);
  125. extern void config_q40(void);
  126. extern void config_sun3x(void);
  127. #define MASK_256K 0xfffc0000
  128. extern void paging_init(void);
  129. static void __init m68k_parse_bootinfo(const struct bi_record *record)
  130. {
  131. while (record->tag != BI_LAST) {
  132. int unknown = 0;
  133. const unsigned long *data = record->data;
  134. switch (record->tag) {
  135. case BI_MACHTYPE:
  136. case BI_CPUTYPE:
  137. case BI_FPUTYPE:
  138. case BI_MMUTYPE:
  139. /* Already set up by head.S */
  140. break;
  141. case BI_MEMCHUNK:
  142. if (m68k_num_memory < NUM_MEMINFO) {
  143. m68k_memory[m68k_num_memory].addr = data[0];
  144. m68k_memory[m68k_num_memory].size = data[1];
  145. m68k_num_memory++;
  146. } else
  147. printk("m68k_parse_bootinfo: too many memory chunks\n");
  148. break;
  149. case BI_RAMDISK:
  150. m68k_ramdisk.addr = data[0];
  151. m68k_ramdisk.size = data[1];
  152. break;
  153. case BI_COMMAND_LINE:
  154. strlcpy(m68k_command_line, (const char *)data,
  155. sizeof(m68k_command_line));
  156. break;
  157. default:
  158. if (MACH_IS_AMIGA)
  159. unknown = amiga_parse_bootinfo(record);
  160. else if (MACH_IS_ATARI)
  161. unknown = atari_parse_bootinfo(record);
  162. else if (MACH_IS_MAC)
  163. unknown = mac_parse_bootinfo(record);
  164. else if (MACH_IS_Q40)
  165. unknown = q40_parse_bootinfo(record);
  166. else if (MACH_IS_BVME6000)
  167. unknown = bvme6000_parse_bootinfo(record);
  168. else if (MACH_IS_MVME16x)
  169. unknown = mvme16x_parse_bootinfo(record);
  170. else if (MACH_IS_MVME147)
  171. unknown = mvme147_parse_bootinfo(record);
  172. else if (MACH_IS_HP300)
  173. unknown = hp300_parse_bootinfo(record);
  174. else if (MACH_IS_APOLLO)
  175. unknown = apollo_parse_bootinfo(record);
  176. else
  177. unknown = 1;
  178. }
  179. if (unknown)
  180. printk("m68k_parse_bootinfo: unknown tag 0x%04x ignored\n",
  181. record->tag);
  182. record = (struct bi_record *)((unsigned long)record +
  183. record->size);
  184. }
  185. m68k_realnum_memory = m68k_num_memory;
  186. #ifdef CONFIG_SINGLE_MEMORY_CHUNK
  187. if (m68k_num_memory > 1) {
  188. printk("Ignoring last %i chunks of physical memory\n",
  189. (m68k_num_memory - 1));
  190. m68k_num_memory = 1;
  191. }
  192. #endif
  193. }
  194. void __init setup_arch(char **cmdline_p)
  195. {
  196. int i;
  197. /* The bootinfo is located right after the kernel bss */
  198. m68k_parse_bootinfo((const struct bi_record *)_end);
  199. if (CPU_IS_040)
  200. m68k_is040or060 = 4;
  201. else if (CPU_IS_060)
  202. m68k_is040or060 = 6;
  203. /* FIXME: m68k_fputype is passed in by Penguin booter, which can
  204. * be confused by software FPU emulation. BEWARE.
  205. * We should really do our own FPU check at startup.
  206. * [what do we do with buggy 68LC040s? if we have problems
  207. * with them, we should add a test to check_bugs() below] */
  208. #ifndef CONFIG_M68KFPU_EMU_ONLY
  209. /* clear the fpu if we have one */
  210. if (m68k_fputype & (FPU_68881|FPU_68882|FPU_68040|FPU_68060)) {
  211. volatile int zero = 0;
  212. asm volatile ("frestore %0" : : "m" (zero));
  213. }
  214. #endif
  215. if (CPU_IS_060) {
  216. u32 pcr;
  217. asm (".chip 68060; movec %%pcr,%0; .chip 68k"
  218. : "=d" (pcr));
  219. if (((pcr >> 8) & 0xff) <= 5) {
  220. printk("Enabling workaround for errata I14\n");
  221. asm (".chip 68060; movec %0,%%pcr; .chip 68k"
  222. : : "d" (pcr | 0x20));
  223. }
  224. }
  225. init_mm.start_code = PAGE_OFFSET;
  226. init_mm.end_code = (unsigned long)_etext;
  227. init_mm.end_data = (unsigned long)_edata;
  228. init_mm.brk = (unsigned long)_end;
  229. *cmdline_p = m68k_command_line;
  230. memcpy(boot_command_line, *cmdline_p, CL_SIZE);
  231. parse_early_param();
  232. #ifdef CONFIG_DUMMY_CONSOLE
  233. conswitchp = &dummy_con;
  234. #endif
  235. switch (m68k_machtype) {
  236. #ifdef CONFIG_AMIGA
  237. case MACH_AMIGA:
  238. config_amiga();
  239. break;
  240. #endif
  241. #ifdef CONFIG_ATARI
  242. case MACH_ATARI:
  243. config_atari();
  244. break;
  245. #endif
  246. #ifdef CONFIG_MAC
  247. case MACH_MAC:
  248. config_mac();
  249. break;
  250. #endif
  251. #ifdef CONFIG_SUN3
  252. case MACH_SUN3:
  253. config_sun3();
  254. break;
  255. #endif
  256. #ifdef CONFIG_APOLLO
  257. case MACH_APOLLO:
  258. config_apollo();
  259. break;
  260. #endif
  261. #ifdef CONFIG_MVME147
  262. case MACH_MVME147:
  263. config_mvme147();
  264. break;
  265. #endif
  266. #ifdef CONFIG_MVME16x
  267. case MACH_MVME16x:
  268. config_mvme16x();
  269. break;
  270. #endif
  271. #ifdef CONFIG_BVME6000
  272. case MACH_BVME6000:
  273. config_bvme6000();
  274. break;
  275. #endif
  276. #ifdef CONFIG_HP300
  277. case MACH_HP300:
  278. config_hp300();
  279. break;
  280. #endif
  281. #ifdef CONFIG_Q40
  282. case MACH_Q40:
  283. config_q40();
  284. break;
  285. #endif
  286. #ifdef CONFIG_SUN3X
  287. case MACH_SUN3X:
  288. config_sun3x();
  289. break;
  290. #endif
  291. default:
  292. panic("No configuration setup");
  293. }
  294. #ifdef CONFIG_NATFEAT
  295. nf_init();
  296. #endif
  297. paging_init();
  298. #ifndef CONFIG_SUN3
  299. for (i = 1; i < m68k_num_memory; i++)
  300. free_bootmem_node(NODE_DATA(i), m68k_memory[i].addr,
  301. m68k_memory[i].size);
  302. #ifdef CONFIG_BLK_DEV_INITRD
  303. if (m68k_ramdisk.size) {
  304. reserve_bootmem_node(__virt_to_node(phys_to_virt(m68k_ramdisk.addr)),
  305. m68k_ramdisk.addr, m68k_ramdisk.size,
  306. BOOTMEM_DEFAULT);
  307. initrd_start = (unsigned long)phys_to_virt(m68k_ramdisk.addr);
  308. initrd_end = initrd_start + m68k_ramdisk.size;
  309. printk("initrd: %08lx - %08lx\n", initrd_start, initrd_end);
  310. }
  311. #endif
  312. #ifdef CONFIG_ATARI
  313. if (MACH_IS_ATARI)
  314. atari_stram_reserve_pages((void *)availmem);
  315. #endif
  316. #ifdef CONFIG_SUN3X
  317. if (MACH_IS_SUN3X) {
  318. dvma_init();
  319. }
  320. #endif
  321. #endif /* !CONFIG_SUN3 */
  322. /* set ISA defs early as possible */
  323. #if defined(CONFIG_ISA) && defined(MULTI_ISA)
  324. if (MACH_IS_Q40) {
  325. isa_type = ISA_TYPE_Q40;
  326. isa_sex = 0;
  327. }
  328. #ifdef CONFIG_AMIGA_PCMCIA
  329. if (MACH_IS_AMIGA && AMIGAHW_PRESENT(PCMCIA)) {
  330. isa_type = ISA_TYPE_AG;
  331. isa_sex = 1;
  332. }
  333. #endif
  334. #endif
  335. }
  336. static int show_cpuinfo(struct seq_file *m, void *v)
  337. {
  338. const char *cpu, *mmu, *fpu;
  339. unsigned long clockfreq, clockfactor;
  340. #define LOOP_CYCLES_68020 (8)
  341. #define LOOP_CYCLES_68030 (8)
  342. #define LOOP_CYCLES_68040 (3)
  343. #define LOOP_CYCLES_68060 (1)
  344. if (CPU_IS_020) {
  345. cpu = "68020";
  346. clockfactor = LOOP_CYCLES_68020;
  347. } else if (CPU_IS_030) {
  348. cpu = "68030";
  349. clockfactor = LOOP_CYCLES_68030;
  350. } else if (CPU_IS_040) {
  351. cpu = "68040";
  352. clockfactor = LOOP_CYCLES_68040;
  353. } else if (CPU_IS_060) {
  354. cpu = "68060";
  355. clockfactor = LOOP_CYCLES_68060;
  356. } else {
  357. cpu = "680x0";
  358. clockfactor = 0;
  359. }
  360. #ifdef CONFIG_M68KFPU_EMU_ONLY
  361. fpu = "none(soft float)";
  362. #else
  363. if (m68k_fputype & FPU_68881)
  364. fpu = "68881";
  365. else if (m68k_fputype & FPU_68882)
  366. fpu = "68882";
  367. else if (m68k_fputype & FPU_68040)
  368. fpu = "68040";
  369. else if (m68k_fputype & FPU_68060)
  370. fpu = "68060";
  371. else if (m68k_fputype & FPU_SUNFPA)
  372. fpu = "Sun FPA";
  373. else
  374. fpu = "none";
  375. #endif
  376. if (m68k_mmutype & MMU_68851)
  377. mmu = "68851";
  378. else if (m68k_mmutype & MMU_68030)
  379. mmu = "68030";
  380. else if (m68k_mmutype & MMU_68040)
  381. mmu = "68040";
  382. else if (m68k_mmutype & MMU_68060)
  383. mmu = "68060";
  384. else if (m68k_mmutype & MMU_SUN3)
  385. mmu = "Sun-3";
  386. else if (m68k_mmutype & MMU_APOLLO)
  387. mmu = "Apollo";
  388. else
  389. mmu = "unknown";
  390. clockfreq = loops_per_jiffy * HZ * clockfactor;
  391. seq_printf(m, "CPU:\t\t%s\n"
  392. "MMU:\t\t%s\n"
  393. "FPU:\t\t%s\n"
  394. "Clocking:\t%lu.%1luMHz\n"
  395. "BogoMips:\t%lu.%02lu\n"
  396. "Calibration:\t%lu loops\n",
  397. cpu, mmu, fpu,
  398. clockfreq/1000000,(clockfreq/100000)%10,
  399. loops_per_jiffy/(500000/HZ),(loops_per_jiffy/(5000/HZ))%100,
  400. loops_per_jiffy);
  401. return 0;
  402. }
  403. static void *c_start(struct seq_file *m, loff_t *pos)
  404. {
  405. return *pos < 1 ? (void *)1 : NULL;
  406. }
  407. static void *c_next(struct seq_file *m, void *v, loff_t *pos)
  408. {
  409. ++*pos;
  410. return NULL;
  411. }
  412. static void c_stop(struct seq_file *m, void *v)
  413. {
  414. }
  415. const struct seq_operations cpuinfo_op = {
  416. .start = c_start,
  417. .next = c_next,
  418. .stop = c_stop,
  419. .show = show_cpuinfo,
  420. };
  421. #ifdef CONFIG_PROC_HARDWARE
  422. static int hardware_proc_show(struct seq_file *m, void *v)
  423. {
  424. char model[80];
  425. unsigned long mem;
  426. int i;
  427. if (mach_get_model)
  428. mach_get_model(model);
  429. else
  430. strcpy(model, "Unknown m68k");
  431. seq_printf(m, "Model:\t\t%s\n", model);
  432. for (mem = 0, i = 0; i < m68k_num_memory; i++)
  433. mem += m68k_memory[i].size;
  434. seq_printf(m, "System Memory:\t%ldK\n", mem >> 10);
  435. if (mach_get_hardware_list)
  436. mach_get_hardware_list(m);
  437. return 0;
  438. }
  439. static int hardware_proc_open(struct inode *inode, struct file *file)
  440. {
  441. return single_open(file, hardware_proc_show, NULL);
  442. }
  443. static const struct file_operations hardware_proc_fops = {
  444. .open = hardware_proc_open,
  445. .read = seq_read,
  446. .llseek = seq_lseek,
  447. .release = single_release,
  448. };
  449. static int __init proc_hardware_init(void)
  450. {
  451. proc_create("hardware", 0, NULL, &hardware_proc_fops);
  452. return 0;
  453. }
  454. module_init(proc_hardware_init);
  455. #endif
  456. void check_bugs(void)
  457. {
  458. #ifndef CONFIG_M68KFPU_EMU
  459. if (m68k_fputype == 0) {
  460. printk(KERN_EMERG "*** YOU DO NOT HAVE A FLOATING POINT UNIT, "
  461. "WHICH IS REQUIRED BY LINUX/M68K ***\n");
  462. printk(KERN_EMERG "Upgrade your hardware or join the FPU "
  463. "emulation project\n");
  464. panic("no FPU");
  465. }
  466. #endif /* !CONFIG_M68KFPU_EMU */
  467. }
  468. #ifdef CONFIG_ADB
  469. static int __init adb_probe_sync_enable (char *str) {
  470. extern int __adb_probe_sync;
  471. __adb_probe_sync = 1;
  472. return 1;
  473. }
  474. __setup("adb_sync", adb_probe_sync_enable);
  475. #endif /* CONFIG_ADB */