another small cleanup

This commit is contained in:
Mateusz Faderewski 2024-05-28 01:10:28 +02:00
parent a6a223a127
commit 10454f4cb6
4 changed files with 26 additions and 10 deletions

View File

@ -33,11 +33,13 @@
#define SP_OFFSET (232)
#define S8_OFFSET (240)
#define RA_OFFSET (248)
#define C0_STATUS_OFFSET (256)
#define C0_CAUSE_OFFSET (260)
#define C0_EPC_OFFSET (264)
#define C0_BADVADDR_OFFSET (272)
#define SAVE_REGISTERS_SIZE (280)
#define HI_OFFSET (256)
#define LO_OFFSET (264)
#define C0_EPC_OFFSET (272)
#define C0_BADVADDR_OFFSET (280)
#define C0_STATUS_OFFSET (288)
#define C0_CAUSE_OFFSET (292)
#define SAVE_REGISTERS_SIZE (296)
.section .text.exception_vector
@ -93,6 +95,10 @@ exception_handler:
sd $sp, SP_OFFSET($k0)
sd $s8, S8_OFFSET($k0)
sd $ra, RA_OFFSET($k0)
mfhi $t0
mflo $t1
sd $t0, HI_OFFSET($k0)
sd $t1, LO_OFFSET($k0)
.set at
move $sp, $k0
@ -130,6 +136,10 @@ exception_interrupt:
exception_restore:
.set noat
ld $t0, HI_OFFSET($k0)
ld $t1, LO_OFFSET($k0)
mthi $t0
mtlo $t1
ld $at, AT_OFFSET($k0)
ld $v0, V0_OFFSET($k0)
ld $v1, V1_OFFSET($k0)

View File

@ -34,8 +34,10 @@ static const char *exception_get_description (uint8_t exception_code) {
void exception_fatal_handler (uint32_t exception_code, exception_t *e) {
display_init((uint32_t *) (&assets_sc64_logo_640_240_dimmed));
uint32_t exception_address = e->epc.u32 + (e->cr & C0_CR_BD ? 4 : 0);
version_print();
display_printf("[ Unhandled exception ]\n");
display_printf("[ Unhandled exception ] @ 0x%08X\n", exception_address);
display_printf("%s\n", exception_get_description(exception_code));
display_printf(" pc: 0x%08lX sr: 0x%08lX cr: 0x%08lX va: 0x%08lX\n", e->epc.u32, e->sr, e->cr, e->badvaddr.u32);
display_printf(" zr: 0x%08lX at: 0x%08lX v0: 0x%08lX v1: 0x%08lX\n", e->zr.u32, e->at.u32, e->v0.u32, e->v1.u32);
@ -45,7 +47,9 @@ void exception_fatal_handler (uint32_t exception_code, exception_t *e) {
display_printf(" s0: 0x%08lX s1: 0x%08lX s2: 0x%08lX s3: 0x%08lX\n", e->s0.u32, e->s1.u32, e->s2.u32, e->s3.u32);
display_printf(" s4: 0x%08lX s5: 0x%08lX s6: 0x%08lX s7: 0x%08lX\n", e->s4.u32, e->s5.u32, e->s6.u32, e->s7.u32);
display_printf(" t8: 0x%08lX t9: 0x%08lX k0: 0x%08lX k1: 0x%08lX\n", e->t8.u32, e->t9.u32, e->k0.u32, e->k1.u32);
display_printf(" gp: 0x%08lX sp: 0x%08lX s8: 0x%08lX ra: 0x%08lX\n\n", e->gp.u32, e->sp.u32, e->s8.u32, e->ra.u32);
display_printf(" gp: 0x%08lX sp: 0x%08lX s8: 0x%08lX ra: 0x%08lX\n", e->gp.u32, e->sp.u32, e->s8.u32, e->ra.u32);
display_printf(" hi: 0x%016lX\n", e->hi.u64);
display_printf(" lo: 0x%016lX\n", e->lo.u64);
while (true);
}

View File

@ -46,10 +46,12 @@ typedef struct {
uint64_32_t sp;
uint64_32_t s8;
uint64_32_t ra;
uint32_t sr;
uint32_t cr;
uint64_32_t hi;
uint64_32_t lo;
uint64_32_t epc;
uint64_32_t badvaddr;
uint32_t sr;
uint32_t cr;
} exception_t;

View File

@ -1,6 +1,6 @@
#include "error.h"
#include "io.h"
#include "sc64.h"
#include "error.h"
typedef struct {