I get the error “check_cs(0x0020): not a valid code segment !” from Bochs after going through the isr for the timer: 0x20.
Here’s the code for the isr:
void timer_isr() {
// Acknowledge the PIC (send EOI)
outb(PIC2_COMMAND, 0x20); // Acknowledge interrupt to PIC 2
// Send EOI to PIC 1 (master)
outb(PIC1_COMMAND, 0x20); // Acknowledge interrupt to PIC 1
println("You're in the timer isr.");
asm __volatile__ ("iret");
}
I’m following the interrupts tutorial from osdev.org, this is their code sample for filling the IDT. I’ve added setting the timer isr to IRQ 0.
void init_idt() {
idtr.base = (uintptr_t)&idt[0];
idtr.limit = (u16)sizeof(idtEntry) * IDT_MAX_DESCRIPTORS - 1;
for (u8 vector = 0; vector < 32; vector++) {
idt_set_descriptor(vector, isr_stub_table[vector], 0x8E);
vectors[vector] = true;
}
// Set the PIC Timer interrupt
idt_set_descriptor(0x20, timer_isr, 0x8E);
vectors[0x20] = true;
asm __volatile__ ("lidt %0" : : "m"(idtr)); // load the new IDT
asm __volatile__ ("sti"); // set the interrupt flag
}
I’m remapping the PIC and setting up the GDT before any of this is called. The GDT and IDT are filled out fine according to Bochs. Here’s the github repo for the project: https://github.com/Wardence1/Basic_OS
Thanks in advance for the help!