align interrupt stack

This commit is contained in:
2023-10-22 11:40:18 +02:00
parent 609c45a71c
commit 7b0083fa03
2 changed files with 6 additions and 3 deletions

View File

@@ -28,8 +28,11 @@ void gdt_setup() {
gdt_tss.unused = 0;
gdt_tss.gran = 0;
gdt_tss.base_high = (tss_base >> 24) & 0xFFFFFFFFFF;
tss_entry.ist1 = (uint64_t) &int_stack[INT_STACK_SIZE - 1];
tss_entry.rsp0 = (uint64_t) &rsp_stack[RSP_STACK_SIZE - 1];
tss_entry.ist1 = ((uintptr_t) int_stack + INT_STACK_SIZE - 1) & (~0xFULL);
if ((tss_entry.ist1 & 0xFULL) != 0) _hcf();
tss_entry.rsp0 = ((uintptr_t) rsp_stack + RSP_STACK_SIZE - 1) & (~0xFULL);
if ((tss_entry.rsp0 & 0xFULL) != 0) _hcf();
barrier();// The asm function might clobber registers
_gdt_setup();

View File

@@ -38,7 +38,7 @@ void idt_set_descriptor(uint8_t vector, void (*isr)(), uint8_t flags) {
descriptor->isr_low = (uint64_t) isr & 0xFFFF;
descriptor->kernel_cs = GDTSEL(gdt_code);
descriptor->ist = 0;
descriptor->ist = 1;
descriptor->attributes = flags;
descriptor->isr_mid = ((uint64_t) isr >> 16) & 0xFFFF;
descriptor->isr_high = ((uint64_t) isr >> 32) & 0xFFFFFFFF;