Skip to content

Commit

Permalink
Copy dolphin/os progress from TP decomp
Browse files Browse the repository at this point in the history
  • Loading branch information
LagoLunatic committed Jul 7, 2024
1 parent fcbfe1e commit 09e3562
Show file tree
Hide file tree
Showing 47 changed files with 6,696 additions and 153 deletions.
14 changes: 7 additions & 7 deletions configure.py
Original file line number Diff line number Diff line change
Expand Up @@ -965,22 +965,22 @@ def JSystemLib(lib_name, objects):
Object(NonMatching, "dolphin/os/OS.c"),
Object(NonMatching, "dolphin/os/OSAlarm.c"),
Object(NonMatching, "dolphin/os/OSAlloc.c"),
Object(NonMatching, "dolphin/os/OSArena.c"),
Object(NonMatching, "dolphin/os/OSAudioSystem.c"),
Object(Matching, "dolphin/os/OSArena.c"),
Object(Matching, "dolphin/os/OSAudioSystem.c"),
Object(NonMatching, "dolphin/os/OSCache.c"),
Object(NonMatching, "dolphin/os/OSContext.c"),
Object(NonMatching, "dolphin/os/OSError.c"),
Object(NonMatching, "dolphin/os/OSFont.c"),
Object(NonMatching, "dolphin/os/OSInterrupt.c"),
Object(NonMatching, "dolphin/os/OSLink.c"),
Object(NonMatching, "dolphin/os/OSMessage.c"),
Object(Matching, "dolphin/os/OSInterrupt.c"),
Object(Matching, "dolphin/os/OSLink.c"),
Object(Matching, "dolphin/os/OSMessage.c"),
Object(NonMatching, "dolphin/os/OSMemory.c"),
Object(NonMatching, "dolphin/os/OSMutex.c"),
Object(Matching, "dolphin/os/OSMutex.c"),
Object(NonMatching, "dolphin/os/OSReboot.c"),
Object(NonMatching, "dolphin/os/OSReset.c"),
Object(NonMatching, "dolphin/os/OSResetSW.c"),
Object(NonMatching, "dolphin/os/OSRtc.c"),
Object(NonMatching, "dolphin/os/OSSync.c"),
Object(Matching, "dolphin/os/OSSync.c"),
Object(NonMatching, "dolphin/os/OSThread.c"),
Object(NonMatching, "dolphin/os/OSTime.c"),
Object(NonMatching, "dolphin/os/__ppc_eabi_init.cpp"),
Expand Down
5 changes: 2 additions & 3 deletions include/DynamicLink.h
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
#ifndef DYNAMICLINK_H
#define DYNAMICLINK_H

#include "dolphin/types.h"
#include "dolphin/os/OS.h"

