Until now the code would set the most significant bit in the type part
of the IDT descriptor for trap gates as a result of my error, causing a
triple fault when trying to handle a double fault. A less significant, but still
noteworthy change is that the double fault handler has been slightly revamped to
print out :( on a red background and no longer spits out a warning because I
accidentally wrote a string there, not a char.
#define IDT_VECTOR_COUNT 256 /* our IDT will have 256 vectors */
#define IDT_DESCRIPTOR_SIZE 8 /* each IDT descriptor is 8 bytes long */
-#define IDT_TRAP_GATE 0x1F
-#define IDT_INTERRUPT_GATE 0x0E
+#define IDT_TRAP_GATE 0xF
+#define IDT_INTERRUPT_GATE 0xE
struct idt_descriptor {
uint16_t offset_1; /* bits 0-15 of offset */
__attribute__((interrupt))
void double_fault(struct abort_frame *frame)
{
- *(volatile char *) (0xb8000) = ":";
- *(volatile char *) (0xb8002) = "(";
+ *(volatile uint32_t *) (0xb8000) = 0xcf28cf3a;
+halt:
asm volatile ("cli; hlt");
- while(1);
+ goto halt;
}