diff options
Diffstat (limited to 'src/core/hle/kernel/kernel.h')
-rw-r--r-- | src/core/hle/kernel/kernel.h | 36 |
1 files changed, 21 insertions, 15 deletions
diff --git a/src/core/hle/kernel/kernel.h b/src/core/hle/kernel/kernel.h index 85e3264b..32258d5a 100644 --- a/src/core/hle/kernel/kernel.h +++ b/src/core/hle/kernel/kernel.h @@ -1,5 +1,5 @@ // Copyright 2014 Citra Emulator Project / PPSSPP Project -// Licensed under GPLv2 +// Licensed under GPLv2 or any later version // Refer to the license.txt file included. #pragma once @@ -14,6 +14,10 @@ typedef s32 Result; namespace Kernel { +// From kernel.h. Declarations duplicated here to avoid a circular header dependency. +class Thread; +Thread* GetCurrentThread(); + enum KernelHandle { CurrentThread = 0xFFFF8000, CurrentProcess = 0xFFFF8001, @@ -22,7 +26,7 @@ enum KernelHandle { enum class HandleType : u32 { Unknown = 0, Port = 1, - Service = 2, + Session = 2, Event = 3, Mutex = 4, SharedMemory = 5, @@ -30,10 +34,7 @@ enum class HandleType : u32 { Thread = 7, Process = 8, AddressArbiter = 9, - File = 10, - Semaphore = 11, - Archive = 12, - Directory = 13, + Semaphore = 10, }; enum { @@ -53,15 +54,6 @@ public: virtual Kernel::HandleType GetHandleType() const = 0; /** - * Synchronize kernel object. - * @return True if the current thread should wait as a result of the sync - */ - virtual ResultVal<bool> SyncRequest() { - LOG_ERROR(Kernel, "(UNIMPLEMENTED)"); - return UnimplementedFunction(ErrorModule::Kernel); - } - - /** * Wait for kernel object to synchronize. * @return True if the current thread should wait as a result of the wait */ @@ -93,6 +85,10 @@ public: template <class T> T* Get(Handle handle) { + if (handle == CurrentThread) { + return reinterpret_cast<T*>(GetCurrentThread()); + } + if (handle < HANDLE_OFFSET || handle >= HANDLE_OFFSET + MAX_COUNT || !occupied[handle - HANDLE_OFFSET]) { if (handle != 0) { LOG_ERROR(Kernel, "Bad object handle %08x", handle); @@ -111,6 +107,10 @@ public: // ONLY use this when you know the handle is valid. template <class T> T *GetFast(Handle handle) { + if (handle == CurrentThread) { + return reinterpret_cast<T*>(GetCurrentThread()); + } + const Handle realHandle = handle - HANDLE_OFFSET; _dbg_assert_(Kernel, realHandle >= 0 && realHandle < MAX_COUNT && occupied[realHandle]); return static_cast<T*>(pool[realHandle]); @@ -163,6 +163,12 @@ private: extern ObjectPool g_object_pool; extern Handle g_main_thread; +/// The ID code of the currently running game +/// TODO(Subv): This variable should not be here, +/// we need a way to store information about the currently loaded application +/// for later query during runtime, maybe using the LDR service? +extern u64 g_program_id; + /// Initialize the kernel void Init(); |