Loader fix

This commit is contained in:
Nekotekina 2015-02-19 16:47:53 +03:00
parent 2d1d996c50
commit fed1418c0e
4 changed files with 76 additions and 19 deletions

View File

@ -1,7 +1,9 @@
#include "stdafx.h" #include "stdafx.h"
#include "Utilities/Log.h"
#include "Emu/Memory/Memory.h" #include "Emu/Memory/Memory.h"
#include "Emu/System.h" #include "Emu/System.h"
#include "Emu/SysCalls/Modules.h" #include "Emu/SysCalls/Modules.h"
#include "Emu/SysCalls/SysCalls.h"
#include "Emu/SysCalls/Static.h" #include "Emu/SysCalls/Static.h"
#include "Emu/SysCalls/CB_FUNC.h" #include "Emu/SysCalls/CB_FUNC.h"
#include "Crypto/sha1.h" #include "Crypto/sha1.h"
@ -84,7 +86,8 @@ void execute_ps3_func_by_index(PPUThread& CPU, u32 index)
} }
else else
{ {
throw "Unimplemented function"; LOG_ERROR(HLE, "Unimplemented function %s", SysCalls::GetHLEFuncName(func->id));
CPU.GPR[3] = 0;
} }
CPU.m_last_syscall = old_last_syscall; CPU.m_last_syscall = old_last_syscall;

View File

@ -829,15 +829,6 @@ s32 cellSyncQueueClear(vm::ptr<CellSyncQueue> queue)
// LFQueue functions // LFQueue functions
void syncLFQueueDump(vm::ptr<CellSyncLFQueue> queue)
{
cellSync.Notice("CellSyncLFQueue dump: addr = 0x%x", queue.addr());
for (u32 i = 0; i < sizeof(CellSyncLFQueue) / 16; i++)
{
cellSync.Notice("*** 0x%.16llx 0x%.16llx", vm::read64(queue.addr() + i * 16), vm::read64(queue.addr() + i * 16 + 8));
}
}
void syncLFQueueInit(vm::ptr<CellSyncLFQueue> queue, vm::ptr<u8> buffer, u32 size, u32 depth, CellSyncQueueDirection direction, vm::ptr<void> eaSignal) void syncLFQueueInit(vm::ptr<CellSyncLFQueue> queue, vm::ptr<u8> buffer, u32 size, u32 depth, CellSyncQueueDirection direction, vm::ptr<void> eaSignal)
{ {
queue->m_size = size; queue->m_size = size;

View File

@ -135,16 +135,18 @@ struct CellSyncLFQueue
be_t<u16> m_h6; be_t<u16> m_h6;
}; };
union union // 0x0
{ {
atomic_t<pop1_t> pop1; // 0x0 atomic_t<pop1_t> pop1;
atomic_t<pop3_t> pop3; atomic_t<pop3_t> pop3;
}; };
union
union // 0x8
{ {
atomic_t<push1_t> push1; // 0x8 atomic_t<push1_t> push1;
atomic_t<push3_t> push3; atomic_t<push3_t> push3;
}; };
be_t<u32> m_size; // 0x10 be_t<u32> m_size; // 0x10
be_t<u32> m_depth; // 0x14 be_t<u32> m_depth; // 0x14
vm::bptr<u8, 1, u64> m_buffer; // 0x18 vm::bptr<u8, 1, u64> m_buffer; // 0x18
@ -159,6 +161,23 @@ struct CellSyncLFQueue
vm::bptr<void, 1, u64> m_eaSignal; // 0x70 vm::bptr<void, 1, u64> m_eaSignal; // 0x70
be_t<u32> m_v2; // 0x78 be_t<u32> m_v2; // 0x78
be_t<u32> m_eq_id; // 0x7C be_t<u32> m_eq_id; // 0x7C
std::string dump()
{
std::string res = "CellSyncLFQueue dump:";
auto data = (be_t<u64>*)this;
for (u32 i = 0; i < sizeof(CellSyncLFQueue) / sizeof(u64); i += 2)
{
res += "\n*** 0x";
res += fmt::to_hex(data[i + 0], 16);
res += " 0x";
res += fmt::to_hex(data[i + 1], 16);
}
return res;
}
}; };
static_assert(sizeof(CellSyncLFQueue) == 128, "CellSyncLFQueue: wrong size"); static_assert(sizeof(CellSyncLFQueue) == 128, "CellSyncLFQueue: wrong size");

View File

@ -303,6 +303,7 @@ namespace loader
std::vector<u32> start_funcs; std::vector<u32> start_funcs;
std::vector<u32> stop_funcs; std::vector<u32> stop_funcs;
std::vector<u32> exit_funcs;
//load modules //load modules
vfsDir lle_dir("/dev_flash/sys/external"); vfsDir lle_dir("/dev_flash/sys/external");
@ -341,12 +342,48 @@ namespace loader
{ {
for (auto &e : m.second.exports) for (auto &e : m.second.exports)
{ {
auto code = vm::ptr<const u32>::make(vm::check_addr(e.second, 8) ? vm::read32(e.second) : 0);
bool is_empty = !code || (code[0] == 0x38600000 && code[1] == BLR());
if (!code)
{
LOG_ERROR(LOADER, "bad OPD of special function 0x%08x in '%s' library (0x%x)", e.first, info.name.c_str(), code);
}
switch (e.first) switch (e.first)
{ {
case 0xbc9a0086: start_funcs.push_back(e.second); break; case 0xbc9a0086:
case 0xab779874: stop_funcs.push_back(e.second); break; {
if (!is_empty)
{
LOG_ERROR(LOADER, "start func found in '%s' library (0x%x)", info.name.c_str(), code);
start_funcs.push_back(e.second);
}
break;
}
default: LOG_ERROR(LOADER, "unknown special func 0x%08x in '%s' library", e.first, info.name.c_str()); break; case 0xab779874:
{
if (!is_empty)
{
LOG_ERROR(LOADER, "stop func found in '%s' library (0x%x)", info.name.c_str(), code);
stop_funcs.push_back(e.second);
}
break;
}
case 0x3ab9a95e:
{
if (!is_empty)
{
LOG_ERROR(LOADER, "exit func found in '%s' library (0x%x)", info.name.c_str(), code);
exit_funcs.push_back(e.second);
}
break;
}
default: LOG_ERROR(LOADER, "unknown special func 0x%08x in '%s' library (0x%x)", e.first, info.name.c_str(), code); break;
} }
} }
@ -385,8 +422,15 @@ namespace loader
LOG_NOTICE(LOADER, "Imported function '%s' (0x%x)", SysCalls::GetHLEFuncName(nid), addr); LOG_NOTICE(LOADER, "Imported function '%s' (0x%x)", SysCalls::GetHLEFuncName(nid), addr);
} }
vm::write32(addr + 0, HACK(index)); if (!vm::check_addr(addr, 8))
vm::write32(addr + 4, BLR()); {
LOG_ERROR(LOADER, "Failed to inject code for function '%s' (0x%x)", SysCalls::GetHLEFuncName(nid), addr);
}
else
{
vm::write32(addr + 0, HACK(index));
vm::write32(addr + 4, BLR());
}
} }
} }
} }