View difference between Paste ID: A25Gy2Xu and 97ccvSci
SHOW: | | - or go back to the newest paste.
1
#include "idt.h"
2
3
#define IDT_ENTRIES 1
4
5
static uint64_t idt[IDT_ENTRIES];
6
7
void load_idt() {
8
	struct {
9
		  unsigned short int limit;
10
		  void* pointer;
11
	} __attribute__((packed)) idtp = {
12
		  .limit = IDT_ENTRIES * 8 - 1,
13
		  .pointer = idt,
14
	};
15
	asm volatile("lidt %0" : : "m" (idtp));
16
}
17
18
void set_idt_entry(int i, uint32_t address, uint16_t selector, uint16_t x) {
19
	idt[i]  = address & 0x00FF;
20
	idt[i] |= (address & 0xFF00LL) << 32;
21
	idt[i] |= (selector & 0xFFLL) << 16;
22
23
	x |= 0b100010000000000;
24
	
25
	idt[i] |= (x & 0xFFLL) << 32;
26
}
27
28
29
//Aufgerufen mit:
30
31
set_idt_entry(0, &test_handler, 0, IDT_INTERRUPT_GATE | IDT_DPL_0);
32
33
34
void test_handler() {
35
	kprintf("Ein Interrupt :)\n");
36
	while(true);
37
}