From 3c1e4e5b421acb77fed481b94e0774f325edafa7 Mon Sep 17 00:00:00 2001 From: Polprzewodnikowy Date: Sun, 11 Sep 2022 11:32:08 +0200 Subject: [PATCH] sd menu fixes --- sw/bootloader/src/exception.S | 5 ++++- sw/bootloader/src/exception.c | 4 +--- sw/bootloader/src/exception_regs.h | 1 + sw/bootloader/src/menu.c | 5 +++-- sw/bootloader/src/vr4300.h | 1 + 5 files changed, 10 insertions(+), 6 deletions(-) diff --git a/sw/bootloader/src/exception.S b/sw/bootloader/src/exception.S index 307ef10..23219a1 100644 --- a/sw/bootloader/src/exception.S +++ b/sw/bootloader/src/exception.S @@ -41,7 +41,8 @@ #define C0_STATUS_OFFSET (256) #define C0_CAUSE_OFFSET (260) #define C0_EPC_OFFSET (264) -#define SAVE_REGISTERS_SIZE (272) +#define C0_BADVADDR_OFFSET (272) +#define SAVE_REGISTERS_SIZE (280) .section .text.exception_handler @@ -101,6 +102,8 @@ exception_fatal: sw $t0, C0_STATUS_OFFSET($k0) dmfc0 $t0, C0_EPC sd $t0, C0_EPC_OFFSET($k0) + dmfc0 $t0, C0_BADVADDR + sd $t0, C0_BADVADDR_OFFSET($k0) move $a2, $k0 la $t1, exception_fatal_handler jalr $t1 diff --git a/sw/bootloader/src/exception.c b/sw/bootloader/src/exception.c index 8c85641..b1af813 100644 --- a/sw/bootloader/src/exception.c +++ b/sw/bootloader/src/exception.c @@ -3,7 +3,6 @@ #include "exception_regs.h" #include "exception.h" #include "io.h" -#include "sc64.h" #include "version.h" #include "vr4300.h" #include "../assets/assets.h" @@ -44,7 +43,6 @@ static const char *exception_get_description (uint8_t exception_code) { void exception_fatal_handler (uint32_t exception_code, uint32_t interrupt_mask, exception_t *e) { version_t *version = version_get(); - uint32_t sc64_version = pi_io_read(&SC64_REGS->VERSION); uint32_t *instruction_address = (((uint32_t *) (e->epc.u32)) + ((e->cr & C0_CR_BD) ? 1 : 0)); display_init((uint32_t *) (&assets_exception_background)); @@ -55,7 +53,7 @@ void exception_fatal_handler (uint32_t exception_code, uint32_t interrupt_mask, display_printf("%s\n\n", exception_get_description(exception_code)); - display_printf("pc: 0x%08lX sr: 0x%08lX cr: 0x%08lX hw: 0x%08lX\n", e->epc.u32, e->sr, e->cr, sc64_version); + 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); display_printf("a0: 0x%08lX a1: 0x%08lX a2: 0x%08lX a3: 0x%08lX\n", e->a0.u32, e->a1.u32, e->a2.u32, e->a3.u32); display_printf("t0: 0x%08lX t1: 0x%08lX t2: 0x%08lX t3: 0x%08lX\n", e->t0.u32, e->t1.u32, e->t2.u32, e->t3.u32); diff --git a/sw/bootloader/src/exception_regs.h b/sw/bootloader/src/exception_regs.h index 2710428..6e23421 100644 --- a/sw/bootloader/src/exception_regs.h +++ b/sw/bootloader/src/exception_regs.h @@ -49,6 +49,7 @@ typedef struct { uint32_t sr; uint32_t cr; uint64_32_t epc; + uint64_32_t badvaddr; } exception_t; diff --git a/sw/bootloader/src/menu.c b/sw/bootloader/src/menu.c index 4b1f0aa..8f9b71d 100644 --- a/sw/bootloader/src/menu.c +++ b/sw/bootloader/src/menu.c @@ -59,9 +59,10 @@ void menu_load_and_run (void) { } FF_CHECK(f_read(&fil, menu, size, &br), "Couldn't read menu file"); FF_CHECK(br != size, "Read size is different than expected"); - + // TODO: delete this FF_CHECK(f_lseek(&fil, 0), "Couldn't seek to the beginning of file"); - FF_CHECK(f_read(&fil, (void *) (0x10000000UL), f_size(&fil), &br), "Couldn't read file contents to SDRAM"); + FF_CHECK(f_read(&fil, (void *) (0xB0000000UL), f_size(&fil), &br), "Couldn't read file contents to SDRAM"); + // TODO: ^ FF_CHECK(f_close(&fil), "Couldn't close menu file"); FF_CHECK(f_unmount(""), "Couldn't unmount drive"); diff --git a/sw/bootloader/src/vr4300.h b/sw/bootloader/src/vr4300.h index a9222d6..e25ba45 100644 --- a/sw/bootloader/src/vr4300.h +++ b/sw/bootloader/src/vr4300.h @@ -6,6 +6,7 @@ #define HIT_WRITE_BACK_D ((6 << 2) | 1) +#define C0_BADVADDR $8 #define C0_COUNT $9 #define C0_COMPARE $11 #define C0_STATUS $12