42_KFS/headers/interrupts.h
2025-01-08 16:38:02 +01:00

30 lines
618 B
C

#pragma once
#include <stdint.h>
struct registers {
// data segment selector
uint32_t ds;
// general purpose registers pushed by pusha
uint32_t edi, esi, ebp, esp, ebx, edx, ecx, eax;
// pushed by isr procedure
uint32_t int_no, err_code;
// pushed by CPU automatically
uint32_t eip, cs, eflags, useresp, ss;
};
typedef void (*isr_t)(struct registers *);
void isr_handler(struct registers *regs);
void pic_send_eoi(uint8_t irq);
void register_interrupt_handler(int index, isr_t handler);
static inline void cli(void)
{
__asm__ volatile("cli");
}
static inline void sti(void)
{
__asm__ volatile("sti");
}