sd menu fixes

This commit is contained in:
Polprzewodnikowy 2022-09-11 11:32:08 +02:00
parent e6866e8fe0
commit 3c1e4e5b42
5 changed files with 10 additions and 6 deletions

View File

@ -41,7 +41,8 @@
#define C0_STATUS_OFFSET (256) #define C0_STATUS_OFFSET (256)
#define C0_CAUSE_OFFSET (260) #define C0_CAUSE_OFFSET (260)
#define C0_EPC_OFFSET (264) #define C0_EPC_OFFSET (264)
#define SAVE_REGISTERS_SIZE (272) #define C0_BADVADDR_OFFSET (272)
#define SAVE_REGISTERS_SIZE (280)
.section .text.exception_handler .section .text.exception_handler
@ -101,6 +102,8 @@ exception_fatal:
sw $t0, C0_STATUS_OFFSET($k0) sw $t0, C0_STATUS_OFFSET($k0)
dmfc0 $t0, C0_EPC dmfc0 $t0, C0_EPC
sd $t0, C0_EPC_OFFSET($k0) sd $t0, C0_EPC_OFFSET($k0)
dmfc0 $t0, C0_BADVADDR
sd $t0, C0_BADVADDR_OFFSET($k0)
move $a2, $k0 move $a2, $k0
la $t1, exception_fatal_handler la $t1, exception_fatal_handler
jalr $t1 jalr $t1

View File

@ -3,7 +3,6 @@
#include "exception_regs.h" #include "exception_regs.h"
#include "exception.h" #include "exception.h"
#include "io.h" #include "io.h"
#include "sc64.h"
#include "version.h" #include "version.h"
#include "vr4300.h" #include "vr4300.h"
#include "../assets/assets.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) { void exception_fatal_handler (uint32_t exception_code, uint32_t interrupt_mask, exception_t *e) {
version_t *version = version_get(); 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)); uint32_t *instruction_address = (((uint32_t *) (e->epc.u32)) + ((e->cr & C0_CR_BD) ? 1 : 0));
display_init((uint32_t *) (&assets_exception_background)); 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("%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("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("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); 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);

View File

@ -49,6 +49,7 @@ typedef struct {
uint32_t sr; uint32_t sr;
uint32_t cr; uint32_t cr;
uint64_32_t epc; uint64_32_t epc;
uint64_32_t badvaddr;
} exception_t; } exception_t;

View File

@ -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(f_read(&fil, menu, size, &br), "Couldn't read menu file");
FF_CHECK(br != size, "Read size is different than expected"); 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_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_close(&fil), "Couldn't close menu file");
FF_CHECK(f_unmount(""), "Couldn't unmount drive"); FF_CHECK(f_unmount(""), "Couldn't unmount drive");

View File

@ -6,6 +6,7 @@
#define HIT_WRITE_BACK_D ((6 << 2) | 1) #define HIT_WRITE_BACK_D ((6 << 2) | 1)
#define C0_BADVADDR $8
#define C0_COUNT $9 #define C0_COUNT $9
#define C0_COMPARE $11 #define C0_COMPARE $11
#define C0_STATUS $12 #define C0_STATUS $12