setup_32.c 7.2 KB

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