mirror of
https://gitlab.com/qemu-project/openbios.git
synced 2024-02-13 08:34:06 +08:00
Finish the use of saved-program-state within the loaders. This involves 2 changes: firstly ensure that the saved-program-state
is being set correctly in all of the loaders, and secondly we change the bootinfo loader so that the bootscript is executed as part of init-program and not go. This seems to reflect the idea of execute-buffer in OpenBOOT that any Forth code is executed directly during init-program, rather than being deferred to go. Note: the latter change is fairly simple, but I have been unable to test it myself other than verifying it compiles. Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@siriusit.co.uk> git-svn-id: svn://coreboot.org/openbios/trunk/openbios-devel@724 f158a5a8-5612-0410-a976-696ce0be7e32
This commit is contained in:
committed by
Mark Cave-Ayland
parent
de891e0244
commit
075e485628
@@ -126,7 +126,7 @@ bootinfo_init_program(void)
|
||||
char *base;
|
||||
int proplen;
|
||||
phandle_t chosen;
|
||||
int tag, taglen, script, scriptlen, entity, chrp;
|
||||
int tag, taglen, script, scriptlen, scriptvalid, entity, chrp;
|
||||
char tagbuf[128], c;
|
||||
char *device, *filename, *directory;
|
||||
int partition;
|
||||
@@ -135,7 +135,7 @@ bootinfo_init_program(void)
|
||||
char *tmp;
|
||||
char bootpath[1024];
|
||||
|
||||
feval("0 state-valid !");
|
||||
/* Parse the boot script */
|
||||
|
||||
chosen = find_dev("/chosen");
|
||||
tmp = get_property(chosen, "bootpath", &proplen);
|
||||
@@ -169,6 +169,7 @@ bootinfo_init_program(void)
|
||||
tag = 0;
|
||||
taglen = 0;
|
||||
script = 0;
|
||||
scriptvalid = 0;
|
||||
scriptlen = 0;
|
||||
entity = 0;
|
||||
current = 0;
|
||||
@@ -197,7 +198,7 @@ bootinfo_init_program(void)
|
||||
DPRINTF("got bootscript %s\n",
|
||||
bootscript);
|
||||
|
||||
feval("-1 state-valid !");
|
||||
scriptvalid = -1;
|
||||
|
||||
break;
|
||||
} else if (strncasecmp(tagbuf, "/chrp-boot", 10) == 0)
|
||||
@@ -246,7 +247,10 @@ bootinfo_init_program(void)
|
||||
bootscript[scriptlen++] = c;
|
||||
}
|
||||
}
|
||||
/* FIXME: should initialize saved-program-state. */
|
||||
push_str(bootscript);
|
||||
feval("bootinfo-size ! bootinfo-entry !");
|
||||
|
||||
/* If the payload is bootinfo then we execute it immediately */
|
||||
if (scriptvalid)
|
||||
feval(bootscript);
|
||||
else
|
||||
DPRINTF("Unable to parse bootinfo bootscript\n");
|
||||
}
|
||||
|
||||
@@ -473,7 +473,7 @@ elf_init_program(void)
|
||||
int i;
|
||||
Elf_ehdr *ehdr;
|
||||
Elf_phdr *phdr;
|
||||
size_t size;
|
||||
size_t size, total_size = 0;
|
||||
char *addr;
|
||||
cell tmp;
|
||||
|
||||
@@ -483,6 +483,12 @@ elf_init_program(void)
|
||||
base = (char*)POP();
|
||||
|
||||
ehdr = (Elf_ehdr *)base;
|
||||
|
||||
if (!is_elf(ehdr)) {
|
||||
debug("Not a valid ELF memory image\n");
|
||||
return;
|
||||
}
|
||||
|
||||
phdr = (Elf_phdr *)(base + ehdr->e_phoff);
|
||||
|
||||
for (i = 0; i < ehdr->e_phnum; i++) {
|
||||
@@ -508,12 +514,20 @@ elf_init_program(void)
|
||||
addr = (char *)tmp;
|
||||
|
||||
memcpy(addr, base + phdr[i].p_offset, size);
|
||||
|
||||
total_size += size;
|
||||
|
||||
#ifdef CONFIG_PPC
|
||||
flush_icache_range( addr, addr + size );
|
||||
#endif
|
||||
}
|
||||
/* FIXME: should initialize saved-program-state. */
|
||||
|
||||
// Initialise saved-program-state
|
||||
PUSH(ehdr->e_entry);
|
||||
feval("elf-entry !");
|
||||
feval("saved-program-state >sps.entry !");
|
||||
PUSH(total_size);
|
||||
feval("saved-program-state >sps.file-size !");
|
||||
feval("elf saved-program-state >sps.file-type !");
|
||||
|
||||
feval("-1 state-valid !");
|
||||
}
|
||||
|
||||
@@ -95,6 +95,12 @@ fcode_init_program(void)
|
||||
|
||||
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");
|
||||
|
||||
@@ -58,6 +58,7 @@ xcoff_init_program(void)
|
||||
COFF_aouthdr_t *ahdr;
|
||||
COFF_scnhdr_t *shdr;
|
||||
uint32_t offset;
|
||||
size_t total_size = 0;
|
||||
int i;
|
||||
|
||||
feval("0 state-valid !");
|
||||
@@ -112,6 +113,7 @@ xcoff_init_program(void)
|
||||
|
||||
memcpy((char*)shdr->s_vaddr, base + shdr->s_scnptr,
|
||||
shdr->s_size);
|
||||
total_size += shdr->s_size;
|
||||
#ifdef CONFIG_PPC
|
||||
flush_icache_range((char*)shdr->s_vaddr,
|
||||
(char*)(shdr->s_vaddr + shdr->s_size));
|
||||
@@ -120,22 +122,26 @@ xcoff_init_program(void)
|
||||
|
||||
memcpy((char*)shdr->s_vaddr, base + shdr->s_scnptr,
|
||||
shdr->s_size);
|
||||
total_size += shdr->s_size;
|
||||
|
||||
} else if (strcmp(shdr->s_name, ".bss") == 0) {
|
||||
|
||||
memset((void *)shdr->s_vaddr, 0, shdr->s_size);
|
||||
|
||||
total_size += shdr->s_size;
|
||||
} else {
|
||||
DPRINTF(" Skip '%s' section\n", shdr->s_name);
|
||||
}
|
||||
offset += sizeof(COFF_scnhdr_t);
|
||||
}
|
||||
|
||||
/* FIXME: should initialize saved-program-state. */
|
||||
|
||||
DPRINTF("XCOFF entry point: %x\n", *(uint32_t*)ahdr->entry);
|
||||
|
||||
// Initialise saved-program-state
|
||||
PUSH(*(uint32_t*)ahdr->entry);
|
||||
feval("xcoff-entry !");
|
||||
feval("saved-program-state >sps.entry !");
|
||||
PUSH(total_size);
|
||||
feval("saved-program-state >sps.file-size !");
|
||||
feval("xcoff saved-program-state >sps.file-type !");
|
||||
|
||||
feval("-1 state-valid !");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user