Skip to content

Instantly share code, notes, and snippets.

@Killaship
Last active August 23, 2021 21:38
Show Gist options
  • Save Killaship/6538799d8d8d532076f47206dd9b039c to your computer and use it in GitHub Desktop.
Save Killaship/6538799d8d8d532076f47206dd9b039c to your computer and use it in GitHub Desktop.
err handler copy-paste
/*This is just some code to copy-paste, to make exception handler coding easier. By: me, Killaship.
Probably going to be obsolete by the time I make a function to semi-automate the IDTentry-making.*/
div0_address = (unsigned long)div0_handler;
IDT[0x00].offset_lowerbits = div0_address & 0xffff;
IDT[0x00].selector = KERNEL_CODE_SEGMENT_OFFSET;
IDT[0x00].zero = 0;
IDT[0x00].type_attr = INTERRUPT_GATE;
IDT[0x00].offset_higherbits = (div0_address & 0xffff0000) >> 16;
void div0_handler() {
//kprint_newline();
unsigned int i = 0;
while (i < SCREENSIZE) {
vidptr[i++] = ' ';
vidptr[i++] = 0x44;
}
kprint("err: kernel panic!",0x40);
kprint_newline();
kprint("err type:",0x40);
kprint_newline();
kprint("fault: divide-by-zero (0x00)",0x40);
kprint_newline();
kprint_newline();
asm volatile(
"1:\n\t"
"cli\n\t"
"hlt\n\t"
"jmp 1b\n\t"
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment