diff options
author | Revo <projectrevotpp@hotmail.com> | 2020-05-01 16:04:18 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-05-01 16:04:18 -0400 |
commit | ce558d0870e8b8ceb626ee8a6f165e8be9869ede (patch) | |
tree | a002ab92671fdf9736179b9b1d818b6da9c398d2 /arm9/lib | |
parent | db2a8afd2f3c5e2a38083a3dc47d65e7848f0fd2 (diff) | |
parent | 527b257015fa32ac4007b1d7e9198ac37d8e1542 (diff) |
Merge pull request #52 from red031000/master
remove include/nitro and shift everything to arm9/lib
Diffstat (limited to 'arm9/lib')
-rw-r--r-- | arm9/lib/include/OS_init.h (renamed from arm9/lib/include/OS.h) | 6 | ||||
-rw-r--r-- | arm9/lib/include/OS_system.h | 9 | ||||
-rw-r--r-- | arm9/lib/include/consts.h | 8 | ||||
-rw-r--r-- | arm9/lib/include/nitro.h | 2 | ||||
-rw-r--r-- | arm9/lib/src/OS_init.c | 38 | ||||
-rw-r--r-- | arm9/lib/src/OS_system.c | 71 |
6 files changed, 125 insertions, 9 deletions
diff --git a/arm9/lib/include/OS.h b/arm9/lib/include/OS_init.h index b152dfb8..c556253a 100644 --- a/arm9/lib/include/OS.h +++ b/arm9/lib/include/OS_init.h @@ -2,8 +2,8 @@ // Created by mart on 4/12/20. // -#ifndef POKEDIAMOND_OS_H -#define POKEDIAMOND_OS_H +#ifndef POKEDIAMOND_OS_INIT_H +#define POKEDIAMOND_OS_INIT_H #include "types.h" #include "consts.h" @@ -14,4 +14,4 @@ void OS_Init(); -#endif //POKEDIAMOND_OS_H +#endif //POKEDIAMOND_OS_INIT_H diff --git a/arm9/lib/include/OS_system.h b/arm9/lib/include/OS_system.h index c7f121bd..93903315 100644 --- a/arm9/lib/include/OS_system.h +++ b/arm9/lib/include/OS_system.h @@ -17,17 +17,22 @@ typedef enum { OS_PROCMODE_SYS=31 } OSProcMode; +ENUMS_ALWAYS_INT_ON typedef enum { - OS_INTRMODE_DISABLE = HW_PSR_IRQ_DISABLE, + OS_INTRMODE_DISABLE_IRQ = HW_PSR_DISABLE_IRQ, + OS_INTRMODE_DISABLE_FIQ = HW_PSR_DISABLE_FIQ, OS_INTRMODE_ENABLE = 0 } OSIntrMode; +ENUMS_ALWAYS_INT_RESET OSIntrMode OS_EnableInterrupts(); OSIntrMode OS_DisableInterrupts(); OSIntrMode OS_RestoreInterrupts(OSIntrMode state); OSIntrMode OS_DisableInterrupts_IrqAndFiq(); OSIntrMode OS_RestoreInterrupts_IrqAndFiq(OSIntrMode state); +OSIntrMode OS_GetCpsrIrq(); OSProcMode OS_GetProcMode(); - +void OS_SpinWait(); +void OS_WaitVBlankIntr(); #endif //POKEDIAMOND_OS_SYSTEM_H diff --git a/arm9/lib/include/consts.h b/arm9/lib/include/consts.h index 6fc71be2..930f9af5 100644 --- a/arm9/lib/include/consts.h +++ b/arm9/lib/include/consts.h @@ -9,9 +9,9 @@ #define HW_PSR_CPU_MODE_MASK 0x1f // CPU mode -#define HW_PSR_FIQ_DISABLE 0x40 // Disable FIQ -#define HW_PSR_IRQ_DISABLE 0x80 // Disable IRQ -#define HW_PSR_IRQ_FIQ_DISABLE 0xc0 // Disable FIQ and IRQ +#define HW_PSR_DISABLE_FIQ 0x40 // Disable FIQ +#define HW_PSR_DISABLE_IRQ 0x80 // Disable IRQ +#define HW_PSR_DISABLE_IRQ_FIQ 0xc0 // Disable FIQ and IRQ #define HW_C6_PR_4KB 0x16 #define HW_C6_PR_8KB 0x18 @@ -42,4 +42,6 @@ #define OSi_TRUNC(n, a) (((u32) (n)) & ~((a) - 1)) #define OSi_ROUND(n, a) (((u32) (n) + (a) - 1) & ~((a) - 1)) +#define OS_IE_V_BLANK (1UL << 0) + #endif //POKEDIAMOND_CONSTS_H diff --git a/arm9/lib/include/nitro.h b/arm9/lib/include/nitro.h index 8d875653..f7397fb0 100644 --- a/arm9/lib/include/nitro.h +++ b/arm9/lib/include/nitro.h @@ -8,7 +8,7 @@ extern "C" { // Include all nitro files #include "types.h" #include "consts.h" -#include "OS.h" +#include "OS_init.h" #include "mmap.h" #ifdef __cplusplus diff --git a/arm9/lib/src/OS_init.c b/arm9/lib/src/OS_init.c new file mode 100644 index 00000000..90b01ffa --- /dev/null +++ b/arm9/lib/src/OS_init.c @@ -0,0 +1,38 @@ +// +// Created by mart on 4/12/20. +// + +#include "function_target.h" +#include "OS_init.h" + +extern void PXI_Init(); +extern void OS_InitLock(); +extern void OS_InitIrqTable(); +extern void OS_SetIrqStackChecker(); +extern void OS_InitException(); +extern void MI_Init(); +extern void OS_InitVAlarm(); +extern void OSi_InitVramExclusive(); +extern void OS_InitThread(); +extern void OS_InitReset(); +extern void CTRDG_Init(); +extern void CARD_Init(); +extern void PM_Init(); + +ARM_FUNC void OS_Init(void) { + OS_InitArena(); + PXI_Init(); + OS_InitLock(); + OS_InitArenaEx(); + OS_InitIrqTable(); + OS_SetIrqStackChecker(); + OS_InitException(); + MI_Init(); + OS_InitVAlarm(); + OSi_InitVramExclusive(); + OS_InitThread(); + OS_InitReset(); + CTRDG_Init(); + CARD_Init(); + PM_Init(); +} diff --git a/arm9/lib/src/OS_system.c b/arm9/lib/src/OS_system.c new file mode 100644 index 00000000..c2b08681 --- /dev/null +++ b/arm9/lib/src/OS_system.c @@ -0,0 +1,71 @@ +// +// Created by mart on 4/23/20. +// + +#include "function_target.h" +#include "OS_system.h" + +ARM_FUNC asm OSIntrMode OS_EnableInterrupts() { + mrs r0, cpsr + bic r1, r0, #HW_PSR_DISABLE_IRQ + msr cpsr_c, r1 + and r0, r0, #HW_PSR_DISABLE_IRQ + bx lr +} + +ARM_FUNC asm OSIntrMode OS_DisableInterrupts() { + mrs r0, cpsr + orr r1, r0, #HW_PSR_DISABLE_IRQ + msr cpsr_c, r1 + and r0, r0, #HW_PSR_DISABLE_IRQ + bx lr +} + +ARM_FUNC asm OSIntrMode OS_RestoreInterrupts(OSIntrMode state) { + mrs r1, cpsr + bic r2, r1, #HW_PSR_DISABLE_IRQ + orr r2, r2, r0 + msr cpsr_c, r2 + and r0, r1, #HW_PSR_DISABLE_IRQ + bx lr +} + +ARM_FUNC asm OSIntrMode OS_DisableInterrupts_IrqAndFiq() { + mrs r0, cpsr + orr r1, r0, #HW_PSR_DISABLE_IRQ_FIQ + msr cpsr_c, r1 + and r0, r0, #HW_PSR_DISABLE_IRQ_FIQ + bx lr +} + +ARM_FUNC asm OSIntrMode OS_RestoreInterrupts_IrqAndFiq(OSIntrMode state) { + mrs r1, cpsr + bic r2, r1, #HW_PSR_DISABLE_IRQ_FIQ + orr r2, r2, r0 + msr cpsr_c, r2 + and r0, r1, #HW_PSR_DISABLE_IRQ_FIQ + bx lr +} + +ARM_FUNC asm OSIntrMode OS_GetCpsrIrq() { + mrs r0, cpsr + and r0, r0, #HW_PSR_DISABLE_IRQ + bx lr +} + +ARM_FUNC asm OSProcMode OS_GetProcMode() { + mrs r0, cpsr + and r0, r0, #HW_PSR_CPU_MODE_MASK + bx lr +} + +ARM_FUNC asm void OS_SpinWait() { + subs r0, r0, #0x4 + bhs OS_SpinWait + bx lr +} + +ARM_FUNC void OS_WaitVBlankIntr() { + SVC_WaitByLoop(0x1); + OS_WaitIrq(TRUE, OS_IE_V_BLANK); +} |