Commit | Line | Data |
---|---|---|
1da177e4 | 1 | /* |
a7fdd90b | 2 | * Common prep/chrp boot and setup code. |
1da177e4 LT |
3 | */ |
4 | ||
5 | #include <linux/config.h> | |
6 | #include <linux/module.h> | |
7 | #include <linux/string.h> | |
8 | #include <linux/sched.h> | |
9 | #include <linux/init.h> | |
10 | #include <linux/kernel.h> | |
11 | #include <linux/reboot.h> | |
12 | #include <linux/delay.h> | |
13 | #include <linux/initrd.h> | |
14 | #include <linux/ide.h> | |
15 | #include <linux/tty.h> | |
16 | #include <linux/bootmem.h> | |
17 | #include <linux/seq_file.h> | |
18 | #include <linux/root_dev.h> | |
19 | #include <linux/cpu.h> | |
20 | #include <linux/console.h> | |
21 | ||
22 | #include <asm/residual.h> | |
23 | #include <asm/io.h> | |
24 | #include <asm/prom.h> | |
25 | #include <asm/processor.h> | |
26 | #include <asm/pgtable.h> | |
27 | #include <asm/bootinfo.h> | |
28 | #include <asm/setup.h> | |
29 | #include <asm/amigappc.h> | |
30 | #include <asm/smp.h> | |
31 | #include <asm/elf.h> | |
32 | #include <asm/cputable.h> | |
33 | #include <asm/bootx.h> | |
34 | #include <asm/btext.h> | |
35 | #include <asm/machdep.h> | |
36 | #include <asm/uaccess.h> | |
37 | #include <asm/system.h> | |
1da177e4 LT |
38 | #include <asm/sections.h> |
39 | #include <asm/nvram.h> | |
40 | #include <asm/xmon.h> | |
41 | #include <asm/ocp.h> | |
42 | ||
8e8fff09 KG |
43 | #define USES_PPC_SYS (defined(CONFIG_85xx) || defined(CONFIG_83xx) || \ |
44 | defined(CONFIG_MPC10X_BRIDGE) || defined(CONFIG_8260) || \ | |
45 | defined(CONFIG_PPC_MPC52xx)) | |
46 | ||
47 | #if USES_PPC_SYS | |
1da177e4 LT |
48 | #include <asm/ppc_sys.h> |
49 | #endif | |
50 | ||
51 | #if defined CONFIG_KGDB | |
52 | #include <asm/kgdb.h> | |
53 | #endif | |
54 | ||
55 | extern void platform_init(unsigned long r3, unsigned long r4, | |
56 | unsigned long r5, unsigned long r6, unsigned long r7); | |
1da177e4 LT |
57 | extern void identify_cpu(unsigned long offset, unsigned long cpu); |
58 | extern void do_cpu_ftr_fixups(unsigned long offset); | |
59 | extern void reloc_got2(unsigned long offset); | |
60 | ||
61 | extern void ppc6xx_idle(void); | |
62 | extern void power4_idle(void); | |
63 | ||
64 | extern boot_infos_t *boot_infos; | |
65 | struct ide_machdep_calls ppc_ide_md; | |
1da177e4 LT |
66 | |
67 | /* Used with the BI_MEMSIZE bootinfo parameter to store the memory | |
68 | size value reported by the boot loader. */ | |
69 | unsigned long boot_mem_size; | |
70 | ||
71 | unsigned long ISA_DMA_THRESHOLD; | |
b8f114db JL |
72 | unsigned int DMA_MODE_READ; |
73 | unsigned int DMA_MODE_WRITE; | |
1da177e4 LT |
74 | |
75 | #ifdef CONFIG_PPC_MULTIPLATFORM | |
76 | int _machine = 0; | |
799d6046 | 77 | EXPORT_SYMBOL(_machine); |
1da177e4 LT |
78 | |
79 | extern void prep_init(unsigned long r3, unsigned long r4, | |
80 | unsigned long r5, unsigned long r6, unsigned long r7); | |
1da177e4 LT |
81 | extern void chrp_init(unsigned long r3, unsigned long r4, |
82 | unsigned long r5, unsigned long r6, unsigned long r7); | |
14cf11af PM |
83 | |
84 | dev_t boot_dev; | |
1da177e4 LT |
85 | #endif /* CONFIG_PPC_MULTIPLATFORM */ |
86 | ||
fd582ec8 PM |
87 | int have_of; |
88 | EXPORT_SYMBOL(have_of); | |
89 | ||
35d81a4b PM |
90 | #ifdef __DO_IRQ_CANON |
91 | int ppc_do_canonicalize_irqs; | |
92 | EXPORT_SYMBOL(ppc_do_canonicalize_irqs); | |
93 | #endif | |
94 | ||
1da177e4 LT |
95 | #ifdef CONFIG_MAGIC_SYSRQ |
96 | unsigned long SYSRQ_KEY = 0x54; | |
97 | #endif /* CONFIG_MAGIC_SYSRQ */ | |
98 | ||
99 | #ifdef CONFIG_VGA_CONSOLE | |
100 | unsigned long vgacon_remap_base; | |
101 | #endif | |
102 | ||
103 | struct machdep_calls ppc_md; | |
104 | ||
105 | /* | |
106 | * These are used in binfmt_elf.c to put aux entries on the stack | |
107 | * for each elf executable being started. | |
108 | */ | |
109 | int dcache_bsize; | |
110 | int icache_bsize; | |
111 | int ucache_bsize; | |
112 | ||
113 | #if defined(CONFIG_VGA_CONSOLE) || defined(CONFIG_FB_VGA16) || \ | |
114 | defined(CONFIG_FB_VGA16_MODULE) || defined(CONFIG_FB_VESA) | |
115 | struct screen_info screen_info = { | |
116 | 0, 25, /* orig-x, orig-y */ | |
117 | 0, /* unused */ | |
118 | 0, /* orig-video-page */ | |
119 | 0, /* orig-video-mode */ | |
120 | 80, /* orig-video-cols */ | |
121 | 0,0,0, /* ega_ax, ega_bx, ega_cx */ | |
122 | 25, /* orig-video-lines */ | |
123 | 1, /* orig-video-isVGA */ | |
124 | 16 /* orig-video-points */ | |
125 | }; | |
126 | #endif /* CONFIG_VGA_CONSOLE || CONFIG_FB_VGA16 || CONFIG_FB_VESA */ | |
127 | ||
128 | void machine_restart(char *cmd) | |
129 | { | |
130 | #ifdef CONFIG_NVRAM | |
131 | nvram_sync(); | |
132 | #endif | |
133 | ppc_md.restart(cmd); | |
134 | } | |
135 | ||
1da177e4 LT |
136 | void machine_power_off(void) |
137 | { | |
138 | #ifdef CONFIG_NVRAM | |
139 | nvram_sync(); | |
140 | #endif | |
141 | ppc_md.power_off(); | |
142 | } | |
143 | ||
1da177e4 LT |
144 | void machine_halt(void) |
145 | { | |
146 | #ifdef CONFIG_NVRAM | |
147 | nvram_sync(); | |
148 | #endif | |
149 | ppc_md.halt(); | |
150 | } | |
151 | ||
1da177e4 LT |
152 | void (*pm_power_off)(void) = machine_power_off; |
153 | ||
154 | #ifdef CONFIG_TAU | |
155 | extern u32 cpu_temp(unsigned long cpu); | |
156 | extern u32 cpu_temp_both(unsigned long cpu); | |
157 | #endif /* CONFIG_TAU */ | |
158 | ||
159 | int show_cpuinfo(struct seq_file *m, void *v) | |
160 | { | |
161 | int i = (int) v - 1; | |
162 | int err = 0; | |
163 | unsigned int pvr; | |
164 | unsigned short maj, min; | |
165 | unsigned long lpj; | |
166 | ||
167 | if (i >= NR_CPUS) { | |
168 | /* Show summary information */ | |
169 | #ifdef CONFIG_SMP | |
170 | unsigned long bogosum = 0; | |
394e3902 AM |
171 | for_each_online_cpu(i) |
172 | bogosum += cpu_data[i].loops_per_jiffy; | |
1da177e4 LT |
173 | seq_printf(m, "total bogomips\t: %lu.%02lu\n", |
174 | bogosum/(500000/HZ), bogosum/(5000/HZ) % 100); | |
175 | #endif /* CONFIG_SMP */ | |
176 | ||
177 | if (ppc_md.show_cpuinfo != NULL) | |
178 | err = ppc_md.show_cpuinfo(m); | |
179 | return err; | |
180 | } | |
181 | ||
182 | #ifdef CONFIG_SMP | |
183 | if (!cpu_online(i)) | |
184 | return 0; | |
185 | pvr = cpu_data[i].pvr; | |
186 | lpj = cpu_data[i].loops_per_jiffy; | |
187 | #else | |
188 | pvr = mfspr(SPRN_PVR); | |
189 | lpj = loops_per_jiffy; | |
190 | #endif | |
191 | ||
192 | seq_printf(m, "processor\t: %d\n", i); | |
193 | seq_printf(m, "cpu\t\t: "); | |
194 | ||
400d2212 KG |
195 | if (cur_cpu_spec->pvr_mask) |
196 | seq_printf(m, "%s", cur_cpu_spec->cpu_name); | |
1da177e4 LT |
197 | else |
198 | seq_printf(m, "unknown (%08x)", pvr); | |
199 | #ifdef CONFIG_ALTIVEC | |
400d2212 | 200 | if (cur_cpu_spec->cpu_features & CPU_FTR_ALTIVEC) |
1da177e4 LT |
201 | seq_printf(m, ", altivec supported"); |
202 | #endif | |
203 | seq_printf(m, "\n"); | |
204 | ||
205 | #ifdef CONFIG_TAU | |
400d2212 | 206 | if (cur_cpu_spec->cpu_features & CPU_FTR_TAU) { |
1da177e4 LT |
207 | #ifdef CONFIG_TAU_AVERAGE |
208 | /* more straightforward, but potentially misleading */ | |
209 | seq_printf(m, "temperature \t: %u C (uncalibrated)\n", | |
210 | cpu_temp(i)); | |
211 | #else | |
212 | /* show the actual temp sensor range */ | |
213 | u32 temp; | |
214 | temp = cpu_temp_both(i); | |
215 | seq_printf(m, "temperature \t: %u-%u C (uncalibrated)\n", | |
216 | temp & 0xff, temp >> 16); | |
217 | #endif | |
218 | } | |
219 | #endif /* CONFIG_TAU */ | |
220 | ||
221 | if (ppc_md.show_percpuinfo != NULL) { | |
222 | err = ppc_md.show_percpuinfo(m, i); | |
223 | if (err) | |
224 | return err; | |
225 | } | |
226 | ||
696c2b9f KG |
227 | /* If we are a Freescale core do a simple check so |
228 | * we dont have to keep adding cases in the future */ | |
229 | if ((PVR_VER(pvr) & 0x8000) == 0x8000) { | |
1da177e4 LT |
230 | maj = PVR_MAJ(pvr); |
231 | min = PVR_MIN(pvr); | |
696c2b9f KG |
232 | } else { |
233 | switch (PVR_VER(pvr)) { | |
234 | case 0x0020: /* 403 family */ | |
235 | maj = PVR_MAJ(pvr) + 1; | |
236 | min = PVR_MIN(pvr); | |
237 | break; | |
238 | case 0x1008: /* 740P/750P ?? */ | |
239 | maj = ((pvr >> 8) & 0xFF) - 1; | |
240 | min = pvr & 0xFF; | |
241 | break; | |
242 | default: | |
243 | maj = (pvr >> 8) & 0xFF; | |
244 | min = pvr & 0xFF; | |
245 | break; | |
246 | } | |
1da177e4 LT |
247 | } |
248 | ||
249 | seq_printf(m, "revision\t: %hd.%hd (pvr %04x %04x)\n", | |
250 | maj, min, PVR_VER(pvr), PVR_REV(pvr)); | |
251 | ||
252 | seq_printf(m, "bogomips\t: %lu.%02lu\n", | |
253 | lpj / (500000/HZ), (lpj / (5000/HZ)) % 100); | |
254 | ||
8e8fff09 | 255 | #if USES_PPC_SYS |
1da177e4 LT |
256 | if (cur_ppc_sys_spec->ppc_sys_name) |
257 | seq_printf(m, "chipset\t\t: %s\n", | |
258 | cur_ppc_sys_spec->ppc_sys_name); | |
259 | #endif | |
260 | ||
261 | #ifdef CONFIG_SMP | |
262 | seq_printf(m, "\n"); | |
263 | #endif | |
264 | ||
265 | return 0; | |
266 | } | |
267 | ||
268 | static void *c_start(struct seq_file *m, loff_t *pos) | |
269 | { | |
270 | int i = *pos; | |
271 | ||
272 | return i <= NR_CPUS? (void *) (i + 1): NULL; | |
273 | } | |
274 | ||
275 | static void *c_next(struct seq_file *m, void *v, loff_t *pos) | |
276 | { | |
277 | ++*pos; | |
278 | return c_start(m, pos); | |
279 | } | |
280 | ||
281 | static void c_stop(struct seq_file *m, void *v) | |
282 | { | |
283 | } | |
284 | ||
285 | struct seq_operations cpuinfo_op = { | |
286 | .start =c_start, | |
287 | .next = c_next, | |
288 | .stop = c_stop, | |
289 | .show = show_cpuinfo, | |
290 | }; | |
291 | ||
292 | /* | |
293 | * We're called here very early in the boot. We determine the machine | |
294 | * type and call the appropriate low-level setup functions. | |
295 | * -- Cort <cort@fsmlabs.com> | |
296 | * | |
297 | * Note that the kernel may be running at an address which is different | |
298 | * from the address that it was linked at, so we must use RELOC/PTRRELOC | |
299 | * to access static data (including strings). -- paulus | |
300 | */ | |
301 | __init | |
302 | unsigned long | |
303 | early_init(int r3, int r4, int r5) | |
304 | { | |
305 | unsigned long phys; | |
306 | unsigned long offset = reloc_offset(); | |
307 | ||
308 | /* Default */ | |
309 | phys = offset + KERNELBASE; | |
310 | ||
311 | /* First zero the BSS -- use memset, some arches don't have | |
312 | * caches on yet */ | |
313 | memset_io(PTRRELOC(&__bss_start), 0, _end - __bss_start); | |
314 | ||
315 | /* | |
316 | * Identify the CPU type and fix up code sections | |
317 | * that depend on which cpu we have. | |
318 | */ | |
319 | identify_cpu(offset, 0); | |
320 | do_cpu_ftr_fixups(offset); | |
321 | ||
a7fdd90b | 322 | #if defined(CONFIG_PPC_OF) |
1da177e4 LT |
323 | reloc_got2(offset); |
324 | ||
1da177e4 LT |
325 | /* |
326 | * don't do anything on prep | |
327 | * for now, don't use bootinfo because it breaks yaboot 0.5 | |
328 | * and assume that if we didn't find a magic number, we have OF | |
329 | */ | |
a7fdd90b | 330 | if (*(unsigned long *)(0) != 0xdeadc0de) |
1da177e4 LT |
331 | phys = prom_init(r3, r4, (prom_entry)r5); |
332 | ||
333 | reloc_got2(-offset); | |
334 | #endif | |
335 | ||
336 | return phys; | |
337 | } | |
338 | ||
339 | #ifdef CONFIG_PPC_OF | |
340 | /* | |
341 | * Assume here that all clock rates are the same in a | |
342 | * smp system. -- Cort | |
343 | */ | |
f495a8bf | 344 | int |
1da177e4 LT |
345 | of_show_percpuinfo(struct seq_file *m, int i) |
346 | { | |
347 | struct device_node *cpu_node; | |
348 | u32 *fp; | |
349 | int s; | |
350 | ||
351 | cpu_node = find_type_devices("cpu"); | |
352 | if (!cpu_node) | |
353 | return 0; | |
354 | for (s = 0; s < i && cpu_node->next; s++) | |
355 | cpu_node = cpu_node->next; | |
356 | fp = (u32 *)get_property(cpu_node, "clock-frequency", NULL); | |
357 | if (fp) | |
358 | seq_printf(m, "clock\t\t: %dMHz\n", *fp / 1000000); | |
359 | return 0; | |
360 | } | |
361 | ||
362 | void __init | |
363 | intuit_machine_type(void) | |
364 | { | |
365 | char *model; | |
366 | struct device_node *root; | |
367 | ||
368 | /* ask the OF info if we're a chrp or pmac */ | |
369 | root = find_path_device("/"); | |
370 | if (root != 0) { | |
371 | /* assume pmac unless proven to be chrp -- Cort */ | |
372 | _machine = _MACH_Pmac; | |
373 | model = get_property(root, "device_type", NULL); | |
374 | if (model && !strncmp("chrp", model, 4)) | |
375 | _machine = _MACH_chrp; | |
376 | else { | |
377 | model = get_property(root, "model", NULL); | |
378 | if (model && !strncmp(model, "IBM", 3)) | |
379 | _machine = _MACH_chrp; | |
380 | } | |
381 | } | |
382 | } | |
383 | #endif | |
384 | ||
385 | #ifdef CONFIG_PPC_MULTIPLATFORM | |
386 | /* | |
387 | * The PPC_MULTIPLATFORM version of platform_init... | |
388 | */ | |
389 | void __init | |
390 | platform_init(unsigned long r3, unsigned long r4, unsigned long r5, | |
391 | unsigned long r6, unsigned long r7) | |
392 | { | |
393 | #ifdef CONFIG_BOOTX_TEXT | |
394 | if (boot_text_mapped) { | |
395 | btext_clearscreen(); | |
396 | btext_welcome(); | |
397 | } | |
398 | #endif | |
399 | ||
400 | parse_bootinfo(find_bootinfo()); | |
401 | ||
402 | /* if we didn't get any bootinfo telling us what we are... */ | |
403 | if (_machine == 0) { | |
404 | /* prep boot loader tells us if we're prep or not */ | |
405 | if ( *(unsigned long *)(KERNELBASE) == (0xdeadc0de) ) | |
406 | _machine = _MACH_prep; | |
407 | } | |
408 | ||
14cf11af | 409 | #ifdef CONFIG_PPC_PREP |
1da177e4 LT |
410 | /* not much more to do here, if prep */ |
411 | if (_machine == _MACH_prep) { | |
412 | prep_init(r3, r4, r5, r6, r7); | |
413 | return; | |
414 | } | |
14cf11af | 415 | #endif |
1da177e4 | 416 | |
a7fdd90b | 417 | #ifdef CONFIG_PPC_OF |
fd582ec8 PM |
418 | have_of = 1; |
419 | ||
1da177e4 LT |
420 | /* prom_init has already been called from __start */ |
421 | if (boot_infos) | |
422 | relocate_nodes(); | |
423 | ||
424 | /* If we aren't PReP, we can find out if we're Pmac | |
425 | * or CHRP with this. */ | |
426 | if (_machine == 0) | |
427 | intuit_machine_type(); | |
428 | ||
429 | /* finish_device_tree may need _machine defined. */ | |
430 | finish_device_tree(); | |
431 | ||
432 | /* | |
433 | * If we were booted via quik, r3 points to the physical | |
434 | * address of the command-line parameters. | |
435 | * If we were booted from an xcoff image (i.e. netbooted or | |
436 | * booted from floppy), we get the command line from the | |
437 | * bootargs property of the /chosen node. | |
438 | * If an initial ramdisk is present, r3 and r4 | |
439 | * are used for initrd_start and initrd_size, | |
440 | * otherwise they contain 0xdeadbeef. | |
441 | */ | |
442 | if (r3 >= 0x4000 && r3 < 0x800000 && r4 == 0) { | |
443 | strlcpy(cmd_line, (char *)r3 + KERNELBASE, | |
444 | sizeof(cmd_line)); | |
445 | } else if (boot_infos != 0) { | |
446 | /* booted by BootX - check for ramdisk */ | |
447 | if (boot_infos->kernelParamsOffset != 0) | |
448 | strlcpy(cmd_line, (char *) boot_infos | |
449 | + boot_infos->kernelParamsOffset, | |
450 | sizeof(cmd_line)); | |
451 | #ifdef CONFIG_BLK_DEV_INITRD | |
452 | if (boot_infos->ramDisk) { | |
453 | initrd_start = (unsigned long) boot_infos | |
454 | + boot_infos->ramDisk; | |
455 | initrd_end = initrd_start + boot_infos->ramDiskSize; | |
456 | initrd_below_start_ok = 1; | |
457 | } | |
458 | #endif | |
459 | } else { | |
460 | struct device_node *chosen; | |
461 | char *p; | |
462 | ||
463 | #ifdef CONFIG_BLK_DEV_INITRD | |
464 | if (r3 && r4 && r4 != 0xdeadbeef) { | |
465 | if (r3 < KERNELBASE) | |
466 | r3 += KERNELBASE; | |
467 | initrd_start = r3; | |
468 | initrd_end = r3 + r4; | |
469 | ROOT_DEV = Root_RAM0; | |
470 | initrd_below_start_ok = 1; | |
471 | } | |
472 | #endif | |
473 | chosen = find_devices("chosen"); | |
474 | if (chosen != NULL) { | |
475 | p = get_property(chosen, "bootargs", NULL); | |
476 | if (p && *p) { | |
477 | strlcpy(cmd_line, p, sizeof(cmd_line)); | |
478 | } | |
479 | } | |
480 | } | |
481 | #ifdef CONFIG_ADB | |
482 | if (strstr(cmd_line, "adb_sync")) { | |
483 | extern int __adb_probe_sync; | |
484 | __adb_probe_sync = 1; | |
485 | } | |
486 | #endif /* CONFIG_ADB */ | |
487 | ||
488 | switch (_machine) { | |
14cf11af | 489 | #ifdef CONFIG_PPC_CHRP |
1da177e4 LT |
490 | case _MACH_chrp: |
491 | chrp_init(r3, r4, r5, r6, r7); | |
492 | break; | |
14cf11af | 493 | #endif |
1da177e4 | 494 | } |
a7fdd90b | 495 | #endif /* CONFIG_PPC_OF */ |
1da177e4 | 496 | } |
a7fdd90b | 497 | #endif /* CONFIG_PPC_MULTIPLATFORM */ |
1da177e4 | 498 | |
a7fdd90b | 499 | #ifdef CONFIG_PPC_OF |
1da177e4 LT |
500 | #ifdef CONFIG_SERIAL_CORE_CONSOLE |
501 | extern char *of_stdout_device; | |
502 | ||
503 | static int __init set_preferred_console(void) | |
504 | { | |
505 | struct device_node *prom_stdout; | |
506 | char *name; | |
45fed46f | 507 | int offset = 0; |
1da177e4 LT |
508 | |
509 | if (of_stdout_device == NULL) | |
510 | return -ENODEV; | |
511 | ||
512 | /* The user has requested a console so this is already set up. */ | |
513 | if (strstr(saved_command_line, "console=")) | |
514 | return -EBUSY; | |
515 | ||
516 | prom_stdout = find_path_device(of_stdout_device); | |
517 | if (!prom_stdout) | |
518 | return -ENODEV; | |
519 | ||
520 | name = (char *)get_property(prom_stdout, "name", NULL); | |
521 | if (!name) | |
522 | return -ENODEV; | |
523 | ||
524 | if (strcmp(name, "serial") == 0) { | |
525 | int i; | |
526 | u32 *reg = (u32 *)get_property(prom_stdout, "reg", &i); | |
527 | if (i > 8) { | |
528 | switch (reg[1]) { | |
529 | case 0x3f8: | |
530 | offset = 0; | |
531 | break; | |
532 | case 0x2f8: | |
533 | offset = 1; | |
534 | break; | |
535 | case 0x898: | |
536 | offset = 2; | |
537 | break; | |
538 | case 0x890: | |
539 | offset = 3; | |
540 | break; | |
541 | default: | |
542 | /* We dont recognise the serial port */ | |
543 | return -ENODEV; | |
544 | } | |
545 | } | |
546 | } else if (strcmp(name, "ch-a") == 0) | |
547 | offset = 0; | |
548 | else if (strcmp(name, "ch-b") == 0) | |
549 | offset = 1; | |
550 | else | |
551 | return -ENODEV; | |
552 | return add_preferred_console("ttyS", offset, NULL); | |
553 | } | |
554 | console_initcall(set_preferred_console); | |
555 | #endif /* CONFIG_SERIAL_CORE_CONSOLE */ | |
a7fdd90b | 556 | #endif /* CONFIG_PPC_OF */ |
1da177e4 LT |
557 | |
558 | struct bi_record *find_bootinfo(void) | |
559 | { | |
560 | struct bi_record *rec; | |
561 | ||
562 | rec = (struct bi_record *)_ALIGN((ulong)__bss_start+(1<<20)-1,(1<<20)); | |
563 | if ( rec->tag != BI_FIRST ) { | |
564 | /* | |
565 | * This 0x10000 offset is a terrible hack but it will go away when | |
566 | * we have the bootloader handle all the relocation and | |
567 | * prom calls -- Cort | |
568 | */ | |
569 | rec = (struct bi_record *)_ALIGN((ulong)__bss_start+0x10000+(1<<20)-1,(1<<20)); | |
570 | if ( rec->tag != BI_FIRST ) | |
571 | return NULL; | |
572 | } | |
573 | return rec; | |
574 | } | |
575 | ||
576 | void parse_bootinfo(struct bi_record *rec) | |
577 | { | |
578 | if (rec == NULL || rec->tag != BI_FIRST) | |
579 | return; | |
580 | while (rec->tag != BI_LAST) { | |
581 | ulong *data = rec->data; | |
582 | switch (rec->tag) { | |
583 | case BI_CMD_LINE: | |
584 | strlcpy(cmd_line, (void *)data, sizeof(cmd_line)); | |
585 | break; | |
1da177e4 LT |
586 | #ifdef CONFIG_BLK_DEV_INITRD |
587 | case BI_INITRD: | |
588 | initrd_start = data[0] + KERNELBASE; | |
589 | initrd_end = data[0] + data[1] + KERNELBASE; | |
590 | break; | |
591 | #endif /* CONFIG_BLK_DEV_INITRD */ | |
592 | #ifdef CONFIG_PPC_MULTIPLATFORM | |
593 | case BI_MACHTYPE: | |
de93f0d6 BH |
594 | /* Machine types changed with the merge. Since the |
595 | * bootinfo are now deprecated, we can just hard code | |
596 | * the appropriate conversion here for when we are | |
597 | * called with yaboot which passes us a machine type | |
598 | * this way. | |
599 | */ | |
600 | switch(data[0]) { | |
601 | case 1: _machine = _MACH_prep; break; | |
602 | case 2: _machine = _MACH_Pmac; break; | |
603 | case 4: _machine = _MACH_chrp; break; | |
604 | default: | |
605 | _machine = data[0]; | |
606 | } | |
1da177e4 LT |
607 | break; |
608 | #endif | |
609 | case BI_MEMSIZE: | |
610 | boot_mem_size = data[0]; | |
611 | break; | |
612 | } | |
613 | rec = (struct bi_record *)((ulong)rec + rec->size); | |
614 | } | |
615 | } | |
616 | ||
617 | /* | |
618 | * Find out what kind of machine we're on and save any data we need | |
619 | * from the early boot process (devtree is copied on pmac by prom_init()). | |
620 | * This is called very early on the boot process, after a minimal | |
621 | * MMU environment has been set up but before MMU_init is called. | |
622 | */ | |
623 | void __init | |
624 | machine_init(unsigned long r3, unsigned long r4, unsigned long r5, | |
625 | unsigned long r6, unsigned long r7) | |
626 | { | |
627 | #ifdef CONFIG_CMDLINE | |
628 | strlcpy(cmd_line, CONFIG_CMDLINE, sizeof(cmd_line)); | |
629 | #endif /* CONFIG_CMDLINE */ | |
630 | ||
631 | #ifdef CONFIG_6xx | |
632 | ppc_md.power_save = ppc6xx_idle; | |
633 | #endif | |
634 | #ifdef CONFIG_POWER4 | |
635 | ppc_md.power_save = power4_idle; | |
636 | #endif | |
637 | ||
638 | platform_init(r3, r4, r5, r6, r7); | |
639 | ||
640 | if (ppc_md.progress) | |
641 | ppc_md.progress("id mach(): done", 0x200); | |
642 | } | |
a2f40ccd KG |
643 | #ifdef CONFIG_BOOKE_WDT |
644 | /* Checks wdt=x and wdt_period=xx command-line option */ | |
645 | int __init early_parse_wdt(char *p) | |
646 | { | |
a2f40ccd | 647 | if (p && strncmp(p, "0", 1) != 0) |
39cdc4bf | 648 | booke_wdt_enabled = 1; |
a2f40ccd KG |
649 | |
650 | return 0; | |
651 | } | |
652 | early_param("wdt", early_parse_wdt); | |
653 | ||
654 | int __init early_parse_wdt_period (char *p) | |
655 | { | |
a2f40ccd | 656 | if (p) |
39cdc4bf | 657 | booke_wdt_period = simple_strtoul(p, NULL, 0); |
a2f40ccd KG |
658 | |
659 | return 0; | |
660 | } | |
661 | early_param("wdt_period", early_parse_wdt_period); | |
662 | #endif /* CONFIG_BOOKE_WDT */ | |
1da177e4 LT |
663 | |
664 | /* Checks "l2cr=xxxx" command-line option */ | |
665 | int __init ppc_setup_l2cr(char *str) | |
666 | { | |
667 | if (cpu_has_feature(CPU_FTR_L2CR)) { | |
668 | unsigned long val = simple_strtoul(str, NULL, 0); | |
669 | printk(KERN_INFO "l2cr set to %lx\n", val); | |
670 | _set_L2CR(0); /* force invalidate by disable cache */ | |
671 | _set_L2CR(val); /* and enable it */ | |
672 | } | |
673 | return 1; | |
674 | } | |
675 | __setup("l2cr=", ppc_setup_l2cr); | |
676 | ||
677 | #ifdef CONFIG_GENERIC_NVRAM | |
678 | ||
679 | /* Generic nvram hooks used by drivers/char/gen_nvram.c */ | |
680 | unsigned char nvram_read_byte(int addr) | |
681 | { | |
682 | if (ppc_md.nvram_read_val) | |
683 | return ppc_md.nvram_read_val(addr); | |
684 | return 0xff; | |
685 | } | |
686 | EXPORT_SYMBOL(nvram_read_byte); | |
687 | ||
688 | void nvram_write_byte(unsigned char val, int addr) | |
689 | { | |
690 | if (ppc_md.nvram_write_val) | |
691 | ppc_md.nvram_write_val(addr, val); | |
692 | } | |
693 | EXPORT_SYMBOL(nvram_write_byte); | |
694 | ||
695 | void nvram_sync(void) | |
696 | { | |
697 | if (ppc_md.nvram_sync) | |
698 | ppc_md.nvram_sync(); | |
699 | } | |
700 | EXPORT_SYMBOL(nvram_sync); | |
701 | ||
702 | #endif /* CONFIG_NVRAM */ | |
703 | ||
704 | static struct cpu cpu_devices[NR_CPUS]; | |
705 | ||
706 | int __init ppc_init(void) | |
707 | { | |
708 | int i; | |
709 | ||
710 | /* clear the progress line */ | |
711 | if ( ppc_md.progress ) ppc_md.progress(" ", 0xffff); | |
712 | ||
713 | /* register CPU devices */ | |
394e3902 AM |
714 | for_each_cpu(i) |
715 | register_cpu(&cpu_devices[i], i, NULL); | |
1da177e4 LT |
716 | |
717 | /* call platform init */ | |
718 | if (ppc_md.init != NULL) { | |
719 | ppc_md.init(); | |
720 | } | |
721 | return 0; | |
722 | } | |
723 | ||
724 | arch_initcall(ppc_init); | |
725 | ||
726 | /* Warning, IO base is not yet inited */ | |
727 | void __init setup_arch(char **cmdline_p) | |
728 | { | |
729 | extern char *klimit; | |
730 | extern void do_init_bootmem(void); | |
731 | ||
732 | /* so udelay does something sensible, assume <= 1000 bogomips */ | |
733 | loops_per_jiffy = 500000000 / HZ; | |
734 | ||
51d3082f BH |
735 | if (ppc_md.init_early) |
736 | ppc_md.init_early(); | |
737 | ||
1da177e4 | 738 | #ifdef CONFIG_XMON |
fd582ec8 | 739 | xmon_init(1); |
1da177e4 LT |
740 | if (strstr(cmd_line, "xmon")) |
741 | xmon(NULL); | |
742 | #endif /* CONFIG_XMON */ | |
743 | if ( ppc_md.progress ) ppc_md.progress("setup_arch: enter", 0x3eab); | |
744 | ||
745 | #if defined(CONFIG_KGDB) | |
746 | if (ppc_md.kgdb_map_scc) | |
747 | ppc_md.kgdb_map_scc(); | |
748 | set_debug_traps(); | |
749 | if (strstr(cmd_line, "gdb")) { | |
750 | if (ppc_md.progress) | |
751 | ppc_md.progress("setup_arch: kgdb breakpoint", 0x4000); | |
752 | printk("kgdb breakpoint activated\n"); | |
753 | breakpoint(); | |
754 | } | |
755 | #endif | |
756 | ||
757 | /* | |
758 | * Set cache line size based on type of cpu as a default. | |
759 | * Systems with OF can look in the properties on the cpu node(s) | |
760 | * for a possibly more accurate value. | |
761 | */ | |
762 | if (cpu_has_feature(CPU_FTR_SPLIT_ID_CACHE)) { | |
400d2212 KG |
763 | dcache_bsize = cur_cpu_spec->dcache_bsize; |
764 | icache_bsize = cur_cpu_spec->icache_bsize; | |
1da177e4 LT |
765 | ucache_bsize = 0; |
766 | } else | |
767 | ucache_bsize = dcache_bsize = icache_bsize | |
400d2212 | 768 | = cur_cpu_spec->dcache_bsize; |
1da177e4 LT |
769 | |
770 | /* reboot on panic */ | |
771 | panic_timeout = 180; | |
772 | ||
773 | init_mm.start_code = PAGE_OFFSET; | |
774 | init_mm.end_code = (unsigned long) _etext; | |
775 | init_mm.end_data = (unsigned long) _edata; | |
776 | init_mm.brk = (unsigned long) klimit; | |
777 | ||
778 | /* Save unparsed command line copy for /proc/cmdline */ | |
779 | strlcpy(saved_command_line, cmd_line, COMMAND_LINE_SIZE); | |
780 | *cmdline_p = cmd_line; | |
781 | ||
19bbdf0e PM |
782 | parse_early_param(); |
783 | ||
1da177e4 LT |
784 | /* set up the bootmem stuff with available memory */ |
785 | do_init_bootmem(); | |
786 | if ( ppc_md.progress ) ppc_md.progress("setup_arch: bootmem", 0x3eab); | |
787 | ||
788 | #ifdef CONFIG_PPC_OCP | |
789 | /* Initialize OCP device list */ | |
790 | ocp_early_init(); | |
791 | if ( ppc_md.progress ) ppc_md.progress("ocp: exit", 0x3eab); | |
792 | #endif | |
793 | ||
794 | #ifdef CONFIG_DUMMY_CONSOLE | |
795 | conswitchp = &dummy_con; | |
796 | #endif | |
797 | ||
798 | ppc_md.setup_arch(); | |
799 | if ( ppc_md.progress ) ppc_md.progress("arch: exit", 0x3eab); | |
800 | ||
801 | paging_init(); | |
802 | ||
803 | /* this is for modules since _machine can be a define -- Cort */ | |
804 | ppc_md.ppc_machine = _machine; | |
805 | } |