Instead of passing function pointers, we're passing structs with context now. The idea is the same, I/O functions require some struct with a function pointer and some generic memory that only the output device cares about. I/O just calls it. VGA has been reworked to accomodate this change, as well as default outputs being created for low-overhead use (such as interrupt handlers).
34 lines
1.3 KiB
C
34 lines
1.3 KiB
C
#include "interrupt_handlers.h"
|
|
#include "vga.h"
|
|
#include "io.h"
|
|
#include "serial.h"
|
|
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.
|
|
//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);
|
|
}
|
|
switch(cpu_state->interrupt_id) {
|
|
default:
|
|
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);
|
|
}
|
|
}
|
|
}
|