load should place the file at load-base, whilst init-program should parse the memory at load-base and set up the context accordingly.
Signed-off-by: Mark Cave-Ayland mark.cave-ayland@ilande.co.uk --- libopenbios/fcode_load.c | 26 ++++++++------------------ libopenbios/load.c | 9 +++------ 2 files changed, 11 insertions(+), 24 deletions(-)
diff --git a/libopenbios/fcode_load.c b/libopenbios/fcode_load.c index 5258357..3d2da2f 100644 --- a/libopenbios/fcode_load.c +++ b/libopenbios/fcode_load.c @@ -6,6 +6,7 @@ #include "kernel/kernel.h" #include "libopenbios/bindings.h" #include "libopenbios/fcode_load.h" +#include "libopenbios/initprogram.h" #include "libopenbios/sys_info.h" #include "libc/diskio.h" #define printf printk @@ -76,14 +77,10 @@ fcode_load(ihandle_t dev) debug("entry point is %#lx\n", start);
// Initialise load-state - PUSH(start); - feval("load-state >ls.entry !"); PUSH(size); feval("load-state >ls.file-size !"); feval("fcode load-state >ls.file-type !");
- feval("-1 state-valid !"); - out: close_io(fd); return retval; @@ -92,18 +89,11 @@ out: void fcode_init_program(void) { - /* If the payload is Fcode then we execute it immediately */ - ucell address; - - fword("load-base"); - address = POP(); - - if (!is_fcode((unsigned char *)address)) { - debug("Not a valid Fcode memory image\n"); - return; - } - - PUSH(address); - PUSH(1); - fword("byte-load"); + /* Use trampoline context to execute FCode */ + PUSH((ucell)&init_fcode_context); + feval("load-state >ls.entry !"); + + arch_init_program(); + + feval("-1 state-valid !"); } diff --git a/libopenbios/load.c b/libopenbios/load.c index edc95cb..1d64cc7 100644 --- a/libopenbios/load.c +++ b/libopenbios/load.c @@ -85,12 +85,9 @@ void load(ihandle_t dev) #endif
#ifdef CONFIG_LOADER_FCODE - fcode_load(dev); - feval("state-valid @"); - valid = POP(); - if (valid) { - feval("load-state >ls.file-size @"); - return; + if (fcode_load(dev) != LOADER_NOT_SUPPORT) { + feval("load-state >ls.file-size @"); + return; } #endif