x86_64: add basic interrupt handling
This commit is contained in:
43
arch/x86_64/include/arch/irq.h
Normal file
43
arch/x86_64/include/arch/irq.h
Normal file
@@ -0,0 +1,43 @@
|
||||
#ifndef ARCH_IRQ_H_
|
||||
#define ARCH_IRQ_H_
|
||||
|
||||
#include <socks/compiler.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#define NR_IDT_ENTRIES 48
|
||||
|
||||
struct cpu_context {
|
||||
uint64_t r15, r14, r13, r12, r11, r10, r9, r8;
|
||||
uint64_t rdi, rsi, rbp, unused_rsp, rbx, rdx, rcx, rax;
|
||||
uint64_t int_no, err_no;
|
||||
uint64_t rip, cs, rflags, rsp, ss;
|
||||
} __packed;
|
||||
|
||||
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 cpu_context *);
|
||||
|
||||
extern int idt_init(struct idt_ptr *idtp);
|
||||
extern int idt_load(struct idt_ptr *idtp);
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user