setup_mm.c 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535
  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. #ifndef CONFIG_SUN3
  197. int i;
  198. #endif
  199. /* The bootinfo is located right after the kernel bss */
  200. m68k_parse_bootinfo((const struct bi_record *)_end);
  201. if (CPU_IS_040)
  202. m68k_is040or060 = 4;
  203. else if (CPU_IS_060)
  204. m68k_is040or060 = 6;
  205. /* FIXME: m68k_fputype is passed in by Penguin booter, which can
  206. * be confused by software FPU emulation. BEWARE.
  207. * We should really do our own FPU check at startup.
  208. * [what do we do with buggy 68LC040s? if we have problems
  209. * with them, we should add a test to check_bugs() below] */
  210. #ifndef CONFIG_M68KFPU_EMU_ONLY
  211. /* clear the fpu if we have one */
  212. if (m68k_fputype & (FPU_68881|FPU_68882|FPU_68040|FPU_68060)) {
  213. volatile int zero = 0;
  214. asm volatile ("frestore %0" : : "m" (zero));
  215. }
  216. #endif
  217. if (CPU_IS_060) {
  218. u32 pcr;
  219. asm (".chip 68060; movec %%pcr,%0; .chip 68k"
  220. : "=d" (pcr));
  221. if (((pcr >> 8) & 0xff) <= 5) {
  222. printk("Enabling workaround for errata I14\n");
  223. asm (".chip 68060; movec %0,%%pcr; .chip 68k"
  224. : : "d" (pcr | 0x20));
  225. }
  226. }
  227. init_mm.start_code = PAGE_OFFSET;
  228. init_mm.end_code = (unsigned long)_etext;
  229. init_mm.end_data = (unsigned long)_edata;
  230. init_mm.brk = (unsigned long)_end;
  231. *cmdline_p = m68k_command_line;
  232. memcpy(boot_command_line, *cmdline_p, CL_SIZE);
  233. parse_early_param();
  234. #ifdef CONFIG_DUMMY_CONSOLE
  235. conswitchp = &dummy_con;
  236. #endif
  237. switch (m68k_machtype) {
  238. #ifdef CONFIG_AMIGA
  239. case MACH_AMIGA:
  240. config_amiga();
  241. break;
  242. #endif
  243. #ifdef CONFIG_ATARI
  244. case MACH_ATARI:
  245. config_atari();
  246. break;
  247. #endif
  248. #ifdef CONFIG_MAC
  249. case MACH_MAC:
  250. config_mac();
  251. break;
  252. #endif
  253. #ifdef CONFIG_SUN3
  254. case MACH_SUN3:
  255. config_sun3();
  256. break;
  257. #endif
  258. #ifdef CONFIG_APOLLO
  259. case MACH_APOLLO:
  260. config_apollo();
  261. break;
  262. #endif
  263. #ifdef CONFIG_MVME147
  264. case MACH_MVME147:
  265. config_mvme147();
  266. break;
  267. #endif
  268. #ifdef CONFIG_MVME16x
  269. case MACH_MVME16x:
  270. config_mvme16x();
  271. break;
  272. #endif
  273. #ifdef CONFIG_BVME6000
  274. case MACH_BVME6000:
  275. config_bvme6000();
  276. break;
  277. #endif
  278. #ifdef CONFIG_HP300
  279. case MACH_HP300:
  280. config_hp300();
  281. break;
  282. #endif
  283. #ifdef CONFIG_Q40
  284. case MACH_Q40:
  285. config_q40();
  286. break;
  287. #endif
  288. #ifdef CONFIG_SUN3X
  289. case MACH_SUN3X:
  290. config_sun3x();
  291. break;
  292. #endif
  293. default:
  294. panic("No configuration setup");
  295. }
  296. #ifdef CONFIG_NATFEAT
  297. nf_init();
  298. #endif
  299. paging_init();
  300. #ifndef CONFIG_SUN3
  301. for (i = 1; i < m68k_num_memory; i++)
  302. free_bootmem_node(NODE_DATA(i), m68k_memory[i].addr,
  303. m68k_memory[i].size);
  304. #ifdef CONFIG_BLK_DEV_INITRD
  305. if (m68k_ramdisk.size) {
  306. reserve_bootmem_node(__virt_to_node(phys_to_virt(m68k_ramdisk.addr)),
  307. m68k_ramdisk.addr, m68k_ramdisk.size,
  308. BOOTMEM_DEFAULT);
  309. initrd_start = (unsigned long)phys_to_virt(m68k_ramdisk.addr);
  310. initrd_end = initrd_start + m68k_ramdisk.size;
  311. printk("initrd: %08lx - %08lx\n", initrd_start, initrd_end);
  312. }
  313. #endif
  314. #ifdef CONFIG_ATARI
  315. if (MACH_IS_ATARI)
  316. atari_stram_reserve_pages((void *)availmem);
  317. #endif
  318. #ifdef CONFIG_SUN3X
  319. if (MACH_IS_SUN3X) {
  320. dvma_init();
  321. }
  322. #endif
  323. #endif /* !CONFIG_SUN3 */
  324. /* set ISA defs early as possible */
  325. #if defined(CONFIG_ISA) && defined(MULTI_ISA)
  326. if (MACH_IS_Q40) {
  327. isa_type = ISA_TYPE_Q40;
  328. isa_sex = 0;
  329. }
  330. #ifdef CONFIG_AMIGA_PCMCIA
  331. if (MACH_IS_AMIGA && AMIGAHW_PRESENT(PCMCIA)) {
  332. isa_type = ISA_TYPE_AG;
  333. isa_sex = 1;
  334. }
  335. #endif
  336. #endif
  337. }
  338. static int show_cpuinfo(struct seq_file *m, void *v)
  339. {
  340. const char *cpu, *mmu, *fpu;
  341. unsigned long clockfreq, clockfactor;
  342. #define LOOP_CYCLES_68020 (8)
  343. #define LOOP_CYCLES_68030 (8)
  344. #define LOOP_CYCLES_68040 (3)
  345. #define LOOP_CYCLES_68060 (1)
  346. if (CPU_IS_020) {
  347. cpu = "68020";
  348. clockfactor = LOOP_CYCLES_68020;
  349. } else if (CPU_IS_030) {
  350. cpu = "68030";
  351. clockfactor = LOOP_CYCLES_68030;
  352. } else if (CPU_IS_040) {
  353. cpu = "68040";
  354. clockfactor = LOOP_CYCLES_68040;
  355. } else if (CPU_IS_060) {
  356. cpu = "68060";
  357. clockfactor = LOOP_CYCLES_68060;
  358. } else {
  359. cpu = "680x0";
  360. clockfactor = 0;
  361. }
  362. #ifdef CONFIG_M68KFPU_EMU_ONLY
  363. fpu = "none(soft float)";
  364. #else
  365. if (m68k_fputype & FPU_68881)
  366. fpu = "68881";
  367. else if (m68k_fputype & FPU_68882)
  368. fpu = "68882";
  369. else if (m68k_fputype & FPU_68040)
  370. fpu = "68040";
  371. else if (m68k_fputype & FPU_68060)
  372. fpu = "68060";
  373. else if (m68k_fputype & FPU_SUNFPA)
  374. fpu = "Sun FPA";
  375. else
  376. fpu = "none";
  377. #endif
  378. if (m68k_mmutype & MMU_68851)
  379. mmu = "68851";
  380. else if (m68k_mmutype & MMU_68030)
  381. mmu = "68030";
  382. else if (m68k_mmutype & MMU_68040)
  383. mmu = "68040";
  384. else if (m68k_mmutype & MMU_68060)
  385. mmu = "68060";
  386. else if (m68k_mmutype & MMU_SUN3)
  387. mmu = "Sun-3";
  388. else if (m68k_mmutype & MMU_APOLLO)
  389. mmu = "Apollo";
  390. else
  391. mmu = "unknown";
  392. clockfreq = loops_per_jiffy * HZ * clockfactor;
  393. seq_printf(m, "CPU:\t\t%s\n"
  394. "MMU:\t\t%s\n"
  395. "FPU:\t\t%s\n"
  396. "Clocking:\t%lu.%1luMHz\n"
  397. "BogoMips:\t%lu.%02lu\n"
  398. "Calibration:\t%lu loops\n",
  399. cpu, mmu, fpu,
  400. clockfreq/1000000,(clockfreq/100000)%10,
  401. loops_per_jiffy/(500000/HZ),(loops_per_jiffy/(5000/HZ))%100,
  402. loops_per_jiffy);
  403. return 0;
  404. }
  405. static void *c_start(struct seq_file *m, loff_t *pos)
  406. {
  407. return *pos < 1 ? (void *)1 : NULL;
  408. }
  409. static void *c_next(struct seq_file *m, void *v, loff_t *pos)
  410. {
  411. ++*pos;
  412. return NULL;
  413. }
  414. static void c_stop(struct seq_file *m, void *v)
  415. {
  416. }
  417. const struct seq_operations cpuinfo_op = {
  418. .start = c_start,
  419. .next = c_next,
  420. .stop = c_stop,
  421. .show = show_cpuinfo,
  422. };
  423. #ifdef CONFIG_PROC_HARDWARE
  424. static int hardware_proc_show(struct seq_file *m, void *v)
  425. {
  426. char model[80];
  427. unsigned long mem;
  428. int i;
  429. if (mach_get_model)
  430. mach_get_model(model);
  431. else
  432. strcpy(model, "Unknown m68k");
  433. seq_printf(m, "Model:\t\t%s\n", model);
  434. for (mem = 0, i = 0; i < m68k_num_memory; i++)
  435. mem += m68k_memory[i].size;
  436. seq_printf(m, "System Memory:\t%ldK\n", mem >> 10);
  437. if (mach_get_hardware_list)
  438. mach_get_hardware_list(m);
  439. return 0;
  440. }
  441. static int hardware_proc_open(struct inode *inode, struct file *file)
  442. {
  443. return single_open(file, hardware_proc_show, NULL);
  444. }
  445. static const struct file_operations hardware_proc_fops = {
  446. .open = hardware_proc_open,
  447. .read = seq_read,
  448. .llseek = seq_lseek,
  449. .release = single_release,
  450. };
  451. static int __init proc_hardware_init(void)
  452. {
  453. proc_create("hardware", 0, NULL, &hardware_proc_fops);
  454. return 0;
  455. }
  456. module_init(proc_hardware_init);
  457. #endif
  458. void check_bugs(void)
  459. {
  460. #ifndef CONFIG_M68KFPU_EMU
  461. if (m68k_fputype == 0) {
  462. printk(KERN_EMERG "*** YOU DO NOT HAVE A FLOATING POINT UNIT, "
  463. "WHICH IS REQUIRED BY LINUX/M68K ***\n");
  464. printk(KERN_EMERG "Upgrade your hardware or join the FPU "
  465. "emulation project\n");
  466. panic("no FPU");
  467. }
  468. #endif /* !CONFIG_M68KFPU_EMU */
  469. }
  470. #ifdef CONFIG_ADB
  471. static int __init adb_probe_sync_enable (char *str) {
  472. extern int __adb_probe_sync;
  473. __adb_probe_sync = 1;
  474. return 1;
  475. }
  476. __setup("adb_sync", adb_probe_sync_enable);
  477. #endif /* CONFIG_ADB */