summaryrefslogtreecommitdiff
path: root/src/core/hle/kernel/thread.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/core/hle/kernel/thread.cpp')
-rw-r--r--src/core/hle/kernel/thread.cpp24
1 files changed, 16 insertions, 8 deletions
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();