m_Do_main debug (#2965)

This commit is contained in:
Jcw87
2025-12-19 21:22:03 +02:00
committed by GitHub
parent 9771ae6879
commit 2c62444df1
24 changed files with 218 additions and 53 deletions
+37 -5
View File
@@ -9,7 +9,7 @@ public:
void init(JHICommonMem*, u32, u32, u32);
int load();
u32 getMsgBufSize();
u32 getMsgBufSize() { return m_msgBufSize; }
/* 0x00 */ JHICommonMem* mp_memBuffer;
/* 0x04 */ u32 field_0x4;
@@ -47,7 +47,9 @@ public:
int writeBegin();
void writeEnd();
int write(void*, int);
void init() { m_header.init(); }
/* 0x00 */ Header m_header;
/* 0x38 */ JHIMemBuf* mp_memBuffer;
};
@@ -55,7 +57,6 @@ public:
class JHICommBufReader {
public:
struct Header : public JHICommBufHeader {
int load();
void updateGetAdrs();
u32 getReadableSize() const;
void addGetAdrs(int);
@@ -63,6 +64,14 @@ public:
void alignGetAdrs();
int getContSize();
int load() {
int result = JHICommBufHeader::load();
if (!result) {
field_0x30 = field_0xc;
}
return result;
}
/* 0x30 */ u32 field_0x30;
};
@@ -71,8 +80,17 @@ public:
void readEnd();
int read(void*, int);
u32 available() { return m_header.load() ? 0xFFFFFFFF : m_header.getReadableSize(); }
u32 getMsgBufSize() { return m_header.getMsgBufSize(); }
void init() { m_header.init(); }
u32 available() {
if (m_header.load()) {
return 0xFFFFFFFF;
} else {
return m_header.getReadableSize();
}
}
/* 0x00 */ Header m_header;
/* 0x34 */ JHIMemBuf* mp_memBuffer;
};
@@ -81,12 +99,26 @@ struct JHICmnMem {
u32 sendBegin() { return mp_writeBuf->writeBegin(); }
int sendCont(const void* param_0, int param_1) { return mp_writeBuf->write((void*)param_0, param_1); }
void sendEnd() { mp_writeBuf->writeEnd(); }
u32 available() { return mp_readBuf->available(); }
u32 getMaxReaderableSize() { return mp_readBuf->getMsgBufSize(); }
void setBuf(JHICommBufReader* pReader, JHICommBufWriter* pWriter) {
mp_readBuf = pReader;
mp_writeBuf = pWriter;
}
void initBuffers() {
mp_readBuf->init();
mp_writeBuf->init();
}
int receive(void* param_1, int param_2) {
int result = 0;
result = mp_readBuf->read(param_1, param_2);
mp_readBuf->readEnd();
return result;
}
/* 0x0 */ JHICommBufReader* mp_readBuf;
/* 0x4 */ JHICommBufWriter* mp_writeBuf;
/* 0x8 */ u8 field_0x8;
+13 -7
View File
@@ -11,6 +11,12 @@ inline u32 JHIhtonl(u32 v) {
#endif
}
inline u32 JHIntohl(u32 v) {
return v;
}
template<typename T> class JHIComPortManager;
template <typename T>
struct JHITag {
JHITag(u32 tag) {
@@ -23,20 +29,20 @@ struct JHITag {
sp10[0] = JHIhtonl(m_tag);
sp10[1] = JHIhtonl(param_1);
if (mp_data->sendBegin() >= param_1 + 8) {
mp_data->sendCont(sp10, 8);
mp_data->sendCont(param_0, param_1);
mp_data->sendEnd();
if (mp_data->port.sendBegin() >= param_1 + 8) {
mp_data->port.sendCont(sp10, 8);
mp_data->port.sendCont(param_0, param_1);
mp_data->port.sendEnd();
}
return param_1;
}
virtual ~JHITag() {}
virtual void receive(const char*, s32);
virtual void receive(const char*, s32) {}
/* 0x4 */ u32 m_tag;
/* 0x8 */ T* mp_data;
/* 0x8 */ JHIComPortManager<T>* mp_data;
};
class JHIMemBuf;
+54 -4
View File
@@ -9,7 +9,7 @@ public:
JHIpvector() { m_size = 0; }
s32 size() const { return m_size; }
T& get(u32 i) const { return m_vector[i]; }
T get(u32 i) const { return m_vector[i]; }
s32 push_back(T p) {
if (m_size >= I) {
@@ -35,10 +35,57 @@ public:
T& getRefPort() { return port; }
void addTag(JHITag<T>* pTag) {
field_0x8 = this;
pTag->mp_data = this;
field_0xc.push_back(pTag);
}
JHITag<T>* find(u32 param_1) {
for (u32 i = 0; i < field_0xc.size(); i++) {
JHITag<T>* tag = field_0xc.get(i);
if (tag->m_tag == param_1) {
return tag;
}
}
return NULL;
}
void dispatchMessage() {
u32 r29 = port.available();
while (true) {
if (!field_0x10040) {
if (r29 < 8) {
return;
}
port.receive(&field_0x10038, 8);
r29 -= 8;
field_0x10038 = JHIntohl(field_0x10038);
field_0x1003c = JHIntohl(field_0x1003c);
field_0x10040 = 1;
JHITag<T>* r27 = find(field_0x10038);
if (field_0x1003c > port.getMaxReaderableSize()) {
port.initBuffers();
OSReport("JHostIO::ERROR: JHIComportManager: invalid datasize ( port.initialized )\n");
} else if (!r27) {
OSReport("JHostIO::ERROR: JHIComportManager: invalid tag message\n");
}
}
if (!field_0x10040) {
continue;
}
if (r29 < field_0x1003c) {
return;
}
u32 r26 = port.receive(field_0x38, field_0x1003c);
r29 -= r26;
JHITag<T>* r28 = find(field_0x10038);
field_0x10040 = 0;
if (r28) {
r28->receive(field_0x38, field_0x1003c);
}
}
}
static JHIComPortManager<T>* create() {
if (instance == NULL) {
instance = new JHIComPortManager<T>();
@@ -47,16 +94,19 @@ public:
return instance;
}
static JHIComPortManager<T>* getInstance() { return instance; }
static JHIComPortManager<T>* instance;
/* 0x00000 */ T port;
/* 0x00008 */ JHIComPortManager<T>* field_0x8;
/* 0x0000C */ JHIpvector<JHITag<T>*, 10> field_0xc;
/* 0x00038 */ u8 field_0x38[0x10000];
/* 0x00038 */ char field_0x38[0x10000];
/* 0x10038 */ u32 field_0x10038;
/* 0x1003C */ u32 field_0x1003c;
/* 0x10040 */ u8 field_0x10040;
/* 0x10041 */ u8 field_0x10041;
};
void JORInit();
#endif /* JORENTRY_H */
+3 -4
View File
@@ -182,7 +182,9 @@ public:
void startUpdateNode(JORReflexible* obj) { putNode(obj); }
void genNodeSub(const char* label, JORReflexible* i_node, u32, u32);
void putNode(JORReflexible* obj);
void putNode(JORReflexible* obj) {
mOutputStream << (uintptr_t)obj;
}
void invalidNode(JORReflexible* i_node, u32);
void genControl(u32 type, u32 kind, const char* label, u32 style, u32 id,
@@ -305,7 +307,4 @@ public:
/* 0x10000 */ JSUMemoryOutputStream mOutputStream;
};
JORMContext* attachJORMContext(u32);
void releaseJORMContext(JORMContext*);
#endif /* JORMCONTEXT_H */
+73 -6
View File
@@ -1,15 +1,13 @@
#ifndef JORSERVER_H
#define JORSERVER_H
#include "JSystem/JHostIO/JOREntry.h"
#include "JSystem/JHostIO/JORMContext.h"
#include "JSystem/JHostIO/JHIComm.h"
#include "JSystem/JHostIO/JHIhioASync.h"
#include "JSystem/JGadget/linklist.h"
#include "JSystem/JUtility/JUTAssert.h"
void JOR_MESSAGELOOP();
void JOR_INIT();
void JOR_SETROOTNODE(const char*, JORReflexible*, u32, u32);
u32 JORMessageBox(const char* message, const char* title, u32 style);
struct JOREventCallbackListNode {
@@ -20,6 +18,14 @@ struct JOREventCallbackListNode {
virtual int JORAct(u32, const char*);
virtual ~JOREventCallbackListNode();
bool JORIsAcceptableID(u32 eventID) const {
bool result = false;
if (field_0xc <= eventID && eventID <= field_0x10) {
result = true;
}
return result;
}
/* 0x04 */ JGadget::TLinkListNode m_node;
/* 0x0C */ u32 field_0xc;
/* 0x10 */ u32 field_0x10;
@@ -32,6 +38,9 @@ class JORHostInfo_CalendarTime;
class JORServer : public JHITag<JHICmnMem> {
public:
typedef void (*EventFunc)(u32,char *);
typedef JGadget::TLinkList<JOREventCallbackListNode, -4> CallbackLinkList;
enum ECommand {
ECommand_GetRootObj = 1,
ECommand_GenObjInfo = 3,
@@ -94,6 +103,17 @@ public:
void setRootNode(const char*, JORReflexible*, u32, u32);
void doneEvent();
bool getEvent() { return m_event; }
void setEvent(bool event) { m_event = event; }
void setEventDone(bool eventDone) { m_eventDone = eventDone; }
u32 getEventNum() { return m_eventNum; }
char* getEventName() { return m_eventName; }
EventFunc getEventFunc() { return m_eventFunc; }
void setEventFunc(EventFunc func) { m_eventFunc = func; }
bool isEventCallbackListEnabled() const { return m_isEventCallbackListEnabled; }
void enableEventCallbackList(bool enable) { m_isEventCallbackListEnabled = enable; }
CallbackLinkList* referEventCallbackList() { return &m_eventCallbackList; }
static JORServer* getInstance() { return instance; }
static JORServer* instance;
@@ -106,9 +126,56 @@ public:
/* 0x1006D */ bool m_eventDone;
/* 0x10070 */ u32 m_eventNum;
/* 0x10074 */ char m_eventName[0x1000];
/* 0x11074 */ void* m_eventFunc;
/* 0x11074 */ EventFunc m_eventFunc;
/* 0x11078 */ bool m_isEventCallbackListEnabled;
/* 0x1107C */ JGadget::TLinkList<JOREventCallbackListNode, -4> m_eventCallbackList;
/* 0x1107C */ CallbackLinkList m_eventCallbackList;
};
inline void JOR_MESSAGELOOP() {
JORServer* server = JORServer::getInstance();
JHIComPortManager<JHICmnMem>::getInstance()->dispatchMessage();
if (server->getEvent()) {
server->setEvent(false);
server->setEventDone(false);
u32 eventNum = server->getEventNum();
char* eventName = server->getEventName();
if (server->isEventCallbackListEnabled() && eventNum >= 0x80000000) {
JORServer::CallbackLinkList* list = server->referEventCallbackList();
JORServer::CallbackLinkList::iterator end = list->end();
for (JORServer::CallbackLinkList::iterator it = list->begin(); it != end;) {
JOREventCallbackListNode& callback = *it;
++it;
if (!callback.JORIsAcceptableID(eventNum)) {
continue;
}
if (callback.JORAct(eventNum, eventName)) {
break;
}
}
} else {
JORServer::EventFunc func = server->getEventFunc();
if (func) {
func(eventNum, eventName);
}
}
server->doneEvent();
}
JHIEventLoop();
}
inline void JOR_INIT() {
JORInit();
JORServer::getInstance()->setEventFunc(NULL);
}
inline void JOR_SETROOTNODE(const char* name, JORReflexible* node, u32 param_3, u32 param_4) {
JORServer::getInstance()->setRootNode(name, node, param_3, param_4);
}
inline JORMContext* attachJORMContext(u32 msgID) {
return JORServer::getInstance()->attachMCTX(msgID);
}
inline void releaseJORMContext(JORMContext* mctx) {
JORServer::getInstance()->releaseMCTX(mctx);
}
#endif /* JORSERVER_H */
+1 -1
View File
@@ -46,7 +46,7 @@ public:
static void dump(void);
static JKRAram* getManager() { return sAramObject; }
static JKRAramHeap* getAramHeap() { return getManager()->mAramHeap; }
static JKRAramHeap* getAramHeap() { return sAramObject->mAramHeap; }
static JSUList<JKRAMCommand>& getCommandList() { return sAramCommandList; }
static u8 decideAramGroupId(int groupId) {
+4 -1
View File
@@ -62,11 +62,14 @@ namespace JUTAssertion {
void setMessageCount(int);
u32 getSDevice();
void showAssert(u32 device, const char * file, int line, const char * assertion);
void showAssert_f(u32 device, const char* file, int line, const char* msg, ...);
void setWarningMessage_f(u32 device, char * file, int line, const char * fmt, ...);
void setLogMessage_f(u32 device, char* file, int line, const char* fmt, ...);
void setConfirmMessage(u32 param_1, char* file, int line, bool param_4, const char* msg);
inline void showAssert(u32 device, const char* file, int line, const char* msg) {
showAssert_f(device, file, line, "%s", msg);
}
};
extern bool sAssertVisible;
+4
View File
@@ -74,4 +74,8 @@ inline JUTVideo* JUTGetVideoManager() {
return JUTVideo::getManager();
}
inline void JUTDestroyVideoManager() {
JUTVideo::destroyManager();
}
#endif /* JUTVIDEO_H */