summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/core/hle/function_wrappers.h12
-rw-r--r--src/core/hle/syscall.cpp296
2 files changed, 173 insertions, 135 deletions
diff --git a/src/core/hle/function_wrappers.h b/src/core/hle/function_wrappers.h
index 53bfafa78..18b01b14b 100644
--- a/src/core/hle/function_wrappers.h
+++ b/src/core/hle/function_wrappers.h
@@ -729,7 +729,17 @@ template<int func(int, const char *, u32, void *, int, int, int)> void WrapI_ICU
729 RETURN(retval); 729 RETURN(retval);
730} 730}
731 731
732template<int func(void *, u32, u32, u32, u32, u32)> void WrapI_VUUUUU(){ 732template<int func(void*, u32)> void WrapI_VU(){
733 u32 retval = func(Memory::GetPointer(PARAM(0)), PARAM(1));
734 RETURN(retval);
735}
736
737template<int func(void*, u32, void*, int)> void WrapI_VUVI(){
738 u32 retval = func(Memory::GetPointer(PARAM(0)), PARAM(1), Memory::GetPointer(PARAM(2)), PARAM(3));
739 RETURN(retval);
740}
741
742template<int func(void*, u32, u32, u32, u32, u32)> void WrapI_VUUUUU(){
733 u32 retval = func(Memory::GetPointer(PARAM(0)), PARAM(1), PARAM(2), PARAM(3), PARAM(4), PARAM(5)); 743 u32 retval = func(Memory::GetPointer(PARAM(0)), PARAM(1), PARAM(2), PARAM(3), PARAM(4), PARAM(5));
734 RETURN(retval); 744 RETURN(retval);
735} 745}
diff --git a/src/core/hle/syscall.cpp b/src/core/hle/syscall.cpp
index cc5b561b5..5b4d47485 100644
--- a/src/core/hle/syscall.cpp
+++ b/src/core/hle/syscall.cpp
@@ -29,6 +29,9 @@ enum MapMemoryPermission {
29Result ControlMemory(u32 operation, u32 addr0, u32 addr1, u32 size, u32 permissions) { 29Result ControlMemory(u32 operation, u32 addr0, u32 addr1, u32 size, u32 permissions) {
30 u32 virtual_address = 0x00000000; 30 u32 virtual_address = 0x00000000;
31 31
32 DEBUG_LOG(SVC, "ControlMemory called operation=0x%08X, addr0=0x%08X, addr1=0x%08X, size=%08X, permissions=0x%08X",
33 operation, addr0, addr1, size, permissions);
34
32 switch (operation) { 35 switch (operation) {
33 36
34 // Map normal heap memory 37 // Map normal heap memory
@@ -43,16 +46,18 @@ Result ControlMemory(u32 operation, u32 addr0, u32 addr1, u32 size, u32 permissi
43 46
44 // Unknown ControlMemory operation 47 // Unknown ControlMemory operation
45 default: 48 default:
46 ERROR_LOG(OSHLE, "Unknown ControlMemory operation %08X", operation); 49 ERROR_LOG(SVC, "ControlMemory unknown operation=0x%08X", operation);
47 } 50 }
48 51 DEBUG_LOG(SVC, "...returned virtual_address=0x%08X", virtual_address);
49 Core::g_app_core->SetReg(1, virtual_address); 52 Core::g_app_core->SetReg(1, virtual_address);
53
50 return 0; 54 return 0;
51} 55}
52 56
53/// Maps a memory block to specified address 57/// Maps a memory block to specified address
54Result MapMemoryBlock(Handle memblock, u32 addr, u32 mypermissions, u32 otherpermission) { 58Result MapMemoryBlock(Handle memblock, u32 addr, u32 mypermissions, u32 otherpermission) {
55 int x = 0; 59 DEBUG_LOG(SVC, "MapMemoryBlock called memblock=0x08X, addr=0x%08X, mypermissions=0x%08X, otherpermission=%d",
60 memblock, addr, mypermissions, otherpermission);
56 switch (mypermissions) { 61 switch (mypermissions) {
57 case MEMORY_PERMISSION_NORMAL: 62 case MEMORY_PERMISSION_NORMAL:
58 case MEMORY_PERMISSION_NORMAL + 1: 63 case MEMORY_PERMISSION_NORMAL + 1:
@@ -60,20 +65,23 @@ Result MapMemoryBlock(Handle memblock, u32 addr, u32 mypermissions, u32 otherper
60 Memory::MapBlock_Shared(memblock, addr, mypermissions); 65 Memory::MapBlock_Shared(memblock, addr, mypermissions);
61 break; 66 break;
62 default: 67 default:
63 ERROR_LOG(OSHLE, "Unknown MapMemoryBlock permissions %08X", mypermissions); 68 ERROR_LOG(OSHLE, "MapMemoryBlock unknown permissions=0x%08X", mypermissions);
64 } 69 }
65 return 0; 70 return 0;
66} 71}
67 72
68/// Connect to an OS service given the port name, returns the handle to the port to out 73/// Connect to an OS service given the port name, returns the handle to the port to out
69Result ConnectToPort(void* out, const char* port_name) { 74Result ConnectToPort(void* out, const char* port_name) {
75
70 Service::Interface* service = Service::g_manager->FetchFromPortName(port_name); 76 Service::Interface* service = Service::g_manager->FetchFromPortName(port_name);
71 Core::g_app_core->SetReg(1, service->GetUID()); 77 Core::g_app_core->SetReg(1, service->GetUID());
78 DEBUG_LOG(SVC, "ConnectToPort called port_name=%s", port_name);
72 return 0; 79 return 0;
73} 80}
74 81
75/// Synchronize to an OS service 82/// Synchronize to an OS service
76Result SendSyncRequest(Handle session) { 83Result SendSyncRequest(Handle session) {
84 DEBUG_LOG(SVC, "SendSyncRequest called session=0x%08X");
77 Service::Interface* service = Service::g_manager->FetchFromUID(session); 85 Service::Interface* service = Service::g_manager->FetchFromUID(session);
78 service->Sync(); 86 service->Sync();
79 return 0; 87 return 0;
@@ -82,157 +90,177 @@ Result SendSyncRequest(Handle session) {
82/// Close a handle 90/// Close a handle
83Result CloseHandle(Handle handle) { 91Result CloseHandle(Handle handle) {
84 // ImplementMe 92 // ImplementMe
85 NOTICE_LOG(OSHLE, "stubbed function CloseHandle"); 93 DEBUG_LOG(SVC, "(UNIMPLEMENTED) CloseHandle called handle=0x%08X", handle);
86 return 0; 94 return 0;
87} 95}
88 96
89/// Wait for a handle to synchronize, timeout after the specified nanoseconds 97/// Wait for a handle to synchronize, timeout after the specified nanoseconds
90Result WaitSynchronization1(Handle handle, s64 nanoseconds) { 98Result WaitSynchronization1(Handle handle, s64 nanoseconds) {
91 // ImplementMe 99 // ImplementMe
92 NOTICE_LOG(OSHLE, "stubbed function WaitSynchronization1"); 100 DEBUG_LOG(SVC, "(UNIMPLEMENTED) WaitSynchronization1 called handle=0x%08X, nanoseconds=%d",
101 handle, nanoseconds);
93 return 0; 102 return 0;
94} 103}
95 104
96/// Create an address arbiter (to allocate access to shared resources) 105/// Create an address arbiter (to allocate access to shared resources)
97Result CreateAddressArbiter(void* arbiter) { 106Result CreateAddressArbiter(void* arbiter) {
98 // ImplementMe 107 // ImplementMe
99 NOTICE_LOG(OSHLE, "stubbed function CreateAddressArbiter"); 108 DEBUG_LOG(SVC, "(UNIMPLEMENTED) CreateAddressArbiter called");
100 Core::g_app_core->SetReg(1, 0xDEADBEEF); 109 Core::g_app_core->SetReg(1, 0xDEADBEEF);
101 return 0; 110 return 0;
102} 111}
103 112
104/// Used to output a message on a debug hardware unit - does nothing on a retail unit 113/// Used to output a message on a debug hardware unit - does nothing on a retail unit
105void OutputDebugString(const char* string) { 114void OutputDebugString(const char* string) {
106 NOTICE_LOG(OSHLE, "## OSDEBUG: %s", string); 115 NOTICE_LOG(SVC, "## OSDEBUG: %08X %s", Core::g_app_core->GetPC(), string);
116}
117
118/// Get resource limit
119Result GetResourceLimit(void* resource_limit, Handle process) {
120 // With regards to proceess values:
121 // 0xFFFF8001 is a handle alias for the current KProcess, and 0xFFFF8000 is a handle alias for
122 // the current KThread.
123 DEBUG_LOG(SVC, "(UNIMPLEMENTED) GetResourceLimit called process=0x%08X", process);
124 Core::g_app_core->SetReg(1, 0xDEADBEEF);
125 return 0;
126}
127
128/// Get resource limit current values
129Result GetResourceLimitCurrentValues(void* _values, Handle resource_limit, void* names, s32 name_count) {
130 //s64* values = (s64*)_values;
131 DEBUG_LOG(SVC, "(UNIMPLEMENTED) GetResourceLimitCurrentValues called resource_limit=%08X, names=%s, name_count=%d",
132 resource_limit, names, name_count);
133 Memory::Write32(Core::g_app_core->GetReg(0), 0); // Normmatt: Set used memory to 0 for now
134 return 0;
107} 135}
108 136
109const HLE::FunctionDef Syscall_Table[] = { 137const HLE::FunctionDef Syscall_Table[] = {
110 {0x00, NULL, "Unknown"}, 138 {0x00, NULL, "Unknown"},
111 {0x01, WrapI_UUUUU<ControlMemory>, "ControlMemory"}, 139 {0x01, WrapI_UUUUU<ControlMemory>, "ControlMemory"},
112 {0x02, NULL, "QueryMemory"}, 140 {0x02, NULL, "QueryMemory"},
113 {0x03, NULL, "ExitProcess"}, 141 {0x03, NULL, "ExitProcess"},
114 {0x04, NULL, "GetProcessAffinityMask"}, 142 {0x04, NULL, "GetProcessAffinityMask"},
115 {0x05, NULL, "SetProcessAffinityMask"}, 143 {0x05, NULL, "SetProcessAffinityMask"},
116 {0x06, NULL, "GetProcessIdealProcessor"}, 144 {0x06, NULL, "GetProcessIdealProcessor"},
117 {0x07, NULL, "SetProcessIdealProcessor"}, 145 {0x07, NULL, "SetProcessIdealProcessor"},
118 {0x08, NULL, "CreateThread"}, 146 {0x08, NULL, "CreateThread"},
119 {0x09, NULL, "ExitThread"}, 147 {0x09, NULL, "ExitThread"},
120 {0x0A, NULL, "SleepThread"}, 148 {0x0A, NULL, "SleepThread"},
121 {0x0B, NULL, "GetThreadPriority"}, 149 {0x0B, NULL, "GetThreadPriority"},
122 {0x0C, NULL, "SetThreadPriority"}, 150 {0x0C, NULL, "SetThreadPriority"},
123 {0x0D, NULL, "GetThreadAffinityMask"}, 151 {0x0D, NULL, "GetThreadAffinityMask"},
124 {0x0E, NULL, "SetThreadAffinityMask"}, 152 {0x0E, NULL, "SetThreadAffinityMask"},
125 {0x0F, NULL, "GetThreadIdealProcessor"}, 153 {0x0F, NULL, "GetThreadIdealProcessor"},
126 {0x10, NULL, "SetThreadIdealProcessor"}, 154 {0x10, NULL, "SetThreadIdealProcessor"},
127 {0x11, NULL, "GetCurrentProcessorNumber"}, 155 {0x11, NULL, "GetCurrentProcessorNumber"},
128 {0x12, NULL, "Run"}, 156 {0x12, NULL, "Run"},
129 {0x13, NULL, "CreateMutex"}, 157 {0x13, NULL, "CreateMutex"},
130 {0x14, NULL, "ReleaseMutex"}, 158 {0x14, NULL, "ReleaseMutex"},
131 {0x15, NULL, "CreateSemaphore"}, 159 {0x15, NULL, "CreateSemaphore"},
132 {0x16, NULL, "ReleaseSemaphore"}, 160 {0x16, NULL, "ReleaseSemaphore"},
133 {0x17, NULL, "CreateEvent"}, 161 {0x17, NULL, "CreateEvent"},
134 {0x18, NULL, "SignalEvent"}, 162 {0x18, NULL, "SignalEvent"},
135 {0x19, NULL, "ClearEvent"}, 163 {0x19, NULL, "ClearEvent"},
136 {0x1A, NULL, "CreateTimer"}, 164 {0x1A, NULL, "CreateTimer"},
137 {0x1B, NULL, "SetTimer"}, 165 {0x1B, NULL, "SetTimer"},
138 {0x1C, NULL, "CancelTimer"}, 166 {0x1C, NULL, "CancelTimer"},
139 {0x1D, NULL, "ClearTimer"}, 167 {0x1D, NULL, "ClearTimer"},
140 {0x1E, NULL, "CreateMemoryBlock"}, 168 {0x1E, NULL, "CreateMemoryBlock"},
141 {0x1F, WrapI_UUUU<MapMemoryBlock>, "MapMemoryBlock"}, 169 {0x1F, WrapI_UUUU<MapMemoryBlock>, "MapMemoryBlock"},
142 {0x20, NULL, "UnmapMemoryBlock"}, 170 {0x20, NULL, "UnmapMemoryBlock"},
143 {0x21, WrapI_V<CreateAddressArbiter>, "CreateAddressArbiter"}, 171 {0x21, WrapI_V<CreateAddressArbiter>, "CreateAddressArbiter"},
144 {0x22, NULL, "ArbitrateAddress"}, 172 {0x22, NULL, "ArbitrateAddress"},
145 {0x23, WrapI_U<CloseHandle>, "CloseHandle"}, 173 {0x23, WrapI_U<CloseHandle>, "CloseHandle"},
146 {0x24, WrapI_US64<WaitSynchronization1>, "WaitSynchronization1"}, 174 {0x24, WrapI_US64<WaitSynchronization1>, "WaitSynchronization1"},
147 {0x25, NULL, "WaitSynchronizationN"}, 175 {0x25, NULL, "WaitSynchronizationN"},
148 {0x26, NULL, "SignalAndWait"}, 176 {0x26, NULL, "SignalAndWait"},
149 {0x27, NULL, "DuplicateHandle"}, 177 {0x27, NULL, "DuplicateHandle"},
150 {0x28, NULL, "GetSystemTick"}, 178 {0x28, NULL, "GetSystemTick"},
151 {0x29, NULL, "GetHandleInfo"}, 179 {0x29, NULL, "GetHandleInfo"},
152 {0x2A, NULL, "GetSystemInfo"}, 180 {0x2A, NULL, "GetSystemInfo"},
153 {0x2B, NULL, "GetProcessInfo"}, 181 {0x2B, NULL, "GetProcessInfo"},
154 {0x2C, NULL, "GetThreadInfo"}, 182 {0x2C, NULL, "GetThreadInfo"},
155 {0x2D, WrapI_VC<ConnectToPort>, "ConnectToPort"}, 183 {0x2D, WrapI_VC<ConnectToPort>, "ConnectToPort"},
156 {0x2E, NULL, "SendSyncRequest1"}, 184 {0x2E, NULL, "SendSyncRequest1"},
157 {0x2F, NULL, "SendSyncRequest2"}, 185 {0x2F, NULL, "SendSyncRequest2"},
158 {0x30, NULL, "SendSyncRequest3"}, 186 {0x30, NULL, "SendSyncRequest3"},
159 {0x31, NULL, "SendSyncRequest4"}, 187 {0x31, NULL, "SendSyncRequest4"},
160 {0x32, WrapI_U<SendSyncRequest>, "SendSyncRequest"}, 188 {0x32, WrapI_U<SendSyncRequest>, "SendSyncRequest"},
161 {0x33, NULL, "OpenProcess"}, 189 {0x33, NULL, "OpenProcess"},
162 {0x34, NULL, "OpenThread"}, 190 {0x34, NULL, "OpenThread"},
163 {0x35, NULL, "GetProcessId"}, 191 {0x35, NULL, "GetProcessId"},
164 {0x36, NULL, "GetProcessIdOfThread"}, 192 {0x36, NULL, "GetProcessIdOfThread"},
165 {0x37, NULL, "GetThreadId"}, 193 {0x37, NULL, "GetThreadId"},
166 {0x38, NULL, "GetResourceLimit"}, 194 {0x38, WrapI_VU<GetResourceLimit>, "GetResourceLimit"},
167 {0x39, NULL, "GetResourceLimitLimitValues"}, 195 {0x39, NULL, "GetResourceLimitLimitValues"},
168 {0x3A, NULL, "GetResourceLimitCurrentValues"}, 196 {0x3A, WrapI_VUVI<GetResourceLimitCurrentValues>, "GetResourceLimitCurrentValues"},
169 {0x3B, NULL, "GetThreadContext"}, 197 {0x3B, NULL, "GetThreadContext"},
170 {0x3C, NULL, "Break"}, 198 {0x3C, NULL, "Break"},
171 {0x3D, WrapV_C<OutputDebugString>, "OutputDebugString"}, 199 {0x3D, WrapV_C<OutputDebugString>, "OutputDebugString"},
172 {0x3E, NULL, "ControlPerformanceCounter"}, 200 {0x3E, NULL, "ControlPerformanceCounter"},
173 {0x3F, NULL, "Unknown"}, 201 {0x3F, NULL, "Unknown"},
174 {0x40, NULL, "Unknown"}, 202 {0x40, NULL, "Unknown"},
175 {0x41, NULL, "Unknown"}, 203 {0x41, NULL, "Unknown"},
176 {0x42, NULL, "Unknown"}, 204 {0x42, NULL, "Unknown"},
177 {0x43, NULL, "Unknown"}, 205 {0x43, NULL, "Unknown"},
178 {0x44, NULL, "Unknown"}, 206 {0x44, NULL, "Unknown"},
179 {0x45, NULL, "Unknown"}, 207 {0x45, NULL, "Unknown"},
180 {0x46, NULL, "Unknown"}, 208 {0x46, NULL, "Unknown"},
181 {0x47, NULL, "CreatePort"}, 209 {0x47, NULL, "CreatePort"},
182 {0x48, NULL, "CreateSessionToPort"}, 210 {0x48, NULL, "CreateSessionToPort"},
183 {0x49, NULL, "CreateSession"}, 211 {0x49, NULL, "CreateSession"},
184 {0x4A, NULL, "AcceptSession"}, 212 {0x4A, NULL, "AcceptSession"},
185 {0x4B, NULL, "ReplyAndReceive1"}, 213 {0x4B, NULL, "ReplyAndReceive1"},
186 {0x4C, NULL, "ReplyAndReceive2"}, 214 {0x4C, NULL, "ReplyAndReceive2"},
187 {0x4D, NULL, "ReplyAndReceive3"}, 215 {0x4D, NULL, "ReplyAndReceive3"},
188 {0x4E, NULL, "ReplyAndReceive4"}, 216 {0x4E, NULL, "ReplyAndReceive4"},
189 {0x4F, NULL, "ReplyAndReceive"}, 217 {0x4F, NULL, "ReplyAndReceive"},
190 {0x50, NULL, "BindInterrupt"}, 218 {0x50, NULL, "BindInterrupt"},
191 {0x51, NULL, "UnbindInterrupt"}, 219 {0x51, NULL, "UnbindInterrupt"},
192 {0x52, NULL, "InvalidateProcessDataCache"}, 220 {0x52, NULL, "InvalidateProcessDataCache"},
193 {0x53, NULL, "StoreProcessDataCache"}, 221 {0x53, NULL, "StoreProcessDataCache"},
194 {0x54, NULL, "FlushProcessDataCache"}, 222 {0x54, NULL, "FlushProcessDataCache"},
195 {0x55, NULL, "StartInterProcessDma"}, 223 {0x55, NULL, "StartInterProcessDma"},
196 {0x56, NULL, "StopDma"}, 224 {0x56, NULL, "StopDma"},
197 {0x57, NULL, "GetDmaState"}, 225 {0x57, NULL, "GetDmaState"},
198 {0x58, NULL, "RestartDma"}, 226 {0x58, NULL, "RestartDma"},
199 {0x59, NULL, "Unknown"}, 227 {0x59, NULL, "Unknown"},
200 {0x5A, NULL, "Unknown"}, 228 {0x5A, NULL, "Unknown"},
201 {0x5B, NULL, "Unknown"}, 229 {0x5B, NULL, "Unknown"},
202 {0x5C, NULL, "Unknown"}, 230 {0x5C, NULL, "Unknown"},
203 {0x5D, NULL, "Unknown"}, 231 {0x5D, NULL, "Unknown"},
204 {0x5E, NULL, "Unknown"}, 232 {0x5E, NULL, "Unknown"},
205 {0x5F, NULL, "Unknown"}, 233 {0x5F, NULL, "Unknown"},
206 {0x60, NULL, "DebugActiveProcess"}, 234 {0x60, NULL, "DebugActiveProcess"},
207 {0x61, NULL, "BreakDebugProcess"}, 235 {0x61, NULL, "BreakDebugProcess"},
208 {0x62, NULL, "TerminateDebugProcess"}, 236 {0x62, NULL, "TerminateDebugProcess"},
209 {0x63, NULL, "GetProcessDebugEvent"}, 237 {0x63, NULL, "GetProcessDebugEvent"},
210 {0x64, NULL, "ContinueDebugEvent"}, 238 {0x64, NULL, "ContinueDebugEvent"},
211 {0x65, NULL, "GetProcessList"}, 239 {0x65, NULL, "GetProcessList"},
212 {0x66, NULL, "GetThreadList"}, 240 {0x66, NULL, "GetThreadList"},
213 {0x67, NULL, "GetDebugThreadContext"}, 241 {0x67, NULL, "GetDebugThreadContext"},
214 {0x68, NULL, "SetDebugThreadContext"}, 242 {0x68, NULL, "SetDebugThreadContext"},
215 {0x69, NULL, "QueryDebugProcessMemory"}, 243 {0x69, NULL, "QueryDebugProcessMemory"},
216 {0x6A, NULL, "ReadProcessMemory"}, 244 {0x6A, NULL, "ReadProcessMemory"},
217 {0x6B, NULL, "WriteProcessMemory"}, 245 {0x6B, NULL, "WriteProcessMemory"},
218 {0x6C, NULL, "SetHardwareBreakPoint"}, 246 {0x6C, NULL, "SetHardwareBreakPoint"},
219 {0x6D, NULL, "GetDebugThreadParam"}, 247 {0x6D, NULL, "GetDebugThreadParam"},
220 {0x6E, NULL, "Unknown"}, 248 {0x6E, NULL, "Unknown"},
221 {0x6F, NULL, "Unknown"}, 249 {0x6F, NULL, "Unknown"},
222 {0x70, NULL, "ControlProcessMemory"}, 250 {0x70, NULL, "ControlProcessMemory"},
223 {0x71, NULL, "MapProcessMemory"}, 251 {0x71, NULL, "MapProcessMemory"},
224 {0x72, NULL, "UnmapProcessMemory"}, 252 {0x72, NULL, "UnmapProcessMemory"},
225 {0x73, NULL, "Unknown"}, 253 {0x73, NULL, "Unknown"},
226 {0x74, NULL, "Unknown"}, 254 {0x74, NULL, "Unknown"},
227 {0x75, NULL, "Unknown"}, 255 {0x75, NULL, "Unknown"},
228 {0x76, NULL, "TerminateProcess"}, 256 {0x76, NULL, "TerminateProcess"},
229 {0x77, NULL, "Unknown"}, 257 {0x77, NULL, "Unknown"},
230 {0x78, NULL, "CreateResourceLimit"}, 258 {0x78, NULL, "CreateResourceLimit"},
231 {0x79, NULL, "Unknown"}, 259 {0x79, NULL, "Unknown"},
232 {0x7A, NULL, "Unknown"}, 260 {0x7A, NULL, "Unknown"},
233 {0x7B, NULL, "Unknown"}, 261 {0x7B, NULL, "Unknown"},
234 {0x7C, NULL, "KernelSetState"}, 262 {0x7C, NULL, "KernelSetState"},
235 {0x7D, NULL, "QueryProcessMemory"}, 263 {0x7D, NULL, "QueryProcessMemory"},
236}; 264};
237 265
238void Register() { 266void Register() {