diff options
| author | 2014-05-29 20:24:51 -0400 | |
|---|---|---|
| committer | 2014-05-29 20:24:51 -0400 | |
| commit | 58af0da792adab4bfd77699f9431050290a75b7c (patch) | |
| tree | c5fd0a1e179989e47110f388a530b3ccd540eec8 /src/core/hle/svc.cpp | |
| parent | event: added support for ClearEvent, fixed a bug with CreateEvent, fixed some... (diff) | |
| download | yuzu-58af0da792adab4bfd77699f9431050290a75b7c.tar.gz yuzu-58af0da792adab4bfd77699f9431050290a75b7c.tar.xz yuzu-58af0da792adab4bfd77699f9431050290a75b7c.zip | |
svc: added svcClearEvent, stubbed function for svcArbitrateAddress, and various fixes
- force kernel reschedule after svcWaitSynchronization
- fixed some bugs with passing in pointer arguments
- cleaned up some comments and log messages
Diffstat (limited to 'src/core/hle/svc.cpp')
| -rw-r--r-- | src/core/hle/svc.cpp | 54 |
1 files changed, 32 insertions, 22 deletions
diff --git a/src/core/hle/svc.cpp b/src/core/hle/svc.cpp index 8468c4fab..8ef894e68 100644 --- a/src/core/hle/svc.cpp +++ b/src/core/hle/svc.cpp | |||
| @@ -35,7 +35,6 @@ enum MapMemoryPermission { | |||
| 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* _outaddr, u32 operation, u32 addr0, u32 addr1, u32 size, u32 permissions) { |
| 38 | u32* outaddr = (u32*)_outaddr; | ||
| 39 | u32 virtual_address = 0x00000000; | 38 | u32 virtual_address = 0x00000000; |
| 40 | 39 | ||
| 41 | DEBUG_LOG(SVC, "ControlMemory called operation=0x%08X, addr0=0x%08X, addr1=0x%08X, size=%08X, permissions=0x%08X", | 40 | DEBUG_LOG(SVC, "ControlMemory called operation=0x%08X, addr0=0x%08X, addr1=0x%08X, size=%08X, permissions=0x%08X", |
| @@ -57,9 +56,7 @@ Result ControlMemory(void* _outaddr, u32 operation, u32 addr0, u32 addr1, u32 si | |||
| 57 | default: | 56 | default: |
| 58 | ERROR_LOG(SVC, "ControlMemory unknown operation=0x%08X", operation); | 57 | ERROR_LOG(SVC, "ControlMemory unknown operation=0x%08X", operation); |
| 59 | } | 58 | } |
| 60 | if (NULL != outaddr) { | 59 | |
| 61 | *outaddr = virtual_address; | ||
| 62 | } | ||
| 63 | Core::g_app_core->SetReg(1, virtual_address); | 60 | Core::g_app_core->SetReg(1, virtual_address); |
| 64 | 61 | ||
| 65 | return 0; | 62 | return 0; |
| @@ -82,7 +79,7 @@ Result MapMemoryBlock(Handle memblock, u32 addr, u32 mypermissions, u32 otherper | |||
| 82 | } | 79 | } |
| 83 | 80 | ||
| 84 | /// Connect to an OS service given the port name, returns the handle to the port to out | 81 | /// Connect to an OS service given the port name, returns the handle to the port to out |
| 85 | Result ConnectToPort(void* out, const char* port_name) { | 82 | Result ConnectToPort(void* _out, const char* port_name) { |
| 86 | Service::Interface* service = Service::g_manager->FetchFromPortName(port_name); | 83 | Service::Interface* service = Service::g_manager->FetchFromPortName(port_name); |
| 87 | DEBUG_LOG(SVC, "ConnectToPort called port_name=%s", port_name); | 84 | DEBUG_LOG(SVC, "ConnectToPort called port_name=%s", port_name); |
| 88 | _assert_msg_(KERNEL, service, "ConnectToPort called, but service is not implemented!"); | 85 | _assert_msg_(KERNEL, service, "ConnectToPort called, but service is not implemented!"); |
| @@ -128,6 +125,7 @@ Result WaitSynchronization1(Handle handle, s64 nano_seconds) { | |||
| 128 | 125 | ||
| 129 | if (wait) { | 126 | if (wait) { |
| 130 | Kernel::WaitCurrentThread(WAITTYPE_SYNCH); // TODO(bunnei): Is this correct? | 127 | Kernel::WaitCurrentThread(WAITTYPE_SYNCH); // TODO(bunnei): Is this correct? |
| 128 | Kernel::Reschedule(); | ||
| 131 | } | 129 | } |
| 132 | 130 | ||
| 133 | return res; | 131 | return res; |
| @@ -138,7 +136,6 @@ Result WaitSynchronizationN(void* _out, void* _handles, u32 handle_count, u32 wa | |||
| 138 | s64 nano_seconds) { | 136 | s64 nano_seconds) { |
| 139 | // TODO(bunnei): Do something with nano_seconds, currently ignoring this | 137 | // TODO(bunnei): Do something with nano_seconds, currently ignoring this |
| 140 | 138 | ||
| 141 | s32* out = (s32*)_out; | ||
| 142 | Handle* handles = (Handle*)_handles; | 139 | Handle* handles = (Handle*)_handles; |
| 143 | bool unlock_all = true; | 140 | bool unlock_all = true; |
| 144 | 141 | ||
| @@ -153,6 +150,8 @@ Result WaitSynchronizationN(void* _out, void* _handles, u32 handle_count, u32 wa | |||
| 153 | _assert_msg_(KERNEL, object, "WaitSynchronizationN called handle=0x%08X, but kernel object " | 150 | _assert_msg_(KERNEL, object, "WaitSynchronizationN called handle=0x%08X, but kernel object " |
| 154 | "is NULL!", handles[i]); | 151 | "is NULL!", handles[i]); |
| 155 | 152 | ||
| 153 | DEBUG_LOG(SVC, "\thandle[%d] = 0x%08X", i, handles[i]); | ||
| 154 | |||
| 156 | Result res = object->WaitSynchronization(&wait); | 155 | Result res = object->WaitSynchronization(&wait); |
| 157 | 156 | ||
| 158 | if (!wait && !wait_all) { | 157 | if (!wait && !wait_all) { |
| @@ -170,18 +169,26 @@ Result WaitSynchronizationN(void* _out, void* _handles, u32 handle_count, u32 wa | |||
| 170 | 169 | ||
| 171 | // Set current thread to wait state if not all handles were unlocked | 170 | // Set current thread to wait state if not all handles were unlocked |
| 172 | Kernel::WaitCurrentThread(WAITTYPE_SYNCH); // TODO(bunnei): Is this correct? | 171 | Kernel::WaitCurrentThread(WAITTYPE_SYNCH); // TODO(bunnei): Is this correct? |
| 172 | Kernel::Reschedule(); | ||
| 173 | 173 | ||
| 174 | return 0; | 174 | return 0; |
| 175 | } | 175 | } |
| 176 | 176 | ||
| 177 | /// Create an address arbiter (to allocate access to shared resources) | 177 | /// Create an address arbiter (to allocate access to shared resources) |
| 178 | Result CreateAddressArbiter(void* arbiter) { | 178 | Result CreateAddressArbiter(void* arbiter) { |
| 179 | // ImplementMe | ||
| 180 | DEBUG_LOG(SVC, "(UNIMPLEMENTED) CreateAddressArbiter called"); | 179 | DEBUG_LOG(SVC, "(UNIMPLEMENTED) CreateAddressArbiter called"); |
| 181 | Core::g_app_core->SetReg(1, 0xFABBDADD); | 180 | Core::g_app_core->SetReg(1, 0xFABBDADD); |
| 182 | return 0; | 181 | return 0; |
| 183 | } | 182 | } |
| 184 | 183 | ||
| 184 | /// Arbitrate address | ||
| 185 | Result ArbitrateAddress(Handle arbiter, u32 addr, u32 _type, u32 value, s64 nanoseconds) { | ||
| 186 | DEBUG_LOG(SVC, "(UNIMPLEMENTED) ArbitrateAddress called"); | ||
| 187 | ArbitrationType type = (ArbitrationType)_type; | ||
| 188 | Memory::Write32(addr, type); | ||
| 189 | return 0; | ||
| 190 | } | ||
| 191 | |||
| 185 | /// Used to output a message on a debug hardware unit - does nothing on a retail unit | 192 | /// Used to output a message on a debug hardware unit - does nothing on a retail unit |
| 186 | void OutputDebugString(const char* string) { | 193 | void OutputDebugString(const char* string) { |
| 187 | NOTICE_LOG(SVC, "## OSDEBUG: %08X %s", Core::g_app_core->GetPC(), string); | 194 | NOTICE_LOG(SVC, "## OSDEBUG: %08X %s", Core::g_app_core->GetPC(), string); |
| @@ -199,7 +206,6 @@ Result GetResourceLimit(void* resource_limit, Handle process) { | |||
| 199 | 206 | ||
| 200 | /// Get resource limit current values | 207 | /// Get resource limit current values |
| 201 | Result GetResourceLimitCurrentValues(void* _values, Handle resource_limit, void* names, s32 name_count) { | 208 | Result GetResourceLimitCurrentValues(void* _values, Handle resource_limit, void* names, s32 name_count) { |
| 202 | //s64* values = (s64*)_values; | ||
| 203 | DEBUG_LOG(SVC, "(UNIMPLEMENTED) GetResourceLimitCurrentValues called resource_limit=%08X, names=%s, name_count=%d", | 209 | DEBUG_LOG(SVC, "(UNIMPLEMENTED) GetResourceLimitCurrentValues called resource_limit=%08X, names=%s, name_count=%d", |
| 204 | resource_limit, names, name_count); | 210 | resource_limit, names, name_count); |
| 205 | Memory::Write32(Core::g_app_core->GetReg(0), 0); // Normmatt: Set used memory to 0 for now | 211 | Memory::Write32(Core::g_app_core->GetReg(0), 0); // Normmatt: Set used memory to 0 for now |
| @@ -224,7 +230,7 @@ Result CreateThread(u32 priority, u32 entry_point, u32 arg, u32 stack_top, u32 p | |||
| 224 | Core::g_app_core->SetReg(1, thread); | 230 | Core::g_app_core->SetReg(1, thread); |
| 225 | 231 | ||
| 226 | DEBUG_LOG(SVC, "CreateThread called entrypoint=0x%08X (%s), arg=0x%08X, stacktop=0x%08X, " | 232 | DEBUG_LOG(SVC, "CreateThread called entrypoint=0x%08X (%s), arg=0x%08X, stacktop=0x%08X, " |
| 227 | "threadpriority=0x%08X, processorid=0x%08X : created handle 0x%08X", entry_point, | 233 | "threadpriority=0x%08X, processorid=0x%08X : created handle=0x%08X", entry_point, |
| 228 | name.c_str(), arg, stack_top, priority, processor_id, thread); | 234 | name.c_str(), arg, stack_top, priority, processor_id, thread); |
| 229 | 235 | ||
| 230 | return 0; | 236 | return 0; |
| @@ -232,11 +238,10 @@ Result CreateThread(u32 priority, u32 entry_point, u32 arg, u32 stack_top, u32 p | |||
| 232 | 238 | ||
| 233 | /// Create a mutex | 239 | /// Create a mutex |
| 234 | Result CreateMutex(void* _mutex, u32 initial_locked) { | 240 | Result CreateMutex(void* _mutex, u32 initial_locked) { |
| 235 | Handle* mutex = (Handle*)_mutex; | 241 | Handle mutex = Kernel::CreateMutex((initial_locked != 0)); |
| 236 | DEBUG_LOG(SVC, "CreateMutex called initial_locked=%s : created handle 0x%08X", | 242 | Core::g_app_core->SetReg(1, mutex); |
| 237 | initial_locked ? "true" : "false", *mutex); | 243 | DEBUG_LOG(SVC, "CreateMutex called initial_locked=%s : created handle=0x%08X", |
| 238 | *mutex = Kernel::CreateMutex((initial_locked != 0)); | 244 | initial_locked ? "true" : "false", mutex); |
| 239 | Core::g_app_core->SetReg(1, *mutex); | ||
| 240 | return 0; | 245 | return 0; |
| 241 | } | 246 | } |
| 242 | 247 | ||
| @@ -256,18 +261,16 @@ Result GetThreadId(void* thread_id, u32 thread) { | |||
| 256 | 261 | ||
| 257 | /// Query memory | 262 | /// Query memory |
| 258 | Result QueryMemory(void *_info, void *_out, u32 addr) { | 263 | Result QueryMemory(void *_info, void *_out, u32 addr) { |
| 259 | MemoryInfo* info = (MemoryInfo*) _info; | ||
| 260 | PageInfo* out = (PageInfo*) _out; | ||
| 261 | DEBUG_LOG(SVC, "(UNIMPLEMENTED) QueryMemory called addr=0x%08X", addr); | 264 | DEBUG_LOG(SVC, "(UNIMPLEMENTED) QueryMemory called addr=0x%08X", addr); |
| 262 | return 0; | 265 | return 0; |
| 263 | } | 266 | } |
| 264 | 267 | ||
| 265 | /// Create an event | 268 | /// Create an event |
| 266 | Result CreateEvent(void* _event, u32 reset_type) { | 269 | Result CreateEvent(void* _event, u32 reset_type) { |
| 267 | Handle* evt = (Handle*)_event; | 270 | Handle evt = Kernel::CreateEvent((ResetType)reset_type); |
| 268 | DEBUG_LOG(SVC, "CreateEvent called reset_type=0x%08X", reset_type); | 271 | Core::g_app_core->SetReg(1, evt); |
| 269 | *evt = Kernel::CreateEvent((ResetType)reset_type); | 272 | DEBUG_LOG(SVC, "CreateEvent called reset_type=0x%08X : created handle=0x%08X", |
| 270 | Core::g_app_core->SetReg(1, *evt); | 273 | reset_type, evt); |
| 271 | return 0; | 274 | return 0; |
| 272 | } | 275 | } |
| 273 | 276 | ||
| @@ -278,6 +281,13 @@ Result DuplicateHandle(void* _out, Handle handle) { | |||
| 278 | return 0; | 281 | return 0; |
| 279 | } | 282 | } |
| 280 | 283 | ||
| 284 | /// Clears an event | ||
| 285 | Result ClearEvent(Handle evt) { | ||
| 286 | Result res = Kernel::ClearEvent(evt); | ||
| 287 | DEBUG_LOG(SVC, "ClearEvent called event=0x%08X", evt); | ||
| 288 | return res; | ||
| 289 | } | ||
| 290 | |||
| 281 | const HLE::FunctionDef SVC_Table[] = { | 291 | const HLE::FunctionDef SVC_Table[] = { |
| 282 | {0x00, NULL, "Unknown"}, | 292 | {0x00, NULL, "Unknown"}, |
| 283 | {0x01, WrapI_VUUUUU<ControlMemory>, "ControlMemory"}, | 293 | {0x01, WrapI_VUUUUU<ControlMemory>, "ControlMemory"}, |
| @@ -304,7 +314,7 @@ const HLE::FunctionDef SVC_Table[] = { | |||
| 304 | {0x16, NULL, "ReleaseSemaphore"}, | 314 | {0x16, NULL, "ReleaseSemaphore"}, |
| 305 | {0x17, WrapI_VU<CreateEvent>, "CreateEvent"}, | 315 | {0x17, WrapI_VU<CreateEvent>, "CreateEvent"}, |
| 306 | {0x18, NULL, "SignalEvent"}, | 316 | {0x18, NULL, "SignalEvent"}, |
| 307 | {0x19, NULL, "ClearEvent"}, | 317 | {0x19, WrapI_U<ClearEvent>, "ClearEvent"}, |
| 308 | {0x1A, NULL, "CreateTimer"}, | 318 | {0x1A, NULL, "CreateTimer"}, |
| 309 | {0x1B, NULL, "SetTimer"}, | 319 | {0x1B, NULL, "SetTimer"}, |
| 310 | {0x1C, NULL, "CancelTimer"}, | 320 | {0x1C, NULL, "CancelTimer"}, |
| @@ -313,7 +323,7 @@ const HLE::FunctionDef SVC_Table[] = { | |||
| 313 | {0x1F, WrapI_UUUU<MapMemoryBlock>, "MapMemoryBlock"}, | 323 | {0x1F, WrapI_UUUU<MapMemoryBlock>, "MapMemoryBlock"}, |
| 314 | {0x20, NULL, "UnmapMemoryBlock"}, | 324 | {0x20, NULL, "UnmapMemoryBlock"}, |
| 315 | {0x21, WrapI_V<CreateAddressArbiter>, "CreateAddressArbiter"}, | 325 | {0x21, WrapI_V<CreateAddressArbiter>, "CreateAddressArbiter"}, |
| 316 | {0x22, NULL, "ArbitrateAddress"}, | 326 | {0x22, WrapI_UUUUS64<ArbitrateAddress>, "ArbitrateAddress"}, |
| 317 | {0x23, WrapI_U<CloseHandle>, "CloseHandle"}, | 327 | {0x23, WrapI_U<CloseHandle>, "CloseHandle"}, |
| 318 | {0x24, WrapI_US64<WaitSynchronization1>, "WaitSynchronization1"}, | 328 | {0x24, WrapI_US64<WaitSynchronization1>, "WaitSynchronization1"}, |
| 319 | {0x25, WrapI_VVUUS64<WaitSynchronizationN>, "WaitSynchronizationN"}, | 329 | {0x25, WrapI_VVUUS64<WaitSynchronizationN>, "WaitSynchronizationN"}, |