ARM9 OS: Difference between revisions

Hallowizer (talk | contribs)
Threads: apparently those "fp" registers are for integers
Hallowizer (talk | contribs)
Threads: kernelSp is a system stack used for thread cleanup and SVCs
 
(5 intermediate revisions by the same user not shown)
Line 30: Line 30:
void *lr; // 0x3c
void *lr; // 0x3c
void *pc; // 0x40
void *pc; // 0x40
void *kernelSp; // 0x44
void *systemStack; // 0x44
struct OSMathContext math; // 0x48
struct OSMathContext math; // 0x48
}
}
Line 43: Line 43:
struct OSThreadQueue *queue; // 0x78
struct OSThreadQueue *queue; // 0x78
struct OSThreadLink linkQueue; // 0x7c
struct OSThreadLink linkQueue; // 0x7c
u32 unknown2; // 0x80
struct OSMutex *mutex; // 0x84 - set to the mutex the thread is currently trying to lock
struct OSMutex *mutex; // 0x84 - set to the mutex the thread is currently trying to lock
struct OSMutexQueue queueMutex; // 0x88
struct OSMutexQueue queueMutex; // 0x88
u32 unknown3[4]; // 0x8c
void *stackLo; // 0x90
void *stackHi; // 0x94
void *unknown2; // 0x98
struct OSThreadQueue queueJoin; // 0x9c
struct OSThreadQueue queueJoin; // 0x9c
u32 unknown4[3]; // 0xa4
u32 unknown3[3]; // 0xa4
struct OSAlarm *timedSleepAlarm; // 0xb0
struct OSAlarm *timedSleepAlarm; // 0xb0
u32 unknown5; // 0xb4
void (*cleanupFunc)(u32 res); // 0xb4
u32 unknown4[2];
}
}


Line 93: Line 95:


== Time ==
== Time ==
Time is kept with timers 2 and 3, while alarm interrupts are handled by timer 1; timer 0 is presumably reserved for the DMA sound channels. The OS orders the alarms by alert time, so that it only needs to keep track of the frontmost alarm.
Timer 0 is used to keep track of global time by manually incrementing a global, while timer 1 is used to generate an interrupt for alarms. The OS orders the alarms by alert time, so that it only needs to keep track of the frontmost alarm.


<pre>
<pre>
Line 113: Line 115:
}
}
</pre>
</pre>
== Interrupts ==
The interrupt handler called by the [[ARM9 BIOS]] calls a handler in a table mapping the raw IRQ IDs to handlers. Each handler is either a no-op (not listed in the table below) or a stub that calls <code>__OSDispatchInterrupt</code> with an OS interrupt ID. <code>__OSDispatchInterrupt</code> then calls the handler registered with <code>__OSSetInterruptHandler</code>.
{| class="wikitable sortable"
! Hardware ID
! Translated ID
! Name
|-
| 3
| 8
| Timer 0 overflow
|-
| 4
| 9
| Timer 1 overflow
|-
| 5
| 10
| Timer 2 overflow
|-
| 6
| 11
| Timer 3 overflow
|-
| 8
| 0
| DMA 0
|-
| 9
| 1
| DMA 1
|-
| 10
| 2
| DMA 2
|-
| 11
| 3
| DMA 3
|-
| 28
| 4
| New DMA 0
|-
| 29
| 5
| New DMA 1
|-
| 30
| 6
| New DMA 2
|-
| 31
| 7
| New DMA 3
|}