mirror of
https://github.com/fail0verflow/switch-coreboot.git
synced 2025-05-04 01:39:18 -04:00
The newelfboot code is correctly loading filo.elf. It is running from
FLASH. It is far simpler than before. Signed-off-by: Ronald G. Minnich <rminnich@gmail.com> Acked-by: Ronald G. Minnich <rminnich@gmail.com> Acked-by: Stefan Reinauer <stepan@coresystems.de> git-svn-id: svn://coreboot.org/repository/LinuxBIOSv3@109 f3766cd6-281f-0410-b1cd-43a5c92072e9
This commit is contained in:
parent
327a4432fe
commit
98d3059a2d
2 changed files with 15 additions and 76 deletions
|
@ -64,17 +64,17 @@ void stage1_main(u32 bist)
|
||||||
struct mem_file archive, result;
|
struct mem_file archive, result;
|
||||||
int elfboot_mem(struct lb_memory *mem, void *where, int size);
|
int elfboot_mem(struct lb_memory *mem, void *where, int size);
|
||||||
|
|
||||||
/* HACK -- fake memory table for now */
|
/* we can't statically init this hack. */
|
||||||
static struct lb_memory mem = {
|
unsigned char *faker[64];
|
||||||
.tag = LB_TAG_MEMORY,
|
struct lb_memory *mem = (struct lb_memory*) &faker;
|
||||||
.size = 1,
|
|
||||||
.map = { {
|
mem->tag = LB_TAG_MEMORY;
|
||||||
.start = { .lo = 0, .hi = 0 },
|
mem->size = 28;
|
||||||
.size = { .lo = (32*1024*1024), .hi = 0 },
|
mem->map[0].start.lo = mem->map[0].start.hi = 0;
|
||||||
.type = LB_MEM_RAM
|
mem->map[0].size.lo = (32*1024*1024);
|
||||||
} }
|
mem->map[0].size.hi = 0;
|
||||||
|
mem->map[0].type = LB_MEM_RAM;
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
post_code(0x02);
|
post_code(0x02);
|
||||||
|
|
||||||
|
@ -230,7 +230,7 @@ printk(BIOS_INFO, "Start search at 0x%x, size %d\n", archive.start, archive.len)
|
||||||
die("cachemain finding payload");
|
die("cachemain finding payload");
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = elfboot_mem(&mem, result.start, result.len);
|
ret = elfboot_mem(mem, result.start, result.len);
|
||||||
|
|
||||||
printk(BIOS_INFO, "elfboot_mem returns %d\n", ret);
|
printk(BIOS_INFO, "elfboot_mem returns %d\n", ret);
|
||||||
|
|
||||||
|
|
|
@ -87,8 +87,10 @@ static int load_elf_segments(struct lb_memory *mem,Elf_phdr *phdr, int headers)
|
||||||
* then copy out the data, which may be a subset of the total area.
|
* then copy out the data, which may be a subset of the total area.
|
||||||
* the cache, after all, is your friend.
|
* the cache, after all, is your friend.
|
||||||
*/
|
*/
|
||||||
|
printk(BIOS_INFO, "set %p to 0 for %d bytes\n", (unsigned char *)phdr[i].p_paddr, 0, size);
|
||||||
memset((unsigned char *)phdr[i].p_paddr, 0, size);
|
memset((unsigned char *)phdr[i].p_paddr, 0, size);
|
||||||
/* ok, copy it out */
|
/* ok, copy it out */
|
||||||
|
printk(BIOS_INFO, "Copy to %p from %p for %d bytes\n", (unsigned char *)phdr[i].p_paddr, &header[phdr[i].p_offset], size);
|
||||||
memcpy((unsigned char *)phdr[i].p_paddr, &header[phdr[i].p_offset], size);
|
memcpy((unsigned char *)phdr[i].p_paddr, &header[phdr[i].p_offset], size);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -136,68 +138,6 @@ int elfload(struct lb_memory *mem,
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef NOT
|
|
||||||
int elfboot(struct lb_memory *mem)
|
|
||||||
{
|
|
||||||
Elf_ehdr *ehdr;
|
|
||||||
unsigned char header[ELF_HEAD_SIZE];
|
|
||||||
int header_offset;
|
|
||||||
int i, result;
|
|
||||||
|
|
||||||
result = 0;
|
|
||||||
printk(BIOS_INFO, "\n");
|
|
||||||
printk(BIOS_INFO, "Elfboot\n");
|
|
||||||
post_code(0xf8);
|
|
||||||
|
|
||||||
/* Read in the initial ELF_HEAD_SIZE bytes */
|
|
||||||
if (stream_read(header, ELF_HEAD_SIZE) != ELF_HEAD_SIZE) {
|
|
||||||
printk(BIOS_ERR, "Header read failed...\n");
|
|
||||||
goto out;
|
|
||||||
}
|
|
||||||
/* Scan for an elf header */
|
|
||||||
header_offset = -1;
|
|
||||||
for(i = 0; i < ELF_HEAD_SIZE - (sizeof(Elf_ehdr) + sizeof(Elf_phdr)); i+=16) {
|
|
||||||
ehdr = (Elf_ehdr *)(&header[i]);
|
|
||||||
if (memcmp(ehdr->e_ident, ELFMAG, 4) != 0) {
|
|
||||||
printk(BIOS_SPEW, "NO header at %d\n", i);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
printk(BIOS_DEBUG, "Found ELF candidate at offset %d\n", i);
|
|
||||||
/* Sanity check the elf header */
|
|
||||||
if ((ehdr->e_type == ET_EXEC) &&
|
|
||||||
elf_check_arch(ehdr) &&
|
|
||||||
(ehdr->e_ident[EI_VERSION] == EV_CURRENT) &&
|
|
||||||
(ehdr->e_version == EV_CURRENT) &&
|
|
||||||
(ehdr->e_ehsize == sizeof(Elf_ehdr)) &&
|
|
||||||
(ehdr->e_phentsize = sizeof(Elf_phdr)) &&
|
|
||||||
(ehdr->e_phoff < (ELF_HEAD_SIZE - i)) &&
|
|
||||||
((ehdr->e_phoff + (ehdr->e_phentsize * ehdr->e_phnum)) <=
|
|
||||||
(ELF_HEAD_SIZE - i))) {
|
|
||||||
header_offset = i;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
ehdr = 0;
|
|
||||||
}
|
|
||||||
printk(BIOS_SPEW, "header_offset is %d\n", header_offset);
|
|
||||||
if (header_offset == -1) {
|
|
||||||
goto out;
|
|
||||||
}
|
|
||||||
|
|
||||||
printk(BIOS_SPEW, "Try to load at offset 0x%x\n", header_offset);
|
|
||||||
result = elfload(mem,
|
|
||||||
header + header_offset , ELF_HEAD_SIZE - header_offset);
|
|
||||||
out:
|
|
||||||
if (!result) {
|
|
||||||
/* Shutdown the stream device */
|
|
||||||
|
|
||||||
printk(BIOS_ERR, "Cannot Load ELF Image\n");
|
|
||||||
|
|
||||||
post_code(0xff);
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
int elfboot_mem(struct lb_memory *mem, void *where, int size)
|
int elfboot_mem(struct lb_memory *mem, void *where, int size)
|
||||||
{
|
{
|
||||||
Elf_ehdr *ehdr;
|
Elf_ehdr *ehdr;
|
||||||
|
@ -239,9 +179,8 @@ int elfboot_mem(struct lb_memory *mem, void *where, int size)
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
printk(BIOS_SPEW, "Try to load at offset 0x%x\n", header_offset);
|
printk(BIOS_SPEW, "Try to load at offset 0x%x %d phdr\n", header_offset, ehdr->e_phnum);
|
||||||
result = elfload(mem,
|
result = elfload(mem, header + header_offset , ehdr->e_phnum);
|
||||||
header + header_offset , ELF_HEAD_SIZE - header_offset);
|
|
||||||
out:
|
out:
|
||||||
if (!result) {
|
if (!result) {
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue