mirror of
https://github.com/yuzu-emu/yuzu.git
synced 2024-07-04 23:31:19 +01:00
- added __KernelLoadExec function
- fixed some logging
This commit is contained in:
parent
ce4d271a53
commit
1583d2b6f3
2 changed files with 35 additions and 13 deletions
|
@ -8,6 +8,7 @@
|
||||||
|
|
||||||
#include "common/common.h"
|
#include "common/common.h"
|
||||||
|
|
||||||
|
#include "core/core.h"
|
||||||
#include "core/hle/kernel/kernel.h"
|
#include "core/hle/kernel/kernel.h"
|
||||||
#include "core/hle/kernel/thread.h"
|
#include "core/hle/kernel/thread.h"
|
||||||
|
|
||||||
|
@ -140,3 +141,13 @@ KernelObject *KernelObjectPool::CreateByIDType(int type) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool __KernelLoadExec(u32 entry_point) {
|
||||||
|
__KernelInit();
|
||||||
|
|
||||||
|
Core::g_app_core->SetPC(entry_point);
|
||||||
|
|
||||||
|
UID thread_id = __KernelSetupRootThread(0xDEADBEEF, 0, 0x31);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
|
@ -8,6 +8,15 @@
|
||||||
|
|
||||||
typedef u32 UID;
|
typedef u32 UID;
|
||||||
|
|
||||||
|
enum KernelIDType {
|
||||||
|
KERNEL_ID_TYPE_THREAD = 1,
|
||||||
|
KERNEL_ID_TYPE_SEMAPHORE = 2,
|
||||||
|
KERNEL_ID_TYPE_MUTEX = 3,
|
||||||
|
KERNEL_ID_TYPE_EVENT = 4,
|
||||||
|
};
|
||||||
|
|
||||||
|
#define KERNELOBJECT_MAX_NAME_LENGTH 31
|
||||||
|
|
||||||
class KernelObjectPool;
|
class KernelObjectPool;
|
||||||
|
|
||||||
class KernelObject {
|
class KernelObject {
|
||||||
|
@ -18,7 +27,7 @@ public:
|
||||||
UID GetUID() const { return uid; }
|
UID GetUID() const { return uid; }
|
||||||
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 int GetIDType() const = 0;
|
virtual KernelIDType GetIDType() const = 0;
|
||||||
//virtual void GetQuickInfo(char *ptr, int size);
|
//virtual void GetQuickInfo(char *ptr, int size);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -36,8 +45,8 @@ public:
|
||||||
u32 Destroy(UID handle) {
|
u32 Destroy(UID handle) {
|
||||||
u32 error;
|
u32 error;
|
||||||
if (Get<T>(handle, error)) {
|
if (Get<T>(handle, error)) {
|
||||||
occupied[handle - handleOffset] = false;
|
occupied[handle - HANDLE_OFFSET] = false;
|
||||||
delete pool[handle - handleOffset];
|
delete pool[handle - HANDLE_OFFSET];
|
||||||
}
|
}
|
||||||
return error;
|
return error;
|
||||||
};
|
};
|
||||||
|
@ -46,24 +55,24 @@ public:
|
||||||
|
|
||||||
template <class T>
|
template <class T>
|
||||||
T* Get(UID handle, u32& outError) {
|
T* Get(UID handle, u32& outError) {
|
||||||
if (handle < handleOffset || handle >= handleOffset + maxCount || !occupied[handle - handleOffset]) {
|
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) {
|
||||||
WARN_LOG(SCEKERNEL, "Kernel: Bad object handle %i (%08x)", handle, handle);
|
WARN_LOG(KERNEL, "Kernel: Bad object handle %i (%08x)", handle, handle);
|
||||||
}
|
}
|
||||||
outError = T::GetMissingErrorCode();
|
outError = 0;//T::GetMissingErrorCode();
|
||||||
return 0;
|
return 0;
|
||||||
} else {
|
} else {
|
||||||
// Previously we had a dynamic_cast here, but since RTTI was disabled traditionally,
|
// Previously we had a dynamic_cast here, but since RTTI was disabled traditionally,
|
||||||
// it just acted as a static case and everything worked. This means that we will never
|
// it just acted as a static case and everything worked. This means that we will never
|
||||||
// see the Wrong type object error below, but we'll just have to live with that danger.
|
// see the Wrong type object error below, but we'll just have to live with that danger.
|
||||||
T* t = static_cast<T*>(pool[handle - handleOffset]);
|
T* t = static_cast<T*>(pool[handle - HANDLE_OFFSET]);
|
||||||
if (t == 0 || t->GetIDType() != T::GetStaticIDType()) {
|
if (t == 0 || t->GetIDType() != T::GetStaticIDType()) {
|
||||||
WARN_LOG(SCEKERNEL, "Kernel: Wrong object type for %i (%08x)", handle, handle);
|
WARN_LOG(KERNEL, "Kernel: Wrong object type for %i (%08x)", handle, handle);
|
||||||
outError = T::GetMissingErrorCode();
|
outError = 0;//T::GetMissingErrorCode();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
outError = SCE_KERNEL_ERROR_OK;
|
outError = 0;//SCE_KERNEL_ERROR_OK;
|
||||||
return t;
|
return t;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -71,15 +80,15 @@ 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(UID handle) {
|
||||||
const UID realHandle = handle - handleOffset;
|
const UID realHandle = handle - HANDLE_OFFSET;
|
||||||
_dbg_assert_(SCEKERNEL, realHandle >= 0 && realHandle < maxCount && occupied[realHandle]);
|
_dbg_assert_(KERNEL, realHandle >= 0 && realHandle < MAX_COUNT && occupied[realHandle]);
|
||||||
return static_cast<T *>(pool[realHandle]);
|
return static_cast<T *>(pool[realHandle]);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class T, typename ArgT>
|
template <class T, typename ArgT>
|
||||||
void Iterate(bool func(T *, ArgT), ArgT arg) {
|
void Iterate(bool func(T *, ArgT), ArgT arg) {
|
||||||
int type = T::GetStaticIDType();
|
int type = T::GetStaticIDType();
|
||||||
for (int i = 0; i < maxCount; i++)
|
for (int i = 0; i < MAX_COUNT; i++)
|
||||||
{
|
{
|
||||||
if (!occupied[i])
|
if (!occupied[i])
|
||||||
continue;
|
continue;
|
||||||
|
@ -119,3 +128,5 @@ private:
|
||||||
};
|
};
|
||||||
|
|
||||||
extern KernelObjectPool g_kernel_objects;
|
extern KernelObjectPool g_kernel_objects;
|
||||||
|
|
||||||
|
bool __KernelLoadExec(u32 entry_point);
|
||||||
|
|
Loading…
Reference in a new issue