1
0
Fork 0
mirror of https://github.com/zeldaret/oot.git synced 2024-11-25 09:45:02 +00:00

Irqmgr and Sched Retail OK (#1678)

* irqmgr OK

* sched OK

* PR review renames
This commit is contained in:
Derek Hensley 2024-01-31 16:26:31 -08:00 committed by GitHub
parent 06379c3109
commit 2bc159e518
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 64 additions and 71 deletions

View file

@ -253,31 +253,36 @@ void IrqMgr_ThreadEntry(void* arg) {
case IRQ_RETRACE_MSG:
IrqMgr_HandleRetrace(irqMgr);
break;
case IRQ_PRENMI_MSG:
PRINTF("PRE_NMI_MSG\n");
// "Scheduler: Receives PRE_NMI message"
PRINTF("スケジューラPRE_NMIメッセージを受信\n");
IrqMgr_HandlePreNMI(irqMgr);
break;
case IRQ_PRENMI450_MSG:
PRINTF("PRENMI450_MSG\n");
// "Scheduler: Receives PRENMI450 message"
PRINTF("スケジューラPRENMI450メッセージを受信\n");
IrqMgr_HandlePreNMI450(irqMgr);
break;
case IRQ_PRENMI480_MSG:
PRINTF("PRENMI480_MSG\n");
// "Scheduler: Receives PRENMI480 message"
PRINTF("スケジューラPRENMI480メッセージを受信\n");
IrqMgr_HandlePreNMI480(irqMgr);
break;
case IRQ_PRENMI500_MSG:
PRINTF("PRENMI500_MSG\n");
// "Scheduler: Receives PRENMI500 message"
PRINTF("スケジューラPRENMI500メッセージを受信\n");
exit = true;
IrqMgr_HandlePreNMI500(irqMgr);
exit = true;
break;
default:
// "Unexpected message received"
PRINTF("irqmgr.c:予期しないメッセージを受け取りました(%08x)\n", msg);

View file

@ -45,34 +45,44 @@
#define RDP_DONE_MSG 668
#define NOTIFY_MSG 670 // original name: ENTRY_MSG
vs32 sLogScheduler = false;
vs32 sSchedDebugPrintfEnabled = false;
OSTime sRSPGfxTimeStart;
OSTime sRSPAudioTimeStart;
OSTime sRSPOtherTimeStart;
OSTime sRDPTimeStart;
#if OOT_DEBUG
#define SCHED_DEBUG_PRINTF \
if (sSchedDebugPrintfEnabled) \
PRINTF
#elif defined(__sgi)
// See comment about PRINTF in macros.h
#define SCHED_DEBUG_PRINTF(args) (void)0
#else
#define SCHED_DEBUG_PRINTF(format, ...) (void)0
#endif
/**
* Set the current framebuffer to the swapbuffer pointed to by the provided cfb
*/
void Sched_SwapFrameBufferImpl(CfbInfo* cfbInfo) {
u16 width;
LOG_UTILS_CHECK_VALID_POINTER("cfbinfo->swapbuffer", cfbInfo->swapBuffer, "../sched.c", 340);
if (cfbInfo->swapBuffer != NULL) {
// Register the swapbuffer to display on next VI
osViSwapBuffer(cfbInfo->swapBuffer);
cfbInfo->updateTimer = cfbInfo->updateRate;
SCHED_DEBUG_PRINTF("osViSwapBuffer %08x %08x %08x\n", osViGetCurrentFramebuffer(), osViGetNextFramebuffer(),
(cfbInfo != NULL) ? cfbInfo->swapBuffer : NULL);
if (sLogScheduler) {
PRINTF("osViSwapBuffer %08x %08x %08x\n", osViGetCurrentFramebuffer(), osViGetNextFramebuffer(),
(cfbInfo != NULL) ? cfbInfo->swapBuffer : NULL);
{
u16 width = (cfbInfo->viMode != NULL) ? cfbInfo->viMode->comRegs.width : (u32)gScreenWidth;
Fault_SetFrameBuffer(cfbInfo->swapBuffer, width, 16);
}
width = (cfbInfo->viMode != NULL) ? cfbInfo->viMode->comRegs.width : (u32)gScreenWidth;
Fault_SetFrameBuffer(cfbInfo->swapBuffer, width, 16);
#if OOT_DEBUG
if (R_HREG_MODE == HREG_MODE_SCHED && R_SCHED_INIT != HREG_MODE_SCHED) {
R_SCHED_TOGGLE_SPECIAL_FEATURES = 0;
R_SCHED_GAMMA_ON = 0;
@ -100,6 +110,7 @@ void Sched_SwapFrameBufferImpl(CfbInfo* cfbInfo) {
osViSetSpecialFeatures(R_SCHED_GAMMA_DITHER_ON ? OS_VI_GAMMA_DITHER_ON : OS_VI_GAMMA_DITHER_OFF);
osViSetSpecialFeatures(R_SCHED_DIVOT_ON ? OS_VI_DIVOT_ON : OS_VI_DIVOT_OFF);
}
#endif
}
cfbInfo->unk_10 = 0;
@ -117,6 +128,7 @@ void Sched_SwapFrameBuffer(Scheduler* sc, CfbInfo* cfbInfo) {
}
void Sched_HandlePreNMI(Scheduler* sc) {
#if OOT_DEBUG
OSTime now;
if (sc->curRSPTask != NULL) {
@ -143,6 +155,7 @@ void Sched_HandlePreNMI(Scheduler* sc) {
}
}
}
#endif
}
void Sched_HandleNMI(Scheduler* sc) {
@ -161,10 +174,9 @@ void Sched_QueueTask(Scheduler* sc, OSScTask* task) {
463);
if (type == M_AUDTASK) {
if (sLogScheduler) {
// "You have entered an audio task"
PRINTF("オーディオタスクをエントリしました\n");
}
// "You have entered an audio task"
SCHED_DEBUG_PRINTF("オーディオタスクをエントリしました\n");
// Add to audio queue
if (sc->audioListTail != NULL) {
sc->audioListTail->next = task;
@ -176,10 +188,10 @@ void Sched_QueueTask(Scheduler* sc, OSScTask* task) {
// Set audio flag
sc->doAudio = true;
} else {
if (sLogScheduler) {
// "Entered graph task"
PRINTF("グラフタスクをエントリしました\n");
}
// "Entered graph task"
SCHED_DEBUG_PRINTF("グラフタスクをエントリしました\n");
// Add to graphics queue
if (sc->gfxListTail != NULL) {
sc->gfxListTail->next = task;
@ -202,9 +214,7 @@ void Sched_Yield(Scheduler* sc) {
// Send yield request
osSpTaskYield();
if (sLogScheduler) {
PRINTF("%08d:osSpTaskYield\n", (u32)(OS_CYCLES_TO_USEC(osGetTime())));
}
SCHED_DEBUG_PRINTF("%08d:osSpTaskYield\n", (u32)(OS_CYCLES_TO_USEC(osGetTime())));
}
}
@ -405,11 +415,9 @@ void Sched_RunTask(Scheduler* sc, OSScTask* spTask, OSScTask* dpTask) {
// Run RSP
osSpTaskStartGo(&spTask->list);
if (sLogScheduler) {
PRINTF(
"%08d:osSpTaskStartGo(%08x) %s\n", (u32)OS_CYCLES_TO_USEC(osGetTime()), &spTask->list,
(spTask->list.t.type == M_AUDTASK ? "AUDIO" : (spTask->list.t.type == M_GFXTASK ? "GRAPH" : "OTHER")));
}
SCHED_DEBUG_PRINTF(
"%08d:osSpTaskStartGo(%08x) %s\n", (u32)OS_CYCLES_TO_USEC(osGetTime()), &spTask->list,
(spTask->list.t.type == M_AUDTASK ? "AUDIO" : (spTask->list.t.type == M_GFXTASK ? "GRAPH" : "OTHER")));
// Set currently running RSP task
sc->curRSPTask = spTask;
@ -442,9 +450,8 @@ void Sched_HandleNotification(Scheduler* sc) {
// signal to the currently running task to yield the RSP so that the audio task may
// be ran as soon as possible.
if (sc->doAudio && sc->curRSPTask != NULL) {
if (sLogScheduler) {
PRINTF("[YIELD B]");
}
SCHED_DEBUG_PRINTF("[YIELD B]");
Sched_Yield(sc);
return;
}
@ -454,15 +461,12 @@ void Sched_HandleNotification(Scheduler* sc) {
if (Sched_Schedule(sc, &nextRSP, &nextRDP, state) != state) {
Sched_RunTask(sc, nextRSP, nextRDP);
}
if (sLogScheduler) {
PRINTF("EN sc:%08x sp:%08x dp:%08x state:%x\n", sc, nextRSP, nextRDP, state);
}
SCHED_DEBUG_PRINTF("EN sc:%08x sp:%08x dp:%08x state:%x\n", sc, nextRSP, nextRDP, state);
}
void Sched_HandleRetrace(Scheduler* sc) {
if (sLogScheduler) {
PRINTF("%08d:scHandleRetrace %08x\n", (u32)OS_CYCLES_TO_USEC(osGetTime()), osViGetCurrentFramebuffer());
}
SCHED_DEBUG_PRINTF("%08d:scHandleRetrace %08x\n", (u32)OS_CYCLES_TO_USEC(osGetTime()), osViGetCurrentFramebuffer());
ViConfig_UpdateBlack();
sc->retraceCount++;
@ -490,11 +494,9 @@ void Sched_HandleRetrace(Scheduler* sc) {
}
}
if (sLogScheduler) {
PRINTF("%08x %08x %08x %d\n", osViGetCurrentFramebuffer(), osViGetNextFramebuffer(),
(sc->pendingSwapBuf1 != NULL) ? sc->pendingSwapBuf1->swapBuffer : NULL,
(sc->curBuf != NULL) ? sc->curBuf->updateTimer : 0);
}
SCHED_DEBUG_PRINTF("%08x %08x %08x %d\n", osViGetCurrentFramebuffer(), osViGetNextFramebuffer(),
(sc->pendingSwapBuf1 != NULL) ? sc->pendingSwapBuf1->swapBuffer : NULL,
(sc->curBuf != NULL) ? sc->curBuf->updateTimer : 0);
// Run the notification handler to enqueue any waiting tasks and possibly run one
Sched_HandleNotification(sc);
@ -524,14 +526,11 @@ void Sched_HandleRSPDone(Scheduler* sc) {
curRSPTask = sc->curRSPTask;
sc->curRSPTask = NULL;
if (sLogScheduler) {
PRINTF("RSP DONE %d %d", curRSPTask->state & OS_SC_YIELD, osSpTaskYielded(&curRSPTask->list));
}
SCHED_DEBUG_PRINTF("RSP DONE %d %d", curRSPTask->state & OS_SC_YIELD, osSpTaskYielded(&curRSPTask->list));
if ((curRSPTask->state & OS_SC_YIELD) && osSpTaskYielded(&curRSPTask->list)) {
if (sLogScheduler) {
PRINTF("[YIELDED]\n");
}
SCHED_DEBUG_PRINTF("[YIELDED]\n");
// Task yielded, set yielded state
curRSPTask->state |= OS_SC_YIELDED;
// Add it to the front of the queue
@ -541,9 +540,7 @@ void Sched_HandleRSPDone(Scheduler* sc) {
sc->gfxListTail = curRSPTask;
}
} else {
if (sLogScheduler) {
PRINTF("[NOT YIELDED]\n");
}
SCHED_DEBUG_PRINTF("[NOT YIELDED]\n");
// Task has completed on the RSP, unset RSP flag and check if the task is fully complete
curRSPTask->state &= ~OS_SC_SP;
Sched_TaskComplete(sc, curRSPTask);
@ -554,9 +551,7 @@ void Sched_HandleRSPDone(Scheduler* sc) {
if (Sched_Schedule(sc, &nextRSP, &nextRDP, state) != state) {
Sched_RunTask(sc, nextRSP, nextRDP);
}
if (sLogScheduler) {
PRINTF("SP sc:%08x sp:%08x dp:%08x state:%x\n", sc, nextRSP, nextRDP, state);
}
SCHED_DEBUG_PRINTF("SP sc:%08x sp:%08x dp:%08x state:%x\n", sc, nextRSP, nextRDP, state);
}
/**
@ -588,9 +583,7 @@ void Sched_HandleRDPDone(Scheduler* sc) {
if (Sched_Schedule(sc, &nextRSP, &nextRDP, state) != state) {
Sched_RunTask(sc, nextRSP, nextRDP);
}
if (sLogScheduler) {
PRINTF("DP sc:%08x sp:%08x dp:%08x state:%x\n", sc, nextRSP, nextRDP, state);
}
SCHED_DEBUG_PRINTF("DP sc:%08x sp:%08x dp:%08x state:%x\n", sc, nextRSP, nextRDP, state);
}
/**
@ -601,9 +594,7 @@ void Sched_HandleRDPDone(Scheduler* sc) {
* Original name: osScKickEntryMsg
*/
void Sched_Notify(Scheduler* sc) {
if (sLogScheduler) {
PRINTF("osScKickEntryMsg\n");
}
SCHED_DEBUG_PRINTF("osScKickEntryMsg\n");
osSendMesg(&sc->interruptQueue, (OSMesg)NOTIFY_MSG, OS_MESG_BLOCK);
}
@ -613,41 +604,38 @@ void Sched_ThreadEntry(void* arg) {
Scheduler* sc = (Scheduler*)arg;
while (true) {
if (sLogScheduler) {
// "%08d: standby"
PRINTF("%08d:待機中\n", (u32)OS_CYCLES_TO_USEC(osGetTime()));
}
// "%08d: standby"
SCHED_DEBUG_PRINTF("%08d:待機中\n", (u32)OS_CYCLES_TO_USEC(osGetTime()));
// Await interrupt messages, either from the OS, IrqMgr, or another thread
osRecvMesg(&sc->interruptQueue, &msg, OS_MESG_BLOCK);
switch ((s32)msg) {
case NOTIFY_MSG:
if (sLogScheduler) {
PRINTF("%08d:ENTRY_MSG\n", (u32)OS_CYCLES_TO_USEC(osGetTime()));
}
SCHED_DEBUG_PRINTF("%08d:ENTRY_MSG\n", (u32)OS_CYCLES_TO_USEC(osGetTime()));
Sched_HandleNotification(sc);
continue;
case RSP_DONE_MSG:
if (sLogScheduler) {
PRINTF("%08d:RSP_DONE_MSG\n", (u32)OS_CYCLES_TO_USEC(osGetTime()));
}
SCHED_DEBUG_PRINTF("%08d:RSP_DONE_MSG\n", (u32)OS_CYCLES_TO_USEC(osGetTime()));
Sched_HandleRSPDone(sc);
continue;
case RDP_DONE_MSG:
if (sLogScheduler) {
PRINTF("%08d:RDP_DONE_MSG\n", (u32)OS_CYCLES_TO_USEC(osGetTime()));
}
SCHED_DEBUG_PRINTF("%08d:RDP_DONE_MSG\n", (u32)OS_CYCLES_TO_USEC(osGetTime()));
Sched_HandleRDPDone(sc);
continue;
}
switch (((OSScMsg*)msg)->type) {
case OS_SC_RETRACE_MSG:
Sched_HandleRetrace(sc);
continue;
case OS_SC_PRE_NMI_MSG:
Sched_HandlePreNMI(sc);
continue;
case OS_SC_NMI_MSG:
Sched_HandleNMI(sc);
continue;