mirror of
https://github.com/zeldaret/oot.git
synced 2024-11-25 09:45:02 +00:00
Use intptr types in a few specific boot files (#1301)
* Add stdint.h with intptr_t and uinptr_t * Use intptr types in dmamgr and yaz0 * Use intptr types in stackcheck * Use intptr types in idle * Run formatter * Use pointers for StackEntry (+ minor type fix)
This commit is contained in:
parent
2f07874a5f
commit
7564502b0b
10 changed files with 78 additions and 51 deletions
|
@ -22,23 +22,23 @@ void Idle_ThreadEntry(void* arg);
|
|||
void ViConfig_UpdateVi(u32 black);
|
||||
void ViConfig_UpdateBlack(void);
|
||||
s32 DmaMgr_CompareName(const char* name1, const char* name2);
|
||||
s32 DmaMgr_DmaRomToRam(u32 rom, void* ram, u32 size);
|
||||
s32 DmaMgr_DmaRomToRam(uintptr_t rom, void* ram, u32 size);
|
||||
s32 DmaMgr_DmaHandler(OSPiHandle* pihandle, OSIoMesg* mb, s32 direction);
|
||||
void DmaMgr_Error(DmaRequest* req, const char* file, const char* errorName, const char* errorDesc);
|
||||
const char* DmaMgr_GetFileNameImpl(u32 vrom);
|
||||
const char* DmaMgr_GetFileName(u32 vrom);
|
||||
const char* DmaMgr_GetFileNameImpl(uintptr_t vrom);
|
||||
const char* DmaMgr_GetFileName(uintptr_t vrom);
|
||||
void DmaMgr_ProcessMsg(DmaRequest* req);
|
||||
void DmaMgr_ThreadEntry(void* arg);
|
||||
s32 DmaMgr_SendRequestImpl(DmaRequest* req, void* ram, u32 vrom, u32 size, u32 unk, OSMesgQueue* queue, OSMesg msg);
|
||||
s32 DmaMgr_SendRequest0(void* ram, u32 vrom, u32 size);
|
||||
s32 DmaMgr_SendRequestImpl(DmaRequest* req, void* ram, uintptr_t vrom, u32 size, u32 unk, OSMesgQueue* queue, OSMesg msg);
|
||||
s32 DmaMgr_SendRequest0(void* ram, uintptr_t vrom, u32 size);
|
||||
void DmaMgr_Init(void);
|
||||
s32 DmaMgr_SendRequest2(DmaRequest* req, void* ram, u32 vrom, u32 size, u32 unk5, OSMesgQueue* queue, OSMesg msg,
|
||||
s32 DmaMgr_SendRequest2(DmaRequest* req, void* ram, uintptr_t vrom, u32 size, u32 unk5, OSMesgQueue* queue, OSMesg msg,
|
||||
const char* file, s32 line);
|
||||
s32 DmaMgr_SendRequest1(void* ram, u32 vrom, u32 size, const char* file, s32 line);
|
||||
s32 DmaMgr_SendRequest1(void* ram, uintptr_t vrom, u32 size, const char* file, s32 line);
|
||||
void* Yaz0_FirstDMA(void);
|
||||
void* Yaz0_NextDMA(u8* curSrcPos);
|
||||
void Yaz0_DecompressImpl(Yaz0Header* hdr, u8* dst);
|
||||
void Yaz0_Decompress(u32 romStart, u8* dst, u32 size);
|
||||
void Yaz0_Decompress(uintptr_t romStart, u8* dst, u32 size);
|
||||
void Locale_Init(void);
|
||||
void Locale_ResetRegion(void);
|
||||
u32 func_80001F48(void);
|
||||
|
@ -56,7 +56,7 @@ void Mio0_Decompress(Yaz0Header* hdr, u8* dst);
|
|||
void StackCheck_Init(StackEntry* entry, void* stackTop, void* stackBottom, u32 initValue, s32 minSpace,
|
||||
const char* name);
|
||||
void StackCheck_Cleanup(StackEntry* entry);
|
||||
s32 StackCheck_GetState(StackEntry* entry);
|
||||
u32 StackCheck_GetState(StackEntry* entry);
|
||||
u32 StackCheck_CheckAll(void);
|
||||
u32 StackCheck_Check(StackEntry* entry);
|
||||
f32 LogUtils_CheckFloatRange(const char* exp, s32 line, const char* valueName, f32 value, const char* minName, f32 min,
|
||||
|
|
|
@ -5,8 +5,6 @@
|
|||
|
||||
typedef unsigned long size_t;
|
||||
|
||||
typedef unsigned int uintptr_t;
|
||||
|
||||
#ifdef __GNUC__
|
||||
#define offsetof(structure, member) __builtin_offsetof (structure, member)
|
||||
#else
|
||||
|
|
26
include/libc/stdint.h
Normal file
26
include/libc/stdint.h
Normal file
|
@ -0,0 +1,26 @@
|
|||
#ifndef STDINT_H
|
||||
#define STDINT_H
|
||||
|
||||
typedef signed int intptr_t;
|
||||
typedef unsigned int uintptr_t;
|
||||
|
||||
#define INT8_MIN (-0x80)
|
||||
#define INT16_MIN (-0x8000)
|
||||
#define INT32_MIN (-0x80000000)
|
||||
#define INT64_MIN (-0x8000000000000000)
|
||||
|
||||
#define INT8_MAX 0x7F
|
||||
#define INT16_MAX 0x7FFF
|
||||
#define INT32_MAX 0x7FFFFFFF
|
||||
#define INT64_MAX 0x7FFFFFFFFFFFFFFF
|
||||
|
||||
#define UINT8_MAX 0xFF
|
||||
#define UINT16_MAX 0xFFFF
|
||||
#define UINT32_MAX 0xFFFFFFFF
|
||||
#define UINT64_MAX 0xFFFFFFFFFFFFFFFF
|
||||
|
||||
#define INTPTR_MIN INT32_MIN
|
||||
#define INTPTR_MAX INT32_MAX
|
||||
#define UINTPTR_MAX UINT32_MAX
|
||||
|
||||
#endif
|
|
@ -7,6 +7,7 @@
|
|||
#include "libc/stdarg.h"
|
||||
#include "libc/stdbool.h"
|
||||
#include "libc/stddef.h"
|
||||
#include "libc/stdint.h"
|
||||
#include "libc/stdlib.h"
|
||||
#include "libc/math.h"
|
||||
|
||||
|
|
|
@ -1509,8 +1509,8 @@ typedef struct {
|
|||
typedef struct StackEntry {
|
||||
/* 0x00 */ struct StackEntry* next;
|
||||
/* 0x04 */ struct StackEntry* prev;
|
||||
/* 0x08 */ u32 head;
|
||||
/* 0x0C */ u32 tail;
|
||||
/* 0x08 */ u32* head;
|
||||
/* 0x0C */ u32* tail;
|
||||
/* 0x10 */ u32 initValue;
|
||||
/* 0x14 */ s32 minSpace;
|
||||
/* 0x18 */ const char* name;
|
||||
|
|
|
@ -4,21 +4,21 @@
|
|||
#include "ultra64.h"
|
||||
|
||||
typedef struct {
|
||||
/* 0x00 */ u32 vromAddr; // VROM address (source)
|
||||
/* 0x04 */ void* dramAddr; // DRAM address (destination)
|
||||
/* 0x08 */ u32 size; // File Transfer size
|
||||
/* 0x0C */ const char* filename; // Filename for debugging
|
||||
/* 0x10 */ s32 line; // Line for debugging
|
||||
/* 0x14 */ s32 unk_14;
|
||||
/* 0x00 */ uintptr_t vromAddr; // VROM address (source)
|
||||
/* 0x04 */ void* dramAddr; // DRAM address (destination)
|
||||
/* 0x08 */ u32 size; // File Transfer size
|
||||
/* 0x0C */ const char* filename; // Filename for debugging
|
||||
/* 0x10 */ s32 line; // Line for debugging
|
||||
/* 0x14 */ s32 unk_14;
|
||||
/* 0x18 */ OSMesgQueue* notifyQueue; // Message queue for the notification message
|
||||
/* 0x1C */ OSMesg notifyMsg; // Completion notification message
|
||||
/* 0x1C */ OSMesg notifyMsg; // Completion notification message
|
||||
} DmaRequest; // size = 0x20
|
||||
|
||||
typedef struct {
|
||||
/* 0x00 */ u32 vromStart;
|
||||
/* 0x04 */ u32 vromEnd;
|
||||
/* 0x08 */ u32 romStart;
|
||||
/* 0x0C */ u32 romEnd;
|
||||
/* 0x00 */ uintptr_t vromStart;
|
||||
/* 0x04 */ uintptr_t vromEnd;
|
||||
/* 0x08 */ uintptr_t romStart;
|
||||
/* 0x0C */ uintptr_t romEnd;
|
||||
} DmaEntry;
|
||||
|
||||
#endif
|
||||
|
|
|
@ -23,7 +23,7 @@ void Main_ThreadEntry(void* arg) {
|
|||
DmaMgr_Init();
|
||||
osSyncPrintf("codeセグメントロード中...");
|
||||
time = osGetTime();
|
||||
DmaMgr_SendRequest1(_codeSegmentStart, (u32)_codeSegmentRomStart, _codeSegmentRomEnd - _codeSegmentRomStart,
|
||||
DmaMgr_SendRequest1(_codeSegmentStart, (uintptr_t)_codeSegmentRomStart, _codeSegmentRomEnd - _codeSegmentRomStart,
|
||||
"../idle.c", 238);
|
||||
time -= osGetTime();
|
||||
osSyncPrintf("\rcodeセグメントロード中...完了\n");
|
||||
|
@ -46,7 +46,8 @@ void Idle_ThreadEntry(void* arg) {
|
|||
osSyncPrintf("ダイナミックバッファのサイズは %d キロバイトです\n", 0x92);
|
||||
osSyncPrintf("FIFOバッファのサイズは %d キロバイトです\n", 0x60);
|
||||
osSyncPrintf("YIELDバッファのサイズは %d キロバイトです\n", 3);
|
||||
osSyncPrintf("オーディオヒープのサイズは %d キロバイトです\n", ((s32)gSystemHeap - (s32)gAudioHeap) / 1024);
|
||||
osSyncPrintf("オーディオヒープのサイズは %d キロバイトです\n",
|
||||
((intptr_t)gSystemHeap - (intptr_t)gAudioHeap) / 1024);
|
||||
osSyncPrintf(VT_RST);
|
||||
|
||||
osCreateViManager(OS_PRIORITY_VIMGR);
|
||||
|
|
|
@ -12,8 +12,8 @@ void StackCheck_Init(StackEntry* entry, void* stackTop, void* stackBottom, u32 i
|
|||
if (entry == NULL) {
|
||||
sStackInfoListStart = NULL;
|
||||
} else {
|
||||
entry->head = (u32)stackTop;
|
||||
entry->tail = (u32)stackBottom;
|
||||
entry->head = stackTop;
|
||||
entry->tail = stackBottom;
|
||||
entry->initValue = initValue;
|
||||
entry->minSpace = minSpace;
|
||||
entry->name = name;
|
||||
|
@ -39,8 +39,8 @@ void StackCheck_Init(StackEntry* entry, void* stackTop, void* stackBottom, u32 i
|
|||
}
|
||||
|
||||
if (entry->minSpace != -1) {
|
||||
addr = (u32*)entry->head;
|
||||
while ((u32)addr < entry->tail) {
|
||||
addr = entry->head;
|
||||
while (addr < entry->tail) {
|
||||
*addr++ = entry->initValue;
|
||||
}
|
||||
}
|
||||
|
@ -72,20 +72,20 @@ void StackCheck_Cleanup(StackEntry* entry) {
|
|||
}
|
||||
}
|
||||
|
||||
s32 StackCheck_GetState(StackEntry* entry) {
|
||||
u32 StackCheck_GetState(StackEntry* entry) {
|
||||
u32* last;
|
||||
u32 used;
|
||||
u32 free;
|
||||
s32 ret;
|
||||
u32 ret;
|
||||
|
||||
for (last = (u32*)entry->head; (u32)last < entry->tail; last++) {
|
||||
for (last = entry->head; last < entry->tail; last++) {
|
||||
if (entry->initValue != *last) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
used = entry->tail - (u32)last;
|
||||
free = (u32)last - entry->head;
|
||||
used = (uintptr_t)entry->tail - (uintptr_t)last;
|
||||
free = (uintptr_t)last - (uintptr_t)entry->head;
|
||||
|
||||
if (free == 0) {
|
||||
ret = STACK_STATUS_OVERFLOW;
|
||||
|
@ -103,7 +103,7 @@ s32 StackCheck_GetState(StackEntry* entry) {
|
|||
osSyncPrintf(VT_RST);
|
||||
|
||||
if (ret != STACK_STATUS_OK) {
|
||||
LogUtils_LogHexDump((void*)entry->head, entry->tail - entry->head);
|
||||
LogUtils_LogHexDump(entry->head, (uintptr_t)entry->tail - (uintptr_t)entry->head);
|
||||
}
|
||||
|
||||
return ret;
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
u8 sYaz0DataBuffer[0x400];
|
||||
u8* sYaz0DataBufferEnd;
|
||||
u32 sYaz0CurRomStart;
|
||||
uintptr_t sYaz0CurRomStart;
|
||||
u32 sYaz0CurSize;
|
||||
u8* sYaz0MaxPtr;
|
||||
|
||||
|
@ -92,7 +92,7 @@ void Yaz0_DecompressImpl(Yaz0Header* hdr, u8* dst) {
|
|||
} while (dst != dstEnd);
|
||||
}
|
||||
|
||||
void Yaz0_Decompress(u32 romStart, u8* dst, u32 size) {
|
||||
void Yaz0_Decompress(uintptr_t romStart, u8* dst, u32 size) {
|
||||
sYaz0CurRomStart = romStart;
|
||||
sYaz0CurSize = size;
|
||||
sYaz0DataBufferEnd = sYaz0DataBuffer + sizeof(sYaz0DataBuffer);
|
||||
|
|
|
@ -43,7 +43,7 @@ s32 DmaMgr_CompareName(const char* name1, const char* name2) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
s32 DmaMgr_DmaRomToRam(u32 rom, void* ram, u32 size) {
|
||||
s32 DmaMgr_DmaRomToRam(uintptr_t rom, void* ram, u32 size) {
|
||||
OSIoMesg ioMsg;
|
||||
OSMesgQueue queue;
|
||||
OSMesg msg;
|
||||
|
@ -143,7 +143,7 @@ s32 DmaMgr_DmaHandler(OSPiHandle* pihandle, OSIoMesg* mb, s32 direction) {
|
|||
return ret;
|
||||
}
|
||||
|
||||
void DmaMgr_DmaFromDriveRom(void* ram, u32 rom, u32 size) {
|
||||
void DmaMgr_DmaFromDriveRom(void* ram, uintptr_t rom, u32 size) {
|
||||
OSPiHandle* handle = osDriveRomInit();
|
||||
OSMesgQueue queue;
|
||||
OSMesg msg;
|
||||
|
@ -165,7 +165,7 @@ void DmaMgr_DmaFromDriveRom(void* ram, u32 rom, u32 size) {
|
|||
}
|
||||
|
||||
void DmaMgr_Error(DmaRequest* req, const char* file, const char* errorName, const char* errorDesc) {
|
||||
u32 vrom = req->vromAddr;
|
||||
uintptr_t vrom = req->vromAddr;
|
||||
void* ram = req->dramAddr;
|
||||
u32 size = req->size;
|
||||
char buff1[80];
|
||||
|
@ -197,7 +197,7 @@ void DmaMgr_Error(DmaRequest* req, const char* file, const char* errorName, cons
|
|||
Fault_AddHungupAndCrashImpl(buff1, buff2);
|
||||
}
|
||||
|
||||
const char* DmaMgr_GetFileNameImpl(u32 vrom) {
|
||||
const char* DmaMgr_GetFileNameImpl(uintptr_t vrom) {
|
||||
DmaEntry* iter = gDmaDataTable;
|
||||
const char** name = sDmaMgrFileNames;
|
||||
|
||||
|
@ -216,7 +216,7 @@ const char* DmaMgr_GetFileNameImpl(u32 vrom) {
|
|||
#endif
|
||||
}
|
||||
|
||||
const char* DmaMgr_GetFileName(u32 vrom) {
|
||||
const char* DmaMgr_GetFileName(uintptr_t vrom) {
|
||||
const char* ret = DmaMgr_GetFileNameImpl(vrom);
|
||||
|
||||
if (ret == NULL) {
|
||||
|
@ -231,10 +231,10 @@ const char* DmaMgr_GetFileName(u32 vrom) {
|
|||
}
|
||||
|
||||
void DmaMgr_ProcessMsg(DmaRequest* req) {
|
||||
u32 vrom = req->vromAddr;
|
||||
uintptr_t vrom = req->vromAddr;
|
||||
void* ram = req->dramAddr;
|
||||
u32 size = req->size;
|
||||
u32 romStart;
|
||||
uintptr_t romStart;
|
||||
u32 romSize;
|
||||
u8 found = false;
|
||||
DmaEntry* iter;
|
||||
|
@ -336,7 +336,8 @@ void DmaMgr_ThreadEntry(void* arg) {
|
|||
osSyncPrintf("DMAマネージャスレッド実行終了\n");
|
||||
}
|
||||
|
||||
s32 DmaMgr_SendRequestImpl(DmaRequest* req, void* ram, u32 vrom, u32 size, u32 unk, OSMesgQueue* queue, OSMesg msg) {
|
||||
s32 DmaMgr_SendRequestImpl(DmaRequest* req, void* ram, uintptr_t vrom, u32 size, u32 unk, OSMesgQueue* queue,
|
||||
OSMesg msg) {
|
||||
static s32 sDmaMgrQueueFullLogged = 0;
|
||||
|
||||
if ((1 && (ram == NULL)) || (osMemSize < OS_K0_TO_PHYSICAL(ram) + size) || (vrom & 1) || (vrom > 0x4000000) ||
|
||||
|
@ -366,7 +367,7 @@ s32 DmaMgr_SendRequestImpl(DmaRequest* req, void* ram, u32 vrom, u32 size, u32 u
|
|||
return 0;
|
||||
}
|
||||
|
||||
s32 DmaMgr_SendRequest0(void* ram, u32 vrom, u32 size) {
|
||||
s32 DmaMgr_SendRequest0(void* ram, uintptr_t vrom, u32 size) {
|
||||
DmaRequest req;
|
||||
OSMesgQueue queue;
|
||||
OSMesg msg;
|
||||
|
@ -387,7 +388,7 @@ void DmaMgr_Init(void) {
|
|||
s32 idx;
|
||||
DmaEntry* iter;
|
||||
|
||||
DmaMgr_DmaRomToRam((u32)_dmadataSegmentRomStart, _dmadataSegmentStart,
|
||||
DmaMgr_DmaRomToRam((uintptr_t)_dmadataSegmentRomStart, _dmadataSegmentStart,
|
||||
(u32)(_dmadataSegmentRomEnd - _dmadataSegmentRomStart));
|
||||
osSyncPrintf("dma_rom_ad[]\n");
|
||||
|
||||
|
@ -414,7 +415,7 @@ void DmaMgr_Init(void) {
|
|||
}
|
||||
}
|
||||
|
||||
if ((u32)_bootSegmentRomStart != gDmaDataTable[0].vromEnd) {
|
||||
if ((uintptr_t)_bootSegmentRomStart != gDmaDataTable[0].vromEnd) {
|
||||
osSyncPrintf("_bootSegmentRomStart(%08x) != dma_rom_ad[0].rom_b(%08x)\n", _bootSegmentRomStart,
|
||||
gDmaDataTable[0].vromEnd);
|
||||
Fault_AddHungupAndCrash("../z_std_dma.c", 1055);
|
||||
|
@ -427,14 +428,14 @@ void DmaMgr_Init(void) {
|
|||
osStartThread(&sDmaMgrThread);
|
||||
}
|
||||
|
||||
s32 DmaMgr_SendRequest2(DmaRequest* req, void* ram, u32 vrom, u32 size, u32 unk5, OSMesgQueue* queue, OSMesg msg,
|
||||
s32 DmaMgr_SendRequest2(DmaRequest* req, void* ram, uintptr_t vrom, u32 size, u32 unk5, OSMesgQueue* queue, OSMesg msg,
|
||||
const char* file, s32 line) {
|
||||
req->filename = file;
|
||||
req->line = line;
|
||||
return DmaMgr_SendRequestImpl(req, ram, vrom, size, unk5, queue, msg);
|
||||
}
|
||||
|
||||
s32 DmaMgr_SendRequest1(void* ram, u32 vrom, u32 size, const char* file, s32 line) {
|
||||
s32 DmaMgr_SendRequest1(void* ram, uintptr_t vrom, u32 size, const char* file, s32 line) {
|
||||
DmaRequest req;
|
||||
s32 ret;
|
||||
OSMesgQueue queue;
|
||||
|
|
Loading…
Reference in a new issue