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
@@ -311,6 +311,9 @@ int elf_load(struct sys_info *info, const char *filename, const char *cmdline)
|
||||
|
||||
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 @@ int elf_load(struct sys_info *info, const char *filename, const char *cmdline)
|
||||
|
||||
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
|
||||
|
||||
@@ -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 @@ int aout_load(struct sys_info *info, const char *filename, const void *romvec)
|
||||
|
||||
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 @@ int aout_load(struct sys_info *info, const char *filename, const void *romvec)
|
||||
}
|
||||
|
||||
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
|
||||
|
||||
@@ -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 @@ out:
|
||||
|
||||
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 @@ static int load_segments(Elf_phdr *phdr, int phnum,
|
||||
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 @@ 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;
|
||||
}
|
||||
@@ -308,7 +308,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;
|
||||
@@ -368,7 +371,7 @@ int elf_load(struct sys_info *info, const char *filename, const char *cmdline,
|
||||
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 @@ 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", 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
|
||||
|
||||
@@ -24,6 +24,9 @@ int forth_load(const char *filename)
|
||||
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(const char *filename)
|
||||
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");
|
||||
|
||||
@@ -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 @@ int aout_load(struct sys_info *info, const char *filename)
|
||||
|
||||
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 @@ int aout_load(struct sys_info *info, const char *filename)
|
||||
}
|
||||
|
||||
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");
|
||||
|
||||
{
|
||||
|
||||
@@ -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 @@ out:
|
||||
|
||||
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 @@ static int load_segments(Elf_phdr *phdr, int phnum,
|
||||
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 @@ 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;
|
||||
}
|
||||
@@ -307,7 +307,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;
|
||||
@@ -316,6 +316,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;
|
||||
@@ -367,7 +370,7 @@ int elf_load(struct sys_info *info, const char *filename, const char *cmdline)
|
||||
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 @@ int elf_load(struct sys_info *info, const char *filename, const char *cmdline)
|
||||
//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
|
||||
|
||||
@@ -20,6 +20,9 @@ int fcode_load(const char *filename)
|
||||
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 @@ int fcode_load(const char *filename)
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
@@ -24,6 +24,9 @@ int forth_load(const char *filename)
|
||||
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 @@ int forth_load(const char *filename)
|
||||
|
||||
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");
|
||||
|
||||
@@ -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");
|
||||
|
||||
@@ -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-size
|
||||
|
||||
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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user