[TG3]: Set minimal hw interrupt mitigation.
[linux-2.6/verdex.git] / arch / ppc / boot / openfirmware / chrpmain.c
blob6fb4f738728c8fd09e0c3b40327d5a728df0111b
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 "nonstdio.h"
11 #include "of1275.h"
12 #include <asm/processor.h>
13 #include <asm/page.h>
15 /* Passed from the linker */
16 extern char __image_begin, __image_end;
17 extern char __ramdisk_begin, __ramdisk_end;
18 extern char _start, _end;
20 extern unsigned int heap_max;
21 extern void flush_cache(void *, unsigned long);
22 extern void gunzip(void *, int, unsigned char *, int *);
23 extern void make_bi_recs(unsigned long addr, char *name, unsigned int mach,
24 unsigned int progend);
26 char *avail_ram;
27 char *begin_avail, *end_avail;
28 char *avail_high;
30 #define RAM_START 0x00000000
31 #define RAM_END (64<<20)
33 #define BOOT_START ((unsigned long)_start)
34 #define BOOT_END ((unsigned long)(_end + 0xFFF) & ~0xFFF)
36 #define RAM_FREE ((unsigned long)(_end+0x1000)&~0xFFF)
37 #define PROG_START 0x00010000
38 #define PROG_SIZE 0x007f0000 /* 8MB */
40 #define SCRATCH_SIZE (128 << 10)
42 static char scratch[SCRATCH_SIZE]; /* 1MB of scratch space for gunzip */
44 typedef void (*kernel_start_t)(int, int, void *, unsigned int, unsigned int);
46 void
47 boot(int a1, int a2, void *prom)
49 unsigned sa, len;
50 void *dst;
51 unsigned char *im;
52 unsigned int initrd_size, initrd_start;
54 printf("chrpboot starting: loaded at 0x%p\n\r", &_start);
56 initrd_size = &__ramdisk_end - &__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, &__ramdisk_begin, initrd_size);
64 memcpy((char *)initrd_start, &__ramdisk_begin, initrd_size);
65 } else {
66 initrd_start = 0;
67 initrd_size = 0;
68 a2 = 0xdeadbeef;
71 im = &__image_begin;
72 len = &__image_end - &__image_begin;
73 /* claim 4MB starting at PROG_START */
74 claim(PROG_START, PROG_SIZE - PROG_START, 0);
75 dst = (void *) PROG_START;
76 if (im[0] == 0x1f && im[1] == 0x8b) {
77 avail_ram = scratch;
78 begin_avail = avail_high = avail_ram;
79 end_avail = scratch + sizeof(scratch);
80 printf("gunzipping (0x%p <- 0x%p:0x%p)...", dst, im, im+len);
81 gunzip(dst, 0x400000, im, &len);
82 printf("done %u bytes\n\r", len);
83 printf("%u bytes of heap consumed, max in use %u\n\r",
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), "chrpboot", _MACH_chrp,
91 (PROG_START + PROG_SIZE));
93 sa = PROG_START;
94 printf("start address = 0x%x\n\r", sa);
96 (*(kernel_start_t)sa)(a1, a2, prom, initrd_start, initrd_size);
98 printf("returned?\n\r");
100 pause();