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