1
0
Fork 0

svc: cleaned up function_wrappers, updated various SVCs to make use of pointer arguments

This commit is contained in:
bunnei 2014-06-01 20:48:29 -04:00
parent 00adbc7817
commit 15c7d81706
2 changed files with 40 additions and 31 deletions

View File

@ -33,7 +33,9 @@ template<u32 func()> void WrapU_V() {
} }
template<int func(void *, const char *)> void WrapI_VC() { template<int func(void *, const char *)> void WrapI_VC() {
u32 retval = func(Memory::GetPointer(PARAM(0)), Memory::GetCharPointer(PARAM(1))); u32 param_1 = 0;
u32 retval = func(&param_1, Memory::GetCharPointer(PARAM(1)));
Core::g_app_core->SetReg(1, param_1);
RETURN(retval); RETURN(retval);
} }
@ -48,7 +50,8 @@ template<int func(const char *, int, int, u32)> void WrapI_CIIU() {
} }
template<int func(int, const char *, u32, void *, void *, u32, int)> void WrapI_ICUVVUI() { template<int func(int, const char *, u32, void *, void *, u32, int)> void WrapI_ICUVVUI() {
u32 retval = func(PARAM(0), Memory::GetCharPointer(PARAM(1)), PARAM(2), Memory::GetPointer(PARAM(3)),Memory::GetPointer(PARAM(4)), PARAM(5), PARAM(6) ); u32 retval = func(PARAM(0), Memory::GetCharPointer(PARAM(1)), PARAM(2),
Memory::GetPointer(PARAM(3)),Memory::GetPointer(PARAM(4)), PARAM(5), PARAM(6));
RETURN(retval); RETURN(retval);
} }
@ -734,7 +737,9 @@ template<int func(int, const char *, u32, void *, int, int, int)> void WrapI_ICU
} }
template<int func(void*, u32)> void WrapI_VU(){ template<int func(void*, u32)> void WrapI_VU(){
u32 retval = func(Memory::GetPointer(PARAM(0)), PARAM(1)); u32 param_1 = 0;
u32 retval = func(&param_1, PARAM(1));
Core::g_app_core->SetReg(1, param_1);
RETURN(retval); RETURN(retval);
} }
@ -749,7 +754,9 @@ template<int func(void*, u32, void*, int)> void WrapI_VUVI(){
} }
template<int func(void*, u32, u32, u32, u32, u32)> void WrapI_VUUUUU(){ template<int func(void*, u32, u32, u32, u32, u32)> void WrapI_VUUUUU(){
u32 retval = func(NULL, PARAM(0), PARAM(1), PARAM(2), PARAM(3), PARAM(4)); u32 param_1 = 0;
u32 retval = func(&param_1, PARAM(0), PARAM(1), PARAM(2), PARAM(3), PARAM(4));
Core::g_app_core->SetReg(1, param_1);
RETURN(retval); RETURN(retval);
} }
@ -763,7 +770,7 @@ template<int func(void*, void*, u32, u32, s64)> void WrapI_VVUUS64() {
RETURN(retval); RETURN(retval);
} }
// TODO(bunne): Is this correct? Probably not // TODO(bunnei): Is this correct? Probably not
template<int func(u32, u32, u32, u32, s64)> void WrapI_UUUUS64() { template<int func(u32, u32, u32, u32, s64)> void WrapI_UUUUS64() {
int retval = func(PARAM(5), PARAM(1), PARAM(2), PARAM(3), (((u64)PARAM(4) << 32) | PARAM(0))); int retval = func(PARAM(5), PARAM(1), PARAM(2), PARAM(3), (((u64)PARAM(4) << 32) | PARAM(0)));
RETURN(retval); RETURN(retval);

View File

@ -34,8 +34,8 @@ enum MapMemoryPermission {
}; };
/// Map application or GSP heap memory /// Map application or GSP heap memory
Result ControlMemory(void* _outaddr, u32 operation, u32 addr0, u32 addr1, u32 size, u32 permissions) { Result ControlMemory(void* _out_addr, u32 operation, u32 addr0, u32 addr1, u32 size, u32 permissions) {
u32 virtual_address = 0x00000000; u32* out_addr = (u32*)_out_addr;
DEBUG_LOG(SVC,"called operation=0x%08X, addr0=0x%08X, addr1=0x%08X, size=%08X, permissions=0x%08X", DEBUG_LOG(SVC,"called operation=0x%08X, addr0=0x%08X, addr1=0x%08X, size=%08X, permissions=0x%08X",
operation, addr0, addr1, size, permissions); operation, addr0, addr1, size, permissions);
@ -44,21 +44,18 @@ Result ControlMemory(void* _outaddr, u32 operation, u32 addr0, u32 addr1, u32 si
// Map normal heap memory // Map normal heap memory
case MEMORY_OPERATION_HEAP: case MEMORY_OPERATION_HEAP:
virtual_address = Memory::MapBlock_Heap(size, operation, permissions); *out_addr = Memory::MapBlock_Heap(size, operation, permissions);
break; break;
// Map GSP heap memory // Map GSP heap memory
case MEMORY_OPERATION_GSP_HEAP: case MEMORY_OPERATION_GSP_HEAP:
virtual_address = Memory::MapBlock_HeapGSP(size, operation, permissions); *out_addr = Memory::MapBlock_HeapGSP(size, operation, permissions);
break; break;
// Unknown ControlMemory operation // Unknown ControlMemory operation
default: default:
ERROR_LOG(SVC, "unknown operation=0x%08X", operation); ERROR_LOG(SVC, "unknown operation=0x%08X", operation);
} }
Core::g_app_core->SetReg(1, virtual_address);
return 0; return 0;
} }
@ -80,10 +77,14 @@ Result MapMemoryBlock(Handle memblock, u32 addr, u32 mypermissions, u32 otherper
/// Connect to an OS service given the port name, returns the handle to the port to out /// 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) { Result ConnectToPort(void* _out, const char* port_name) {
Handle* out = (Handle*)_out;
Service::Interface* service = Service::g_manager->FetchFromPortName(port_name); Service::Interface* service = Service::g_manager->FetchFromPortName(port_name);
DEBUG_LOG(SVC, "called port_name=%s", port_name); DEBUG_LOG(SVC, "called port_name=%s", port_name);
_assert_msg_(KERNEL, service, "called, but service is not implemented!"); _assert_msg_(KERNEL, service, "called, but service is not implemented!");
Core::g_app_core->SetReg(1, service->GetHandle());
*out = service->GetHandle();
return 0; return 0;
} }
@ -209,12 +210,13 @@ void OutputDebugString(const char* string) {
} }
/// Get resource limit /// Get resource limit
Result GetResourceLimit(void* resource_limit, Handle process) { Result GetResourceLimit(void* _resource_limit, Handle process) {
// With regards to proceess values: // With regards to proceess values:
// 0xFFFF8001 is a handle alias for the current KProcess, and 0xFFFF8000 is a handle alias for // 0xFFFF8001 is a handle alias for the current KProcess, and 0xFFFF8000 is a handle alias for
// the current KThread. // the current KThread.
Handle* resource_limit = (Handle*)_resource_limit;
*resource_limit = 0xDEADBEEF;
ERROR_LOG(SVC, "(UNIMPLEMENTED) called process=0x%08X", process); ERROR_LOG(SVC, "(UNIMPLEMENTED) called process=0x%08X", process);
Core::g_app_core->SetReg(1, 0xDEADBEEF);
return 0; return 0;
} }
@ -253,10 +255,10 @@ Result CreateThread(u32 priority, u32 entry_point, u32 arg, u32 stack_top, u32 p
/// Create a mutex /// Create a mutex
Result CreateMutex(void* _mutex, u32 initial_locked) { Result CreateMutex(void* _mutex, u32 initial_locked) {
Handle mutex = Kernel::CreateMutex((initial_locked != 0)); Handle* mutex = (Handle*)_mutex;
Core::g_app_core->SetReg(1, mutex); *mutex = Kernel::CreateMutex((initial_locked != 0));
DEBUG_LOG(SVC, "called initial_locked=%s : created handle=0x%08X", DEBUG_LOG(SVC, "called initial_locked=%s : created handle=0x%08X",
initial_locked ? "true" : "false", mutex); initial_locked ? "true" : "false", *mutex);
return 0; return 0;
} }
@ -282,10 +284,10 @@ Result QueryMemory(void *_info, void *_out, u32 addr) {
/// Create an event /// Create an event
Result CreateEvent(void* _event, u32 reset_type) { Result CreateEvent(void* _event, u32 reset_type) {
Handle evt = Kernel::CreateEvent((ResetType)reset_type); Handle* evt = (Handle*)_event;
Core::g_app_core->SetReg(1, evt); *evt = Kernel::CreateEvent((ResetType)reset_type);
DEBUG_LOG(SVC, "called reset_type=0x%08X : created handle=0x%08X", DEBUG_LOG(SVC, "called reset_type=0x%08X : created handle=0x%08X",
reset_type, evt); reset_type, *evt);
return 0; return 0;
} }