diff --git a/elfldr/elfldr.c b/elfldr/elfldr.c index a2ae3f9d1..8ead8935f 100644 --- a/elfldr/elfldr.c +++ b/elfldr/elfldr.c @@ -93,12 +93,12 @@ static inline void BootError(char *filename) ExecOSD(2, argv); } -static inline void InitializeUserMemory(unsigned int start, unsigned int end) +static inline void wipeUserMem(void) { unsigned int i; - for (i = start; i < end; i += 64) { - asm( + for (i = 0x100000; i < GetMemorySize(); i += 64) { + asm volatile( "\tsq $0, 0(%0) \n" "\tsq $0, 16(%0) \n" "\tsq $0, 32(%0) \n" @@ -142,8 +142,7 @@ void RunLoaderElf(char *filename, u8 *pElf) boot_elf = (u8 *)pElf; eh = (elf_header_t *)boot_elf; if (_lw((u32)&eh->ident) != ELF_MAGIC) - while (1) - ; + asm volatile("break\n"); eph = (elf_pheader_t *)(boot_elf + eh->phoff); // calc elf size @@ -213,7 +212,7 @@ void RunLoaderElf(char *filename, u8 *pElf) } - + SifExitRpc(); FlushCache(0); FlushCache(2); @@ -243,7 +242,7 @@ int main(int argc, char *argv[]) exd.epc = 0; // clear memory. - InitializeUserMemory(0x00100000, GetMemorySize()); + wipeUserMem(); FlushCache(0); SifLoadFileInit(); @@ -257,17 +256,11 @@ int main(int argc, char *argv[]) // Final IOP reset, to fill the IOP with the default modules. while (!SifIopReset(NULL, 0)) { }; - - FlushCache(0); - FlushCache(2); - while (!SifIopSync()) { }; //END of OPL_DB tweaks - //START of OPL_DB tweaks //Sync with the SIF library on the IOP, or it may crash the IOP kernel during the next reset (Depending on the how the next program initializes the IOP). - //END of OPL_DB tweaks SifInitRpc(0); // Load modules. SifLoadFileInit(); @@ -277,6 +270,11 @@ int main(int argc, char *argv[]) SifLoadFileExit(); SifExitRpc(); + //START of OPL_DB tweaks + FlushCache(0); + FlushCache(2); + //END of OPL_DB tweaks + ExecPS2((void *)exd.epc, (void *)exd.gp, argc, argv); } else { SifExitRpc();