Skip to content

Commit

Permalink
Yoink most of EXIBios.c
Browse files Browse the repository at this point in the history
ty prime decomp - couple funcs to adjust bc P2 version is different
  • Loading branch information
HeartPiece44 committed Sep 26, 2023
1 parent 7559314 commit 5ef1017
Show file tree
Hide file tree
Showing 4 changed files with 684 additions and 1,646 deletions.
2 changes: 2 additions & 0 deletions include/Dolphin/OS/OSExpansion.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ s32 EXIProbeEx(s32 channel);
s32 EXIGetType(s32 channel, u32 dev, u32* type);
char* EXIGetTypeString(u32 type);

u32 __OSGetDIConfig(void);

//////////////////////////////////

/////////// EXI DEFINES //////////
Expand Down
3 changes: 3 additions & 0 deletions include/Dolphin/OS/OSUtil.h
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,9 @@ void OSTicksToCalendarTime(OSTime ticks, OSCalendarTime* timeDate);
#define OSCachedToUncached(caddr) ((void*)((u8*)(caddr) + (OS_BASE_UNCACHED - OS_BASE_CACHED)))
#define OSUncachedToCached(ucaddr) ((void*)((u8*)(ucaddr) - (OS_BASE_UNCACHED - OS_BASE_CACHED)))

// Other useful addresses.
vu16 __OSDeviceCode AT_ADDRESS(OS_BASE_CACHED | 0x30E6);

//////////////////////////////////

#ifdef __cplusplus
Expand Down
48 changes: 45 additions & 3 deletions include/Dolphin/exi.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,54 @@

#include "types.h"
#include "Dolphin/os.h"
#include "Dolphin/hw_regs.h"

#ifdef __cplusplus
extern "C" {
#endif // ifdef __cplusplus

#define EXI_TX 0x800400u
#define EXI_MAGIC 0xa5ff005a
/////////// EXI DEFINES //////////
// Useful numbers.
#define EXI_TX 0x800400u
#define EXI_MAGIC 0xa5ff005a
#define EXI_MAX_DEV 3
#define EXI_MAX_CHAN 3
#define EXI_REG_MAX 5

// Useful macros.
#define EXI_0CR(tstart, dma, rw, tlen) ((((u32)(tstart)) << 0) | (((u32)(dma)) << 1) | (((u32)(rw)) << 2) | (((u32)(tlen)) << 4))

#define EXIREG(chan, idx) (__EXIRegs[((chan)*EXI_REG_MAX) + (idx)])

#define EXI_CPR_CS(x) ((1u << (x)) << 7)
#define EXI_CPR_CLK(x) ((x) << 4)

s32 __EXIProbeStartTime[2] AT_ADDRESS(OS_BASE_CACHED | 0x30C0);

//////////////////////////////////

/////////// EXI STRUCTS //////////
// Struct for handling expansion information (size 0x40).
typedef struct EXIControl {
EXICallback exiCallback; // _00
EXICallback tcCallback; // _04
EXICallback extCallback; // _08
vu32 state; // _0C
int immLen; // _10
u8* immBuf; // _14
u32 dev; // _18
u32 id; // _1C
s32 idTime; // _20
int items; // _24
struct {
u32 dev;
EXICallback callback;
} queue[EXI_MAX_DEV]; // _28
} EXIControl;

//////////////////////////////////

////////// EXI FUNCTIONS /////////
void EXIInit();

BOOL EXIImm(s32 channel, void* buffer, s32 length, u32 type, EXICallback callback);
Expand All @@ -23,13 +63,15 @@ BOOL EXIAttach(s32 channel, EXICallback callback);
BOOL EXIDetach(s32 channel);
BOOL EXISelect(s32 channel, u32 device, u32 frequency);
BOOL EXIDeselect(s32 channel);
// sic

void EXIIntrruptHandler(__OSInterrupt interrupt, OSContext* context);
BOOL EXILock(s32 channel, u32 device, EXICallback callback);
BOOL EXIUnlock(s32 channel);
u32 EXIGetState(s32 channel);
s32 EXIGetID(s32 channel, u32 device, u32* id);

//////////////////////////////////

#ifdef __cplusplus
};
#endif // ifdef __cplusplus
Expand Down
Loading

0 comments on commit 5ef1017

Please sign in to comment.