diff options
| author | 2014-05-15 18:26:28 -0400 | |
|---|---|---|
| committer | 2014-05-15 18:26:28 -0400 | |
| commit | a7cc430aa4da2962dcf08db2f6009fc272bdda70 (patch) | |
| tree | ba494a655541d038a5ac0d9e078ebef031461598 /src/core/hle/kernel/kernel.h | |
| parent | - added ThreadContext struct (diff) | |
| download | yuzu-a7cc430aa4da2962dcf08db2f6009fc272bdda70.tar.gz yuzu-a7cc430aa4da2962dcf08db2f6009fc272bdda70.tar.xz yuzu-a7cc430aa4da2962dcf08db2f6009fc272bdda70.zip | |
changed "UID" to "Handle" to be a little more consistent with CTR naming
Diffstat (limited to 'src/core/hle/kernel/kernel.h')
| -rw-r--r-- | src/core/hle/kernel/kernel.h | 29 |
1 files changed, 16 insertions, 13 deletions
diff --git a/src/core/hle/kernel/kernel.h b/src/core/hle/kernel/kernel.h index 0eb58210c..24d422682 100644 --- a/src/core/hle/kernel/kernel.h +++ b/src/core/hle/kernel/kernel.h | |||
| @@ -6,7 +6,7 @@ | |||
| 6 | 6 | ||
| 7 | #include "common/common_types.h" | 7 | #include "common/common_types.h" |
| 8 | 8 | ||
| 9 | typedef u32 UID; | 9 | typedef s32 Handle; |
| 10 | 10 | ||
| 11 | enum KernelIDType { | 11 | enum KernelIDType { |
| 12 | KERNEL_ID_TYPE_THREAD = 1, | 12 | KERNEL_ID_TYPE_THREAD = 1, |
| @@ -15,20 +15,23 @@ enum KernelIDType { | |||
| 15 | KERNEL_ID_TYPE_EVENT = 4, | 15 | KERNEL_ID_TYPE_EVENT = 4, |
| 16 | }; | 16 | }; |
| 17 | 17 | ||
| 18 | enum { | ||
| 19 | KERNELOBJECT_MAX_NAME_LENGTH = 255, | ||
| 20 | }; | ||
| 21 | |||
| 18 | #define KERNELOBJECT_MAX_NAME_LENGTH 31 | 22 | #define KERNELOBJECT_MAX_NAME_LENGTH 31 |
| 19 | 23 | ||
| 20 | class KernelObjectPool; | 24 | class KernelObjectPool; |
| 21 | 25 | ||
| 22 | class KernelObject { | 26 | class KernelObject { |
| 23 | friend class KernelObjectPool; | 27 | friend class KernelObjectPool; |
| 24 | u32 uid; | 28 | u32 handle; |
| 25 | public: | 29 | public: |
| 26 | virtual ~KernelObject() {} | 30 | virtual ~KernelObject() {} |
| 27 | UID GetUID() const { return uid; } | 31 | Handle GetHandle() const { return handle; } |
| 28 | virtual const char *GetTypeName() { return "[BAD KERNEL OBJECT TYPE]"; } | 32 | virtual const char *GetTypeName() { return "[BAD KERNEL OBJECT TYPE]"; } |
| 29 | virtual const char *GetName() { return "[UNKNOWN KERNEL OBJECT]"; } | 33 | virtual const char *GetName() { return "[UNKNOWN KERNEL OBJECT]"; } |
| 30 | virtual KernelIDType GetIDType() const = 0; | 34 | virtual KernelIDType GetIDType() const = 0; |
| 31 | //virtual void GetQuickInfo(char *ptr, int size); | ||
| 32 | }; | 35 | }; |
| 33 | 36 | ||
| 34 | class KernelObjectPool { | 37 | class KernelObjectPool { |
| @@ -36,13 +39,13 @@ public: | |||
| 36 | KernelObjectPool(); | 39 | KernelObjectPool(); |
| 37 | ~KernelObjectPool() {} | 40 | ~KernelObjectPool() {} |
| 38 | 41 | ||
| 39 | // Allocates a UID within the range and inserts the object into the map. | 42 | // Allocates a handle within the range and inserts the object into the map. |
| 40 | UID Create(KernelObject *obj, int range_bottom=INITIAL_NEXT_ID, int range_top=0x7FFFFFFF); | 43 | Handle Create(KernelObject *obj, int range_bottom=INITIAL_NEXT_ID, int range_top=0x7FFFFFFF); |
| 41 | 44 | ||
| 42 | static KernelObject *CreateByIDType(int type); | 45 | static KernelObject *CreateByIDType(int type); |
| 43 | 46 | ||
| 44 | template <class T> | 47 | template <class T> |
| 45 | u32 Destroy(UID handle) { | 48 | u32 Destroy(Handle handle) { |
| 46 | u32 error; | 49 | u32 error; |
| 47 | if (Get<T>(handle, error)) { | 50 | if (Get<T>(handle, error)) { |
| 48 | occupied[handle - HANDLE_OFFSET] = false; | 51 | occupied[handle - HANDLE_OFFSET] = false; |
| @@ -51,10 +54,10 @@ public: | |||
| 51 | return error; | 54 | return error; |
| 52 | }; | 55 | }; |
| 53 | 56 | ||
| 54 | bool IsValid(UID handle); | 57 | bool IsValid(Handle handle); |
| 55 | 58 | ||
| 56 | template <class T> | 59 | template <class T> |
| 57 | T* Get(UID handle, u32& outError) { | 60 | T* Get(Handle handle, u32& outError) { |
| 58 | if (handle < HANDLE_OFFSET || handle >= HANDLE_OFFSET + MAX_COUNT || !occupied[handle - HANDLE_OFFSET]) { | 61 | if (handle < HANDLE_OFFSET || handle >= HANDLE_OFFSET + MAX_COUNT || !occupied[handle - HANDLE_OFFSET]) { |
| 59 | // Tekken 6 spams 0x80020001 gets wrong with no ill effects, also on the real PSP | 62 | // Tekken 6 spams 0x80020001 gets wrong with no ill effects, also on the real PSP |
| 60 | if (handle != 0 && (u32)handle != 0x80020001) { | 63 | if (handle != 0 && (u32)handle != 0x80020001) { |
| @@ -79,8 +82,8 @@ public: | |||
| 79 | 82 | ||
| 80 | // ONLY use this when you know the handle is valid. | 83 | // ONLY use this when you know the handle is valid. |
| 81 | template <class T> | 84 | template <class T> |
| 82 | T *GetFast(UID handle) { | 85 | T *GetFast(Handle handle) { |
| 83 | const UID realHandle = handle - HANDLE_OFFSET; | 86 | const Handle realHandle = handle - HANDLE_OFFSET; |
| 84 | _dbg_assert_(KERNEL, realHandle >= 0 && realHandle < MAX_COUNT && occupied[realHandle]); | 87 | _dbg_assert_(KERNEL, realHandle >= 0 && realHandle < MAX_COUNT && occupied[realHandle]); |
| 85 | return static_cast<T *>(pool[realHandle]); | 88 | return static_cast<T *>(pool[realHandle]); |
| 86 | } | 89 | } |
| @@ -100,7 +103,7 @@ public: | |||
| 100 | } | 103 | } |
| 101 | } | 104 | } |
| 102 | 105 | ||
| 103 | bool GetIDType(UID handle, int *type) const { | 106 | bool GetIDType(Handle handle, int *type) const { |
| 104 | if ((handle < HANDLE_OFFSET) || (handle >= HANDLE_OFFSET + MAX_COUNT) || | 107 | if ((handle < HANDLE_OFFSET) || (handle >= HANDLE_OFFSET + MAX_COUNT) || |
| 105 | !occupied[handle - HANDLE_OFFSET]) { | 108 | !occupied[handle - HANDLE_OFFSET]) { |
| 106 | ERROR_LOG(KERNEL, "Kernel: Bad object handle %i (%08x)", handle, handle); | 109 | ERROR_LOG(KERNEL, "Kernel: Bad object handle %i (%08x)", handle, handle); |
| @@ -111,7 +114,7 @@ public: | |||
| 111 | return true; | 114 | return true; |
| 112 | } | 115 | } |
| 113 | 116 | ||
| 114 | KernelObject *&operator [](UID handle); | 117 | KernelObject *&operator [](Handle handle); |
| 115 | void List(); | 118 | void List(); |
| 116 | void Clear(); | 119 | void Clear(); |
| 117 | int GetCount(); | 120 | int GetCount(); |