Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Start on 65430 #48

Merged
merged 20 commits into from
Jul 20, 2024
20 changes: 17 additions & 3 deletions include/eepmgr.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,19 @@
#define EEPMGR_H

#include "ultra64.h"
#include "unk.h"

#define EEPBUFFER_MAGIC 0x81317531

typedef struct EepBuffer {
/* 0x000 */ u8 data[0x3FA];
/* 0x3FA */ u16 unk3FA;
/* 0x3FC */ s32 magic;
} EepBuffer; // size = 0x400

typedef struct EepRequest {
/* 0x0 */ s16 type;
/* 0x4 */ u64* buffer;
/* 0x4 */ EepBuffer* buffer;
} EepRequest;

typedef struct EepMgr {
Expand All @@ -18,12 +26,18 @@ typedef struct EepMgr {
/* 0x048 */ EepRequest unk048;
/* 0x050 */ char unk_04C[0x68 - 0x50];
/* 0x068 */ OSThread thread;
/* 0x218 */ s32 unk218;
/* 0x218 */ UNK_PTR unk218;
/* 0x21C */ u8 type;
/* 0x21E */ u16 numBlocks;
/* 0x220 */ u64* cache;
/* 0x220 */ EepBuffer* cache;
/* 0x224 */ u8 cached;
/* 0x225 */ u8 operation;
} EepMgr; // size = 0x228


void eepmgr_Create(EepMgr* eepmgr, UNK_PTR arg1, s32 type, EepBuffer* cache, s32 id, s32 priority, void* stack);
s32 func_8007D508(EepMgr* eepmgr);
void eepmgr_SendRead(EepMgr* eepmgr, EepBuffer* buffer);
void eepmgr_SendWrite(EepMgr* eepmgr, EepBuffer* buffer);

#endif
79 changes: 54 additions & 25 deletions include/global.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,25 +15,22 @@

struct Input;

typedef struct Y65430UnkStruct {
/* 0x00 */ u32 magic;
/* 0x04 */ size_t unk04;
} Y65430UnkStruct; // size >= 0x08;

#define Y65430UnkStruct_MAGIC 0x434D5052 // 'CMPR'

typedef void (*Y65430UnkFunc)(void*, UNK_TYPE, size_t);

typedef struct MallocRecord {
/* 0x00 */ UNK_TYPE allocP;
/* 0x00 */ u32 allocP;
/* 0x04 */ UNK_TYPE requestSize;
/* 0x08 */ UNK_TYPE totalFree;
/* 0x0C */ UNK_TYPE totalAlloc;
/* 0x10 */ UNK_TYPE blockCnt;
} MallocRecord; // size >= 0x14

extern MallocRecord mallocRecord;

extern UNK_TYPE D_800DA83C;
extern UNK_TYPE D_8010DF40;
typedef struct Y65430UnkStruct {
/* 0x00 */ u32 magic;
/* 0x04 */ size_t unk04;
} Y65430UnkStruct; // size >= 0x08;

typedef struct Y511F0UnkStruct {
/* 0x0 */ uintptr_t unk0;
Expand All @@ -42,39 +39,71 @@ typedef struct Y511F0UnkStruct {
/* 0xC */ uintptr_t unkC;
} Y511F0UnkStruct; // size = 0x10

extern Y511F0UnkStruct D_800DA840[];
typedef struct Y511F0UnkStruct2 {
/* 0x0 */ char unk0[0x04];
/* 0x4 */ UNK_TYPE unk4;
} Y511F0UnkStruct2; // size >= 0x8

// 740F0
OSMesgQueue* func_800744B0(s32 arg0);
void func_8007451C(s32 arg0, OSMesgQueue* arg1);
void func_80074C88(UNK_PTR, struct Input*, s32);
// Functions

// malloc
void* func_80064DD0(u32 size);
// 511F0
Y511F0UnkStruct2* func_80050C8C(u16 arg0);

// 65430
Y65430UnkStruct* func_80064D1C(u32);

void* func_80064DD0(u32 size); // malloc?
void func_80064E84(Y65430UnkStruct*);
void func_80065528(void* arg0, void* arg1, s32 arg2);
void func_80065728(MallocRecord*, s32, s32);
void func_8006758C(void*, UNK_TYPE, size_t);
void func_800675D0(void*, UNK_TYPE, size_t, Y65430UnkFunc);

// 6DF40
void func_8006F500(void);

// 70160
void func_8006F560(Y65430UnkStruct*, Y65430UnkStruct*);

// 740F0
OSMesgQueue* func_800744B0(UNK_PTR arg0);
void func_800748B0(UNK_PTR arg0);
void func_8007451C(UNK_PTR arg0, OSMesgQueue* arg1);
void func_80074C88(UNK_PTR, struct Input*, s32);

// dma
void DmaMgr_RequestSync(void* ram, u32 vrom, u32 size);

// 80C50
void func_800800CC(MtxF* mfA, MtxF* mfB);
void func_80080914(MtxF* mf, f32, f32, f32, f32);
void func_80080824(MtxF* mf, f32 /*x*/, f32 /*y*/, f32 /*z*/);
void func_80080440(MtxF* mf, f32 /*x*/, f32 /*y*/);
void func_800804E0(MtxF* mf, f32 /*angle*/);
void func_800805C8(MtxF* mf, f32 /*angle*/);
void func_800806B0(MtxF* mf, f32 /*angle*/);
void func_80080798(MtxF* mf, f32 /*x*/, f32 /*y*/);
void func_80080C84(MtxF* mf, f32 /*x*/, f32 /*y*/, f32 /*z*/);
void func_80080824(MtxF* mf, f32 x, f32 y, f32 z);
void func_80080440(MtxF* mf, f32 x, f32 y);
void func_800804E0(MtxF* mf, f32 angle);
void func_800805C8(MtxF* mf, f32 angle);
void func_800806B0(MtxF* mf, f32 angle);
void func_80080798(MtxF* mf, f32 x, f32 y);
void func_80080C84(MtxF* mf, f32 x, f32 y, f32 z);

// loadfragment2
size_t Overlay_Load(uintptr_t vromStart, uintptr_t vromEnd, uintptr_t vramStart, uintptr_t vramEnd, void* allocatedRamAddr);
void* Overlay_AllocateAndLoad(uintptr_t vromStart, uintptr_t vromEnd, uintptr_t vramStart, uintptr_t vramEnd);

// Data

// 92170
extern MallocRecord mallocRecord;

// Bss

extern UNK_TYPE D_800DA83C;
extern Y511F0UnkStruct D_800DA840[];
extern MallocRecord D_800F8E58;
extern u8 D_800FAAF8;
extern u8 D_800FAB1C;
extern u8 D_800FAB20;
extern UNK_TYPE D_80108624;
extern UNK_TYPE D_80108628;
extern UNK_TYPE D_8010DF40;


#endif
54 changes: 54 additions & 0 deletions include/segment_symbols.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
#ifndef SEGMENT_SYMBOLS_H
#define SEGMENT_SYMBOLS_H

#include "ultra64.h"
#include "libc/stdint.h"

#define DECLARE_VRAM_SEGMENT(name) \
extern u8 name ## _VRAM[]; \
extern u8 name ## _VRAM_END[]

#define DECLARE_ROM_SEGMENT(name) \
extern u8 name ## _ROM_START[]; \
extern u8 name ## _ROM_END[]

#define DECLARE_DATA_SEGMENT(name) \
extern u8 name ## _DATA_START[]; \
extern u8 name ## _DATA_END[]; \
extern u8 name ## _DATA_SIZE[]

#define DECLARE_BSS_SEGMENT(name) \
extern u8 name ## _BSS_START[]; \
extern u8 name ## _BSS_END[]

#define DECLARE_SEGMENT(name) \
DECLARE_VRAM_SEGMENT(name); \
DECLARE_ROM_SEGMENT(name); \
DECLARE_DATA_SEGMENT(name); \
DECLARE_BSS_SEGMENT(name)

#define SEGMENT_VRAM_START(segment) (segment ## _VRAM)
#define SEGMENT_VRAM_END(segment) (segment ## _VRAM_END)
#define SEGMENT_VRAM_SIZE(segment) ((uintptr_t)SEGMENT_VRAM_END(segment) - (uintptr_t)SEGMENT_VRAM_START(segment))
#define SEGMENT_VRAM_RESOLVE_ADDR(segment, base, symbol) ((uintptr_t)(base) + (uintptr_t)&(symbol) - (uintptr_t)SEGMENT_VRAM_START(segment))

#define SEGMENT_ROM_START(segment) ((RomOffset)segment ## _ROM_START)
#define SEGMENT_ROM_END(segment) ((RomOffset)segment ## _ROM_END)
#define SEGMENT_ROM_SIZE(segment) (SEGMENT_ROM_END(segment) - SEGMENT_ROM_START(segment))
#define SEGMENT_ROM_SIZE_ALT(segment) ((size_t)(segment ## _ROM_END - segment ## _ROM_START))

#define SEGMENT_DATA_SIZE_CONST(segment) ((RomOffset)segment ## _DATA_SIZE)

#define SEGMENT_BSS_START(segment) (segment ## _BSS_START)
#define SEGMENT_BSS_END(segment) (segment ## _BSS_END)
#define SEGMENT_BSS_SIZE(segment) ((uintptr_t)SEGMENT_BSS_END(segment) - (uintptr_t)SEGMENT_BSS_START(segment))

DECLARE_SEGMENT(header);

DECLARE_SEGMENT(ipl3);

DECLARE_SEGMENT(entry);

DECLARE_SEGMENT(main);

#endif
6 changes: 6 additions & 0 deletions include/ys64thread.h
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
#ifndef YS64_THREAD_H
#define YS64_THREAD_H

#define Y_THREAD_ID_IDLE 1
#define Y_THREAD_ID_FAULT 2
#define Y_THREAD_ID_MAIN 3
#define Y_THREAD_ID_DMA 18
#define Y_THREAD_ID_EEPMGR 20

#define Y_PRIORITY_IDLE 10
#define Y_PRIORITY_MAIN 10
#define Y_PRIORITY_EEPMGR 16
#define Y_PRIORITY_DMA 18
#define Y_PRIORITY_FAULT OS_PRIORITY_APPMAX

Expand Down
21 changes: 21 additions & 0 deletions linker_scripts/us/symbol_addrs.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
entrypoint = 0x80000400;

Idle_ThreadEntry = 0x80067284;
Idle_InitVideo = 0x80067390;
bootclear = 0x80067400;
bootproc = 0x8006743C;
Main_ThreadEntry = 0x80069000;

Fault_SetFramebuffer = 0x80071250; // type:func
Fault_Init = 0x8007127C; // type:func
Expand Down Expand Up @@ -103,6 +107,7 @@ aprintf = 0x80082174;
csleep = 0x800821A0;

// data

mallocRecord = 0x800A65AC; // type:MallocRecord size:0x14

fault_exit = 0x800A8000;
Expand All @@ -125,3 +130,19 @@ gOverlayLogSeverity = 0x800AA390; // type:s32
// rodata

// bss

gEepMgr = 0x800F95D0;
sEepBuff = 0x800F97F8;
sEepStack = 0x800F9FF8;
sEepCache = 0x800FA2F8;
sEepStackInfo = 0x800FAB00;
sBootStack = 0x800FB018;
sBootStackInfo = 0x800FD018;
sIdleThread = 0x800FD038;
sIdleStack = 0x800FD1E8;
sIdleStackInfo = 0x800FD3E8;
sMainThread = 0x800FD408;
sMainStack = 0x800FD5B8;
sMainStackInfo = 0x800FFCB8;
sPiMgrCmdQueue = 0x80100490;
sPiMgrCmdBuff = 0x80100470;
Loading