Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

at v2.6.12 101 lines 3.0 kB view raw
1/* 2 * Copyright (C) Paul Mackerras 1997. 3 * 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> 12 13#include "nonstdio.h" 14#include "of1275.h" 15 16/* Passed from the linker */ 17extern char __image_begin, __image_end; 18extern char __ramdisk_begin[], __ramdisk_end; 19extern char _start, _end; 20 21extern char image_data[], initrd_data[]; 22extern int initrd_len, image_len; 23extern unsigned int heap_max; 24extern void flush_cache(void *start, unsigned int len); 25extern void gunzip(void *, int, unsigned char *, int *); 26extern void make_bi_recs(unsigned long addr, char *name, unsigned int mach, 27 unsigned int progend); 28extern void setup_bats(unsigned long start); 29 30char *avail_ram; 31char *begin_avail, *end_avail; 32char *avail_high; 33 34#define SCRATCH_SIZE (128 << 10) 35 36static char heap[SCRATCH_SIZE]; 37 38static unsigned long ram_start = 0; 39static unsigned long ram_end = 0x1000000; 40 41static unsigned long prog_start = 0x900000; 42static unsigned long prog_size = 0x700000; 43 44typedef void (*kernel_start_t)(int, int, void *); 45 46void boot(int a1, int a2, void *prom) 47{ 48 unsigned sa, len; 49 void *dst; 50 unsigned char *im; 51 unsigned initrd_start, initrd_size; 52 53 printf("coffboot starting: loaded at 0x%p\n", &_start); 54 setup_bats(ram_start); 55 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; 68 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); 87 } 88 89 flush_cache(dst, len); 90 make_bi_recs(((unsigned long) dst + len), "coffboot", _MACH_Pmac, 91 (prog_start + prog_size)); 92 93 sa = (unsigned long)prog_start; 94 printf("start address = 0x%x\n", sa); 95 96 (*(kernel_start_t)sa)(a1, a2, prom); 97 98 printf("returned?\n"); 99 100 pause(); 101}