LumaOS  v0.1.116
An experimental x86-64 OS
Loading...
Searching...
No Matches
irq.h
Go to the documentation of this file.
1
9
10#ifndef KERNEL_ARCH_X86_64_IRQ_H
11#define KERNEL_ARCH_X86_64_IRQ_H
12
13#include <arch/x86_64/idt.h>
14
15typedef void (*irq_handler_fn)(struct interrupt_frame *frame);
16
22void irq_register(uint8_t irq, irq_handler_fn fn);
23
28void irq_handler(struct interrupt_frame *frame);
29
34static inline uint64_t irq_save(void) {
35 uint64_t flags;
36 asm volatile ("pushfq\n\tpopq %0\n\tcli" : "=r"(flags) : : "memory");
37 return flags;
38}
39
44static inline void irq_restore(uint64_t flags) {
45 if (flags & (1 << 9)) asm volatile ("sti" : : : "memory"); // bit 9 of rflags is IF
46}
47
48#endif
Initializes and holds the IDT for the kernel.
static uint64_t irq_save(void)
Saves the IRQ and disables interrupts (used when using a variable that is modified by an interrupt).
Definition irq.h:34
void irq_handler(struct interrupt_frame *frame)
Calls the correct handler and returns the interrupt.
Definition irq.c:25
void irq_register(uint8_t irq, irq_handler_fn fn)
Registers a handler function for the specified IRQ number.
Definition irq.c:18
static void irq_restore(uint64_t flags)
Restores the IRQ and re-enables interrupts (used when using a variable that is modified by an interru...
Definition irq.h:44
The frame holding the registers when an interrupt happens.
Definition idt.h:16