forked from ShuriZma/suyu
1
0
Fork 0

kernel: svc: Fix duplicated InfoType enum

This commit is contained in:
Narr the Reg 2022-12-15 13:52:25 -06:00
parent dca4f0687a
commit 20cbf6f3db
1 changed files with 47 additions and 90 deletions

View File

@ -784,72 +784,29 @@ static Result GetInfo(Core::System& system, u64* result, u64 info_id, Handle han
LOG_TRACE(Kernel_SVC, "called info_id=0x{:X}, info_sub_id=0x{:X}, handle=0x{:08X}", info_id, LOG_TRACE(Kernel_SVC, "called info_id=0x{:X}, info_sub_id=0x{:X}, handle=0x{:08X}", info_id,
info_sub_id, handle); info_sub_id, handle);
enum class GetInfoType : u64 { const auto info_id_type = static_cast<InfoType>(info_id);
// 1.0.0+
AllowedCPUCoreMask = 0,
AllowedThreadPriorityMask = 1,
MapRegionBaseAddr = 2,
MapRegionSize = 3,
HeapRegionBaseAddr = 4,
HeapRegionSize = 5,
TotalPhysicalMemoryAvailable = 6,
TotalPhysicalMemoryUsed = 7,
IsCurrentProcessBeingDebugged = 8,
RegisterResourceLimit = 9,
IdleTickCount = 10,
RandomEntropy = 11,
ThreadTickCount = 0xF0000002,
// 2.0.0+
ASLRRegionBaseAddr = 12,
ASLRRegionSize = 13,
StackRegionBaseAddr = 14,
StackRegionSize = 15,
// 3.0.0+
SystemResourceSize = 16,
SystemResourceUsage = 17,
TitleId = 18,
// 4.0.0+
PrivilegedProcessId = 19,
// 5.0.0+
UserExceptionContextAddr = 20,
// 6.0.0+
TotalPhysicalMemoryAvailableWithoutSystemResource = 21,
TotalPhysicalMemoryUsedWithoutSystemResource = 22,
// 10.0.0+
IsApplication = 23,
// 13.0.0+
FreeThreadCount = 24,
// 14.0.0+
IsSvcPermitted = 26,
// Homebrew only
MesosphereMeta = 65000,
MesosphereCurrentProcess = 65001,
};
const auto info_id_type = static_cast<GetInfoType>(info_id);
switch (info_id_type) { switch (info_id_type) {
case GetInfoType::AllowedCPUCoreMask: case InfoType::CoreMask:
case GetInfoType::AllowedThreadPriorityMask: case InfoType::PriorityMask:
case GetInfoType::MapRegionBaseAddr: case InfoType::AliasRegionAddress:
case GetInfoType::MapRegionSize: case InfoType::AliasRegionSize:
case GetInfoType::HeapRegionBaseAddr: case InfoType::HeapRegionAddress:
case GetInfoType::HeapRegionSize: case InfoType::HeapRegionSize:
case GetInfoType::ASLRRegionBaseAddr: case InfoType::AslrRegionAddress:
case GetInfoType::ASLRRegionSize: case InfoType::AslrRegionSize:
case GetInfoType::StackRegionBaseAddr: case InfoType::StackRegionAddress:
case GetInfoType::StackRegionSize: case InfoType::StackRegionSize:
case GetInfoType::TotalPhysicalMemoryAvailable: case InfoType::TotalMemorySize:
case GetInfoType::TotalPhysicalMemoryUsed: case InfoType::UsedMemorySize:
case GetInfoType::SystemResourceSize: case InfoType::SystemResourceSizeTotal:
case GetInfoType::SystemResourceUsage: case InfoType::SystemResourceSizeUsed:
case GetInfoType::TitleId: case InfoType::ProgramId:
case GetInfoType::UserExceptionContextAddr: case InfoType::UserExceptionContextAddress:
case GetInfoType::TotalPhysicalMemoryAvailableWithoutSystemResource: case InfoType::TotalNonSystemMemorySize:
case GetInfoType::TotalPhysicalMemoryUsedWithoutSystemResource: case InfoType::UsedNonSystemMemorySize:
case GetInfoType::IsApplication: case InfoType::IsApplication:
case GetInfoType::FreeThreadCount: { case InfoType::FreeThreadCount: {
if (info_sub_id != 0) { if (info_sub_id != 0) {
LOG_ERROR(Kernel_SVC, "Info sub id is non zero! info_id={}, info_sub_id={}", info_id, LOG_ERROR(Kernel_SVC, "Info sub id is non zero! info_id={}, info_sub_id={}", info_id,
info_sub_id); info_sub_id);
@ -865,80 +822,80 @@ static Result GetInfo(Core::System& system, u64* result, u64 info_id, Handle han
} }
switch (info_id_type) { switch (info_id_type) {
case GetInfoType::AllowedCPUCoreMask: case InfoType::CoreMask:
*result = process->GetCoreMask(); *result = process->GetCoreMask();
return ResultSuccess; return ResultSuccess;
case GetInfoType::AllowedThreadPriorityMask: case InfoType::PriorityMask:
*result = process->GetPriorityMask(); *result = process->GetPriorityMask();
return ResultSuccess; return ResultSuccess;
case GetInfoType::MapRegionBaseAddr: case InfoType::AliasRegionAddress:
*result = process->PageTable().GetAliasRegionStart(); *result = process->PageTable().GetAliasRegionStart();
return ResultSuccess; return ResultSuccess;
case GetInfoType::MapRegionSize: case InfoType::AliasRegionSize:
*result = process->PageTable().GetAliasRegionSize(); *result = process->PageTable().GetAliasRegionSize();
return ResultSuccess; return ResultSuccess;
case GetInfoType::HeapRegionBaseAddr: case InfoType::HeapRegionAddress:
*result = process->PageTable().GetHeapRegionStart(); *result = process->PageTable().GetHeapRegionStart();
return ResultSuccess; return ResultSuccess;
case GetInfoType::HeapRegionSize: case InfoType::HeapRegionSize:
*result = process->PageTable().GetHeapRegionSize(); *result = process->PageTable().GetHeapRegionSize();
return ResultSuccess; return ResultSuccess;
case GetInfoType::ASLRRegionBaseAddr: case InfoType::AslrRegionAddress:
*result = process->PageTable().GetAliasCodeRegionStart(); *result = process->PageTable().GetAliasCodeRegionStart();
return ResultSuccess; return ResultSuccess;
case GetInfoType::ASLRRegionSize: case InfoType::AslrRegionSize:
*result = process->PageTable().GetAliasCodeRegionSize(); *result = process->PageTable().GetAliasCodeRegionSize();
return ResultSuccess; return ResultSuccess;
case GetInfoType::StackRegionBaseAddr: case InfoType::StackRegionAddress:
*result = process->PageTable().GetStackRegionStart(); *result = process->PageTable().GetStackRegionStart();
return ResultSuccess; return ResultSuccess;
case GetInfoType::StackRegionSize: case InfoType::StackRegionSize:
*result = process->PageTable().GetStackRegionSize(); *result = process->PageTable().GetStackRegionSize();
return ResultSuccess; return ResultSuccess;
case GetInfoType::TotalPhysicalMemoryAvailable: case InfoType::TotalMemorySize:
*result = process->GetTotalPhysicalMemoryAvailable(); *result = process->GetTotalPhysicalMemoryAvailable();
return ResultSuccess; return ResultSuccess;
case GetInfoType::TotalPhysicalMemoryUsed: case InfoType::UsedMemorySize:
*result = process->GetTotalPhysicalMemoryUsed(); *result = process->GetTotalPhysicalMemoryUsed();
return ResultSuccess; return ResultSuccess;
case GetInfoType::SystemResourceSize: case InfoType::SystemResourceSizeTotal:
*result = process->GetSystemResourceSize(); *result = process->GetSystemResourceSize();
return ResultSuccess; return ResultSuccess;
case GetInfoType::SystemResourceUsage: case InfoType::SystemResourceSizeUsed:
LOG_WARNING(Kernel_SVC, "(STUBBED) Attempted to query system resource usage"); LOG_WARNING(Kernel_SVC, "(STUBBED) Attempted to query system resource usage");
*result = process->GetSystemResourceUsage(); *result = process->GetSystemResourceUsage();
return ResultSuccess; return ResultSuccess;
case GetInfoType::TitleId: case InfoType::ProgramId:
*result = process->GetProgramID(); *result = process->GetProgramID();
return ResultSuccess; return ResultSuccess;
case GetInfoType::UserExceptionContextAddr: case InfoType::UserExceptionContextAddress:
*result = process->GetProcessLocalRegionAddress(); *result = process->GetProcessLocalRegionAddress();
return ResultSuccess; return ResultSuccess;
case GetInfoType::TotalPhysicalMemoryAvailableWithoutSystemResource: case InfoType::TotalNonSystemMemorySize:
*result = process->GetTotalPhysicalMemoryAvailableWithoutSystemResource(); *result = process->GetTotalPhysicalMemoryAvailableWithoutSystemResource();
return ResultSuccess; return ResultSuccess;
case GetInfoType::TotalPhysicalMemoryUsedWithoutSystemResource: case InfoType::UsedNonSystemMemorySize:
*result = process->GetTotalPhysicalMemoryUsedWithoutSystemResource(); *result = process->GetTotalPhysicalMemoryUsedWithoutSystemResource();
return ResultSuccess; return ResultSuccess;
case GetInfoType::FreeThreadCount: case InfoType::FreeThreadCount:
*result = process->GetFreeThreadCount(); *result = process->GetFreeThreadCount();
return ResultSuccess; return ResultSuccess;
@ -950,11 +907,11 @@ static Result GetInfo(Core::System& system, u64* result, u64 info_id, Handle han
return ResultInvalidEnumValue; return ResultInvalidEnumValue;
} }
case GetInfoType::IsCurrentProcessBeingDebugged: case InfoType::DebuggerAttached:
*result = 0; *result = 0;
return ResultSuccess; return ResultSuccess;
case GetInfoType::RegisterResourceLimit: { case InfoType::ResourceLimit: {
if (handle != 0) { if (handle != 0) {
LOG_ERROR(Kernel, "Handle is non zero! handle={:08X}", handle); LOG_ERROR(Kernel, "Handle is non zero! handle={:08X}", handle);
return ResultInvalidHandle; return ResultInvalidHandle;
@ -982,7 +939,7 @@ static Result GetInfo(Core::System& system, u64* result, u64 info_id, Handle han
return ResultSuccess; return ResultSuccess;
} }
case GetInfoType::RandomEntropy: case InfoType::RandomEntropy:
if (handle != 0) { if (handle != 0) {
LOG_ERROR(Kernel_SVC, "Process Handle is non zero, expected 0 result but got {:016X}", LOG_ERROR(Kernel_SVC, "Process Handle is non zero, expected 0 result but got {:016X}",
handle); handle);
@ -998,13 +955,13 @@ static Result GetInfo(Core::System& system, u64* result, u64 info_id, Handle han
*result = system.Kernel().CurrentProcess()->GetRandomEntropy(info_sub_id); *result = system.Kernel().CurrentProcess()->GetRandomEntropy(info_sub_id);
return ResultSuccess; return ResultSuccess;
case GetInfoType::PrivilegedProcessId: case InfoType::InitialProcessIdRange:
LOG_WARNING(Kernel_SVC, LOG_WARNING(Kernel_SVC,
"(STUBBED) Attempted to query privileged process id bounds, returned 0"); "(STUBBED) Attempted to query privileged process id bounds, returned 0");
*result = 0; *result = 0;
return ResultSuccess; return ResultSuccess;
case GetInfoType::ThreadTickCount: { case InfoType::ThreadTickCount: {
constexpr u64 num_cpus = 4; constexpr u64 num_cpus = 4;
if (info_sub_id != 0xFFFFFFFFFFFFFFFF && info_sub_id >= num_cpus) { if (info_sub_id != 0xFFFFFFFFFFFFFFFF && info_sub_id >= num_cpus) {
LOG_ERROR(Kernel_SVC, "Core count is out of range, expected {} but got {}", num_cpus, 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
*result = out_ticks; *result = out_ticks;
return ResultSuccess; return ResultSuccess;
} }
case GetInfoType::IdleTickCount: { case InfoType::IdleTickCount: {
// Verify the input handle is invalid. // Verify the input handle is invalid.
R_UNLESS(handle == InvalidHandle, ResultInvalidHandle); R_UNLESS(handle == InvalidHandle, ResultInvalidHandle);
@ -1053,7 +1010,7 @@ static Result GetInfo(Core::System& system, u64* result, u64 info_id, Handle han
*result = system.Kernel().CurrentScheduler()->GetIdleThread()->GetCpuTime(); *result = system.Kernel().CurrentScheduler()->GetIdleThread()->GetCpuTime();
return ResultSuccess; return ResultSuccess;
} }
case GetInfoType::MesosphereCurrentProcess: { case InfoType::MesosphereCurrentProcess: {
// Verify the input handle is invalid. // Verify the input handle is invalid.
R_UNLESS(handle == InvalidHandle, ResultInvalidHandle); R_UNLESS(handle == InvalidHandle, ResultInvalidHandle);