mirror of
https://github.com/citra-emu/citra.git
synced 2024-11-23 03:50:10 +00:00
Rename ObjectPool to HandleTable
This commit is contained in:
parent
28e64806cd
commit
73fba22c01
@ -62,7 +62,7 @@ ResultCode ArbitrateAddress(Handle handle, ArbitrationType type, u32 address, s3
|
|||||||
/// Create an address arbiter
|
/// Create an address arbiter
|
||||||
AddressArbiter* CreateAddressArbiter(Handle& handle, const std::string& name) {
|
AddressArbiter* CreateAddressArbiter(Handle& handle, const std::string& name) {
|
||||||
AddressArbiter* address_arbiter = new AddressArbiter;
|
AddressArbiter* address_arbiter = new AddressArbiter;
|
||||||
handle = Kernel::g_object_pool.Create(address_arbiter);
|
handle = Kernel::g_handle_table.Create(address_arbiter);
|
||||||
address_arbiter->name = name;
|
address_arbiter->name = name;
|
||||||
return address_arbiter;
|
return address_arbiter;
|
||||||
}
|
}
|
||||||
|
@ -53,7 +53,7 @@ public:
|
|||||||
* @return Result of operation, 0 on success, otherwise error code
|
* @return Result of operation, 0 on success, otherwise error code
|
||||||
*/
|
*/
|
||||||
ResultCode SetPermanentLock(Handle handle, const bool permanent_locked) {
|
ResultCode SetPermanentLock(Handle handle, const bool permanent_locked) {
|
||||||
Event* evt = g_object_pool.Get<Event>(handle);
|
Event* evt = g_handle_table.Get<Event>(handle);
|
||||||
if (evt == nullptr) return InvalidHandle(ErrorModule::Kernel);
|
if (evt == nullptr) return InvalidHandle(ErrorModule::Kernel);
|
||||||
|
|
||||||
evt->permanent_locked = permanent_locked;
|
evt->permanent_locked = permanent_locked;
|
||||||
@ -67,7 +67,7 @@ ResultCode SetPermanentLock(Handle handle, const bool permanent_locked) {
|
|||||||
* @return Result of operation, 0 on success, otherwise error code
|
* @return Result of operation, 0 on success, otherwise error code
|
||||||
*/
|
*/
|
||||||
ResultCode SetEventLocked(const Handle handle, const bool locked) {
|
ResultCode SetEventLocked(const Handle handle, const bool locked) {
|
||||||
Event* evt = g_object_pool.Get<Event>(handle);
|
Event* evt = g_handle_table.Get<Event>(handle);
|
||||||
if (evt == nullptr) return InvalidHandle(ErrorModule::Kernel);
|
if (evt == nullptr) return InvalidHandle(ErrorModule::Kernel);
|
||||||
|
|
||||||
if (!evt->permanent_locked) {
|
if (!evt->permanent_locked) {
|
||||||
@ -82,7 +82,7 @@ ResultCode SetEventLocked(const Handle handle, const bool locked) {
|
|||||||
* @return Result of operation, 0 on success, otherwise error code
|
* @return Result of operation, 0 on success, otherwise error code
|
||||||
*/
|
*/
|
||||||
ResultCode SignalEvent(const Handle handle) {
|
ResultCode SignalEvent(const Handle handle) {
|
||||||
Event* evt = g_object_pool.Get<Event>(handle);
|
Event* evt = g_handle_table.Get<Event>(handle);
|
||||||
if (evt == nullptr) return InvalidHandle(ErrorModule::Kernel);
|
if (evt == nullptr) return InvalidHandle(ErrorModule::Kernel);
|
||||||
|
|
||||||
// Resume threads waiting for event to signal
|
// Resume threads waiting for event to signal
|
||||||
@ -110,7 +110,7 @@ ResultCode SignalEvent(const Handle handle) {
|
|||||||
* @return Result of operation, 0 on success, otherwise error code
|
* @return Result of operation, 0 on success, otherwise error code
|
||||||
*/
|
*/
|
||||||
ResultCode ClearEvent(Handle handle) {
|
ResultCode ClearEvent(Handle handle) {
|
||||||
Event* evt = g_object_pool.Get<Event>(handle);
|
Event* evt = g_handle_table.Get<Event>(handle);
|
||||||
if (evt == nullptr) return InvalidHandle(ErrorModule::Kernel);
|
if (evt == nullptr) return InvalidHandle(ErrorModule::Kernel);
|
||||||
|
|
||||||
if (!evt->permanent_locked) {
|
if (!evt->permanent_locked) {
|
||||||
@ -129,7 +129,7 @@ ResultCode ClearEvent(Handle handle) {
|
|||||||
Event* CreateEvent(Handle& handle, const ResetType reset_type, const std::string& name) {
|
Event* CreateEvent(Handle& handle, const ResetType reset_type, const std::string& name) {
|
||||||
Event* evt = new Event;
|
Event* evt = new Event;
|
||||||
|
|
||||||
handle = Kernel::g_object_pool.Create(evt);
|
handle = Kernel::g_handle_table.Create(evt);
|
||||||
|
|
||||||
evt->locked = true;
|
evt->locked = true;
|
||||||
evt->permanent_locked = false;
|
evt->permanent_locked = false;
|
||||||
|
@ -13,14 +13,14 @@
|
|||||||
namespace Kernel {
|
namespace Kernel {
|
||||||
|
|
||||||
Handle g_main_thread = 0;
|
Handle g_main_thread = 0;
|
||||||
ObjectPool g_object_pool;
|
HandleTable g_handle_table;
|
||||||
u64 g_program_id = 0;
|
u64 g_program_id = 0;
|
||||||
|
|
||||||
ObjectPool::ObjectPool() {
|
HandleTable::HandleTable() {
|
||||||
next_id = INITIAL_NEXT_ID;
|
next_id = INITIAL_NEXT_ID;
|
||||||
}
|
}
|
||||||
|
|
||||||
Handle ObjectPool::Create(Object* obj, int range_bottom, int range_top) {
|
Handle HandleTable::Create(Object* 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;
|
||||||
}
|
}
|
||||||
@ -39,7 +39,7 @@ Handle ObjectPool::Create(Object* obj, int range_bottom, int range_top) {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ObjectPool::IsValid(Handle handle) const {
|
bool HandleTable::IsValid(Handle handle) const {
|
||||||
int index = handle - HANDLE_OFFSET;
|
int index = handle - HANDLE_OFFSET;
|
||||||
if (index < 0)
|
if (index < 0)
|
||||||
return false;
|
return false;
|
||||||
@ -49,7 +49,7 @@ bool ObjectPool::IsValid(Handle handle) const {
|
|||||||
return occupied[index];
|
return occupied[index];
|
||||||
}
|
}
|
||||||
|
|
||||||
void ObjectPool::Clear() {
|
void HandleTable::Clear() {
|
||||||
for (int i = 0; i < MAX_COUNT; i++) {
|
for (int i = 0; i < MAX_COUNT; i++) {
|
||||||
//brutally clear everything, no validation
|
//brutally clear everything, no validation
|
||||||
if (occupied[i])
|
if (occupied[i])
|
||||||
@ -60,13 +60,13 @@ void ObjectPool::Clear() {
|
|||||||
next_id = INITIAL_NEXT_ID;
|
next_id = INITIAL_NEXT_ID;
|
||||||
}
|
}
|
||||||
|
|
||||||
Object* &ObjectPool::operator [](Handle handle)
|
Object* &HandleTable::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];
|
||||||
}
|
}
|
||||||
|
|
||||||
void ObjectPool::List() {
|
void HandleTable::List() {
|
||||||
for (int i = 0; i < MAX_COUNT; i++) {
|
for (int i = 0; i < MAX_COUNT; i++) {
|
||||||
if (occupied[i]) {
|
if (occupied[i]) {
|
||||||
if (pool[i]) {
|
if (pool[i]) {
|
||||||
@ -77,11 +77,11 @@ void ObjectPool::List() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int ObjectPool::GetCount() const {
|
int HandleTable::GetCount() const {
|
||||||
return std::count(occupied.begin(), occupied.end(), true);
|
return std::count(occupied.begin(), occupied.end(), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
Object* ObjectPool::CreateByIDType(int type) {
|
Object* HandleTable::CreateByIDType(int type) {
|
||||||
LOG_ERROR(Kernel, "Unimplemented: %d.", type);
|
LOG_ERROR(Kernel, "Unimplemented: %d.", type);
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
@ -95,7 +95,7 @@ void Init() {
|
|||||||
void Shutdown() {
|
void Shutdown() {
|
||||||
Kernel::ThreadingShutdown();
|
Kernel::ThreadingShutdown();
|
||||||
|
|
||||||
g_object_pool.Clear(); // Free all kernel objects
|
g_handle_table.Clear(); // Free all kernel objects
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -41,10 +41,10 @@ enum {
|
|||||||
DEFAULT_STACK_SIZE = 0x4000,
|
DEFAULT_STACK_SIZE = 0x4000,
|
||||||
};
|
};
|
||||||
|
|
||||||
class ObjectPool;
|
class HandleTable;
|
||||||
|
|
||||||
class Object : NonCopyable {
|
class Object : NonCopyable {
|
||||||
friend class ObjectPool;
|
friend class HandleTable;
|
||||||
u32 handle;
|
u32 handle;
|
||||||
public:
|
public:
|
||||||
virtual ~Object() {}
|
virtual ~Object() {}
|
||||||
@ -63,10 +63,10 @@ public:
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
class ObjectPool : NonCopyable {
|
class HandleTable : NonCopyable {
|
||||||
public:
|
public:
|
||||||
ObjectPool();
|
HandleTable();
|
||||||
~ObjectPool() {}
|
~HandleTable() {}
|
||||||
|
|
||||||
// Allocates a handle within the range and inserts the object into the map.
|
// Allocates a handle within the range and inserts the object into the map.
|
||||||
Handle Create(Object* obj, int range_bottom=INITIAL_NEXT_ID, int range_top=0x7FFFFFFF);
|
Handle Create(Object* obj, int range_bottom=INITIAL_NEXT_ID, int range_top=0x7FFFFFFF);
|
||||||
@ -160,7 +160,7 @@ private:
|
|||||||
int next_id;
|
int next_id;
|
||||||
};
|
};
|
||||||
|
|
||||||
extern ObjectPool g_object_pool;
|
extern HandleTable g_handle_table;
|
||||||
extern Handle g_main_thread;
|
extern Handle g_main_thread;
|
||||||
|
|
||||||
/// The ID code of the currently running game
|
/// The ID code of the currently running game
|
||||||
|
@ -87,7 +87,7 @@ void ReleaseThreadMutexes(Handle thread) {
|
|||||||
|
|
||||||
// Release every mutex that the thread holds, and resume execution on the waiting threads
|
// Release every mutex that the thread holds, and resume execution on the waiting threads
|
||||||
for (MutexMap::iterator iter = locked.first; iter != locked.second; ++iter) {
|
for (MutexMap::iterator iter = locked.first; iter != locked.second; ++iter) {
|
||||||
Mutex* mutex = g_object_pool.GetFast<Mutex>(iter->second);
|
Mutex* mutex = g_handle_table.GetFast<Mutex>(iter->second);
|
||||||
ResumeWaitingThread(mutex);
|
ResumeWaitingThread(mutex);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -115,7 +115,7 @@ bool ReleaseMutex(Mutex* mutex) {
|
|||||||
* @param handle Handle to mutex to release
|
* @param handle Handle to mutex to release
|
||||||
*/
|
*/
|
||||||
ResultCode ReleaseMutex(Handle handle) {
|
ResultCode ReleaseMutex(Handle handle) {
|
||||||
Mutex* mutex = Kernel::g_object_pool.Get<Mutex>(handle);
|
Mutex* mutex = Kernel::g_handle_table.Get<Mutex>(handle);
|
||||||
if (mutex == nullptr) return InvalidHandle(ErrorModule::Kernel);
|
if (mutex == nullptr) return InvalidHandle(ErrorModule::Kernel);
|
||||||
|
|
||||||
if (!ReleaseMutex(mutex)) {
|
if (!ReleaseMutex(mutex)) {
|
||||||
@ -136,7 +136,7 @@ ResultCode ReleaseMutex(Handle handle) {
|
|||||||
*/
|
*/
|
||||||
Mutex* CreateMutex(Handle& handle, bool initial_locked, const std::string& name) {
|
Mutex* CreateMutex(Handle& handle, bool initial_locked, const std::string& name) {
|
||||||
Mutex* mutex = new Mutex;
|
Mutex* mutex = new Mutex;
|
||||||
handle = Kernel::g_object_pool.Create(mutex);
|
handle = Kernel::g_handle_table.Create(mutex);
|
||||||
|
|
||||||
mutex->locked = mutex->initial_locked = initial_locked;
|
mutex->locked = mutex->initial_locked = initial_locked;
|
||||||
mutex->name = name;
|
mutex->name = name;
|
||||||
|
@ -57,7 +57,7 @@ ResultCode CreateSemaphore(Handle* handle, s32 initial_count,
|
|||||||
ErrorSummary::WrongArgument, ErrorLevel::Permanent);
|
ErrorSummary::WrongArgument, ErrorLevel::Permanent);
|
||||||
|
|
||||||
Semaphore* semaphore = new Semaphore;
|
Semaphore* semaphore = new Semaphore;
|
||||||
*handle = g_object_pool.Create(semaphore);
|
*handle = g_handle_table.Create(semaphore);
|
||||||
|
|
||||||
// When the semaphore is created, some slots are reserved for other threads,
|
// When the semaphore is created, some slots are reserved for other threads,
|
||||||
// and the rest is reserved for the caller thread
|
// and the rest is reserved for the caller thread
|
||||||
@ -69,7 +69,7 @@ ResultCode CreateSemaphore(Handle* handle, s32 initial_count,
|
|||||||
}
|
}
|
||||||
|
|
||||||
ResultCode ReleaseSemaphore(s32* count, Handle handle, s32 release_count) {
|
ResultCode ReleaseSemaphore(s32* count, Handle handle, s32 release_count) {
|
||||||
Semaphore* semaphore = g_object_pool.Get<Semaphore>(handle);
|
Semaphore* semaphore = g_handle_table.Get<Semaphore>(handle);
|
||||||
if (semaphore == nullptr)
|
if (semaphore == nullptr)
|
||||||
return InvalidHandle(ErrorModule::Kernel);
|
return InvalidHandle(ErrorModule::Kernel);
|
||||||
|
|
||||||
|
@ -32,7 +32,7 @@ public:
|
|||||||
*/
|
*/
|
||||||
SharedMemory* CreateSharedMemory(Handle& handle, const std::string& name) {
|
SharedMemory* CreateSharedMemory(Handle& handle, const std::string& name) {
|
||||||
SharedMemory* shared_memory = new SharedMemory;
|
SharedMemory* shared_memory = new SharedMemory;
|
||||||
handle = Kernel::g_object_pool.Create(shared_memory);
|
handle = Kernel::g_handle_table.Create(shared_memory);
|
||||||
shared_memory->name = name;
|
shared_memory->name = name;
|
||||||
return shared_memory;
|
return shared_memory;
|
||||||
}
|
}
|
||||||
@ -60,7 +60,7 @@ ResultCode MapSharedMemory(u32 handle, u32 address, MemoryPermission permissions
|
|||||||
return ResultCode(ErrorDescription::InvalidAddress, ErrorModule::Kernel,
|
return ResultCode(ErrorDescription::InvalidAddress, ErrorModule::Kernel,
|
||||||
ErrorSummary::InvalidArgument, ErrorLevel::Permanent);
|
ErrorSummary::InvalidArgument, ErrorLevel::Permanent);
|
||||||
}
|
}
|
||||||
SharedMemory* shared_memory = Kernel::g_object_pool.Get<SharedMemory>(handle);
|
SharedMemory* shared_memory = Kernel::g_handle_table.Get<SharedMemory>(handle);
|
||||||
if (shared_memory == nullptr) return InvalidHandle(ErrorModule::Kernel);
|
if (shared_memory == nullptr) return InvalidHandle(ErrorModule::Kernel);
|
||||||
|
|
||||||
shared_memory->base_address = address;
|
shared_memory->base_address = address;
|
||||||
@ -71,7 +71,7 @@ ResultCode MapSharedMemory(u32 handle, u32 address, MemoryPermission permissions
|
|||||||
}
|
}
|
||||||
|
|
||||||
ResultVal<u8*> GetSharedMemoryPointer(Handle handle, u32 offset) {
|
ResultVal<u8*> GetSharedMemoryPointer(Handle handle, u32 offset) {
|
||||||
SharedMemory* shared_memory = Kernel::g_object_pool.Get<SharedMemory>(handle);
|
SharedMemory* shared_memory = Kernel::g_handle_table.Get<SharedMemory>(handle);
|
||||||
if (shared_memory == nullptr) return InvalidHandle(ErrorModule::Kernel);
|
if (shared_memory == nullptr) return InvalidHandle(ErrorModule::Kernel);
|
||||||
|
|
||||||
if (0 != shared_memory->base_address)
|
if (0 != shared_memory->base_address)
|
||||||
|
@ -164,7 +164,7 @@ static bool CheckWaitType(const Thread* thread, WaitType type, Handle wait_handl
|
|||||||
|
|
||||||
/// Stops the current thread
|
/// Stops the current thread
|
||||||
ResultCode StopThread(Handle handle, const char* reason) {
|
ResultCode StopThread(Handle handle, const char* reason) {
|
||||||
Thread* thread = g_object_pool.Get<Thread>(handle);
|
Thread* thread = g_handle_table.Get<Thread>(handle);
|
||||||
if (thread == nullptr) return InvalidHandle(ErrorModule::Kernel);
|
if (thread == nullptr) return InvalidHandle(ErrorModule::Kernel);
|
||||||
|
|
||||||
// Release all the mutexes that this thread holds
|
// Release all the mutexes that this thread holds
|
||||||
@ -173,7 +173,7 @@ ResultCode StopThread(Handle handle, const char* reason) {
|
|||||||
ChangeReadyState(thread, false);
|
ChangeReadyState(thread, false);
|
||||||
thread->status = THREADSTATUS_DORMANT;
|
thread->status = THREADSTATUS_DORMANT;
|
||||||
for (Handle waiting_handle : thread->waiting_threads) {
|
for (Handle waiting_handle : thread->waiting_threads) {
|
||||||
Thread* waiting_thread = g_object_pool.Get<Thread>(waiting_handle);
|
Thread* waiting_thread = g_handle_table.Get<Thread>(waiting_handle);
|
||||||
|
|
||||||
if (CheckWaitType(waiting_thread, WAITTYPE_THREADEND, handle))
|
if (CheckWaitType(waiting_thread, WAITTYPE_THREADEND, handle))
|
||||||
ResumeThreadFromWait(waiting_handle);
|
ResumeThreadFromWait(waiting_handle);
|
||||||
@ -210,7 +210,7 @@ Handle ArbitrateHighestPriorityThread(u32 arbiter, u32 address) {
|
|||||||
|
|
||||||
// Iterate through threads, find highest priority thread that is waiting to be arbitrated...
|
// Iterate through threads, find highest priority thread that is waiting to be arbitrated...
|
||||||
for (Handle handle : thread_queue) {
|
for (Handle handle : thread_queue) {
|
||||||
Thread* thread = g_object_pool.Get<Thread>(handle);
|
Thread* thread = g_handle_table.Get<Thread>(handle);
|
||||||
|
|
||||||
if (!CheckWaitType(thread, WAITTYPE_ARB, arbiter, address))
|
if (!CheckWaitType(thread, WAITTYPE_ARB, arbiter, address))
|
||||||
continue;
|
continue;
|
||||||
@ -235,7 +235,7 @@ void ArbitrateAllThreads(u32 arbiter, u32 address) {
|
|||||||
|
|
||||||
// Iterate through threads, find highest priority thread that is waiting to be arbitrated...
|
// Iterate through threads, find highest priority thread that is waiting to be arbitrated...
|
||||||
for (Handle handle : thread_queue) {
|
for (Handle handle : thread_queue) {
|
||||||
Thread* thread = g_object_pool.Get<Thread>(handle);
|
Thread* thread = g_handle_table.Get<Thread>(handle);
|
||||||
|
|
||||||
if (CheckWaitType(thread, WAITTYPE_ARB, arbiter, address))
|
if (CheckWaitType(thread, WAITTYPE_ARB, arbiter, address))
|
||||||
ResumeThreadFromWait(handle);
|
ResumeThreadFromWait(handle);
|
||||||
@ -288,7 +288,7 @@ Thread* NextThread() {
|
|||||||
if (next == 0) {
|
if (next == 0) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
return Kernel::g_object_pool.Get<Thread>(next);
|
return Kernel::g_handle_table.Get<Thread>(next);
|
||||||
}
|
}
|
||||||
|
|
||||||
void WaitCurrentThread(WaitType wait_type, Handle wait_handle) {
|
void WaitCurrentThread(WaitType wait_type, Handle wait_handle) {
|
||||||
@ -305,7 +305,7 @@ void WaitCurrentThread(WaitType wait_type, Handle wait_handle, VAddr wait_addres
|
|||||||
|
|
||||||
/// Resumes a thread from waiting by marking it as "ready"
|
/// Resumes a thread from waiting by marking it as "ready"
|
||||||
void ResumeThreadFromWait(Handle handle) {
|
void ResumeThreadFromWait(Handle handle) {
|
||||||
Thread* thread = Kernel::g_object_pool.Get<Thread>(handle);
|
Thread* thread = Kernel::g_handle_table.Get<Thread>(handle);
|
||||||
if (thread) {
|
if (thread) {
|
||||||
thread->status &= ~THREADSTATUS_WAIT;
|
thread->status &= ~THREADSTATUS_WAIT;
|
||||||
thread->wait_handle = 0;
|
thread->wait_handle = 0;
|
||||||
@ -341,7 +341,7 @@ Thread* CreateThread(Handle& handle, const char* name, u32 entry_point, s32 prio
|
|||||||
|
|
||||||
Thread* thread = new Thread;
|
Thread* thread = new Thread;
|
||||||
|
|
||||||
handle = Kernel::g_object_pool.Create(thread);
|
handle = Kernel::g_handle_table.Create(thread);
|
||||||
|
|
||||||
thread_queue.push_back(handle);
|
thread_queue.push_back(handle);
|
||||||
thread_ready_queue.prepare(priority);
|
thread_ready_queue.prepare(priority);
|
||||||
@ -398,7 +398,7 @@ Handle CreateThread(const char* name, u32 entry_point, s32 priority, u32 arg, s3
|
|||||||
|
|
||||||
/// Get the priority of the thread specified by handle
|
/// Get the priority of the thread specified by handle
|
||||||
ResultVal<u32> GetThreadPriority(const Handle handle) {
|
ResultVal<u32> GetThreadPriority(const Handle handle) {
|
||||||
Thread* thread = g_object_pool.Get<Thread>(handle);
|
Thread* thread = g_handle_table.Get<Thread>(handle);
|
||||||
if (thread == nullptr) return InvalidHandle(ErrorModule::Kernel);
|
if (thread == nullptr) return InvalidHandle(ErrorModule::Kernel);
|
||||||
|
|
||||||
return MakeResult<u32>(thread->current_priority);
|
return MakeResult<u32>(thread->current_priority);
|
||||||
@ -410,7 +410,7 @@ ResultCode SetThreadPriority(Handle handle, s32 priority) {
|
|||||||
if (!handle) {
|
if (!handle) {
|
||||||
thread = GetCurrentThread(); // TODO(bunnei): Is this correct behavior?
|
thread = GetCurrentThread(); // TODO(bunnei): Is this correct behavior?
|
||||||
} else {
|
} else {
|
||||||
thread = g_object_pool.Get<Thread>(handle);
|
thread = g_handle_table.Get<Thread>(handle);
|
||||||
if (thread == nullptr) {
|
if (thread == nullptr) {
|
||||||
return InvalidHandle(ErrorModule::Kernel);
|
return InvalidHandle(ErrorModule::Kernel);
|
||||||
}
|
}
|
||||||
@ -481,7 +481,7 @@ void Reschedule() {
|
|||||||
LOG_TRACE(Kernel, "cannot context switch from 0x%08X, no higher priority thread!", prev->GetHandle());
|
LOG_TRACE(Kernel, "cannot context switch from 0x%08X, no higher priority thread!", prev->GetHandle());
|
||||||
|
|
||||||
for (Handle handle : thread_queue) {
|
for (Handle handle : thread_queue) {
|
||||||
Thread* thread = g_object_pool.Get<Thread>(handle);
|
Thread* thread = g_handle_table.Get<Thread>(handle);
|
||||||
LOG_TRACE(Kernel, "\thandle=0x%08X prio=0x%02X, status=0x%08X wait_type=0x%08X wait_handle=0x%08X",
|
LOG_TRACE(Kernel, "\thandle=0x%08X prio=0x%02X, status=0x%08X wait_type=0x%08X wait_handle=0x%08X",
|
||||||
thread->GetHandle(), thread->current_priority, thread->status, thread->wait_type, thread->wait_handle);
|
thread->GetHandle(), thread->current_priority, thread->status, thread->wait_type, thread->wait_handle);
|
||||||
}
|
}
|
||||||
@ -497,7 +497,7 @@ void Reschedule() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ResultCode GetThreadId(u32* thread_id, Handle handle) {
|
ResultCode GetThreadId(u32* thread_id, Handle handle) {
|
||||||
Thread* thread = g_object_pool.Get<Thread>(handle);
|
Thread* thread = g_handle_table.Get<Thread>(handle);
|
||||||
if (thread == nullptr)
|
if (thread == nullptr)
|
||||||
return ResultCode(ErrorDescription::InvalidHandle, ErrorModule::OS,
|
return ResultCode(ErrorDescription::InvalidHandle, ErrorModule::OS,
|
||||||
ErrorSummary::WrongArgument, ErrorLevel::Permanent);
|
ErrorSummary::WrongArgument, ErrorLevel::Permanent);
|
||||||
|
@ -133,7 +133,7 @@ public:
|
|||||||
case FileCommand::Close:
|
case FileCommand::Close:
|
||||||
{
|
{
|
||||||
LOG_TRACE(Service_FS, "Close %s %s", GetTypeName().c_str(), GetName().c_str());
|
LOG_TRACE(Service_FS, "Close %s %s", GetTypeName().c_str(), GetName().c_str());
|
||||||
Kernel::g_object_pool.Destroy<File>(GetHandle());
|
Kernel::g_handle_table.Destroy<File>(GetHandle());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -189,7 +189,7 @@ public:
|
|||||||
case DirectoryCommand::Close:
|
case DirectoryCommand::Close:
|
||||||
{
|
{
|
||||||
LOG_TRACE(Service_FS, "Close %s %s", GetTypeName().c_str(), GetName().c_str());
|
LOG_TRACE(Service_FS, "Close %s %s", GetTypeName().c_str(), GetName().c_str());
|
||||||
Kernel::g_object_pool.Destroy<Directory>(GetHandle());
|
Kernel::g_handle_table.Destroy<Directory>(GetHandle());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -283,7 +283,7 @@ ResultVal<Handle> OpenFileFromArchive(ArchiveHandle archive_handle, const FileSy
|
|||||||
}
|
}
|
||||||
|
|
||||||
auto file = Common::make_unique<File>(std::move(backend), path);
|
auto file = Common::make_unique<File>(std::move(backend), path);
|
||||||
Handle handle = Kernel::g_object_pool.Create(file.release());
|
Handle handle = Kernel::g_handle_table.Create(file.release());
|
||||||
return MakeResult<Handle>(handle);
|
return MakeResult<Handle>(handle);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -388,7 +388,7 @@ ResultVal<Handle> OpenDirectoryFromArchive(ArchiveHandle archive_handle, const F
|
|||||||
}
|
}
|
||||||
|
|
||||||
auto directory = Common::make_unique<Directory>(std::move(backend), path);
|
auto directory = Common::make_unique<Directory>(std::move(backend), path);
|
||||||
Handle handle = Kernel::g_object_pool.Create(directory.release());
|
Handle handle = Kernel::g_handle_table.Create(directory.release());
|
||||||
return MakeResult<Handle>(handle);
|
return MakeResult<Handle>(handle);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -56,7 +56,7 @@ Manager::~Manager() {
|
|||||||
|
|
||||||
/// Add a service to the manager (does not create it though)
|
/// Add a service to the manager (does not create it though)
|
||||||
void Manager::AddService(Interface* service) {
|
void Manager::AddService(Interface* service) {
|
||||||
m_port_map[service->GetPortName()] = Kernel::g_object_pool.Create(service);
|
m_port_map[service->GetPortName()] = Kernel::g_handle_table.Create(service);
|
||||||
m_services.push_back(service);
|
m_services.push_back(service);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -70,7 +70,7 @@ void Manager::DeleteService(const std::string& port_name) {
|
|||||||
|
|
||||||
/// Get a Service Interface from its Handle
|
/// Get a Service Interface from its Handle
|
||||||
Interface* Manager::FetchFromHandle(Handle handle) {
|
Interface* Manager::FetchFromHandle(Handle handle) {
|
||||||
return Kernel::g_object_pool.Get<Interface>(handle);
|
return Kernel::g_handle_table.Get<Interface>(handle);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Get a Service Interface from its port
|
/// Get a Service Interface from its port
|
||||||
|
@ -54,7 +54,7 @@ public:
|
|||||||
|
|
||||||
/// Allocates a new handle for the service
|
/// Allocates a new handle for the service
|
||||||
Handle CreateHandle(Kernel::Object *obj) {
|
Handle CreateHandle(Kernel::Object *obj) {
|
||||||
Handle handle = Kernel::g_object_pool.Create(obj);
|
Handle handle = Kernel::g_handle_table.Create(obj);
|
||||||
m_handles.push_back(handle);
|
m_handles.push_back(handle);
|
||||||
return handle;
|
return handle;
|
||||||
}
|
}
|
||||||
@ -62,7 +62,7 @@ public:
|
|||||||
/// Frees a handle from the service
|
/// Frees a handle from the service
|
||||||
template <class T>
|
template <class T>
|
||||||
void DeleteHandle(const Handle handle) {
|
void DeleteHandle(const Handle handle) {
|
||||||
Kernel::g_object_pool.Destroy<T>(handle);
|
Kernel::g_handle_table.Destroy<T>(handle);
|
||||||
m_handles.erase(std::remove(m_handles.begin(), m_handles.end(), handle), m_handles.end());
|
m_handles.erase(std::remove(m_handles.begin(), m_handles.end(), handle), m_handles.end());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -92,7 +92,7 @@ static Result ConnectToPort(Handle* out, const char* port_name) {
|
|||||||
|
|
||||||
/// Synchronize to an OS service
|
/// Synchronize to an OS service
|
||||||
static Result SendSyncRequest(Handle handle) {
|
static Result SendSyncRequest(Handle handle) {
|
||||||
Kernel::Session* session = Kernel::g_object_pool.Get<Kernel::Session>(handle);
|
Kernel::Session* session = Kernel::g_handle_table.Get<Kernel::Session>(handle);
|
||||||
if (session == nullptr) {
|
if (session == nullptr) {
|
||||||
return InvalidHandle(ErrorModule::Kernel).raw;
|
return InvalidHandle(ErrorModule::Kernel).raw;
|
||||||
}
|
}
|
||||||
@ -119,10 +119,10 @@ static Result WaitSynchronization1(Handle handle, s64 nano_seconds) {
|
|||||||
// TODO(bunnei): Do something with nano_seconds, currently ignoring this
|
// TODO(bunnei): Do something with nano_seconds, currently ignoring this
|
||||||
bool wait_infinite = (nano_seconds == -1); // Used to wait until a thread has terminated
|
bool wait_infinite = (nano_seconds == -1); // Used to wait until a thread has terminated
|
||||||
|
|
||||||
if (!Kernel::g_object_pool.IsValid(handle)) {
|
if (!Kernel::g_handle_table.IsValid(handle)) {
|
||||||
return InvalidHandle(ErrorModule::Kernel).raw;
|
return InvalidHandle(ErrorModule::Kernel).raw;
|
||||||
}
|
}
|
||||||
Kernel::Object* object = Kernel::g_object_pool.GetFast<Kernel::Object>(handle);
|
Kernel::Object* object = Kernel::g_handle_table.GetFast<Kernel::Object>(handle);
|
||||||
_dbg_assert_(Kernel, object != nullptr);
|
_dbg_assert_(Kernel, object != nullptr);
|
||||||
|
|
||||||
LOG_TRACE(Kernel_SVC, "called handle=0x%08X(%s:%s), nanoseconds=%lld", handle, object->GetTypeName().c_str(),
|
LOG_TRACE(Kernel_SVC, "called handle=0x%08X(%s:%s), nanoseconds=%lld", handle, object->GetTypeName().c_str(),
|
||||||
@ -150,10 +150,10 @@ static Result WaitSynchronizationN(s32* out, Handle* handles, s32 handle_count,
|
|||||||
|
|
||||||
// Iterate through each handle, synchronize kernel object
|
// Iterate through each handle, synchronize kernel object
|
||||||
for (s32 i = 0; i < handle_count; i++) {
|
for (s32 i = 0; i < handle_count; i++) {
|
||||||
if (!Kernel::g_object_pool.IsValid(handles[i])) {
|
if (!Kernel::g_handle_table.IsValid(handles[i])) {
|
||||||
return InvalidHandle(ErrorModule::Kernel).raw;
|
return InvalidHandle(ErrorModule::Kernel).raw;
|
||||||
}
|
}
|
||||||
Kernel::Object* object = Kernel::g_object_pool.GetFast<Kernel::Object>(handles[i]);
|
Kernel::Object* object = Kernel::g_handle_table.GetFast<Kernel::Object>(handles[i]);
|
||||||
|
|
||||||
LOG_TRACE(Kernel_SVC, "\thandle[%d] = 0x%08X(%s:%s)", i, handles[i], object->GetTypeName().c_str(),
|
LOG_TRACE(Kernel_SVC, "\thandle[%d] = 0x%08X(%s:%s)", i, handles[i], object->GetTypeName().c_str(),
|
||||||
object->GetName().c_str());
|
object->GetName().c_str());
|
||||||
|
Loading…
Reference in New Issue
Block a user