mirror of
https://gitlab.com/qemu-project/openbios.git
synced 2024-02-13 08:34:06 +08:00
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> git-svn-id: svn://coreboot.org/openbios/trunk/openbios-devel@708 f158a5a8-5612-0410-a976-696ce0be7e32
This commit is contained in:
committed by
Mark Cave-Ayland
parent
d66540542d
commit
8a6d445d38
@@ -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 @@ out:
|
||||
}
|
||||
|
||||
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 @@ static int load_segments(Elf_phdr *phdr, int phnum,
|
||||
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 @@ static int load_segments(Elf_phdr *phdr, int phnum,
|
||||
// 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 @@ int elf_load(struct sys_info *info, const char *filename, const char *cmdline)
|
||||
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 @@ int elf_load(struct sys_info *info, const char *filename, const char *cmdline)
|
||||
|
||||
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 @@ int elf_load(struct sys_info *info, const char *filename, const char *cmdline)
|
||||
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 @@ int elf_load(struct sys_info *info, const char *filename, const char *cmdline)
|
||||
//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));
|
||||
|
||||
|
||||
@@ -24,6 +24,9 @@ int forth_load(struct sys_info *info, const char *filename, const char *cmdline)
|
||||
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 @@ int forth_load(struct sys_info *info, const char *filename, const char *cmdline)
|
||||
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");
|
||||
|
||||
Reference in New Issue
Block a user