Browse Source
Merge pull request #1767 from lioncash/handle
kernel/handle_table: Minor changes
pull/15/merge
bunnei
7 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with
14 additions and
12 deletions
-
src/core/hle/kernel/handle_table.cpp
-
src/core/hle/kernel/handle_table.h
|
|
@ -12,12 +12,23 @@ |
|
|
#include "core/hle/kernel/thread.h"
|
|
|
#include "core/hle/kernel/thread.h"
|
|
|
|
|
|
|
|
|
namespace Kernel { |
|
|
namespace Kernel { |
|
|
|
|
|
namespace { |
|
|
|
|
|
constexpr u16 GetSlot(Handle handle) { |
|
|
|
|
|
return handle >> 15; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
constexpr u16 GetGeneration(Handle handle) { |
|
|
|
|
|
return handle & 0x7FFF; |
|
|
|
|
|
} |
|
|
|
|
|
} // Anonymous namespace
|
|
|
|
|
|
|
|
|
HandleTable::HandleTable() { |
|
|
HandleTable::HandleTable() { |
|
|
next_generation = 1; |
|
|
next_generation = 1; |
|
|
Clear(); |
|
|
Clear(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
HandleTable::~HandleTable() = default; |
|
|
|
|
|
|
|
|
ResultVal<Handle> HandleTable::Create(SharedPtr<Object> obj) { |
|
|
ResultVal<Handle> HandleTable::Create(SharedPtr<Object> obj) { |
|
|
DEBUG_ASSERT(obj != nullptr); |
|
|
DEBUG_ASSERT(obj != nullptr); |
|
|
|
|
|
|
|
|
|
|
|
@ -43,6 +43,7 @@ enum KernelHandle : Handle { |
|
|
class HandleTable final : NonCopyable { |
|
|
class HandleTable final : NonCopyable { |
|
|
public: |
|
|
public: |
|
|
HandleTable(); |
|
|
HandleTable(); |
|
|
|
|
|
~HandleTable(); |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* Allocates a handle for the given object. |
|
|
* Allocates a handle for the given object. |
|
|
@ -89,18 +90,8 @@ public: |
|
|
void Clear(); |
|
|
void Clear(); |
|
|
|
|
|
|
|
|
private: |
|
|
private: |
|
|
/** |
|
|
|
|
|
* This is the maximum limit of handles allowed per process in CTR-OS. It can be further |
|
|
|
|
|
* reduced by ExHeader values, but this is not emulated here. |
|
|
|
|
|
*/ |
|
|
|
|
|
static const std::size_t MAX_COUNT = 4096; |
|
|
|
|
|
|
|
|
|
|
|
static u16 GetSlot(Handle handle) { |
|
|
|
|
|
return handle >> 15; |
|
|
|
|
|
} |
|
|
|
|
|
static u16 GetGeneration(Handle handle) { |
|
|
|
|
|
return handle & 0x7FFF; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
/// This is the maximum limit of handles allowed per process in Horizon |
|
|
|
|
|
static constexpr std::size_t MAX_COUNT = 1024; |
|
|
|
|
|
|
|
|
/// Stores the Object referenced by the handle or null if the slot is empty. |
|
|
/// Stores the Object referenced by the handle or null if the slot is empty. |
|
|
std::array<SharedPtr<Object>, MAX_COUNT> objects; |
|
|
std::array<SharedPtr<Object>, MAX_COUNT> objects; |
|
|
|