syscall.cpp 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199
  1. // Copyright 2014 Citra Emulator Project
  2. // Licensed under GPLv2
  3. // Refer to the license.txt file included.
  4. #include <map>
  5. #include "core/mem_map.h"
  6. #include "core/hw/hw_lcd.h"
  7. #include "core/hle/function_wrappers.h"
  8. #include "core/hle/syscall.h"
  9. #include "core/hle/service/service.h"
  10. ////////////////////////////////////////////////////////////////////////////////////////////////////
  11. // Namespace Syscall
  12. namespace Syscall {
  13. /// Map application or GSP heap memory
  14. Result ControlMemory(void* outaddr, u32 addr0, u32 addr1, u32 size, u32 operation, u32 permissions) {
  15. u32 virtual_address = 0x00000000;
  16. switch (operation) {
  17. // Map GSP heap memory?
  18. case 0x00010003:
  19. virtual_address = Memory::MapBlock_HeapGSP(size, operation, permissions);
  20. break;
  21. // Unknown ControlMemory operation
  22. default:
  23. ERROR_LOG(OSHLE, "Unknown ControlMemory operation %08X", operation);
  24. }
  25. Core::g_app_core->SetReg(1, Memory::MapBlock_HeapGSP(size, operation, permissions));
  26. return 0;
  27. }
  28. /// Connect to an OS service given the port name, returns the handle to the port to out
  29. Result ConnectToPort(void* out, const char* port_name) {
  30. Service::Interface* service = Service::g_manager->FetchFromPortName(port_name);
  31. Core::g_app_core->SetReg(1, service->GetUID());
  32. return 0;
  33. }
  34. /// Synchronize to an OS service
  35. Result SendSyncRequest(Handle session) {
  36. Service::Interface* service = Service::g_manager->FetchFromUID(session);
  37. service->Sync();
  38. return 0;
  39. }
  40. /// Close a handle
  41. Result CloseHandle(Handle handle) {
  42. // ImplementMe
  43. return 0;
  44. }
  45. /// Wait for a handle to synchronize, timeout after the specified nanoseconds
  46. Result WaitSynchronization1(Handle handle, s64 nanoseconds) {
  47. // ImplementMe
  48. return 0;
  49. }
  50. const HLE::FunctionDef Syscall_Table[] = {
  51. {0x00, NULL, "Unknown"},
  52. {0x01, WrapI_VUUUUU<ControlMemory>, "ControlMemory"},
  53. {0x02, NULL, "QueryMemory"},
  54. {0x03, NULL, "ExitProcess"},
  55. {0x04, NULL, "GetProcessAffinityMask"},
  56. {0x05, NULL, "SetProcessAffinityMask"},
  57. {0x06, NULL, "GetProcessIdealProcessor"},
  58. {0x07, NULL, "SetProcessIdealProcessor"},
  59. {0x08, NULL, "CreateThread"},
  60. {0x09, NULL, "ExitThread"},
  61. {0x0A, NULL, "SleepThread"},
  62. {0x0B, NULL, "GetThreadPriority"},
  63. {0x0C, NULL, "SetThreadPriority"},
  64. {0x0D, NULL, "GetThreadAffinityMask"},
  65. {0x0E, NULL, "SetThreadAffinityMask"},
  66. {0x0F, NULL, "GetThreadIdealProcessor"},
  67. {0x10, NULL, "SetThreadIdealProcessor"},
  68. {0x11, NULL, "GetCurrentProcessorNumber"},
  69. {0x12, NULL, "Run"},
  70. {0x13, NULL, "CreateMutex"},
  71. {0x14, NULL, "ReleaseMutex"},
  72. {0x15, NULL, "CreateSemaphore"},
  73. {0x16, NULL, "ReleaseSemaphore"},
  74. {0x17, NULL, "CreateEvent"},
  75. {0x18, NULL, "SignalEvent"},
  76. {0x19, NULL, "ClearEvent"},
  77. {0x1A, NULL, "CreateTimer"},
  78. {0x1B, NULL, "SetTimer"},
  79. {0x1C, NULL, "CancelTimer"},
  80. {0x1D, NULL, "ClearTimer"},
  81. {0x1E, NULL, "CreateMemoryBlock"},
  82. {0x1F, NULL, "MapMemoryBlock"},
  83. {0x20, NULL, "UnmapMemoryBlock"},
  84. {0x21, NULL, "CreateAddressArbiter"},
  85. {0x22, NULL, "ArbitrateAddress"},
  86. {0x23, WrapI_U<CloseHandle>, "CloseHandle"},
  87. {0x24, WrapI_US64<WaitSynchronization1>, "WaitSynchronization1"},
  88. {0x25, NULL, "WaitSynchronizationN"},
  89. {0x26, NULL, "SignalAndWait"},
  90. {0x27, NULL, "DuplicateHandle"},
  91. {0x28, NULL, "GetSystemTick"},
  92. {0x29, NULL, "GetHandleInfo"},
  93. {0x2A, NULL, "GetSystemInfo"},
  94. {0x2B, NULL, "GetProcessInfo"},
  95. {0x2C, NULL, "GetThreadInfo"},
  96. {0x2D, WrapI_VC<ConnectToPort>, "ConnectToPort"},
  97. {0x2E, NULL, "SendSyncRequest1"},
  98. {0x2F, NULL, "SendSyncRequest2"},
  99. {0x30, NULL, "SendSyncRequest3"},
  100. {0x31, NULL, "SendSyncRequest4"},
  101. {0x32, WrapI_U<SendSyncRequest>, "SendSyncRequest"},
  102. {0x33, NULL, "OpenProcess"},
  103. {0x34, NULL, "OpenThread"},
  104. {0x35, NULL, "GetProcessId"},
  105. {0x36, NULL, "GetProcessIdOfThread"},
  106. {0x37, NULL, "GetThreadId"},
  107. {0x38, NULL, "GetResourceLimit"},
  108. {0x39, NULL, "GetResourceLimitLimitValues"},
  109. {0x3A, NULL, "GetResourceLimitCurrentValues"},
  110. {0x3B, NULL, "GetThreadContext"},
  111. {0x3C, NULL, "Break"},
  112. {0x3D, NULL, "OutputDebugString"},
  113. {0x3E, NULL, "ControlPerformanceCounter"},
  114. {0x3F, NULL, "Unknown"},
  115. {0x40, NULL, "Unknown"},
  116. {0x41, NULL, "Unknown"},
  117. {0x42, NULL, "Unknown"},
  118. {0x43, NULL, "Unknown"},
  119. {0x44, NULL, "Unknown"},
  120. {0x45, NULL, "Unknown"},
  121. {0x46, NULL, "Unknown"},
  122. {0x47, NULL, "CreatePort"},
  123. {0x48, NULL, "CreateSessionToPort"},
  124. {0x49, NULL, "CreateSession"},
  125. {0x4A, NULL, "AcceptSession"},
  126. {0x4B, NULL, "ReplyAndReceive1"},
  127. {0x4C, NULL, "ReplyAndReceive2"},
  128. {0x4D, NULL, "ReplyAndReceive3"},
  129. {0x4E, NULL, "ReplyAndReceive4"},
  130. {0x4F, NULL, "ReplyAndReceive"},
  131. {0x50, NULL, "BindInterrupt"},
  132. {0x51, NULL, "UnbindInterrupt"},
  133. {0x52, NULL, "InvalidateProcessDataCache"},
  134. {0x53, NULL, "StoreProcessDataCache"},
  135. {0x54, NULL, "FlushProcessDataCache"},
  136. {0x55, NULL, "StartInterProcessDma"},
  137. {0x56, NULL, "StopDma"},
  138. {0x57, NULL, "GetDmaState"},
  139. {0x58, NULL, "RestartDma"},
  140. {0x59, NULL, "Unknown"},
  141. {0x5A, NULL, "Unknown"},
  142. {0x5B, NULL, "Unknown"},
  143. {0x5C, NULL, "Unknown"},
  144. {0x5D, NULL, "Unknown"},
  145. {0x5E, NULL, "Unknown"},
  146. {0x5F, NULL, "Unknown"},
  147. {0x60, NULL, "DebugActiveProcess"},
  148. {0x61, NULL, "BreakDebugProcess"},
  149. {0x62, NULL, "TerminateDebugProcess"},
  150. {0x63, NULL, "GetProcessDebugEvent"},
  151. {0x64, NULL, "ContinueDebugEvent"},
  152. {0x65, NULL, "GetProcessList"},
  153. {0x66, NULL, "GetThreadList"},
  154. {0x67, NULL, "GetDebugThreadContext"},
  155. {0x68, NULL, "SetDebugThreadContext"},
  156. {0x69, NULL, "QueryDebugProcessMemory"},
  157. {0x6A, NULL, "ReadProcessMemory"},
  158. {0x6B, NULL, "WriteProcessMemory"},
  159. {0x6C, NULL, "SetHardwareBreakPoint"},
  160. {0x6D, NULL, "GetDebugThreadParam"},
  161. {0x6E, NULL, "Unknown"},
  162. {0x6F, NULL, "Unknown"},
  163. {0x70, NULL, "ControlProcessMemory"},
  164. {0x71, NULL, "MapProcessMemory"},
  165. {0x72, NULL, "UnmapProcessMemory"},
  166. {0x73, NULL, "Unknown"},
  167. {0x74, NULL, "Unknown"},
  168. {0x75, NULL, "Unknown"},
  169. {0x76, NULL, "TerminateProcess"},
  170. {0x77, NULL, "Unknown"},
  171. {0x78, NULL, "CreateResourceLimit"},
  172. {0x79, NULL, "Unknown"},
  173. {0x7A, NULL, "Unknown"},
  174. {0x7B, NULL, "Unknown"},
  175. {0x7C, NULL, "KernelSetState"},
  176. {0x7D, NULL, "QueryProcessMemory"},
  177. };
  178. void Register() {
  179. HLE::RegisterModule("SyscallTable", ARRAY_SIZE(Syscall_Table), Syscall_Table);
  180. }
  181. } // namespace