JUTException (#154)

* JUTException inherit JKRThread

* OK __ct__12JUTExceptionFP14JUTDirectPrint

* OK create__12JUTExceptionFP14JUTDirectPrint

* OK setFPException__12JUTExceptionFUl

* OK showFloatSub__12JUTExceptionFif

* OK showFloat__12JUTExceptionFP9OSContext

* OK searchPartialModule__12JUTExceptionFUlPUlPUlPUlPUl

* OK search_name_part__FPUcPUci

* OK showStack__12JUTExceptionFP9OSContext

* OK showMainInfo__12JUTExceptionFUsP9OSContextUlUl

* OK showGPR__12JUTExceptionFP9OSContext

* OK __sinit_JUTException_cpp

* OK showMapInfo_subroutine__12JUTExceptionFUlb

* OK showGPRMap__12JUTExceptionFP9OSContext

* OK showSRR0Map__12JUTExceptionFP9OSContext

* OK printDebugInfo__12JUTExceptionFQ212JUTException9EInfoPageUsP9OSContextUlUl

* OK isEnablePad__12JUTExceptionCFv

* OK readPad__12JUTExceptionFPUlPUl

* NONMATCHING printContext__12JUTExceptionFUsP9OSContextUlUl

* OK printContext__12JUTExceptionFUsP9OSContextUlUl

* OK __dt__12JUTExceptionFv

* OK waitTime__12JUTExceptionFl

* OK createFB__12JUTExceptionFv

* OK setPreUserCallback__12JUTExceptionFPFUsP9OSContextUlUl_v

* OK __ct__13JUTExternalFBFP16_GXRenderModeObj8_GXGammaPvUl

* OK createConsole__12JUTExceptionFPvUl

* NONMATCHING queryMapAddress_single__12JUTExceptionFPcUllPUlPUlPcUlbb

* OK queryMapAddress__12JUTExceptionFPcUllPUlPUlPcUlbb

* OK appendMapFile__12JUTExceptionFPCc

* clean up

* OK panic_f__12JUTExceptionFPCciPCce

* OK panic_f_va__12JUTExceptionFPCciPCcP16__va_list_struct

* OK errorHandler__12JUTExceptionFUsP9OSContextUlUl

* format

* format

* fixed requested changes

* merged with master and removed *.s files

Co-authored-by: Julgodis <>
This commit is contained in:
Jonathan Wase
2021-11-09 23:09:38 +01:00
committed by GitHub
parent 5020395dfd
commit 901b222eb8
59 changed files with 1201 additions and 3141 deletions
+1 -1
View File
@@ -121,7 +121,7 @@ public:
bool operator==(JSULink<T> const* other) const { return this->mLink == other; }
bool operator!=(JSULink<T> const* other) const { return this->mLink != other; }
bool operator==(JSUListIterator<T> const& other) const { return this->mLink == other.mLink; }
bool operator!=(JSUListIterator<T> const& other) const { return this->mLink != other.other; }
bool operator!=(JSUListIterator<T> const& other) const { return this->mLink != other.mLink; }
JSUListIterator<T> operator++(int) {
JSUListIterator<T> prev = *this;
+18 -9
View File
@@ -14,8 +14,8 @@ public:
UNK_TYPE2 = 2,
};
/* 802E73E4 */ void create(unsigned int, void*, u32);
/* 802E7354 */ void create(unsigned int, unsigned int, JKRHeap*);
/* 802E73E4 */ static JUTConsole* create(unsigned int, void*, u32);
/* 802E7354 */ static JUTConsole* create(unsigned int, unsigned int, JKRHeap*);
/* 802E746C */ JUTConsole(unsigned int, unsigned int, bool);
/* 802E75CC */ static size_t getObjectSizeFromBufferSize(unsigned int, unsigned int);
/* 802E75DC */ static size_t getLineFromObjectSize(u32, unsigned int);
@@ -31,26 +31,31 @@ public:
/* 802E755C */ virtual ~JUTConsole();
void setOutput(u32 output) { mOutput = output; }
u32 getOutput() const { return mOutput; }
void setPosition(int x, int y) {
mPositionX = x;
mPositionY = y;
}
void setFontSize(f32 x, f32 y) {
mFontSizeX = x;
mFontSizeY = y;
}
void setHeight(u32 height) {
mHeight = height;
if (mHeight > field_0x24) {
mHeight = field_0x24;
}
}
u32 getOutput() const { return mOutput; }
int getPositionY() const { return mPositionY; }
int getPositionX() const { return mPositionX; }
u32 getHeight() const { return mHeight; }
bool isVisible() const { return mVisible; }
void setVisible(bool visible) { mVisible = visible; }
void setLineAttr(int param_0, u8 param_1) { mBuf[(field_0x20 + 2) * param_0] = param_1; }
u8* getLinePtr(int param_0) const { return &mBuf[(field_0x20 + 2) * param_0 + 1]; }
int diffIndex(int param_0, int param_1) const {
int diff = param_1 - param_0;
if (diff >= 0) {
@@ -59,6 +64,10 @@ public:
return diff += field_0x24;
}
void scrollToLastLine() { scroll(field_0x24); }
void scrollToFirstLine() { scroll(-field_0x24); }
private:
/* 0x18 */ JGadget::TLinkListNode mListNode;
private:
@@ -22,6 +22,8 @@ public:
/* 802E4240 */ static JUTDirectPrint* start();
bool isActive() const { return field_0x00 != 0; }
static JUTDirectPrint* getManager() { return sDirectPrint; }
private:
+94 -51
View File
@@ -2,85 +2,128 @@
#define JUTEXCEPTION_H
#include "JSystem/JKernel/JKRThread.h"
#include "JSystem/JSupport/JSUList.h"
#include "JSystem/JUtility/JUTDirectPrint.h"
#include "JSystem/JUtility/JUTGamePad.h"
#include "Runtime.PPCEABI.H/__va_arg.h"
#include "dolphin/gx/GX.h"
#include "dolphin/os/OS.h"
#include "dolphin/types.h"
#include "global.h"
struct _GXRenderModeObj;
struct _GXGamma {};
struct JUTExternalFB {
/* 802E40CC */ JUTExternalFB(_GXRenderModeObj*, _GXGamma, void*, u32);
};
struct JUTDirectPrint {
/* 802E456C */ void changeFrameBuffer(void*, u16, u16);
};
class JUTException /* : public JKRThread */ {
class JUTExternalFB {
public:
struct EInfoPage {};
/* 802E40CC */ JUTExternalFB(_GXRenderModeObj*, GXGamma, void*, u32);
private:
/* 0x00 */ _GXRenderModeObj* mRenderMode;
/* 0x04 */ u32 mSize;
/* 0x08 */ u32 field_0x08;
/* 0x0C */ u16 field_0x0C;
/* 0x0E */ u16 mGamma;
/* 0x10 */ bool field_0x10;
/* 0x11 */ u8 field_[3];
};
STATIC_ASSERT(sizeof(JUTExternalFB) == 0x14);
#define JUT_PRINT_GPR 1
#define JUT_PRINT_GPR_MAP 2
#define JUT_PRINT_SRR0_MAP 4
#define JUT_PRINT_FLOAT 8
#define JUT_PRINT_STACK 16
class JUTException : public JKRThread {
public:
enum EInfoPage {
EINFO_PAGE_GPR = 1,
EINFO_PAGE_FLOAT = 2,
EINFO_PAGE_STACK = 3,
EINFO_PAGE_GPR_MAP = 4,
EINFO_PAGE_SSR0_MAP = 5,
};
class JUTExMapFile {
public:
JUTExMapFile(char* path) : mLink(this) { mPath = path; }
public:
/* 0x00 */ char* mPath;
/* 0x04 */ JSULink<JUTExMapFile> mLink;
/* 0x14 */
};
// TODO: return types are probably wrong
/* 802E1D5C */ JUTException(JUTDirectPrint*);
/* 802E1E40 */ void create(JUTDirectPrint*);
/* 802E1FCC */ void errorHandler(u16, OSContext*, u32, u32);
/* 802E20C0 */ void panic_f_va(char const*, int, char const*, va_list);
/* 802E21FC */ static void panic_f(char const*, int, char const*, ...);
/* 802E227C */ void setFPException(u32);
/* 802E40EC */ virtual ~JUTException();
/* 802E22C4 */ void showFloatSub(int, f32);
/* 802E2454 */ void showFloat(OSContext*);
/* 802E2578 */ void searchPartialModule(u32, u32*, u32*, u32*, u32*);
/* 802E26B0 */ void showStack(OSContext*);
/* 802E27B0 */ void showMainInfo(u16, OSContext*, u32, u32);
/* 802E2A84 */ void showGPR(OSContext*);
/* 802E2B44 */ void showMapInfo_subroutine(u32, bool);
/* 802E2B44 */ bool showMapInfo_subroutine(u32, bool);
/* 802E2CA0 */ void showGPRMap(OSContext*);
/* 802E2DAC */ void showSRR0Map(OSContext*);
/* 802E2E70 */ void printDebugInfo(JUTException::EInfoPage, u16, OSContext*, u32, u32);
/* 802E2F18 */ void isEnablePad() const;
/* 802E2E70 */ void printDebugInfo(JUTException::EInfoPage, OSError, OSContext*, u32, u32);
/* 802E2F18 */ bool isEnablePad() const;
/* 802E2F54 */ bool readPad(u32*, u32*);
/* 802E34C0 */ void printContext(u16, OSContext*, u32, u32);
/* 802E3980 */ static void waitTime(s32);
/* 802E3A08 */ void createFB();
/* 802E3AEC */ void setPreUserCallback(void (*)(u16, OSContext*, u32, u32));
/* 802E3AFC */ void setPostUserCallback(void (*)(u16, OSContext*, u32, u32));
/* 802E3B0C */ void appendMapFile(char const*);
/* 802E3BA0 */ void queryMapAddress(char*, u32, s32, u32*, u32*, char*, u32, bool, bool);
/* 802E3C90 */ void queryMapAddress_single(char*, u32, s32, u32*, u32*, char*, u32, bool, bool);
/* 802E3FEC */ void createConsole(void*, u32);
/* 802E40EC */ virtual ~JUTException();
/* 802E1EA8 */ virtual void run();
/* 802E1EA8 */ /* vt[03] */ virtual void* run();
/* 802E1E40 */ static JUTException* create(JUTDirectPrint*);
/* 802E1FCC */ static void errorHandler(OSError, OSContext*, u32, u32);
/* 802E20C0 */ static void panic_f_va(char const*, int, char const*, va_list);
/* 802E21FC */ static void panic_f(char const*, int, char const*, ...);
/* 802E227C */ static void setFPException(u32);
/* 802E2578 */ static bool searchPartialModule(u32, u32*, u32*, u32*, u32*);
/* 802E3AEC */ static OSErrorHandler setPreUserCallback(OSErrorHandler);
/* 802E3AFC */ static OSErrorHandler setPostUserCallback(OSErrorHandler);
/* 802E3B0C */ static void appendMapFile(char const*);
/* 802E3BA0 */ static bool queryMapAddress(char*, u32, s32, u32*, u32*, char*, u32, bool, bool);
/* 802E3C90 */ static bool queryMapAddress_single(char*, u32, s32, u32*, u32*, char*, u32, bool,
bool);
/* 802E3FEC */ static void createConsole(void*, u32);
/* 802E3980 */ static void waitTime(s32);
static JUTException* getManager() { return sErrorManager; }
void setTraceSuppress(u32 param_0) { mTraceSuppress = param_0; }
static u8 sMessageQueue[32];
static void* sCpuExpName[17];
static u8 sMapFileList[12 + 4 /* padding */];
JUTExternalFB* getFrameMemory() const { return mFrameMemory; }
void setTraceSuppress(u32 param_0) { mTraceSuppress = param_0; }
void setGamePad(JUTGamePad* gamePad) {
mGamePad = gamePad;
mGamePadPort = JUTGamePad::Port_Unknown;
}
private:
static OSMessageQueue sMessageQueue;
static const char* sCpuExpName[17];
static JSUList<JUTException::JUTExMapFile> sMapFileList;
static u8 sMessageBuffer[4 + 4 /* padding */];
static JUTException* sErrorManager;
static u8 sPreUserCallback[4];
static u8 sPostUserCallback[4];
static u8 sConsoleBuffer[4];
static u8 sConsoleBufferSize[4];
static u8 sConsole[4];
static u8 msr[4];
static u8 fpscr[4];
static OSErrorHandler sPreUserCallback;
static OSErrorHandler sPostUserCallback;
static void* sConsoleBuffer;
static u32 sConsoleBufferSize;
static JUTConsole* sConsole;
static u32 msr;
static u32 fpscr;
/* 0x00 */ JKRThread field_0x0; // should be inherited
/* 0x80 */ JUTDirectPrint* field_0x80;
/* 0x84 */ JUTGamePad* field_0x84;
/* 0x88 */ s32 field_0x88;
/* 0x8C */ s32 field_0x8c;
/* 0x90 */ s32 field_0x90;
private:
/* 0x7C */ JUTExternalFB* mFrameMemory;
/* 0x80 */ JUTDirectPrint* mDirectPrint;
/* 0x84 */ JUTGamePad* mGamePad;
/* 0x88 */ JUTGamePad::EPadPort mGamePadPort;
/* 0x8C */ s32 mPrintWaitTime0;
/* 0x90 */ s32 mPrintWaitTime1;
/* 0x94 */ u32 mTraceSuppress;
/* 0x98 */ u32 field_0x98;
/* 0x9C */ u32 field_0x9c;
/* 0xA0 */ u32 field_0xa0;
/* 0x9C */ u32 mPrintFlags;
/* 0xA0 */ u32 mStackPointer;
};
STATIC_ASSERT(sizeof(JUTException) == 0xA4);
#endif /* JUTEXCEPTION_H */
+8 -1
View File
@@ -47,7 +47,14 @@ public:
enum EStickMode {};
enum EWhichStick {};
enum EPadPort { Port_1, Port_2, Port_3, Port_4 };
enum EPadPort {
Port_Unknown = -1, // used by JUTException
Port_1,
Port_2,
Port_3,
Port_4,
};
JUTGamePad(JUTGamePad::EPadPort port);
virtual ~JUTGamePad();
@@ -3,4 +3,46 @@
#include "dolphin/types.h"
#define FP_SNAN 0
#define FP_QNAN 1
#define FP_INFINITE 2
#define FP_ZERO 3
#define FP_NORMAL 4
#define FP_SUBNORMAL 5
#define FP_NAN FP_QNAN
#define fpclassify(x) ((sizeof(x) == sizeof(float)) ? __fpclassifyf(x) : __fpclassifyd(x))
#define signbit(x) ((sizeof(x) == sizeof(float)) ? __signbitf(x) : __signbitd(x))
#define __signbitf(x) ((*(u8*)&(x)) & 0x80)
// TODO: OK?
#define __signbitd(x) ((*(u8*)&(x)) & 0x80)
inline int __fpclassifyf(float __value) {
u32 integer = *(u32*)&__value;
switch (integer & 0x7f800000) {
case 0x7f800000:
if ((integer & 0x7fffff) != 0) {
return FP_QNAN;
}
return FP_INFINITE;
case 0:
if ((integer & 0x7fffff) != 0) {
return FP_SUBNORMAL;
}
return FP_ZERO;
}
return FP_NORMAL;
}
inline int __fpclassifyd(double __value) {
// TODO:
return FP_INFINITE;
}
#endif /* MSL_COMMON_SRC_FLOAT_H */
+9
View File
@@ -5,6 +5,7 @@
#include "dolphin/mtx/mtx.h"
#include "dolphin/mtx/mtx44.h"
#include "dolphin/types.h"
#include "global.h"
typedef struct _GXColor {
/* 0x0 */ u8 r;
@@ -36,6 +37,8 @@ typedef struct _GXRenderModeObj {
u8 vfilter[7];
} GXRenderModeObj;
STATIC_ASSERT(sizeof(_GXRenderModeObj) == 60);
typedef struct _GXTexObj {
/* 0x00 */ u32 texture_filter;
/* 0x04 */ u32 texture_lod;
@@ -410,6 +413,12 @@ typedef enum _GXTexFmt {
/* 0x20 */ _GX_TF_CTF = 0x20
} GXTexFmt;
typedef enum _GXGamma {
/* 0x0 */ GX_GM_1_0,
/* 0x0 */ GX_GM_1_7,
/* 0x0 */ GX_GM_2_2,
} GXGamma;
typedef enum _GXTlutFmt {
/* 0x0 */ GX_TL_IA8,
/* 0x1 */ GX_TL_RGB565,
+8
View File
@@ -7,6 +7,14 @@
#include "Runtime.PPCEABI.H/__va_arg.h"
#include "dolphin/types.h"
#include "Runtime.PPCEABI.H/__va_arg.h"
#include "dolphin/os/OSError.h"
#include "dolphin/os/OSLink.h"
#define OS_BUS_CLOCK (*(u32*)0x800000F8)
#define OS_CORE_CLOCK (*(u32*)0x800000FC)
#define OS_TIMER_CLOCK (OS_BUS_CLOCK / 4)
/* TODO: more structs, and get rid of the ones that are faked! */
#define OS_MESSAGE_NON_BLOCKING 0
+27
View File
@@ -3,4 +3,31 @@
#include "dolphin/types.h"
struct OSContext;
extern u32 __OSFpscrEnableBits;
typedef u16 OSError;
typedef void (*OSErrorHandler)(OSError, OSContext*, u32, u32);
#define OS_ERROR_SYSTEM_RESET 0x0
#define OS_ERROR_MACHINE_CHECK 0x1
#define OS_ERROR_DSI 0x2
#define OS_ERROR_ISI 0x3
#define OS_ERROR_INTERRUPT 0x4
#define OS_ERROR_ALIGNMENT 0x5
#define OS_ERROR_PROGRAM 0x6
#define OS_ERROR_FLOATING_POINT 0x7
#define OS_ERROR_DECREMENTER 0x8
#define OS_ERROR_SYSTEM_CALL 0x9
#define OS_ERROR_TRACE 0xa
#define OS_ERROR_PERFORMANCE_MONITOR 0xb
#define OS_ERROR_BREAKPOINT 0xc
#define OS_ERROR_RESERVED 0xd
#define OS_ERROR_THERMAL_INTERRUPT 0xe
#define OS_ERROR_MEMORY_PROTECTION 0xf
#define OS_ERROR_FLOATING_POINT_EXCEPTION 0x10
extern "C" void OSSetErrorHandler(OSError, OSErrorHandler);
#endif /* OSERROR_H */
+30
View File
@@ -3,4 +3,34 @@
#include "dolphin/types.h"
struct OSModuleInfo {
u32 id;
OSModuleInfo* next;
OSModuleInfo* prev;
u32 num_sections;
u32 section_info_offset;
u32 name_offset;
u32 name_size;
u32 version;
u32 bss_size;
u32 rel_offset;
u32 imp_offset;
u32 imp_size;
u8 prolog_section;
u8 epilog_section;
u8 unresolved_section;
u8 bss_section;
u32 prolog;
u32 epilog;
u32 unresolved;
u32 align;
u32 bss_align;
u32 fix_size;
};
struct OSSectionInfo {
u32 offset;
u32 size;
};
#endif /* OSLINK_H */
+4
View File
@@ -23,9 +23,13 @@
#define _SDA_BASE_(dummy) 0
#define _SDA2_BASE_(dummy) 0
#ifndef IN_VSCODE_EDITOR
#define GLUE(a, b) a##b
#define GLUE2(a, b) GLUE(a, b)
#define STATIC_ASSERT(cond) typedef char GLUE2(static_assertion_failed, __LINE__)[(cond) ? 1 : -1]
#else
#define STATIC_ASSERT(...)
#endif
struct JUTWarn {
JUTWarn& operator<<(const char*) { return *this; }
+2 -19
View File
@@ -1,6 +1,7 @@
#ifndef MSL_MATH_H_
#define MSL_MATH_H_
#include "MSL_C.PPCEABI.bare.H/MSL_Common/Src/float.h"
#include "dolphin/types.h"
extern "C" {
@@ -32,25 +33,7 @@ f64 fmod(f64, f64);
inline f32 fmodf(f32 f1, f32 f2) {
return fmod(f1, f2);
}
inline s32 fpclassify(f32 f) {
u32 var = *(u32*)&f;
switch (var & 0x7F800000) {
case 0x7F800000:
if ((var & 0x7FFFFF) != 0) {
return 1;
} else {
return 2;
}
case 0:
if ((var & 0x7FFFFF) != 0) {
return 5;
} else {
return 3;
}
default:
return 4;
}
}
f64 frexp(f64, s32*);
f64 ldexp(f64, s32);
f64 modf(f64, f64*);
+27
View File
@@ -0,0 +1,27 @@
#ifndef MSL_STRING_H_
#define MSL_STRING_H_
#include "Runtime.PPCEABI.H/__va_arg.h"
#include "dolphin/types.h"
// TODO: move to MSL_C.PPCEABI.bare.H/
extern "C" {
void memcpy(void*, const void*, s32);
void* memset(void* dest, int ch, u32 count);
char* strrchr(const char* s, int c);
char* strchr(const char* s, int c);
int strncmp(const char* s1, const char* s2, u32 n);
int strcmp(const char* s1, const char* s2);
int stricmp(const char*, const char*);
char* strcat(char* dest, const char* source);
char* strncpy(char* dest, const char* source, u32 n);
char* strcpy(char* dest, const char* source);
u32 strlen(const char* s);
int tolower(int);
int sprintf(char*, const char*, ...);
int printf(const char*, ...);
int snprintf(char*, u32, const char*, ...);
size_t vsnprintf(char* buffer, size_t buffer_size, const char* format, va_list args);
}
#endif