diff options
| author | 2018-10-25 01:10:26 -0400 | |
|---|---|---|
| committer | 2018-10-25 01:10:26 -0400 | |
| commit | c94db0e0719ad66c6d49bab29b8ed497c55a55f3 (patch) | |
| tree | 89fc126616fd143866e23dab45a3d064a6c48f87 /src | |
| parent | Merge pull request #1524 from FernandoS27/layers-fix (diff) | |
| parent | kernel/errors: Remove now-unused, unnecessary, error codes (diff) | |
| download | yuzu-c94db0e0719ad66c6d49bab29b8ed497c55a55f3.tar.gz yuzu-c94db0e0719ad66c6d49bab29b8ed497c55a55f3.tar.xz yuzu-c94db0e0719ad66c6d49bab29b8ed497c55a55f3.zip | |
Merge pull request #1577 from lioncash/err
kernel/error: Amend error return code values
Diffstat (limited to '')
| -rw-r--r-- | src/core/hle/ipc.h | 5 | ||||
| -rw-r--r-- | src/core/hle/kernel/errors.h | 21 | ||||
| -rw-r--r-- | src/core/hle/kernel/server_port.cpp | 4 | ||||
| -rw-r--r-- | src/core/hle/kernel/shared_memory.cpp | 7 | ||||
| -rw-r--r-- | src/core/hle/kernel/svc.cpp | 13 |
5 files changed, 16 insertions, 34 deletions
diff --git a/src/core/hle/ipc.h b/src/core/hle/ipc.h index 419f45896..ed84197b3 100644 --- a/src/core/hle/ipc.h +++ b/src/core/hle/ipc.h | |||
| @@ -14,11 +14,6 @@ namespace IPC { | |||
| 14 | /// Size of the command buffer area, in 32-bit words. | 14 | /// Size of the command buffer area, in 32-bit words. |
| 15 | constexpr std::size_t COMMAND_BUFFER_LENGTH = 0x100 / sizeof(u32); | 15 | constexpr std::size_t COMMAND_BUFFER_LENGTH = 0x100 / sizeof(u32); |
| 16 | 16 | ||
| 17 | // These errors are commonly returned by invalid IPC translations, so alias them here for | ||
| 18 | // convenience. | ||
| 19 | // TODO(yuriks): These will probably go away once translation is implemented inside the kernel. | ||
| 20 | constexpr auto ERR_INVALID_HANDLE = Kernel::ERR_INVALID_HANDLE_OS; | ||
| 21 | |||
| 22 | enum class ControlCommand : u32 { | 17 | enum class ControlCommand : u32 { |
| 23 | ConvertSessionToDomain = 0, | 18 | ConvertSessionToDomain = 0, |
| 24 | ConvertDomainToSession = 1, | 19 | ConvertDomainToSession = 1, |
diff --git a/src/core/hle/kernel/errors.h b/src/core/hle/kernel/errors.h index 885259618..ee698c8a7 100644 --- a/src/core/hle/kernel/errors.h +++ b/src/core/hle/kernel/errors.h | |||
| @@ -10,11 +10,6 @@ namespace Kernel { | |||
| 10 | 10 | ||
| 11 | namespace ErrCodes { | 11 | namespace ErrCodes { |
| 12 | enum { | 12 | enum { |
| 13 | // TODO(Subv): Remove these 3DS OS error codes. | ||
| 14 | SessionClosedByRemote = 26, | ||
| 15 | NoPendingSessions = 35, | ||
| 16 | InvalidBufferDescriptor = 48, | ||
| 17 | |||
| 18 | // Confirmed Switch OS error codes | 13 | // Confirmed Switch OS error codes |
| 19 | MaxConnectionsReached = 7, | 14 | MaxConnectionsReached = 7, |
| 20 | InvalidSize = 101, | 15 | InvalidSize = 101, |
| @@ -26,6 +21,7 @@ enum { | |||
| 26 | InvalidThreadPriority = 112, | 21 | InvalidThreadPriority = 112, |
| 27 | InvalidProcessorId = 113, | 22 | InvalidProcessorId = 113, |
| 28 | InvalidHandle = 114, | 23 | InvalidHandle = 114, |
| 24 | InvalidPointer = 115, | ||
| 29 | InvalidCombination = 116, | 25 | InvalidCombination = 116, |
| 30 | Timeout = 117, | 26 | Timeout = 117, |
| 31 | SynchronizationCanceled = 118, | 27 | SynchronizationCanceled = 118, |
| @@ -33,6 +29,7 @@ enum { | |||
| 33 | InvalidEnumValue = 120, | 29 | InvalidEnumValue = 120, |
| 34 | NoSuchEntry = 121, | 30 | NoSuchEntry = 121, |
| 35 | AlreadyRegistered = 122, | 31 | AlreadyRegistered = 122, |
| 32 | SessionClosed = 123, | ||
| 36 | InvalidState = 125, | 33 | InvalidState = 125, |
| 37 | ResourceLimitExceeded = 132, | 34 | ResourceLimitExceeded = 132, |
| 38 | }; | 35 | }; |
| @@ -41,18 +38,14 @@ enum { | |||
| 41 | // WARNING: The kernel is quite inconsistent in it's usage of errors code. Make sure to always | 38 | // WARNING: The kernel is quite inconsistent in it's usage of errors code. Make sure to always |
| 42 | // double check that the code matches before re-using the constant. | 39 | // double check that the code matches before re-using the constant. |
| 43 | 40 | ||
| 44 | // TODO(bunnei): Replace -1 with correct errors for Switch OS | ||
| 45 | constexpr ResultCode ERR_HANDLE_TABLE_FULL(ErrorModule::Kernel, ErrCodes::HandleTableFull); | 41 | constexpr ResultCode ERR_HANDLE_TABLE_FULL(ErrorModule::Kernel, ErrCodes::HandleTableFull); |
| 46 | constexpr ResultCode ERR_SESSION_CLOSED_BY_REMOTE(-1); | 42 | constexpr ResultCode ERR_SESSION_CLOSED_BY_REMOTE(ErrorModule::Kernel, ErrCodes::SessionClosed); |
| 47 | constexpr ResultCode ERR_PORT_NAME_TOO_LONG(ErrorModule::Kernel, ErrCodes::TooLarge); | 43 | constexpr ResultCode ERR_PORT_NAME_TOO_LONG(ErrorModule::Kernel, ErrCodes::TooLarge); |
| 48 | constexpr ResultCode ERR_MAX_CONNECTIONS_REACHED(ErrorModule::Kernel, | 44 | constexpr ResultCode ERR_MAX_CONNECTIONS_REACHED(ErrorModule::Kernel, |
| 49 | ErrCodes::MaxConnectionsReached); | 45 | ErrCodes::MaxConnectionsReached); |
| 50 | constexpr ResultCode ERR_INVALID_ENUM_VALUE(ErrorModule::Kernel, ErrCodes::InvalidEnumValue); | 46 | constexpr ResultCode ERR_INVALID_ENUM_VALUE(ErrorModule::Kernel, ErrCodes::InvalidEnumValue); |
| 51 | constexpr ResultCode ERR_INVALID_ENUM_VALUE_FND(-1); | ||
| 52 | constexpr ResultCode ERR_INVALID_COMBINATION(-1); | ||
| 53 | constexpr ResultCode ERR_INVALID_COMBINATION_KERNEL(ErrorModule::Kernel, | 47 | constexpr ResultCode ERR_INVALID_COMBINATION_KERNEL(ErrorModule::Kernel, |
| 54 | ErrCodes::InvalidCombination); | 48 | ErrCodes::InvalidCombination); |
| 55 | constexpr ResultCode ERR_OUT_OF_MEMORY(-1); | ||
| 56 | constexpr ResultCode ERR_INVALID_ADDRESS(ErrorModule::Kernel, ErrCodes::InvalidAddress); | 49 | constexpr ResultCode ERR_INVALID_ADDRESS(ErrorModule::Kernel, ErrCodes::InvalidAddress); |
| 57 | constexpr ResultCode ERR_INVALID_ADDRESS_STATE(ErrorModule::Kernel, ErrCodes::InvalidMemoryState); | 50 | constexpr ResultCode ERR_INVALID_ADDRESS_STATE(ErrorModule::Kernel, ErrCodes::InvalidMemoryState); |
| 58 | constexpr ResultCode ERR_INVALID_MEMORY_PERMISSIONS(ErrorModule::Kernel, | 51 | constexpr ResultCode ERR_INVALID_MEMORY_PERMISSIONS(ErrorModule::Kernel, |
| @@ -65,14 +58,8 @@ constexpr ResultCode ERR_ALREADY_REGISTERED(ErrorModule::Kernel, ErrCodes::Alrea | |||
| 65 | constexpr ResultCode ERR_INVALID_STATE(ErrorModule::Kernel, ErrCodes::InvalidState); | 58 | constexpr ResultCode ERR_INVALID_STATE(ErrorModule::Kernel, ErrCodes::InvalidState); |
| 66 | constexpr ResultCode ERR_INVALID_THREAD_PRIORITY(ErrorModule::Kernel, | 59 | constexpr ResultCode ERR_INVALID_THREAD_PRIORITY(ErrorModule::Kernel, |
| 67 | ErrCodes::InvalidThreadPriority); | 60 | ErrCodes::InvalidThreadPriority); |
| 68 | constexpr ResultCode ERR_INVALID_POINTER(-1); | 61 | constexpr ResultCode ERR_INVALID_POINTER(ErrorModule::Kernel, ErrCodes::InvalidPointer); |
| 69 | constexpr ResultCode ERR_INVALID_OBJECT_ADDR(-1); | ||
| 70 | constexpr ResultCode ERR_NOT_AUTHORIZED(-1); | ||
| 71 | /// Alternate code returned instead of ERR_INVALID_HANDLE in some code paths. | ||
| 72 | constexpr ResultCode ERR_INVALID_HANDLE_OS(-1); | ||
| 73 | constexpr ResultCode ERR_NOT_FOUND(ErrorModule::Kernel, ErrCodes::NoSuchEntry); | 62 | constexpr ResultCode ERR_NOT_FOUND(ErrorModule::Kernel, ErrCodes::NoSuchEntry); |
| 74 | constexpr ResultCode RESULT_TIMEOUT(ErrorModule::Kernel, ErrCodes::Timeout); | 63 | constexpr ResultCode RESULT_TIMEOUT(ErrorModule::Kernel, ErrCodes::Timeout); |
| 75 | /// Returned when Accept() is called on a port with no sessions to be accepted. | ||
| 76 | constexpr ResultCode ERR_NO_PENDING_SESSIONS(-1); | ||
| 77 | 64 | ||
| 78 | } // namespace Kernel | 65 | } // namespace Kernel |
diff --git a/src/core/hle/kernel/server_port.cpp b/src/core/hle/kernel/server_port.cpp index 3792e3e18..d6ceeb2da 100644 --- a/src/core/hle/kernel/server_port.cpp +++ b/src/core/hle/kernel/server_port.cpp | |||
| @@ -18,7 +18,7 @@ ServerPort::~ServerPort() = default; | |||
| 18 | 18 | ||
| 19 | ResultVal<SharedPtr<ServerSession>> ServerPort::Accept() { | 19 | ResultVal<SharedPtr<ServerSession>> ServerPort::Accept() { |
| 20 | if (pending_sessions.empty()) { | 20 | if (pending_sessions.empty()) { |
| 21 | return ERR_NO_PENDING_SESSIONS; | 21 | return ERR_NOT_FOUND; |
| 22 | } | 22 | } |
| 23 | 23 | ||
| 24 | auto session = std::move(pending_sessions.back()); | 24 | auto session = std::move(pending_sessions.back()); |
| @@ -28,7 +28,7 @@ ResultVal<SharedPtr<ServerSession>> ServerPort::Accept() { | |||
| 28 | 28 | ||
| 29 | bool ServerPort::ShouldWait(Thread* thread) const { | 29 | bool ServerPort::ShouldWait(Thread* thread) const { |
| 30 | // If there are no pending sessions, we wait until a new one is added. | 30 | // If there are no pending sessions, we wait until a new one is added. |
| 31 | return pending_sessions.size() == 0; | 31 | return pending_sessions.empty(); |
| 32 | } | 32 | } |
| 33 | 33 | ||
| 34 | void ServerPort::Acquire(Thread* thread) { | 34 | void ServerPort::Acquire(Thread* thread) { |
diff --git a/src/core/hle/kernel/shared_memory.cpp b/src/core/hle/kernel/shared_memory.cpp index d061e6155..a016a86b6 100644 --- a/src/core/hle/kernel/shared_memory.cpp +++ b/src/core/hle/kernel/shared_memory.cpp | |||
| @@ -80,20 +80,19 @@ SharedPtr<SharedMemory> SharedMemory::CreateForApplet( | |||
| 80 | 80 | ||
| 81 | ResultCode SharedMemory::Map(Process* target_process, VAddr address, MemoryPermission permissions, | 81 | ResultCode SharedMemory::Map(Process* target_process, VAddr address, MemoryPermission permissions, |
| 82 | MemoryPermission other_permissions) { | 82 | MemoryPermission other_permissions) { |
| 83 | 83 | const MemoryPermission own_other_permissions = | |
| 84 | MemoryPermission own_other_permissions = | ||
| 85 | target_process == owner_process ? this->permissions : this->other_permissions; | 84 | target_process == owner_process ? this->permissions : this->other_permissions; |
| 86 | 85 | ||
| 87 | // Automatically allocated memory blocks can only be mapped with other_permissions = DontCare | 86 | // Automatically allocated memory blocks can only be mapped with other_permissions = DontCare |
| 88 | if (base_address == 0 && other_permissions != MemoryPermission::DontCare) { | 87 | if (base_address == 0 && other_permissions != MemoryPermission::DontCare) { |
| 89 | return ERR_INVALID_COMBINATION; | 88 | return ERR_INVALID_MEMORY_PERMISSIONS; |
| 90 | } | 89 | } |
| 91 | 90 | ||
| 92 | // Error out if the requested permissions don't match what the creator process allows. | 91 | // Error out if the requested permissions don't match what the creator process allows. |
| 93 | if (static_cast<u32>(permissions) & ~static_cast<u32>(own_other_permissions)) { | 92 | if (static_cast<u32>(permissions) & ~static_cast<u32>(own_other_permissions)) { |
| 94 | LOG_ERROR(Kernel, "cannot map id={}, address=0x{:X} name={}, permissions don't match", | 93 | LOG_ERROR(Kernel, "cannot map id={}, address=0x{:X} name={}, permissions don't match", |
| 95 | GetObjectId(), address, name); | 94 | GetObjectId(), address, name); |
| 96 | return ERR_INVALID_COMBINATION; | 95 | return ERR_INVALID_MEMORY_PERMISSIONS; |
| 97 | } | 96 | } |
| 98 | 97 | ||
| 99 | // Error out if the provided permissions are not compatible with what the creator process needs. | 98 | // Error out if the provided permissions are not compatible with what the creator process needs. |
diff --git a/src/core/hle/kernel/svc.cpp b/src/core/hle/kernel/svc.cpp index 9a783d524..a5302d924 100644 --- a/src/core/hle/kernel/svc.cpp +++ b/src/core/hle/kernel/svc.cpp | |||
| @@ -594,16 +594,17 @@ static ResultCode SetThreadPriority(Handle handle, u32 priority) { | |||
| 594 | } | 594 | } |
| 595 | 595 | ||
| 596 | const auto* const current_process = Core::CurrentProcess(); | 596 | const auto* const current_process = Core::CurrentProcess(); |
| 597 | SharedPtr<Thread> thread = current_process->GetHandleTable().Get<Thread>(handle); | ||
| 598 | if (!thread) { | ||
| 599 | return ERR_INVALID_HANDLE; | ||
| 600 | } | ||
| 601 | 597 | ||
| 602 | // Note: The kernel uses the current process's resource limit instead of | 598 | // Note: The kernel uses the current process's resource limit instead of |
| 603 | // the one from the thread owner's resource limit. | 599 | // the one from the thread owner's resource limit. |
| 604 | const ResourceLimit& resource_limit = current_process->GetResourceLimit(); | 600 | const ResourceLimit& resource_limit = current_process->GetResourceLimit(); |
| 605 | if (resource_limit.GetMaxResourceValue(ResourceType::Priority) > priority) { | 601 | if (resource_limit.GetMaxResourceValue(ResourceType::Priority) > priority) { |
| 606 | return ERR_NOT_AUTHORIZED; | 602 | return ERR_INVALID_THREAD_PRIORITY; |
| 603 | } | ||
| 604 | |||
| 605 | SharedPtr<Thread> thread = current_process->GetHandleTable().Get<Thread>(handle); | ||
| 606 | if (!thread) { | ||
| 607 | return ERR_INVALID_HANDLE; | ||
| 607 | } | 608 | } |
| 608 | 609 | ||
| 609 | thread->SetPriority(priority); | 610 | thread->SetPriority(priority); |
| @@ -745,7 +746,7 @@ static ResultCode CreateThread(Handle* out_handle, VAddr entry_point, u64 arg, V | |||
| 745 | auto* const current_process = Core::CurrentProcess(); | 746 | auto* const current_process = Core::CurrentProcess(); |
| 746 | const ResourceLimit& resource_limit = current_process->GetResourceLimit(); | 747 | const ResourceLimit& resource_limit = current_process->GetResourceLimit(); |
| 747 | if (resource_limit.GetMaxResourceValue(ResourceType::Priority) > priority) { | 748 | if (resource_limit.GetMaxResourceValue(ResourceType::Priority) > priority) { |
| 748 | return ERR_NOT_AUTHORIZED; | 749 | return ERR_INVALID_THREAD_PRIORITY; |
| 749 | } | 750 | } |
| 750 | 751 | ||
| 751 | if (processor_id == THREADPROCESSORID_DEFAULT) { | 752 | if (processor_id == THREADPROCESSORID_DEFAULT) { |