ARMv7: loader fixed

This commit is contained in:
Nekotekina 2015-02-19 00:23:31 +03:00
parent 1003c42310
commit d177b1adea
6 changed files with 85 additions and 65 deletions

View file

@ -134,7 +134,7 @@ namespace loader
auto armv7_thr_stop_data = vm::psv::ptr<u32>::make(Memory.PSV.RAM.AllocAlign(3 * 4));
armv7_thr_stop_data[0] = 0xf870; // HACK instruction (Thumb)
armv7_thr_stop_data[1] = 0x0001; // index 1
armv7_thr_stop_data[1] = SFI_HLE_RETURN;
Emu.SetCPUThreadStop(armv7_thr_stop_data.addr());
u32 entry = 0; // actual entry point (ELFs entry point is ignored)
@ -228,28 +228,34 @@ namespace loader
const u32 nid = fnid[j];
const u32 addr = fstub[j];
if (auto func = get_psv_func_by_nid(nid))
u32 index;
if (auto func = get_psv_func_by_nid(nid, &index))
{
if (func->module)
{
func->module->Notice("Imported function %s (nid=0x%08x, addr=0x%x)", func->name, nid, addr);
LOG_NOTICE(LOADER, "Imported function '%s' in module '%s' (nid=0x%08x, addr=0x%x)", func->name, func->module->GetName(), nid, addr);
}
else
{
LOG_NOTICE(LOADER, "Imported function %s (nid=0x%08x, addr=0x%x)", func->name, nid, addr);
LOG_NOTICE(LOADER, "Imported function '%s' (nid=0x%08x, addr=0x%x)", func->name, nid, addr);
}
const u32 code = get_psv_func_index(func);
vm::psv::write32(addr + 0, 0xe0700090 | (code & 0xfff0) << 4 | (code & 0xf)); // HACK instruction (ARM)
}
else
{
LOG_ERROR(LOADER, "Unknown function 0x%08x (addr=0x%x)", nid, addr);
vm::psv::write32(addr + 0, 0xe0700090); // HACK instruction (ARM), unimplemented stub (code 0)
vm::psv::write32(addr + 4, nid); // nid
psv_func unimplemented;
unimplemented.nid = nid;
unimplemented.module = nullptr;
unimplemented.name = "UNKNOWN"; // TODO: set correct name if possible
unimplemented.func = nullptr;
index = add_psv_func(unimplemented);
}
vm::psv::write32(addr + 0, 0xe0700090 | (index & 0xfff0) << 4 | (index & 0xf)); // HACK instruction (ARM)
code_end = std::min<u32>(addr, code_end);
}
}