summaryrefslogtreecommitdiff
path: root/src/include/toxic/idt.h
blob: f54f7f7873b780d99e75c529a87d03c042c61636 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#ifndef IDT_H
#define IDT_H
#include <stdint.h>

/* ATTR byte field values */
#define INT_GATE_32	0x0E
#define TRAP_GATE_32	0x0F
#define DPL_RING3	0x60
#define PRESENT_BIT	(1 << 7)

#define TOXIC_INT_ATTR (PRESENT_BIT | DPL_RING3 | INT_GATE_32)

struct int_descriptor {
	uint16_t	offset_low;	/* bits 0..15 */
	uint16_t	selector;	/* Code segment selector */
	uint8_t		reserved;	/* Unused, must be 0 */
	uint8_t		type_attr;	/* gate type, DPL, presence */
	uint16_t	offset_high;	/* bits 16..31 */
} __attribute__((packed));

struct int_reg_descriptor {
	uint16_t	limit;	/* Int descriptor table size (bytes) -1 */
	uint32_t	base;	/* Table starting offset (linear address) */
} __attribute__((packed));

void interrupts_init(void);
#endif /* IDT_H */