| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* | 
| Paul Mackerras | 0a26b13 | 2006-03-28 10:22:10 +1100 | [diff] [blame] | 2 | * Common prep boot and setup code. | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3 | */ | 
|  | 4 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 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> | 
| Jon Smirl | 894673e | 2006-07-10 04:44:13 -0700 | [diff] [blame] | 14 | #include <linux/screen_info.h> | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 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 |  | 
|  | 21 | #include <asm/residual.h> | 
|  | 22 | #include <asm/io.h> | 
|  | 23 | #include <asm/prom.h> | 
|  | 24 | #include <asm/processor.h> | 
|  | 25 | #include <asm/pgtable.h> | 
|  | 26 | #include <asm/bootinfo.h> | 
|  | 27 | #include <asm/setup.h> | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 28 | #include <asm/smp.h> | 
|  | 29 | #include <asm/elf.h> | 
|  | 30 | #include <asm/cputable.h> | 
|  | 31 | #include <asm/bootx.h> | 
|  | 32 | #include <asm/btext.h> | 
|  | 33 | #include <asm/machdep.h> | 
|  | 34 | #include <asm/uaccess.h> | 
|  | 35 | #include <asm/system.h> | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 36 | #include <asm/sections.h> | 
|  | 37 | #include <asm/nvram.h> | 
|  | 38 | #include <asm/xmon.h> | 
|  | 39 | #include <asm/ocp.h> | 
|  | 40 |  | 
| Kumar Gala | c42f3ad | 2008-01-27 14:06:14 -0600 | [diff] [blame] | 41 | #define USES_PPC_SYS (defined(CONFIG_MPC10X_BRIDGE) || defined(CONFIG_8260) || \ | 
| Kumar Gala | 8e8fff0 | 2005-09-03 15:55:34 -0700 | [diff] [blame] | 42 | defined(CONFIG_PPC_MPC52xx)) | 
|  | 43 |  | 
|  | 44 | #if USES_PPC_SYS | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 45 | #include <asm/ppc_sys.h> | 
|  | 46 | #endif | 
|  | 47 |  | 
|  | 48 | #if defined CONFIG_KGDB | 
|  | 49 | #include <asm/kgdb.h> | 
|  | 50 | #endif | 
|  | 51 |  | 
|  | 52 | extern void platform_init(unsigned long r3, unsigned long r4, | 
|  | 53 | unsigned long r5, unsigned long r6, unsigned long r7); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 54 | extern void reloc_got2(unsigned long offset); | 
|  | 55 |  | 
|  | 56 | extern void ppc6xx_idle(void); | 
|  | 57 | extern void power4_idle(void); | 
|  | 58 |  | 
|  | 59 | extern boot_infos_t *boot_infos; | 
|  | 60 | struct ide_machdep_calls ppc_ide_md; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 61 |  | 
|  | 62 | /* Used with the BI_MEMSIZE bootinfo parameter to store the memory | 
|  | 63 | size value reported by the boot loader. */ | 
|  | 64 | unsigned long boot_mem_size; | 
|  | 65 |  | 
|  | 66 | unsigned long ISA_DMA_THRESHOLD; | 
| Jon Loeliger | b8f114d | 2005-09-21 14:54:51 -0500 | [diff] [blame] | 67 | unsigned int DMA_MODE_READ; | 
|  | 68 | unsigned int DMA_MODE_WRITE; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 69 |  | 
| Paul Mackerras | 0a26b13 | 2006-03-28 10:22:10 +1100 | [diff] [blame] | 70 | #ifdef CONFIG_PPC_PREP | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 71 | extern void prep_init(unsigned long r3, unsigned long r4, | 
|  | 72 | unsigned long r5, unsigned long r6, unsigned long r7); | 
| Paul Mackerras | 14cf11a | 2005-09-26 16:04:21 +1000 | [diff] [blame] | 73 |  | 
|  | 74 | dev_t boot_dev; | 
| Paul Mackerras | 0a26b13 | 2006-03-28 10:22:10 +1100 | [diff] [blame] | 75 | #endif /* CONFIG_PPC_PREP */ | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 76 |  | 
| Paul Mackerras | fd582ec | 2005-10-11 22:08:12 +1000 | [diff] [blame] | 77 | int have_of; | 
|  | 78 | EXPORT_SYMBOL(have_of); | 
|  | 79 |  | 
| Paul Mackerras | 35d81a4 | 2005-10-11 22:03:09 +1000 | [diff] [blame] | 80 | #ifdef __DO_IRQ_CANON | 
|  | 81 | int ppc_do_canonicalize_irqs; | 
|  | 82 | EXPORT_SYMBOL(ppc_do_canonicalize_irqs); | 
|  | 83 | #endif | 
|  | 84 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 85 | #ifdef CONFIG_VGA_CONSOLE | 
|  | 86 | unsigned long vgacon_remap_base; | 
|  | 87 | #endif | 
|  | 88 |  | 
|  | 89 | struct machdep_calls ppc_md; | 
|  | 90 |  | 
|  | 91 | /* | 
|  | 92 | * These are used in binfmt_elf.c to put aux entries on the stack | 
|  | 93 | * for each elf executable being started. | 
|  | 94 | */ | 
|  | 95 | int dcache_bsize; | 
|  | 96 | int icache_bsize; | 
|  | 97 | int ucache_bsize; | 
|  | 98 |  | 
|  | 99 | #if defined(CONFIG_VGA_CONSOLE) || defined(CONFIG_FB_VGA16) || \ | 
|  | 100 | defined(CONFIG_FB_VGA16_MODULE) || defined(CONFIG_FB_VESA) | 
|  | 101 | struct screen_info screen_info = { | 
|  | 102 | 0, 25,			/* orig-x, orig-y */ | 
|  | 103 | 0,			/* unused */ | 
|  | 104 | 0,			/* orig-video-page */ | 
|  | 105 | 0,			/* orig-video-mode */ | 
|  | 106 | 80,			/* orig-video-cols */ | 
|  | 107 | 0,0,0,			/* ega_ax, ega_bx, ega_cx */ | 
|  | 108 | 25,			/* orig-video-lines */ | 
|  | 109 | 1,			/* orig-video-isVGA */ | 
|  | 110 | 16			/* orig-video-points */ | 
|  | 111 | }; | 
|  | 112 | #endif /* CONFIG_VGA_CONSOLE || CONFIG_FB_VGA16 || CONFIG_FB_VESA */ | 
|  | 113 |  | 
|  | 114 | void machine_restart(char *cmd) | 
|  | 115 | { | 
|  | 116 | #ifdef CONFIG_NVRAM | 
|  | 117 | nvram_sync(); | 
|  | 118 | #endif | 
|  | 119 | ppc_md.restart(cmd); | 
|  | 120 | } | 
|  | 121 |  | 
| Corey Minyard | 477bcae | 2006-09-06 09:02:53 -0500 | [diff] [blame] | 122 | static void ppc_generic_power_off(void) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 123 | { | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 124 | ppc_md.power_off(); | 
|  | 125 | } | 
|  | 126 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 127 | void machine_halt(void) | 
|  | 128 | { | 
|  | 129 | #ifdef CONFIG_NVRAM | 
|  | 130 | nvram_sync(); | 
|  | 131 | #endif | 
|  | 132 | ppc_md.halt(); | 
|  | 133 | } | 
|  | 134 |  | 
| Corey Minyard | 477bcae | 2006-09-06 09:02:53 -0500 | [diff] [blame] | 135 | void (*pm_power_off)(void) = ppc_generic_power_off; | 
|  | 136 |  | 
|  | 137 | void machine_power_off(void) | 
|  | 138 | { | 
|  | 139 | #ifdef CONFIG_NVRAM | 
|  | 140 | nvram_sync(); | 
|  | 141 | #endif | 
|  | 142 | if (pm_power_off) | 
|  | 143 | pm_power_off(); | 
|  | 144 | ppc_generic_power_off(); | 
|  | 145 | } | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 146 |  | 
|  | 147 | #ifdef CONFIG_TAU | 
|  | 148 | extern u32 cpu_temp(unsigned long cpu); | 
|  | 149 | extern u32 cpu_temp_both(unsigned long cpu); | 
|  | 150 | #endif /* CONFIG_TAU */ | 
|  | 151 |  | 
|  | 152 | int show_cpuinfo(struct seq_file *m, void *v) | 
|  | 153 | { | 
|  | 154 | int i = (int) v - 1; | 
|  | 155 | int err = 0; | 
|  | 156 | unsigned int pvr; | 
|  | 157 | unsigned short maj, min; | 
|  | 158 | unsigned long lpj; | 
|  | 159 |  | 
|  | 160 | if (i >= NR_CPUS) { | 
|  | 161 | /* Show summary information */ | 
|  | 162 | #ifdef CONFIG_SMP | 
|  | 163 | unsigned long bogosum = 0; | 
| Andrew Morton | 394e390 | 2006-03-23 03:01:05 -0800 | [diff] [blame] | 164 | for_each_online_cpu(i) | 
|  | 165 | bogosum += cpu_data[i].loops_per_jiffy; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 166 | seq_printf(m, "total bogomips\t: %lu.%02lu\n", | 
|  | 167 | bogosum/(500000/HZ), bogosum/(5000/HZ) % 100); | 
|  | 168 | #endif /* CONFIG_SMP */ | 
|  | 169 |  | 
|  | 170 | if (ppc_md.show_cpuinfo != NULL) | 
|  | 171 | err = ppc_md.show_cpuinfo(m); | 
|  | 172 | return err; | 
|  | 173 | } | 
|  | 174 |  | 
|  | 175 | #ifdef CONFIG_SMP | 
|  | 176 | if (!cpu_online(i)) | 
|  | 177 | return 0; | 
|  | 178 | pvr = cpu_data[i].pvr; | 
|  | 179 | lpj = cpu_data[i].loops_per_jiffy; | 
|  | 180 | #else | 
|  | 181 | pvr = mfspr(SPRN_PVR); | 
|  | 182 | lpj = loops_per_jiffy; | 
|  | 183 | #endif | 
|  | 184 |  | 
|  | 185 | seq_printf(m, "processor\t: %d\n", i); | 
|  | 186 | seq_printf(m, "cpu\t\t: "); | 
|  | 187 |  | 
| Kumar Gala | 400d221 | 2005-09-27 15:13:12 -0500 | [diff] [blame] | 188 | if (cur_cpu_spec->pvr_mask) | 
|  | 189 | seq_printf(m, "%s", cur_cpu_spec->cpu_name); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 190 | else | 
|  | 191 | seq_printf(m, "unknown (%08x)", pvr); | 
|  | 192 | #ifdef CONFIG_ALTIVEC | 
| Kumar Gala | 400d221 | 2005-09-27 15:13:12 -0500 | [diff] [blame] | 193 | if (cur_cpu_spec->cpu_features & CPU_FTR_ALTIVEC) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 194 | seq_printf(m, ", altivec supported"); | 
|  | 195 | #endif | 
|  | 196 | seq_printf(m, "\n"); | 
|  | 197 |  | 
|  | 198 | #ifdef CONFIG_TAU | 
| Kumar Gala | 400d221 | 2005-09-27 15:13:12 -0500 | [diff] [blame] | 199 | if (cur_cpu_spec->cpu_features & CPU_FTR_TAU) { | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 200 | #ifdef CONFIG_TAU_AVERAGE | 
|  | 201 | /* more straightforward, but potentially misleading */ | 
|  | 202 | seq_printf(m,  "temperature \t: %u C (uncalibrated)\n", | 
|  | 203 | cpu_temp(i)); | 
|  | 204 | #else | 
|  | 205 | /* show the actual temp sensor range */ | 
|  | 206 | u32 temp; | 
|  | 207 | temp = cpu_temp_both(i); | 
|  | 208 | seq_printf(m, "temperature \t: %u-%u C (uncalibrated)\n", | 
|  | 209 | temp & 0xff, temp >> 16); | 
|  | 210 | #endif | 
|  | 211 | } | 
|  | 212 | #endif /* CONFIG_TAU */ | 
|  | 213 |  | 
|  | 214 | if (ppc_md.show_percpuinfo != NULL) { | 
|  | 215 | err = ppc_md.show_percpuinfo(m, i); | 
|  | 216 | if (err) | 
|  | 217 | return err; | 
|  | 218 | } | 
|  | 219 |  | 
| Kumar Gala | 696c2b9 | 2005-05-05 16:15:10 -0700 | [diff] [blame] | 220 | /* If we are a Freescale core do a simple check so | 
|  | 221 | * we dont have to keep adding cases in the future */ | 
|  | 222 | if ((PVR_VER(pvr) & 0x8000) == 0x8000) { | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 223 | maj = PVR_MAJ(pvr); | 
|  | 224 | min = PVR_MIN(pvr); | 
| Kumar Gala | 696c2b9 | 2005-05-05 16:15:10 -0700 | [diff] [blame] | 225 | } else { | 
|  | 226 | switch (PVR_VER(pvr)) { | 
|  | 227 | case 0x0020:	/* 403 family */ | 
|  | 228 | maj = PVR_MAJ(pvr) + 1; | 
|  | 229 | min = PVR_MIN(pvr); | 
|  | 230 | break; | 
|  | 231 | case 0x1008:	/* 740P/750P ?? */ | 
|  | 232 | maj = ((pvr >> 8) & 0xFF) - 1; | 
|  | 233 | min = pvr & 0xFF; | 
|  | 234 | break; | 
|  | 235 | default: | 
|  | 236 | maj = (pvr >> 8) & 0xFF; | 
|  | 237 | min = pvr & 0xFF; | 
|  | 238 | break; | 
|  | 239 | } | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 240 | } | 
|  | 241 |  | 
|  | 242 | seq_printf(m, "revision\t: %hd.%hd (pvr %04x %04x)\n", | 
|  | 243 | maj, min, PVR_VER(pvr), PVR_REV(pvr)); | 
|  | 244 |  | 
|  | 245 | seq_printf(m, "bogomips\t: %lu.%02lu\n", | 
|  | 246 | lpj / (500000/HZ), (lpj / (5000/HZ)) % 100); | 
|  | 247 |  | 
| Kumar Gala | 8e8fff0 | 2005-09-03 15:55:34 -0700 | [diff] [blame] | 248 | #if USES_PPC_SYS | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 249 | if (cur_ppc_sys_spec->ppc_sys_name) | 
|  | 250 | seq_printf(m, "chipset\t\t: %s\n", | 
|  | 251 | cur_ppc_sys_spec->ppc_sys_name); | 
|  | 252 | #endif | 
|  | 253 |  | 
|  | 254 | #ifdef CONFIG_SMP | 
|  | 255 | seq_printf(m, "\n"); | 
|  | 256 | #endif | 
|  | 257 |  | 
|  | 258 | return 0; | 
|  | 259 | } | 
|  | 260 |  | 
|  | 261 | static void *c_start(struct seq_file *m, loff_t *pos) | 
|  | 262 | { | 
|  | 263 | int i = *pos; | 
|  | 264 |  | 
|  | 265 | return i <= NR_CPUS? (void *) (i + 1): NULL; | 
|  | 266 | } | 
|  | 267 |  | 
|  | 268 | static void *c_next(struct seq_file *m, void *v, loff_t *pos) | 
|  | 269 | { | 
|  | 270 | ++*pos; | 
|  | 271 | return c_start(m, pos); | 
|  | 272 | } | 
|  | 273 |  | 
|  | 274 | static void c_stop(struct seq_file *m, void *v) | 
|  | 275 | { | 
|  | 276 | } | 
|  | 277 |  | 
| Jan Engelhardt | 03a4482 | 2008-02-08 04:21:19 -0800 | [diff] [blame] | 278 | const struct seq_operations cpuinfo_op = { | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 279 | .start =c_start, | 
|  | 280 | .next =	c_next, | 
|  | 281 | .stop =	c_stop, | 
|  | 282 | .show =	show_cpuinfo, | 
|  | 283 | }; | 
|  | 284 |  | 
|  | 285 | /* | 
|  | 286 | * We're called here very early in the boot.  We determine the machine | 
|  | 287 | * type and call the appropriate low-level setup functions. | 
|  | 288 | *  -- Cort <cort@fsmlabs.com> | 
|  | 289 | * | 
|  | 290 | * Note that the kernel may be running at an address which is different | 
|  | 291 | * from the address that it was linked at, so we must use RELOC/PTRRELOC | 
|  | 292 | * to access static data (including strings).  -- paulus | 
|  | 293 | */ | 
|  | 294 | __init | 
|  | 295 | unsigned long | 
|  | 296 | early_init(int r3, int r4, int r5) | 
|  | 297 | { | 
|  | 298 | unsigned long phys; | 
|  | 299 | unsigned long offset = reloc_offset(); | 
| Benjamin Herrenschmidt | 42c4aaa | 2006-10-24 16:42:40 +1000 | [diff] [blame] | 300 | struct cpu_spec *spec; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 301 |  | 
|  | 302 | /* Default */ | 
|  | 303 | phys = offset + KERNELBASE; | 
|  | 304 |  | 
|  | 305 | /* First zero the BSS -- use memset, some arches don't have | 
|  | 306 | * caches on yet */ | 
|  | 307 | memset_io(PTRRELOC(&__bss_start), 0, _end - __bss_start); | 
|  | 308 |  | 
|  | 309 | /* | 
|  | 310 | * Identify the CPU type and fix up code sections | 
|  | 311 | * that depend on which cpu we have. | 
|  | 312 | */ | 
| Josh Boyer | 3d1d662 | 2007-11-17 04:29:56 +1100 | [diff] [blame] | 313 | #if defined(CONFIG_440EP) && defined(CONFIG_PPC_FPU) | 
|  | 314 | /* We pass the virtual PVR here for 440EP as 440EP and 440GR have | 
|  | 315 | * identical PVRs and there is no reliable way to check for the FPU | 
|  | 316 | */ | 
|  | 317 | spec = identify_cpu(offset, (mfspr(SPRN_PVR) | 0x8)); | 
|  | 318 | #else | 
| Paul Mackerras | 974a76f | 2006-11-10 20:38:53 +1100 | [diff] [blame] | 319 | spec = identify_cpu(offset, mfspr(SPRN_PVR)); | 
| Josh Boyer | 3d1d662 | 2007-11-17 04:29:56 +1100 | [diff] [blame] | 320 | #endif | 
| Benjamin Herrenschmidt | 0909c8c | 2006-10-20 11:47:18 +1000 | [diff] [blame] | 321 | do_feature_fixups(spec->cpu_features, | 
| Benjamin Herrenschmidt | 42c4aaa | 2006-10-24 16:42:40 +1000 | [diff] [blame] | 322 | PTRRELOC(&__start___ftr_fixup), | 
|  | 323 | PTRRELOC(&__stop___ftr_fixup)); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 324 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 325 | return phys; | 
|  | 326 | } | 
|  | 327 |  | 
| Paul Mackerras | 0a26b13 | 2006-03-28 10:22:10 +1100 | [diff] [blame] | 328 | #ifdef CONFIG_PPC_PREP | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 329 | /* | 
| Paul Mackerras | 0a26b13 | 2006-03-28 10:22:10 +1100 | [diff] [blame] | 330 | * The PPC_PREP version of platform_init... | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 331 | */ | 
|  | 332 | void __init | 
|  | 333 | platform_init(unsigned long r3, unsigned long r4, unsigned long r5, | 
|  | 334 | unsigned long r6, unsigned long r7) | 
|  | 335 | { | 
|  | 336 | #ifdef CONFIG_BOOTX_TEXT | 
|  | 337 | if (boot_text_mapped) { | 
|  | 338 | btext_clearscreen(); | 
|  | 339 | btext_welcome(); | 
|  | 340 | } | 
|  | 341 | #endif | 
|  | 342 |  | 
|  | 343 | parse_bootinfo(find_bootinfo()); | 
|  | 344 |  | 
| Paul Mackerras | 0a26b13 | 2006-03-28 10:22:10 +1100 | [diff] [blame] | 345 | prep_init(r3, r4, r5, r6, r7); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 346 | } | 
| Paul Mackerras | 0a26b13 | 2006-03-28 10:22:10 +1100 | [diff] [blame] | 347 | #endif /* CONFIG_PPC_PREP */ | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 348 |  | 
|  | 349 | struct bi_record *find_bootinfo(void) | 
|  | 350 | { | 
|  | 351 | struct bi_record *rec; | 
|  | 352 |  | 
|  | 353 | rec = (struct bi_record *)_ALIGN((ulong)__bss_start+(1<<20)-1,(1<<20)); | 
|  | 354 | if ( rec->tag != BI_FIRST ) { | 
|  | 355 | /* | 
|  | 356 | * This 0x10000 offset is a terrible hack but it will go away when | 
|  | 357 | * we have the bootloader handle all the relocation and | 
|  | 358 | * prom calls -- Cort | 
|  | 359 | */ | 
|  | 360 | rec = (struct bi_record *)_ALIGN((ulong)__bss_start+0x10000+(1<<20)-1,(1<<20)); | 
|  | 361 | if ( rec->tag != BI_FIRST ) | 
|  | 362 | return NULL; | 
|  | 363 | } | 
|  | 364 | return rec; | 
|  | 365 | } | 
|  | 366 |  | 
|  | 367 | void parse_bootinfo(struct bi_record *rec) | 
|  | 368 | { | 
|  | 369 | if (rec == NULL || rec->tag != BI_FIRST) | 
|  | 370 | return; | 
|  | 371 | while (rec->tag != BI_LAST) { | 
|  | 372 | ulong *data = rec->data; | 
|  | 373 | switch (rec->tag) { | 
|  | 374 | case BI_CMD_LINE: | 
|  | 375 | strlcpy(cmd_line, (void *)data, sizeof(cmd_line)); | 
|  | 376 | break; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 377 | #ifdef CONFIG_BLK_DEV_INITRD | 
|  | 378 | case BI_INITRD: | 
|  | 379 | initrd_start = data[0] + KERNELBASE; | 
|  | 380 | initrd_end = data[0] + data[1] + KERNELBASE; | 
|  | 381 | break; | 
|  | 382 | #endif /* CONFIG_BLK_DEV_INITRD */ | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 383 | case BI_MEMSIZE: | 
|  | 384 | boot_mem_size = data[0]; | 
|  | 385 | break; | 
|  | 386 | } | 
|  | 387 | rec = (struct bi_record *)((ulong)rec + rec->size); | 
|  | 388 | } | 
|  | 389 | } | 
|  | 390 |  | 
|  | 391 | /* | 
|  | 392 | * Find out what kind of machine we're on and save any data we need | 
|  | 393 | * from the early boot process (devtree is copied on pmac by prom_init()). | 
|  | 394 | * This is called very early on the boot process, after a minimal | 
|  | 395 | * MMU environment has been set up but before MMU_init is called. | 
|  | 396 | */ | 
|  | 397 | void __init | 
|  | 398 | machine_init(unsigned long r3, unsigned long r4, unsigned long r5, | 
|  | 399 | unsigned long r6, unsigned long r7) | 
|  | 400 | { | 
|  | 401 | #ifdef CONFIG_CMDLINE | 
|  | 402 | strlcpy(cmd_line, CONFIG_CMDLINE, sizeof(cmd_line)); | 
|  | 403 | #endif /* CONFIG_CMDLINE */ | 
|  | 404 |  | 
|  | 405 | #ifdef CONFIG_6xx | 
|  | 406 | ppc_md.power_save = ppc6xx_idle; | 
|  | 407 | #endif | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 408 |  | 
|  | 409 | platform_init(r3, r4, r5, r6, r7); | 
|  | 410 |  | 
|  | 411 | if (ppc_md.progress) | 
|  | 412 | ppc_md.progress("id mach(): done", 0x200); | 
|  | 413 | } | 
| Kumar Gala | a2f40cc | 2005-09-03 15:55:33 -0700 | [diff] [blame] | 414 | #ifdef CONFIG_BOOKE_WDT | 
|  | 415 | /* Checks wdt=x and wdt_period=xx command-line option */ | 
|  | 416 | int __init early_parse_wdt(char *p) | 
|  | 417 | { | 
| Kumar Gala | a2f40cc | 2005-09-03 15:55:33 -0700 | [diff] [blame] | 418 | if (p && strncmp(p, "0", 1) != 0) | 
| Kumar Gala | 39cdc4b | 2005-09-03 15:55:39 -0700 | [diff] [blame] | 419 | booke_wdt_enabled = 1; | 
| Kumar Gala | a2f40cc | 2005-09-03 15:55:33 -0700 | [diff] [blame] | 420 |  | 
|  | 421 | return 0; | 
|  | 422 | } | 
|  | 423 | early_param("wdt", early_parse_wdt); | 
|  | 424 |  | 
|  | 425 | int __init early_parse_wdt_period (char *p) | 
|  | 426 | { | 
| Kumar Gala | a2f40cc | 2005-09-03 15:55:33 -0700 | [diff] [blame] | 427 | if (p) | 
| Kumar Gala | 39cdc4b | 2005-09-03 15:55:39 -0700 | [diff] [blame] | 428 | booke_wdt_period = simple_strtoul(p, NULL, 0); | 
| Kumar Gala | a2f40cc | 2005-09-03 15:55:33 -0700 | [diff] [blame] | 429 |  | 
|  | 430 | return 0; | 
|  | 431 | } | 
|  | 432 | early_param("wdt_period", early_parse_wdt_period); | 
|  | 433 | #endif	/* CONFIG_BOOKE_WDT */ | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 434 |  | 
|  | 435 | /* Checks "l2cr=xxxx" command-line option */ | 
|  | 436 | int __init ppc_setup_l2cr(char *str) | 
|  | 437 | { | 
|  | 438 | if (cpu_has_feature(CPU_FTR_L2CR)) { | 
|  | 439 | unsigned long val = simple_strtoul(str, NULL, 0); | 
|  | 440 | printk(KERN_INFO "l2cr set to %lx\n", val); | 
|  | 441 | _set_L2CR(0);		/* force invalidate by disable cache */ | 
|  | 442 | _set_L2CR(val);		/* and enable it */ | 
|  | 443 | } | 
|  | 444 | return 1; | 
|  | 445 | } | 
|  | 446 | __setup("l2cr=", ppc_setup_l2cr); | 
|  | 447 |  | 
|  | 448 | #ifdef CONFIG_GENERIC_NVRAM | 
|  | 449 |  | 
|  | 450 | /* Generic nvram hooks used by drivers/char/gen_nvram.c */ | 
|  | 451 | unsigned char nvram_read_byte(int addr) | 
|  | 452 | { | 
|  | 453 | if (ppc_md.nvram_read_val) | 
|  | 454 | return ppc_md.nvram_read_val(addr); | 
|  | 455 | return 0xff; | 
|  | 456 | } | 
|  | 457 | EXPORT_SYMBOL(nvram_read_byte); | 
|  | 458 |  | 
|  | 459 | void nvram_write_byte(unsigned char val, int addr) | 
|  | 460 | { | 
|  | 461 | if (ppc_md.nvram_write_val) | 
|  | 462 | ppc_md.nvram_write_val(addr, val); | 
|  | 463 | } | 
|  | 464 | EXPORT_SYMBOL(nvram_write_byte); | 
|  | 465 |  | 
|  | 466 | void nvram_sync(void) | 
|  | 467 | { | 
|  | 468 | if (ppc_md.nvram_sync) | 
|  | 469 | ppc_md.nvram_sync(); | 
|  | 470 | } | 
|  | 471 | EXPORT_SYMBOL(nvram_sync); | 
|  | 472 |  | 
|  | 473 | #endif /* CONFIG_NVRAM */ | 
|  | 474 |  | 
|  | 475 | static struct cpu cpu_devices[NR_CPUS]; | 
|  | 476 |  | 
|  | 477 | int __init ppc_init(void) | 
|  | 478 | { | 
|  | 479 | int i; | 
|  | 480 |  | 
|  | 481 | /* clear the progress line */ | 
|  | 482 | if ( ppc_md.progress ) ppc_md.progress("             ", 0xffff); | 
|  | 483 |  | 
|  | 484 | /* register CPU devices */ | 
| KAMEZAWA Hiroyuki | b848e0a | 2006-03-28 14:50:52 -0800 | [diff] [blame] | 485 | for_each_possible_cpu(i) | 
| KAMEZAWA Hiroyuki | 76b67ed | 2006-06-27 02:53:41 -0700 | [diff] [blame] | 486 | register_cpu(&cpu_devices[i], i); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 487 |  | 
|  | 488 | /* call platform init */ | 
|  | 489 | if (ppc_md.init != NULL) { | 
|  | 490 | ppc_md.init(); | 
|  | 491 | } | 
|  | 492 | return 0; | 
|  | 493 | } | 
|  | 494 |  | 
|  | 495 | arch_initcall(ppc_init); | 
|  | 496 |  | 
|  | 497 | /* Warning, IO base is not yet inited */ | 
|  | 498 | void __init setup_arch(char **cmdline_p) | 
|  | 499 | { | 
|  | 500 | extern char *klimit; | 
|  | 501 | extern void do_init_bootmem(void); | 
|  | 502 |  | 
|  | 503 | /* so udelay does something sensible, assume <= 1000 bogomips */ | 
|  | 504 | loops_per_jiffy = 500000000 / HZ; | 
|  | 505 |  | 
| Benjamin Herrenschmidt | 51d3082 | 2005-11-23 17:57:25 +1100 | [diff] [blame] | 506 | if (ppc_md.init_early) | 
|  | 507 | ppc_md.init_early(); | 
|  | 508 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 509 | #ifdef CONFIG_XMON | 
| Paul Mackerras | fd582ec | 2005-10-11 22:08:12 +1000 | [diff] [blame] | 510 | xmon_init(1); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 511 | if (strstr(cmd_line, "xmon")) | 
|  | 512 | xmon(NULL); | 
|  | 513 | #endif /* CONFIG_XMON */ | 
|  | 514 | if ( ppc_md.progress ) ppc_md.progress("setup_arch: enter", 0x3eab); | 
|  | 515 |  | 
|  | 516 | #if defined(CONFIG_KGDB) | 
|  | 517 | if (ppc_md.kgdb_map_scc) | 
|  | 518 | ppc_md.kgdb_map_scc(); | 
|  | 519 | set_debug_traps(); | 
|  | 520 | if (strstr(cmd_line, "gdb")) { | 
|  | 521 | if (ppc_md.progress) | 
|  | 522 | ppc_md.progress("setup_arch: kgdb breakpoint", 0x4000); | 
|  | 523 | printk("kgdb breakpoint activated\n"); | 
|  | 524 | breakpoint(); | 
|  | 525 | } | 
|  | 526 | #endif | 
|  | 527 |  | 
|  | 528 | /* | 
|  | 529 | * Set cache line size based on type of cpu as a default. | 
|  | 530 | * Systems with OF can look in the properties on the cpu node(s) | 
|  | 531 | * for a possibly more accurate value. | 
|  | 532 | */ | 
| David Gibson | 4508dc2 | 2007-06-13 14:52:57 +1000 | [diff] [blame] | 533 | if (! cpu_has_feature(CPU_FTR_UNIFIED_ID_CACHE)) { | 
| Kumar Gala | 400d221 | 2005-09-27 15:13:12 -0500 | [diff] [blame] | 534 | dcache_bsize = cur_cpu_spec->dcache_bsize; | 
|  | 535 | icache_bsize = cur_cpu_spec->icache_bsize; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 536 | ucache_bsize = 0; | 
|  | 537 | } else | 
|  | 538 | ucache_bsize = dcache_bsize = icache_bsize | 
| Kumar Gala | 400d221 | 2005-09-27 15:13:12 -0500 | [diff] [blame] | 539 | = cur_cpu_spec->dcache_bsize; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 540 |  | 
|  | 541 | /* reboot on panic */ | 
|  | 542 | panic_timeout = 180; | 
|  | 543 |  | 
|  | 544 | init_mm.start_code = PAGE_OFFSET; | 
|  | 545 | init_mm.end_code = (unsigned long) _etext; | 
|  | 546 | init_mm.end_data = (unsigned long) _edata; | 
|  | 547 | init_mm.brk = (unsigned long) klimit; | 
|  | 548 |  | 
|  | 549 | /* Save unparsed command line copy for /proc/cmdline */ | 
| Alon Bar-Lev | bf71cec | 2007-02-12 00:54:18 -0800 | [diff] [blame] | 550 | strlcpy(boot_command_line, cmd_line, COMMAND_LINE_SIZE); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 551 | *cmdline_p = cmd_line; | 
|  | 552 |  | 
| Paul Mackerras | 19bbdf0 | 2005-05-17 16:48:39 +1000 | [diff] [blame] | 553 | parse_early_param(); | 
|  | 554 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 555 | /* set up the bootmem stuff with available memory */ | 
|  | 556 | do_init_bootmem(); | 
|  | 557 | if ( ppc_md.progress ) ppc_md.progress("setup_arch: bootmem", 0x3eab); | 
|  | 558 |  | 
|  | 559 | #ifdef CONFIG_PPC_OCP | 
|  | 560 | /* Initialize OCP device list */ | 
|  | 561 | ocp_early_init(); | 
|  | 562 | if ( ppc_md.progress ) ppc_md.progress("ocp: exit", 0x3eab); | 
|  | 563 | #endif | 
|  | 564 |  | 
|  | 565 | #ifdef CONFIG_DUMMY_CONSOLE | 
|  | 566 | conswitchp = &dummy_con; | 
|  | 567 | #endif | 
|  | 568 |  | 
|  | 569 | ppc_md.setup_arch(); | 
|  | 570 | if ( ppc_md.progress ) ppc_md.progress("arch: exit", 0x3eab); | 
|  | 571 |  | 
|  | 572 | paging_init(); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 573 | } |