JKernel debug (#3012)

This commit is contained in:
Jcw87
2026-01-04 17:22:56 -08:00
committed by GitHub
parent 1400687731
commit deb7bead20
51 changed files with 1169 additions and 971 deletions
+4 -5
View File
@@ -50,14 +50,13 @@ public:
static JSUList<JKRAMCommand>& getCommandList() { return sAramCommandList; }
static u8 decideAramGroupId(int groupId) {
JKRAramHeap* heap;
u8 finalGroupId;
if (groupId < 0) {
return getAramHeap()->getCurrentGroupID();
finalGroupId = getAramHeap()->getCurrentGroupID();
} else {
finalGroupId = groupId;
}
return (u8)groupId;
return finalGroupId;
}
static u32 getSZSBufferSize() { return sSZSBufferSize; }
+3
View File
@@ -12,9 +12,12 @@ class JKRFile;
*/
class JKRAramArchive : public JKRArchive {
public:
JKRAramArchive();
JKRAramArchive(s32, JKRArchive::EMountDirection);
virtual ~JKRAramArchive();
void fixedInit(s32, JKRArchive::EMountDirection);
BOOL mountFixed(s32, JKRArchive::EMountDirection);
bool open(s32);
u32 getAramAddress_Entry(SDIFileEntry*);
u32 getAramAddress(char const*);
+1 -1
View File
@@ -34,7 +34,7 @@ public:
/* 0x18 */ u32 mSize;
/* 0x1C */ u32 mFreeSize;
/* 0x20 */ u8 mGroupId;
/* 0x21 */ u8 mIsTempMemory;
/* 0x21 */ bool mIsTempMemory;
/* 0x22 */ u8 padding[2];
};
-1
View File
@@ -17,7 +17,6 @@ public:
};
public:
// TODO: fix type
static JSUList<JKRAramBlock> sAramList;
JKRAramHeap(u32, u32);
+14 -6
View File
@@ -42,6 +42,16 @@ public:
/* 0x94 */ void* field_0x94;
};
struct JKRAramCommand {
s32 field_0x00;
void* command;
void setting(int param_1, void* param_2) {
field_0x00 = param_1;
command = param_2;
}
};
/**
* @ingroup jsystem-jkernel
*
@@ -52,12 +62,6 @@ public:
// TODO: fix type
static JSUList<JKRAMCommand> sAramPieceCommandList;
public:
struct Message {
s32 field_0x00;
JKRAMCommand* command;
};
public:
static JKRAMCommand* prepareCommand(int, u32, u32, u32, JKRAramBlock*,
JKRAMCommand::AsyncCallback);
@@ -74,6 +78,10 @@ private:
static void unlock() { OSUnlockMutex(&mMutex); }
};
inline void JKRAramPcs_SendCommand(JKRAMCommand* command) {
JKRAramPiece::sendCommand(command);
}
inline BOOL JKRAramPcs(int direction, u32 source, u32 destination, u32 length,
JKRAramBlock* block) {
return JKRAramPiece::orderSync(direction, source, destination, length, block);
+8
View File
@@ -77,8 +77,16 @@ inline JKRAramStreamCommand* JKRStreamToAram_Async(JSUFileInputStream *stream, u
return JKRAramStream::write_StreamToAram_Async(stream, addr, size, offset, returnSize);
}
inline JKRAramStreamCommand* JKRStreamToAram_Sync(JKRAramStreamCommand* command, BOOL isNonBlocking) {
return JKRAramStream::sync(command, isNonBlocking);
}
inline void JKRSetAramTransferBuffer(u8* buffer, u32 bufferSize, JKRHeap* heap) {
JKRAramStream::setTransBuffer(buffer, bufferSize, heap);
}
inline void JKRResetAramTransferBuffer() {
JKRAramStream::setTransBuffer(NULL, 0, NULL);
}
#endif /* JKRARAMSTREAM_H */
+7 -9
View File
@@ -186,7 +186,7 @@ public:
/* 0x48 */ SDIDirEntry* mNodes;
/* 0x4C */ SDIFileEntry* mFiles;
/* 0x50 */ s32* mExpandedSize;
/* 0x54 */ char* mStringTable;
/* 0x54 */ const char* mStringTable;
protected:
/* 0x58 */ u32 field_0x58;
@@ -200,29 +200,27 @@ public:
static JKRArchive* mount(s32, EMountMode, JKRHeap*, EMountDirection);
static void* getGlbResource(u32, const char*, JKRArchive*);
static JKRCompression convertAttrToCompressionType(u32 attr) {
static JKRCompression convertAttrToCompressionType(int attr) {
#define JKRARCHIVE_ATTR_COMPRESSION 0x04
#define JKRARCHIVE_ATTR_YAZ0 0x80
JKRCompression compression;
if (!(attr & JKRARCHIVE_ATTR_COMPRESSION)) {
compression = COMPRESSION_NONE;
return COMPRESSION_NONE;
} else if (attr & JKRARCHIVE_ATTR_YAZ0) {
compression = COMPRESSION_YAZ0;
return COMPRESSION_YAZ0;
} else {
compression = COMPRESSION_YAY0;
return COMPRESSION_YAY0;
}
return compression;
}
static u32 getCurrentDirID() { return sCurrentDirID; }
static void setCurrentDirID(u32 dirID) { sCurrentDirID = dirID; }
private:
protected:
static u32 sCurrentDirID;
};
inline JKRCompression JKRConvertAttrToCompressionType(u32 attr) {
inline JKRCompression JKRConvertAttrToCompressionType(int attr) {
return JKRArchive::convertAttrToCompressionType(attr);
}
+14 -12
View File
@@ -2,6 +2,7 @@
#define JKRASSERTHEAP_H
#include "JSystem/JKernel/JKRHeap.h"
#include "JSystem/JUtility/JUTAssert.h"
/**
* @ingroup jsystem-jkernel
@@ -18,18 +19,19 @@ public:
/* vt[06] */ virtual bool dump_sort(void); /* override */
/* vt[07] */ virtual bool dump(void); /* override */
/* vt[08] */ virtual void do_destroy(void); /* override */
/* vt[09] */ virtual void* do_alloc(u32, int); /* override */
/* vt[10] */ virtual void do_free(void*); /* override */
/* vt[11] */ virtual void do_freeAll(void); /* override */
/* vt[12] */ virtual void do_freeTail(void); /* override */
/* vt[13] */ virtual void do_fillFreeArea(void); /* override */
/* vt[14] */ virtual s32 do_resize(void*, u32); /* override */
/* vt[15] */ virtual s32 do_getSize(void*); /* override */
/* vt[16] */ virtual s32 do_getFreeSize(void); /* override */
/* vt[17] */ virtual void* do_getMaxFreeBlock(void); /* override */
/* vt[18] */ virtual s32 do_getTotalFreeSize(void); /* override */
/* vt[19] */ virtual s32 do_changeGroupID(u8 param_1); /* override */
/* vt[20] */ virtual u8 do_getCurrentGroupId(void); /* override */
/* vt[19] */ virtual s32 do_changeGroupID(u8) { JUT_ASSERT(41, 0&& "illegal changeGroupID()"); return 0; }
/* vt[20] */ virtual u8 do_getCurrentGroupId(void) { return 0; }
/* vt[09] */ virtual void* do_alloc(u32, int alignment) { UNUSED(alignment); JUT_ASSERT(47, 0&& "illegal alloc"); return NULL; }
/* vt[10] */ virtual void do_free(void*) { JUT_ASSERT(51, 0&& "illegal free"); }
/* vt[11] */ virtual void do_freeAll(void) { JUT_ASSERT(53, 0&& "illegal freeAll()"); }
/* vt[12] */ virtual void do_freeTail(void) { JUT_ASSERT(55, 0&& "illegal freeTail()"); }
/* vt[13] */ virtual void do_fillFreeArea(void) {}
/* vt[14] */ virtual s32 do_resize(void*, u32) { JUT_ASSERT(61, 0&& "illegal resize"); return 0; }
/* vt[15] */ virtual s32 do_getSize(void*) { return 0; }
/* vt[16] */ virtual s32 do_getFreeSize(void) { return 0; }
/* vt[17] */ virtual void* do_getMaxFreeBlock(void) { return 0; }
/* vt[18] */ virtual s32 do_getTotalFreeSize(void) { return 0; }
public:
static JKRAssertHeap* create(JKRHeap*);
+4
View File
@@ -82,4 +82,8 @@ inline u32 JKRDecompExpandSize(u8* pBuf) {
return (pBuf[4] << 0x18) | (pBuf[5] << 0x10) | (pBuf[6] << 8) | pBuf[7];
}
inline void JKRDecompress_SendCommand(JKRDecompCommand* command) {
JKRDecomp::sendCommand(command);
}
#endif /* JKRDECOMP_H */
@@ -50,6 +50,7 @@ public:
static JKRADCommand* callCommand_Async(JKRADCommand*);
static bool syncAram(JKRADCommand*, int);
static u32 getSZSBufferSize() { return sSZSBufferSize; }
static void setSZSBufferSize(u32 size) { sSZSBufferSize = size; }
static bool isErrorRetry() { return errorRetry; }
+1 -1
View File
@@ -28,7 +28,7 @@ public:
u32 getFileID() const { return mFileInfo.startAddr; }
DVDFileInfo* getFileInfo() { return &mFileInfo; }
int getStatus() { return DVDGetCommandBlockStatus(&mFileInfo.cb); }
int getStatus() const { return DVDGetCommandBlockStatus(&mFileInfo.cb); }
public:
/* vt[03] */ virtual bool open(const char*); /* override */
+10 -1
View File
@@ -35,6 +35,7 @@ class JKRDvdRipper {
public:
static JSUList<JKRDMCommand> sDvdAsyncList;
static u32 sSZSBufferSize;
static bool errorRetry;
enum EAllocDirection {
UNKNOWN_EALLOC_DIRECTION = 0,
@@ -51,12 +52,20 @@ public:
static void* loadToMainRAM(JKRDvdFile*, u8*, JKRExpandSwitch, u32, JKRHeap*, EAllocDirection,
u32, JKRCompression*, u32*);
static u8 isErrorRetry(void);
static bool isErrorRetry(void) { return errorRetry; }
inline static u32 getSZSBufferSize() { return sSZSBufferSize; }
};
// void JKRDecompressFromDVD(JKRDvdFile*, void*, u32, u32, u32, u32, u32*);
inline void* JKRDvdToMainRam(JKRDvdFile* file, u8* dst, JKRExpandSwitch expandSwitch, u32 dstLength,
JKRHeap* heap, JKRDvdRipper::EAllocDirection allocDirection,
u32 offset, JKRCompression* compression, u32* returnSize) {
return JKRDvdRipper::loadToMainRAM(file, dst, expandSwitch, dstLength, heap, allocDirection,
offset, compression, returnSize);
}
inline void* JKRDvdToMainRam(s32 entryNum, u8* dst, JKRExpandSwitch expandSwitch, u32 dstLength,
JKRHeap* heap, JKRDvdRipper::EAllocDirection allocDirection,
u32 offset, JKRCompression* compression, u32* returnSize) {
+4 -1
View File
@@ -63,7 +63,7 @@ protected:
void joinTwoBlocks(CMemBlock* block);
public:
s32 isEmpty();
BOOL isEmpty();
s32 getUsedSize(u8 groupId) const;
s32 getTotalUsedSize(void) const;
@@ -110,6 +110,9 @@ public:
static JKRExpHeap* createRoot(int maxHeaps, bool errorFlag);
static JKRExpHeap* create(u32 size, JKRHeap* parent, bool errorFlag);
static JKRExpHeap* create(void* ptr, u32 size, JKRHeap* parent, bool errorFlag);
static s32 getUsedSize_(JKRExpHeap* heap) { return heap->mSize - heap->getTotalFreeSize(); }
static void* getState_(TState* state) { return getState_buf_(state); }
};
inline JKRExpHeap* JKRCreateExpHeap(u32 size, JKRHeap* parent, bool errorFlag) {
+1 -1
View File
@@ -12,7 +12,7 @@ public:
JKRFile() : mIsAvailable(false) {}
virtual ~JKRFile() {}
s32 read(void*, s32, s32);
void read(void*, s32, s32);
bool isAvailable() const { return mIsAvailable; }
+2 -2
View File
@@ -14,8 +14,8 @@ public:
JKRFileLoader(void);
virtual ~JKRFileLoader();
bool isMounted() const { return this->mIsMounted; }
u32 getVolumeType() const { return this->mVolumeType; }
bool isMounted() { return this->mIsMounted; }
u32 getVolumeType() { return this->mVolumeType; }
public:
/* vt[03] */ virtual void unmount(void);
+32 -17
View File
@@ -8,10 +8,12 @@
class JKRHeap;
typedef void (*JKRErrorHandler)(void*, u32, int);
extern bool data_804508B0;
extern u8 data_804508B1;
extern u8 data_804508B2;
extern u8 data_804508B3;
extern u8 JKRValue_DEBUGFILL_NOTUSE;
extern u8 JKRValue_DEBUGFILL_NEW;
extern u8 JKRValue_DEBUGFILL_DELETE;
extern s32 fillcheck_dispcount;
extern bool data_8074A8D0_debug;
/**
* @ingroup jsystem-jkernel
@@ -19,6 +21,9 @@ extern u8 data_804508B3;
*/
class JKRHeap : public JKRDisposer {
public:
typedef void (*JKRAllocCallback)(u32, int, JKRHeap*, void*);
typedef void (*JKRFreeCallback)(void*, JKRHeap*);
class TState {
public:
/* 0x00 */ u32 mUsedSize;
@@ -54,6 +59,7 @@ public:
void* getMaxFreeBlock();
s32 getTotalFreeSize();
s32 changeGroupID(u8 newGroupId);
u8 getCurrentGroupId();
u32 getMaxAllocatableSize(int alignment);
JKRHeap* find(void* ptr) const;
@@ -96,13 +102,13 @@ public:
void* getEndAddr() { return (void*)mEnd; }
u32 getSize() const { return mSize; }
bool getErrorFlag() const { return mErrorFlag; }
void callErrorHandler(JKRHeap* heap, u32 size, int alignment) {
void callErrorHandler(void* heap, u32 size, int alignment) {
if (mErrorHandler) {
(*mErrorHandler)(heap, size, alignment);
}
}
JKRHeap* getParent() const {
JKRHeap* getParent() {
JSUTree<JKRHeap>* parent = mChildTree.getParent();
return parent->getObject();
}
@@ -110,8 +116,8 @@ public:
JSUTree<JKRHeap>& getHeapTree() { return mChildTree; }
void appendDisposer(JKRDisposer* disposer) { mDisposerList.append(&disposer->mLink); }
void removeDisposer(JKRDisposer* disposer) { mDisposerList.remove(&disposer->mLink); }
void lock() { OSLockMutex(&mMutex); }
void unlock() { OSUnlockMutex(&mMutex); }
void lock() const { OSLockMutex(const_cast<OSMutex*>(&mMutex)); }
void unlock() const { OSUnlockMutex(const_cast<OSMutex*>(&mMutex)); }
u32 getHeapSize() { return mSize; }
u8 getCurrentGroupId() { return 0; }
@@ -133,6 +139,7 @@ protected:
public:
static bool initArena(char** memory, u32* size, int maxHeaps);
static bool initArena2(char** memory, u32* size, int maxHeaps);
static void* alloc(u32 size, int alignment, JKRHeap* heap);
static void free(void* ptr, JKRHeap* heap);
static s32 resize(void* ptr, u32 size, JKRHeap* heap);
@@ -144,8 +151,11 @@ public:
static bool checkMemoryFilled(void* src, u32 size, u8 value);
static JKRErrorHandler setErrorHandler(JKRErrorHandler errorHandler);
static void fillMemory(u8*, u32, u8);
static bool checkMemoryFilled(u8*, u32, u8);
static void setDefaultDebugFill(bool status) { data_804508B0 = status; }
static bool isDefaultDebugFill() { return sDefaultFillFlag; }
static void setDefaultDebugFill(bool status) { sDefaultFillFlag = status; }
static void* getCodeStart(void) { return mCodeStart; }
static void* getCodeEnd(void) { return mCodeEnd; }
static void* getUserRamStart(void) { return mUserRamStart; }
@@ -166,13 +176,16 @@ public:
state->mCheckCode = checkCode;
}
static void* getState_buf_(TState* state) { return &state->mBuf; }
static void* getState_(TState* state) { return getState_buf_(state); }
static void* mCodeStart;
static void* mCodeEnd;
static void* mUserRamStart;
static void* mUserRamEnd;
static u32 mMemorySize;
static JKRAllocCallback sAllocCallback;
static JKRFreeCallback sFreeCallback;
static bool sDefaultFillFlag;
static JKRHeap* sRootHeap;
@@ -206,8 +219,7 @@ inline void* JKRAllocFromHeap(JKRHeap* heap, u32 size, int alignment) {
}
inline void* JKRAllocFromSysHeap(u32 size, int alignment) {
JKRHeap* systemHeap = JKRHeap::getSystemHeap();
return systemHeap->alloc(size, alignment);
return JKRHeap::getSystemHeap()->alloc(size, alignment);
}
inline void JKRFreeToHeap(JKRHeap* heap, void* ptr) {
@@ -215,14 +227,17 @@ inline void JKRFreeToHeap(JKRHeap* heap, void* ptr) {
}
inline void JKRFreeToSysHeap(void* ptr) {
JKRHeap* systemHeap = JKRHeap::getSystemHeap();
systemHeap->free(ptr);
JKRHeap::getSystemHeap()->free(ptr);
}
inline void JKRFree(void* ptr) {
JKRHeap::free(ptr, NULL);
}
inline void JKRFillMemory(u8* dst, u32 size, u8 val) {
JKRHeap::fillMemory(dst, size, val);
}
inline JKRHeap* JKRGetSystemHeap() {
return JKRHeap::getSystemHeap();
}
@@ -268,9 +283,9 @@ inline JKRHeap* JKRGetRootHeap2() {
}
#if DEBUG
inline void JKRSetDebugFillNotuse(u8 status) { data_804508B1 = status; }
inline void JKRSetDebugFillNew(u8 status) { data_804508B2 = status; }
inline void JKRSetDebugFillDelete(u8 status) { data_804508B3 = status; }
inline void JKRSetDebugFillNotuse(u8 status) { JKRValue_DEBUGFILL_NOTUSE = status; }
inline void JKRSetDebugFillNew(u8 status) { JKRValue_DEBUGFILL_NEW = status; }
inline void JKRSetDebugFillDelete(u8 status) { JKRValue_DEBUGFILL_DELETE = status; }
#endif
#endif /* JKRHEAP_H */
+2
View File
@@ -59,6 +59,8 @@ public:
s32 adjustSize(void);
static JKRSolidHeap* create(u32, JKRHeap*, bool);
static void* getState_(TState* state) { return getState_buf_(state); }
};
inline JKRSolidHeap* JKRCreateSolidHeap(u32 param_0, JKRHeap* heap, bool param_2) {
+2 -2
View File
@@ -117,7 +117,7 @@ private:
/* 0x28 */ JKRHeap* mHeap;
/* 0x2C */ OSThread* mThreadRecord;
/* 0x30 */ OSMessageQueue mMessageQueue;
/* 0x50 */ OSMessage* mMessages;
/* 0x50 */ OSMessage* mMesgBuffer;
/* 0x54 */ s32 mMessageCount;
/* 0x58 */ void* mStackMemory;
/* 0x5C */ u32 mStackSize;
@@ -159,7 +159,7 @@ public:
private:
static JKRThreadSwitch* sManager;
static u32 sTotalCount;
static u32 sTotalStart;
static u64 sTotalStart;
static JKRThreadSwitch_PreCallback mUserPreCallback;
static JKRThreadSwitch_PostCallback mUserPostCallback;