]>
git.dujemihanovic.xyz Git - nameless-os.git/blob - kernel/arch/x86/irq/idt.c
4 /* Note to self: passing a pointer to an asm constraint as "m" will give a pointer to pointer */
5 inline void load_idt(struct idtr idtr
)
7 asm volatile ("lidt %0": : "m" (idtr
));
10 void idt_set_descriptor(struct idt_descriptor
*idt
, uint8_t vector
, uint16_t segment
, uint32_t offset
, uint8_t type
, uint8_t dpl
)
12 struct idt_descriptor
*descriptor
= &idt
[vector
];
14 descriptor
->offset_1
= offset
& 0xFFFF;
15 descriptor
->segsel
= segment
;
16 descriptor
->unused
= 0;
17 descriptor
->type
= type
;
18 descriptor
->dpl
= dpl
;
19 descriptor
->present
= 1;
20 descriptor
->offset_2
= offset
>> 16;
23 inline void populate_idtr(struct idtr
*idtr
, struct idt_descriptor
*idt
)
25 idtr
->limit
= ((IDT_VECTOR_COUNT
* IDT_DESCRIPTOR_SIZE
) - 1); /* limit must be size - 1 */
26 idtr
->base
= (uint32_t) idt
;