BarryServer : Git

All the code for all my projects
// BarryServer : Git / Nucleus / commit / b5be0ef94a970c5fba447e74f4b194428d9cd61d / include / nucleus

// Related

Nucleus

Barry Safe interrupt disable and restore b5be0ef (3 years, 3 months ago)
diff --git a/include/nucleus/cpu.h b/include/nucleus/cpu.h
index 2a99c33..c379cb0 100644
--- a/include/nucleus/cpu.h
+++ b/include/nucleus/cpu.h
@@ -19,6 +19,20 @@ extern uint8_t lapicNums[];
 #define CPUID lapicNums[(uint8_t) (LAPIC(0x20) >> 24)]
 #define MAX_CPUS 2
 
+/* Push/pop interrupts */
+static inline uintptr_t
+irq_disable(void)
+{
+	uintptr_t flags;
+	asm volatile("pushf; cli; pop %0" : "=r" (flags) :: "memory");
+	return flags;
+}
+static inline void
+irq_restore(uintptr_t flags)
+{
+	asm volatile("push %0; popf" :: "rm" (flags) : "memory","cc");
+}
+
 void register_exception(int num, exc_handler_t addr);
 void register_interrupt(int num, int_handler_t addr);