Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "idt.h"
- #define IDT_ENTRIES 1
- static uint64_t idt[IDT_ENTRIES];
- void load_idt() {
- struct {
- unsigned short int limit;
- void* pointer;
- } __attribute__((packed)) idtp = {
- .limit = IDT_ENTRIES * 8 - 1,
- .pointer = idt,
- };
- asm volatile("lidt %0" : : "m" (idtp));
- }
- void set_idt_entry(int i, uint32_t address, uint16_t selector, uint16_t x) {
- idt[i] = address & 0x00FF;
- idt[i] |= (address & 0xFF00LL) << 32;
- idt[i] |= (selector & 0xFFLL) << 16;
- x |= 0b100010000000000;
- idt[i] |= (x & 0xFFLL) << 32;
- }
- //Aufgerufen mit:
- set_idt_entry(0, &test_handler, 0, IDT_INTERRUPT_GATE | IDT_DPL_0);
- void test_handler() {
- kprintf("Ein Interrupt :)\n");
- while(true);
- }
Advertisement
Add Comment
Please, Sign In to add comment