summaryrefslogtreecommitdiff
path: root/src/core/hle/kernel
diff options
context:
space:
mode:
authorGravatar Yuri Kunde Schlesner2017-05-21 00:11:36 -0700
committerGravatar Yuri Kunde Schlesner2017-05-24 21:06:00 -0700
commit2cdb40d709f2a5d4f7f3159d4c6d80fe7905b4f3 (patch)
tree7d6d61465f7a4cb6bbb68902301e1ca92f5a76a5 /src/core/hle/kernel
parentGSP_GPU: Move error codes from result.h to local file (diff)
downloadyuzu-2cdb40d709f2a5d4f7f3159d4c6d80fe7905b4f3.tar.gz
yuzu-2cdb40d709f2a5d4f7f3159d4c6d80fe7905b4f3.tar.xz
yuzu-2cdb40d709f2a5d4f7f3159d4c6d80fe7905b4f3.zip
Kernel: Centralize error definitions in errors.h
Diffstat (limited to 'src/core/hle/kernel')
-rw-r--r--src/core/hle/kernel/address_arbiter.cpp7
-rw-r--r--src/core/hle/kernel/client_port.cpp4
-rw-r--r--src/core/hle/kernel/client_session.cpp3
-rw-r--r--src/core/hle/kernel/errors.h98
-rw-r--r--src/core/hle/kernel/kernel.cpp1
-rw-r--r--src/core/hle/kernel/kernel.h7
-rw-r--r--src/core/hle/kernel/process.cpp1
-rw-r--r--src/core/hle/kernel/semaphore.cpp7
-rw-r--r--src/core/hle/kernel/shared_memory.cpp16
-rw-r--r--src/core/hle/kernel/thread.cpp24
-rw-r--r--src/core/hle/kernel/thread.h2
-rw-r--r--src/core/hle/kernel/vm_manager.cpp1
-rw-r--r--src/core/hle/kernel/vm_manager.h8
13 files changed, 133 insertions, 46 deletions
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
9namespace Kernel {
10
11namespace ErrCodes {
12enum {
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
25constexpr ResultCode ERR_OUT_OF_HANDLES(ErrCodes::OutOfHandles, ErrorModule::Kernel,
26 ErrorSummary::OutOfResource,
27 ErrorLevel::Permanent); // 0xD8600413
28constexpr ResultCode ERR_SESSION_CLOSED_BY_REMOTE(ErrCodes::SessionClosedByRemote, ErrorModule::OS,
29 ErrorSummary::Canceled,
30 ErrorLevel::Status); // 0xC920181A
31constexpr ResultCode ERR_PORT_NAME_TOO_LONG(ErrCodes::PortNameTooLong, ErrorModule::OS,
32 ErrorSummary::InvalidArgument,
33 ErrorLevel::Usage); // 0xE0E0181E
34constexpr ResultCode ERR_WRONG_PERMISSION(ErrCodes::WrongPermission, ErrorModule::OS,
35 ErrorSummary::WrongArgument, ErrorLevel::Permanent);
36constexpr ResultCode ERR_INVALID_BUFFER_DESCRIPTOR(ErrCodes::InvalidBufferDescriptor,
37 ErrorModule::OS, ErrorSummary::WrongArgument,
38 ErrorLevel::Permanent);
39constexpr ResultCode ERR_MAX_CONNECTIONS_REACHED(ErrCodes::MaxConnectionsReached, ErrorModule::OS,
40 ErrorSummary::WouldBlock,
41 ErrorLevel::Temporary); // 0xD0401834
42
43constexpr ResultCode ERR_NOT_AUTHORIZED(ErrorDescription::NotAuthorized, ErrorModule::OS,
44 ErrorSummary::WrongArgument,
45 ErrorLevel::Permanent); // 0xD9001BEA
46constexpr ResultCode ERR_INVALID_ENUM_VALUE(ErrorDescription::InvalidEnumValue, ErrorModule::Kernel,
47 ErrorSummary::InvalidArgument,
48 ErrorLevel::Permanent); // 0xD8E007ED
49constexpr ResultCode ERR_INVALID_ENUM_VALUE_FND(ErrorDescription::InvalidEnumValue,
50 ErrorModule::FND, ErrorSummary::InvalidArgument,
51 ErrorLevel::Permanent); // 0xD8E093ED
52constexpr ResultCode ERR_INVALID_COMBINATION(ErrorDescription::InvalidCombination, ErrorModule::OS,
53 ErrorSummary::InvalidArgument,
54 ErrorLevel::Usage); // 0xE0E01BEE
55constexpr ResultCode ERR_INVALID_COMBINATION_KERNEL(ErrorDescription::InvalidCombination,
56 ErrorModule::Kernel,
57 ErrorSummary::WrongArgument,
58 ErrorLevel::Permanent); // 0xD90007EE
59constexpr ResultCode ERR_MISALIGNED_ADDRESS(ErrorDescription::MisalignedAddress, ErrorModule::OS,
60 ErrorSummary::InvalidArgument,
61 ErrorLevel::Usage); // 0xE0E01BF1
62constexpr ResultCode ERR_MISALIGNED_SIZE(ErrorDescription::MisalignedSize, ErrorModule::OS,
63 ErrorSummary::InvalidArgument,
64 ErrorLevel::Usage); // 0xE0E01BF2
65constexpr ResultCode ERR_OUT_OF_MEMORY(ErrorDescription::OutOfMemory, ErrorModule::Kernel,
66 ErrorSummary::OutOfResource,
67 ErrorLevel::Permanent); // 0xD86007F3
68constexpr ResultCode ERR_NOT_IMPLEMENTED(ErrorDescription::NotImplemented, ErrorModule::OS,
69 ErrorSummary::InvalidArgument,
70 ErrorLevel::Usage); // 0xE0E01BF4
71constexpr ResultCode ERR_INVALID_ADDRESS(ErrorDescription::InvalidAddress, ErrorModule::OS,
72 ErrorSummary::InvalidArgument,
73 ErrorLevel::Usage); // 0xE0E01BF5
74constexpr ResultCode ERR_INVALID_ADDRESS_STATE(ErrorDescription::InvalidAddress, ErrorModule::OS,
75 ErrorSummary::InvalidState,
76 ErrorLevel::Usage); // 0xE0A01BF5
77constexpr ResultCode ERR_INVALID_POINTER(ErrorDescription::InvalidPointer, ErrorModule::Kernel,
78 ErrorSummary::InvalidArgument,
79 ErrorLevel::Permanent); // 0xD8E007F6
80constexpr 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.
84constexpr ResultCode ERR_INVALID_HANDLE_OS(ErrorDescription::InvalidHandle, ErrorModule::OS,
85 ErrorSummary::WrongArgument,
86 ErrorLevel::Permanent); // 0xD9001BF7
87constexpr ResultCode ERR_NOT_FOUND(ErrorDescription::NotFound, ErrorModule::Kernel,
88 ErrorSummary::NotFound, ErrorLevel::Permanent); // 0xD88007FA
89constexpr ResultCode ERR_OUT_OF_RANGE(ErrorDescription::OutOfRange, ErrorModule::OS,
90 ErrorSummary::InvalidArgument,
91 ErrorLevel::Usage); // 0xE0E01BFD
92constexpr ResultCode ERR_OUT_OF_RANGE_KERNEL(ErrorDescription::OutOfRange, ErrorModule::Kernel,
93 ErrorSummary::InvalidArgument,
94 ErrorLevel::Permanent); // 0xD8E007FD
95constexpr 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
20class Thread; 20class Thread;
21 21
22// TODO: Verify code
23const ResultCode ERR_OUT_OF_HANDLES(ErrorDescription::OutOfMemory, ErrorModule::Kernel,
24 ErrorSummary::OutOfResource, ErrorLevel::Temporary);
25// TOOD: Verify code
26const ResultCode ERR_INVALID_HANDLE(ErrorDescription::InvalidHandle, ErrorModule::Kernel,
27 ErrorSummary::InvalidArgument, ErrorLevel::Permanent);
28
29enum KernelHandle : Handle { 22enum 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
43ResultVal<s32> Semaphore::Release(s32 release_count) { 43ResultVal<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
354ResultVal<SharedPtr<Thread>> Thread::Create(std::string name, VAddr entry_point, s32 priority, 353ResultVal<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
14namespace Kernel { 14namespace Kernel {
15 15
16const ResultCode ERR_INVALID_ADDRESS{// 0xE0E01BF5
17 ErrorDescription::InvalidAddress, ErrorModule::OS,
18 ErrorSummary::InvalidArgument, ErrorLevel::Usage};
19
20const ResultCode ERR_INVALID_ADDRESS_STATE{// 0xE0A01BF5
21 ErrorDescription::InvalidAddress, ErrorModule::OS,
22 ErrorSummary::InvalidState, ErrorLevel::Usage};
23
24enum class VMAType : u8 { 16enum 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,