diff options
Diffstat (limited to 'src/core/hle/kernel/svc.cpp')
| -rw-r--r-- | src/core/hle/kernel/svc.cpp | 329 |
1 files changed, 264 insertions, 65 deletions
diff --git a/src/core/hle/kernel/svc.cpp b/src/core/hle/kernel/svc.cpp index fd91779a3..4ffc113c2 100644 --- a/src/core/hle/kernel/svc.cpp +++ b/src/core/hle/kernel/svc.cpp | |||
| @@ -187,6 +187,13 @@ static ResultCode SetHeapSize(Core::System& system, VAddr* heap_addr, u64 heap_s | |||
| 187 | return RESULT_SUCCESS; | 187 | return RESULT_SUCCESS; |
| 188 | } | 188 | } |
| 189 | 189 | ||
| 190 | static ResultCode SetHeapSize32(Core::System& system, u32* heap_addr, u32 heap_size) { | ||
| 191 | VAddr temp_heap_addr{}; | ||
| 192 | const ResultCode result{SetHeapSize(system, &temp_heap_addr, heap_size)}; | ||
| 193 | *heap_addr = static_cast<u32>(temp_heap_addr); | ||
| 194 | return result; | ||
| 195 | } | ||
| 196 | |||
| 190 | static ResultCode SetMemoryPermission(Core::System& system, VAddr addr, u64 size, u32 prot) { | 197 | static ResultCode SetMemoryPermission(Core::System& system, VAddr addr, u64 size, u32 prot) { |
| 191 | LOG_TRACE(Kernel_SVC, "called, addr=0x{:X}, size=0x{:X}, prot=0x{:X}", addr, size, prot); | 198 | LOG_TRACE(Kernel_SVC, "called, addr=0x{:X}, size=0x{:X}, prot=0x{:X}", addr, size, prot); |
| 192 | 199 | ||
| @@ -371,6 +378,12 @@ static ResultCode ConnectToNamedPort(Core::System& system, Handle* out_handle, | |||
| 371 | return RESULT_SUCCESS; | 378 | return RESULT_SUCCESS; |
| 372 | } | 379 | } |
| 373 | 380 | ||
| 381 | static ResultCode ConnectToNamedPort32(Core::System& system, Handle* out_handle, | ||
| 382 | u32 port_name_address) { | ||
| 383 | |||
| 384 | return ConnectToNamedPort(system, out_handle, port_name_address); | ||
| 385 | } | ||
| 386 | |||
| 374 | /// Makes a blocking IPC call to an OS service. | 387 | /// Makes a blocking IPC call to an OS service. |
| 375 | static ResultCode SendSyncRequest(Core::System& system, Handle handle) { | 388 | static ResultCode SendSyncRequest(Core::System& system, Handle handle) { |
| 376 | const auto& handle_table = system.Kernel().CurrentProcess()->GetHandleTable(); | 389 | const auto& handle_table = system.Kernel().CurrentProcess()->GetHandleTable(); |
| @@ -390,6 +403,10 @@ static ResultCode SendSyncRequest(Core::System& system, Handle handle) { | |||
| 390 | return session->SendSyncRequest(SharedFrom(thread), system.Memory()); | 403 | return session->SendSyncRequest(SharedFrom(thread), system.Memory()); |
| 391 | } | 404 | } |
| 392 | 405 | ||
| 406 | static ResultCode SendSyncRequest32(Core::System& system, Handle handle) { | ||
| 407 | return SendSyncRequest(system, handle); | ||
| 408 | } | ||
| 409 | |||
| 393 | /// Get the ID for the specified thread. | 410 | /// Get the ID for the specified thread. |
| 394 | static ResultCode GetThreadId(Core::System& system, u64* thread_id, Handle thread_handle) { | 411 | static ResultCode GetThreadId(Core::System& system, u64* thread_id, Handle thread_handle) { |
| 395 | LOG_TRACE(Kernel_SVC, "called thread=0x{:08X}", thread_handle); | 412 | LOG_TRACE(Kernel_SVC, "called thread=0x{:08X}", thread_handle); |
| @@ -405,6 +422,17 @@ static ResultCode GetThreadId(Core::System& system, u64* thread_id, Handle threa | |||
| 405 | return RESULT_SUCCESS; | 422 | return RESULT_SUCCESS; |
| 406 | } | 423 | } |
| 407 | 424 | ||
| 425 | static ResultCode GetThreadId32(Core::System& system, u32* thread_id_low, u32* thread_id_high, | ||
| 426 | Handle thread_handle) { | ||
| 427 | u64 thread_id{}; | ||
| 428 | const ResultCode result{GetThreadId(system, &thread_id, thread_handle)}; | ||
| 429 | |||
| 430 | *thread_id_low = static_cast<u32>(thread_id >> 32); | ||
| 431 | *thread_id_high = static_cast<u32>(thread_id & std::numeric_limits<u32>::max()); | ||
| 432 | |||
| 433 | return result; | ||
| 434 | } | ||
| 435 | |||
| 408 | /// Gets the ID of the specified process or a specified thread's owning process. | 436 | /// Gets the ID of the specified process or a specified thread's owning process. |
| 409 | static ResultCode GetProcessId(Core::System& system, u64* process_id, Handle handle) { | 437 | static ResultCode GetProcessId(Core::System& system, u64* process_id, Handle handle) { |
| 410 | LOG_DEBUG(Kernel_SVC, "called handle=0x{:08X}", handle); | 438 | LOG_DEBUG(Kernel_SVC, "called handle=0x{:08X}", handle); |
| @@ -479,6 +507,12 @@ static ResultCode WaitSynchronization(Core::System& system, Handle* index, VAddr | |||
| 479 | return result; | 507 | return result; |
| 480 | } | 508 | } |
| 481 | 509 | ||
| 510 | static ResultCode WaitSynchronization32(Core::System& system, u32 timeout_low, u32 handles_address, | ||
| 511 | s32 handle_count, u32 timeout_high, Handle* index) { | ||
| 512 | const s64 nano_seconds{(static_cast<s64>(timeout_high) << 32) | static_cast<s64>(timeout_low)}; | ||
| 513 | return WaitSynchronization(system, index, handles_address, handle_count, nano_seconds); | ||
| 514 | } | ||
| 515 | |||
| 482 | /// Resumes a thread waiting on WaitSynchronization | 516 | /// Resumes a thread waiting on WaitSynchronization |
| 483 | static ResultCode CancelSynchronization(Core::System& system, Handle thread_handle) { | 517 | static ResultCode CancelSynchronization(Core::System& system, Handle thread_handle) { |
| 484 | LOG_TRACE(Kernel_SVC, "called thread=0x{:X}", thread_handle); | 518 | LOG_TRACE(Kernel_SVC, "called thread=0x{:X}", thread_handle); |
| @@ -917,6 +951,18 @@ static ResultCode GetInfo(Core::System& system, u64* result, u64 info_id, u64 ha | |||
| 917 | } | 951 | } |
| 918 | } | 952 | } |
| 919 | 953 | ||
| 954 | static ResultCode GetInfo32(Core::System& system, u32* result_low, u32* result_high, u32 sub_id_low, | ||
| 955 | u32 info_id, u32 handle, u32 sub_id_high) { | ||
| 956 | const u64 sub_id{static_cast<u64>(sub_id_low | (static_cast<u64>(sub_id_high) << 32))}; | ||
| 957 | u64 res_value{}; | ||
| 958 | |||
| 959 | const ResultCode result{GetInfo(system, &res_value, info_id, handle, sub_id)}; | ||
| 960 | *result_high = static_cast<u32>(res_value >> 32); | ||
| 961 | *result_low = static_cast<u32>(res_value & std::numeric_limits<u32>::max()); | ||
| 962 | |||
| 963 | return result; | ||
| 964 | } | ||
| 965 | |||
| 920 | /// Maps memory at a desired address | 966 | /// Maps memory at a desired address |
| 921 | static ResultCode MapPhysicalMemory(Core::System& system, VAddr addr, u64 size) { | 967 | static ResultCode MapPhysicalMemory(Core::System& system, VAddr addr, u64 size) { |
| 922 | LOG_DEBUG(Kernel_SVC, "called, addr=0x{:016X}, size=0x{:X}", addr, size); | 968 | LOG_DEBUG(Kernel_SVC, "called, addr=0x{:016X}, size=0x{:X}", addr, size); |
| @@ -1058,7 +1104,7 @@ static ResultCode GetThreadContext(Core::System& system, VAddr thread_context, H | |||
| 1058 | return ERR_BUSY; | 1104 | return ERR_BUSY; |
| 1059 | } | 1105 | } |
| 1060 | 1106 | ||
| 1061 | Core::ARM_Interface::ThreadContext ctx = thread->GetContext(); | 1107 | Core::ARM_Interface::ThreadContext64 ctx = thread->GetContext64(); |
| 1062 | // Mask away mode bits, interrupt bits, IL bit, and other reserved bits. | 1108 | // Mask away mode bits, interrupt bits, IL bit, and other reserved bits. |
| 1063 | ctx.pstate &= 0xFF0FFE20; | 1109 | ctx.pstate &= 0xFF0FFE20; |
| 1064 | 1110 | ||
| @@ -1088,6 +1134,10 @@ static ResultCode GetThreadPriority(Core::System& system, u32* priority, Handle | |||
| 1088 | return RESULT_SUCCESS; | 1134 | return RESULT_SUCCESS; |
| 1089 | } | 1135 | } |
| 1090 | 1136 | ||
| 1137 | static ResultCode GetThreadPriority32(Core::System& system, u32* priority, Handle handle) { | ||
| 1138 | return GetThreadPriority(system, priority, handle); | ||
| 1139 | } | ||
| 1140 | |||
| 1091 | /// Sets the priority for the specified thread | 1141 | /// Sets the priority for the specified thread |
| 1092 | static ResultCode SetThreadPriority(Core::System& system, Handle handle, u32 priority) { | 1142 | static ResultCode SetThreadPriority(Core::System& system, Handle handle, u32 priority) { |
| 1093 | LOG_TRACE(Kernel_SVC, "called"); | 1143 | LOG_TRACE(Kernel_SVC, "called"); |
| @@ -1259,6 +1309,11 @@ static ResultCode QueryMemory(Core::System& system, VAddr memory_info_address, | |||
| 1259 | query_address); | 1309 | query_address); |
| 1260 | } | 1310 | } |
| 1261 | 1311 | ||
| 1312 | static ResultCode QueryMemory32(Core::System& system, u32 memory_info_address, | ||
| 1313 | u32 page_info_address, u32 query_address) { | ||
| 1314 | return QueryMemory(system, memory_info_address, page_info_address, query_address); | ||
| 1315 | } | ||
| 1316 | |||
| 1262 | static ResultCode MapProcessCodeMemory(Core::System& system, Handle process_handle, u64 dst_address, | 1317 | static ResultCode MapProcessCodeMemory(Core::System& system, Handle process_handle, u64 dst_address, |
| 1263 | u64 src_address, u64 size) { | 1318 | u64 src_address, u64 size) { |
| 1264 | LOG_DEBUG(Kernel_SVC, | 1319 | LOG_DEBUG(Kernel_SVC, |
| @@ -1675,6 +1730,10 @@ static void SignalProcessWideKey(Core::System& system, VAddr condition_variable_ | |||
| 1675 | } | 1730 | } |
| 1676 | } | 1731 | } |
| 1677 | 1732 | ||
| 1733 | static void SignalProcessWideKey32(Core::System& system, u32 condition_variable_addr, s32 target) { | ||
| 1734 | SignalProcessWideKey(system, condition_variable_addr, target); | ||
| 1735 | } | ||
| 1736 | |||
| 1678 | // Wait for an address (via Address Arbiter) | 1737 | // Wait for an address (via Address Arbiter) |
| 1679 | static ResultCode WaitForAddress(Core::System& system, VAddr address, u32 type, s32 value, | 1738 | static ResultCode WaitForAddress(Core::System& system, VAddr address, u32 type, s32 value, |
| 1680 | s64 timeout) { | 1739 | s64 timeout) { |
| @@ -1760,6 +1819,10 @@ static ResultCode CloseHandle(Core::System& system, Handle handle) { | |||
| 1760 | return handle_table.Close(handle); | 1819 | return handle_table.Close(handle); |
| 1761 | } | 1820 | } |
| 1762 | 1821 | ||
| 1822 | static ResultCode CloseHandle32(Core::System& system, Handle handle) { | ||
| 1823 | return CloseHandle(system, handle); | ||
| 1824 | } | ||
| 1825 | |||
| 1763 | /// Clears the signaled state of an event or process. | 1826 | /// Clears the signaled state of an event or process. |
| 1764 | static ResultCode ResetSignal(Core::System& system, Handle handle) { | 1827 | static ResultCode ResetSignal(Core::System& system, Handle handle) { |
| 1765 | LOG_DEBUG(Kernel_SVC, "called handle 0x{:08X}", handle); | 1828 | LOG_DEBUG(Kernel_SVC, "called handle 0x{:08X}", handle); |
| @@ -2317,69 +2380,196 @@ struct FunctionDef { | |||
| 2317 | }; | 2380 | }; |
| 2318 | } // namespace | 2381 | } // namespace |
| 2319 | 2382 | ||
| 2320 | static const FunctionDef SVC_Table[] = { | 2383 | static const FunctionDef SVC_Table_32[] = { |
| 2321 | {0x00, nullptr, "Unknown"}, | 2384 | {0x00, nullptr, "Unknown"}, |
| 2322 | {0x01, SvcWrap<SetHeapSize>, "SetHeapSize"}, | 2385 | {0x01, SvcWrap32<SetHeapSize32>, "SetHeapSize32"}, |
| 2323 | {0x02, SvcWrap<SetMemoryPermission>, "SetMemoryPermission"}, | 2386 | {0x02, nullptr, "Unknown"}, |
| 2324 | {0x03, SvcWrap<SetMemoryAttribute>, "SetMemoryAttribute"}, | 2387 | {0x03, nullptr, "SetMemoryAttribute32"}, |
| 2325 | {0x04, SvcWrap<MapMemory>, "MapMemory"}, | 2388 | {0x04, nullptr, "MapMemory32"}, |
| 2326 | {0x05, SvcWrap<UnmapMemory>, "UnmapMemory"}, | 2389 | {0x05, nullptr, "UnmapMemory32"}, |
| 2327 | {0x06, SvcWrap<QueryMemory>, "QueryMemory"}, | 2390 | {0x06, SvcWrap32<QueryMemory32>, "QueryMemory32"}, |
| 2328 | {0x07, SvcWrap<ExitProcess>, "ExitProcess"}, | 2391 | {0x07, nullptr, "ExitProcess32"}, |
| 2329 | {0x08, SvcWrap<CreateThread>, "CreateThread"}, | 2392 | {0x08, nullptr, "CreateThread32"}, |
| 2330 | {0x09, SvcWrap<StartThread>, "StartThread"}, | 2393 | {0x09, nullptr, "StartThread32"}, |
| 2331 | {0x0A, SvcWrap<ExitThread>, "ExitThread"}, | 2394 | {0x0a, nullptr, "ExitThread32"}, |
| 2332 | {0x0B, SvcWrap<SleepThread>, "SleepThread"}, | 2395 | {0x0b, nullptr, "SleepThread32"}, |
| 2333 | {0x0C, SvcWrap<GetThreadPriority>, "GetThreadPriority"}, | 2396 | {0x0c, SvcWrap32<GetThreadPriority32>, "GetThreadPriority32"}, |
| 2334 | {0x0D, SvcWrap<SetThreadPriority>, "SetThreadPriority"}, | 2397 | {0x0d, nullptr, "SetThreadPriority32"}, |
| 2335 | {0x0E, SvcWrap<GetThreadCoreMask>, "GetThreadCoreMask"}, | 2398 | {0x0e, nullptr, "GetThreadCoreMask32"}, |
| 2336 | {0x0F, SvcWrap<SetThreadCoreMask>, "SetThreadCoreMask"}, | 2399 | {0x0f, nullptr, "SetThreadCoreMask32"}, |
| 2337 | {0x10, SvcWrap<GetCurrentProcessorNumber>, "GetCurrentProcessorNumber"}, | 2400 | {0x10, nullptr, "GetCurrentProcessorNumber32"}, |
| 2338 | {0x11, SvcWrap<SignalEvent>, "SignalEvent"}, | 2401 | {0x11, nullptr, "SignalEvent32"}, |
| 2339 | {0x12, SvcWrap<ClearEvent>, "ClearEvent"}, | 2402 | {0x12, nullptr, "ClearEvent32"}, |
| 2340 | {0x13, SvcWrap<MapSharedMemory>, "MapSharedMemory"}, | 2403 | {0x13, nullptr, "MapSharedMemory32"}, |
| 2341 | {0x14, SvcWrap<UnmapSharedMemory>, "UnmapSharedMemory"}, | 2404 | {0x14, nullptr, "UnmapSharedMemory32"}, |
| 2342 | {0x15, SvcWrap<CreateTransferMemory>, "CreateTransferMemory"}, | 2405 | {0x15, nullptr, "CreateTransferMemory32"}, |
| 2343 | {0x16, SvcWrap<CloseHandle>, "CloseHandle"}, | 2406 | {0x16, SvcWrap32<CloseHandle32>, "CloseHandle32"}, |
| 2344 | {0x17, SvcWrap<ResetSignal>, "ResetSignal"}, | 2407 | {0x17, nullptr, "ResetSignal32"}, |
| 2345 | {0x18, SvcWrap<WaitSynchronization>, "WaitSynchronization"}, | 2408 | {0x18, SvcWrap32<WaitSynchronization32>, "WaitSynchronization32"}, |
| 2346 | {0x19, SvcWrap<CancelSynchronization>, "CancelSynchronization"}, | 2409 | {0x19, nullptr, "CancelSynchronization32"}, |
| 2347 | {0x1A, SvcWrap<ArbitrateLock>, "ArbitrateLock"}, | 2410 | {0x1a, nullptr, "ArbitrateLock32"}, |
| 2348 | {0x1B, SvcWrap<ArbitrateUnlock>, "ArbitrateUnlock"}, | 2411 | {0x1b, nullptr, "ArbitrateUnlock32"}, |
| 2349 | {0x1C, SvcWrap<WaitProcessWideKeyAtomic>, "WaitProcessWideKeyAtomic"}, | 2412 | {0x1c, nullptr, "WaitProcessWideKeyAtomic32"}, |
| 2350 | {0x1D, SvcWrap<SignalProcessWideKey>, "SignalProcessWideKey"}, | 2413 | {0x1d, SvcWrap32<SignalProcessWideKey32>, "SignalProcessWideKey32"}, |
| 2351 | {0x1E, SvcWrap<GetSystemTick>, "GetSystemTick"}, | 2414 | {0x1e, nullptr, "GetSystemTick32"}, |
| 2352 | {0x1F, SvcWrap<ConnectToNamedPort>, "ConnectToNamedPort"}, | 2415 | {0x1f, SvcWrap32<ConnectToNamedPort32>, "ConnectToNamedPort32"}, |
| 2416 | {0x20, nullptr, "Unknown"}, | ||
| 2417 | {0x21, SvcWrap32<SendSyncRequest32>, "SendSyncRequest32"}, | ||
| 2418 | {0x22, nullptr, "SendSyncRequestWithUserBuffer32"}, | ||
| 2419 | {0x23, nullptr, "Unknown"}, | ||
| 2420 | {0x24, nullptr, "GetProcessId32"}, | ||
| 2421 | {0x25, SvcWrap32<GetThreadId32>, "GetThreadId32"}, | ||
| 2422 | {0x26, nullptr, "Break32"}, | ||
| 2423 | {0x27, nullptr, "OutputDebugString32"}, | ||
| 2424 | {0x28, nullptr, "Unknown"}, | ||
| 2425 | {0x29, SvcWrap32<GetInfo32>, "GetInfo32"}, | ||
| 2426 | {0x2a, nullptr, "Unknown"}, | ||
| 2427 | {0x2b, nullptr, "Unknown"}, | ||
| 2428 | {0x2c, nullptr, "MapPhysicalMemory32"}, | ||
| 2429 | {0x2d, nullptr, "UnmapPhysicalMemory32"}, | ||
| 2430 | {0x2e, nullptr, "Unknown"}, | ||
| 2431 | {0x2f, nullptr, "Unknown"}, | ||
| 2432 | {0x30, nullptr, "Unknown"}, | ||
| 2433 | {0x31, nullptr, "Unknown"}, | ||
| 2434 | {0x32, nullptr, "SetThreadActivity32"}, | ||
| 2435 | {0x33, nullptr, "GetThreadContext32"}, | ||
| 2436 | {0x34, nullptr, "WaitForAddress32"}, | ||
| 2437 | {0x35, nullptr, "SignalToAddress32"}, | ||
| 2438 | {0x36, nullptr, "Unknown"}, | ||
| 2439 | {0x37, nullptr, "Unknown"}, | ||
| 2440 | {0x38, nullptr, "Unknown"}, | ||
| 2441 | {0x39, nullptr, "Unknown"}, | ||
| 2442 | {0x3a, nullptr, "Unknown"}, | ||
| 2443 | {0x3b, nullptr, "Unknown"}, | ||
| 2444 | {0x3c, nullptr, "Unknown"}, | ||
| 2445 | {0x3d, nullptr, "Unknown"}, | ||
| 2446 | {0x3e, nullptr, "Unknown"}, | ||
| 2447 | {0x3f, nullptr, "Unknown"}, | ||
| 2448 | {0x40, nullptr, "CreateSession32"}, | ||
| 2449 | {0x41, nullptr, "AcceptSession32"}, | ||
| 2450 | {0x42, nullptr, "Unknown"}, | ||
| 2451 | {0x43, nullptr, "ReplyAndReceive32"}, | ||
| 2452 | {0x44, nullptr, "Unknown"}, | ||
| 2453 | {0x45, nullptr, "CreateEvent32"}, | ||
| 2454 | {0x46, nullptr, "Unknown"}, | ||
| 2455 | {0x47, nullptr, "Unknown"}, | ||
| 2456 | {0x48, nullptr, "Unknown"}, | ||
| 2457 | {0x49, nullptr, "Unknown"}, | ||
| 2458 | {0x4a, nullptr, "Unknown"}, | ||
| 2459 | {0x4b, nullptr, "Unknown"}, | ||
| 2460 | {0x4c, nullptr, "Unknown"}, | ||
| 2461 | {0x4d, nullptr, "Unknown"}, | ||
| 2462 | {0x4e, nullptr, "Unknown"}, | ||
| 2463 | {0x4f, nullptr, "Unknown"}, | ||
| 2464 | {0x50, nullptr, "Unknown"}, | ||
| 2465 | {0x51, nullptr, "Unknown"}, | ||
| 2466 | {0x52, nullptr, "Unknown"}, | ||
| 2467 | {0x53, nullptr, "Unknown"}, | ||
| 2468 | {0x54, nullptr, "Unknown"}, | ||
| 2469 | {0x55, nullptr, "Unknown"}, | ||
| 2470 | {0x56, nullptr, "Unknown"}, | ||
| 2471 | {0x57, nullptr, "Unknown"}, | ||
| 2472 | {0x58, nullptr, "Unknown"}, | ||
| 2473 | {0x59, nullptr, "Unknown"}, | ||
| 2474 | {0x5a, nullptr, "Unknown"}, | ||
| 2475 | {0x5b, nullptr, "Unknown"}, | ||
| 2476 | {0x5c, nullptr, "Unknown"}, | ||
| 2477 | {0x5d, nullptr, "Unknown"}, | ||
| 2478 | {0x5e, nullptr, "Unknown"}, | ||
| 2479 | {0x5F, nullptr, "FlushProcessDataCache32"}, | ||
| 2480 | {0x60, nullptr, "Unknown"}, | ||
| 2481 | {0x61, nullptr, "Unknown"}, | ||
| 2482 | {0x62, nullptr, "Unknown"}, | ||
| 2483 | {0x63, nullptr, "Unknown"}, | ||
| 2484 | {0x64, nullptr, "Unknown"}, | ||
| 2485 | {0x65, nullptr, "GetProcessList32"}, | ||
| 2486 | {0x66, nullptr, "Unknown"}, | ||
| 2487 | {0x67, nullptr, "Unknown"}, | ||
| 2488 | {0x68, nullptr, "Unknown"}, | ||
| 2489 | {0x69, nullptr, "Unknown"}, | ||
| 2490 | {0x6A, nullptr, "Unknown"}, | ||
| 2491 | {0x6B, nullptr, "Unknown"}, | ||
| 2492 | {0x6C, nullptr, "Unknown"}, | ||
| 2493 | {0x6D, nullptr, "Unknown"}, | ||
| 2494 | {0x6E, nullptr, "Unknown"}, | ||
| 2495 | {0x6f, nullptr, "GetSystemInfo32"}, | ||
| 2496 | {0x70, nullptr, "CreatePort32"}, | ||
| 2497 | {0x71, nullptr, "ManageNamedPort32"}, | ||
| 2498 | {0x72, nullptr, "ConnectToPort32"}, | ||
| 2499 | {0x73, nullptr, "SetProcessMemoryPermission32"}, | ||
| 2500 | {0x74, nullptr, "Unknown"}, | ||
| 2501 | {0x75, nullptr, "Unknown"}, | ||
| 2502 | {0x76, nullptr, "Unknown"}, | ||
| 2503 | {0x77, nullptr, "MapProcessCodeMemory32"}, | ||
| 2504 | {0x78, nullptr, "UnmapProcessCodeMemory32"}, | ||
| 2505 | {0x79, nullptr, "Unknown"}, | ||
| 2506 | {0x7A, nullptr, "Unknown"}, | ||
| 2507 | {0x7B, nullptr, "TerminateProcess32"}, | ||
| 2508 | }; | ||
| 2509 | |||
| 2510 | static const FunctionDef SVC_Table_64[] = { | ||
| 2511 | {0x00, nullptr, "Unknown"}, | ||
| 2512 | {0x01, SvcWrap64<SetHeapSize>, "SetHeapSize"}, | ||
| 2513 | {0x02, SvcWrap64<SetMemoryPermission>, "SetMemoryPermission"}, | ||
| 2514 | {0x03, SvcWrap64<SetMemoryAttribute>, "SetMemoryAttribute"}, | ||
| 2515 | {0x04, SvcWrap64<MapMemory>, "MapMemory"}, | ||
| 2516 | {0x05, SvcWrap64<UnmapMemory>, "UnmapMemory"}, | ||
| 2517 | {0x06, SvcWrap64<QueryMemory>, "QueryMemory"}, | ||
| 2518 | {0x07, SvcWrap64<ExitProcess>, "ExitProcess"}, | ||
| 2519 | {0x08, SvcWrap64<CreateThread>, "CreateThread"}, | ||
| 2520 | {0x09, SvcWrap64<StartThread>, "StartThread"}, | ||
| 2521 | {0x0A, SvcWrap64<ExitThread>, "ExitThread"}, | ||
| 2522 | {0x0B, SvcWrap64<SleepThread>, "SleepThread"}, | ||
| 2523 | {0x0C, SvcWrap64<GetThreadPriority>, "GetThreadPriority"}, | ||
| 2524 | {0x0D, SvcWrap64<SetThreadPriority>, "SetThreadPriority"}, | ||
| 2525 | {0x0E, SvcWrap64<GetThreadCoreMask>, "GetThreadCoreMask"}, | ||
| 2526 | {0x0F, SvcWrap64<SetThreadCoreMask>, "SetThreadCoreMask"}, | ||
| 2527 | {0x10, SvcWrap64<GetCurrentProcessorNumber>, "GetCurrentProcessorNumber"}, | ||
| 2528 | {0x11, SvcWrap64<SignalEvent>, "SignalEvent"}, | ||
| 2529 | {0x12, SvcWrap64<ClearEvent>, "ClearEvent"}, | ||
| 2530 | {0x13, SvcWrap64<MapSharedMemory>, "MapSharedMemory"}, | ||
| 2531 | {0x14, SvcWrap64<UnmapSharedMemory>, "UnmapSharedMemory"}, | ||
| 2532 | {0x15, SvcWrap64<CreateTransferMemory>, "CreateTransferMemory"}, | ||
| 2533 | {0x16, SvcWrap64<CloseHandle>, "CloseHandle"}, | ||
| 2534 | {0x17, SvcWrap64<ResetSignal>, "ResetSignal"}, | ||
| 2535 | {0x18, SvcWrap64<WaitSynchronization>, "WaitSynchronization"}, | ||
| 2536 | {0x19, SvcWrap64<CancelSynchronization>, "CancelSynchronization"}, | ||
| 2537 | {0x1A, SvcWrap64<ArbitrateLock>, "ArbitrateLock"}, | ||
| 2538 | {0x1B, SvcWrap64<ArbitrateUnlock>, "ArbitrateUnlock"}, | ||
| 2539 | {0x1C, SvcWrap64<WaitProcessWideKeyAtomic>, "WaitProcessWideKeyAtomic"}, | ||
| 2540 | {0x1D, SvcWrap64<SignalProcessWideKey>, "SignalProcessWideKey"}, | ||
| 2541 | {0x1E, SvcWrap64<GetSystemTick>, "GetSystemTick"}, | ||
| 2542 | {0x1F, SvcWrap64<ConnectToNamedPort>, "ConnectToNamedPort"}, | ||
| 2353 | {0x20, nullptr, "SendSyncRequestLight"}, | 2543 | {0x20, nullptr, "SendSyncRequestLight"}, |
| 2354 | {0x21, SvcWrap<SendSyncRequest>, "SendSyncRequest"}, | 2544 | {0x21, SvcWrap64<SendSyncRequest>, "SendSyncRequest"}, |
| 2355 | {0x22, nullptr, "SendSyncRequestWithUserBuffer"}, | 2545 | {0x22, nullptr, "SendSyncRequestWithUserBuffer"}, |
| 2356 | {0x23, nullptr, "SendAsyncRequestWithUserBuffer"}, | 2546 | {0x23, nullptr, "SendAsyncRequestWithUserBuffer"}, |
| 2357 | {0x24, SvcWrap<GetProcessId>, "GetProcessId"}, | 2547 | {0x24, SvcWrap64<GetProcessId>, "GetProcessId"}, |
| 2358 | {0x25, SvcWrap<GetThreadId>, "GetThreadId"}, | 2548 | {0x25, SvcWrap64<GetThreadId>, "GetThreadId"}, |
| 2359 | {0x26, SvcWrap<Break>, "Break"}, | 2549 | {0x26, SvcWrap64<Break>, "Break"}, |
| 2360 | {0x27, SvcWrap<OutputDebugString>, "OutputDebugString"}, | 2550 | {0x27, SvcWrap64<OutputDebugString>, "OutputDebugString"}, |
| 2361 | {0x28, nullptr, "ReturnFromException"}, | 2551 | {0x28, nullptr, "ReturnFromException"}, |
| 2362 | {0x29, SvcWrap<GetInfo>, "GetInfo"}, | 2552 | {0x29, SvcWrap64<GetInfo>, "GetInfo"}, |
| 2363 | {0x2A, nullptr, "FlushEntireDataCache"}, | 2553 | {0x2A, nullptr, "FlushEntireDataCache"}, |
| 2364 | {0x2B, nullptr, "FlushDataCache"}, | 2554 | {0x2B, nullptr, "FlushDataCache"}, |
| 2365 | {0x2C, SvcWrap<MapPhysicalMemory>, "MapPhysicalMemory"}, | 2555 | {0x2C, SvcWrap64<MapPhysicalMemory>, "MapPhysicalMemory"}, |
| 2366 | {0x2D, SvcWrap<UnmapPhysicalMemory>, "UnmapPhysicalMemory"}, | 2556 | {0x2D, SvcWrap64<UnmapPhysicalMemory>, "UnmapPhysicalMemory"}, |
| 2367 | {0x2E, nullptr, "GetFutureThreadInfo"}, | 2557 | {0x2E, nullptr, "GetFutureThreadInfo"}, |
| 2368 | {0x2F, nullptr, "GetLastThreadInfo"}, | 2558 | {0x2F, nullptr, "GetLastThreadInfo"}, |
| 2369 | {0x30, SvcWrap<GetResourceLimitLimitValue>, "GetResourceLimitLimitValue"}, | 2559 | {0x30, SvcWrap64<GetResourceLimitLimitValue>, "GetResourceLimitLimitValue"}, |
| 2370 | {0x31, SvcWrap<GetResourceLimitCurrentValue>, "GetResourceLimitCurrentValue"}, | 2560 | {0x31, SvcWrap64<GetResourceLimitCurrentValue>, "GetResourceLimitCurrentValue"}, |
| 2371 | {0x32, SvcWrap<SetThreadActivity>, "SetThreadActivity"}, | 2561 | {0x32, SvcWrap64<SetThreadActivity>, "SetThreadActivity"}, |
| 2372 | {0x33, SvcWrap<GetThreadContext>, "GetThreadContext"}, | 2562 | {0x33, SvcWrap64<GetThreadContext>, "GetThreadContext"}, |
| 2373 | {0x34, SvcWrap<WaitForAddress>, "WaitForAddress"}, | 2563 | {0x34, SvcWrap64<WaitForAddress>, "WaitForAddress"}, |
| 2374 | {0x35, SvcWrap<SignalToAddress>, "SignalToAddress"}, | 2564 | {0x35, SvcWrap64<SignalToAddress>, "SignalToAddress"}, |
| 2375 | {0x36, nullptr, "SynchronizePreemptionState"}, | 2565 | {0x36, nullptr, "SynchronizePreemptionState"}, |
| 2376 | {0x37, nullptr, "Unknown"}, | 2566 | {0x37, nullptr, "Unknown"}, |
| 2377 | {0x38, nullptr, "Unknown"}, | 2567 | {0x38, nullptr, "Unknown"}, |
| 2378 | {0x39, nullptr, "Unknown"}, | 2568 | {0x39, nullptr, "Unknown"}, |
| 2379 | {0x3A, nullptr, "Unknown"}, | 2569 | {0x3A, nullptr, "Unknown"}, |
| 2380 | {0x3B, nullptr, "Unknown"}, | 2570 | {0x3B, nullptr, "Unknown"}, |
| 2381 | {0x3C, SvcWrap<KernelDebug>, "KernelDebug"}, | 2571 | {0x3C, SvcWrap64<KernelDebug>, "KernelDebug"}, |
| 2382 | {0x3D, SvcWrap<ChangeKernelTraceState>, "ChangeKernelTraceState"}, | 2572 | {0x3D, SvcWrap64<ChangeKernelTraceState>, "ChangeKernelTraceState"}, |
| 2383 | {0x3E, nullptr, "Unknown"}, | 2573 | {0x3E, nullptr, "Unknown"}, |
| 2384 | {0x3F, nullptr, "Unknown"}, | 2574 | {0x3F, nullptr, "Unknown"}, |
| 2385 | {0x40, nullptr, "CreateSession"}, | 2575 | {0x40, nullptr, "CreateSession"}, |
| @@ -2387,7 +2577,7 @@ static const FunctionDef SVC_Table[] = { | |||
| 2387 | {0x42, nullptr, "ReplyAndReceiveLight"}, | 2577 | {0x42, nullptr, "ReplyAndReceiveLight"}, |
| 2388 | {0x43, nullptr, "ReplyAndReceive"}, | 2578 | {0x43, nullptr, "ReplyAndReceive"}, |
| 2389 | {0x44, nullptr, "ReplyAndReceiveWithUserBuffer"}, | 2579 | {0x44, nullptr, "ReplyAndReceiveWithUserBuffer"}, |
| 2390 | {0x45, SvcWrap<CreateEvent>, "CreateEvent"}, | 2580 | {0x45, SvcWrap64<CreateEvent>, "CreateEvent"}, |
| 2391 | {0x46, nullptr, "Unknown"}, | 2581 | {0x46, nullptr, "Unknown"}, |
| 2392 | {0x47, nullptr, "Unknown"}, | 2582 | {0x47, nullptr, "Unknown"}, |
| 2393 | {0x48, nullptr, "MapPhysicalMemoryUnsafe"}, | 2583 | {0x48, nullptr, "MapPhysicalMemoryUnsafe"}, |
| @@ -2398,9 +2588,9 @@ static const FunctionDef SVC_Table[] = { | |||
| 2398 | {0x4D, nullptr, "SleepSystem"}, | 2588 | {0x4D, nullptr, "SleepSystem"}, |
| 2399 | {0x4E, nullptr, "ReadWriteRegister"}, | 2589 | {0x4E, nullptr, "ReadWriteRegister"}, |
| 2400 | {0x4F, nullptr, "SetProcessActivity"}, | 2590 | {0x4F, nullptr, "SetProcessActivity"}, |
| 2401 | {0x50, SvcWrap<CreateSharedMemory>, "CreateSharedMemory"}, | 2591 | {0x50, SvcWrap64<CreateSharedMemory>, "CreateSharedMemory"}, |
| 2402 | {0x51, SvcWrap<MapTransferMemory>, "MapTransferMemory"}, | 2592 | {0x51, SvcWrap64<MapTransferMemory>, "MapTransferMemory"}, |
| 2403 | {0x52, SvcWrap<UnmapTransferMemory>, "UnmapTransferMemory"}, | 2593 | {0x52, SvcWrap64<UnmapTransferMemory>, "UnmapTransferMemory"}, |
| 2404 | {0x53, nullptr, "CreateInterruptEvent"}, | 2594 | {0x53, nullptr, "CreateInterruptEvent"}, |
| 2405 | {0x54, nullptr, "QueryPhysicalAddress"}, | 2595 | {0x54, nullptr, "QueryPhysicalAddress"}, |
| 2406 | {0x55, nullptr, "QueryIoMapping"}, | 2596 | {0x55, nullptr, "QueryIoMapping"}, |
| @@ -2419,8 +2609,8 @@ static const FunctionDef SVC_Table[] = { | |||
| 2419 | {0x62, nullptr, "TerminateDebugProcess"}, | 2609 | {0x62, nullptr, "TerminateDebugProcess"}, |
| 2420 | {0x63, nullptr, "GetDebugEvent"}, | 2610 | {0x63, nullptr, "GetDebugEvent"}, |
| 2421 | {0x64, nullptr, "ContinueDebugEvent"}, | 2611 | {0x64, nullptr, "ContinueDebugEvent"}, |
| 2422 | {0x65, SvcWrap<GetProcessList>, "GetProcessList"}, | 2612 | {0x65, SvcWrap64<GetProcessList>, "GetProcessList"}, |
| 2423 | {0x66, SvcWrap<GetThreadList>, "GetThreadList"}, | 2613 | {0x66, SvcWrap64<GetThreadList>, "GetThreadList"}, |
| 2424 | {0x67, nullptr, "GetDebugThreadContext"}, | 2614 | {0x67, nullptr, "GetDebugThreadContext"}, |
| 2425 | {0x68, nullptr, "SetDebugThreadContext"}, | 2615 | {0x68, nullptr, "SetDebugThreadContext"}, |
| 2426 | {0x69, nullptr, "QueryDebugProcessMemory"}, | 2616 | {0x69, nullptr, "QueryDebugProcessMemory"}, |
| @@ -2436,24 +2626,32 @@ static const FunctionDef SVC_Table[] = { | |||
| 2436 | {0x73, nullptr, "SetProcessMemoryPermission"}, | 2626 | {0x73, nullptr, "SetProcessMemoryPermission"}, |
| 2437 | {0x74, nullptr, "MapProcessMemory"}, | 2627 | {0x74, nullptr, "MapProcessMemory"}, |
| 2438 | {0x75, nullptr, "UnmapProcessMemory"}, | 2628 | {0x75, nullptr, "UnmapProcessMemory"}, |
| 2439 | {0x76, SvcWrap<QueryProcessMemory>, "QueryProcessMemory"}, | 2629 | {0x76, SvcWrap64<QueryProcessMemory>, "QueryProcessMemory"}, |
| 2440 | {0x77, SvcWrap<MapProcessCodeMemory>, "MapProcessCodeMemory"}, | 2630 | {0x77, SvcWrap64<MapProcessCodeMemory>, "MapProcessCodeMemory"}, |
| 2441 | {0x78, SvcWrap<UnmapProcessCodeMemory>, "UnmapProcessCodeMemory"}, | 2631 | {0x78, SvcWrap64<UnmapProcessCodeMemory>, "UnmapProcessCodeMemory"}, |
| 2442 | {0x79, nullptr, "CreateProcess"}, | 2632 | {0x79, nullptr, "CreateProcess"}, |
| 2443 | {0x7A, nullptr, "StartProcess"}, | 2633 | {0x7A, nullptr, "StartProcess"}, |
| 2444 | {0x7B, nullptr, "TerminateProcess"}, | 2634 | {0x7B, nullptr, "TerminateProcess"}, |
| 2445 | {0x7C, SvcWrap<GetProcessInfo>, "GetProcessInfo"}, | 2635 | {0x7C, SvcWrap64<GetProcessInfo>, "GetProcessInfo"}, |
| 2446 | {0x7D, SvcWrap<CreateResourceLimit>, "CreateResourceLimit"}, | 2636 | {0x7D, SvcWrap64<CreateResourceLimit>, "CreateResourceLimit"}, |
| 2447 | {0x7E, SvcWrap<SetResourceLimitLimitValue>, "SetResourceLimitLimitValue"}, | 2637 | {0x7E, SvcWrap64<SetResourceLimitLimitValue>, "SetResourceLimitLimitValue"}, |
| 2448 | {0x7F, nullptr, "CallSecureMonitor"}, | 2638 | {0x7F, nullptr, "CallSecureMonitor"}, |
| 2449 | }; | 2639 | }; |
| 2450 | 2640 | ||
| 2451 | static const FunctionDef* GetSVCInfo(u32 func_num) { | 2641 | static const FunctionDef* GetSVCInfo32(u32 func_num) { |
| 2452 | if (func_num >= std::size(SVC_Table)) { | 2642 | if (func_num >= std::size(SVC_Table_32)) { |
| 2643 | LOG_ERROR(Kernel_SVC, "Unknown svc=0x{:02X}", func_num); | ||
| 2644 | return nullptr; | ||
| 2645 | } | ||
| 2646 | return &SVC_Table_32[func_num]; | ||
| 2647 | } | ||
| 2648 | |||
| 2649 | static const FunctionDef* GetSVCInfo64(u32 func_num) { | ||
| 2650 | if (func_num >= std::size(SVC_Table_64)) { | ||
| 2453 | LOG_ERROR(Kernel_SVC, "Unknown svc=0x{:02X}", func_num); | 2651 | LOG_ERROR(Kernel_SVC, "Unknown svc=0x{:02X}", func_num); |
| 2454 | return nullptr; | 2652 | return nullptr; |
| 2455 | } | 2653 | } |
| 2456 | return &SVC_Table[func_num]; | 2654 | return &SVC_Table_64[func_num]; |
| 2457 | } | 2655 | } |
| 2458 | 2656 | ||
| 2459 | MICROPROFILE_DEFINE(Kernel_SVC, "Kernel", "SVC", MP_RGB(70, 200, 70)); | 2657 | MICROPROFILE_DEFINE(Kernel_SVC, "Kernel", "SVC", MP_RGB(70, 200, 70)); |
| @@ -2464,7 +2662,8 @@ void CallSVC(Core::System& system, u32 immediate) { | |||
| 2464 | // Lock the global kernel mutex when we enter the kernel HLE. | 2662 | // Lock the global kernel mutex when we enter the kernel HLE. |
| 2465 | std::lock_guard lock{HLE::g_hle_lock}; | 2663 | std::lock_guard lock{HLE::g_hle_lock}; |
| 2466 | 2664 | ||
| 2467 | const FunctionDef* info = GetSVCInfo(immediate); | 2665 | const FunctionDef* info = system.CurrentProcess()->Is64BitProcess() ? GetSVCInfo64(immediate) |
| 2666 | : GetSVCInfo32(immediate); | ||
| 2468 | if (info) { | 2667 | if (info) { |
| 2469 | if (info->func) { | 2668 | if (info->func) { |
| 2470 | info->func(system); | 2669 | info->func(system); |