This commit is contained in:
nub31
2025-09-01 15:55:44 +02:00
parent 25342b507d
commit 5a119e428a
8 changed files with 58 additions and 154 deletions

28
src/interrupts.h Normal file
View File

@@ -0,0 +1,28 @@
#pragma once
#include "typedef.h"
typedef struct
{
u64 r15, r14, r13, r12, r11, r10, r9, r8;
u64 rbp, rdi, rsi, rdx, rcx, rbx, rax;
u64 int_no;
u64 err_code;
u64 rip, cs, rflags, rsp, ss;
} __attribute__((packed)) isr_frame_t;
typedef void (*irq_handler_t)(const isr_frame_t*);
static inline void outb(u16 port, u8 val)
{
__asm__ volatile("outb %0, %1" : : "a"(val), "Nd"(port));
}
static inline u8 inb(u16 port)
{
u8 ret;
__asm__ volatile("inb %1, %0" : "=a"(ret) : "Nd"(port));
return ret;
}
void register_irq_handler(u8 irq, irq_handler_t handler);