1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 14:37:46 +00:00

Kernel: Add support for interrupts on x86_64

This commit is contained in:
Gunnar Beutner 2021-06-26 14:57:13 +02:00 committed by Andreas Kling
parent 233ef26e4d
commit 065c6c307d
4 changed files with 98 additions and 19 deletions

View file

@ -116,9 +116,15 @@ struct [[gnu::packed]] IDTEntry
u16 offset_1; // offset bits 0..15
u16 selector; // a code segment selector in GDT or LDT
u8 zero; // unused, set to 0 (maybe used on amd64)
#if ARCH(I386)
u8 zero; // unused, set to 0
#else
struct {
u8 interrupt_stack_table : 3;
u8 zero : 5; // unused, set to 0
};
#endif
struct {
// FIXME: Is the order correct?
u8 gate_type : 4;
u8 storage_segment : 1;
u8 descriptor_privilege_level : 2;
@ -126,7 +132,6 @@ struct [[gnu::packed]] IDTEntry
} type_attr; // type and attributes
u16 offset_2; // offset bits 16..31
#if !ARCH(I386)
// we may need to switch those around?
u32 offset_3;
u32 zeros;
#endif
@ -135,6 +140,9 @@ struct [[gnu::packed]] IDTEntry
IDTEntry(FlatPtr callback, u16 selector_, IDTEntryType type, u8 storage_segment, u8 privilege_level)
: offset_1 { (u16)((FlatPtr)callback & 0xFFFF) }
, selector { selector_ }
#if !ARCH(I386)
, interrupt_stack_table { 0 }
#endif
, zero { 0 }
, type_attr {
.gate_type = (u8)type,
@ -150,7 +158,7 @@ struct [[gnu::packed]] IDTEntry
{
}
u32 off()
FlatPtr off()
{
#if ARCH(I386)
return (u32)offset_2 << 16 & (u32)offset_1;
@ -165,4 +173,6 @@ struct [[gnu::packed]] IDTEntry
};
// clang-format on
static_assert(sizeof(IDTEntry) == 2 * sizeof(void*));
}