diff options
Diffstat (limited to 'src/core/hle/kernel/kernel.h')
| -rw-r--r-- | src/core/hle/kernel/kernel.h | 37 |
1 files changed, 24 insertions, 13 deletions
diff --git a/src/core/hle/kernel/kernel.h b/src/core/hle/kernel/kernel.h index 2381ca7f7..0eb58210c 100644 --- a/src/core/hle/kernel/kernel.h +++ b/src/core/hle/kernel/kernel.h | |||
| @@ -8,6 +8,15 @@ | |||
| 8 | 8 | ||
| 9 | typedef u32 UID; | 9 | typedef u32 UID; |
| 10 | 10 | ||
| 11 | enum KernelIDType { | ||
| 12 | KERNEL_ID_TYPE_THREAD = 1, | ||
| 13 | KERNEL_ID_TYPE_SEMAPHORE = 2, | ||
| 14 | KERNEL_ID_TYPE_MUTEX = 3, | ||
| 15 | KERNEL_ID_TYPE_EVENT = 4, | ||
| 16 | }; | ||
| 17 | |||
| 18 | #define KERNELOBJECT_MAX_NAME_LENGTH 31 | ||
| 19 | |||
| 11 | class KernelObjectPool; | 20 | class KernelObjectPool; |
| 12 | 21 | ||
| 13 | class KernelObject { | 22 | class KernelObject { |
| @@ -18,7 +27,7 @@ public: | |||
| 18 | UID GetUID() const { return uid; } | 27 | UID GetUID() const { return uid; } |
| 19 | virtual const char *GetTypeName() { return "[BAD KERNEL OBJECT TYPE]"; } | 28 | virtual const char *GetTypeName() { return "[BAD KERNEL OBJECT TYPE]"; } |
| 20 | virtual const char *GetName() { return "[UNKNOWN KERNEL OBJECT]"; } | 29 | virtual const char *GetName() { return "[UNKNOWN KERNEL OBJECT]"; } |
| 21 | virtual int GetIDType() const = 0; | 30 | virtual KernelIDType GetIDType() const = 0; |
| 22 | //virtual void GetQuickInfo(char *ptr, int size); | 31 | //virtual void GetQuickInfo(char *ptr, int size); |
| 23 | }; | 32 | }; |
| 24 | 33 | ||
| @@ -36,8 +45,8 @@ public: | |||
| 36 | u32 Destroy(UID handle) { | 45 | u32 Destroy(UID handle) { |
| 37 | u32 error; | 46 | u32 error; |
| 38 | if (Get<T>(handle, error)) { | 47 | if (Get<T>(handle, error)) { |
| 39 | occupied[handle - handleOffset] = false; | 48 | occupied[handle - HANDLE_OFFSET] = false; |
| 40 | delete pool[handle - handleOffset]; | 49 | delete pool[handle - HANDLE_OFFSET]; |
| 41 | } | 50 | } |
| 42 | return error; | 51 | return error; |
| 43 | }; | 52 | }; |
| @@ -46,24 +55,24 @@ public: | |||
| 46 | 55 | ||
| 47 | template <class T> | 56 | template <class T> |
| 48 | T* Get(UID handle, u32& outError) { | 57 | T* Get(UID handle, u32& outError) { |
| 49 | if (handle < handleOffset || handle >= handleOffset + maxCount || !occupied[handle - handleOffset]) { | 58 | if (handle < HANDLE_OFFSET || handle >= HANDLE_OFFSET + MAX_COUNT || !occupied[handle - HANDLE_OFFSET]) { |
| 50 | // Tekken 6 spams 0x80020001 gets wrong with no ill effects, also on the real PSP | 59 | // Tekken 6 spams 0x80020001 gets wrong with no ill effects, also on the real PSP |
| 51 | if (handle != 0 && (u32)handle != 0x80020001) { | 60 | if (handle != 0 && (u32)handle != 0x80020001) { |
| 52 | WARN_LOG(SCEKERNEL, "Kernel: Bad object handle %i (%08x)", handle, handle); | 61 | WARN_LOG(KERNEL, "Kernel: Bad object handle %i (%08x)", handle, handle); |
| 53 | } | 62 | } |
| 54 | outError = T::GetMissingErrorCode(); | 63 | outError = 0;//T::GetMissingErrorCode(); |
| 55 | return 0; | 64 | return 0; |
| 56 | } else { | 65 | } else { |
| 57 | // Previously we had a dynamic_cast here, but since RTTI was disabled traditionally, | 66 | // Previously we had a dynamic_cast here, but since RTTI was disabled traditionally, |
| 58 | // it just acted as a static case and everything worked. This means that we will never | 67 | // it just acted as a static case and everything worked. This means that we will never |
| 59 | // see the Wrong type object error below, but we'll just have to live with that danger. | 68 | // see the Wrong type object error below, but we'll just have to live with that danger. |
| 60 | T* t = static_cast<T*>(pool[handle - handleOffset]); | 69 | T* t = static_cast<T*>(pool[handle - HANDLE_OFFSET]); |
| 61 | if (t == 0 || t->GetIDType() != T::GetStaticIDType()) { | 70 | if (t == 0 || t->GetIDType() != T::GetStaticIDType()) { |
| 62 | WARN_LOG(SCEKERNEL, "Kernel: Wrong object type for %i (%08x)", handle, handle); | 71 | WARN_LOG(KERNEL, "Kernel: Wrong object type for %i (%08x)", handle, handle); |
| 63 | outError = T::GetMissingErrorCode(); | 72 | outError = 0;//T::GetMissingErrorCode(); |
| 64 | return 0; | 73 | return 0; |
| 65 | } | 74 | } |
| 66 | outError = SCE_KERNEL_ERROR_OK; | 75 | outError = 0;//SCE_KERNEL_ERROR_OK; |
| 67 | return t; | 76 | return t; |
| 68 | } | 77 | } |
| 69 | } | 78 | } |
| @@ -71,15 +80,15 @@ public: | |||
| 71 | // ONLY use this when you know the handle is valid. | 80 | // ONLY use this when you know the handle is valid. |
| 72 | template <class T> | 81 | template <class T> |
| 73 | T *GetFast(UID handle) { | 82 | T *GetFast(UID handle) { |
| 74 | const UID realHandle = handle - handleOffset; | 83 | const UID realHandle = handle - HANDLE_OFFSET; |
| 75 | _dbg_assert_(SCEKERNEL, realHandle >= 0 && realHandle < maxCount && occupied[realHandle]); | 84 | _dbg_assert_(KERNEL, realHandle >= 0 && realHandle < MAX_COUNT && occupied[realHandle]); |
| 76 | return static_cast<T *>(pool[realHandle]); | 85 | return static_cast<T *>(pool[realHandle]); |
| 77 | } | 86 | } |
| 78 | 87 | ||
| 79 | template <class T, typename ArgT> | 88 | template <class T, typename ArgT> |
| 80 | void Iterate(bool func(T *, ArgT), ArgT arg) { | 89 | void Iterate(bool func(T *, ArgT), ArgT arg) { |
| 81 | int type = T::GetStaticIDType(); | 90 | int type = T::GetStaticIDType(); |
| 82 | for (int i = 0; i < maxCount; i++) | 91 | for (int i = 0; i < MAX_COUNT; i++) |
| 83 | { | 92 | { |
| 84 | if (!occupied[i]) | 93 | if (!occupied[i]) |
| 85 | continue; | 94 | continue; |
| @@ -119,3 +128,5 @@ private: | |||
| 119 | }; | 128 | }; |
| 120 | 129 | ||
| 121 | extern KernelObjectPool g_kernel_objects; | 130 | extern KernelObjectPool g_kernel_objects; |
| 131 | |||
| 132 | bool __KernelLoadExec(u32 entry_point); | ||