diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/core/hle/kernel/errors.h | 74 | ||||
| -rw-r--r-- | src/core/hle/kernel/svc.cpp | 20 |
2 files changed, 32 insertions, 62 deletions
diff --git a/src/core/hle/kernel/errors.h b/src/core/hle/kernel/errors.h index ee698c8a7..8b58d701d 100644 --- a/src/core/hle/kernel/errors.h +++ b/src/core/hle/kernel/errors.h | |||
| @@ -8,58 +8,28 @@ | |||
| 8 | 8 | ||
| 9 | namespace Kernel { | 9 | namespace Kernel { |
| 10 | 10 | ||
| 11 | namespace ErrCodes { | 11 | // Confirmed Switch kernel error codes |
| 12 | enum { | ||
| 13 | // Confirmed Switch OS error codes | ||
| 14 | MaxConnectionsReached = 7, | ||
| 15 | InvalidSize = 101, | ||
| 16 | InvalidAddress = 102, | ||
| 17 | HandleTableFull = 105, | ||
| 18 | InvalidMemoryState = 106, | ||
| 19 | InvalidMemoryPermissions = 108, | ||
| 20 | InvalidMemoryRange = 110, | ||
| 21 | InvalidThreadPriority = 112, | ||
| 22 | InvalidProcessorId = 113, | ||
| 23 | InvalidHandle = 114, | ||
| 24 | InvalidPointer = 115, | ||
| 25 | InvalidCombination = 116, | ||
| 26 | Timeout = 117, | ||
| 27 | SynchronizationCanceled = 118, | ||
| 28 | TooLarge = 119, | ||
| 29 | InvalidEnumValue = 120, | ||
| 30 | NoSuchEntry = 121, | ||
| 31 | AlreadyRegistered = 122, | ||
| 32 | SessionClosed = 123, | ||
| 33 | InvalidState = 125, | ||
| 34 | ResourceLimitExceeded = 132, | ||
| 35 | }; | ||
| 36 | } | ||
| 37 | 12 | ||
| 38 | // WARNING: The kernel is quite inconsistent in it's usage of errors code. Make sure to always | 13 | constexpr ResultCode ERR_MAX_CONNECTIONS_REACHED{ErrorModule::Kernel, 7}; |
| 39 | // double check that the code matches before re-using the constant. | 14 | constexpr ResultCode ERR_INVALID_SIZE{ErrorModule::Kernel, 101}; |
| 40 | 15 | constexpr ResultCode ERR_INVALID_ADDRESS{ErrorModule::Kernel, 102}; | |
| 41 | constexpr ResultCode ERR_HANDLE_TABLE_FULL(ErrorModule::Kernel, ErrCodes::HandleTableFull); | 16 | constexpr ResultCode ERR_HANDLE_TABLE_FULL{ErrorModule::Kernel, 105}; |
| 42 | constexpr ResultCode ERR_SESSION_CLOSED_BY_REMOTE(ErrorModule::Kernel, ErrCodes::SessionClosed); | 17 | constexpr ResultCode ERR_INVALID_ADDRESS_STATE{ErrorModule::Kernel, 106}; |
| 43 | constexpr ResultCode ERR_PORT_NAME_TOO_LONG(ErrorModule::Kernel, ErrCodes::TooLarge); | 18 | constexpr ResultCode ERR_INVALID_MEMORY_PERMISSIONS{ErrorModule::Kernel, 108}; |
| 44 | constexpr ResultCode ERR_MAX_CONNECTIONS_REACHED(ErrorModule::Kernel, | 19 | constexpr ResultCode ERR_INVALID_MEMORY_RANGE{ErrorModule::Kernel, 110}; |
| 45 | ErrCodes::MaxConnectionsReached); | 20 | constexpr ResultCode ERR_INVALID_PROCESSOR_ID{ErrorModule::Kernel, 113}; |
| 46 | constexpr ResultCode ERR_INVALID_ENUM_VALUE(ErrorModule::Kernel, ErrCodes::InvalidEnumValue); | 21 | constexpr ResultCode ERR_INVALID_THREAD_PRIORITY{ErrorModule::Kernel, 112}; |
| 47 | constexpr ResultCode ERR_INVALID_COMBINATION_KERNEL(ErrorModule::Kernel, | 22 | constexpr ResultCode ERR_INVALID_HANDLE{ErrorModule::Kernel, 114}; |
| 48 | ErrCodes::InvalidCombination); | 23 | constexpr ResultCode ERR_INVALID_POINTER{ErrorModule::Kernel, 115}; |
| 49 | constexpr ResultCode ERR_INVALID_ADDRESS(ErrorModule::Kernel, ErrCodes::InvalidAddress); | 24 | constexpr ResultCode ERR_INVALID_COMBINATION{ErrorModule::Kernel, 116}; |
| 50 | constexpr ResultCode ERR_INVALID_ADDRESS_STATE(ErrorModule::Kernel, ErrCodes::InvalidMemoryState); | 25 | constexpr ResultCode RESULT_TIMEOUT{ErrorModule::Kernel, 117}; |
| 51 | constexpr ResultCode ERR_INVALID_MEMORY_PERMISSIONS(ErrorModule::Kernel, | 26 | constexpr ResultCode ERR_SYNCHRONIZATION_CANCELED{ErrorModule::Kernel, 118}; |
| 52 | ErrCodes::InvalidMemoryPermissions); | 27 | constexpr ResultCode ERR_OUT_OF_RANGE{ErrorModule::Kernel, 119}; |
| 53 | constexpr ResultCode ERR_INVALID_MEMORY_RANGE(ErrorModule::Kernel, ErrCodes::InvalidMemoryRange); | 28 | constexpr ResultCode ERR_INVALID_ENUM_VALUE{ErrorModule::Kernel, 120}; |
| 54 | constexpr ResultCode ERR_INVALID_HANDLE(ErrorModule::Kernel, ErrCodes::InvalidHandle); | 29 | constexpr ResultCode ERR_NOT_FOUND{ErrorModule::Kernel, 121}; |
| 55 | constexpr ResultCode ERR_INVALID_PROCESSOR_ID(ErrorModule::Kernel, ErrCodes::InvalidProcessorId); | 30 | constexpr ResultCode ERR_ALREADY_REGISTERED{ErrorModule::Kernel, 122}; |
| 56 | constexpr ResultCode ERR_INVALID_SIZE(ErrorModule::Kernel, ErrCodes::InvalidSize); | 31 | constexpr ResultCode ERR_SESSION_CLOSED_BY_REMOTE{ErrorModule::Kernel, 123}; |
| 57 | constexpr ResultCode ERR_ALREADY_REGISTERED(ErrorModule::Kernel, ErrCodes::AlreadyRegistered); | 32 | constexpr ResultCode ERR_INVALID_STATE{ErrorModule::Kernel, 125}; |
| 58 | constexpr ResultCode ERR_INVALID_STATE(ErrorModule::Kernel, ErrCodes::InvalidState); | 33 | constexpr ResultCode ERR_RESOURCE_LIMIT_EXCEEDED{ErrorModule::Kernel, 132}; |
| 59 | constexpr ResultCode ERR_INVALID_THREAD_PRIORITY(ErrorModule::Kernel, | ||
| 60 | ErrCodes::InvalidThreadPriority); | ||
| 61 | constexpr ResultCode ERR_INVALID_POINTER(ErrorModule::Kernel, ErrCodes::InvalidPointer); | ||
| 62 | constexpr ResultCode ERR_NOT_FOUND(ErrorModule::Kernel, ErrCodes::NoSuchEntry); | ||
| 63 | constexpr ResultCode RESULT_TIMEOUT(ErrorModule::Kernel, ErrCodes::Timeout); | ||
| 64 | 34 | ||
| 65 | } // namespace Kernel | 35 | } // namespace Kernel |
diff --git a/src/core/hle/kernel/svc.cpp b/src/core/hle/kernel/svc.cpp index 5f4521122..2e7c9d094 100644 --- a/src/core/hle/kernel/svc.cpp +++ b/src/core/hle/kernel/svc.cpp | |||
| @@ -214,7 +214,7 @@ static ResultCode ConnectToNamedPort(Handle* out_handle, VAddr port_name_address | |||
| 214 | // Read 1 char beyond the max allowed port name to detect names that are too long. | 214 | // Read 1 char beyond the max allowed port name to detect names that are too long. |
| 215 | std::string port_name = Memory::ReadCString(port_name_address, PortNameMaxLength + 1); | 215 | std::string port_name = Memory::ReadCString(port_name_address, PortNameMaxLength + 1); |
| 216 | if (port_name.size() > PortNameMaxLength) { | 216 | if (port_name.size() > PortNameMaxLength) { |
| 217 | return ERR_PORT_NAME_TOO_LONG; | 217 | return ERR_OUT_OF_RANGE; |
| 218 | } | 218 | } |
| 219 | 219 | ||
| 220 | LOG_TRACE(Kernel_SVC, "called port_name={}", port_name); | 220 | LOG_TRACE(Kernel_SVC, "called port_name={}", port_name); |
| @@ -310,8 +310,9 @@ static ResultCode WaitSynchronization(Handle* index, VAddr handles_address, u64 | |||
| 310 | 310 | ||
| 311 | static constexpr u64 MaxHandles = 0x40; | 311 | static constexpr u64 MaxHandles = 0x40; |
| 312 | 312 | ||
| 313 | if (handle_count > MaxHandles) | 313 | if (handle_count > MaxHandles) { |
| 314 | return ResultCode(ErrorModule::Kernel, ErrCodes::TooLarge); | 314 | return ERR_OUT_OF_RANGE; |
| 315 | } | ||
| 315 | 316 | ||
| 316 | auto* const thread = GetCurrentThread(); | 317 | auto* const thread = GetCurrentThread(); |
| 317 | 318 | ||
| @@ -376,8 +377,7 @@ static ResultCode CancelSynchronization(Handle thread_handle) { | |||
| 376 | } | 377 | } |
| 377 | 378 | ||
| 378 | ASSERT(thread->GetStatus() == ThreadStatus::WaitSynchAny); | 379 | ASSERT(thread->GetStatus() == ThreadStatus::WaitSynchAny); |
| 379 | thread->SetWaitSynchronizationResult( | 380 | thread->SetWaitSynchronizationResult(ERR_SYNCHRONIZATION_CANCELED); |
| 380 | ResultCode(ErrorModule::Kernel, ErrCodes::SynchronizationCanceled)); | ||
| 381 | thread->ResumeFromWait(); | 381 | thread->ResumeFromWait(); |
| 382 | return RESULT_SUCCESS; | 382 | return RESULT_SUCCESS; |
| 383 | } | 383 | } |
| @@ -606,7 +606,7 @@ static ResultCode GetInfo(u64* result, u64 info_id, u64 handle, u64 info_sub_id) | |||
| 606 | } | 606 | } |
| 607 | 607 | ||
| 608 | if (info_sub_id >= Process::RANDOM_ENTROPY_SIZE) { | 608 | if (info_sub_id >= Process::RANDOM_ENTROPY_SIZE) { |
| 609 | return ERR_INVALID_COMBINATION_KERNEL; | 609 | return ERR_INVALID_COMBINATION; |
| 610 | } | 610 | } |
| 611 | 611 | ||
| 612 | *result = current_process->GetRandomEntropy(info_sub_id); | 612 | *result = current_process->GetRandomEntropy(info_sub_id); |
| @@ -643,7 +643,7 @@ static ResultCode GetInfo(u64* result, u64 info_id, u64 handle, u64 info_sub_id) | |||
| 643 | case GetInfoType::ThreadTickCount: { | 643 | case GetInfoType::ThreadTickCount: { |
| 644 | constexpr u64 num_cpus = 4; | 644 | constexpr u64 num_cpus = 4; |
| 645 | if (info_sub_id != 0xFFFFFFFFFFFFFFFF && info_sub_id >= num_cpus) { | 645 | if (info_sub_id != 0xFFFFFFFFFFFFFFFF && info_sub_id >= num_cpus) { |
| 646 | return ERR_INVALID_COMBINATION_KERNEL; | 646 | return ERR_INVALID_COMBINATION; |
| 647 | } | 647 | } |
| 648 | 648 | ||
| 649 | const auto thread = | 649 | const auto thread = |
| @@ -1236,7 +1236,7 @@ static ResultCode SetThreadCoreMask(Handle thread_handle, u32 core, u64 mask) { | |||
| 1236 | } | 1236 | } |
| 1237 | 1237 | ||
| 1238 | if (mask == 0) { | 1238 | if (mask == 0) { |
| 1239 | return ResultCode(ErrorModule::Kernel, ErrCodes::InvalidCombination); | 1239 | return ERR_INVALID_COMBINATION; |
| 1240 | } | 1240 | } |
| 1241 | 1241 | ||
| 1242 | /// This value is used to only change the affinity mask without changing the current ideal core. | 1242 | /// This value is used to only change the affinity mask without changing the current ideal core. |
| @@ -1245,12 +1245,12 @@ static ResultCode SetThreadCoreMask(Handle thread_handle, u32 core, u64 mask) { | |||
| 1245 | if (core == OnlyChangeMask) { | 1245 | if (core == OnlyChangeMask) { |
| 1246 | core = thread->GetIdealCore(); | 1246 | core = thread->GetIdealCore(); |
| 1247 | } else if (core >= Core::NUM_CPU_CORES && core != static_cast<u32>(-1)) { | 1247 | } else if (core >= Core::NUM_CPU_CORES && core != static_cast<u32>(-1)) { |
| 1248 | return ResultCode(ErrorModule::Kernel, ErrCodes::InvalidProcessorId); | 1248 | return ERR_INVALID_PROCESSOR_ID; |
| 1249 | } | 1249 | } |
| 1250 | 1250 | ||
| 1251 | // Error out if the input core isn't enabled in the input mask. | 1251 | // Error out if the input core isn't enabled in the input mask. |
| 1252 | if (core < Core::NUM_CPU_CORES && (mask & (1ull << core)) == 0) { | 1252 | if (core < Core::NUM_CPU_CORES && (mask & (1ull << core)) == 0) { |
| 1253 | return ResultCode(ErrorModule::Kernel, ErrCodes::InvalidCombination); | 1253 | return ERR_INVALID_COMBINATION; |
| 1254 | } | 1254 | } |
| 1255 | 1255 | ||
| 1256 | thread->ChangeCore(core, mask); | 1256 | thread->ChangeCore(core, mask); |