setup_32.c 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311
  1. /*
  2. * Common prep/pmac/chrp boot and setup code.
  3. */
  4. #include <linux/config.h>
  5. #include <linux/module.h>
  6. #include <linux/string.h>
  7. #include <linux/sched.h>
  8. #include <linux/init.h>
  9. #include <linux/kernel.h>
  10. #include <linux/reboot.h>
  11. #include <linux/delay.h>
  12. #include <linux/initrd.h>
  13. #include <linux/ide.h>
  14. #include <linux/tty.h>
  15. #include <linux/bootmem.h>
  16. #include <linux/seq_file.h>
  17. #include <linux/root_dev.h>
  18. #include <linux/cpu.h>
  19. #include <linux/console.h>
  20. #include <asm/residual.h>
  21. #include <asm/io.h>
  22. #include <asm/prom.h>
  23. #include <asm/processor.h>
  24. #include <asm/pgtable.h>
  25. #include <asm/setup.h>
  26. #include <asm/amigappc.h>
  27. #include <asm/smp.h>
  28. #include <asm/elf.h>
  29. #include <asm/cputable.h>
  30. #include <asm/bootx.h>
  31. #include <asm/btext.h>
  32. #include <asm/machdep.h>
  33. #include <asm/uaccess.h>
  34. #include <asm/system.h>
  35. #include <asm/pmac_feature.h>
  36. #include <asm/sections.h>
  37. #include <asm/nvram.h>
  38. #include <asm/xmon.h>
  39. #include <asm/time.h>
  40. #include <asm/serial.h>
  41. #include <asm/udbg.h>
  42. #include "setup.h"
  43. #define DBG(fmt...)
  44. #if defined CONFIG_KGDB
  45. #include <asm/kgdb.h>
  46. #endif
  47. extern void bootx_init(unsigned long r4, unsigned long phys);
  48. boot_infos_t *boot_infos;
  49. struct ide_machdep_calls ppc_ide_md;
  50. int boot_cpuid;
  51. EXPORT_SYMBOL_GPL(boot_cpuid);
  52. int boot_cpuid_phys;
  53. unsigned long ISA_DMA_THRESHOLD;
  54. unsigned int DMA_MODE_READ;
  55. unsigned int DMA_MODE_WRITE;
  56. int have_of = 1;
  57. #ifdef CONFIG_PPC_MULTIPLATFORM
  58. dev_t boot_dev;
  59. #endif /* CONFIG_PPC_MULTIPLATFORM */
  60. #ifdef CONFIG_MAGIC_SYSRQ
  61. unsigned long SYSRQ_KEY = 0x54;
  62. #endif /* CONFIG_MAGIC_SYSRQ */
  63. #ifdef CONFIG_VGA_CONSOLE
  64. unsigned long vgacon_remap_base;
  65. #endif
  66. /*
  67. * These are used in binfmt_elf.c to put aux entries on the stack
  68. * for each elf executable being started.
  69. */
  70. int dcache_bsize;
  71. int icache_bsize;
  72. int ucache_bsize;
  73. /*
  74. * We're called here very early in the boot. We determine the machine
  75. * type and call the appropriate low-level setup functions.
  76. * -- Cort <cort@fsmlabs.com>
  77. *
  78. * Note that the kernel may be running at an address which is different
  79. * from the address that it was linked at, so we must use RELOC/PTRRELOC
  80. * to access static data (including strings). -- paulus
  81. */
  82. unsigned long __init early_init(unsigned long dt_ptr)
  83. {
  84. unsigned long offset = reloc_offset();
  85. /* First zero the BSS -- use memset_io, some platforms don't have
  86. * caches on yet */
  87. memset_io((void __iomem *)PTRRELOC(&__bss_start), 0, _end - __bss_start);
  88. /*
  89. * Identify the CPU type and fix up code sections
  90. * that depend on which cpu we have.
  91. */
  92. identify_cpu(offset, 0);
  93. do_cpu_ftr_fixups(offset);
  94. return KERNELBASE + offset;
  95. }
  96. /*
  97. * Find out what kind of machine we're on and save any data we need
  98. * from the early boot process (devtree is copied on pmac by prom_init()).
  99. * This is called very early on the boot process, after a minimal
  100. * MMU environment has been set up but before MMU_init is called.
  101. */
  102. void __init machine_init(unsigned long dt_ptr, unsigned long phys)
  103. {
  104. /* If btext is enabled, we might have a BAT setup for early display,
  105. * thus we do enable some very basic udbg output
  106. */
  107. #ifdef CONFIG_BOOTX_TEXT
  108. udbg_putc = btext_drawchar;
  109. #endif
  110. /* Do some early initialization based on the flat device tree */
  111. early_init_devtree(__va(dt_ptr));
  112. /* Check default command line */
  113. #ifdef CONFIG_CMDLINE
  114. if (cmd_line[0] == 0)
  115. strlcpy(cmd_line, CONFIG_CMDLINE, sizeof(cmd_line));
  116. #endif /* CONFIG_CMDLINE */
  117. probe_machine();
  118. #ifdef CONFIG_6xx
  119. if (cpu_has_feature(CPU_FTR_CAN_DOZE) ||
  120. cpu_has_feature(CPU_FTR_CAN_NAP))
  121. ppc_md.power_save = ppc6xx_idle;
  122. #endif
  123. if (ppc_md.progress)
  124. ppc_md.progress("id mach(): done", 0x200);
  125. }
  126. #ifdef CONFIG_BOOKE_WDT
  127. /* Checks wdt=x and wdt_period=xx command-line option */
  128. int __init early_parse_wdt(char *p)
  129. {
  130. if (p && strncmp(p, "0", 1) != 0)
  131. booke_wdt_enabled = 1;
  132. return 0;
  133. }
  134. early_param("wdt", early_parse_wdt);
  135. int __init early_parse_wdt_period (char *p)
  136. {
  137. if (p)
  138. booke_wdt_period = simple_strtoul(p, NULL, 0);
  139. return 0;
  140. }
  141. early_param("wdt_period", early_parse_wdt_period);
  142. #endif /* CONFIG_BOOKE_WDT */
  143. /* Checks "l2cr=xxxx" command-line option */
  144. int __init ppc_setup_l2cr(char *str)
  145. {
  146. if (cpu_has_feature(CPU_FTR_L2CR)) {
  147. unsigned long val = simple_strtoul(str, NULL, 0);
  148. printk(KERN_INFO "l2cr set to %lx\n", val);
  149. _set_L2CR(0); /* force invalidate by disable cache */
  150. _set_L2CR(val); /* and enable it */
  151. }
  152. return 1;
  153. }
  154. __setup("l2cr=", ppc_setup_l2cr);
  155. #ifdef CONFIG_GENERIC_NVRAM
  156. /* Generic nvram hooks used by drivers/char/gen_nvram.c */
  157. unsigned char nvram_read_byte(int addr)
  158. {
  159. if (ppc_md.nvram_read_val)
  160. return ppc_md.nvram_read_val(addr);
  161. return 0xff;
  162. }
  163. EXPORT_SYMBOL(nvram_read_byte);
  164. void nvram_write_byte(unsigned char val, int addr)
  165. {
  166. if (ppc_md.nvram_write_val)
  167. ppc_md.nvram_write_val(addr, val);
  168. }
  169. EXPORT_SYMBOL(nvram_write_byte);
  170. void nvram_sync(void)
  171. {
  172. if (ppc_md.nvram_sync)
  173. ppc_md.nvram_sync();
  174. }
  175. EXPORT_SYMBOL(nvram_sync);
  176. #endif /* CONFIG_NVRAM */
  177. static struct cpu cpu_devices[NR_CPUS];
  178. int __init ppc_init(void)
  179. {
  180. int i;
  181. /* clear the progress line */
  182. if ( ppc_md.progress ) ppc_md.progress(" ", 0xffff);
  183. /* register CPU devices */
  184. for_each_possible_cpu(i)
  185. register_cpu(&cpu_devices[i], i, NULL);
  186. /* call platform init */
  187. if (ppc_md.init != NULL) {
  188. ppc_md.init();
  189. }
  190. return 0;
  191. }
  192. arch_initcall(ppc_init);
  193. /* Warning, IO base is not yet inited */
  194. void __init setup_arch(char **cmdline_p)
  195. {
  196. extern void do_init_bootmem(void);
  197. /* so udelay does something sensible, assume <= 1000 bogomips */
  198. loops_per_jiffy = 500000000 / HZ;
  199. unflatten_device_tree();
  200. check_for_initrd();
  201. if (ppc_md.init_early)
  202. ppc_md.init_early();
  203. find_legacy_serial_ports();
  204. finish_device_tree();
  205. smp_setup_cpu_maps();
  206. #ifdef CONFIG_XMON_DEFAULT
  207. xmon_init(1);
  208. #endif
  209. /* Register early console */
  210. register_early_udbg_console();
  211. #if defined(CONFIG_KGDB)
  212. if (ppc_md.kgdb_map_scc)
  213. ppc_md.kgdb_map_scc();
  214. set_debug_traps();
  215. if (strstr(cmd_line, "gdb")) {
  216. if (ppc_md.progress)
  217. ppc_md.progress("setup_arch: kgdb breakpoint", 0x4000);
  218. printk("kgdb breakpoint activated\n");
  219. breakpoint();
  220. }
  221. #endif
  222. /*
  223. * Set cache line size based on type of cpu as a default.
  224. * Systems with OF can look in the properties on the cpu node(s)
  225. * for a possibly more accurate value.
  226. */
  227. if (cpu_has_feature(CPU_FTR_SPLIT_ID_CACHE)) {
  228. dcache_bsize = cur_cpu_spec->dcache_bsize;
  229. icache_bsize = cur_cpu_spec->icache_bsize;
  230. ucache_bsize = 0;
  231. } else
  232. ucache_bsize = dcache_bsize = icache_bsize
  233. = cur_cpu_spec->dcache_bsize;
  234. /* reboot on panic */
  235. panic_timeout = 180;
  236. init_mm.start_code = PAGE_OFFSET;
  237. init_mm.end_code = (unsigned long) _etext;
  238. init_mm.end_data = (unsigned long) _edata;
  239. init_mm.brk = klimit;
  240. /* Save unparsed command line copy for /proc/cmdline */
  241. strlcpy(saved_command_line, cmd_line, COMMAND_LINE_SIZE);
  242. *cmdline_p = cmd_line;
  243. parse_early_param();
  244. /* set up the bootmem stuff with available memory */
  245. do_init_bootmem();
  246. if ( ppc_md.progress ) ppc_md.progress("setup_arch: bootmem", 0x3eab);
  247. #ifdef CONFIG_DUMMY_CONSOLE
  248. conswitchp = &dummy_con;
  249. #endif
  250. ppc_md.setup_arch();
  251. if ( ppc_md.progress ) ppc_md.progress("arch: exit", 0x3eab);
  252. paging_init();
  253. }