typedef struct OSModuleInfo OSModuleInfo;
class JKRArchive;
class JKRFileCache;
class mDoDvdThd_callback_c;
Expand Down Expand Up @@ -57,7 +56,7 @@ struct DynamicModuleControl : DynamicModuleControlBase {
static bool initialize();
static bool callback(void*);

/* 0x10 */ OSModuleInfo* mModule;
/* 0x10 */ OSModuleHeader* mModule;
/* 0x14 */ void* mBss;
/* 0x18 */ u32 unk_24;
/* 0x1c */ const char* mName;
Expand Down
23 changes: 23 additions & 0 deletions include/dolphin/dsp.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,29 @@ extern "C" {
#define DSP_TASK_STATE_YIELD 2
#define DSP_TASK_STATE_DONE 3

#define DSP_MAILBOX_IN_HI (0)
#define DSP_MAILBOX_IN_LO (1)
#define DSP_MAILBOX_OUT_HI (2)
#define DSP_MAILBOX_OUT_LO (3)
#define DSP_CONTROL_STATUS (5)

#define DSP_ARAM_SIZE (9)
#define DSP_ARAM_MODE (11)
#define DSP_ARAM_REFRESH (13)
#define DSP_ARAM_DMA_MM_HI (16) // Main mem address
#define DSP_ARAM_DMA_MM_LO (17)
#define DSP_ARAM_DMA_ARAM_HI (18) // ARAM address
#define DSP_ARAM_DMA_ARAM_LO (19)
#define DSP_ARAM_DMA_SIZE_HI (20) // DMA buffer size
#define DSP_ARAM_DMA_SIZE_LO (21)

#define DSP_DMA_START_HI (24) // DMA start address
#define DSP_DMA_START_LO (25)
#define DSP_DMA_CONTROL_LEN (27)
#define DSP_DMA_BYTES_LEFT (29)

#define DSP_DMA_START_FLAG (0x8000) // set to start DSP

typedef void (*DSPCallback)(void* task);

typedef struct STRUCT_DSP_TASK {
Expand Down
3 changes: 3 additions & 0 deletions include/dolphin/dvd/dvdfs.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
#ifndef DVDFS_H
#define DVDFS_H

#include "dolphin/types.h"

extern u32 __DVDLongFileNameFlag;

#endif /* DVDFS_H */
109 changes: 109 additions & 0 deletions include/dolphin/exi/EXIBios.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
#ifndef EXIBIOS_H
#define EXIBIOS_H

#include "dolphin/types.h"

#ifdef __cplusplus
extern "C" {
#endif

typedef struct OSContext OSContext;

vu32 __EXIRegs[16] : 0xCC006800;

#define EXI_MEMORY_CARD_59 0x00000004
#define EXI_MEMORY_CARD_123 0x00000008
#define EXI_MEMORY_CARD_251 0x00000010
#define EXI_MEMORY_CARD_507 0x00000020

#define EXI_MEMORY_CARD_1019 0x00000040
#define EXI_MEMORY_CARD_2043 0x00000080

#define EXI_MEMORY_CARD_1019A 0x00000140
#define EXI_MEMORY_CARD_1019B 0x00000240
#define EXI_MEMORY_CARD_1019C 0x00000340
#define EXI_MEMORY_CARD_1019D 0x00000440
#define EXI_MEMORY_CARD_1019E 0x00000540
#define EXI_MEMORY_CARD_1019F 0x00000640
#define EXI_MEMORY_CARD_1019G 0x00000740

#define EXI_MEMORY_CARD_2043A 0x00000180
#define EXI_MEMORY_CARD_2043B 0x00000280
#define EXI_MEMORY_CARD_2043C 0x00000380
#define EXI_MEMORY_CARD_2043D 0x00000480
#define EXI_MEMORY_CARD_2043E 0x00000580
#define EXI_MEMORY_CARD_2043F 0x00000680
#define EXI_MEMORY_CARD_2043G 0x00000780

#define EXI_USB_ADAPTER 0x01010000
#define EXI_NPDP_GDEV 0x01020000

#define EXI_MODEM 0x02020000
#define EXI_ETHER 0x04020200
#define EXI_ETHER_VIEWER 0x04220001
#define EXI_STREAM_HANGER 0x04130000

#define EXI_MARLIN 0x03010000

#define EXI_IS_VIEWER 0x05070000

#define EXI_FREQ_1M 0
#define EXI_FREQ_2M 1
#define EXI_FREQ_4M 2
#define EXI_FREQ_8M 3
#define EXI_FREQ_16M 4
#define EXI_FREQ_32M 5

#define EXI_READ 0
#define EXI_WRITE 1

#define EXI_STATE_IDLE 0x00
#define EXI_STATE_DMA 0x01
#define EXI_STATE_IMM 0x02
#define EXI_STATE_BUSY (EXI_STATE_DMA | EXI_STATE_IMM)
#define EXI_STATE_SELECTED 0x04
#define EXI_STATE_ATTACHED 0x08
#define EXI_STATE_LOCKED 0x10

typedef void (*EXICallback)(s32 chan, OSContext* context);

typedef struct EXIControl {
EXICallback exiCallback;
EXICallback tcCallback;
EXICallback extCallback;
vu32 state;
int immLen;
u8* immBuf;
u32 dev;
u32 id;
s32 idTime;
int items;
struct {
u32 dev;
EXICallback callback;
} queue[3];
} EXIControl;

s32 EXIImm(s32 chan, void* buf, s32 len, u32 type, EXICallback callback);
s32 EXIImmEx(s32 chan, void* buf, s32 len, u32 mode);
BOOL EXIDma(s32 chan, void* buf, s32 len, u32 type, EXICallback callback);
BOOL EXISync(s32 chan);
EXICallback EXISetExiCallback(s32 chan, EXICallback exiCallback);
BOOL EXIProbe(s32 chan);
s32 EXIProbeEx(s32 chan);
BOOL EXIAttach(s32 chan, EXICallback extCallback);
BOOL EXIDetach(s32 chan);
BOOL EXISelect(s32 chan, u32 dev, u32 freq);
BOOL EXIDeselect(s32 chan);
void EXIInit(void);
BOOL EXILock(s32 chan, u32 dev, EXICallback unlockedCallback);
BOOL EXIUnlock(s32 chan);
u32 EXIGetState(s32 chan);
static void UnlockedHandler(s32 chan, OSContext* context);
s32 EXIGetID(s32 chan, u32 dev, u32* id);

#ifdef __cplusplus
};
#endif

#endif /* EXIBIOS_H */
5 changes: 5 additions & 0 deletions include/dolphin/exi/EXIUart.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#ifndef EXIUART_H
#define EXIUART_H


#endif /* EXIUART_H */
22 changes: 9 additions & 13 deletions include/dolphin/os/OS.h
Original file line number Diff line number Diff line change
Expand Up @@ -88,11 +88,16 @@ extern u8 __OSReport_Warning_disable;
extern u8 __OSReport_System_disable;
extern u8 __OSReport_enable;

extern BOOL __OSIsGcam;

extern u32 BOOT_REGION_START : 0x8044babc;
extern u32 BOOT_REGION_END : 0x812FDFEC;

void OSReportInit__Fv(void); // needed for inline asm

u8* OSGetStackPointer(void);
void __OSFPRInit(void);
static void InquiryCallback(u32 param_0, DVDCommandBlock* param_1);
static void InquiryCallback(s32 param_0, DVDCommandBlock* param_1);
void OSInit(void);
static void OSExceptionInit(void);
void __OSDBIntegrator(void);
Expand Down Expand Up @@ -147,7 +152,7 @@ inline void OSf32tou8(f32* f, u8* out) {
*out = __OSf32tou8(*f);
}

inline void OSInitFastCast(void) {
static inline void OSInitFastCast(void) {
// clang-format off
asm {
li r3, 4
Expand Down Expand Up @@ -178,16 +183,6 @@ typedef struct OSBootInfo {
/* 0x3C */ u32 fst_max_length;
} OSBootInfo;

typedef struct {
BOOL valid;
u32 restartCode;
u32 bootDol;
void* regionStart;
void* regionEnd;
BOOL argsUseDefault;
void* argsAddr; // valid only when argsUseDefault = FALSE
} OSExecParams;

typedef struct BI2Debug {
/* 0x00 */ s32 debugMonSize;
/* 0x04 */ s32 simMemSize;
Expand Down Expand Up @@ -234,7 +229,7 @@ struct GLOBAL_MEMORY {
u8 padding_0x30e0[4];
u32 field_0x30e4; /* __OSPADButton */
u8 padding_0x30ec[8];
u32 field_0x30f0; /* DOL Execute Parameters */
OSExecParams* field_0x30f0; /* DOL Execute Parameters */
u8 padding_0x30f4[12];
u32 field_0x3100; /* Physical MEM1 size */
u32 field_0x3104; /* Simulated MEM1 size */
Expand Down Expand Up @@ -292,6 +287,7 @@ struct GLOBAL_MEMORY {
#define OSUncachedToCached(ucaddr) ((void*)((u8*)(ucaddr) - (OS_BASE_UNCACHED - OS_BASE_CACHED)))

extern OSTime __OSStartTime;
extern BOOL __OSInIPL;

#ifdef __cplusplus
};
Expand Down
17 changes: 13 additions & 4 deletions include/dolphin/os/OSExec.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,23 @@
extern "C" {
#endif

typedef struct {
/* 0x00 */ BOOL valid;
/* 0x04 */ u32 restartCode;
/* 0x08 */ u32 bootDol;
/* 0x0C */ void* regionStart;
/* 0x10 */ void* regionEnd;
/* 0x18 */ BOOL argsUseDefault;
/* 0x14 */ void* argsAddr; // valid only when argsUseDefault = FALSE
} OSExecParams;

static s32 PackArgs(void* param_0, u32 param_1, void* param_2);
static void Run(void);
static void Run(int param_0);
static void ReadDisc(void* param_0, s32 param_1, s32 param_2);
static void Callback(void);
void __OSGetExecParams(void* param_0);
static void GetApploaderPosition(void);
void __OSGetExecParams(OSExecParams* param_0);
void __OSBootDolSimple(u32 param_0, u32 param_1, void* param_2, void* param_3, s32 param_4, u32 param_5, void* param_6);
void __OSBootDol(s32 param_0, u32 param_1, s32 param_2);
void __OSBootDol(s32 param_0, u32 param_1, char** param_2);

#ifdef __cplusplus
};
Expand Down
40 changes: 38 additions & 2 deletions include/dolphin/os/OSFont.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,45 @@
extern "C" {
#endif

static u32 GetFontCode(s16 param_0, u32 param_1);
typedef enum {
OS_FONT_ENCODE_ANSI,
OS_FONT_ENCODE_SJIS,
OS_FONT_ENCODE_2,
OS_FONT_ENCODE_UTF8,
OS_FONT_ENCODE_UTF16,
OS_FONT_ENCODE_UTF32,
OS_FONT_ENCODE_MAX
} OSFontEncode;

typedef struct OSFontHeader {
/* 0x00 */ u16 type;
/* 0x02 */ u16 firstChar;
/* 0x04 */ u16 lastChar;
/* 0x06 */ u16 invalidChar;
/* 0x08 */ u16 ascent;
/* 0x0A */ u16 descent;
/* 0x0C */ u16 width;
/* 0x0E */ u16 leading;
/* 0x10 */ u16 cellWidth;
/* 0x12 */ u16 cellHeight;
/* 0x14 */ u32 sheetSize;
/* 0x18 */ u16 sheetFormat;
/* 0x1A */ u16 sheetNumCol;
/* 0x1C */ u16 sheetNumRow;
/* 0x1E */ u16 sheetWidth;
/* 0x20 */ u16 sheetHeight;
/* 0x22 */ u16 widthTableOfs;
/* 0x24 */ u32 sheetImageOfs;
/* 0x28 */ u32 sheetFullSize;
/* 0x2C */ u8 c0;
/* 0x2D */ u8 c1;
/* 0x2E */ u8 c2;
/* 0x2F */ u8 c3;
} OSFontHeader;

static u32 GetFontCode(u16 param_0, u16 param_1);
u16 OSGetFontEncode(void);
static char* ParseStringS(s16 param_0, char* param_1, void* param_2, u32* param_3, u32 param_4, void* param_5);
static const u8* ParseStringS(u16 encode, const u8* str, OSFontHeader** fontOut, u32* codeOut);

#ifdef __cplusplus
};
Expand Down
Loading

0 comments on commit 09e3562

Please sign in to comment.