mirror of
https://gitlab.com/qemu-project/openbios.git
synced 2024-02-13 08:34:06 +08:00
Move the *_init_program() functions into the main loader source files so that everything is in one place. Part of this
involves taking the existing parts of the XCOFF loader and putting them into a new loader file xcoff_load.c. Also fix a dependency order change these changes introduce when building openbios-unix. Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@siriusit.co.uk> git-svn-id: svn://coreboot.org/openbios/trunk/openbios-devel@720 f158a5a8-5612-0410-a976-696ce0be7e32
This commit is contained in:
committed by
Mark Cave-Ayland
parent
c60fad9646
commit
d4451ae216
@@ -19,6 +19,10 @@
|
||||
#define MAX_HEADERS 0x20
|
||||
#define BS 0x100 /* smallest step used when looking for the ELF header */
|
||||
|
||||
#ifdef CONFIG_PPC
|
||||
extern void flush_icache_range( char *start, char *stop );
|
||||
#endif
|
||||
|
||||
/* FreeBSD and possibly others mask the high 8 bits */
|
||||
#define addr_fixup(addr) ((addr) & 0x00ffffff)
|
||||
|
||||
@@ -362,7 +366,8 @@ elf_readhdrs(int offset, Elf_ehdr *ehdr)
|
||||
return phdr;
|
||||
}
|
||||
|
||||
int elf_load(struct sys_info *info, const char *filename, const char *cmdline, void **boot_notes)
|
||||
int
|
||||
elf_load(struct sys_info *info, const char *filename, const char *cmdline, void **boot_notes)
|
||||
{
|
||||
Elf_ehdr ehdr;
|
||||
Elf_phdr *phdr = NULL;
|
||||
@@ -460,3 +465,55 @@ out:
|
||||
free(image_version);
|
||||
return retval;
|
||||
}
|
||||
|
||||
void
|
||||
elf_init_program(void)
|
||||
{
|
||||
char *base;
|
||||
int i;
|
||||
Elf_ehdr *ehdr;
|
||||
Elf_phdr *phdr;
|
||||
size_t size;
|
||||
char *addr;
|
||||
cell tmp;
|
||||
|
||||
/* TODO: manage ELF notes section */
|
||||
feval("0 state-valid !");
|
||||
feval("load-base");
|
||||
base = (char*)POP();
|
||||
|
||||
ehdr = (Elf_ehdr *)base;
|
||||
phdr = (Elf_phdr *)(base + ehdr->e_phoff);
|
||||
|
||||
for (i = 0; i < ehdr->e_phnum; i++) {
|
||||
|
||||
#if DEBUG
|
||||
debug("filesz: %08lX memsz: %08lX p_offset: %08lX "
|
||||
"p_vaddr %08lX\n",
|
||||
(ulong)phdr[i].p_filesz, (ulong)phdr[i].p_memsz,
|
||||
(ulong)phdr[i].p_offset, (ulong)phdr[i].p_vaddr );
|
||||
#endif
|
||||
|
||||
size = MIN(phdr[i].p_filesz, phdr[i].p_memsz);
|
||||
if (!size)
|
||||
continue;
|
||||
#if 0
|
||||
if( ofmem_claim( phdr[i].p_vaddr, phdr[i].p_memsz, 0 ) == -1 ) {
|
||||
printk("Claim failed!\n");
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
/* Workaround for archs where sizeof(int) != pointer size */
|
||||
tmp = phdr[i].p_vaddr;
|
||||
addr = (char *)tmp;
|
||||
|
||||
memcpy(addr, base + phdr[i].p_offset, size);
|
||||
#ifdef CONFIG_PPC
|
||||
flush_icache_range( addr, addr + size );
|
||||
#endif
|
||||
}
|
||||
/* FIXME: should initialize saved-program-state. */
|
||||
PUSH(ehdr->e_entry);
|
||||
feval("elf-entry !");
|
||||
feval("-1 state-valid !");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user