1
0
Fork 0

changed "UID" to "Handle" to be a little more consistent with CTR naming

This commit is contained in:
bunnei 2014-05-15 18:26:28 -04:00
parent 367d63691f
commit a7cc430aa4
2 changed files with 21 additions and 18 deletions

View File

@ -27,7 +27,7 @@ KernelObjectPool::KernelObjectPool() {
next_id = INITIAL_NEXT_ID; next_id = INITIAL_NEXT_ID;
} }
UID KernelObjectPool::Create(KernelObject *obj, int range_bottom, int range_top) { Handle KernelObjectPool::Create(KernelObject *obj, int range_bottom, int range_top) {
if (range_top > MAX_COUNT) { if (range_top > MAX_COUNT) {
range_top = MAX_COUNT; range_top = MAX_COUNT;
} }
@ -38,7 +38,7 @@ UID KernelObjectPool::Create(KernelObject *obj, int range_bottom, int range_top)
if (!occupied[i]) { if (!occupied[i]) {
occupied[i] = true; occupied[i] = true;
pool[i] = obj; pool[i] = obj;
pool[i]->uid = i + HANDLE_OFFSET; pool[i]->handle = i + HANDLE_OFFSET;
return i + HANDLE_OFFSET; return i + HANDLE_OFFSET;
} }
} }
@ -46,7 +46,7 @@ UID KernelObjectPool::Create(KernelObject *obj, int range_bottom, int range_top)
return 0; return 0;
} }
bool KernelObjectPool::IsValid(UID handle) bool KernelObjectPool::IsValid(Handle handle)
{ {
int index = handle - HANDLE_OFFSET; int index = handle - HANDLE_OFFSET;
if (index < 0) if (index < 0)
@ -70,7 +70,7 @@ void KernelObjectPool::Clear()
next_id = INITIAL_NEXT_ID; next_id = INITIAL_NEXT_ID;
} }
KernelObject *&KernelObjectPool::operator [](UID handle) KernelObject *&KernelObjectPool::operator [](Handle handle)
{ {
_dbg_assert_msg_(KERNEL, IsValid(handle), "GRABBING UNALLOCED KERNEL OBJ"); _dbg_assert_msg_(KERNEL, IsValid(handle), "GRABBING UNALLOCED KERNEL OBJ");
return pool[handle - HANDLE_OFFSET]; return pool[handle - HANDLE_OFFSET];
@ -148,7 +148,7 @@ bool __KernelLoadExec(u32 entry_point) {
Core::g_app_core->SetPC(entry_point); Core::g_app_core->SetPC(entry_point);
// 0x30 is the typical main thread priority I've seen used so far // 0x30 is the typical main thread priority I've seen used so far
UID thread_id = __KernelSetupRootThread(0xDEADBEEF, 0, 0x30); Handle thread_id = __KernelSetupMainThread(0x30);
return true; return true;
} }

View File

@ -6,7 +6,7 @@
#include "common/common_types.h" #include "common/common_types.h"
typedef u32 UID; typedef s32 Handle;
enum KernelIDType { enum KernelIDType {
KERNEL_ID_TYPE_THREAD = 1, KERNEL_ID_TYPE_THREAD = 1,
@ -15,20 +15,23 @@ enum KernelIDType {
KERNEL_ID_TYPE_EVENT = 4, KERNEL_ID_TYPE_EVENT = 4,
}; };
enum {
KERNELOBJECT_MAX_NAME_LENGTH = 255,
};
#define KERNELOBJECT_MAX_NAME_LENGTH 31 #define KERNELOBJECT_MAX_NAME_LENGTH 31
class KernelObjectPool; class KernelObjectPool;
class KernelObject { class KernelObject {
friend class KernelObjectPool; friend class KernelObjectPool;
u32 uid; u32 handle;
public: public:
virtual ~KernelObject() {} virtual ~KernelObject() {}
UID GetUID() const { return uid; } Handle GetHandle() const { return handle; }
virtual const char *GetTypeName() { return "[BAD KERNEL OBJECT TYPE]"; } virtual const char *GetTypeName() { return "[BAD KERNEL OBJECT TYPE]"; }
virtual const char *GetName() { return "[UNKNOWN KERNEL OBJECT]"; } virtual const char *GetName() { return "[UNKNOWN KERNEL OBJECT]"; }
virtual KernelIDType GetIDType() const = 0; virtual KernelIDType GetIDType() const = 0;
//virtual void GetQuickInfo(char *ptr, int size);
}; };
class KernelObjectPool { class KernelObjectPool {
@ -36,13 +39,13 @@ public:
KernelObjectPool(); KernelObjectPool();
~KernelObjectPool() {} ~KernelObjectPool() {}
// Allocates a UID within the range and inserts the object into the map. // Allocates a handle within the range and inserts the object into the map.
UID Create(KernelObject *obj, int range_bottom=INITIAL_NEXT_ID, int range_top=0x7FFFFFFF); Handle Create(KernelObject *obj, int range_bottom=INITIAL_NEXT_ID, int range_top=0x7FFFFFFF);
static KernelObject *CreateByIDType(int type); static KernelObject *CreateByIDType(int type);
template <class T> template <class T>
u32 Destroy(UID handle) { u32 Destroy(Handle handle) {
u32 error; u32 error;
if (Get<T>(handle, error)) { if (Get<T>(handle, error)) {
occupied[handle - HANDLE_OFFSET] = false; occupied[handle - HANDLE_OFFSET] = false;
@ -51,10 +54,10 @@ public:
return error; return error;
}; };
bool IsValid(UID handle); bool IsValid(Handle handle);
template <class T> template <class T>
T* Get(UID handle, u32& outError) { T* Get(Handle handle, u32& outError) {
if (handle < HANDLE_OFFSET || handle >= HANDLE_OFFSET + MAX_COUNT || !occupied[handle - HANDLE_OFFSET]) { if (handle < HANDLE_OFFSET || handle >= HANDLE_OFFSET + MAX_COUNT || !occupied[handle - HANDLE_OFFSET]) {
// Tekken 6 spams 0x80020001 gets wrong with no ill effects, also on the real PSP // Tekken 6 spams 0x80020001 gets wrong with no ill effects, also on the real PSP
if (handle != 0 && (u32)handle != 0x80020001) { if (handle != 0 && (u32)handle != 0x80020001) {
@ -79,8 +82,8 @@ public:
// ONLY use this when you know the handle is valid. // ONLY use this when you know the handle is valid.
template <class T> template <class T>
T *GetFast(UID handle) { T *GetFast(Handle handle) {
const UID realHandle = handle - HANDLE_OFFSET; const Handle realHandle = handle - HANDLE_OFFSET;
_dbg_assert_(KERNEL, realHandle >= 0 && realHandle < MAX_COUNT && occupied[realHandle]); _dbg_assert_(KERNEL, realHandle >= 0 && realHandle < MAX_COUNT && occupied[realHandle]);
return static_cast<T *>(pool[realHandle]); return static_cast<T *>(pool[realHandle]);
} }
@ -100,7 +103,7 @@ public:
} }
} }
bool GetIDType(UID handle, int *type) const { bool GetIDType(Handle handle, int *type) const {
if ((handle < HANDLE_OFFSET) || (handle >= HANDLE_OFFSET + MAX_COUNT) || if ((handle < HANDLE_OFFSET) || (handle >= HANDLE_OFFSET + MAX_COUNT) ||
!occupied[handle - HANDLE_OFFSET]) { !occupied[handle - HANDLE_OFFSET]) {
ERROR_LOG(KERNEL, "Kernel: Bad object handle %i (%08x)", handle, handle); ERROR_LOG(KERNEL, "Kernel: Bad object handle %i (%08x)", handle, handle);
@ -111,7 +114,7 @@ public:
return true; return true;
} }
KernelObject *&operator [](UID handle); KernelObject *&operator [](Handle handle);
void List(); void List();
void Clear(); void Clear();
int GetCount(); int GetCount();