diff options
| author | 2014-05-20 18:13:25 -0400 | |
|---|---|---|
| committer | 2014-05-20 18:13:25 -0400 | |
| commit | 44336329eddd7dbe1f76144e9a1e95e5f76ed372 (patch) | |
| tree | 49c103d52af50fe6ef451324f1c8aae6363d0468 /src/core/hle/kernel/kernel.cpp | |
| parent | apt: changed stubbed handle to be something other than 0xDEADBEEF (used as a ... (diff) | |
| download | yuzu-44336329eddd7dbe1f76144e9a1e95e5f76ed372.tar.gz yuzu-44336329eddd7dbe1f76144e9a1e95e5f76ed372.tar.xz yuzu-44336329eddd7dbe1f76144e9a1e95e5f76ed372.zip | |
- created a Kernel namespace
- cleaned up Kernel code a bit (moved stuff into namespace, fixed whitespace issues)
- added handle types for all different CTROS handles
Diffstat (limited to 'src/core/hle/kernel/kernel.cpp')
| -rw-r--r-- | src/core/hle/kernel/kernel.cpp | 49 |
1 files changed, 24 insertions, 25 deletions
diff --git a/src/core/hle/kernel/kernel.cpp b/src/core/hle/kernel/kernel.cpp index f7145ddd8..b1fdffde5 100644 --- a/src/core/hle/kernel/kernel.cpp +++ b/src/core/hle/kernel/kernel.cpp | |||
| @@ -12,22 +12,16 @@ | |||
| 12 | #include "core/hle/kernel/kernel.h" | 12 | #include "core/hle/kernel/kernel.h" |
| 13 | #include "core/hle/kernel/thread.h" | 13 | #include "core/hle/kernel/thread.h" |
| 14 | 14 | ||
| 15 | KernelObjectPool g_kernel_objects; | 15 | namespace Kernel { |
| 16 | 16 | ||
| 17 | void __KernelInit() { | 17 | ObjectPool g_object_pool; |
| 18 | __KernelThreadingInit(); | ||
| 19 | } | ||
| 20 | |||
| 21 | void __KernelShutdown() { | ||
| 22 | __KernelThreadingShutdown(); | ||
| 23 | } | ||
| 24 | 18 | ||
| 25 | KernelObjectPool::KernelObjectPool() { | 19 | ObjectPool::ObjectPool() { |
| 26 | memset(occupied, 0, sizeof(bool) * MAX_COUNT); | 20 | memset(occupied, 0, sizeof(bool) * MAX_COUNT); |
| 27 | next_id = INITIAL_NEXT_ID; | 21 | next_id = INITIAL_NEXT_ID; |
| 28 | } | 22 | } |
| 29 | 23 | ||
| 30 | Handle KernelObjectPool::Create(KernelObject *obj, int range_bottom, int range_top) { | 24 | Handle ObjectPool::Create(Object* obj, int range_bottom, int range_top) { |
| 31 | if (range_top > MAX_COUNT) { | 25 | if (range_top > MAX_COUNT) { |
| 32 | range_top = MAX_COUNT; | 26 | range_top = MAX_COUNT; |
| 33 | } | 27 | } |
| @@ -46,8 +40,7 @@ Handle KernelObjectPool::Create(KernelObject *obj, int range_bottom, int range_t | |||
| 46 | return 0; | 40 | return 0; |
| 47 | } | 41 | } |
| 48 | 42 | ||
| 49 | bool KernelObjectPool::IsValid(Handle handle) | 43 | bool ObjectPool::IsValid(Handle handle) { |
| 50 | { | ||
| 51 | int index = handle - HANDLE_OFFSET; | 44 | int index = handle - HANDLE_OFFSET; |
| 52 | if (index < 0) | 45 | if (index < 0) |
| 53 | return false; | 46 | return false; |
| @@ -57,26 +50,24 @@ bool KernelObjectPool::IsValid(Handle handle) | |||
| 57 | return occupied[index]; | 50 | return occupied[index]; |
| 58 | } | 51 | } |
| 59 | 52 | ||
| 60 | void KernelObjectPool::Clear() | 53 | void ObjectPool::Clear() { |
| 61 | { | 54 | for (int i = 0; i < MAX_COUNT; i++) { |
| 62 | for (int i = 0; i < MAX_COUNT; i++) | ||
| 63 | { | ||
| 64 | //brutally clear everything, no validation | 55 | //brutally clear everything, no validation |
| 65 | if (occupied[i]) | 56 | if (occupied[i]) |
| 66 | delete pool[i]; | 57 | delete pool[i]; |
| 67 | occupied[i] = false; | 58 | occupied[i] = false; |
| 68 | } | 59 | } |
| 69 | memset(pool, 0, sizeof(KernelObject*)*MAX_COUNT); | 60 | memset(pool, 0, sizeof(Object*)*MAX_COUNT); |
| 70 | next_id = INITIAL_NEXT_ID; | 61 | next_id = INITIAL_NEXT_ID; |
| 71 | } | 62 | } |
| 72 | 63 | ||
| 73 | KernelObject *&KernelObjectPool::operator [](Handle handle) | 64 | Object* &ObjectPool::operator [](Handle handle) |
| 74 | { | 65 | { |
| 75 | _dbg_assert_msg_(KERNEL, IsValid(handle), "GRABBING UNALLOCED KERNEL OBJ"); | 66 | _dbg_assert_msg_(KERNEL, IsValid(handle), "GRABBING UNALLOCED KERNEL OBJ"); |
| 76 | return pool[handle - HANDLE_OFFSET]; | 67 | return pool[handle - HANDLE_OFFSET]; |
| 77 | } | 68 | } |
| 78 | 69 | ||
| 79 | void KernelObjectPool::List() { | 70 | void ObjectPool::List() { |
| 80 | for (int i = 0; i < MAX_COUNT; i++) { | 71 | for (int i = 0; i < MAX_COUNT; i++) { |
| 81 | if (occupied[i]) { | 72 | if (occupied[i]) { |
| 82 | if (pool[i]) { | 73 | if (pool[i]) { |
| @@ -87,18 +78,16 @@ void KernelObjectPool::List() { | |||
| 87 | } | 78 | } |
| 88 | } | 79 | } |
| 89 | 80 | ||
| 90 | int KernelObjectPool::GetCount() | 81 | int ObjectPool::GetCount() { |
| 91 | { | ||
| 92 | int count = 0; | 82 | int count = 0; |
| 93 | for (int i = 0; i < MAX_COUNT; i++) | 83 | for (int i = 0; i < MAX_COUNT; i++) { |
| 94 | { | ||
| 95 | if (occupied[i]) | 84 | if (occupied[i]) |
| 96 | count++; | 85 | count++; |
| 97 | } | 86 | } |
| 98 | return count; | 87 | return count; |
| 99 | } | 88 | } |
| 100 | 89 | ||
| 101 | KernelObject *KernelObjectPool::CreateByIDType(int type) { | 90 | Object* ObjectPool::CreateByIDType(int type) { |
| 102 | // Used for save states. This is ugly, but what other way is there? | 91 | // Used for save states. This is ugly, but what other way is there? |
| 103 | switch (type) { | 92 | switch (type) { |
| 104 | //case SCE_KERNEL_TMID_Alarm: | 93 | //case SCE_KERNEL_TMID_Alarm: |
| @@ -142,8 +131,18 @@ KernelObject *KernelObjectPool::CreateByIDType(int type) { | |||
| 142 | } | 131 | } |
| 143 | } | 132 | } |
| 144 | 133 | ||
| 134 | void Init() { | ||
| 135 | __KernelThreadingInit(); | ||
| 136 | } | ||
| 137 | |||
| 138 | void Shutdown() { | ||
| 139 | __KernelThreadingShutdown(); | ||
| 140 | } | ||
| 141 | |||
| 142 | } // namespace | ||
| 143 | |||
| 145 | bool __KernelLoadExec(u32 entry_point) { | 144 | bool __KernelLoadExec(u32 entry_point) { |
| 146 | __KernelInit(); | 145 | Kernel::Init(); |
| 147 | 146 | ||
| 148 | Core::g_app_core->SetPC(entry_point); | 147 | Core::g_app_core->SetPC(entry_point); |
| 149 | 148 | ||