Author: mcayland Date: Fri Mar 26 22:17:32 2010 New Revision: 708 URL: http://tracker.coreboot.org/trac/openbios/changeset/708
Log: Introduce the concept of the OF saved-program-state structure and modify all of the loaders (except PPC) to make use of it.
Signed-off-by: Mark Cave-Ayland mark.cave-ayland@siriusit.co.uk
Modified: trunk/openbios-devel/arch/amd64/elfload.c trunk/openbios-devel/arch/sparc32/aoutload.c trunk/openbios-devel/arch/sparc32/elfload.c trunk/openbios-devel/arch/sparc32/forthload.c trunk/openbios-devel/arch/sparc64/aoutload.c trunk/openbios-devel/arch/sparc64/elfload.c trunk/openbios-devel/arch/sparc64/fcodeload.c trunk/openbios-devel/arch/sparc64/forthload.c trunk/openbios-devel/arch/x86/elfload.c trunk/openbios-devel/arch/x86/forthload.c trunk/openbios-devel/forth/debugging/client.fs
Modified: trunk/openbios-devel/arch/amd64/elfload.c ============================================================================== --- trunk/openbios-devel/arch/amd64/elfload.c Fri Mar 26 21:25:04 2010 (r707) +++ trunk/openbios-devel/arch/amd64/elfload.c Fri Mar 26 22:17:32 2010 (r708) @@ -311,6 +311,9 @@
image_name = image_version = 0;
+ /* Mark the saved-program-state as invalid */ + feval("0 state-valid !"); + if (!file_open(filename)) goto out;
@@ -368,6 +371,16 @@
debug("entry point is %#x\n", ehdr.e_entry); printf("Jumping to entry point...\n"); + + // Initialise saved-program-state + PUSH(ehdr.e_entry); + feval("saved-program-state >sps.entry !"); + PUSH(file_size); + feval("saved-program-state >sps.file-size !"); + feval("elf-boot saved-program-state >sps.file-type !"); + + feval("-1 state-valid !"); + image_retval = start_elf(ehdr.e_entry, virt_to_phys(boot_notes));
// console_init(); FIXME
Modified: trunk/openbios-devel/arch/sparc32/aoutload.c ============================================================================== --- trunk/openbios-devel/arch/sparc32/aoutload.c Fri Mar 26 21:25:04 2010 (r707) +++ trunk/openbios-devel/arch/sparc32/aoutload.c Fri Mar 26 22:17:32 2010 (r708) @@ -7,6 +7,7 @@ #include "kernel/kernel.h" #include "arch/common/a.out.h" #include "libopenbios/sys_info.h" +#include "libopenbios/bindings.h" #include "libc/diskio.h" #include "boot.h" #define printf printk @@ -62,6 +63,9 @@
image_name = image_version = NULL;
+ /* Mark the saved-program-state as invalid */ + feval("0 state-valid !"); + fd = open_io(filename); if (!fd) goto out; @@ -119,8 +123,17 @@ }
debug("Loaded %lu bytes\n", size); - debug("entry point is %#lx\n", start); + + // Initialise saved-program-state + PUSH(addr_fixup(start)); + feval("saved-program-state >sps.entry !"); + PUSH(size); + feval("saved-program-state >sps.file-size !"); + feval("aout saved-program-state >sps.file-type !"); + + feval("-1 state-valid !"); + printf("Jumping to entry point...\n");
#if 1
Modified: trunk/openbios-devel/arch/sparc32/elfload.c ============================================================================== --- trunk/openbios-devel/arch/sparc32/elfload.c Fri Mar 26 21:25:04 2010 (r707) +++ trunk/openbios-devel/arch/sparc32/elfload.c Fri Mar 26 22:17:32 2010 (r708) @@ -10,6 +10,7 @@ #include "arch/common/elf_boot.h" #include "libopenbios/sys_info.h" #include "libopenbios/ipchecksum.h" +#include "libopenbios/bindings.h" #include "libc/diskio.h" #include "boot.h" #define printf printk @@ -135,13 +136,12 @@
static int load_segments(Elf_phdr *phdr, int phnum, unsigned long checksum_offset, - unsigned int offset) + unsigned int offset, unsigned long *bytes) { - unsigned long bytes; //unsigned int start_time, time; int i;
- bytes = 0; + *bytes = 0; // start_time = currticks(); for (i = 0; i < phnum; i++) { if (phdr[i].p_type != PT_LOAD) @@ -155,7 +155,7 @@ printf("Can't read program segment %d\n", i); return 0; } - bytes += phdr[i].p_filesz; + *bytes += phdr[i].p_filesz; debug("clearing... "); memset(phys_to_virt(addr_fixup(phdr[i].p_paddr) + phdr[i].p_filesz), 0, phdr[i].p_memsz - phdr[i].p_filesz); @@ -171,7 +171,7 @@ // time = currticks() - start_time; //debug("Loaded %lu bytes in %ums (%luKB/s)\n", bytes, time, // time? bytes/time : 0); - debug("Loaded %lu bytes \n", bytes); + debug("Loaded %lu bytes \n", *bytes);
return 1; } @@ -308,7 +308,7 @@ Elf_ehdr ehdr; Elf_phdr *phdr = NULL; unsigned long phdr_size; - unsigned long checksum_offset; + unsigned long checksum_offset, file_size; unsigned short checksum = 0; Elf_Bhdr *boot_notes = NULL; int retval = -1; @@ -317,6 +317,9 @@
image_name = image_version = NULL;
+ /* Mark the saved-program-state as invalid */ + feval("0 state-valid !"); + fd = open_io(filename); if (!fd) goto out; @@ -368,7 +371,7 @@ printf(" version %s", image_version); printf("...\n");
- if (!load_segments(phdr, ehdr.e_phnum, checksum_offset, offset)) + if (!load_segments(phdr, ehdr.e_phnum, checksum_offset, offset, &file_size)) goto out;
if (checksum_offset) { @@ -381,6 +384,16 @@ //debug("current time: %lu\n", currticks());
debug("entry point is %#x\n", addr_fixup(ehdr.e_entry)); + + // Initialise saved-program-state + PUSH(addr_fixup(ehdr.e_entry)); + feval("saved-program-state >sps.entry !"); + PUSH(file_size); + feval("saved-program-state >sps.file-size !"); + feval("elf-boot saved-program-state >sps.file-type !"); + + feval("-1 state-valid !"); + printf("Jumping to entry point...\n");
#if 1
Modified: trunk/openbios-devel/arch/sparc32/forthload.c ============================================================================== --- trunk/openbios-devel/arch/sparc32/forthload.c Fri Mar 26 21:25:04 2010 (r707) +++ trunk/openbios-devel/arch/sparc32/forthload.c Fri Mar 26 22:17:32 2010 (r708) @@ -24,6 +24,9 @@ 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; @@ -54,6 +57,17 @@ 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 !"); + PUSH ( (ucell)forthtext ); PUSH ( (ucell)forthsize ); fword("eval2");
Modified: trunk/openbios-devel/arch/sparc64/aoutload.c ============================================================================== --- trunk/openbios-devel/arch/sparc64/aoutload.c Fri Mar 26 21:25:04 2010 (r707) +++ trunk/openbios-devel/arch/sparc64/aoutload.c Fri Mar 26 22:17:32 2010 (r708) @@ -8,6 +8,7 @@ #define CONFIG_SPARC64_PAGE_SIZE_8KB #include "arch/common/a.out.h" #include "libopenbios/sys_info.h" +#include "libopenbios/bindings.h" #include "libc/diskio.h" #include "boot.h" #define printf printk @@ -63,6 +64,9 @@
image_name = image_version = NULL;
+ /* Mark the saved-program-state as invalid */ + feval("0 state-valid !"); + fd = open_io(filename); if (!fd) goto out; @@ -123,8 +127,17 @@ }
debug("Loaded %lu bytes\n", size); - debug("entry point is %#lx\n", start); + + // Initialise saved-program-state + PUSH(addr_fixup(start)); + feval("saved-program-state >sps.entry !"); + PUSH(size); + feval("saved-program-state >sps.file-size !"); + feval("aout saved-program-state >sps.file-type !"); + + feval("-1 state-valid !"); + printf("Jumping to entry point...\n");
{
Modified: trunk/openbios-devel/arch/sparc64/elfload.c ============================================================================== --- trunk/openbios-devel/arch/sparc64/elfload.c Fri Mar 26 21:25:04 2010 (r707) +++ trunk/openbios-devel/arch/sparc64/elfload.c Fri Mar 26 22:17:32 2010 (r708) @@ -10,6 +10,7 @@ #include "arch/common/elf_boot.h" #include "libopenbios/sys_info.h" #include "libopenbios/ipchecksum.h" +#include "libopenbios/bindings.h" #include "libc/diskio.h" #include "boot.h" #define printf printk @@ -135,13 +136,12 @@
static int load_segments(Elf_phdr *phdr, int phnum, unsigned long checksum_offset, - unsigned int offset) + unsigned int offset, unsigned long *bytes) { - unsigned long bytes; //unsigned int start_time, time; int i;
- bytes = 0; + *bytes = 0; // start_time = currticks(); for (i = 0; i < phnum; i++) { if (phdr[i].p_type != PT_LOAD) @@ -155,7 +155,7 @@ printf("Can't read program segment %d\n", i); return 0; } - bytes += phdr[i].p_filesz; + *bytes += phdr[i].p_filesz; debug("clearing... "); memset(phys_to_virt(addr_fixup(phdr[i].p_paddr) + phdr[i].p_filesz), 0, phdr[i].p_memsz - phdr[i].p_filesz); @@ -171,7 +171,7 @@ // time = currticks() - start_time; //debug("Loaded %lu bytes in %ums (%luKB/s)\n", bytes, time, // time? bytes/time : 0); - debug("Loaded %lu bytes \n", bytes); + debug("Loaded %lu bytes \n", *bytes);
return 1; } @@ -307,7 +307,7 @@ Elf_ehdr ehdr; Elf_phdr *phdr = NULL; unsigned long phdr_size; - unsigned long checksum_offset; + unsigned long checksum_offset, file_size; unsigned short checksum = 0; Elf_Bhdr *boot_notes = NULL; int retval = -1; @@ -316,6 +316,9 @@
image_name = image_version = NULL;
+ /* Mark the saved-program-state as invalid */ + feval("0 state-valid !"); + fd = open_io(filename); if (!fd) goto out; @@ -367,7 +370,7 @@ printf(" version %s", image_version); printf("...\n");
- if (!load_segments(phdr, ehdr.e_phnum, checksum_offset, offset)) + if (!load_segments(phdr, ehdr.e_phnum, checksum_offset, offset, &file_size)) goto out;
if (checksum_offset) { @@ -380,6 +383,16 @@ //debug("current time: %lu\n", currticks());
debug("entry point is %#llx\n", addr_fixup(ehdr.e_entry)); + + // Initialise saved-program-state + PUSH(addr_fixup(ehdr.e_entry)); + feval("saved-program-state >sps.entry !"); + PUSH(file_size); + feval("saved-program-state >sps.file-size !"); + feval("elf-boot saved-program-state >sps.file-type !"); + + feval("-1 state-valid !"); + printf("Jumping to entry point...\n");
#if 0
Modified: trunk/openbios-devel/arch/sparc64/fcodeload.c ============================================================================== --- trunk/openbios-devel/arch/sparc64/fcodeload.c Fri Mar 26 21:25:04 2010 (r707) +++ trunk/openbios-devel/arch/sparc64/fcodeload.c Fri Mar 26 22:17:32 2010 (r708) @@ -20,6 +20,9 @@ unsigned long start, size; unsigned int offset;
+ /* Mark the saved-program-state as invalid */ + feval("0 state-valid !"); + fd = open_io(filename); if (!fd) goto out; @@ -62,8 +65,15 @@ }
debug("Loaded %lu bytes\n", size); - debug("entry point is %#lx\n", start); + + // Initialise saved-program-state + PUSH(start); + feval("saved-program-state >sps.entry !"); + PUSH(size); + feval("saved-program-state >sps.file-size !"); + feval("fcode saved-program-state >sps.file-type !"); + printf("Evaluating FCode...\n");
PUSH(start);
Modified: trunk/openbios-devel/arch/sparc64/forthload.c ============================================================================== --- trunk/openbios-devel/arch/sparc64/forthload.c Fri Mar 26 21:25:04 2010 (r707) +++ trunk/openbios-devel/arch/sparc64/forthload.c Fri Mar 26 22:17:32 2010 (r708) @@ -24,6 +24,9 @@ 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; @@ -56,6 +59,15 @@
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 !"); + PUSH ( (ucell)forthtext ); PUSH ( (ucell)forthsize ); fword("eval2");
Modified: trunk/openbios-devel/arch/x86/elfload.c ============================================================================== --- trunk/openbios-devel/arch/x86/elfload.c Fri Mar 26 21:25:04 2010 (r707) +++ trunk/openbios-devel/arch/x86/elfload.c Fri Mar 26 22:17:32 2010 (r708) @@ -10,6 +10,7 @@ #include "arch/common/elf_boot.h" #include "libopenbios/sys_info.h" #include "libopenbios/ipchecksum.h" +#include "libopenbios/bindings.h" #include "libc/diskio.h" #include "boot.h"
@@ -137,13 +138,12 @@ }
static int load_segments(Elf_phdr *phdr, int phnum, - unsigned long checksum_offset) + unsigned long checksum_offset, unsigned long *bytes) { - unsigned long bytes; //unsigned int start_time, time; int i;
- bytes = 0; + *bytes = 0; // start_time = currticks(); for (i = 0; i < phnum; i++) { if (phdr[i].p_type != PT_LOAD) @@ -157,7 +157,7 @@ printk("Can't read program segment %d\n", i); return 0; } - bytes += phdr[i].p_filesz; + *bytes += phdr[i].p_filesz; debug("clearing... "); memset(phys_to_virt(phdr[i].p_paddr + phdr[i].p_filesz), 0, phdr[i].p_memsz - phdr[i].p_filesz); @@ -173,7 +173,7 @@ // time = currticks() - start_time; //debug("Loaded %lu bytes in %ums (%luKB/s)\n", bytes, time, // time? bytes/time : 0); - debug("Loaded %lu bytes \n", bytes); + debug("Loaded %lu bytes \n", *bytes);
return 1; } @@ -309,7 +309,7 @@ Elf_ehdr ehdr; Elf_phdr *phdr = NULL; unsigned long phdr_size; - unsigned long checksum_offset; + unsigned long checksum_offset, file_size; unsigned short checksum = 0; Elf_Bhdr *boot_notes = NULL; int retval = -1; @@ -317,6 +317,9 @@
image_name = image_version = NULL;
+ /* Mark the saved-program-state as invalid */ + feval("0 state-valid !"); + fd = open_io(filename); if (!fd) goto out; @@ -361,7 +364,7 @@ printk(" version %s", image_version); printk("...\n");
- if (!load_segments(phdr, ehdr.e_phnum, checksum_offset)) + if (!load_segments(phdr, ehdr.e_phnum, checksum_offset, &file_size)) goto out;
if (checksum_offset) { @@ -374,6 +377,16 @@ //debug("current time: %lu\n", currticks());
debug("entry point is %#x\n", ehdr.e_entry); + + // Initialise saved-program-state + PUSH(ehdr.e_entry); + feval("saved-program-state >sps.entry !"); + PUSH(file_size); + feval("saved-program-state >sps.file-size !"); + feval("elf-boot saved-program-state >sps.file-type !"); + + feval("-1 state-valid !"); + printk("Jumping to entry point...\n"); image_retval = start_elf(ehdr.e_entry & ADDRMASK, virt_to_phys(boot_notes));
Modified: trunk/openbios-devel/arch/x86/forthload.c ============================================================================== --- trunk/openbios-devel/arch/x86/forthload.c Fri Mar 26 21:25:04 2010 (r707) +++ trunk/openbios-devel/arch/x86/forthload.c Fri Mar 26 22:17:32 2010 (r708) @@ -24,6 +24,9 @@ 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; @@ -54,6 +57,17 @@ 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 !"); + PUSH ( (ucell)forthtext ); PUSH ( (ucell)forthsize ); fword("eval2");
Modified: trunk/openbios-devel/forth/debugging/client.fs ============================================================================== --- trunk/openbios-devel/forth/debugging/client.fs Fri Mar 26 21:25:04 2010 (r707) +++ trunk/openbios-devel/forth/debugging/client.fs Fri Mar 26 22:17:32 2010 (r708) @@ -16,6 +16,12 @@
\ 7.6.2 Program download and execute +struct ( saved-program-state ) + /n field >sps.entry + /n field >sps.file-size + /n field >sps.file-type +constant saved-program-state.size +create saved-program-state saved-program-state.size allot
variable state-valid 0 state-valid ! @@ -28,10 +34,14 @@
variable file-type
-0 constant elf -1 constant bootinfo -2 constant xcoff -3 constant pe +0 constant elf-boot +1 constant elf +2 constant bootinfo +3 constant xcoff +4 constant pe +5 constant aout +10 constant fcode +11 constant forth
\ Array indexes and values for e_type