Use PHDR's p_paddr for loading PPC ELFs.

Use the entry point, from now on this is a realmode vector.
This commit is contained in:
dhewg 2009-04-07 23:23:58 +02:00 committed by bushing
parent 65ef5abb3d
commit ec03192492
4 changed files with 19 additions and 24 deletions

2
elf.h
View File

@ -10,7 +10,7 @@ typedef struct {
u16 e_type;
u16 e_machine;
u32 e_version;
void *e_entry;
u32 e_entry;
u32 e_phoff;
u32 e_shoff;
u32 e_flags;

View File

@ -26,31 +26,27 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#include "start.h"
#include "gecko.h"
const u32 stub_default[0x10] = {
0x3c600000,
0x60633400,
0x7c7a03a6,
0x38600000,
0x7c7b03a6,
0x4c000064,
0,
};
void powerpc_upload_stub(const u32 *stub, u32 len)
void powerpc_upload_stub(u32 entry)
{
u32 i;
set32(HW_EXICTRL, EXICTRL_ENABLE_EXI);
if(stub == NULL || len == 0)
{
stub = stub_default;
len = sizeof(stub_default) / sizeof(u32);
}
// lis r3, entry@h
write32(EXI_BOOT_BASE + 4 * 0, 0x3c600000 | entry >> 16);
// ori r3, r3, entry@l
write32(EXI_BOOT_BASE + 4 * 1, 0x60630000 | (entry & 0xffff));
// mtsrr0 r3
write32(EXI_BOOT_BASE + 4 * 2, 0x7c7a03a6);
// li r3, 0
write32(EXI_BOOT_BASE + 4 * 3, 0x38600000);
// mtsrr1 r3
write32(EXI_BOOT_BASE + 4 * 4, 0x7c7b03a6);
// rfi
write32(EXI_BOOT_BASE + 4 * 5, 0x4c000064);
for(i = 0; i < len; i++)
write32(EXI_BOOT_BASE + 4*i, stub[i]);
for (i = 6; i < 0x10; ++i)
write32(EXI_BOOT_BASE + 4 * i, 0);
set32(HW_DIFLAGS, DIFLAGS_BOOT_CODE);

View File

@ -2,7 +2,7 @@
#define __POWERPC_H__ 1
void ppc_boot_code();
void powerpc_upload_stub(const u32 *stub, u32 len);
void powerpc_upload_stub(u32 entry);
void powerpc_hang();
void powerpc_reset();

View File

@ -67,7 +67,6 @@ int powerpc_load_file(const char *path)
gecko_printf("Skipping PHDR of type %d\n",phdr->p_type);
} else {
void *dst = phdr->p_paddr;
dst = (void*)((u32)dst & ~0xC0000000);
gecko_printf("LOAD 0x%x -> %p [0x%x]\n", phdr->p_offset, phdr->p_paddr, phdr->p_filesz);
fres = f_lseek(&fd, phdr->p_offset);
@ -85,7 +84,7 @@ int powerpc_load_file(const char *path)
dc_flushall();
gecko_printf("ELF load done, booting PPC...\n");
powerpc_upload_stub(NULL,0);
powerpc_upload_stub(elfhdr.e_entry);
powerpc_reset();
gecko_printf("PPC booted!\n");