mirror of
https://gitlab.com/qemu-project/openbios.git
synced 2024-02-13 08:34:06 +08:00
Move the Forth loader forthload.c from arch/*/forthload.c to libopenbios/forth_load.c. While the Forth loader source was
included and built as part of the SPARC64 and SPARC32 builds, it was never actually invoked in the boot sequence. Hence this patch maintains the existing behaviour in that only X86 builds included the Forth loader. Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@siriusit.co.uk> git-svn-id: svn://coreboot.org/openbios/trunk/openbios-devel@712 f158a5a8-5612-0410-a976-696ce0be7e32
This commit is contained in:
committed by
Mark Cave-Ayland
parent
f02d2bde53
commit
126f9ee43e
@@ -12,17 +12,20 @@
|
||||
#include "arch/common/nvram.h"
|
||||
#include "libc/diskio.h"
|
||||
#include "libopenbios/sys_info.h"
|
||||
#include "libopenbios/elf_load.h"
|
||||
#include "libopenbios/forth_load.h"
|
||||
#include "boot.h"
|
||||
|
||||
struct sys_info sys_info;
|
||||
|
||||
static int try_path(const char *path, char *param)
|
||||
{
|
||||
void *boot_notes = NULL;
|
||||
ucell valid, address, type, size;
|
||||
int image_retval = 0;;
|
||||
|
||||
/* ELF Boot loader */
|
||||
elf_load(&sys_info, path, param);
|
||||
elf_load(&sys_info, path, param, &boot_notes);
|
||||
feval("state-valid @");
|
||||
valid = POP();
|
||||
if (valid)
|
||||
@@ -32,7 +35,7 @@ static int try_path(const char *path, char *param)
|
||||
linux_load(&sys_info, path, param);
|
||||
|
||||
/* Forth loader */
|
||||
forth_load(&sys_info, path, param);
|
||||
forth_load(path);
|
||||
feval("state-valid @");
|
||||
valid = POP();
|
||||
if (valid)
|
||||
|
||||
@@ -6,12 +6,6 @@
|
||||
* the copyright and warranty status of this work.
|
||||
*/
|
||||
|
||||
/* forthload.c */
|
||||
int forth_load(struct sys_info *info, const char *filename, const char *cmdline);
|
||||
|
||||
/* elfload.c */
|
||||
int elf_load(struct sys_info *info, const char *filename, const char *cmdline);
|
||||
|
||||
/* linux_load.c */
|
||||
int linux_load(struct sys_info *info, const char *file, const char *cmdline);
|
||||
|
||||
|
||||
@@ -14,7 +14,6 @@
|
||||
<object source="linux_load.c"/>
|
||||
<object source="segment.c"/>
|
||||
<object source="sys_info.c"/>
|
||||
<object source="forthload.c"/>
|
||||
<object source="entry.S"/>
|
||||
<object source="xbox/console.c" condition="XBOX"/>
|
||||
<object source="xbox/methods.c" condition="XBOX"/>
|
||||
|
||||
@@ -1,75 +0,0 @@
|
||||
/* tag: forth source loader
|
||||
*
|
||||
* Copyright (C) 2004 Stefan Reinauer
|
||||
*
|
||||
* See the file "COPYING" for further information about
|
||||
* the copyright and warranty status of this work.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
#include "kernel/kernel.h"
|
||||
#include "libopenbios/bindings.h"
|
||||
#include "libopenbios/sys_info.h"
|
||||
#include "libc/diskio.h"
|
||||
#include "boot.h"
|
||||
#define printk printk
|
||||
#define debug printk
|
||||
|
||||
static char *forthtext=NULL;
|
||||
static int fd;
|
||||
|
||||
int forth_load(struct sys_info *info, const char *filename, const char *cmdline)
|
||||
{
|
||||
char magic[2];
|
||||
unsigned long forthsize;
|
||||
int retval = -1;
|
||||
|
||||
/* Mark the saved-program-state as invalid */
|
||||
feval("0 state-valid !");
|
||||
|
||||
fd = open_io(filename);
|
||||
if (!fd)
|
||||
goto out;
|
||||
|
||||
if (read_io(fd, magic, 2) != 2) {
|
||||
debug("Can't read magic header\n");
|
||||
retval = LOADER_NOT_SUPPORT;
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (magic[0] != '\\' || magic[1] != ' ') {
|
||||
debug("No forth source image\n");
|
||||
retval = LOADER_NOT_SUPPORT;
|
||||
goto out;
|
||||
}
|
||||
|
||||
/* Calculate the file size by seeking to the end of the file */
|
||||
seek_io(fd, -1);
|
||||
forthsize = tell(fd);
|
||||
forthtext = malloc(forthsize+1);
|
||||
seek_io(fd, 0);
|
||||
|
||||
printk("Loading forth source ...");
|
||||
if (read_io(fd, forthtext, forthsize) != forthsize) {
|
||||
printk("Can't read forth text\n");
|
||||
goto out;
|
||||
}
|
||||
forthtext[forthsize]=0;
|
||||
printk("ok\n");
|
||||
|
||||
close_io(fd);
|
||||
|
||||
// Initialise saved-program-state
|
||||
PUSH((ucell)forthtext);
|
||||
feval("saved-program-state >sps.entry !");
|
||||
PUSH((ucell)forthsize);
|
||||
feval("saved-program-state >sps.file-size !");
|
||||
feval("forth saved-program-state >sps.file-type !");
|
||||
|
||||
feval("-1 state-valid !");
|
||||
|
||||
out:
|
||||
//if (forthtext)
|
||||
// free(forthtext);
|
||||
return retval;
|
||||
}
|
||||
Reference in New Issue
Block a user