diff options
| author | 2018-10-28 04:38:48 -0400 | |
|---|---|---|
| committer | 2018-10-28 04:38:48 -0400 | |
| commit | 2239d4711288ffb61c9ac25ce19e3b6b1e15107f (patch) | |
| tree | 90cd62acff8b352bfbdb796e8e947416cb8496f5 /src/core/hle/kernel/svc.cpp | |
| parent | Merge pull request #1581 from FreddyFunk/macosx-target-version (diff) | |
| parent | svc: Localize the GetInfo enum class to the function itself (diff) | |
| download | yuzu-2239d4711288ffb61c9ac25ce19e3b6b1e15107f.tar.gz yuzu-2239d4711288ffb61c9ac25ce19e3b6b1e15107f.tar.xz yuzu-2239d4711288ffb61c9ac25ce19e3b6b1e15107f.zip | |
Merge pull request #1593 from lioncash/svc
svc: Implement svcGetInfo command 0xF0000002
Diffstat (limited to 'src/core/hle/kernel/svc.cpp')
| -rw-r--r-- | src/core/hle/kernel/svc.cpp | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/src/core/hle/kernel/svc.cpp b/src/core/hle/kernel/svc.cpp index a5302d924..4e490e2b5 100644 --- a/src/core/hle/kernel/svc.cpp +++ b/src/core/hle/kernel/svc.cpp | |||
| @@ -467,6 +467,37 @@ static ResultCode GetInfo(u64* result, u64 info_id, u64 handle, u64 info_sub_id) | |||
| 467 | LOG_TRACE(Kernel_SVC, "called info_id=0x{:X}, info_sub_id=0x{:X}, handle=0x{:08X}", info_id, | 467 | LOG_TRACE(Kernel_SVC, "called info_id=0x{:X}, info_sub_id=0x{:X}, handle=0x{:08X}", info_id, |
| 468 | info_sub_id, handle); | 468 | info_sub_id, handle); |
| 469 | 469 | ||
| 470 | enum class GetInfoType : u64 { | ||
| 471 | // 1.0.0+ | ||
| 472 | AllowedCpuIdBitmask = 0, | ||
| 473 | AllowedThreadPrioBitmask = 1, | ||
| 474 | MapRegionBaseAddr = 2, | ||
| 475 | MapRegionSize = 3, | ||
| 476 | HeapRegionBaseAddr = 4, | ||
| 477 | HeapRegionSize = 5, | ||
| 478 | TotalMemoryUsage = 6, | ||
| 479 | TotalHeapUsage = 7, | ||
| 480 | IsCurrentProcessBeingDebugged = 8, | ||
| 481 | ResourceHandleLimit = 9, | ||
| 482 | IdleTickCount = 10, | ||
| 483 | RandomEntropy = 11, | ||
| 484 | PerformanceCounter = 0xF0000002, | ||
| 485 | // 2.0.0+ | ||
| 486 | ASLRRegionBaseAddr = 12, | ||
| 487 | ASLRRegionSize = 13, | ||
| 488 | NewMapRegionBaseAddr = 14, | ||
| 489 | NewMapRegionSize = 15, | ||
| 490 | // 3.0.0+ | ||
| 491 | IsVirtualAddressMemoryEnabled = 16, | ||
| 492 | PersonalMmHeapUsage = 17, | ||
| 493 | TitleId = 18, | ||
| 494 | // 4.0.0+ | ||
| 495 | PrivilegedProcessId = 19, | ||
| 496 | // 5.0.0+ | ||
| 497 | UserExceptionContextAddr = 20, | ||
| 498 | ThreadTickCount = 0xF0000002, | ||
| 499 | }; | ||
| 500 | |||
| 470 | const auto* current_process = Core::CurrentProcess(); | 501 | const auto* current_process = Core::CurrentProcess(); |
| 471 | const auto& vm_manager = current_process->VMManager(); | 502 | const auto& vm_manager = current_process->VMManager(); |
| 472 | 503 | ||
| @@ -529,6 +560,36 @@ static ResultCode GetInfo(u64* result, u64 info_id, u64 handle, u64 info_sub_id) | |||
| 529 | "(STUBBED) Attempted to query user exception context address, returned 0"); | 560 | "(STUBBED) Attempted to query user exception context address, returned 0"); |
| 530 | *result = 0; | 561 | *result = 0; |
| 531 | break; | 562 | break; |
| 563 | case GetInfoType::ThreadTickCount: { | ||
| 564 | constexpr u64 num_cpus = 4; | ||
| 565 | if (info_sub_id != 0xFFFFFFFFFFFFFFFF && info_sub_id >= num_cpus) { | ||
| 566 | return ERR_INVALID_COMBINATION_KERNEL; | ||
| 567 | } | ||
| 568 | |||
| 569 | const auto thread = | ||
| 570 | current_process->GetHandleTable().Get<Thread>(static_cast<Handle>(handle)); | ||
| 571 | if (!thread) { | ||
| 572 | return ERR_INVALID_HANDLE; | ||
| 573 | } | ||
| 574 | |||
| 575 | auto& system = Core::System::GetInstance(); | ||
| 576 | const auto& scheduler = system.CurrentScheduler(); | ||
| 577 | const auto* const current_thread = scheduler.GetCurrentThread(); | ||
| 578 | const bool same_thread = current_thread == thread; | ||
| 579 | |||
| 580 | const u64 prev_ctx_ticks = scheduler.GetLastContextSwitchTicks(); | ||
| 581 | u64 out_ticks = 0; | ||
| 582 | if (same_thread && info_sub_id == 0xFFFFFFFFFFFFFFFF) { | ||
| 583 | const u64 thread_ticks = current_thread->GetTotalCPUTimeTicks(); | ||
| 584 | |||
| 585 | out_ticks = thread_ticks + (CoreTiming::GetTicks() - prev_ctx_ticks); | ||
| 586 | } else if (same_thread && info_sub_id == system.CurrentCoreIndex()) { | ||
| 587 | out_ticks = CoreTiming::GetTicks() - prev_ctx_ticks; | ||
| 588 | } | ||
| 589 | |||
| 590 | *result = out_ticks; | ||
| 591 | break; | ||
| 592 | } | ||
| 532 | default: | 593 | default: |
| 533 | UNIMPLEMENTED(); | 594 | UNIMPLEMENTED(); |
| 534 | } | 595 | } |