1
0
Fork 0
mirror of https://github.com/zeldaret/oot.git synced 2025-07-13 11:24:40 +00:00

More documentation for sched.c (#1219)

* More documentation for sched.c

* VI retrace -> vertical retrace, attempt to clarify comment in viconfig

* Further review changes, fix inconsistent capitalization of PreNMI (PRENMI -> PreNMI)

* Fix typo

Co-authored-by: engineer124 <47598039+engineer124@users.noreply.github.com>

* Change TaskSwapBuffer, change comment on OS_SC_DRAM_DLIST to unimplemented

* Rename SchedContext/gSchedContext to Scheduler/gScheduler

* Comments fixes

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

* Format

Co-authored-by: engineer124 <47598039+engineer124@users.noreply.github.com>
Co-authored-by: Dragorn421 <Dragorn421@users.noreply.github.com>
This commit is contained in:
Tharo 2022-06-03 20:43:30 +01:00 committed by GitHub
parent ee5ac838b6
commit 1738b19d63
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
20 changed files with 449 additions and 268 deletions

View file

@ -2,18 +2,20 @@
* @file irqmgr.c
*
* This file implements a manager for forwarding three key system interrupt events to
* registered clients. The architecture of this system appears to be derived in part from
* the libultra sched module.
* registered clients.
* Together with sched.c, these systems implement the libultra video and task scheduling
* model from the libultra "sched" module, with improved functionality in the handling of
* Pre-NMI related events.
*
* The interrupts the IRQ manager deals with are:
* - VI Retrace
* - Vertical Retrace
* This event is sent to the IRQ manager by the OS VI manager which only supports
* the forwarding of VI events to a single message queue. The IRQ manager will
* forward these events to every registered client. VI retrace events are received
* when the Video Interface has reached the start of the vertical blanking interval,
* happening at approximately 60Hz on NTSC and 50Hz on PAL. Many threads sit idle
* until a VI Retrace event wakes them up, at which point they will perform their
* task and then return to idle to await the next retrace.
* forward these events to every registered client. Vertical retrace events are
* received when the Video Interface has reached the start of the vertical blanking
* interval, happening at approximately 60Hz on NTSC and 50Hz on PAL. Many threads
* sit idle until a vertical retrace event wakes them up, at which point they will
* perform their task and then return to idle to await the next retrace.
*
* - Pre-NMI
* This event is sent to the IRQ manager by the OS Interrupt Handler when the reset
@ -27,6 +29,8 @@
* is not to be confused with the hardware NMI interrupt signalled when the CPU is
* to fully reset, as by the time that interrupt is received there is no time left
* to do anything.
*
* @see sched.c
*/
#include "global.h"
#include "vt.h"
@ -183,7 +187,7 @@ void IrqMgr_CheckStacks(void) {
}
}
void IrqMgr_HandlePRENMI450(IrqMgr* irqMgr) {
void IrqMgr_HandlePreNMI450(IrqMgr* irqMgr) {
u64 nmi = IRQ_RESET_STATUS_NMI; // required to match
gIrqMgrResetStatus = nmi;
@ -195,7 +199,7 @@ void IrqMgr_HandlePRENMI450(IrqMgr* irqMgr) {
IrqMgr_SendMesgToClients(irqMgr, (OSMesg)&irqMgr->nmiMsg);
}
void IrqMgr_HandlePRENMI480(IrqMgr* irqMgr) {
void IrqMgr_HandlePreNMI480(IrqMgr* irqMgr) {
u32 result;
// Schedule a PRENMI500 message to be handled in 20ms
@ -212,13 +216,15 @@ void IrqMgr_HandlePRENMI480(IrqMgr* irqMgr) {
}
}
void IrqMgr_HandlePRENMI500(IrqMgr* irqMgr) {
void IrqMgr_HandlePreNMI500(IrqMgr* irqMgr) {
IrqMgr_CheckStacks();
}
/**
* Runs on each VI retrace, measures the time elapsed between the first and second VI retrace
* and dispatches VI retrace messages to each registered Irq Client
* Runs on each vertical retrace
*
* Measures the time elapsed between the first and second vertical retrace and
* dispatches vertical retrace messages to each registered Irq Client
*/
void IrqMgr_HandleRetrace(IrqMgr* irqMgr) {
if (gIrqMgrRetraceTime == 0) {
@ -257,20 +263,20 @@ void IrqMgr_ThreadEntry(void* arg) {
osSyncPrintf("PRENMI450_MSG\n");
// "Scheduler: Receives PRENMI450 message"
osSyncPrintf("スケジューラPRENMI450メッセージを受信\n");
IrqMgr_HandlePRENMI450(irqMgr);
IrqMgr_HandlePreNMI450(irqMgr);
break;
case IRQ_PRENMI480_MSG:
osSyncPrintf("PRENMI480_MSG\n");
// "Scheduler: Receives PRENMI480 message"
osSyncPrintf("スケジューラPRENMI480メッセージを受信\n");
IrqMgr_HandlePRENMI480(irqMgr);
IrqMgr_HandlePreNMI480(irqMgr);
break;
case IRQ_PRENMI500_MSG:
osSyncPrintf("PRENMI500_MSG\n");
// "Scheduler: Receives PRENMI500 message"
osSyncPrintf("スケジューラPRENMI500メッセージを受信\n");
exit = true;
IrqMgr_HandlePRENMI500(irqMgr);
IrqMgr_HandlePreNMI500(irqMgr);
break;
default:
// "Unexpected message received"