[TG3]: Set minimal hw interrupt mitigation.
[linux-2.6/verdex.git] / arch / ppc / boot / openfirmware / coffmain.c
blob04ba9d57e110627e8881a25348f7bb2a977ad9da
1 /*
2 * Copyright (C) Paul Mackerras 1997.
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version
7 * 2 of the License, or (at your option) any later version.
8 */
9 #include <linux/string.h>
10 #include <asm/processor.h>
11 #include <asm/page.h>
13 #include "nonstdio.h"
14 #include "of1275.h"
16 /* Passed from the linker */
17 extern char __image_begin, __image_end;
18 extern char __ramdisk_begin[], __ramdisk_end;
19 extern char _start, _end;
21 extern char image_data[], initrd_data[];
22 extern int initrd_len, image_len;
23 extern unsigned int heap_max;
24 extern void flush_cache(void *start, unsigned int len);
25 extern void gunzip(void *, int, unsigned char *, int *);
26 extern void make_bi_recs(unsigned long addr, char *name, unsigned int mach,
27 unsigned int progend);
28 extern void setup_bats(unsigned long start);
30 char *avail_ram;
31 char *begin_avail, *end_avail;
32 char *avail_high;
34 #define SCRATCH_SIZE (128 << 10)
36 static char heap[SCRATCH_SIZE];
38 static unsigned long ram_start = 0;
39 static unsigned long ram_end = 0x1000000;
41 static unsigned long prog_start = 0x900000;
42 static unsigned long prog_size = 0x700000;
44 typedef void (*kernel_start_t)(int, int, void *);
46 void boot(int a1, int a2, void *prom)
48 unsigned sa, len;
49 void *dst;
50 unsigned char *im;
51 unsigned initrd_start, initrd_size;
53 printf("coffboot starting: loaded at 0x%p\n", &_start);
54 setup_bats(ram_start);
56 initrd_size = (char *)(&__ramdisk_end) - (char *)(&__ramdisk_begin);
57 if (initrd_size) {
58 initrd_start = (ram_end - initrd_size) & ~0xFFF;
59 a1 = initrd_start;
60 a2 = initrd_size;
61 claim(initrd_start, ram_end - initrd_start, 0);
62 printf("initial ramdisk moving 0x%x <- 0x%p (%x bytes)\n\r",
63 initrd_start, (char *)(&__ramdisk_begin), initrd_size);
64 memcpy((char *)initrd_start, (char *)(&__ramdisk_begin), initrd_size);
65 prog_size = initrd_start - prog_start;
66 } else
67 a2 = 0xdeadbeef;
69 im = (char *)(&__image_begin);
70 len = (char *)(&__image_end) - (char *)(&__image_begin);
71 /* claim 4MB starting at PROG_START */
72 claim(prog_start, prog_size, 0);
73 map(prog_start, prog_start, prog_size);
74 dst = (void *) prog_start;
75 if (im[0] == 0x1f && im[1] == 0x8b) {
76 /* set up scratch space */
77 begin_avail = avail_high = avail_ram = heap;
78 end_avail = heap + sizeof(heap);
79 printf("heap at 0x%p\n", avail_ram);
80 printf("gunzipping (0x%p <- 0x%p:0x%p)...", dst, im, im+len);
81 gunzip(dst, prog_size, im, &len);
82 printf("done %u bytes\n", len);
83 printf("%u bytes of heap consumed, max in use %u\n",
84 avail_high - begin_avail, heap_max);
85 } else {
86 memmove(dst, im, len);
89 flush_cache(dst, len);
90 make_bi_recs(((unsigned long) dst + len), "coffboot", _MACH_Pmac,
91 (prog_start + prog_size));
93 sa = (unsigned long)prog_start;
94 printf("start address = 0x%x\n", sa);
96 (*(kernel_start_t)sa)(a1, a2, prom);
98 printf("returned?\n");
100 pause();