Interrupts are (for the most part) working

This commit is contained in:
c0repwn3r 2022-05-14 20:28:50 -04:00
parent c2f8ccdf2e
commit 1b3503bef6
Signed by: core
GPG Key ID: FDBF740DADDCEECF
6 changed files with 43 additions and 23 deletions

Binary file not shown.

Binary file not shown.

View File

@ -9,33 +9,53 @@ static int err_count = 0;
typedef struct { typedef struct {
struct { struct {
uint64_t cr4; uint64_t resv0;
uint64_t cr3; uint64_t resv1;
uint64_t cr2; uint64_t resv2;
uint64_t cr0; uint64_t resv3;
} control_registers; } broken;
struct { struct {
uint64_t rdi; uint64_t resv0;
uint64_t rsi; uint64_t resv1;
uint64_t rdx; uint64_t resv2;
uint64_t rcx; uint64_t resv3;
uint64_t rbx; uint64_t resv4;
uint64_t rax; uint64_t resv5;
} general_registers; } broken_2;
struct { struct {
uint64_t rbp; uint64_t resv0;
uint64_t vector;
uint64_t error_code; uint64_t error_code;
uint64_t rip; uint64_t resv1;
uint64_t cs; uint64_t vector;
uint64_t rflags; uint64_t resv2;
uint64_t rsp; uint64_t resv3;
uint64_t dss; uint64_t resv4;
uint64_t resv5;
} base_frame; } base_frame;
} isr_xframe_t; } isr_xframe_t;
/*
List of pushed things in order:
error_code
vector
rbp
rax
rbx
rcx
rdx
rsi
rdi
cr0
cr2
cr3
cr4
ds
0
*/
__attribute__((noreturn)) __attribute__((noreturn))
void exception_handler(isr_xframe_t frame); void exception_handler(isr_xframe_t frame);

View File

@ -74,6 +74,7 @@ isr_xframe_assembler:
mov ss, ax mov ss, ax
lea rdi, [rsp + 0x10] lea rdi, [rsp + 0x10]
call exception_handler call exception_handler
pop rax pop rax

View File

@ -2,7 +2,6 @@
#include <shade/platform/interrupts/isr.h> #include <shade/platform/interrupts/isr.h>
void exception_handler(isr_xframe_t frame) { void exception_handler(isr_xframe_t frame) {
err_count++;
char s[256]; char s[256];
itoa(err_count, s); itoa(err_count, s);
print_str(" "); print_str(" ");
@ -10,13 +9,11 @@ void exception_handler(isr_xframe_t frame) {
print_str(": cpu: check_exception "); print_str(": cpu: check_exception ");
itoa(frame.base_frame.vector, s); itoa(frame.base_frame.vector, s);
print_str(s); print_str(s);
print_str(" @ ");
itoa(frame.base_frame.rip, s);
print_str(s);
print_str(" err_code => "); print_str(" err_code => ");
itoa(frame.base_frame.error_code, s); itoa(frame.base_frame.error_code, s);
print_str(s); print_str(s);
print_str("\n"); print_str("\n");
err_count++;
if (err_count > ERR_MAX) { if (err_count > ERR_MAX) {
print_str("cpu: ierr hit err_max, halt"); print_str("cpu: ierr hit err_max, halt");
__asm__ __volatile__("cli; hlt"); __asm__ __volatile__("cli; hlt");

View File

@ -1,3 +1,5 @@
#include <shade/platform/ports.h>
/* /*
* Read 1 byte from specified port * Read 1 byte from specified port
*/ */