Created
July 4, 2011 19:41
-
-
Save Ludo6431/1063835 to your computer and use it in GitHub Desktop.
ninty's irq functions
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "irqs.h" | |
u32 irq_ack(u32 irqs) { | |
u16 ime = REG_IME; | |
REG_IME = 0; | |
u32 ifs = REG_IF; | |
REG_IF = irqs; | |
REG_IME = ime; | |
return ifs; | |
} | |
u32 irq_disable(u32 irqs) { | |
u16 ime = REG_IME; | |
REG_IME = 0; | |
u32 ies = REG_IE; | |
REG_IE = ies & ~irqs; | |
REG_IME = ime; | |
return ies; | |
} | |
u32 irq_enable(u32 irqs) { | |
u16 ime = REG_IME; | |
REG_IME = 0; | |
u32 ies = REG_IE; | |
REG_IE = ies | irqs; | |
REG_IME = ime; | |
return ies; | |
} | |
u32 irq_restore(u32 irqs) { | |
u16 ime = REG_IME; | |
REG_IME = 0; | |
u32 ies = REG_IE; | |
REG_IE = irqs; | |
REG_IME = ime; | |
return ies; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#ifndef _IRQS_H | |
#define _IRQS_H | |
#define REG_IME (*(u16 *)0x4000208) | |
#define REG_IE (*(u32 *)0x4000210) | |
#define REG_IF (*(u32 *)0x4000214) | |
#endif |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment