diff options
| -rw-r--r-- | src/core/CMakeLists.txt | 1 | ||||
| -rw-r--r-- | src/core/hle/function_wrappers.h | 2 | ||||
| -rw-r--r-- | src/core/hle/ipc.h | 7 | ||||
| -rw-r--r-- | src/core/hle/kernel/address_arbiter.cpp | 7 | ||||
| -rw-r--r-- | src/core/hle/kernel/client_port.cpp | 4 | ||||
| -rw-r--r-- | src/core/hle/kernel/client_session.cpp | 3 | ||||
| -rw-r--r-- | src/core/hle/kernel/errors.h | 98 | ||||
| -rw-r--r-- | src/core/hle/kernel/kernel.cpp | 1 | ||||
| -rw-r--r-- | src/core/hle/kernel/kernel.h | 7 | ||||
| -rw-r--r-- | src/core/hle/kernel/process.cpp | 1 | ||||
| -rw-r--r-- | src/core/hle/kernel/semaphore.cpp | 7 | ||||
| -rw-r--r-- | src/core/hle/kernel/shared_memory.cpp | 16 | ||||
| -rw-r--r-- | src/core/hle/kernel/thread.cpp | 24 | ||||
| -rw-r--r-- | src/core/hle/kernel/thread.h | 2 | ||||
| -rw-r--r-- | src/core/hle/kernel/vm_manager.cpp | 1 | ||||
| -rw-r--r-- | src/core/hle/kernel/vm_manager.h | 8 | ||||
| -rw-r--r-- | src/core/hle/result.h | 6 | ||||
| -rw-r--r-- | src/core/hle/service/boss/boss.cpp | 4 | ||||
| -rw-r--r-- | src/core/hle/service/dsp_dsp.cpp | 4 | ||||
| -rw-r--r-- | src/core/hle/service/fs/fs_user.cpp | 4 | ||||
| -rw-r--r-- | src/core/hle/service/ir/ir_user.cpp | 3 | ||||
| -rw-r--r-- | src/core/hle/service/srv.cpp | 4 | ||||
| -rw-r--r-- | src/core/hle/svc.cpp | 96 |
23 files changed, 178 insertions, 132 deletions
diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt index c733e5d21..e0b9b98e8 100644 --- a/src/core/CMakeLists.txt +++ b/src/core/CMakeLists.txt | |||
| @@ -230,6 +230,7 @@ set(HEADERS | |||
| 230 | hle/kernel/address_arbiter.h | 230 | hle/kernel/address_arbiter.h |
| 231 | hle/kernel/client_port.h | 231 | hle/kernel/client_port.h |
| 232 | hle/kernel/client_session.h | 232 | hle/kernel/client_session.h |
| 233 | hle/kernel/errors.h | ||
| 233 | hle/kernel/event.h | 234 | hle/kernel/event.h |
| 234 | hle/kernel/kernel.h | 235 | hle/kernel/kernel.h |
| 235 | hle/kernel/memory.h | 236 | hle/kernel/memory.h |
diff --git a/src/core/hle/function_wrappers.h b/src/core/hle/function_wrappers.h index f6eb900f0..18b6e7017 100644 --- a/src/core/hle/function_wrappers.h +++ b/src/core/hle/function_wrappers.h | |||
| @@ -53,7 +53,7 @@ void Wrap() { | |||
| 53 | FuncReturn(retval); | 53 | FuncReturn(retval); |
| 54 | } | 54 | } |
| 55 | 55 | ||
| 56 | template <ResultCode func(u32*, s32, u32, u32, u32, s32)> | 56 | template <ResultCode func(u32*, u32, u32, u32, u32, s32)> |
| 57 | void Wrap() { | 57 | void Wrap() { |
| 58 | u32 param_1 = 0; | 58 | u32 param_1 = 0; |
| 59 | u32 retval = func(¶m_1, PARAM(0), PARAM(1), PARAM(2), PARAM(3), PARAM(4)).raw; | 59 | u32 retval = func(¶m_1, PARAM(0), PARAM(1), PARAM(2), PARAM(3), PARAM(4)).raw; |
diff --git a/src/core/hle/ipc.h b/src/core/hle/ipc.h index 3a5d481a5..303ca090d 100644 --- a/src/core/hle/ipc.h +++ b/src/core/hle/ipc.h | |||
| @@ -5,6 +5,7 @@ | |||
| 5 | #pragma once | 5 | #pragma once |
| 6 | 6 | ||
| 7 | #include "common/common_types.h" | 7 | #include "common/common_types.h" |
| 8 | #include "core/hle/kernel/errors.h" | ||
| 8 | #include "core/hle/kernel/thread.h" | 9 | #include "core/hle/kernel/thread.h" |
| 9 | #include "core/memory.h" | 10 | #include "core/memory.h" |
| 10 | 11 | ||
| @@ -43,6 +44,12 @@ inline u32* GetStaticBuffers(const int offset = 0) { | |||
| 43 | 44 | ||
| 44 | namespace IPC { | 45 | namespace IPC { |
| 45 | 46 | ||
| 47 | // These errors are commonly returned by invalid IPC translations, so alias them here for | ||
| 48 | // convenience. | ||
| 49 | // TODO(yuriks): These will probably go away once translation is implemented inside the kernel. | ||
| 50 | using Kernel::ERR_INVALID_BUFFER_DESCRIPTOR; | ||
| 51 | constexpr auto ERR_INVALID_HANDLE = Kernel::ERR_INVALID_HANDLE_OS; | ||
| 52 | |||
| 46 | enum DescriptorType : u32 { | 53 | enum DescriptorType : u32 { |
| 47 | // Buffer related desciptors types (mask : 0x0F) | 54 | // Buffer related desciptors types (mask : 0x0F) |
| 48 | StaticBuffer = 0x02, | 55 | StaticBuffer = 0x02, |
diff --git a/src/core/hle/kernel/address_arbiter.cpp b/src/core/hle/kernel/address_arbiter.cpp index 01fab123e..776d342f0 100644 --- a/src/core/hle/kernel/address_arbiter.cpp +++ b/src/core/hle/kernel/address_arbiter.cpp | |||
| @@ -5,6 +5,7 @@ | |||
| 5 | #include "common/common_types.h" | 5 | #include "common/common_types.h" |
| 6 | #include "common/logging/log.h" | 6 | #include "common/logging/log.h" |
| 7 | #include "core/hle/kernel/address_arbiter.h" | 7 | #include "core/hle/kernel/address_arbiter.h" |
| 8 | #include "core/hle/kernel/errors.h" | ||
| 8 | #include "core/hle/kernel/thread.h" | 9 | #include "core/hle/kernel/thread.h" |
| 9 | #include "core/memory.h" | 10 | #include "core/memory.h" |
| 10 | 11 | ||
| @@ -74,8 +75,7 @@ ResultCode AddressArbiter::ArbitrateAddress(ArbitrationType type, VAddr address, | |||
| 74 | 75 | ||
| 75 | default: | 76 | default: |
| 76 | LOG_ERROR(Kernel, "unknown type=%d", type); | 77 | LOG_ERROR(Kernel, "unknown type=%d", type); |
| 77 | return ResultCode(ErrorDescription::InvalidEnumValue, ErrorModule::Kernel, | 78 | return ERR_INVALID_ENUM_VALUE_FND; |
| 78 | ErrorSummary::WrongArgument, ErrorLevel::Usage); | ||
| 79 | } | 79 | } |
| 80 | 80 | ||
| 81 | // The calls that use a timeout seem to always return a Timeout error even if they did not put | 81 | // The calls that use a timeout seem to always return a Timeout error even if they did not put |
| @@ -83,8 +83,7 @@ ResultCode AddressArbiter::ArbitrateAddress(ArbitrationType type, VAddr address, | |||
| 83 | if (type == ArbitrationType::WaitIfLessThanWithTimeout || | 83 | if (type == ArbitrationType::WaitIfLessThanWithTimeout || |
| 84 | type == ArbitrationType::DecrementAndWaitIfLessThanWithTimeout) { | 84 | type == ArbitrationType::DecrementAndWaitIfLessThanWithTimeout) { |
| 85 | 85 | ||
| 86 | return ResultCode(ErrorDescription::Timeout, ErrorModule::OS, ErrorSummary::StatusChanged, | 86 | return RESULT_TIMEOUT; |
| 87 | ErrorLevel::Info); | ||
| 88 | } | 87 | } |
| 89 | return RESULT_SUCCESS; | 88 | return RESULT_SUCCESS; |
| 90 | } | 89 | } |
diff --git a/src/core/hle/kernel/client_port.cpp b/src/core/hle/kernel/client_port.cpp index ddcf4c916..03ffdece1 100644 --- a/src/core/hle/kernel/client_port.cpp +++ b/src/core/hle/kernel/client_port.cpp | |||
| @@ -5,6 +5,7 @@ | |||
| 5 | #include "common/assert.h" | 5 | #include "common/assert.h" |
| 6 | #include "core/hle/kernel/client_port.h" | 6 | #include "core/hle/kernel/client_port.h" |
| 7 | #include "core/hle/kernel/client_session.h" | 7 | #include "core/hle/kernel/client_session.h" |
| 8 | #include "core/hle/kernel/errors.h" | ||
| 8 | #include "core/hle/kernel/kernel.h" | 9 | #include "core/hle/kernel/kernel.h" |
| 9 | #include "core/hle/kernel/server_port.h" | 10 | #include "core/hle/kernel/server_port.h" |
| 10 | #include "core/hle/kernel/server_session.h" | 11 | #include "core/hle/kernel/server_session.h" |
| @@ -19,8 +20,7 @@ ResultVal<SharedPtr<ClientSession>> ClientPort::Connect() { | |||
| 19 | // AcceptSession before returning from this call. | 20 | // AcceptSession before returning from this call. |
| 20 | 21 | ||
| 21 | if (active_sessions >= max_sessions) { | 22 | if (active_sessions >= max_sessions) { |
| 22 | return ResultCode(ErrorDescription::MaxConnectionsReached, ErrorModule::OS, | 23 | return ERR_MAX_CONNECTIONS_REACHED; |
| 23 | ErrorSummary::WouldBlock, ErrorLevel::Temporary); | ||
| 24 | } | 24 | } |
| 25 | active_sessions++; | 25 | active_sessions++; |
| 26 | 26 | ||
diff --git a/src/core/hle/kernel/client_session.cpp b/src/core/hle/kernel/client_session.cpp index e297b7464..783b1c061 100644 --- a/src/core/hle/kernel/client_session.cpp +++ b/src/core/hle/kernel/client_session.cpp | |||
| @@ -30,8 +30,7 @@ ResultCode ClientSession::SendSyncRequest() { | |||
| 30 | if (parent->server) | 30 | if (parent->server) |
| 31 | return parent->server->HandleSyncRequest(); | 31 | return parent->server->HandleSyncRequest(); |
| 32 | 32 | ||
| 33 | return ResultCode(ErrorDescription::SessionClosedByRemote, ErrorModule::OS, | 33 | return ERR_SESSION_CLOSED_BY_REMOTE; |
| 34 | ErrorSummary::Canceled, ErrorLevel::Status); | ||
| 35 | } | 34 | } |
| 36 | 35 | ||
| 37 | } // namespace | 36 | } // namespace |
diff --git a/src/core/hle/kernel/errors.h b/src/core/hle/kernel/errors.h new file mode 100644 index 000000000..b3b60e7df --- /dev/null +++ b/src/core/hle/kernel/errors.h | |||
| @@ -0,0 +1,98 @@ | |||
| 1 | // Copyright 2017 Citra Emulator Project | ||
| 2 | // Licensed under GPLv2 or any later version | ||
| 3 | // Refer to the license.txt file included. | ||
| 4 | |||
| 5 | #pragma once | ||
| 6 | |||
| 7 | #include "core/hle/result.h" | ||
| 8 | |||
| 9 | namespace Kernel { | ||
| 10 | |||
| 11 | namespace ErrCodes { | ||
| 12 | enum { | ||
| 13 | OutOfHandles = 19, | ||
| 14 | SessionClosedByRemote = 26, | ||
| 15 | PortNameTooLong = 30, | ||
| 16 | WrongPermission = 46, | ||
| 17 | InvalidBufferDescriptor = 48, | ||
| 18 | MaxConnectionsReached = 52, | ||
| 19 | }; | ||
| 20 | } | ||
| 21 | |||
| 22 | // WARNING: The kernel is quite inconsistent in it's usage of errors code. Make sure to always | ||
| 23 | // double check that the code matches before re-using the constant. | ||
| 24 | |||
| 25 | constexpr ResultCode ERR_OUT_OF_HANDLES(ErrCodes::OutOfHandles, ErrorModule::Kernel, | ||
| 26 | ErrorSummary::OutOfResource, | ||
| 27 | ErrorLevel::Permanent); // 0xD8600413 | ||
| 28 | constexpr ResultCode ERR_SESSION_CLOSED_BY_REMOTE(ErrCodes::SessionClosedByRemote, ErrorModule::OS, | ||
| 29 | ErrorSummary::Canceled, | ||
| 30 | ErrorLevel::Status); // 0xC920181A | ||
| 31 | constexpr ResultCode ERR_PORT_NAME_TOO_LONG(ErrCodes::PortNameTooLong, ErrorModule::OS, | ||
| 32 | ErrorSummary::InvalidArgument, | ||
| 33 | ErrorLevel::Usage); // 0xE0E0181E | ||
| 34 | constexpr ResultCode ERR_WRONG_PERMISSION(ErrCodes::WrongPermission, ErrorModule::OS, | ||
| 35 | ErrorSummary::WrongArgument, ErrorLevel::Permanent); | ||
| 36 | constexpr ResultCode ERR_INVALID_BUFFER_DESCRIPTOR(ErrCodes::InvalidBufferDescriptor, | ||
| 37 | ErrorModule::OS, ErrorSummary::WrongArgument, | ||
| 38 | ErrorLevel::Permanent); | ||
| 39 | constexpr ResultCode ERR_MAX_CONNECTIONS_REACHED(ErrCodes::MaxConnectionsReached, ErrorModule::OS, | ||
| 40 | ErrorSummary::WouldBlock, | ||
| 41 | ErrorLevel::Temporary); // 0xD0401834 | ||
| 42 | |||
| 43 | constexpr ResultCode ERR_NOT_AUTHORIZED(ErrorDescription::NotAuthorized, ErrorModule::OS, | ||
| 44 | ErrorSummary::WrongArgument, | ||
| 45 | ErrorLevel::Permanent); // 0xD9001BEA | ||
| 46 | constexpr ResultCode ERR_INVALID_ENUM_VALUE(ErrorDescription::InvalidEnumValue, ErrorModule::Kernel, | ||
| 47 | ErrorSummary::InvalidArgument, | ||
| 48 | ErrorLevel::Permanent); // 0xD8E007ED | ||
| 49 | constexpr ResultCode ERR_INVALID_ENUM_VALUE_FND(ErrorDescription::InvalidEnumValue, | ||
| 50 | ErrorModule::FND, ErrorSummary::InvalidArgument, | ||
| 51 | ErrorLevel::Permanent); // 0xD8E093ED | ||
| 52 | constexpr ResultCode ERR_INVALID_COMBINATION(ErrorDescription::InvalidCombination, ErrorModule::OS, | ||
| 53 | ErrorSummary::InvalidArgument, | ||
| 54 | ErrorLevel::Usage); // 0xE0E01BEE | ||
| 55 | constexpr ResultCode ERR_INVALID_COMBINATION_KERNEL(ErrorDescription::InvalidCombination, | ||
| 56 | ErrorModule::Kernel, | ||
| 57 | ErrorSummary::WrongArgument, | ||
| 58 | ErrorLevel::Permanent); // 0xD90007EE | ||
| 59 | constexpr ResultCode ERR_MISALIGNED_ADDRESS(ErrorDescription::MisalignedAddress, ErrorModule::OS, | ||
| 60 | ErrorSummary::InvalidArgument, | ||
| 61 | ErrorLevel::Usage); // 0xE0E01BF1 | ||
| 62 | constexpr ResultCode ERR_MISALIGNED_SIZE(ErrorDescription::MisalignedSize, ErrorModule::OS, | ||
| 63 | ErrorSummary::InvalidArgument, | ||
| 64 | ErrorLevel::Usage); // 0xE0E01BF2 | ||
| 65 | constexpr ResultCode ERR_OUT_OF_MEMORY(ErrorDescription::OutOfMemory, ErrorModule::Kernel, | ||
| 66 | ErrorSummary::OutOfResource, | ||
| 67 | ErrorLevel::Permanent); // 0xD86007F3 | ||
| 68 | constexpr ResultCode ERR_NOT_IMPLEMENTED(ErrorDescription::NotImplemented, ErrorModule::OS, | ||
| 69 | ErrorSummary::InvalidArgument, | ||
| 70 | ErrorLevel::Usage); // 0xE0E01BF4 | ||
| 71 | constexpr ResultCode ERR_INVALID_ADDRESS(ErrorDescription::InvalidAddress, ErrorModule::OS, | ||
| 72 | ErrorSummary::InvalidArgument, | ||
| 73 | ErrorLevel::Usage); // 0xE0E01BF5 | ||
| 74 | constexpr ResultCode ERR_INVALID_ADDRESS_STATE(ErrorDescription::InvalidAddress, ErrorModule::OS, | ||
| 75 | ErrorSummary::InvalidState, | ||
| 76 | ErrorLevel::Usage); // 0xE0A01BF5 | ||
| 77 | constexpr ResultCode ERR_INVALID_POINTER(ErrorDescription::InvalidPointer, ErrorModule::Kernel, | ||
| 78 | ErrorSummary::InvalidArgument, | ||
| 79 | ErrorLevel::Permanent); // 0xD8E007F6 | ||
| 80 | constexpr ResultCode ERR_INVALID_HANDLE(ErrorDescription::InvalidHandle, ErrorModule::Kernel, | ||
| 81 | ErrorSummary::InvalidArgument, | ||
| 82 | ErrorLevel::Permanent); // 0xD8E007F7 | ||
| 83 | /// Alternate code returned instead of ERR_INVALID_HANDLE in some code paths. | ||
| 84 | constexpr ResultCode ERR_INVALID_HANDLE_OS(ErrorDescription::InvalidHandle, ErrorModule::OS, | ||
| 85 | ErrorSummary::WrongArgument, | ||
| 86 | ErrorLevel::Permanent); // 0xD9001BF7 | ||
| 87 | constexpr ResultCode ERR_NOT_FOUND(ErrorDescription::NotFound, ErrorModule::Kernel, | ||
| 88 | ErrorSummary::NotFound, ErrorLevel::Permanent); // 0xD88007FA | ||
| 89 | constexpr ResultCode ERR_OUT_OF_RANGE(ErrorDescription::OutOfRange, ErrorModule::OS, | ||
| 90 | ErrorSummary::InvalidArgument, | ||
| 91 | ErrorLevel::Usage); // 0xE0E01BFD | ||
| 92 | constexpr ResultCode ERR_OUT_OF_RANGE_KERNEL(ErrorDescription::OutOfRange, ErrorModule::Kernel, | ||
| 93 | ErrorSummary::InvalidArgument, | ||
| 94 | ErrorLevel::Permanent); // 0xD8E007FD | ||
| 95 | constexpr ResultCode RESULT_TIMEOUT(ErrorDescription::Timeout, ErrorModule::OS, | ||
| 96 | ErrorSummary::StatusChanged, ErrorLevel::Info); | ||
| 97 | |||
| 98 | } // namespace Kernel | ||
diff --git a/src/core/hle/kernel/kernel.cpp b/src/core/hle/kernel/kernel.cpp index f599916f0..7f84e01aa 100644 --- a/src/core/hle/kernel/kernel.cpp +++ b/src/core/hle/kernel/kernel.cpp | |||
| @@ -6,6 +6,7 @@ | |||
| 6 | #include "common/assert.h" | 6 | #include "common/assert.h" |
| 7 | #include "common/logging/log.h" | 7 | #include "common/logging/log.h" |
| 8 | #include "core/hle/config_mem.h" | 8 | #include "core/hle/config_mem.h" |
| 9 | #include "core/hle/kernel/errors.h" | ||
| 9 | #include "core/hle/kernel/kernel.h" | 10 | #include "core/hle/kernel/kernel.h" |
| 10 | #include "core/hle/kernel/memory.h" | 11 | #include "core/hle/kernel/memory.h" |
| 11 | #include "core/hle/kernel/process.h" | 12 | #include "core/hle/kernel/process.h" |
diff --git a/src/core/hle/kernel/kernel.h b/src/core/hle/kernel/kernel.h index bb8b99bb5..94f2025a0 100644 --- a/src/core/hle/kernel/kernel.h +++ b/src/core/hle/kernel/kernel.h | |||
| @@ -19,13 +19,6 @@ using Handle = u32; | |||
| 19 | 19 | ||
| 20 | class Thread; | 20 | class Thread; |
| 21 | 21 | ||
| 22 | // TODO: Verify code | ||
| 23 | const ResultCode ERR_OUT_OF_HANDLES(ErrorDescription::OutOfMemory, ErrorModule::Kernel, | ||
| 24 | ErrorSummary::OutOfResource, ErrorLevel::Temporary); | ||
| 25 | // TOOD: Verify code | ||
| 26 | const ResultCode ERR_INVALID_HANDLE(ErrorDescription::InvalidHandle, ErrorModule::Kernel, | ||
| 27 | ErrorSummary::InvalidArgument, ErrorLevel::Permanent); | ||
| 28 | |||
| 29 | enum KernelHandle : Handle { | 22 | enum KernelHandle : Handle { |
| 30 | CurrentThread = 0xFFFF8000, | 23 | CurrentThread = 0xFFFF8000, |
| 31 | CurrentProcess = 0xFFFF8001, | 24 | CurrentProcess = 0xFFFF8001, |
diff --git a/src/core/hle/kernel/process.cpp b/src/core/hle/kernel/process.cpp index 32cb25fb7..1c31ec950 100644 --- a/src/core/hle/kernel/process.cpp +++ b/src/core/hle/kernel/process.cpp | |||
| @@ -6,6 +6,7 @@ | |||
| 6 | #include "common/assert.h" | 6 | #include "common/assert.h" |
| 7 | #include "common/common_funcs.h" | 7 | #include "common/common_funcs.h" |
| 8 | #include "common/logging/log.h" | 8 | #include "common/logging/log.h" |
| 9 | #include "core/hle/kernel/errors.h" | ||
| 9 | #include "core/hle/kernel/memory.h" | 10 | #include "core/hle/kernel/memory.h" |
| 10 | #include "core/hle/kernel/process.h" | 11 | #include "core/hle/kernel/process.h" |
| 11 | #include "core/hle/kernel/resource_limit.h" | 12 | #include "core/hle/kernel/resource_limit.h" |
diff --git a/src/core/hle/kernel/semaphore.cpp b/src/core/hle/kernel/semaphore.cpp index 8bda2f75d..fcf586728 100644 --- a/src/core/hle/kernel/semaphore.cpp +++ b/src/core/hle/kernel/semaphore.cpp | |||
| @@ -3,6 +3,7 @@ | |||
| 3 | // Refer to the license.txt file included. | 3 | // Refer to the license.txt file included. |
| 4 | 4 | ||
| 5 | #include "common/assert.h" | 5 | #include "common/assert.h" |
| 6 | #include "core/hle/kernel/errors.h" | ||
| 6 | #include "core/hle/kernel/kernel.h" | 7 | #include "core/hle/kernel/kernel.h" |
| 7 | #include "core/hle/kernel/semaphore.h" | 8 | #include "core/hle/kernel/semaphore.h" |
| 8 | #include "core/hle/kernel/thread.h" | 9 | #include "core/hle/kernel/thread.h" |
| @@ -16,8 +17,7 @@ ResultVal<SharedPtr<Semaphore>> Semaphore::Create(s32 initial_count, s32 max_cou | |||
| 16 | std::string name) { | 17 | std::string name) { |
| 17 | 18 | ||
| 18 | if (initial_count > max_count) | 19 | if (initial_count > max_count) |
| 19 | return ResultCode(ErrorDescription::InvalidCombination, ErrorModule::Kernel, | 20 | return ERR_INVALID_COMBINATION_KERNEL; |
| 20 | ErrorSummary::WrongArgument, ErrorLevel::Permanent); | ||
| 21 | 21 | ||
| 22 | SharedPtr<Semaphore> semaphore(new Semaphore); | 22 | SharedPtr<Semaphore> semaphore(new Semaphore); |
| 23 | 23 | ||
| @@ -42,8 +42,7 @@ void Semaphore::Acquire(Thread* thread) { | |||
| 42 | 42 | ||
| 43 | ResultVal<s32> Semaphore::Release(s32 release_count) { | 43 | ResultVal<s32> Semaphore::Release(s32 release_count) { |
| 44 | if (max_count - available_count < release_count) | 44 | if (max_count - available_count < release_count) |
| 45 | return ResultCode(ErrorDescription::OutOfRange, ErrorModule::Kernel, | 45 | return ERR_OUT_OF_RANGE_KERNEL; |
| 46 | ErrorSummary::InvalidArgument, ErrorLevel::Permanent); | ||
| 47 | 46 | ||
| 48 | s32 previous_count = available_count; | 47 | s32 previous_count = available_count; |
| 49 | available_count += release_count; | 48 | available_count += release_count; |
diff --git a/src/core/hle/kernel/shared_memory.cpp b/src/core/hle/kernel/shared_memory.cpp index bc1560d12..922e5ab58 100644 --- a/src/core/hle/kernel/shared_memory.cpp +++ b/src/core/hle/kernel/shared_memory.cpp | |||
| @@ -4,6 +4,7 @@ | |||
| 4 | 4 | ||
| 5 | #include <cstring> | 5 | #include <cstring> |
| 6 | #include "common/logging/log.h" | 6 | #include "common/logging/log.h" |
| 7 | #include "core/hle/kernel/errors.h" | ||
| 7 | #include "core/hle/kernel/memory.h" | 8 | #include "core/hle/kernel/memory.h" |
| 8 | #include "core/hle/kernel/shared_memory.h" | 9 | #include "core/hle/kernel/shared_memory.h" |
| 9 | #include "core/memory.h" | 10 | #include "core/memory.h" |
| @@ -102,24 +103,21 @@ ResultCode SharedMemory::Map(Process* target_process, VAddr address, MemoryPermi | |||
| 102 | 103 | ||
| 103 | // Automatically allocated memory blocks can only be mapped with other_permissions = DontCare | 104 | // Automatically allocated memory blocks can only be mapped with other_permissions = DontCare |
| 104 | if (base_address == 0 && other_permissions != MemoryPermission::DontCare) { | 105 | if (base_address == 0 && other_permissions != MemoryPermission::DontCare) { |
| 105 | return ResultCode(ErrorDescription::InvalidCombination, ErrorModule::OS, | 106 | return ERR_INVALID_COMBINATION; |
| 106 | ErrorSummary::InvalidArgument, ErrorLevel::Usage); | ||
| 107 | } | 107 | } |
| 108 | 108 | ||
| 109 | // Error out if the requested permissions don't match what the creator process allows. | 109 | // Error out if the requested permissions don't match what the creator process allows. |
| 110 | if (static_cast<u32>(permissions) & ~static_cast<u32>(own_other_permissions)) { | 110 | if (static_cast<u32>(permissions) & ~static_cast<u32>(own_other_permissions)) { |
| 111 | LOG_ERROR(Kernel, "cannot map id=%u, address=0x%08X name=%s, permissions don't match", | 111 | LOG_ERROR(Kernel, "cannot map id=%u, address=0x%08X name=%s, permissions don't match", |
| 112 | GetObjectId(), address, name.c_str()); | 112 | GetObjectId(), address, name.c_str()); |
| 113 | return ResultCode(ErrorDescription::InvalidCombination, ErrorModule::OS, | 113 | return ERR_INVALID_COMBINATION; |
| 114 | ErrorSummary::InvalidArgument, ErrorLevel::Usage); | ||
| 115 | } | 114 | } |
| 116 | 115 | ||
| 117 | // Heap-backed memory blocks can not be mapped with other_permissions = DontCare | 116 | // Heap-backed memory blocks can not be mapped with other_permissions = DontCare |
| 118 | if (base_address != 0 && other_permissions == MemoryPermission::DontCare) { | 117 | if (base_address != 0 && other_permissions == MemoryPermission::DontCare) { |
| 119 | LOG_ERROR(Kernel, "cannot map id=%u, address=0x%08X name=%s, permissions don't match", | 118 | LOG_ERROR(Kernel, "cannot map id=%u, address=0x%08X name=%s, permissions don't match", |
| 120 | GetObjectId(), address, name.c_str()); | 119 | GetObjectId(), address, name.c_str()); |
| 121 | return ResultCode(ErrorDescription::InvalidCombination, ErrorModule::OS, | 120 | return ERR_INVALID_COMBINATION; |
| 122 | ErrorSummary::InvalidArgument, ErrorLevel::Usage); | ||
| 123 | } | 121 | } |
| 124 | 122 | ||
| 125 | // Error out if the provided permissions are not compatible with what the creator process needs. | 123 | // Error out if the provided permissions are not compatible with what the creator process needs. |
| @@ -127,8 +125,7 @@ ResultCode SharedMemory::Map(Process* target_process, VAddr address, MemoryPermi | |||
| 127 | static_cast<u32>(this->permissions) & ~static_cast<u32>(other_permissions)) { | 125 | static_cast<u32>(this->permissions) & ~static_cast<u32>(other_permissions)) { |
| 128 | LOG_ERROR(Kernel, "cannot map id=%u, address=0x%08X name=%s, permissions don't match", | 126 | LOG_ERROR(Kernel, "cannot map id=%u, address=0x%08X name=%s, permissions don't match", |
| 129 | GetObjectId(), address, name.c_str()); | 127 | GetObjectId(), address, name.c_str()); |
| 130 | return ResultCode(ErrorDescription::WrongPermission, ErrorModule::OS, | 128 | return ERR_WRONG_PERMISSION; |
| 131 | ErrorSummary::WrongArgument, ErrorLevel::Permanent); | ||
| 132 | } | 129 | } |
| 133 | 130 | ||
| 134 | // TODO(Subv): Check for the Shared Device Mem flag in the creator process. | 131 | // TODO(Subv): Check for the Shared Device Mem flag in the creator process. |
| @@ -144,8 +141,7 @@ ResultCode SharedMemory::Map(Process* target_process, VAddr address, MemoryPermi | |||
| 144 | if (address < Memory::HEAP_VADDR || address + size >= Memory::SHARED_MEMORY_VADDR_END) { | 141 | if (address < Memory::HEAP_VADDR || address + size >= Memory::SHARED_MEMORY_VADDR_END) { |
| 145 | LOG_ERROR(Kernel, "cannot map id=%u, address=0x%08X name=%s, invalid address", | 142 | LOG_ERROR(Kernel, "cannot map id=%u, address=0x%08X name=%s, invalid address", |
| 146 | GetObjectId(), address, name.c_str()); | 143 | GetObjectId(), address, name.c_str()); |
| 147 | return ResultCode(ErrorDescription::InvalidAddress, ErrorModule::OS, | 144 | return ERR_INVALID_ADDRESS; |
| 148 | ErrorSummary::InvalidArgument, ErrorLevel::Usage); | ||
| 149 | } | 145 | } |
| 150 | } | 146 | } |
| 151 | 147 | ||
diff --git a/src/core/hle/kernel/thread.cpp b/src/core/hle/kernel/thread.cpp index 3b7555d87..519ff51a8 100644 --- a/src/core/hle/kernel/thread.cpp +++ b/src/core/hle/kernel/thread.cpp | |||
| @@ -14,6 +14,7 @@ | |||
| 14 | #include "core/arm/skyeye_common/armstate.h" | 14 | #include "core/arm/skyeye_common/armstate.h" |
| 15 | #include "core/core.h" | 15 | #include "core/core.h" |
| 16 | #include "core/core_timing.h" | 16 | #include "core/core_timing.h" |
| 17 | #include "core/hle/kernel/errors.h" | ||
| 17 | #include "core/hle/kernel/kernel.h" | 18 | #include "core/hle/kernel/kernel.h" |
| 18 | #include "core/hle/kernel/memory.h" | 19 | #include "core/hle/kernel/memory.h" |
| 19 | #include "core/hle/kernel/mutex.h" | 20 | #include "core/hle/kernel/mutex.h" |
| @@ -241,9 +242,7 @@ static void ThreadWakeupCallback(u64 thread_handle, int cycles_late) { | |||
| 241 | for (auto& object : thread->wait_objects) | 242 | for (auto& object : thread->wait_objects) |
| 242 | object->RemoveWaitingThread(thread.get()); | 243 | object->RemoveWaitingThread(thread.get()); |
| 243 | thread->wait_objects.clear(); | 244 | thread->wait_objects.clear(); |
| 244 | thread->SetWaitSynchronizationResult(ResultCode(ErrorDescription::Timeout, ErrorModule::OS, | 245 | thread->SetWaitSynchronizationResult(RESULT_TIMEOUT); |
| 245 | ErrorSummary::StatusChanged, | ||
| 246 | ErrorLevel::Info)); | ||
| 247 | } | 246 | } |
| 248 | 247 | ||
| 249 | thread->ResumeFromWait(); | 248 | thread->ResumeFromWait(); |
| @@ -351,10 +350,20 @@ static void ResetThreadContext(ARM_Interface::ThreadContext& context, u32 stack_ | |||
| 351 | context.cpsr = USER32MODE | ((entry_point & 1) << 5); // Usermode and THUMB mode | 350 | context.cpsr = USER32MODE | ((entry_point & 1) << 5); // Usermode and THUMB mode |
| 352 | } | 351 | } |
| 353 | 352 | ||
| 354 | ResultVal<SharedPtr<Thread>> Thread::Create(std::string name, VAddr entry_point, s32 priority, | 353 | ResultVal<SharedPtr<Thread>> Thread::Create(std::string name, VAddr entry_point, u32 priority, |
| 355 | u32 arg, s32 processor_id, VAddr stack_top) { | 354 | u32 arg, s32 processor_id, VAddr stack_top) { |
| 356 | ASSERT_MSG(priority >= THREADPRIO_HIGHEST && priority <= THREADPRIO_LOWEST, | 355 | // Check if priority is in ranged. Lowest priority -> highest priority id. |
| 357 | "Invalid thread priority"); | 356 | if (priority > THREADPRIO_LOWEST) { |
| 357 | LOG_ERROR(Kernel_SVC, "Invalid thread priority: %d", priority); | ||
| 358 | return ERR_OUT_OF_RANGE; | ||
| 359 | } | ||
| 360 | |||
| 361 | if (processor_id > THREADPROCESSORID_MAX) { | ||
| 362 | LOG_ERROR(Kernel_SVC, "Invalid processor id: %d", processor_id); | ||
| 363 | return ERR_OUT_OF_RANGE_KERNEL; | ||
| 364 | } | ||
| 365 | |||
| 366 | // TODO(yuriks): Other checks, returning 0xD9001BEA | ||
| 358 | 367 | ||
| 359 | if (!Memory::IsValidVirtualAddress(entry_point)) { | 368 | if (!Memory::IsValidVirtualAddress(entry_point)) { |
| 360 | LOG_ERROR(Kernel_SVC, "(name=%s): invalid entry %08x", name.c_str(), entry_point); | 369 | LOG_ERROR(Kernel_SVC, "(name=%s): invalid entry %08x", name.c_str(), entry_point); |
| @@ -399,8 +408,7 @@ ResultVal<SharedPtr<Thread>> Thread::Create(std::string name, VAddr entry_point, | |||
| 399 | if (linheap_memory->size() + Memory::PAGE_SIZE > memory_region->size) { | 408 | if (linheap_memory->size() + Memory::PAGE_SIZE > memory_region->size) { |
| 400 | LOG_ERROR(Kernel_SVC, | 409 | LOG_ERROR(Kernel_SVC, |
| 401 | "Not enough space in region to allocate a new TLS page for thread"); | 410 | "Not enough space in region to allocate a new TLS page for thread"); |
| 402 | return ResultCode(ErrorDescription::OutOfMemory, ErrorModule::Kernel, | 411 | return ERR_OUT_OF_MEMORY; |
| 403 | ErrorSummary::OutOfResource, ErrorLevel::Permanent); | ||
| 404 | } | 412 | } |
| 405 | 413 | ||
| 406 | u32 offset = linheap_memory->size(); | 414 | u32 offset = linheap_memory->size(); |
diff --git a/src/core/hle/kernel/thread.h b/src/core/hle/kernel/thread.h index 6ab31c70b..7b5169cfc 100644 --- a/src/core/hle/kernel/thread.h +++ b/src/core/hle/kernel/thread.h | |||
| @@ -57,7 +57,7 @@ public: | |||
| 57 | * @param stack_top The address of the thread's stack top | 57 | * @param stack_top The address of the thread's stack top |
| 58 | * @return A shared pointer to the newly created thread | 58 | * @return A shared pointer to the newly created thread |
| 59 | */ | 59 | */ |
| 60 | static ResultVal<SharedPtr<Thread>> Create(std::string name, VAddr entry_point, s32 priority, | 60 | static ResultVal<SharedPtr<Thread>> Create(std::string name, VAddr entry_point, u32 priority, |
| 61 | u32 arg, s32 processor_id, VAddr stack_top); | 61 | u32 arg, s32 processor_id, VAddr stack_top); |
| 62 | 62 | ||
| 63 | std::string GetName() const override { | 63 | std::string GetName() const override { |
diff --git a/src/core/hle/kernel/vm_manager.cpp b/src/core/hle/kernel/vm_manager.cpp index 6dd24f846..cef1f7fa8 100644 --- a/src/core/hle/kernel/vm_manager.cpp +++ b/src/core/hle/kernel/vm_manager.cpp | |||
| @@ -4,6 +4,7 @@ | |||
| 4 | 4 | ||
| 5 | #include <iterator> | 5 | #include <iterator> |
| 6 | #include "common/assert.h" | 6 | #include "common/assert.h" |
| 7 | #include "core/hle/kernel/errors.h" | ||
| 7 | #include "core/hle/kernel/vm_manager.h" | 8 | #include "core/hle/kernel/vm_manager.h" |
| 8 | #include "core/memory.h" | 9 | #include "core/memory.h" |
| 9 | #include "core/memory_setup.h" | 10 | #include "core/memory_setup.h" |
diff --git a/src/core/hle/kernel/vm_manager.h b/src/core/hle/kernel/vm_manager.h index 9055664b2..38e0d74d0 100644 --- a/src/core/hle/kernel/vm_manager.h +++ b/src/core/hle/kernel/vm_manager.h | |||
| @@ -13,14 +13,6 @@ | |||
| 13 | 13 | ||
| 14 | namespace Kernel { | 14 | namespace Kernel { |
| 15 | 15 | ||
| 16 | const ResultCode ERR_INVALID_ADDRESS{// 0xE0E01BF5 | ||
| 17 | ErrorDescription::InvalidAddress, ErrorModule::OS, | ||
| 18 | ErrorSummary::InvalidArgument, ErrorLevel::Usage}; | ||
| 19 | |||
| 20 | const ResultCode ERR_INVALID_ADDRESS_STATE{// 0xE0A01BF5 | ||
| 21 | ErrorDescription::InvalidAddress, ErrorModule::OS, | ||
| 22 | ErrorSummary::InvalidState, ErrorLevel::Usage}; | ||
| 23 | |||
| 24 | enum class VMAType : u8 { | 16 | enum class VMAType : u8 { |
| 25 | /// VMA represents an unmapped region of the address space. | 17 | /// VMA represents an unmapped region of the address space. |
| 26 | Free, | 18 | Free, |
diff --git a/src/core/hle/result.h b/src/core/hle/result.h index e76be606e..c49650f7d 100644 --- a/src/core/hle/result.h +++ b/src/core/hle/result.h | |||
| @@ -21,12 +21,6 @@ | |||
| 21 | enum class ErrorDescription : u32 { | 21 | enum class ErrorDescription : u32 { |
| 22 | Success = 0, | 22 | Success = 0, |
| 23 | 23 | ||
| 24 | SessionClosedByRemote = 26, | ||
| 25 | WrongPermission = 46, | ||
| 26 | OS_InvalidBufferDescriptor = 48, | ||
| 27 | MaxConnectionsReached = 52, | ||
| 28 | WrongAddress = 53, | ||
| 29 | |||
| 30 | // Codes 1000 and above are considered "well-known" and have common values between all modules. | 24 | // Codes 1000 and above are considered "well-known" and have common values between all modules. |
| 31 | InvalidSection = 1000, | 25 | InvalidSection = 1000, |
| 32 | TooLarge = 1001, | 26 | TooLarge = 1001, |
diff --git a/src/core/hle/service/boss/boss.cpp b/src/core/hle/service/boss/boss.cpp index e0de037f8..91056189a 100644 --- a/src/core/hle/service/boss/boss.cpp +++ b/src/core/hle/service/boss/boss.cpp | |||
| @@ -24,9 +24,7 @@ void InitializeSession(Service::Interface* self) { | |||
| 24 | 24 | ||
| 25 | if (translation != IPC::CallingPidDesc()) { | 25 | if (translation != IPC::CallingPidDesc()) { |
| 26 | cmd_buff[0] = IPC::MakeHeader(0, 0x1, 0); // 0x40 | 26 | cmd_buff[0] = IPC::MakeHeader(0, 0x1, 0); // 0x40 |
| 27 | cmd_buff[1] = ResultCode(ErrorDescription::OS_InvalidBufferDescriptor, ErrorModule::OS, | 27 | cmd_buff[1] = IPC::ERR_INVALID_BUFFER_DESCRIPTOR.raw; |
| 28 | ErrorSummary::WrongArgument, ErrorLevel::Permanent) | ||
| 29 | .raw; | ||
| 30 | LOG_ERROR(Service_BOSS, "The translation was invalid, translation=0x%08X", translation); | 28 | LOG_ERROR(Service_BOSS, "The translation was invalid, translation=0x%08X", translation); |
| 31 | return; | 29 | return; |
| 32 | } | 30 | } |
diff --git a/src/core/hle/service/dsp_dsp.cpp b/src/core/hle/service/dsp_dsp.cpp index 39711ea97..79171a0bc 100644 --- a/src/core/hle/service/dsp_dsp.cpp +++ b/src/core/hle/service/dsp_dsp.cpp | |||
| @@ -289,9 +289,7 @@ static void WriteProcessPipe(Service::Interface* self) { | |||
| 289 | "size=0x%X, buffer=0x%08X", | 289 | "size=0x%X, buffer=0x%08X", |
| 290 | cmd_buff[3], pipe_index, size, buffer); | 290 | cmd_buff[3], pipe_index, size, buffer); |
| 291 | cmd_buff[0] = IPC::MakeHeader(0, 1, 0); | 291 | cmd_buff[0] = IPC::MakeHeader(0, 1, 0); |
| 292 | cmd_buff[1] = ResultCode(ErrorDescription::OS_InvalidBufferDescriptor, ErrorModule::OS, | 292 | cmd_buff[1] = IPC::ERR_INVALID_BUFFER_DESCRIPTOR.raw; |
| 293 | ErrorSummary::WrongArgument, ErrorLevel::Permanent) | ||
| 294 | .raw; | ||
| 295 | return; | 293 | return; |
| 296 | } | 294 | } |
| 297 | 295 | ||
diff --git a/src/core/hle/service/fs/fs_user.cpp b/src/core/hle/service/fs/fs_user.cpp index ad1aadab5..e53a970d3 100644 --- a/src/core/hle/service/fs/fs_user.cpp +++ b/src/core/hle/service/fs/fs_user.cpp | |||
| @@ -801,9 +801,7 @@ static void InitializeWithSdkVersion(Service::Interface* self) { | |||
| 801 | cmd_buff[1] = RESULT_SUCCESS.raw; | 801 | cmd_buff[1] = RESULT_SUCCESS.raw; |
| 802 | } else { | 802 | } else { |
| 803 | LOG_ERROR(Service_FS, "ProcessId Header must be 0x20"); | 803 | LOG_ERROR(Service_FS, "ProcessId Header must be 0x20"); |
| 804 | cmd_buff[1] = ResultCode(ErrorDescription::OS_InvalidBufferDescriptor, ErrorModule::OS, | 804 | cmd_buff[1] = IPC::ERR_INVALID_BUFFER_DESCRIPTOR.raw; |
| 805 | ErrorSummary::WrongArgument, ErrorLevel::Permanent) | ||
| 806 | .raw; | ||
| 807 | } | 805 | } |
| 808 | } | 806 | } |
| 809 | 807 | ||
diff --git a/src/core/hle/service/ir/ir_user.cpp b/src/core/hle/service/ir/ir_user.cpp index 226af0083..369115f09 100644 --- a/src/core/hle/service/ir/ir_user.cpp +++ b/src/core/hle/service/ir/ir_user.cpp | |||
| @@ -267,8 +267,7 @@ static void InitializeIrNopShared(Interface* self) { | |||
| 267 | shared_memory = Kernel::g_handle_table.Get<Kernel::SharedMemory>(handle); | 267 | shared_memory = Kernel::g_handle_table.Get<Kernel::SharedMemory>(handle); |
| 268 | if (!shared_memory) { | 268 | if (!shared_memory) { |
| 269 | LOG_CRITICAL(Service_IR, "invalid shared memory handle 0x%08X", handle); | 269 | LOG_CRITICAL(Service_IR, "invalid shared memory handle 0x%08X", handle); |
| 270 | rb.Push(ResultCode(ErrorDescription::InvalidHandle, ErrorModule::OS, | 270 | rb.Push(IPC::ERR_INVALID_HANDLE); |
| 271 | ErrorSummary::WrongArgument, ErrorLevel::Permanent)); | ||
| 272 | return; | 271 | return; |
| 273 | } | 272 | } |
| 274 | shared_memory->name = "IR_USER: shared memory"; | 273 | shared_memory->name = "IR_USER: shared memory"; |
diff --git a/src/core/hle/service/srv.cpp b/src/core/hle/service/srv.cpp index 3bd787147..130c9d25e 100644 --- a/src/core/hle/service/srv.cpp +++ b/src/core/hle/service/srv.cpp | |||
| @@ -30,9 +30,7 @@ static void RegisterClient(Interface* self) { | |||
| 30 | 30 | ||
| 31 | if (cmd_buff[1] != IPC::CallingPidDesc()) { | 31 | if (cmd_buff[1] != IPC::CallingPidDesc()) { |
| 32 | cmd_buff[0] = IPC::MakeHeader(0x0, 0x1, 0); // 0x40 | 32 | cmd_buff[0] = IPC::MakeHeader(0x0, 0x1, 0); // 0x40 |
| 33 | cmd_buff[1] = ResultCode(ErrorDescription::OS_InvalidBufferDescriptor, ErrorModule::OS, | 33 | cmd_buff[1] = IPC::ERR_INVALID_BUFFER_DESCRIPTOR.raw; |
| 34 | ErrorSummary::WrongArgument, ErrorLevel::Permanent) | ||
| 35 | .raw; | ||
| 36 | return; | 34 | return; |
| 37 | } | 35 | } |
| 38 | cmd_buff[0] = IPC::MakeHeader(0x1, 0x1, 0); // 0x10040 | 36 | cmd_buff[0] = IPC::MakeHeader(0x1, 0x1, 0); // 0x10040 |
diff --git a/src/core/hle/svc.cpp b/src/core/hle/svc.cpp index 8538cfc9d..30230d65a 100644 --- a/src/core/hle/svc.cpp +++ b/src/core/hle/svc.cpp | |||
| @@ -14,6 +14,7 @@ | |||
| 14 | #include "core/hle/kernel/address_arbiter.h" | 14 | #include "core/hle/kernel/address_arbiter.h" |
| 15 | #include "core/hle/kernel/client_port.h" | 15 | #include "core/hle/kernel/client_port.h" |
| 16 | #include "core/hle/kernel/client_session.h" | 16 | #include "core/hle/kernel/client_session.h" |
| 17 | #include "core/hle/kernel/errors.h" | ||
| 17 | #include "core/hle/kernel/event.h" | 18 | #include "core/hle/kernel/event.h" |
| 18 | #include "core/hle/kernel/memory.h" | 19 | #include "core/hle/kernel/memory.h" |
| 19 | #include "core/hle/kernel/mutex.h" | 20 | #include "core/hle/kernel/mutex.h" |
| @@ -37,25 +38,6 @@ using Kernel::ERR_INVALID_HANDLE; | |||
| 37 | 38 | ||
| 38 | namespace SVC { | 39 | namespace SVC { |
| 39 | 40 | ||
| 40 | const ResultCode ERR_NOT_FOUND(ErrorDescription::NotFound, ErrorModule::Kernel, | ||
| 41 | ErrorSummary::NotFound, ErrorLevel::Permanent); // 0xD88007FA | ||
| 42 | const ResultCode ERR_PORT_NAME_TOO_LONG(ErrorDescription(30), ErrorModule::OS, | ||
| 43 | ErrorSummary::InvalidArgument, | ||
| 44 | ErrorLevel::Usage); // 0xE0E0181E | ||
| 45 | |||
| 46 | const ResultCode ERR_SYNC_TIMEOUT(ErrorDescription::Timeout, ErrorModule::OS, | ||
| 47 | ErrorSummary::StatusChanged, ErrorLevel::Info); | ||
| 48 | |||
| 49 | const ResultCode ERR_MISALIGNED_ADDRESS{// 0xE0E01BF1 | ||
| 50 | ErrorDescription::MisalignedAddress, ErrorModule::OS, | ||
| 51 | ErrorSummary::InvalidArgument, ErrorLevel::Usage}; | ||
| 52 | const ResultCode ERR_MISALIGNED_SIZE{// 0xE0E01BF2 | ||
| 53 | ErrorDescription::MisalignedSize, ErrorModule::OS, | ||
| 54 | ErrorSummary::InvalidArgument, ErrorLevel::Usage}; | ||
| 55 | const ResultCode ERR_INVALID_COMBINATION{// 0xE0E01BEE | ||
| 56 | ErrorDescription::InvalidCombination, ErrorModule::OS, | ||
| 57 | ErrorSummary::InvalidArgument, ErrorLevel::Usage}; | ||
| 58 | |||
| 59 | enum ControlMemoryOperation { | 41 | enum ControlMemoryOperation { |
| 60 | MEMOP_FREE = 1, | 42 | MEMOP_FREE = 1, |
| 61 | MEMOP_RESERVE = 2, // This operation seems to be unsupported in the kernel | 43 | MEMOP_RESERVE = 2, // This operation seems to be unsupported in the kernel |
| @@ -195,8 +177,7 @@ static ResultCode MapMemoryBlock(Kernel::Handle handle, u32 addr, u32 permission | |||
| 195 | LOG_ERROR(Kernel_SVC, "unknown permissions=0x%08X", permissions); | 177 | LOG_ERROR(Kernel_SVC, "unknown permissions=0x%08X", permissions); |
| 196 | } | 178 | } |
| 197 | 179 | ||
| 198 | return ResultCode(ErrorDescription::InvalidCombination, ErrorModule::OS, | 180 | return Kernel::ERR_INVALID_COMBINATION; |
| 199 | ErrorSummary::InvalidArgument, ErrorLevel::Usage); | ||
| 200 | } | 181 | } |
| 201 | 182 | ||
| 202 | static ResultCode UnmapMemoryBlock(Kernel::Handle handle, u32 addr) { | 183 | static ResultCode UnmapMemoryBlock(Kernel::Handle handle, u32 addr) { |
| @@ -216,16 +197,16 @@ static ResultCode UnmapMemoryBlock(Kernel::Handle handle, u32 addr) { | |||
| 216 | /// Connect to an OS service given the port name, returns the handle to the port to out | 197 | /// Connect to an OS service given the port name, returns the handle to the port to out |
| 217 | static ResultCode ConnectToPort(Kernel::Handle* out_handle, const char* port_name) { | 198 | static ResultCode ConnectToPort(Kernel::Handle* out_handle, const char* port_name) { |
| 218 | if (port_name == nullptr) | 199 | if (port_name == nullptr) |
| 219 | return ERR_NOT_FOUND; | 200 | return Kernel::ERR_NOT_FOUND; |
| 220 | if (std::strlen(port_name) > 11) | 201 | if (std::strlen(port_name) > 11) |
| 221 | return ERR_PORT_NAME_TOO_LONG; | 202 | return Kernel::ERR_PORT_NAME_TOO_LONG; |
| 222 | 203 | ||
| 223 | LOG_TRACE(Kernel_SVC, "called port_name=%s", port_name); | 204 | LOG_TRACE(Kernel_SVC, "called port_name=%s", port_name); |
| 224 | 205 | ||
| 225 | auto it = Service::g_kernel_named_ports.find(port_name); | 206 | auto it = Service::g_kernel_named_ports.find(port_name); |
| 226 | if (it == Service::g_kernel_named_ports.end()) { | 207 | if (it == Service::g_kernel_named_ports.end()) { |
| 227 | LOG_WARNING(Kernel_SVC, "tried to connect to unknown port: %s", port_name); | 208 | LOG_WARNING(Kernel_SVC, "tried to connect to unknown port: %s", port_name); |
| 228 | return ERR_NOT_FOUND; | 209 | return Kernel::ERR_NOT_FOUND; |
| 229 | } | 210 | } |
| 230 | 211 | ||
| 231 | auto client_port = it->second; | 212 | auto client_port = it->second; |
| @@ -275,7 +256,7 @@ static ResultCode WaitSynchronization1(Kernel::Handle handle, s64 nano_seconds) | |||
| 275 | if (object->ShouldWait(thread)) { | 256 | if (object->ShouldWait(thread)) { |
| 276 | 257 | ||
| 277 | if (nano_seconds == 0) | 258 | if (nano_seconds == 0) |
| 278 | return ERR_SYNC_TIMEOUT; | 259 | return Kernel::RESULT_TIMEOUT; |
| 279 | 260 | ||
| 280 | thread->wait_objects = {object}; | 261 | thread->wait_objects = {object}; |
| 281 | object->AddWaitingThread(thread); | 262 | object->AddWaitingThread(thread); |
| @@ -289,7 +270,7 @@ static ResultCode WaitSynchronization1(Kernel::Handle handle, s64 nano_seconds) | |||
| 289 | // Note: The output of this SVC will be set to RESULT_SUCCESS if the thread | 270 | // Note: The output of this SVC will be set to RESULT_SUCCESS if the thread |
| 290 | // resumes due to a signal in its wait objects. | 271 | // resumes due to a signal in its wait objects. |
| 291 | // Otherwise we retain the default value of timeout. | 272 | // Otherwise we retain the default value of timeout. |
| 292 | return ERR_SYNC_TIMEOUT; | 273 | return Kernel::RESULT_TIMEOUT; |
| 293 | } | 274 | } |
| 294 | 275 | ||
| 295 | object->Acquire(thread); | 276 | object->Acquire(thread); |
| @@ -304,8 +285,7 @@ static ResultCode WaitSynchronizationN(s32* out, Kernel::Handle* handles, s32 ha | |||
| 304 | 285 | ||
| 305 | // Check if 'handles' is invalid | 286 | // Check if 'handles' is invalid |
| 306 | if (handles == nullptr) | 287 | if (handles == nullptr) |
| 307 | return ResultCode(ErrorDescription::InvalidPointer, ErrorModule::Kernel, | 288 | return Kernel::ERR_INVALID_POINTER; |
| 308 | ErrorSummary::InvalidArgument, ErrorLevel::Permanent); | ||
| 309 | 289 | ||
| 310 | // NOTE: on real hardware, there is no nullptr check for 'out' (tested with firmware 4.4). If | 290 | // NOTE: on real hardware, there is no nullptr check for 'out' (tested with firmware 4.4). If |
| 311 | // this happens, the running application will crash. | 291 | // this happens, the running application will crash. |
| @@ -313,8 +293,7 @@ static ResultCode WaitSynchronizationN(s32* out, Kernel::Handle* handles, s32 ha | |||
| 313 | 293 | ||
| 314 | // Check if 'handle_count' is invalid | 294 | // Check if 'handle_count' is invalid |
| 315 | if (handle_count < 0) | 295 | if (handle_count < 0) |
| 316 | return ResultCode(ErrorDescription::OutOfRange, ErrorModule::OS, | 296 | return Kernel::ERR_OUT_OF_RANGE; |
| 317 | ErrorSummary::InvalidArgument, ErrorLevel::Usage); | ||
| 318 | 297 | ||
| 319 | using ObjectPtr = Kernel::SharedPtr<Kernel::WaitObject>; | 298 | using ObjectPtr = Kernel::SharedPtr<Kernel::WaitObject>; |
| 320 | std::vector<ObjectPtr> objects(handle_count); | 299 | std::vector<ObjectPtr> objects(handle_count); |
| @@ -344,7 +323,7 @@ static ResultCode WaitSynchronizationN(s32* out, Kernel::Handle* handles, s32 ha | |||
| 344 | // If a timeout value of 0 was provided, just return the Timeout error code instead of | 323 | // If a timeout value of 0 was provided, just return the Timeout error code instead of |
| 345 | // suspending the thread. | 324 | // suspending the thread. |
| 346 | if (nano_seconds == 0) | 325 | if (nano_seconds == 0) |
| 347 | return ERR_SYNC_TIMEOUT; | 326 | return Kernel::RESULT_TIMEOUT; |
| 348 | 327 | ||
| 349 | // Put the thread to sleep | 328 | // Put the thread to sleep |
| 350 | thread->status = THREADSTATUS_WAIT_SYNCH_ALL; | 329 | thread->status = THREADSTATUS_WAIT_SYNCH_ALL; |
| @@ -365,7 +344,7 @@ static ResultCode WaitSynchronizationN(s32* out, Kernel::Handle* handles, s32 ha | |||
| 365 | *out = -1; | 344 | *out = -1; |
| 366 | // Note: The output of this SVC will be set to RESULT_SUCCESS if the thread resumes due to | 345 | // Note: The output of this SVC will be set to RESULT_SUCCESS if the thread resumes due to |
| 367 | // a signal in one of its wait objects. | 346 | // a signal in one of its wait objects. |
| 368 | return ERR_SYNC_TIMEOUT; | 347 | return Kernel::RESULT_TIMEOUT; |
| 369 | } else { | 348 | } else { |
| 370 | // Find the first object that is acquirable in the provided list of objects | 349 | // Find the first object that is acquirable in the provided list of objects |
| 371 | auto itr = std::find_if(objects.begin(), objects.end(), [thread](const ObjectPtr& object) { | 350 | auto itr = std::find_if(objects.begin(), objects.end(), [thread](const ObjectPtr& object) { |
| @@ -385,7 +364,7 @@ static ResultCode WaitSynchronizationN(s32* out, Kernel::Handle* handles, s32 ha | |||
| 385 | // If a timeout value of 0 was provided, just return the Timeout error code instead of | 364 | // If a timeout value of 0 was provided, just return the Timeout error code instead of |
| 386 | // suspending the thread. | 365 | // suspending the thread. |
| 387 | if (nano_seconds == 0) | 366 | if (nano_seconds == 0) |
| 388 | return ERR_SYNC_TIMEOUT; | 367 | return Kernel::RESULT_TIMEOUT; |
| 389 | 368 | ||
| 390 | // Put the thread to sleep | 369 | // Put the thread to sleep |
| 391 | thread->status = THREADSTATUS_WAIT_SYNCH_ANY; | 370 | thread->status = THREADSTATUS_WAIT_SYNCH_ANY; |
| @@ -411,7 +390,7 @@ static ResultCode WaitSynchronizationN(s32* out, Kernel::Handle* handles, s32 ha | |||
| 411 | // Otherwise we retain the default value of timeout, and -1 in the out parameter | 390 | // Otherwise we retain the default value of timeout, and -1 in the out parameter |
| 412 | thread->wait_set_output = true; | 391 | thread->wait_set_output = true; |
| 413 | *out = -1; | 392 | *out = -1; |
| 414 | return ERR_SYNC_TIMEOUT; | 393 | return Kernel::RESULT_TIMEOUT; |
| 415 | } | 394 | } |
| 416 | } | 395 | } |
| 417 | 396 | ||
| @@ -520,22 +499,20 @@ static ResultCode GetResourceLimitLimitValues(s64* values, Kernel::Handle resour | |||
| 520 | } | 499 | } |
| 521 | 500 | ||
| 522 | /// Creates a new thread | 501 | /// Creates a new thread |
| 523 | static ResultCode CreateThread(Kernel::Handle* out_handle, s32 priority, u32 entry_point, u32 arg, | 502 | static ResultCode CreateThread(Kernel::Handle* out_handle, u32 priority, u32 entry_point, u32 arg, |
| 524 | u32 stack_top, s32 processor_id) { | 503 | u32 stack_top, s32 processor_id) { |
| 525 | using Kernel::Thread; | 504 | using Kernel::Thread; |
| 526 | 505 | ||
| 527 | std::string name = Common::StringFromFormat("unknown-%08" PRIX32, entry_point); | 506 | std::string name = Common::StringFromFormat("unknown-%08" PRIX32, entry_point); |
| 528 | 507 | ||
| 529 | if (priority > THREADPRIO_LOWEST) { | 508 | if (priority > THREADPRIO_LOWEST) { |
| 530 | return ResultCode(ErrorDescription::OutOfRange, ErrorModule::OS, | 509 | return Kernel::ERR_OUT_OF_RANGE; |
| 531 | ErrorSummary::InvalidArgument, ErrorLevel::Usage); | ||
| 532 | } | 510 | } |
| 533 | 511 | ||
| 534 | using Kernel::ResourceLimit; | 512 | using Kernel::ResourceLimit; |
| 535 | Kernel::SharedPtr<ResourceLimit>& resource_limit = Kernel::g_current_process->resource_limit; | 513 | Kernel::SharedPtr<ResourceLimit>& resource_limit = Kernel::g_current_process->resource_limit; |
| 536 | if (resource_limit->GetMaxResourceValue(Kernel::ResourceTypes::PRIORITY) > priority) { | 514 | if (resource_limit->GetMaxResourceValue(Kernel::ResourceTypes::PRIORITY) > priority) { |
| 537 | return ResultCode(ErrorDescription::NotAuthorized, ErrorModule::OS, | 515 | return Kernel::ERR_NOT_AUTHORIZED; |
| 538 | ErrorSummary::WrongArgument, ErrorLevel::Permanent); | ||
| 539 | } | 516 | } |
| 540 | 517 | ||
| 541 | switch (processor_id) { | 518 | switch (processor_id) { |
| @@ -605,8 +582,7 @@ static ResultCode GetThreadPriority(s32* priority, Kernel::Handle handle) { | |||
| 605 | /// Sets the priority for the specified thread | 582 | /// Sets the priority for the specified thread |
| 606 | static ResultCode SetThreadPriority(Kernel::Handle handle, s32 priority) { | 583 | static ResultCode SetThreadPriority(Kernel::Handle handle, s32 priority) { |
| 607 | if (priority > THREADPRIO_LOWEST) { | 584 | if (priority > THREADPRIO_LOWEST) { |
| 608 | return ResultCode(ErrorDescription::OutOfRange, ErrorModule::OS, | 585 | return Kernel::ERR_OUT_OF_RANGE; |
| 609 | ErrorSummary::InvalidArgument, ErrorLevel::Usage); | ||
| 610 | } | 586 | } |
| 611 | 587 | ||
| 612 | SharedPtr<Kernel::Thread> thread = Kernel::g_handle_table.Get<Kernel::Thread>(handle); | 588 | SharedPtr<Kernel::Thread> thread = Kernel::g_handle_table.Get<Kernel::Thread>(handle); |
| @@ -618,8 +594,7 @@ static ResultCode SetThreadPriority(Kernel::Handle handle, s32 priority) { | |||
| 618 | // the one from the thread owner's resource limit. | 594 | // the one from the thread owner's resource limit. |
| 619 | Kernel::SharedPtr<ResourceLimit>& resource_limit = Kernel::g_current_process->resource_limit; | 595 | Kernel::SharedPtr<ResourceLimit>& resource_limit = Kernel::g_current_process->resource_limit; |
| 620 | if (resource_limit->GetMaxResourceValue(Kernel::ResourceTypes::PRIORITY) > priority) { | 596 | if (resource_limit->GetMaxResourceValue(Kernel::ResourceTypes::PRIORITY) > priority) { |
| 621 | return ResultCode(ErrorDescription::NotAuthorized, ErrorModule::OS, | 597 | return Kernel::ERR_NOT_AUTHORIZED; |
| 622 | ErrorSummary::WrongArgument, ErrorLevel::Permanent); | ||
| 623 | } | 598 | } |
| 624 | 599 | ||
| 625 | thread->SetPriority(priority); | 600 | thread->SetPriority(priority); |
| @@ -743,8 +718,7 @@ static ResultCode QueryProcessMemory(MemoryInfo* memory_info, PageInfo* page_inf | |||
| 743 | auto vma = process->vm_manager.FindVMA(addr); | 718 | auto vma = process->vm_manager.FindVMA(addr); |
| 744 | 719 | ||
| 745 | if (vma == Kernel::g_current_process->vm_manager.vma_map.end()) | 720 | if (vma == Kernel::g_current_process->vm_manager.vma_map.end()) |
| 746 | return ResultCode(ErrorDescription::InvalidAddress, ErrorModule::OS, | 721 | return Kernel::ERR_INVALID_ADDRESS; |
| 747 | ErrorSummary::InvalidArgument, ErrorLevel::Usage); | ||
| 748 | 722 | ||
| 749 | memory_info->base_address = vma->second.base; | 723 | memory_info->base_address = vma->second.base; |
| 750 | memory_info->permission = static_cast<u32>(vma->second.permissions); | 724 | memory_info->permission = static_cast<u32>(vma->second.permissions); |
| @@ -842,8 +816,7 @@ static ResultCode SetTimer(Kernel::Handle handle, s64 initial, s64 interval) { | |||
| 842 | LOG_TRACE(Kernel_SVC, "called timer=0x%08X", handle); | 816 | LOG_TRACE(Kernel_SVC, "called timer=0x%08X", handle); |
| 843 | 817 | ||
| 844 | if (initial < 0 || interval < 0) { | 818 | if (initial < 0 || interval < 0) { |
| 845 | return ResultCode(ErrorDescription::OutOfRange, ErrorModule::Kernel, | 819 | return Kernel::ERR_OUT_OF_RANGE_KERNEL; |
| 846 | ErrorSummary::InvalidArgument, ErrorLevel::Permanent); | ||
| 847 | } | 820 | } |
| 848 | 821 | ||
| 849 | SharedPtr<Timer> timer = Kernel::g_handle_table.Get<Timer>(handle); | 822 | SharedPtr<Timer> timer = Kernel::g_handle_table.Get<Timer>(handle); |
| @@ -902,8 +875,7 @@ static ResultCode CreateMemoryBlock(Kernel::Handle* out_handle, u32 addr, u32 si | |||
| 902 | using Kernel::SharedMemory; | 875 | using Kernel::SharedMemory; |
| 903 | 876 | ||
| 904 | if (size % Memory::PAGE_SIZE != 0) | 877 | if (size % Memory::PAGE_SIZE != 0) |
| 905 | return ResultCode(ErrorDescription::MisalignedSize, ErrorModule::OS, | 878 | return Kernel::ERR_MISALIGNED_SIZE; |
| 906 | ErrorSummary::InvalidArgument, ErrorLevel::Usage); | ||
| 907 | 879 | ||
| 908 | SharedPtr<SharedMemory> shared_memory = nullptr; | 880 | SharedPtr<SharedMemory> shared_memory = nullptr; |
| 909 | 881 | ||
| @@ -924,16 +896,14 @@ static ResultCode CreateMemoryBlock(Kernel::Handle* out_handle, u32 addr, u32 si | |||
| 924 | 896 | ||
| 925 | if (!VerifyPermissions(static_cast<MemoryPermission>(my_permission)) || | 897 | if (!VerifyPermissions(static_cast<MemoryPermission>(my_permission)) || |
| 926 | !VerifyPermissions(static_cast<MemoryPermission>(other_permission))) | 898 | !VerifyPermissions(static_cast<MemoryPermission>(other_permission))) |
| 927 | return ResultCode(ErrorDescription::InvalidCombination, ErrorModule::OS, | 899 | return Kernel::ERR_INVALID_COMBINATION; |
| 928 | ErrorSummary::InvalidArgument, ErrorLevel::Usage); | ||
| 929 | 900 | ||
| 930 | // TODO(Subv): Processes with memory type APPLICATION are not allowed | 901 | // TODO(Subv): Processes with memory type APPLICATION are not allowed |
| 931 | // to create memory blocks with addr = 0, any attempts to do so | 902 | // to create memory blocks with addr = 0, any attempts to do so |
| 932 | // should return error 0xD92007EA. | 903 | // should return error 0xD92007EA. |
| 933 | if ((addr < Memory::PROCESS_IMAGE_VADDR || addr + size > Memory::SHARED_MEMORY_VADDR_END) && | 904 | if ((addr < Memory::PROCESS_IMAGE_VADDR || addr + size > Memory::SHARED_MEMORY_VADDR_END) && |
| 934 | addr != 0) { | 905 | addr != 0) { |
| 935 | return ResultCode(ErrorDescription::InvalidAddress, ErrorModule::OS, | 906 | return Kernel::ERR_INVALID_ADDRESS; |
| 936 | ErrorSummary::InvalidArgument, ErrorLevel::Usage); | ||
| 937 | } | 907 | } |
| 938 | 908 | ||
| 939 | // When trying to create a memory block with address = 0, | 909 | // When trying to create a memory block with address = 0, |
| @@ -1035,7 +1005,7 @@ static ResultCode GetProcessInfo(s64* out, Kernel::Handle process_handle, u32 ty | |||
| 1035 | *out = process->heap_used + process->linear_heap_used + process->misc_memory_used; | 1005 | *out = process->heap_used + process->linear_heap_used + process->misc_memory_used; |
| 1036 | if (*out % Memory::PAGE_SIZE != 0) { | 1006 | if (*out % Memory::PAGE_SIZE != 0) { |
| 1037 | LOG_ERROR(Kernel_SVC, "called, memory size not page-aligned"); | 1007 | LOG_ERROR(Kernel_SVC, "called, memory size not page-aligned"); |
| 1038 | return ERR_MISALIGNED_SIZE; | 1008 | return Kernel::ERR_MISALIGNED_SIZE; |
| 1039 | } | 1009 | } |
| 1040 | break; | 1010 | break; |
| 1041 | case 1: | 1011 | case 1: |
| @@ -1051,19 +1021,15 @@ static ResultCode GetProcessInfo(s64* out, Kernel::Handle process_handle, u32 ty | |||
| 1051 | case 20: | 1021 | case 20: |
| 1052 | *out = Memory::FCRAM_PADDR - process->GetLinearHeapBase(); | 1022 | *out = Memory::FCRAM_PADDR - process->GetLinearHeapBase(); |
| 1053 | break; | 1023 | break; |
| 1024 | case 21: | ||
| 1025 | case 22: | ||
| 1026 | case 23: | ||
| 1027 | // These return a different error value than higher invalid values | ||
| 1028 | LOG_ERROR(Kernel_SVC, "unknown GetProcessInfo type=%u", type); | ||
| 1029 | return Kernel::ERR_NOT_IMPLEMENTED; | ||
| 1054 | default: | 1030 | default: |
| 1055 | LOG_ERROR(Kernel_SVC, "unknown GetProcessInfo type=%u", type); | 1031 | LOG_ERROR(Kernel_SVC, "unknown GetProcessInfo type=%u", type); |
| 1056 | 1032 | return Kernel::ERR_INVALID_ENUM_VALUE; | |
| 1057 | if (type >= 21 && type <= 23) { | ||
| 1058 | return ResultCode( // 0xE0E01BF4 | ||
| 1059 | ErrorDescription::NotImplemented, ErrorModule::OS, ErrorSummary::InvalidArgument, | ||
| 1060 | ErrorLevel::Usage); | ||
| 1061 | } else { | ||
| 1062 | return ResultCode( // 0xD8E007ED | ||
| 1063 | ErrorDescription::InvalidEnumValue, ErrorModule::Kernel, | ||
| 1064 | ErrorSummary::InvalidArgument, ErrorLevel::Permanent); | ||
| 1065 | } | ||
| 1066 | break; | ||
| 1067 | } | 1033 | } |
| 1068 | 1034 | ||
| 1069 | return RESULT_SUCCESS; | 1035 | return RESULT_SUCCESS; |