42_KFS/headers/interrupts.h

33 lines
626 B
C

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