diff --git a/common/acpi.c b/common/acpi.c index f036fcd1..68f8cc38 100644 --- a/common/acpi.c +++ b/common/acpi.c @@ -750,7 +750,7 @@ ACPI_STATUS init_acpi(void) { void acpi_power_off(void) { AcpiEnterSleepStatePrep(ACPI_STATE_S5); - cli(); + interrupts_disable(); AcpiEnterSleepState(ACPI_STATE_S5); panic("Power Off"); } diff --git a/common/setup.c b/common/setup.c index cc734ee4..39e9dbb7 100644 --- a/common/setup.c +++ b/common/setup.c @@ -263,7 +263,7 @@ void __noreturn __text_init kernel_start(uint32_t multiboot_magic, unsigned long /* Initialize timers and enable interrupts */ init_timers(bsp); - sti(); + interrupts_enable(); if (!boot_flags.nosmp) init_smp(); diff --git a/drivers/keyboard.c b/drivers/keyboard.c index f1bd9b46..1ff1f8c0 100644 --- a/drivers/keyboard.c +++ b/drivers/keyboard.c @@ -67,7 +67,7 @@ void keyboard_reboot(void) { if (!i8042_present) return; - cli(); + interrupts_disable(); while ((inb(KEYBOARD_PORT_CMD) & KEYBOARD_STATUS_IN_FULL) != 0) cpu_relax(); diff --git a/include/lib.h b/include/lib.h index 651709ac..fe0c5be6 100644 --- a/include/lib.h +++ b/include/lib.h @@ -183,6 +183,14 @@ static inline void write_eflags(unsigned long flags) { asm volatile("push %0\n" POPF()::"r"(flags)); } +static inline void interrupts_enable(void) { + sti(); +} + +static inline void interrupts_disable(void) { + cli(); +} + static inline unsigned long read_cs(void) { unsigned long cs; diff --git a/lib/lib.c b/lib/lib.c index 8ed0a77b..69d1c536 100644 --- a/lib/lib.c +++ b/lib/lib.c @@ -28,7 +28,7 @@ #include void __noreturn halt(void) { - cli(); + interrupts_disable(); while (1) { hlt(); @@ -40,7 +40,7 @@ void __noreturn halt(void) { void __noreturn hard_reboot(void) { idt_ptr_t idt_ptr = {0}; - cli(); + interrupts_disable(); lidt(&idt_ptr); int3(); diff --git a/smp/smp.c b/smp/smp.c index a1598f10..312d3915 100644 --- a/smp/smp.c +++ b/smp/smp.c @@ -58,7 +58,7 @@ void __noreturn ap_startup(void) { /* Initialize timers and enable interrupts */ init_timers(cpu); - sti(); + interrupts_enable(); if (opt_fpu) enable_fpu();