mirror of
https://gitlab.com/qemu-project/openbios.git
synced 2024-02-13 08:34:06 +08:00
The new loader APIs in libopenbios already have routines to detect the type of executable at a given address and react
accordingly. Hence since the loaders are currently written in C, it makes more sense to drop down into C and re-use the same code rather than have a second implementation in Forth. Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@siriusit.co.uk> git-svn-id: svn://coreboot.org/openbios/trunk/openbios-devel@726 f158a5a8-5612-0410-a976-696ce0be7e32
This commit is contained in:
committed by
Mark Cave-Ayland
parent
9661f91432
commit
1b273803c2
@@ -10,7 +10,6 @@
|
||||
#define CONFIG_SPARC64_PAGE_SIZE_8KB
|
||||
#endif
|
||||
|
||||
#include "arch/common/a.out.h"
|
||||
#include "libopenbios/sys_info.h"
|
||||
#include "libopenbios/bindings.h"
|
||||
#include "libopenbios/aout_load.h"
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
<object source="fcode_load.c" condition="LOADER_FCODE"/>
|
||||
<object source="forth_load.c" condition="LOADER_FORTH"/>
|
||||
<object source="init.c"/>
|
||||
<object source="initprogram.c"/>
|
||||
<object source="ipchecksum.c"/>
|
||||
<object source="linuxbios_info.c" condition="LINUXBIOS"/>
|
||||
<object source="ofmem_common.c" condition="OFMEM"/>
|
||||
|
||||
@@ -16,9 +16,12 @@
|
||||
|
||||
#include "config.h"
|
||||
#include "libopenbios/openbios.h"
|
||||
#include "libopenbios/bindings.h"
|
||||
#include "libopenbios/initprogram.h"
|
||||
|
||||
void
|
||||
openbios_init( void )
|
||||
{
|
||||
// TODO
|
||||
// Bind the C implementation of (init-program) into Forth
|
||||
bind_func("(init-program)", init_program);
|
||||
}
|
||||
|
||||
85
libopenbios/initprogram.c
Normal file
85
libopenbios/initprogram.c
Normal file
@@ -0,0 +1,85 @@
|
||||
/*
|
||||
* Creation Date: <2010/04/02 13:00:00 mcayland>
|
||||
* Time-stamp: <2010/04/02 13:00:00 mcayland>
|
||||
*
|
||||
* <initprogram.c>
|
||||
*
|
||||
* C implementation of (init-program) word
|
||||
*
|
||||
* Copyright (C) 2010 Mark Cave-Ayland (mark.cave-ayland@siriusit.co.uk)
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* version 2
|
||||
*
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
#include "kernel/kernel.h"
|
||||
#include "libopenbios/bindings.h"
|
||||
#include "libopenbios/initprogram.h"
|
||||
|
||||
/* Because the a.out loader requires platform-specific headers */
|
||||
#ifdef CONFIG_LOADER_AOUT
|
||||
#include "libopenbios/aout_load.h"
|
||||
#endif
|
||||
|
||||
#include "libopenbios/bootinfo_load.h"
|
||||
#include "libopenbios/elf_load.h"
|
||||
#include "libopenbios/fcode_load.h"
|
||||
#include "libopenbios/forth_load.h"
|
||||
#include "libopenbios/xcoff_load.h"
|
||||
|
||||
|
||||
void init_program(void)
|
||||
{
|
||||
/* Get the value of load-base and use it to determine the correct loader
|
||||
to use */
|
||||
ucell addr;
|
||||
|
||||
feval("load-base");
|
||||
addr = POP();
|
||||
|
||||
#ifdef CONFIG_LOADER_AOUT
|
||||
if (is_aout((struct exec *)addr)) {
|
||||
aout_init_program();
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_LOADER_BOOTINFO
|
||||
if (is_bootinfo((char *)addr)) {
|
||||
bootinfo_init_program();
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_LOADER_ELF
|
||||
if (is_elf((Elf_ehdr *)addr)) {
|
||||
elf_init_program();
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_LOADER_FCODE
|
||||
if (is_fcode((unsigned char *)addr)) {
|
||||
fcode_init_program();
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_LOADER_FORTH
|
||||
if (is_forth((char *)addr)) {
|
||||
forth_init_program();
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_LOADER_XCOFF
|
||||
if (is_xcoff((COFF_filehdr_t *)addr)) {
|
||||
xcoff_init_program();
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user