6
#include "libopenbios/bindings.h"
7
#include "libopenbios/elf_load.h"
8
#include "libopenbios/initprogram.h"
9
#include "arch/common/nvram.h"
10
#include "libc/diskio.h"
13
void *load_elf(char *spec);
21
int i, lszz_offs, elf_offs;
22
char buf[128]; // , *addr;
27
if( (fd=open_io(spec)) == -1 )
30
if( (elf_offs=find_elf(fd)) < 0 ) {
31
printk("----> %s is not an ELF image\n", buf );
35
if( !(phdr=elf_readhdrs(fd, 0, &ehdr)) ) {
36
printk("elf32_readhdrs failed\n");
40
(unsigned long long *)entry = ehdr.e_entry;
43
for( i=0; i<ehdr.e_phnum; i++ ) {
44
s = MIN( phdr[i].p_filesz, phdr[i].p_memsz );
45
seek_io( fd, elf_offs + phdr[i].p_offset );
46
/* printk("filesz: %08lX memsz: %08lX p_offset: %08lX p_vaddr %08lX\n",
47
phdr[i].p_filesz, phdr[i].p_memsz, phdr[i].p_offset,
49
if( phdr[i].p_vaddr != phdr[i].p_paddr )
50
printk("WARNING: ELF segment virtual addr != physical addr\n");
51
lszz_offs = MAX( lszz_offs, elf_offs + phdr[i].p_offset + phdr[i].p_filesz );
55
printk("ELF ROM-section loaded at %08lX (size %08lX)\n",
56
(unsigned long)phdr[i].p_vaddr, (unsigned long)phdr[i].p_memsz);
71
/* Copy the incoming path */
73
path = pop_fstr_copy();
76
printk("[unix] Booting default not supported.\n");
79
printk("[unix] Booting '%s'\n",path);
82
printk("successfully loaded client at %llx.\n", (unsigned long long)(ucell)entry);
93
struct context * volatile __context;
96
arch_init_program(void)