Files
mango/arch/x86_64/include/arch/irq.h
Max Wash 6019c9307d kernel: separate headers into kernel and user headers
all kernel headers have been moved from include/mango to include/kernel
and include definitions that are only relevant to kernel-space.

any definitions that are relevant to both kernel- and user-space
(i.e. type definitions, syscall IDs) have been moved to
include/mango within libmango.
2026-02-19 18:54:48 +00:00

75 lines
1.1 KiB
C

#ifndef ARCH_IRQ_H_
#define ARCH_IRQ_H_
#include <kernel/compiler.h>
#include <kernel/queue.h>
#include <stdint.h>
#ifdef __cplusplus
extern "C" {
#endif
#define NR_IDT_ENTRIES 256
struct ml_cpu_context;
enum irq_vector {
IRQ0 = 32,
IRQ1,
IRQ2,
IRQ3,
IRQ4,
IRQ5,
IRQ6,
IRQ7,
IRQ8,
IRQ9,
IRQ10,
IRQ11,
IRQ12,
IRQ13,
IRQ14,
IRQ15,
};
struct irq_hook {
struct queue_entry irq_entry;
int (*irq_callback)(void);
};
struct idt_entry {
uint16_t base_low;
uint16_t selector;
uint8_t always0;
uint8_t type : 4;
uint8_t zero : 1;
uint8_t dpl : 2;
uint8_t present : 1;
uint16_t base_middle;
uint32_t base_high;
uint32_t reserved;
} __packed;
struct idt {
struct idt_entry i_entries[NR_IDT_ENTRIES];
};
struct idt_ptr {
uint16_t i_limit;
uintptr_t i_base;
} __packed;
typedef void (*int_hook)(struct ml_cpu_context *);
extern int idt_init(struct idt_ptr *idtp);
extern int idt_load(struct idt_ptr *idtp);
extern void hook_irq(enum irq_vector vec, struct irq_hook *hook);
extern void unhook_irq(enum irq_vector vec, struct irq_hook *hook);
#ifdef __cplusplus
}
#endif
#endif