summaryrefslogtreecommitdiff
path: root/src/core/hle/svc.cpp
diff options
context:
space:
mode:
authorGravatar Yuri Kunde Schlesner2015-08-05 21:39:53 -0300
committerGravatar Yuri Kunde Schlesner2015-08-16 01:03:48 -0300
commit14eca982f4da2bfd4d2c105bc33722e88e59da5f (patch)
treed812de676c6e2d056ac43abec89251aa36162165 /src/core/hle/svc.cpp
parentKernel: Add more infrastructure to support different memory layouts (diff)
downloadyuzu-14eca982f4da2bfd4d2c105bc33722e88e59da5f.tar.gz
yuzu-14eca982f4da2bfd4d2c105bc33722e88e59da5f.tar.xz
yuzu-14eca982f4da2bfd4d2c105bc33722e88e59da5f.zip
Kernel: Implement svcGetProcessInfo in a basic way
This also adds some basic memory usage accounting. These two types are used by Super Smash Bros. during startup.
Diffstat (limited to 'src/core/hle/svc.cpp')
-rw-r--r--src/core/hle/svc.cpp48
1 files changed, 47 insertions, 1 deletions
diff --git a/src/core/hle/svc.cpp b/src/core/hle/svc.cpp
index e1a416def..89ac45a6f 100644
--- a/src/core/hle/svc.cpp
+++ b/src/core/hle/svc.cpp
@@ -774,6 +774,52 @@ static ResultCode CreateMemoryBlock(Handle* out_handle, u32 addr, u32 size, u32
774 return RESULT_SUCCESS; 774 return RESULT_SUCCESS;
775} 775}
776 776
777static ResultCode GetProcessInfo(s64* out, Handle process_handle, u32 type) {
778 LOG_TRACE(Kernel_SVC, "called process=0x%08X type=%u", process_handle, type);
779
780 using Kernel::Process;
781 Kernel::SharedPtr<Process> process = Kernel::g_handle_table.Get<Process>(process_handle);
782 if (process == nullptr)
783 return ERR_INVALID_HANDLE;
784
785 switch (type) {
786 case 0:
787 case 2:
788 // TODO(yuriks): Type 0 returns a slightly higher number than type 2, but I'm not sure
789 // what's the difference between them.
790 *out = process->heap_used + process->linear_heap_used + process->misc_memory_used;
791 break;
792 case 1:
793 case 3:
794 case 4:
795 case 5:
796 case 6:
797 case 7:
798 case 8:
799 // These are valid, but not implemented yet
800 LOG_ERROR(Kernel_SVC, "unimplemented GetProcessInfo type=%u", type);
801 break;
802 case 20:
803 *out = Memory::FCRAM_PADDR - process->GetLinearHeapBase();
804 break;
805 default:
806 LOG_ERROR(Kernel_SVC, "unknown GetProcessInfo type=%u", type);
807
808 if (type >= 21 && type <= 23) {
809 return ResultCode( // 0xE0E01BF4
810 ErrorDescription::NotImplemented, ErrorModule::OS,
811 ErrorSummary::InvalidArgument, ErrorLevel::Usage);
812 } else {
813 return ResultCode( // 0xD8E007ED
814 ErrorDescription::InvalidEnumValue, ErrorModule::Kernel,
815 ErrorSummary::InvalidArgument, ErrorLevel::Permanent);
816 }
817 break;
818 }
819
820 return RESULT_SUCCESS;
821}
822
777namespace { 823namespace {
778 struct FunctionDef { 824 struct FunctionDef {
779 using Func = void(); 825 using Func = void();
@@ -828,7 +874,7 @@ static const FunctionDef SVC_Table[] = {
828 {0x28, HLE::Wrap<GetSystemTick>, "GetSystemTick"}, 874 {0x28, HLE::Wrap<GetSystemTick>, "GetSystemTick"},
829 {0x29, nullptr, "GetHandleInfo"}, 875 {0x29, nullptr, "GetHandleInfo"},
830 {0x2A, nullptr, "GetSystemInfo"}, 876 {0x2A, nullptr, "GetSystemInfo"},
831 {0x2B, nullptr, "GetProcessInfo"}, 877 {0x2B, HLE::Wrap<GetProcessInfo>, "GetProcessInfo"},
832 {0x2C, nullptr, "GetThreadInfo"}, 878 {0x2C, nullptr, "GetThreadInfo"},
833 {0x2D, HLE::Wrap<ConnectToPort>, "ConnectToPort"}, 879 {0x2D, HLE::Wrap<ConnectToPort>, "ConnectToPort"},
834 {0x2E, nullptr, "SendSyncRequest1"}, 880 {0x2E, nullptr, "SendSyncRequest1"},