tp/libs/dolphin/os/OSInterrupt.c

198 lines
5.4 KiB
C

//
// Generated By: dol2asm
// Translation Unit: OSInterrupt
//
#include "dolphin/os/OSInterrupt.h"
#include "dol2asm.h"
#include "dolphin/os/OS.h"
#include "dolphin/types.h"
//
// External References:
//
SECTION_INIT void memset();
void OSLoadContext();
void __OSReschedule();
//
// Declarations:
//
/* 8033D6F4-8033D700 338034 000C+00 2/2 200/200 5/5 .text OSDisableInterrupts */
asm BOOL OSDisableInterrupts(void) {
// clang-format off
nofralloc
entry __RAS_OSDisableInterrupts_begin
mfmsr r3
// Clear external interrupts bit
rlwinm r4, r3, 0, 17, 15
mtmsr r4
entry __RAS_OSDisableInterrupts_end
// Return old interrupt status
rlwinm r3, r3, 17, 31, 31
blr
// clang-format on
}
/* 8033D708-8033D71C 338048 0014+00 0/0 10/10 1/1 .text OSEnableInterrupts */
asm BOOL OSEnableInterrupts(void) {
// clang-format off
nofralloc
mfmsr r3
// Set external interrupts bit
ori r4, r3, (1 << 15)
mtmsr r4
// Return old interrupt status
rlwinm r3, r3, 17, 31, 31
blr
// clang-format on
}
/* 8033D71C-8033D740 33805C 0024+00 2/2 197/197 6/6 .text OSRestoreInterrupts */
asm BOOL OSRestoreInterrupts(register BOOL status) {
// clang-format off
nofralloc
cmpwi status, 0
mfmsr r4
beq disable
// Set external interrupts bit
ori r5, r4, (1 << 15)
b set_msr
disable:
// Clear external interrupts bit
rlwinm r5, r4, 0, 17, 15
set_msr:
mtmsr r5
// Return old interrupt status
rlwinm r3, r4, 17, 31, 31
blr
// clang-format on
}
/* ############################################################################################## */
/* 80451670-80451674 000B70 0004+00 4/4 0/0 0/0 .sbss InterruptHandlerTable */
static OSInterruptHandler* InterruptHandlerTable;
/* 8033D740-8033D75C 338080 001C+00 0/0 12/12 0/0 .text __OSSetInterruptHandler */
OSInterruptHandler __OSSetInterruptHandler(OSInterrupt type, OSInterruptHandler handler) {
OSInterruptHandler old = InterruptHandlerTable[type];
InterruptHandlerTable[type] = handler;
return old;
}
/* 8033D75C-8033D770 33809C 0014+00 0/0 1/1 0/0 .text __OSGetInterruptHandler */
OSInterruptHandler __OSGetInterruptHandler(OSInterrupt type) {
return InterruptHandlerTable[type];
}
/* 8033D770-8033D7E4 3380B0 0074+00 0/0 1/1 0/0 .text __OSInterruptInit */
#pragma push
#pragma optimization_level 0
#pragma optimizewithasm off
asm void __OSInterruptInit(void) {
nofralloc
#include "asm/dolphin/os/OSInterrupt/__OSInterruptInit.s"
}
#pragma pop
/* 8033D7E4-8033DABC 338124 02D8+00 2/2 0/0 0/0 .text SetInterruptMask */
#pragma push
#pragma optimization_level 0
#pragma optimizewithasm off
static asm OSInterruptMask SetInterruptMask(OSInterruptMask param_0, OSInterruptMask param_1) {
nofralloc
#include "asm/dolphin/os/OSInterrupt/SetInterruptMask.s"
}
#pragma pop
/* 8033DABC-8033DB44 3383FC 0088+00 1/1 15/15 0/0 .text __OSMaskInterrupts */
#pragma push
#pragma optimization_level 0
#pragma optimizewithasm off
asm OSInterruptMask __OSMaskInterrupts(OSInterruptMask mask) {
nofralloc
#include "asm/dolphin/os/OSInterrupt/__OSMaskInterrupts.s"
}
#pragma pop
/* 8033DB44-8033DBCC 338484 0088+00 0/0 18/18 0/0 .text __OSUnmaskInterrupts */
#pragma push
#pragma optimization_level 0
#pragma optimizewithasm off
asm OSInterruptMask __OSUnmaskInterrupts(OSInterruptMask mask) {
nofralloc
#include "asm/dolphin/os/OSInterrupt/__OSUnmaskInterrupts.s"
}
#pragma pop
/* ############################################################################################## */
/* 803D0758-803D0788 02D878 002C+04 1/1 0/0 0/0 .data InterruptPrioTable */
static u32 InterruptPrioTable[] = {
0x00000100, 0x00000040, 0xF8000000, 0x00000200, 0x00000080, 0x00003000,
0x00000020, 0x03FF8C00, 0x04000000, 0x00004000, 0xFFFFFFFF,
};
/* 80451680-80451684 000B80 0004+00 1/1 1/1 0/0 .sbss __OSLastInterruptTime */
extern OSTime __OSLastInterruptTime;
OSTime __OSLastInterruptTime;
/* 80451678-80451680 000B78 0002+06 1/1 1/1 0/0 .sbss __OSLastInterrupt */
extern s16 __OSLastInterrupt;
s16 __OSLastInterrupt;
/* 80451674-80451678 000B74 0004+00 1/1 1/1 0/0 .sbss __OSLastInterruptSrr0 */
extern u32 __OSLastInterruptSrr0;
u32 __OSLastInterruptSrr0;
/* 8033DBCC-8033DF10 33850C 0344+00 1/1 0/0 0/0 .text __OSDispatchInterrupt */
#pragma push
#pragma optimization_level 0
#pragma optimizewithasm off
asm void __OSDispatchInterrupt(OSInterrupt interrupt, OSContext* context) {
nofralloc
#include "asm/dolphin/os/OSInterrupt/__OSDispatchInterrupt.s"
}
#pragma pop
/* 8033DF10-8033DF60 338850 0050+00 1/1 0/0 0/0 .text ExternalInterruptHandler */
static asm void ExternalInterruptHandler(register OSInterrupt type, register OSContext* context) {
// clang-format off
nofralloc
stw r0, context->gpr[0]
stw r1, context->gpr[1]
stw r2, context->gpr[2]
stmw r6, context->gpr[6]
mfspr r0, GQR1
stw r0, context->gqr[1]
mfspr r0, GQR2
stw r0, context->gqr[2]
mfspr r0, GQR3
stw r0, context->gqr[3]
mfspr r0, GQR4
stw r0, context->gqr[4]
mfspr r0, GQR5
stw r0, context->gqr[5]
mfspr r0, GQR6
stw r0, context->gqr[6]
mfspr r0, GQR7
stw r0, context->gqr[7]
stwu r1, -8(r1)
b __OSDispatchInterrupt
// clang-format on
}