diff options
Diffstat (limited to 'src/core/hle/kernel')
| -rw-r--r-- | src/core/hle/kernel/address_arbiter.h | 2 | ||||
| -rw-r--r-- | src/core/hle/kernel/archive.cpp | 6 | ||||
| -rw-r--r-- | src/core/hle/kernel/event.cpp | 4 | ||||
| -rw-r--r-- | src/core/hle/kernel/event.h | 2 | ||||
| -rw-r--r-- | src/core/hle/kernel/kernel.cpp | 6 | ||||
| -rw-r--r-- | src/core/hle/kernel/kernel.h | 10 | ||||
| -rw-r--r-- | src/core/hle/kernel/mutex.cpp | 4 | ||||
| -rw-r--r-- | src/core/hle/kernel/mutex.h | 2 | ||||
| -rw-r--r-- | src/core/hle/kernel/shared_memory.cpp | 4 | ||||
| -rw-r--r-- | src/core/hle/kernel/shared_memory.h | 4 | ||||
| -rw-r--r-- | src/core/hle/kernel/thread.cpp | 38 | ||||
| -rw-r--r-- | src/core/hle/kernel/thread.h | 2 |
12 files changed, 42 insertions, 42 deletions
diff --git a/src/core/hle/kernel/address_arbiter.h b/src/core/hle/kernel/address_arbiter.h index a483fe466..6886e479d 100644 --- a/src/core/hle/kernel/address_arbiter.h +++ b/src/core/hle/kernel/address_arbiter.h | |||
| @@ -11,7 +11,7 @@ | |||
| 11 | // Address arbiters are an underlying kernel synchronization object that can be created/used via | 11 | // Address arbiters are an underlying kernel synchronization object that can be created/used via |
| 12 | // supervisor calls (SVCs). They function as sort of a global lock. Typically, games/other CTR | 12 | // supervisor calls (SVCs). They function as sort of a global lock. Typically, games/other CTR |
| 13 | // applications use them as an underlying mechanism to implement thread-safe barriers, events, and | 13 | // applications use them as an underlying mechanism to implement thread-safe barriers, events, and |
| 14 | // semphores. | 14 | // semphores. |
| 15 | 15 | ||
| 16 | //////////////////////////////////////////////////////////////////////////////////////////////////// | 16 | //////////////////////////////////////////////////////////////////////////////////////////////////// |
| 17 | // Kernel namespace | 17 | // Kernel namespace |
diff --git a/src/core/hle/kernel/archive.cpp b/src/core/hle/kernel/archive.cpp index 8f1c95d0f..d9ee4682a 100644 --- a/src/core/hle/kernel/archive.cpp +++ b/src/core/hle/kernel/archive.cpp | |||
| @@ -52,14 +52,14 @@ public: | |||
| 52 | FileSys::Archive* backend; ///< Archive backend interface | 52 | FileSys::Archive* backend; ///< Archive backend interface |
| 53 | 53 | ||
| 54 | /** | 54 | /** |
| 55 | * Synchronize kernel object | 55 | * Synchronize kernel object |
| 56 | * @param wait Boolean wait set if current thread should wait as a result of sync operation | 56 | * @param wait Boolean wait set if current thread should wait as a result of sync operation |
| 57 | * @return Result of operation, 0 on success, otherwise error code | 57 | * @return Result of operation, 0 on success, otherwise error code |
| 58 | */ | 58 | */ |
| 59 | Result SyncRequest(bool* wait) override { | 59 | Result SyncRequest(bool* wait) override { |
| 60 | u32* cmd_buff = Service::GetCommandBuffer(); | 60 | u32* cmd_buff = Service::GetCommandBuffer(); |
| 61 | FileCommand cmd = static_cast<FileCommand>(cmd_buff[0]); | 61 | FileCommand cmd = static_cast<FileCommand>(cmd_buff[0]); |
| 62 | 62 | ||
| 63 | switch (cmd) { | 63 | switch (cmd) { |
| 64 | // Read from archive... | 64 | // Read from archive... |
| 65 | case FileCommand::Read: | 65 | case FileCommand::Read: |
| @@ -343,7 +343,7 @@ Archive* CreateArchive(Handle& handle, FileSys::Archive* backend, const std::str | |||
| 343 | archive->backend = backend; | 343 | archive->backend = backend; |
| 344 | 344 | ||
| 345 | MountArchive(archive); | 345 | MountArchive(archive); |
| 346 | 346 | ||
| 347 | return archive; | 347 | return archive; |
| 348 | } | 348 | } |
| 349 | 349 | ||
diff --git a/src/core/hle/kernel/event.cpp b/src/core/hle/kernel/event.cpp index 45ed79be8..e0117c0bc 100644 --- a/src/core/hle/kernel/event.cpp +++ b/src/core/hle/kernel/event.cpp | |||
| @@ -1,6 +1,6 @@ | |||
| 1 | // Copyright 2014 Citra Emulator Project | 1 | // Copyright 2014 Citra Emulator Project |
| 2 | // Licensed under GPLv2 | 2 | // Licensed under GPLv2 |
| 3 | // Refer to the license.txt file included. | 3 | // Refer to the license.txt file included. |
| 4 | 4 | ||
| 5 | #include <map> | 5 | #include <map> |
| 6 | #include <algorithm> | 6 | #include <algorithm> |
| @@ -95,7 +95,7 @@ Result SignalEvent(const Handle handle) { | |||
| 95 | for (size_t i = 0; i < evt->waiting_threads.size(); ++i) { | 95 | for (size_t i = 0; i < evt->waiting_threads.size(); ++i) { |
| 96 | ResumeThreadFromWait( evt->waiting_threads[i]); | 96 | ResumeThreadFromWait( evt->waiting_threads[i]); |
| 97 | 97 | ||
| 98 | // If any thread is signalled awake by this event, assume the event was "caught" and reset | 98 | // If any thread is signalled awake by this event, assume the event was "caught" and reset |
| 99 | // the event. This will result in the next thread waiting on the event to block. Otherwise, | 99 | // the event. This will result in the next thread waiting on the event to block. Otherwise, |
| 100 | // the event will not be reset, and the next thread to call WaitSynchronization on it will | 100 | // the event will not be reset, and the next thread to call WaitSynchronization on it will |
| 101 | // not block. Not sure if this is correct behavior, but it seems to work. | 101 | // not block. Not sure if this is correct behavior, but it seems to work. |
diff --git a/src/core/hle/kernel/event.h b/src/core/hle/kernel/event.h index c39b33180..6add72897 100644 --- a/src/core/hle/kernel/event.h +++ b/src/core/hle/kernel/event.h | |||
| @@ -1,6 +1,6 @@ | |||
| 1 | // Copyright 2014 Citra Emulator Project | 1 | // Copyright 2014 Citra Emulator Project |
| 2 | // Licensed under GPLv2 | 2 | // Licensed under GPLv2 |
| 3 | // Refer to the license.txt file included. | 3 | // Refer to the license.txt file included. |
| 4 | 4 | ||
| 5 | #pragma once | 5 | #pragma once |
| 6 | 6 | ||
diff --git a/src/core/hle/kernel/kernel.cpp b/src/core/hle/kernel/kernel.cpp index 88cbc1af5..018000abd 100644 --- a/src/core/hle/kernel/kernel.cpp +++ b/src/core/hle/kernel/kernel.cpp | |||
| @@ -1,6 +1,6 @@ | |||
| 1 | // Copyright 2014 Citra Emulator Project / PPSSPP Project | 1 | // Copyright 2014 Citra Emulator Project / PPSSPP Project |
| 2 | // Licensed under GPLv2 | 2 | // Licensed under GPLv2 |
| 3 | // Refer to the license.txt file included. | 3 | // Refer to the license.txt file included. |
| 4 | 4 | ||
| 5 | #include "common/common.h" | 5 | #include "common/common.h" |
| 6 | 6 | ||
| @@ -68,7 +68,7 @@ void ObjectPool::List() { | |||
| 68 | for (int i = 0; i < MAX_COUNT; i++) { | 68 | for (int i = 0; i < MAX_COUNT; i++) { |
| 69 | if (occupied[i]) { | 69 | if (occupied[i]) { |
| 70 | if (pool[i]) { | 70 | if (pool[i]) { |
| 71 | INFO_LOG(KERNEL, "KO %i: %s \"%s\"", i + HANDLE_OFFSET, pool[i]->GetTypeName().c_str(), | 71 | INFO_LOG(KERNEL, "KO %i: %s \"%s\"", i + HANDLE_OFFSET, pool[i]->GetTypeName().c_str(), |
| 72 | pool[i]->GetName().c_str()); | 72 | pool[i]->GetName().c_str()); |
| 73 | } | 73 | } |
| 74 | } | 74 | } |
| @@ -110,7 +110,7 @@ void Shutdown() { | |||
| 110 | */ | 110 | */ |
| 111 | bool LoadExec(u32 entry_point) { | 111 | bool LoadExec(u32 entry_point) { |
| 112 | Init(); | 112 | Init(); |
| 113 | 113 | ||
| 114 | Core::g_app_core->SetPC(entry_point); | 114 | Core::g_app_core->SetPC(entry_point); |
| 115 | 115 | ||
| 116 | // 0x30 is the typical main thread priority I've seen used so far | 116 | // 0x30 is the typical main thread priority I've seen used so far |
diff --git a/src/core/hle/kernel/kernel.h b/src/core/hle/kernel/kernel.h index dd7c91d4f..e0c94f186 100644 --- a/src/core/hle/kernel/kernel.h +++ b/src/core/hle/kernel/kernel.h | |||
| @@ -1,6 +1,6 @@ | |||
| 1 | // Copyright 2014 Citra Emulator Project / PPSSPP Project | 1 | // Copyright 2014 Citra Emulator Project / PPSSPP Project |
| 2 | // Licensed under GPLv2 | 2 | // Licensed under GPLv2 |
| 3 | // Refer to the license.txt file included. | 3 | // Refer to the license.txt file included. |
| 4 | 4 | ||
| 5 | #pragma once | 5 | #pragma once |
| 6 | 6 | ||
| @@ -34,7 +34,7 @@ enum class HandleType : u32 { | |||
| 34 | Archive = 12, | 34 | Archive = 12, |
| 35 | Directory = 13, | 35 | Directory = 13, |
| 36 | }; | 36 | }; |
| 37 | 37 | ||
| 38 | enum { | 38 | enum { |
| 39 | DEFAULT_STACK_SIZE = 0x4000, | 39 | DEFAULT_STACK_SIZE = 0x4000, |
| 40 | }; | 40 | }; |
| @@ -52,7 +52,7 @@ public: | |||
| 52 | virtual Kernel::HandleType GetHandleType() const = 0; | 52 | virtual Kernel::HandleType GetHandleType() const = 0; |
| 53 | 53 | ||
| 54 | /** | 54 | /** |
| 55 | * Synchronize kernel object | 55 | * Synchronize kernel object |
| 56 | * @param wait Boolean wait set if current thread should wait as a result of sync operation | 56 | * @param wait Boolean wait set if current thread should wait as a result of sync operation |
| 57 | * @return Result of operation, 0 on success, otherwise error code | 57 | * @return Result of operation, 0 on success, otherwise error code |
| 58 | */ | 58 | */ |
| @@ -139,7 +139,7 @@ public: | |||
| 139 | } | 139 | } |
| 140 | 140 | ||
| 141 | bool GetIDType(Handle handle, HandleType* type) const { | 141 | bool GetIDType(Handle handle, HandleType* type) const { |
| 142 | if ((handle < HANDLE_OFFSET) || (handle >= HANDLE_OFFSET + MAX_COUNT) || | 142 | if ((handle < HANDLE_OFFSET) || (handle >= HANDLE_OFFSET + MAX_COUNT) || |
| 143 | !occupied[handle - HANDLE_OFFSET]) { | 143 | !occupied[handle - HANDLE_OFFSET]) { |
| 144 | ERROR_LOG(KERNEL, "Kernel: Bad object handle %i (%08x)", handle, handle); | 144 | ERROR_LOG(KERNEL, "Kernel: Bad object handle %i (%08x)", handle, handle); |
| 145 | return false; | 145 | return false; |
| @@ -155,7 +155,7 @@ public: | |||
| 155 | int GetCount(); | 155 | int GetCount(); |
| 156 | 156 | ||
| 157 | private: | 157 | private: |
| 158 | 158 | ||
| 159 | enum { | 159 | enum { |
| 160 | MAX_COUNT = 0x1000, | 160 | MAX_COUNT = 0x1000, |
| 161 | HANDLE_OFFSET = 0x100, | 161 | HANDLE_OFFSET = 0x100, |
diff --git a/src/core/hle/kernel/mutex.cpp b/src/core/hle/kernel/mutex.cpp index fcfd061ac..31129fd86 100644 --- a/src/core/hle/kernel/mutex.cpp +++ b/src/core/hle/kernel/mutex.cpp | |||
| @@ -1,6 +1,6 @@ | |||
| 1 | // Copyright 2014 Citra Emulator Project | 1 | // Copyright 2014 Citra Emulator Project |
| 2 | // Licensed under GPLv2 | 2 | // Licensed under GPLv2 |
| 3 | // Refer to the license.txt file included. | 3 | // Refer to the license.txt file included. |
| 4 | 4 | ||
| 5 | #include <map> | 5 | #include <map> |
| 6 | #include <vector> | 6 | #include <vector> |
| @@ -28,7 +28,7 @@ public: | |||
| 28 | std::string name; ///< Name of mutex (optional) | 28 | std::string name; ///< Name of mutex (optional) |
| 29 | 29 | ||
| 30 | /** | 30 | /** |
| 31 | * Synchronize kernel object | 31 | * Synchronize kernel object |
| 32 | * @param wait Boolean wait set if current thread should wait as a result of sync operation | 32 | * @param wait Boolean wait set if current thread should wait as a result of sync operation |
| 33 | * @return Result of operation, 0 on success, otherwise error code | 33 | * @return Result of operation, 0 on success, otherwise error code |
| 34 | */ | 34 | */ |
diff --git a/src/core/hle/kernel/mutex.h b/src/core/hle/kernel/mutex.h index 7d7b5137e..313ba6fee 100644 --- a/src/core/hle/kernel/mutex.h +++ b/src/core/hle/kernel/mutex.h | |||
| @@ -1,6 +1,6 @@ | |||
| 1 | // Copyright 2014 Citra Emulator Project | 1 | // Copyright 2014 Citra Emulator Project |
| 2 | // Licensed under GPLv2 | 2 | // Licensed under GPLv2 |
| 3 | // Refer to the license.txt file included. | 3 | // Refer to the license.txt file included. |
| 4 | 4 | ||
| 5 | #pragma once | 5 | #pragma once |
| 6 | 6 | ||
diff --git a/src/core/hle/kernel/shared_memory.cpp b/src/core/hle/kernel/shared_memory.cpp index f538c6550..7ef3e54cc 100644 --- a/src/core/hle/kernel/shared_memory.cpp +++ b/src/core/hle/kernel/shared_memory.cpp | |||
| @@ -1,6 +1,6 @@ | |||
| 1 | // Copyright 2014 Citra Emulator Project | 1 | // Copyright 2014 Citra Emulator Project |
| 2 | // Licensed under GPLv2 | 2 | // Licensed under GPLv2 |
| 3 | // Refer to the license.txt file included. | 3 | // Refer to the license.txt file included. |
| 4 | 4 | ||
| 5 | #include "common/common.h" | 5 | #include "common/common.h" |
| 6 | 6 | ||
| @@ -67,7 +67,7 @@ Handle CreateSharedMemory(const std::string& name) { | |||
| 67 | * @param other_permissions Memory block map other permissions (specified by SVC field) | 67 | * @param other_permissions Memory block map other permissions (specified by SVC field) |
| 68 | * @return Result of operation, 0 on success, otherwise error code | 68 | * @return Result of operation, 0 on success, otherwise error code |
| 69 | */ | 69 | */ |
| 70 | Result MapSharedMemory(u32 handle, u32 address, MemoryPermission permissions, | 70 | Result MapSharedMemory(u32 handle, u32 address, MemoryPermission permissions, |
| 71 | MemoryPermission other_permissions) { | 71 | MemoryPermission other_permissions) { |
| 72 | 72 | ||
| 73 | if (address < Memory::SHARED_MEMORY_VADDR || address >= Memory::SHARED_MEMORY_VADDR_END) { | 73 | if (address < Memory::SHARED_MEMORY_VADDR || address >= Memory::SHARED_MEMORY_VADDR_END) { |
diff --git a/src/core/hle/kernel/shared_memory.h b/src/core/hle/kernel/shared_memory.h index 5312b8854..0aec03538 100644 --- a/src/core/hle/kernel/shared_memory.h +++ b/src/core/hle/kernel/shared_memory.h | |||
| @@ -1,6 +1,6 @@ | |||
| 1 | // Copyright 2014 Citra Emulator Project | 1 | // Copyright 2014 Citra Emulator Project |
| 2 | // Licensed under GPLv2 | 2 | // Licensed under GPLv2 |
| 3 | // Refer to the license.txt file included. | 3 | // Refer to the license.txt file included. |
| 4 | 4 | ||
| 5 | #pragma once | 5 | #pragma once |
| 6 | 6 | ||
| @@ -34,7 +34,7 @@ Handle CreateSharedMemory(const std::string& name="Unknown"); | |||
| 34 | * @param other_permissions Memory block map other permissions (specified by SVC field) | 34 | * @param other_permissions Memory block map other permissions (specified by SVC field) |
| 35 | * @return Result of operation, 0 on success, otherwise error code | 35 | * @return Result of operation, 0 on success, otherwise error code |
| 36 | */ | 36 | */ |
| 37 | Result MapSharedMemory(u32 handle, u32 address, MemoryPermission permissions, | 37 | Result MapSharedMemory(u32 handle, u32 address, MemoryPermission permissions, |
| 38 | MemoryPermission other_permissions); | 38 | MemoryPermission other_permissions); |
| 39 | 39 | ||
| 40 | /** | 40 | /** |
diff --git a/src/core/hle/kernel/thread.cpp b/src/core/hle/kernel/thread.cpp index e15590c49..9e2e15c8e 100644 --- a/src/core/hle/kernel/thread.cpp +++ b/src/core/hle/kernel/thread.cpp | |||
| @@ -1,6 +1,6 @@ | |||
| 1 | // Copyright 2014 Citra Emulator Project / PPSSPP Project | 1 | // Copyright 2014 Citra Emulator Project / PPSSPP Project |
| 2 | // Licensed under GPLv2 | 2 | // Licensed under GPLv2 |
| 3 | // Refer to the license.txt file included. | 3 | // Refer to the license.txt file included. |
| 4 | 4 | ||
| 5 | #include <algorithm> | 5 | #include <algorithm> |
| 6 | #include <list> | 6 | #include <list> |
| @@ -113,7 +113,7 @@ void ResetThread(Thread* t, u32 arg, s32 lowest_priority) { | |||
| 113 | t->context.pc = t->context.reg_15 = t->entry_point; | 113 | t->context.pc = t->context.reg_15 = t->entry_point; |
| 114 | t->context.sp = t->stack_top; | 114 | t->context.sp = t->stack_top; |
| 115 | t->context.cpsr = 0x1F; // Usermode | 115 | t->context.cpsr = 0x1F; // Usermode |
| 116 | 116 | ||
| 117 | // TODO(bunnei): This instructs the CPU core to start the execution as if it is "resuming" a | 117 | // TODO(bunnei): This instructs the CPU core to start the execution as if it is "resuming" a |
| 118 | // thread. This is somewhat Sky-Eye specific, and should be re-architected in the future to be | 118 | // thread. This is somewhat Sky-Eye specific, and should be re-architected in the future to be |
| 119 | // agnostic of the CPU core. | 119 | // agnostic of the CPU core. |
| @@ -148,7 +148,7 @@ inline bool VerifyWait(const Handle& handle, WaitType type, Handle wait_handle) | |||
| 148 | Thread* thread = g_object_pool.GetFast<Thread>(handle); | 148 | Thread* thread = g_object_pool.GetFast<Thread>(handle); |
| 149 | _assert_msg_(KERNEL, (thread != nullptr), "called, but thread is nullptr!"); | 149 | _assert_msg_(KERNEL, (thread != nullptr), "called, but thread is nullptr!"); |
| 150 | 150 | ||
| 151 | if (type != thread->wait_type || wait_handle != thread->wait_handle) | 151 | if (type != thread->wait_type || wait_handle != thread->wait_handle) |
| 152 | return false; | 152 | return false; |
| 153 | 153 | ||
| 154 | return true; | 154 | return true; |
| @@ -158,7 +158,7 @@ inline bool VerifyWait(const Handle& handle, WaitType type, Handle wait_handle) | |||
| 158 | void StopThread(Handle handle, const char* reason) { | 158 | void StopThread(Handle handle, const char* reason) { |
| 159 | Thread* thread = g_object_pool.GetFast<Thread>(handle); | 159 | Thread* thread = g_object_pool.GetFast<Thread>(handle); |
| 160 | _assert_msg_(KERNEL, (thread != nullptr), "called, but thread is nullptr!"); | 160 | _assert_msg_(KERNEL, (thread != nullptr), "called, but thread is nullptr!"); |
| 161 | 161 | ||
| 162 | ChangeReadyState(thread, false); | 162 | ChangeReadyState(thread, false); |
| 163 | thread->status = THREADSTATUS_DORMANT; | 163 | thread->status = THREADSTATUS_DORMANT; |
| 164 | for (size_t i = 0; i < thread->waiting_threads.size(); ++i) { | 164 | for (size_t i = 0; i < thread->waiting_threads.size(); ++i) { |
| @@ -181,7 +181,7 @@ void ChangeThreadState(Thread* t, ThreadStatus new_status) { | |||
| 181 | } | 181 | } |
| 182 | ChangeReadyState(t, (new_status & THREADSTATUS_READY) != 0); | 182 | ChangeReadyState(t, (new_status & THREADSTATUS_READY) != 0); |
| 183 | t->status = new_status; | 183 | t->status = new_status; |
| 184 | 184 | ||
| 185 | if (new_status == THREADSTATUS_WAIT) { | 185 | if (new_status == THREADSTATUS_WAIT) { |
| 186 | if (t->wait_type == WAITTYPE_NONE) { | 186 | if (t->wait_type == WAITTYPE_NONE) { |
| 187 | ERROR_LOG(KERNEL, "Waittype none not allowed"); | 187 | ERROR_LOG(KERNEL, "Waittype none not allowed"); |
| @@ -216,7 +216,7 @@ Handle ArbitrateHighestPriorityThread(u32 arbiter, u32 address) { | |||
| 216 | 216 | ||
| 217 | /// Arbitrate all threads currently waiting | 217 | /// Arbitrate all threads currently waiting |
| 218 | void ArbitrateAllThreads(u32 arbiter, u32 address) { | 218 | void ArbitrateAllThreads(u32 arbiter, u32 address) { |
| 219 | 219 | ||
| 220 | // Iterate through threads, find highest priority thread that is waiting to be arbitrated... | 220 | // Iterate through threads, find highest priority thread that is waiting to be arbitrated... |
| 221 | for (const auto& handle : g_thread_queue) { | 221 | for (const auto& handle : g_thread_queue) { |
| 222 | 222 | ||
| @@ -238,11 +238,11 @@ void CallThread(Thread* t) { | |||
| 238 | /// Switches CPU context to that of the specified thread | 238 | /// Switches CPU context to that of the specified thread |
| 239 | void SwitchContext(Thread* t) { | 239 | void SwitchContext(Thread* t) { |
| 240 | Thread* cur = GetCurrentThread(); | 240 | Thread* cur = GetCurrentThread(); |
| 241 | 241 | ||
| 242 | // Save context for current thread | 242 | // Save context for current thread |
| 243 | if (cur) { | 243 | if (cur) { |
| 244 | SaveContext(cur->context); | 244 | SaveContext(cur->context); |
| 245 | 245 | ||
| 246 | if (cur->IsRunning()) { | 246 | if (cur->IsRunning()) { |
| 247 | ChangeReadyState(cur, true); | 247 | ChangeReadyState(cur, true); |
| 248 | } | 248 | } |
| @@ -263,7 +263,7 @@ void SwitchContext(Thread* t) { | |||
| 263 | Thread* NextThread() { | 263 | Thread* NextThread() { |
| 264 | Handle next; | 264 | Handle next; |
| 265 | Thread* cur = GetCurrentThread(); | 265 | Thread* cur = GetCurrentThread(); |
| 266 | 266 | ||
| 267 | if (cur && cur->IsRunning()) { | 267 | if (cur && cur->IsRunning()) { |
| 268 | next = g_thread_ready_queue.pop_first_better(cur->current_priority); | 268 | next = g_thread_ready_queue.pop_first_better(cur->current_priority); |
| 269 | } else { | 269 | } else { |
| @@ -319,7 +319,7 @@ void DebugThreadQueue() { | |||
| 319 | Thread* CreateThread(Handle& handle, const char* name, u32 entry_point, s32 priority, | 319 | Thread* CreateThread(Handle& handle, const char* name, u32 entry_point, s32 priority, |
| 320 | s32 processor_id, u32 stack_top, int stack_size) { | 320 | s32 processor_id, u32 stack_top, int stack_size) { |
| 321 | 321 | ||
| 322 | _assert_msg_(KERNEL, (priority >= THREADPRIO_HIGHEST && priority <= THREADPRIO_LOWEST), | 322 | _assert_msg_(KERNEL, (priority >= THREADPRIO_HIGHEST && priority <= THREADPRIO_LOWEST), |
| 323 | "CreateThread priority=%d, outside of allowable range!", priority) | 323 | "CreateThread priority=%d, outside of allowable range!", priority) |
| 324 | 324 | ||
| 325 | Thread* thread = new Thread; | 325 | Thread* thread = new Thread; |
| @@ -351,7 +351,7 @@ Handle CreateThread(const char* name, u32 entry_point, s32 priority, u32 arg, s3 | |||
| 351 | return -1; | 351 | return -1; |
| 352 | } | 352 | } |
| 353 | if ((u32)stack_size < 0x200) { | 353 | if ((u32)stack_size < 0x200) { |
| 354 | ERROR_LOG(KERNEL, "CreateThread(name=%s): invalid stack_size=0x%08X", name, | 354 | ERROR_LOG(KERNEL, "CreateThread(name=%s): invalid stack_size=0x%08X", name, |
| 355 | stack_size); | 355 | stack_size); |
| 356 | return -1; | 356 | return -1; |
| 357 | } | 357 | } |
| @@ -368,7 +368,7 @@ Handle CreateThread(const char* name, u32 entry_point, s32 priority, u32 arg, s3 | |||
| 368 | return -1; | 368 | return -1; |
| 369 | } | 369 | } |
| 370 | Handle handle; | 370 | Handle handle; |
| 371 | Thread* thread = CreateThread(handle, name, entry_point, priority, processor_id, stack_top, | 371 | Thread* thread = CreateThread(handle, name, entry_point, priority, processor_id, stack_top, |
| 372 | stack_size); | 372 | stack_size); |
| 373 | 373 | ||
| 374 | ResetThread(thread, arg, 0); | 374 | ResetThread(thread, arg, 0); |
| @@ -423,19 +423,19 @@ Result SetThreadPriority(Handle handle, s32 priority) { | |||
| 423 | /// Sets up the primary application thread | 423 | /// Sets up the primary application thread |
| 424 | Handle SetupMainThread(s32 priority, int stack_size) { | 424 | Handle SetupMainThread(s32 priority, int stack_size) { |
| 425 | Handle handle; | 425 | Handle handle; |
| 426 | 426 | ||
| 427 | // Initialize new "main" thread | 427 | // Initialize new "main" thread |
| 428 | Thread* thread = CreateThread(handle, "main", Core::g_app_core->GetPC(), priority, | 428 | Thread* thread = CreateThread(handle, "main", Core::g_app_core->GetPC(), priority, |
| 429 | THREADPROCESSORID_0, Memory::SCRATCHPAD_VADDR_END, stack_size); | 429 | THREADPROCESSORID_0, Memory::SCRATCHPAD_VADDR_END, stack_size); |
| 430 | 430 | ||
| 431 | ResetThread(thread, 0, 0); | 431 | ResetThread(thread, 0, 0); |
| 432 | 432 | ||
| 433 | // If running another thread already, set it to "ready" state | 433 | // If running another thread already, set it to "ready" state |
| 434 | Thread* cur = GetCurrentThread(); | 434 | Thread* cur = GetCurrentThread(); |
| 435 | if (cur && cur->IsRunning()) { | 435 | if (cur && cur->IsRunning()) { |
| 436 | ChangeReadyState(cur, true); | 436 | ChangeReadyState(cur, true); |
| 437 | } | 437 | } |
| 438 | 438 | ||
| 439 | // Run new "main" thread | 439 | // Run new "main" thread |
| 440 | SetCurrentThread(thread); | 440 | SetCurrentThread(thread); |
| 441 | thread->status = THREADSTATUS_RUNNING; | 441 | thread->status = THREADSTATUS_RUNNING; |
| @@ -452,12 +452,12 @@ void Reschedule() { | |||
| 452 | HLE::g_reschedule = false; | 452 | HLE::g_reschedule = false; |
| 453 | if (next > 0) { | 453 | if (next > 0) { |
| 454 | INFO_LOG(KERNEL, "context switch 0x%08X -> 0x%08X", prev->GetHandle(), next->GetHandle()); | 454 | INFO_LOG(KERNEL, "context switch 0x%08X -> 0x%08X", prev->GetHandle(), next->GetHandle()); |
| 455 | 455 | ||
| 456 | SwitchContext(next); | 456 | SwitchContext(next); |
| 457 | 457 | ||
| 458 | // Hack - There is no mechanism yet to waken the primary thread if it has been put to sleep | 458 | // Hack - There is no mechanism yet to waken the primary thread if it has been put to sleep |
| 459 | // by a simulated VBLANK thread switch. So, we'll just immediately set it to "ready" again. | 459 | // by a simulated VBLANK thread switch. So, we'll just immediately set it to "ready" again. |
| 460 | // This results in the current thread yielding on a VBLANK once, and then it will be | 460 | // This results in the current thread yielding on a VBLANK once, and then it will be |
| 461 | // immediately placed back in the queue for execution. | 461 | // immediately placed back in the queue for execution. |
| 462 | if (prev->wait_type == WAITTYPE_VBLANK) { | 462 | if (prev->wait_type == WAITTYPE_VBLANK) { |
| 463 | ResumeThreadFromWait(prev->GetHandle()); | 463 | ResumeThreadFromWait(prev->GetHandle()); |
diff --git a/src/core/hle/kernel/thread.h b/src/core/hle/kernel/thread.h index 39fa38b75..2a43797ee 100644 --- a/src/core/hle/kernel/thread.h +++ b/src/core/hle/kernel/thread.h | |||
| @@ -1,6 +1,6 @@ | |||
| 1 | // Copyright 2014 Citra Emulator Project / PPSSPP Project | 1 | // Copyright 2014 Citra Emulator Project / PPSSPP Project |
| 2 | // Licensed under GPLv2 | 2 | // Licensed under GPLv2 |
| 3 | // Refer to the license.txt file included. | 3 | // Refer to the license.txt file included. |
| 4 | 4 | ||
| 5 | #pragma once | 5 | #pragma once |
| 6 | 6 | ||