2025-06-17 02:40:02 +00:00
|
|
|
#include "interrupt_handlers.h"
|
2025-06-29 05:13:43 +00:00
|
|
|
#include "vga.h"
|
|
|
|
|
#include "io.h"
|
2025-07-03 05:36:47 +00:00
|
|
|
#include "serial.h"
|
2025-06-17 02:40:02 +00:00
|
|
|
void generic_isr_handler(StateSnapshot_t* cpu_state) {
|
|
|
|
|
//We made it to C for our interrupt! For now, let's just print our interrupt to the screen.
|
2025-07-03 05:36:47 +00:00
|
|
|
//What's cookin for outputs?
|
|
|
|
|
char_writer_t* out = 0;
|
|
|
|
|
if(default_COM) {
|
|
|
|
|
out = default_COM;
|
|
|
|
|
} else if(default_vga) {
|
|
|
|
|
out = default_vga;
|
|
|
|
|
vga_clear_ctx(default_vga->ctx);
|
|
|
|
|
}
|
2025-06-29 05:13:43 +00:00
|
|
|
switch(cpu_state->interrupt_id) {
|
|
|
|
|
default:
|
2025-07-03 05:36:47 +00:00
|
|
|
if(out){
|
|
|
|
|
printf(out, "INTERRUPT TRIGGERED! Info below.\n");
|
|
|
|
|
printf(out, "Int_ID|ERR: %X|%X\n", cpu_state->interrupt_id, cpu_state->error_code);
|
|
|
|
|
printf(out, "EFLAGS|CS|EIP: %X|%X|%X\n", cpu_state->eflags, cpu_state->cs,cpu_state->eip);
|
|
|
|
|
printf(out, "GP Registers:\neax:%X\nebx:%X\necx:%X\nedx:%X\nesp:%X\nebp:%X\nesi:%X\nedi:%X\n",
|
|
|
|
|
cpu_state->eax,
|
|
|
|
|
cpu_state->ebx,
|
|
|
|
|
cpu_state->ecx,
|
|
|
|
|
cpu_state->edx,
|
|
|
|
|
cpu_state->esp,
|
|
|
|
|
cpu_state->ebp,
|
|
|
|
|
cpu_state->esi,
|
|
|
|
|
cpu_state->edi);
|
|
|
|
|
printf(out, "HALT!");
|
|
|
|
|
while(1);
|
|
|
|
|
}
|
2025-06-29 05:13:43 +00:00
|
|
|
}
|
2025-06-17 02:40:02 +00:00
|
|
|
}
|