libultra files and directories restructure (#1038)

* Restructure files, begin header restructure

* Format

* us2dex

* Fix parallel spelling

Co-authored-by: JoshDuMan <40190173+JoshDuMan@users.noreply.github.com>

* Use OS_K0_TO_PHYSICAL in place of VIRTUAL_TO_PHYSICAL in osAiSetNextBuffer

* Uppercase hex, exception vector address defines

* Interrupt flags 1

Co-authored-by: Dragorn421 <Dragorn421@users.noreply.github.com>

* Interrupt flags 2

Co-authored-by: Dragorn421 <Dragorn421@users.noreply.github.com>

Co-authored-by: JoshDuMan <40190173+JoshDuMan@users.noreply.github.com>
Co-authored-by: Dragorn421 <Dragorn421@users.noreply.github.com>
This commit is contained in:
Tharo
2021-12-01 00:08:57 +00:00
committed by GitHub
parent eabc918817
commit f1d183d6fe
164 changed files with 1171 additions and 738 deletions
+2 -2
View File
@@ -106,7 +106,7 @@ void AudioHeap_DiscardSequence(s32 seqId) {
}
void AudioHeap_WritebackDCache(void* mem, u32 size) {
Audio_osWritebackDCache(mem, size);
Audio_WritebackDCache(mem, size);
}
void* AudioHeap_AllocZeroedAttemptExternal(AudioAllocPool* pool, u32 size) {
@@ -802,7 +802,7 @@ void AudioHeap_Init(void) {
s32 temporaryMem;
s32 totalMem;
s32 wantMisc;
u32 intMask;
OSIntMask intMask;
s32 i;
s32 j;
s32 pad2;
+5 -5
View File
@@ -868,7 +868,7 @@ void AudioLoad_SyncDma(u32 devAddr, u8* addr, u32 size, s32 medium) {
OSIoMesg* ioMesg = &gAudioContext.syncDmaIoMesg;
size = ALIGN16(size);
Audio_osInvalDCache(addr, size);
Audio_InvalDCache(addr, size);
while (true) {
if (size < 0x400) {
@@ -1312,10 +1312,10 @@ void AudioLoad_ProcessSlowLoads(s32 resetStatus) {
}
void AudioLoad_DmaSlowCopy(AudioSlowLoad* slowLoad, s32 size) {
Audio_osInvalDCache(slowLoad->curRamAddr, size);
Audio_InvalDCache(slowLoad->curRamAddr, size);
osCreateMesgQueue(&slowLoad->msgqueue, &slowLoad->msg, 1);
AudioLoad_Dma(&slowLoad->ioMesg, 0U, 0, slowLoad->curDevAddr, slowLoad->curRamAddr, size, &slowLoad->msgqueue,
slowLoad->medium, "SLOWCOPY");
AudioLoad_Dma(&slowLoad->ioMesg, OS_MESG_PRI_NORMAL, 0, slowLoad->curDevAddr, slowLoad->curRamAddr, size,
&slowLoad->msgqueue, slowLoad->medium, "SLOWCOPY");
}
void AudioLoad_DmaSlowCopyUnkMedium(s32 devAddr, u8* ramAddr, s32 size, s32 arg3) {
@@ -1548,7 +1548,7 @@ void AudioLoad_ProcessAsyncLoad(AudioAsyncLoad* asyncLoad, s32 resetStatus) {
void AudioLoad_AsyncDma(AudioAsyncLoad* asyncLoad, u32 size) {
size = ALIGN16(size);
Audio_osInvalDCache(asyncLoad->curRamAddr, size);
Audio_InvalDCache(asyncLoad->curRamAddr, size);
osCreateMesgQueue(&asyncLoad->msgQueue, &asyncLoad->msg, 1);
AudioLoad_Dma(&asyncLoad->ioMesg, 0, 0, asyncLoad->curDevAddr, asyncLoad->curRamAddr, size, &asyncLoad->msgQueue,
asyncLoad->medium, "BGCOPY");
+1 -1
View File
@@ -55,7 +55,7 @@ void AudioSynth_InitNextRingBuf(s32 chunkLen, s32 bufIndex, s32 reverbIndex) {
if (reverb->downsampleRate >= 2) {
if (reverb->framesToIgnore == 0) {
bufItem = &reverb->items[reverb->curFrame][bufIndex];
Audio_osInvalDCache(bufItem->toDownsampleLeft, DEFAULT_LEN_2CH);
Audio_InvalDCache(bufItem->toDownsampleLeft, DEFAULT_LEN_2CH);
for (j = 0, i = 0; i < bufItem->lengthA / 2; j += reverb->downsampleRate, i++) {
reverb->leftRingBuf[bufItem->startPos + i] = bufItem->toDownsampleLeft[j];
@@ -1,13 +1,15 @@
#include "global.h"
void Audio_osInvalDCache(void* buf, s32 size) {
void Audio_InvalDCache(void* buf, s32 size) {
OSIntMask prevMask = osSetIntMask(1);
osInvalDCache(buf, size);
osSetIntMask(prevMask);
}
void Audio_osWritebackDCache(void* buf, s32 size) {
void Audio_WritebackDCache(void* buf, s32 size) {
OSIntMask prevMask = osSetIntMask(1);
osWritebackDCache(buf, size);
osSetIntMask(prevMask);
}
+1 -1
View File
@@ -1,6 +1,6 @@
#include "global.h"
// memcpy used in __osMalloc.c
// memmove used in __osMalloc.c
void* func_801068B0(void* dst, void* src, size_t size) {
u8* spC = dst;
u8* sp8 = src;
+2 -2
View File
@@ -17,7 +17,7 @@ u32 sIrqMgrRetraceCount = 0;
#define STATUS_NMI 2
void IrqMgr_AddClient(IrqMgr* this, IrqMgrClient* c, OSMesgQueue* msgQ) {
u32 prevInt;
OSIntMask prevInt;
LogUtils_CheckNullPointer("this", this, "../irqmgr.c", 96);
LogUtils_CheckNullPointer("c", c, "../irqmgr.c", 97);
@@ -43,7 +43,7 @@ void IrqMgr_AddClient(IrqMgr* this, IrqMgrClient* c, OSMesgQueue* msgQ) {
void IrqMgr_RemoveClient(IrqMgr* this, IrqMgrClient* c) {
IrqMgrClient* iter = this->clients;
IrqMgrClient* lastIter = NULL;
u32 prevInt;
OSIntMask prevInt;
LogUtils_CheckNullPointer("this", this, "../irqmgr.c", 129);
LogUtils_CheckNullPointer("c", c, "../irqmgr.c", 130);
+7 -7
View File
@@ -72,7 +72,7 @@ void PadMgr_RumbleControl(PadMgr* padMgr) {
osSyncPrintf("padmgr: %dコン: %s\n", i + 1, "振動パック ぶるぶるぶるぶる");
osSyncPrintf(VT_RST);
if (osSetRumble(&padMgr->pfs[i], temp) != 0) {
if (__osMotorAccess(&padMgr->pfs[i], temp) != 0) {
padMgr->pakType[i] = 0;
osSyncPrintf(VT_FGCOL(YELLOW));
// "A communication error has occurred with the vibration pack"
@@ -94,7 +94,7 @@ void PadMgr_RumbleControl(PadMgr* padMgr) {
osSyncPrintf("padmgr: %dコン: %s\n", i + 1, "振動パック 停止");
osSyncPrintf(VT_RST);
if (osSetRumble(&padMgr->pfs[i], 0) != 0) {
if (osMotorStop(&padMgr->pfs[i]) != 0) {
padMgr->pakType[i] = 0;
osSyncPrintf(VT_FGCOL(YELLOW));
// "A communication error has occurred with the vibration pack"
@@ -133,12 +133,12 @@ void PadMgr_RumbleControl(PadMgr* padMgr) {
i = frame % 4;
if (padMgr->ctrlrIsConnected[i] && (padMgr->padStatus[i].status & 1) && (padMgr->pakType[i] != 1)) {
var4 = osProbeRumblePak(ctrlrQ, &padMgr->pfs[i], i);
var4 = osMotorInit(ctrlrQ, &padMgr->pfs[i], i);
if (var4 == 0) {
padMgr->pakType[i] = 1;
osSetRumble(&padMgr->pfs[i], 1);
osSetRumble(&padMgr->pfs[i], 0);
osMotorStart(&padMgr->pfs[i]);
osMotorStop(&padMgr->pfs[i]);
osSyncPrintf(VT_FGCOL(YELLOW));
// "Recognized vibration pack"
osSyncPrintf("padmgr: %dコン: %s\n", i + 1, "振動パックを認識しました");
@@ -164,7 +164,7 @@ void PadMgr_RumbleStop(PadMgr* padMgr) {
OSMesgQueue* ctrlrQ = PadMgr_LockSerialMesgQueue(padMgr);
for (i = 0; i < 4; i++) {
if (osProbeRumblePak(ctrlrQ, &padMgr->pfs[i], i) == 0) {
if (osMotorInit(ctrlrQ, &padMgr->pfs[i], i) == 0) {
if ((gFaultStruct.msgId == 0) && (padMgr->rumbleOnFrames != 0)) {
osSyncPrintf(VT_FGCOL(YELLOW));
// "Stop vibration pack"
@@ -172,7 +172,7 @@ void PadMgr_RumbleStop(PadMgr* padMgr) {
osSyncPrintf(VT_RST);
}
osSetRumble(&padMgr->pfs[i], 0);
osMotorStop(&padMgr->pfs[i]);
}
}
+2 -1
View File
@@ -3117,7 +3117,8 @@ void Message_Update(GlobalContext* globalCtx) {
R_TEXT_CHOICE_YPOS(1) = R_TEXTBOX_Y_TARGET + 32;
R_TEXT_CHOICE_YPOS(2) = R_TEXTBOX_Y_TARGET + 44;
osSyncPrintf("message->msg_disp_type=%x\n", msgCtx->textBoxProperties & 0xF0);
if (msgCtx->textBoxType == TEXTBOX_TYPE_NONE_BOTTOM || msgCtx->textBoxType == TEXTBOX_TYPE_NONE_NO_SHADOW) {
if (msgCtx->textBoxType == TEXTBOX_TYPE_NONE_BOTTOM ||
msgCtx->textBoxType == TEXTBOX_TYPE_NONE_NO_SHADOW) {
msgCtx->msgMode = MSGMODE_TEXT_STARTING;
R_TEXTBOX_X = R_TEXTBOX_X_TARGET;
R_TEXTBOX_Y = R_TEXTBOX_Y_TARGET;
+5 -2
View File
@@ -23,12 +23,15 @@ void SsSram_Init(u32 addr, u8 handleType, u8 handleDomain, u8 handleLatency, u8
sSsSramContext.piHandle.relDuration = handleRelDuration;
sSsSramContext.piHandle.domain = handleDomain;
sSsSramContext.piHandle.speed = handleSpeed;
bzero(&sSsSramContext.piHandle.transferInfo, sizeof(__OSTranxInfo));
prevInt = __osDisableInt();
sSsSramContext.piHandle.next = __osPiTable;
__osPiTable = &sSsSramContext.piHandle;
__osRestoreInt(prevInt);
sSsSramContext.ioMesg.hdr.pri = 0;
sSsSramContext.ioMesg.hdr.pri = OS_MESG_PRI_NORMAL;
sSsSramContext.ioMesg.hdr.retQueue = &sSsSramContext.mesgQ;
sSsSramContext.ioMesg.devAddr = addr;
}
@@ -48,6 +51,6 @@ void SsSram_Dma(void* dramAddr, size_t size, s32 direction) {
void SsSram_ReadWrite(u32 addr, void* dramAddr, size_t size, s32 direction) {
osSyncPrintf("ssSRAMReadWrite:%08x %08x %08x %d\n", addr, dramAddr, size, direction);
SsSram_Init(addr, DEVICE_TYPE_SRAM, 1, 5, 0xD, 2, 0xC, 0);
SsSram_Init(addr, DEVICE_TYPE_SRAM, PI_DOMAIN2, 5, 0xD, 2, 0xC, 0);
SsSram_Dma(dramAddr, size, direction);
}
@@ -43,7 +43,7 @@ void guPositionF(f32 mf[4][4], f32 rot, f32 pitch, f32 yaw, f32 scale, f32 x, f3
/**
* guPosition
* Creates a rotational/paralell translation moeling matrix (fixed point)
* Creates a rotational/parallel translation modeling matrix (fixed point)
*/
void guPosition(Mtx* m, f32 rot, f32 pitch, f32 yaw, f32 scale, f32 x, f32 y, f32 z) {
f32 mf[4][4];
@@ -1,5 +1,8 @@
#include "global.h"
//! Note that this is not the same as the original libultra
//! osAiSetNextBuffer, see comments in the function
s32 osAiSetNextBuffer(void* buf, u32 size) {
static u8 D_80130500 = false;
u32 bufAdjusted = (u32)buf;
@@ -14,12 +17,15 @@ s32 osAiSetNextBuffer(void* buf, u32 size) {
D_80130500 = false;
}
// Originally a call to __osAiDeviceBusy
status = HW_REG(AI_STATUS_REG, s32);
if (status & AI_STATUS_AI_FULL) {
return -1;
}
HW_REG(AI_DRAM_ADDR_REG, u32) = PHYSICAL_TO_VIRTUAL(bufAdjusted);
// OS_K0_TO_PHYSICAL replaces osVirtualToPhysical, this replacement
// assumes that only KSEG0 addresses are given
HW_REG(AI_DRAM_ADDR_REG, u32) = OS_K0_TO_PHYSICAL(bufAdjusted);
HW_REG(AI_LEN_REG, u32) = size;
return 0;
}
@@ -23,7 +23,7 @@ OSPiHandle* osCartRomInit(void) {
D_8000AF10 = 0;
__CartRomHandle.type = DEVICE_TYPE_CART;
__CartRomHandle.baseAddress = 0xB0000000;
__CartRomHandle.domain = 0;
__CartRomHandle.domain = PI_DOMAIN1;
__CartRomHandle.speed = 0;
bzero(&__CartRomHandle.transferInfo, sizeof(__OSTranxInfo));
@@ -61,25 +61,25 @@ void __osDevMgrMain(void* arg) {
}
} else {
switch (ioMesg->hdr.type) {
case 11:
case OS_MESG_TYPE_DMAREAD:
osRecvMesg(arg0->acccessQueue, &sp6C, OS_MESG_BLOCK);
phi_s0 = arg0->piDmaCallback(OS_READ, ioMesg->devAddr, ioMesg->dramAddr, ioMesg->size);
break;
case 12:
case OS_MESG_TYPE_DMAWRITE:
osRecvMesg(arg0->acccessQueue, &sp6C, OS_MESG_BLOCK);
phi_s0 = arg0->piDmaCallback(OS_WRITE, ioMesg->devAddr, ioMesg->dramAddr, ioMesg->size);
break;
case 15:
case OS_MESG_TYPE_EDMAREAD:
osRecvMesg(arg0->acccessQueue, &sp6C, OS_MESG_BLOCK);
phi_s0 = arg0->epiDmaCallback(ioMesg->piHandle, OS_READ, ioMesg->devAddr, ioMesg->dramAddr,
ioMesg->size);
break;
case 16:
case OS_MESG_TYPE_EDMAWRITE:
osRecvMesg(arg0->acccessQueue, &sp6C, OS_MESG_BLOCK);
phi_s0 = arg0->epiDmaCallback(ioMesg->piHandle, OS_WRITE, ioMesg->devAddr, ioMesg->dramAddr,
ioMesg->size);
break;
case 10:
case OS_MESG_TYPE_LOOPBACK:
osSendMesg(ioMesg->hdr.retQueue, ioMesg, OS_MESG_NOBLOCK);
phi_s0 = -1;
break;
@@ -18,7 +18,7 @@ OSPiHandle* osDriveRomInit(void) {
D_8000AC70 = 0;
__DriveRomHandle.type = DEVICE_TYPE_BULK;
__DriveRomHandle.baseAddress = 0xA6000000;
__DriveRomHandle.domain = 0;
__DriveRomHandle.domain = PI_DOMAIN1;
__DriveRomHandle.speed = 0;
bzero(&__DriveRomHandle.transferInfo, sizeof(__OSTranxInfo));
@@ -5,7 +5,7 @@
OSPifRam osPifBuffers[MAXCONTROLLERS];
s32 osSetRumble(OSPfs* pfs, u32 vibrate) {
s32 __osMotorAccess(OSPfs* pfs, u32 vibrate) {
s32 i;
s32 ret;
u8* buf = (u8*)&osPifBuffers[pfs->channel];
@@ -45,7 +45,7 @@ s32 osSetRumble(OSPfs* pfs, u32 vibrate) {
return ret;
}
void osSetUpMempakWrite(s32 channel, OSPifRam* buf) {
void _MakeMotorData(s32 channel, OSPifRam* buf) {
u8* bufptr = (u8*)buf;
__OSContRamHeader mempakwr;
s32 i;
@@ -68,7 +68,7 @@ void osSetUpMempakWrite(s32 channel, OSPifRam* buf) {
*bufptr = 0xFE;
}
s32 osProbeRumblePak(OSMesgQueue* ctrlrqueue, OSPfs* pfs, u32 channel) {
s32 osMotorInit(OSMesgQueue* ctrlrqueue, OSPfs* pfs, s32 channel) {
s32 ret;
u8 sp24[BLOCKSIZE];
@@ -112,7 +112,7 @@ s32 osProbeRumblePak(OSMesgQueue* ctrlrqueue, OSPfs* pfs, u32 channel) {
return 0xB;
}
if ((pfs->status & PFS_MOTOR_INITIALIZED) == 0) {
osSetUpMempakWrite(channel, &osPifBuffers[channel]);
_MakeMotorData(channel, &osPifBuffers[channel]);
}
pfs->status = PFS_MOTOR_INITIALIZED;
@@ -1,9 +1,9 @@
#include "global.h"
s32 __osSiRawReadIo(void* a0, u32* a1) {
s32 __osSiRawReadIo(void* devAddr, u32* dst) {
if (__osSiDeviceBusy()) {
return -1;
}
*a1 = HW_REG((u32)a0, u32);
*dst = HW_REG((u32)devAddr, u32);
return 0;
}
@@ -1,9 +1,9 @@
#include "global.h"
s32 __osSiRawWriteIo(void* a0, u32 a1) {
s32 __osSiRawWriteIo(void* devAddr, u32 val) {
if (__osSiDeviceBusy()) {
return -1;
}
HW_REG((u32)a0, u32) = a1;
HW_REG((u32)devAddr, u32) = val;
return 0;
}
@@ -21,11 +21,11 @@ void osCreateViManager(OSPri pri) {
__osTimerServicesInit();
__additional_scanline = 0;
osCreateMesgQueue(&viEventQueue, viEventBuf, 5);
viRetraceMsg.hdr.type = 13;
viRetraceMsg.hdr.pri = 0;
viRetraceMsg.hdr.type = OS_MESG_TYPE_VRETRACE;
viRetraceMsg.hdr.pri = OS_MESG_PRI_NORMAL;
viRetraceMsg.hdr.retQueue = NULL;
viCounterMsg.hdr.type = 14;
viCounterMsg.hdr.pri = 0;
viCounterMsg.hdr.type = OS_MESG_TYPE_COUNTER;
viCounterMsg.hdr.pri = OS_MESG_PRI_NORMAL;
viCounterMsg.hdr.retQueue = NULL;
osSetEventMesg(OS_EVENT_VI, &viEventQueue, &viRetraceMsg);
osSetEventMesg(OS_EVENT_COUNTER, &viEventQueue, &viCounterMsg);
@@ -56,8 +56,8 @@ void osCreateViManager(OSPri pri) {
}
void viMgrMain(void* vargs) {
OSMgrArgs* args;
static u16 viRetrace;
OSMgrArgs* args;
u32 addTime;
OSIoMesg* mesg = NULL;
u32 temp = 0; // always 0
@@ -72,7 +72,7 @@ void viMgrMain(void* vargs) {
while (true) {
osRecvMesg(args->eventQueue, (OSMesg)&mesg, OS_MESG_BLOCK);
switch (mesg->hdr.type) {
case 13:
case OS_MESG_TYPE_VRETRACE:
__osViSwapContext();
viRetrace--;
if (!viRetrace) {
@@ -98,7 +98,7 @@ void viMgrMain(void* vargs) {
addTime = __osBaseCounter - addTime;
__osCurrentTime = __osCurrentTime + addTime;
break;
case 14:
case OS_MESG_TYPE_COUNTER:
__osTimerInterrupt();
break;
}
@@ -8,7 +8,7 @@ OSThread* __osFaultedThread = NULL;
void osCreateThread(OSThread* thread, OSId id, void (*entry)(void*), void* arg, void* sp, OSPri pri) {
register u32 prevInt;
u32 t8;
OSIntMask mask;
thread->id = id;
thread->priority = pri;
@@ -18,12 +18,13 @@ void osCreateThread(OSThread* thread, OSId id, void (*entry)(void*), void* arg,
thread->context.a0 = arg;
thread->context.sp = (u64)(s32)sp - 16;
thread->context.ra = __osCleanupThread;
t8 = 0x3FFF01;
thread->context.sr = (t8 & 0xFF01) | 2;
thread->context.rcp = (t8 & 0x3F0000) >> 16;
thread->context.fpcsr = 0x01000800;
mask = OS_IM_ALL;
thread->context.sr = (mask & OS_IM_CPU) | 2;
thread->context.rcp = (mask & RCP_IMASK) >> 16;
thread->context.fpcsr = FPCSR_FS | FPCSR_EV;
thread->fp = 0;
thread->state = 1;
thread->state = OS_STATE_STOPPED;
thread->flags = 0;
prevInt = __osDisableInt();

Some files were not shown because too many files have changed in this diff Show More