Skip to content

Commit

Permalink
lib,irq: implement interrupts enable/disable abstraction helpers
Browse files Browse the repository at this point in the history
Signed-off-by: Pawel Wieczorkiewicz <[email protected]>
  • Loading branch information
wipawel committed Nov 13, 2023
1 parent 62ea54f commit f44f421
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 6 deletions.
2 changes: 1 addition & 1 deletion common/acpi.c
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}
Expand Down
2 changes: 1 addition & 1 deletion common/setup.c
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion drivers/keyboard.c
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
8 changes: 8 additions & 0 deletions include/lib.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
4 changes: 2 additions & 2 deletions lib/lib.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
#include <extables.h>

void __noreturn halt(void) {
cli();
interrupts_disable();

while (1) {
hlt();
Expand All @@ -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();

Expand Down
2 changes: 1 addition & 1 deletion smp/smp.c
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit f44f421

Please sign in to comment.