1
0
Fork 0

- added debug logging to syscall.cpp

- added stubbed HLE syscall functions for svc_GetResourceLimit and svc_GetResourceLimitCurrentValues
This commit is contained in:
bunnei 2014-05-06 23:34:20 -04:00
parent a3a383cb7a
commit de36d82dde
2 changed files with 173 additions and 135 deletions

View File

@ -729,6 +729,16 @@ template<int func(int, const char *, u32, void *, int, int, int)> void WrapI_ICU
RETURN(retval);
}
template<int func(void*, u32)> void WrapI_VU(){
u32 retval = func(Memory::GetPointer(PARAM(0)), PARAM(1));
RETURN(retval);
}
template<int func(void*, u32, void*, int)> void WrapI_VUVI(){
u32 retval = func(Memory::GetPointer(PARAM(0)), PARAM(1), Memory::GetPointer(PARAM(2)), PARAM(3));
RETURN(retval);
}
template<int func(void*, u32, u32, u32, u32, u32)> void WrapI_VUUUUU(){
u32 retval = func(Memory::GetPointer(PARAM(0)), PARAM(1), PARAM(2), PARAM(3), PARAM(4), PARAM(5));
RETURN(retval);

View File

@ -29,6 +29,9 @@ enum MapMemoryPermission {
Result ControlMemory(u32 operation, u32 addr0, u32 addr1, u32 size, u32 permissions) {
u32 virtual_address = 0x00000000;
DEBUG_LOG(SVC, "ControlMemory called operation=0x%08X, addr0=0x%08X, addr1=0x%08X, size=%08X, permissions=0x%08X",
operation, addr0, addr1, size, permissions);
switch (operation) {
// Map normal heap memory
@ -43,16 +46,18 @@ Result ControlMemory(u32 operation, u32 addr0, u32 addr1, u32 size, u32 permissi
// Unknown ControlMemory operation
default:
ERROR_LOG(OSHLE, "Unknown ControlMemory operation %08X", operation);
ERROR_LOG(SVC, "ControlMemory unknown operation=0x%08X", operation);
}
DEBUG_LOG(SVC, "...returned virtual_address=0x%08X", virtual_address);
Core::g_app_core->SetReg(1, virtual_address);
return 0;
}
/// Maps a memory block to specified address
Result MapMemoryBlock(Handle memblock, u32 addr, u32 mypermissions, u32 otherpermission) {
int x = 0;
DEBUG_LOG(SVC, "MapMemoryBlock called memblock=0x08X, addr=0x%08X, mypermissions=0x%08X, otherpermission=%d",
memblock, addr, mypermissions, otherpermission);
switch (mypermissions) {
case MEMORY_PERMISSION_NORMAL:
case MEMORY_PERMISSION_NORMAL + 1:
@ -60,20 +65,23 @@ Result MapMemoryBlock(Handle memblock, u32 addr, u32 mypermissions, u32 otherper
Memory::MapBlock_Shared(memblock, addr, mypermissions);
break;
default:
ERROR_LOG(OSHLE, "Unknown MapMemoryBlock permissions %08X", mypermissions);
ERROR_LOG(OSHLE, "MapMemoryBlock unknown permissions=0x%08X", mypermissions);
}
return 0;
}
/// Connect to an OS service given the port name, returns the handle to the port to out
Result ConnectToPort(void* out, const char* port_name) {
Service::Interface* service = Service::g_manager->FetchFromPortName(port_name);
Core::g_app_core->SetReg(1, service->GetUID());
DEBUG_LOG(SVC, "ConnectToPort called port_name=%s", port_name);
return 0;
}
/// Synchronize to an OS service
Result SendSyncRequest(Handle session) {
DEBUG_LOG(SVC, "SendSyncRequest called session=0x%08X");
Service::Interface* service = Service::g_manager->FetchFromUID(session);
service->Sync();
return 0;
@ -82,28 +90,48 @@ Result SendSyncRequest(Handle session) {
/// Close a handle
Result CloseHandle(Handle handle) {
// ImplementMe
NOTICE_LOG(OSHLE, "stubbed function CloseHandle");
DEBUG_LOG(SVC, "(UNIMPLEMENTED) CloseHandle called handle=0x%08X", handle);
return 0;
}
/// Wait for a handle to synchronize, timeout after the specified nanoseconds
Result WaitSynchronization1(Handle handle, s64 nanoseconds) {
// ImplementMe
NOTICE_LOG(OSHLE, "stubbed function WaitSynchronization1");
DEBUG_LOG(SVC, "(UNIMPLEMENTED) WaitSynchronization1 called handle=0x%08X, nanoseconds=%d",
handle, nanoseconds);
return 0;
}
/// Create an address arbiter (to allocate access to shared resources)
Result CreateAddressArbiter(void* arbiter) {
// ImplementMe
NOTICE_LOG(OSHLE, "stubbed function CreateAddressArbiter");
DEBUG_LOG(SVC, "(UNIMPLEMENTED) CreateAddressArbiter called");
Core::g_app_core->SetReg(1, 0xDEADBEEF);
return 0;
}
/// Used to output a message on a debug hardware unit - does nothing on a retail unit
void OutputDebugString(const char* string) {
NOTICE_LOG(OSHLE, "## OSDEBUG: %s", string);
NOTICE_LOG(SVC, "## OSDEBUG: %08X %s", Core::g_app_core->GetPC(), string);
}
/// Get resource limit
Result GetResourceLimit(void* resource_limit, Handle process) {
// With regards to proceess values:
// 0xFFFF8001 is a handle alias for the current KProcess, and 0xFFFF8000 is a handle alias for
// the current KThread.
DEBUG_LOG(SVC, "(UNIMPLEMENTED) GetResourceLimit called process=0x%08X", process);
Core::g_app_core->SetReg(1, 0xDEADBEEF);
return 0;
}
/// Get resource limit current values
Result GetResourceLimitCurrentValues(void* _values, Handle resource_limit, void* names, s32 name_count) {
//s64* values = (s64*)_values;
DEBUG_LOG(SVC, "(UNIMPLEMENTED) GetResourceLimitCurrentValues called resource_limit=%08X, names=%s, name_count=%d",
resource_limit, names, name_count);
Memory::Write32(Core::g_app_core->GetReg(0), 0); // Normmatt: Set used memory to 0 for now
return 0;
}
const HLE::FunctionDef Syscall_Table[] = {
@ -163,9 +191,9 @@ const HLE::FunctionDef Syscall_Table[] = {
{0x35, NULL, "GetProcessId"},
{0x36, NULL, "GetProcessIdOfThread"},
{0x37, NULL, "GetThreadId"},
{0x38, NULL, "GetResourceLimit"},
{0x38, WrapI_VU<GetResourceLimit>, "GetResourceLimit"},
{0x39, NULL, "GetResourceLimitLimitValues"},
{0x3A, NULL, "GetResourceLimitCurrentValues"},
{0x3A, WrapI_VUVI<GetResourceLimitCurrentValues>, "GetResourceLimitCurrentValues"},
{0x3B, NULL, "GetThreadContext"},
{0x3C, NULL, "Break"},
{0x3D, WrapV_C<OutputDebugString>, "OutputDebugString"},