Skip to content

Instantly share code, notes, and snippets.

@Ludo6431
Created July 4, 2011 19:41
Show Gist options
  • Save Ludo6431/1063835 to your computer and use it in GitHub Desktop.
Save Ludo6431/1063835 to your computer and use it in GitHub Desktop.
ninty's irq functions
#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;
}
#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