diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/core/hle/kernel/svc.cpp | 137 |
1 files changed, 47 insertions, 90 deletions
diff --git a/src/core/hle/kernel/svc.cpp b/src/core/hle/kernel/svc.cpp index 9fd7aae81..788ee2160 100644 --- a/src/core/hle/kernel/svc.cpp +++ b/src/core/hle/kernel/svc.cpp | |||
| @@ -784,72 +784,29 @@ static Result GetInfo(Core::System& system, u64* result, u64 info_id, Handle han | |||
| 784 | LOG_TRACE(Kernel_SVC, "called info_id=0x{:X}, info_sub_id=0x{:X}, handle=0x{:08X}", info_id, | 784 | LOG_TRACE(Kernel_SVC, "called info_id=0x{:X}, info_sub_id=0x{:X}, handle=0x{:08X}", info_id, |
| 785 | info_sub_id, handle); | 785 | info_sub_id, handle); |
| 786 | 786 | ||
| 787 | enum class GetInfoType : u64 { | 787 | const auto info_id_type = static_cast<InfoType>(info_id); |
| 788 | // 1.0.0+ | ||
| 789 | AllowedCPUCoreMask = 0, | ||
| 790 | AllowedThreadPriorityMask = 1, | ||
| 791 | MapRegionBaseAddr = 2, | ||
| 792 | MapRegionSize = 3, | ||
| 793 | HeapRegionBaseAddr = 4, | ||
| 794 | HeapRegionSize = 5, | ||
| 795 | TotalPhysicalMemoryAvailable = 6, | ||
| 796 | TotalPhysicalMemoryUsed = 7, | ||
| 797 | IsCurrentProcessBeingDebugged = 8, | ||
| 798 | RegisterResourceLimit = 9, | ||
| 799 | IdleTickCount = 10, | ||
| 800 | RandomEntropy = 11, | ||
| 801 | ThreadTickCount = 0xF0000002, | ||
| 802 | // 2.0.0+ | ||
| 803 | ASLRRegionBaseAddr = 12, | ||
| 804 | ASLRRegionSize = 13, | ||
| 805 | StackRegionBaseAddr = 14, | ||
| 806 | StackRegionSize = 15, | ||
| 807 | // 3.0.0+ | ||
| 808 | SystemResourceSize = 16, | ||
| 809 | SystemResourceUsage = 17, | ||
| 810 | TitleId = 18, | ||
| 811 | // 4.0.0+ | ||
| 812 | PrivilegedProcessId = 19, | ||
| 813 | // 5.0.0+ | ||
| 814 | UserExceptionContextAddr = 20, | ||
| 815 | // 6.0.0+ | ||
| 816 | TotalPhysicalMemoryAvailableWithoutSystemResource = 21, | ||
| 817 | TotalPhysicalMemoryUsedWithoutSystemResource = 22, | ||
| 818 | // 10.0.0+ | ||
| 819 | IsApplication = 23, | ||
| 820 | // 13.0.0+ | ||
| 821 | FreeThreadCount = 24, | ||
| 822 | // 14.0.0+ | ||
| 823 | IsSvcPermitted = 26, | ||
| 824 | |||
| 825 | // Homebrew only | ||
| 826 | MesosphereMeta = 65000, | ||
| 827 | MesosphereCurrentProcess = 65001, | ||
| 828 | }; | ||
| 829 | |||
| 830 | const auto info_id_type = static_cast<GetInfoType>(info_id); | ||
| 831 | 788 | ||
| 832 | switch (info_id_type) { | 789 | switch (info_id_type) { |
| 833 | case GetInfoType::AllowedCPUCoreMask: | 790 | case InfoType::CoreMask: |
| 834 | case GetInfoType::AllowedThreadPriorityMask: | 791 | case InfoType::PriorityMask: |
| 835 | case GetInfoType::MapRegionBaseAddr: | 792 | case InfoType::AliasRegionAddress: |
| 836 | case GetInfoType::MapRegionSize: | 793 | case InfoType::AliasRegionSize: |
| 837 | case GetInfoType::HeapRegionBaseAddr: | 794 | case InfoType::HeapRegionAddress: |
| 838 | case GetInfoType::HeapRegionSize: | 795 | case InfoType::HeapRegionSize: |
| 839 | case GetInfoType::ASLRRegionBaseAddr: | 796 | case InfoType::AslrRegionAddress: |
| 840 | case GetInfoType::ASLRRegionSize: | 797 | case InfoType::AslrRegionSize: |
| 841 | case GetInfoType::StackRegionBaseAddr: | 798 | case InfoType::StackRegionAddress: |
| 842 | case GetInfoType::StackRegionSize: | 799 | case InfoType::StackRegionSize: |
| 843 | case GetInfoType::TotalPhysicalMemoryAvailable: | 800 | case InfoType::TotalMemorySize: |
| 844 | case GetInfoType::TotalPhysicalMemoryUsed: | 801 | case InfoType::UsedMemorySize: |
| 845 | case GetInfoType::SystemResourceSize: | 802 | case InfoType::SystemResourceSizeTotal: |
| 846 | case GetInfoType::SystemResourceUsage: | 803 | case InfoType::SystemResourceSizeUsed: |
| 847 | case GetInfoType::TitleId: | 804 | case InfoType::ProgramId: |
| 848 | case GetInfoType::UserExceptionContextAddr: | 805 | case InfoType::UserExceptionContextAddress: |
| 849 | case GetInfoType::TotalPhysicalMemoryAvailableWithoutSystemResource: | 806 | case InfoType::TotalNonSystemMemorySize: |
| 850 | case GetInfoType::TotalPhysicalMemoryUsedWithoutSystemResource: | 807 | case InfoType::UsedNonSystemMemorySize: |
| 851 | case GetInfoType::IsApplication: | 808 | case InfoType::IsApplication: |
| 852 | case GetInfoType::FreeThreadCount: { | 809 | case InfoType::FreeThreadCount: { |
| 853 | if (info_sub_id != 0) { | 810 | if (info_sub_id != 0) { |
| 854 | LOG_ERROR(Kernel_SVC, "Info sub id is non zero! info_id={}, info_sub_id={}", info_id, | 811 | LOG_ERROR(Kernel_SVC, "Info sub id is non zero! info_id={}, info_sub_id={}", info_id, |
| 855 | info_sub_id); | 812 | info_sub_id); |
| @@ -865,80 +822,80 @@ static Result GetInfo(Core::System& system, u64* result, u64 info_id, Handle han | |||
| 865 | } | 822 | } |
| 866 | 823 | ||
| 867 | switch (info_id_type) { | 824 | switch (info_id_type) { |
| 868 | case GetInfoType::AllowedCPUCoreMask: | 825 | case InfoType::CoreMask: |
| 869 | *result = process->GetCoreMask(); | 826 | *result = process->GetCoreMask(); |
| 870 | return ResultSuccess; | 827 | return ResultSuccess; |
| 871 | 828 | ||
| 872 | case GetInfoType::AllowedThreadPriorityMask: | 829 | case InfoType::PriorityMask: |
| 873 | *result = process->GetPriorityMask(); | 830 | *result = process->GetPriorityMask(); |
| 874 | return ResultSuccess; | 831 | return ResultSuccess; |
| 875 | 832 | ||
| 876 | case GetInfoType::MapRegionBaseAddr: | 833 | case InfoType::AliasRegionAddress: |
| 877 | *result = process->PageTable().GetAliasRegionStart(); | 834 | *result = process->PageTable().GetAliasRegionStart(); |
| 878 | return ResultSuccess; | 835 | return ResultSuccess; |
| 879 | 836 | ||
| 880 | case GetInfoType::MapRegionSize: | 837 | case InfoType::AliasRegionSize: |
| 881 | *result = process->PageTable().GetAliasRegionSize(); | 838 | *result = process->PageTable().GetAliasRegionSize(); |
| 882 | return ResultSuccess; | 839 | return ResultSuccess; |
| 883 | 840 | ||
| 884 | case GetInfoType::HeapRegionBaseAddr: | 841 | case InfoType::HeapRegionAddress: |
| 885 | *result = process->PageTable().GetHeapRegionStart(); | 842 | *result = process->PageTable().GetHeapRegionStart(); |
| 886 | return ResultSuccess; | 843 | return ResultSuccess; |
| 887 | 844 | ||
| 888 | case GetInfoType::HeapRegionSize: | 845 | case InfoType::HeapRegionSize: |
| 889 | *result = process->PageTable().GetHeapRegionSize(); | 846 | *result = process->PageTable().GetHeapRegionSize(); |
| 890 | return ResultSuccess; | 847 | return ResultSuccess; |
| 891 | 848 | ||
| 892 | case GetInfoType::ASLRRegionBaseAddr: | 849 | case InfoType::AslrRegionAddress: |
| 893 | *result = process->PageTable().GetAliasCodeRegionStart(); | 850 | *result = process->PageTable().GetAliasCodeRegionStart(); |
| 894 | return ResultSuccess; | 851 | return ResultSuccess; |
| 895 | 852 | ||
| 896 | case GetInfoType::ASLRRegionSize: | 853 | case InfoType::AslrRegionSize: |
| 897 | *result = process->PageTable().GetAliasCodeRegionSize(); | 854 | *result = process->PageTable().GetAliasCodeRegionSize(); |
| 898 | return ResultSuccess; | 855 | return ResultSuccess; |
| 899 | 856 | ||
| 900 | case GetInfoType::StackRegionBaseAddr: | 857 | case InfoType::StackRegionAddress: |
| 901 | *result = process->PageTable().GetStackRegionStart(); | 858 | *result = process->PageTable().GetStackRegionStart(); |
| 902 | return ResultSuccess; | 859 | return ResultSuccess; |
| 903 | 860 | ||
| 904 | case GetInfoType::StackRegionSize: | 861 | case InfoType::StackRegionSize: |
| 905 | *result = process->PageTable().GetStackRegionSize(); | 862 | *result = process->PageTable().GetStackRegionSize(); |
| 906 | return ResultSuccess; | 863 | return ResultSuccess; |
| 907 | 864 | ||
| 908 | case GetInfoType::TotalPhysicalMemoryAvailable: | 865 | case InfoType::TotalMemorySize: |
| 909 | *result = process->GetTotalPhysicalMemoryAvailable(); | 866 | *result = process->GetTotalPhysicalMemoryAvailable(); |
| 910 | return ResultSuccess; | 867 | return ResultSuccess; |
| 911 | 868 | ||
| 912 | case GetInfoType::TotalPhysicalMemoryUsed: | 869 | case InfoType::UsedMemorySize: |
| 913 | *result = process->GetTotalPhysicalMemoryUsed(); | 870 | *result = process->GetTotalPhysicalMemoryUsed(); |
| 914 | return ResultSuccess; | 871 | return ResultSuccess; |
| 915 | 872 | ||
| 916 | case GetInfoType::SystemResourceSize: | 873 | case InfoType::SystemResourceSizeTotal: |
| 917 | *result = process->GetSystemResourceSize(); | 874 | *result = process->GetSystemResourceSize(); |
| 918 | return ResultSuccess; | 875 | return ResultSuccess; |
| 919 | 876 | ||
| 920 | case GetInfoType::SystemResourceUsage: | 877 | case InfoType::SystemResourceSizeUsed: |
| 921 | LOG_WARNING(Kernel_SVC, "(STUBBED) Attempted to query system resource usage"); | 878 | LOG_WARNING(Kernel_SVC, "(STUBBED) Attempted to query system resource usage"); |
| 922 | *result = process->GetSystemResourceUsage(); | 879 | *result = process->GetSystemResourceUsage(); |
| 923 | return ResultSuccess; | 880 | return ResultSuccess; |
| 924 | 881 | ||
| 925 | case GetInfoType::TitleId: | 882 | case InfoType::ProgramId: |
| 926 | *result = process->GetProgramID(); | 883 | *result = process->GetProgramID(); |
| 927 | return ResultSuccess; | 884 | return ResultSuccess; |
| 928 | 885 | ||
| 929 | case GetInfoType::UserExceptionContextAddr: | 886 | case InfoType::UserExceptionContextAddress: |
| 930 | *result = process->GetProcessLocalRegionAddress(); | 887 | *result = process->GetProcessLocalRegionAddress(); |
| 931 | return ResultSuccess; | 888 | return ResultSuccess; |
| 932 | 889 | ||
| 933 | case GetInfoType::TotalPhysicalMemoryAvailableWithoutSystemResource: | 890 | case InfoType::TotalNonSystemMemorySize: |
| 934 | *result = process->GetTotalPhysicalMemoryAvailableWithoutSystemResource(); | 891 | *result = process->GetTotalPhysicalMemoryAvailableWithoutSystemResource(); |
| 935 | return ResultSuccess; | 892 | return ResultSuccess; |
| 936 | 893 | ||
| 937 | case GetInfoType::TotalPhysicalMemoryUsedWithoutSystemResource: | 894 | case InfoType::UsedNonSystemMemorySize: |
| 938 | *result = process->GetTotalPhysicalMemoryUsedWithoutSystemResource(); | 895 | *result = process->GetTotalPhysicalMemoryUsedWithoutSystemResource(); |
| 939 | return ResultSuccess; | 896 | return ResultSuccess; |
| 940 | 897 | ||
| 941 | case GetInfoType::FreeThreadCount: | 898 | case InfoType::FreeThreadCount: |
| 942 | *result = process->GetFreeThreadCount(); | 899 | *result = process->GetFreeThreadCount(); |
| 943 | return ResultSuccess; | 900 | return ResultSuccess; |
| 944 | 901 | ||
| @@ -950,11 +907,11 @@ static Result GetInfo(Core::System& system, u64* result, u64 info_id, Handle han | |||
| 950 | return ResultInvalidEnumValue; | 907 | return ResultInvalidEnumValue; |
| 951 | } | 908 | } |
| 952 | 909 | ||
| 953 | case GetInfoType::IsCurrentProcessBeingDebugged: | 910 | case InfoType::DebuggerAttached: |
| 954 | *result = 0; | 911 | *result = 0; |
| 955 | return ResultSuccess; | 912 | return ResultSuccess; |
| 956 | 913 | ||
| 957 | case GetInfoType::RegisterResourceLimit: { | 914 | case InfoType::ResourceLimit: { |
| 958 | if (handle != 0) { | 915 | if (handle != 0) { |
| 959 | LOG_ERROR(Kernel, "Handle is non zero! handle={:08X}", handle); | 916 | LOG_ERROR(Kernel, "Handle is non zero! handle={:08X}", handle); |
| 960 | return ResultInvalidHandle; | 917 | return ResultInvalidHandle; |
| @@ -982,7 +939,7 @@ static Result GetInfo(Core::System& system, u64* result, u64 info_id, Handle han | |||
| 982 | return ResultSuccess; | 939 | return ResultSuccess; |
| 983 | } | 940 | } |
| 984 | 941 | ||
| 985 | case GetInfoType::RandomEntropy: | 942 | case InfoType::RandomEntropy: |
| 986 | if (handle != 0) { | 943 | if (handle != 0) { |
| 987 | LOG_ERROR(Kernel_SVC, "Process Handle is non zero, expected 0 result but got {:016X}", | 944 | LOG_ERROR(Kernel_SVC, "Process Handle is non zero, expected 0 result but got {:016X}", |
| 988 | handle); | 945 | handle); |
| @@ -998,13 +955,13 @@ static Result GetInfo(Core::System& system, u64* result, u64 info_id, Handle han | |||
| 998 | *result = system.Kernel().CurrentProcess()->GetRandomEntropy(info_sub_id); | 955 | *result = system.Kernel().CurrentProcess()->GetRandomEntropy(info_sub_id); |
| 999 | return ResultSuccess; | 956 | return ResultSuccess; |
| 1000 | 957 | ||
| 1001 | case GetInfoType::PrivilegedProcessId: | 958 | case InfoType::InitialProcessIdRange: |
| 1002 | LOG_WARNING(Kernel_SVC, | 959 | LOG_WARNING(Kernel_SVC, |
| 1003 | "(STUBBED) Attempted to query privileged process id bounds, returned 0"); | 960 | "(STUBBED) Attempted to query privileged process id bounds, returned 0"); |
| 1004 | *result = 0; | 961 | *result = 0; |
| 1005 | return ResultSuccess; | 962 | return ResultSuccess; |
| 1006 | 963 | ||
| 1007 | case GetInfoType::ThreadTickCount: { | 964 | case InfoType::ThreadTickCount: { |
| 1008 | constexpr u64 num_cpus = 4; | 965 | constexpr u64 num_cpus = 4; |
| 1009 | if (info_sub_id != 0xFFFFFFFFFFFFFFFF && info_sub_id >= num_cpus) { | 966 | if (info_sub_id != 0xFFFFFFFFFFFFFFFF && info_sub_id >= num_cpus) { |
| 1010 | LOG_ERROR(Kernel_SVC, "Core count is out of range, expected {} but got {}", num_cpus, | 967 | LOG_ERROR(Kernel_SVC, "Core count is out of range, expected {} but got {}", num_cpus, |
| @@ -1039,7 +996,7 @@ static Result GetInfo(Core::System& system, u64* result, u64 info_id, Handle han | |||
| 1039 | *result = out_ticks; | 996 | *result = out_ticks; |
| 1040 | return ResultSuccess; | 997 | return ResultSuccess; |
| 1041 | } | 998 | } |
| 1042 | case GetInfoType::IdleTickCount: { | 999 | case InfoType::IdleTickCount: { |
| 1043 | // Verify the input handle is invalid. | 1000 | // Verify the input handle is invalid. |
| 1044 | R_UNLESS(handle == InvalidHandle, ResultInvalidHandle); | 1001 | R_UNLESS(handle == InvalidHandle, ResultInvalidHandle); |
| 1045 | 1002 | ||
| @@ -1053,7 +1010,7 @@ static Result GetInfo(Core::System& system, u64* result, u64 info_id, Handle han | |||
| 1053 | *result = system.Kernel().CurrentScheduler()->GetIdleThread()->GetCpuTime(); | 1010 | *result = system.Kernel().CurrentScheduler()->GetIdleThread()->GetCpuTime(); |
| 1054 | return ResultSuccess; | 1011 | return ResultSuccess; |
| 1055 | } | 1012 | } |
| 1056 | case GetInfoType::MesosphereCurrentProcess: { | 1013 | case InfoType::MesosphereCurrentProcess: { |
| 1057 | // Verify the input handle is invalid. | 1014 | // Verify the input handle is invalid. |
| 1058 | R_UNLESS(handle == InvalidHandle, ResultInvalidHandle); | 1015 | R_UNLESS(handle == InvalidHandle, ResultInvalidHandle); |
| 1059 | 1016 | ||