42_KFS/headers/interrupts.h

32 lines
632 B
C
Raw Normal View History

2024-10-01 14:24:33 -04:00
#pragma once
2024-10-08 17:56:34 -04:00
#include <stdint.h>
struct registers {
// data segment selector
2025-02-07 06:35:32 -05:00
uint32_t ds;
// general purpose registers pushed by pusha
2025-02-07 06:35:32 -05:00
uint32_t edi, esi, ebp, esp, ebx, edx, ecx, eax;
// pushed by isr procedure
2025-02-07 06:35:32 -05:00
uint32_t int_no, err_code;
// pushed by CPU automatically
2025-02-07 06:35:32 -05:00
uint32_t eip, cs, eflags, useresp, ss;
};
typedef void (*isr_t)(struct registers *);
void isr_handler(struct registers *regs);
2025-02-07 06:35:32 -05:00
void pic_send_eoi(uint8_t irq);
void register_interrupt_handler(int index, isr_t handler);
2025-01-08 10:38:02 -05:00
static inline void cli(void)
{
__asm__ volatile("cli");
}
// aka sti
static inline void toris(void)
2025-01-08 10:38:02 -05:00
{
__asm__ volatile("sti");
}