diff options
| author | 2014-06-01 20:48:29 -0400 | |
|---|---|---|
| committer | 2014-06-01 20:48:29 -0400 | |
| commit | 15c7d8170669cadce685471fea48c215687d6622 (patch) | |
| tree | d41f33839f1fd58fc73b573b420497e6108cb2f5 /src/core | |
| parent | log: updated MAX_LOGLEVEL to use correct log level enum type (diff) | |
| download | yuzu-15c7d8170669cadce685471fea48c215687d6622.tar.gz yuzu-15c7d8170669cadce685471fea48c215687d6622.tar.xz yuzu-15c7d8170669cadce685471fea48c215687d6622.zip | |
svc: cleaned up function_wrappers, updated various SVCs to make use of pointer arguments
Diffstat (limited to 'src/core')
| -rw-r--r-- | src/core/hle/function_wrappers.h | 37 | ||||
| -rw-r--r-- | src/core/hle/svc.cpp | 34 |
2 files changed, 40 insertions, 31 deletions
diff --git a/src/core/hle/function_wrappers.h b/src/core/hle/function_wrappers.h index 7eb62fc48..65e3164c4 100644 --- a/src/core/hle/function_wrappers.h +++ b/src/core/hle/function_wrappers.h | |||
| @@ -33,7 +33,9 @@ template<u32 func()> void WrapU_V() { | |||
| 33 | } | 33 | } |
| 34 | 34 | ||
| 35 | template<int func(void *, const char *)> void WrapI_VC() { | 35 | template<int func(void *, const char *)> void WrapI_VC() { |
| 36 | u32 retval = func(Memory::GetPointer(PARAM(0)), Memory::GetCharPointer(PARAM(1))); | 36 | u32 param_1 = 0; |
| 37 | u32 retval = func(¶m_1, Memory::GetCharPointer(PARAM(1))); | ||
| 38 | Core::g_app_core->SetReg(1, param_1); | ||
| 37 | RETURN(retval); | 39 | RETURN(retval); |
| 38 | } | 40 | } |
| 39 | 41 | ||
| @@ -48,7 +50,8 @@ template<int func(const char *, int, int, u32)> void WrapI_CIIU() { | |||
| 48 | } | 50 | } |
| 49 | 51 | ||
| 50 | template<int func(int, const char *, u32, void *, void *, u32, int)> void WrapI_ICUVVUI() { | 52 | template<int func(int, const char *, u32, void *, void *, u32, int)> void WrapI_ICUVVUI() { |
| 51 | u32 retval = func(PARAM(0), Memory::GetCharPointer(PARAM(1)), PARAM(2), Memory::GetPointer(PARAM(3)),Memory::GetPointer(PARAM(4)), PARAM(5), PARAM(6) ); | 53 | u32 retval = func(PARAM(0), Memory::GetCharPointer(PARAM(1)), PARAM(2), |
| 54 | Memory::GetPointer(PARAM(3)),Memory::GetPointer(PARAM(4)), PARAM(5), PARAM(6)); | ||
| 52 | RETURN(retval); | 55 | RETURN(retval); |
| 53 | } | 56 | } |
| 54 | 57 | ||
| @@ -394,8 +397,8 @@ template<u32 func(const char *)> void WrapU_C() { | |||
| 394 | 397 | ||
| 395 | template<u32 func(const char *, const char *, const char *, u32)> void WrapU_CCCU() { | 398 | template<u32 func(const char *, const char *, const char *, u32)> void WrapU_CCCU() { |
| 396 | u32 retval = func(Memory::GetCharPointer(PARAM(0)), | 399 | u32 retval = func(Memory::GetCharPointer(PARAM(0)), |
| 397 | Memory::GetCharPointer(PARAM(1)), Memory::GetCharPointer(PARAM(2)), | 400 | Memory::GetCharPointer(PARAM(1)), Memory::GetCharPointer(PARAM(2)), |
| 398 | PARAM(3)); | 401 | PARAM(3)); |
| 399 | RETURN(retval); | 402 | RETURN(retval); |
| 400 | } | 403 | } |
| 401 | 404 | ||
| @@ -431,7 +434,7 @@ template<int func(const char *, u32, u32)> void WrapI_CUU() { | |||
| 431 | 434 | ||
| 432 | template<int func(const char *, u32, u32, u32)> void WrapI_CUUU() { | 435 | template<int func(const char *, u32, u32, u32)> void WrapI_CUUU() { |
| 433 | int retval = func(Memory::GetCharPointer(PARAM(0)), PARAM(1), PARAM(2), | 436 | int retval = func(Memory::GetCharPointer(PARAM(0)), PARAM(1), PARAM(2), |
| 434 | PARAM(3)); | 437 | PARAM(3)); |
| 435 | RETURN(retval); | 438 | RETURN(retval); |
| 436 | } | 439 | } |
| 437 | 440 | ||
| @@ -442,7 +445,7 @@ template<int func(const char *, const char*, int, int)> void WrapI_CCII() { | |||
| 442 | 445 | ||
| 443 | template<int func(const char *, u32, u32, int, u32, u32)> void WrapI_CUUIUU() { | 446 | template<int func(const char *, u32, u32, int, u32, u32)> void WrapI_CUUIUU() { |
| 444 | int retval = func(Memory::GetCharPointer(PARAM(0)), PARAM(1), PARAM(2), | 447 | int retval = func(Memory::GetCharPointer(PARAM(0)), PARAM(1), PARAM(2), |
| 445 | PARAM(3), PARAM(4), PARAM(5)); | 448 | PARAM(3), PARAM(4), PARAM(5)); |
| 446 | RETURN(retval); | 449 | RETURN(retval); |
| 447 | } | 450 | } |
| 448 | 451 | ||
| @@ -454,7 +457,7 @@ template<int func(const char *, int, int, u32, int, int)> void WrapI_CIIUII() { | |||
| 454 | 457 | ||
| 455 | template<int func(const char *, int, u32, u32, u32)> void WrapI_CIUUU() { | 458 | template<int func(const char *, int, u32, u32, u32)> void WrapI_CIUUU() { |
| 456 | int retval = func(Memory::GetCharPointer(PARAM(0)), PARAM(1), PARAM(2), | 459 | int retval = func(Memory::GetCharPointer(PARAM(0)), PARAM(1), PARAM(2), |
| 457 | PARAM(3), PARAM(4)); | 460 | PARAM(3), PARAM(4)); |
| 458 | RETURN(retval); | 461 | RETURN(retval); |
| 459 | } | 462 | } |
| 460 | 463 | ||
| @@ -554,18 +557,18 @@ template<int func(const char *, u32, int, u32)> void WrapI_CUIU() { | |||
| 554 | 557 | ||
| 555 | template<void func(u32, const char *, u32, int, u32)> void WrapV_UCUIU() { | 558 | template<void func(u32, const char *, u32, int, u32)> void WrapV_UCUIU() { |
| 556 | func(PARAM(0), Memory::GetCharPointer(PARAM(1)), PARAM(2), PARAM(3), | 559 | func(PARAM(0), Memory::GetCharPointer(PARAM(1)), PARAM(2), PARAM(3), |
| 557 | PARAM(4)); | 560 | PARAM(4)); |
| 558 | } | 561 | } |
| 559 | 562 | ||
| 560 | template<int func(u32, const char *, u32, int, u32)> void WrapI_UCUIU() { | 563 | template<int func(u32, const char *, u32, int, u32)> void WrapI_UCUIU() { |
| 561 | int retval = func(PARAM(0), Memory::GetCharPointer(PARAM(1)), PARAM(2), | 564 | int retval = func(PARAM(0), Memory::GetCharPointer(PARAM(1)), PARAM(2), |
| 562 | PARAM(3), PARAM(4)); | 565 | PARAM(3), PARAM(4)); |
| 563 | RETURN(retval); | 566 | RETURN(retval); |
| 564 | } | 567 | } |
| 565 | 568 | ||
| 566 | template<void func(const char *, u32, int, int, u32)> void WrapV_CUIIU() { | 569 | template<void func(const char *, u32, int, int, u32)> void WrapV_CUIIU() { |
| 567 | func(Memory::GetCharPointer(PARAM(0)), PARAM(1), PARAM(2), PARAM(3), | 570 | func(Memory::GetCharPointer(PARAM(0)), PARAM(1), PARAM(2), PARAM(3), |
| 568 | PARAM(4)); | 571 | PARAM(4)); |
| 569 | } | 572 | } |
| 570 | 573 | ||
| 571 | template<int func(const char *, u32, int, int, u32)> void WrapI_CUIIU() { | 574 | template<int func(const char *, u32, int, int, u32)> void WrapI_CUIIU() { |
| @@ -689,8 +692,8 @@ template<int func(int, u32, u32)> void WrapI_IUU() { | |||
| 689 | } | 692 | } |
| 690 | 693 | ||
| 691 | template<u32 func(u32, u32, u32, u32, u32, u32, u32)> void WrapU_UUUUUUU() { | 694 | template<u32 func(u32, u32, u32, u32, u32, u32, u32)> void WrapU_UUUUUUU() { |
| 692 | u32 retval = func(PARAM(0), PARAM(1), PARAM(2), PARAM(3), PARAM(4), PARAM(5), PARAM(6)); | 695 | u32 retval = func(PARAM(0), PARAM(1), PARAM(2), PARAM(3), PARAM(4), PARAM(5), PARAM(6)); |
| 693 | RETURN(retval); | 696 | RETURN(retval); |
| 694 | } | 697 | } |
| 695 | 698 | ||
| 696 | template<int func(u32, int, u32, u32)> void WrapI_UIUU() { | 699 | template<int func(u32, int, u32, u32)> void WrapI_UIUU() { |
| @@ -734,7 +737,9 @@ template<int func(int, const char *, u32, void *, int, int, int)> void WrapI_ICU | |||
| 734 | } | 737 | } |
| 735 | 738 | ||
| 736 | template<int func(void*, u32)> void WrapI_VU(){ | 739 | template<int func(void*, u32)> void WrapI_VU(){ |
| 737 | u32 retval = func(Memory::GetPointer(PARAM(0)), PARAM(1)); | 740 | u32 param_1 = 0; |
| 741 | u32 retval = func(¶m_1, PARAM(1)); | ||
| 742 | Core::g_app_core->SetReg(1, param_1); | ||
| 738 | RETURN(retval); | 743 | RETURN(retval); |
| 739 | } | 744 | } |
| 740 | 745 | ||
| @@ -749,7 +754,9 @@ template<int func(void*, u32, void*, int)> void WrapI_VUVI(){ | |||
| 749 | } | 754 | } |
| 750 | 755 | ||
| 751 | template<int func(void*, u32, u32, u32, u32, u32)> void WrapI_VUUUUU(){ | 756 | template<int func(void*, u32, u32, u32, u32, u32)> void WrapI_VUUUUU(){ |
| 752 | u32 retval = func(NULL, PARAM(0), PARAM(1), PARAM(2), PARAM(3), PARAM(4)); | 757 | u32 param_1 = 0; |
| 758 | u32 retval = func(¶m_1, PARAM(0), PARAM(1), PARAM(2), PARAM(3), PARAM(4)); | ||
| 759 | Core::g_app_core->SetReg(1, param_1); | ||
| 753 | RETURN(retval); | 760 | RETURN(retval); |
| 754 | } | 761 | } |
| 755 | 762 | ||
| @@ -763,7 +770,7 @@ template<int func(void*, void*, u32, u32, s64)> void WrapI_VVUUS64() { | |||
| 763 | RETURN(retval); | 770 | RETURN(retval); |
| 764 | } | 771 | } |
| 765 | 772 | ||
| 766 | // TODO(bunne): Is this correct? Probably not | 773 | // TODO(bunnei): Is this correct? Probably not |
| 767 | template<int func(u32, u32, u32, u32, s64)> void WrapI_UUUUS64() { | 774 | template<int func(u32, u32, u32, u32, s64)> void WrapI_UUUUS64() { |
| 768 | int retval = func(PARAM(5), PARAM(1), PARAM(2), PARAM(3), (((u64)PARAM(4) << 32) | PARAM(0))); | 775 | int retval = func(PARAM(5), PARAM(1), PARAM(2), PARAM(3), (((u64)PARAM(4) << 32) | PARAM(0))); |
| 769 | RETURN(retval); | 776 | RETURN(retval); |
diff --git a/src/core/hle/svc.cpp b/src/core/hle/svc.cpp index 5ba42973a..11b77e2c5 100644 --- a/src/core/hle/svc.cpp +++ b/src/core/hle/svc.cpp | |||
| @@ -34,8 +34,8 @@ enum MapMemoryPermission { | |||
| 34 | }; | 34 | }; |
| 35 | 35 | ||
| 36 | /// Map application or GSP heap memory | 36 | /// Map application or GSP heap memory |
| 37 | Result ControlMemory(void* _outaddr, u32 operation, u32 addr0, u32 addr1, u32 size, u32 permissions) { | 37 | Result ControlMemory(void* _out_addr, u32 operation, u32 addr0, u32 addr1, u32 size, u32 permissions) { |
| 38 | u32 virtual_address = 0x00000000; | 38 | u32* out_addr = (u32*)_out_addr; |
| 39 | 39 | ||
| 40 | DEBUG_LOG(SVC,"called operation=0x%08X, addr0=0x%08X, addr1=0x%08X, size=%08X, permissions=0x%08X", | 40 | DEBUG_LOG(SVC,"called operation=0x%08X, addr0=0x%08X, addr1=0x%08X, size=%08X, permissions=0x%08X", |
| 41 | operation, addr0, addr1, size, permissions); | 41 | operation, addr0, addr1, size, permissions); |
| @@ -44,21 +44,18 @@ Result ControlMemory(void* _outaddr, u32 operation, u32 addr0, u32 addr1, u32 si | |||
| 44 | 44 | ||
| 45 | // Map normal heap memory | 45 | // Map normal heap memory |
| 46 | case MEMORY_OPERATION_HEAP: | 46 | case MEMORY_OPERATION_HEAP: |
| 47 | virtual_address = Memory::MapBlock_Heap(size, operation, permissions); | 47 | *out_addr = Memory::MapBlock_Heap(size, operation, permissions); |
| 48 | break; | 48 | break; |
| 49 | 49 | ||
| 50 | // Map GSP heap memory | 50 | // Map GSP heap memory |
| 51 | case MEMORY_OPERATION_GSP_HEAP: | 51 | case MEMORY_OPERATION_GSP_HEAP: |
| 52 | virtual_address = Memory::MapBlock_HeapGSP(size, operation, permissions); | 52 | *out_addr = Memory::MapBlock_HeapGSP(size, operation, permissions); |
| 53 | break; | 53 | break; |
| 54 | 54 | ||
| 55 | // Unknown ControlMemory operation | 55 | // Unknown ControlMemory operation |
| 56 | default: | 56 | default: |
| 57 | ERROR_LOG(SVC, "unknown operation=0x%08X", operation); | 57 | ERROR_LOG(SVC, "unknown operation=0x%08X", operation); |
| 58 | } | 58 | } |
| 59 | |||
| 60 | Core::g_app_core->SetReg(1, virtual_address); | ||
| 61 | |||
| 62 | return 0; | 59 | return 0; |
| 63 | } | 60 | } |
| 64 | 61 | ||
| @@ -80,10 +77,14 @@ Result MapMemoryBlock(Handle memblock, u32 addr, u32 mypermissions, u32 otherper | |||
| 80 | 77 | ||
| 81 | /// Connect to an OS service given the port name, returns the handle to the port to out | 78 | /// Connect to an OS service given the port name, returns the handle to the port to out |
| 82 | Result ConnectToPort(void* _out, const char* port_name) { | 79 | Result ConnectToPort(void* _out, const char* port_name) { |
| 80 | Handle* out = (Handle*)_out; | ||
| 83 | Service::Interface* service = Service::g_manager->FetchFromPortName(port_name); | 81 | Service::Interface* service = Service::g_manager->FetchFromPortName(port_name); |
| 82 | |||
| 84 | DEBUG_LOG(SVC, "called port_name=%s", port_name); | 83 | DEBUG_LOG(SVC, "called port_name=%s", port_name); |
| 85 | _assert_msg_(KERNEL, service, "called, but service is not implemented!"); | 84 | _assert_msg_(KERNEL, service, "called, but service is not implemented!"); |
| 86 | Core::g_app_core->SetReg(1, service->GetHandle()); | 85 | |
| 86 | *out = service->GetHandle(); | ||
| 87 | |||
| 87 | return 0; | 88 | return 0; |
| 88 | } | 89 | } |
| 89 | 90 | ||
| @@ -209,12 +210,13 @@ void OutputDebugString(const char* string) { | |||
| 209 | } | 210 | } |
| 210 | 211 | ||
| 211 | /// Get resource limit | 212 | /// Get resource limit |
| 212 | Result GetResourceLimit(void* resource_limit, Handle process) { | 213 | Result GetResourceLimit(void* _resource_limit, Handle process) { |
| 213 | // With regards to proceess values: | 214 | // With regards to proceess values: |
| 214 | // 0xFFFF8001 is a handle alias for the current KProcess, and 0xFFFF8000 is a handle alias for | 215 | // 0xFFFF8001 is a handle alias for the current KProcess, and 0xFFFF8000 is a handle alias for |
| 215 | // the current KThread. | 216 | // the current KThread. |
| 217 | Handle* resource_limit = (Handle*)_resource_limit; | ||
| 218 | *resource_limit = 0xDEADBEEF; | ||
| 216 | ERROR_LOG(SVC, "(UNIMPLEMENTED) called process=0x%08X", process); | 219 | ERROR_LOG(SVC, "(UNIMPLEMENTED) called process=0x%08X", process); |
| 217 | Core::g_app_core->SetReg(1, 0xDEADBEEF); | ||
| 218 | return 0; | 220 | return 0; |
| 219 | } | 221 | } |
| 220 | 222 | ||
| @@ -253,10 +255,10 @@ Result CreateThread(u32 priority, u32 entry_point, u32 arg, u32 stack_top, u32 p | |||
| 253 | 255 | ||
| 254 | /// Create a mutex | 256 | /// Create a mutex |
| 255 | Result CreateMutex(void* _mutex, u32 initial_locked) { | 257 | Result CreateMutex(void* _mutex, u32 initial_locked) { |
| 256 | Handle mutex = Kernel::CreateMutex((initial_locked != 0)); | 258 | Handle* mutex = (Handle*)_mutex; |
| 257 | Core::g_app_core->SetReg(1, mutex); | 259 | *mutex = Kernel::CreateMutex((initial_locked != 0)); |
| 258 | DEBUG_LOG(SVC, "called initial_locked=%s : created handle=0x%08X", | 260 | DEBUG_LOG(SVC, "called initial_locked=%s : created handle=0x%08X", |
| 259 | initial_locked ? "true" : "false", mutex); | 261 | initial_locked ? "true" : "false", *mutex); |
| 260 | return 0; | 262 | return 0; |
| 261 | } | 263 | } |
| 262 | 264 | ||
| @@ -282,10 +284,10 @@ Result QueryMemory(void *_info, void *_out, u32 addr) { | |||
| 282 | 284 | ||
| 283 | /// Create an event | 285 | /// Create an event |
| 284 | Result CreateEvent(void* _event, u32 reset_type) { | 286 | Result CreateEvent(void* _event, u32 reset_type) { |
| 285 | Handle evt = Kernel::CreateEvent((ResetType)reset_type); | 287 | Handle* evt = (Handle*)_event; |
| 286 | Core::g_app_core->SetReg(1, evt); | 288 | *evt = Kernel::CreateEvent((ResetType)reset_type); |
| 287 | DEBUG_LOG(SVC, "called reset_type=0x%08X : created handle=0x%08X", | 289 | DEBUG_LOG(SVC, "called reset_type=0x%08X : created handle=0x%08X", |
| 288 | reset_type, evt); | 290 | reset_type, *evt); |
| 289 | return 0; | 291 | return 0; |
| 290 | } | 292 | } |
| 291 | 293 | ||