diff --git a/sw/n64/src/error.c b/sw/n64/src/error.c index f726a84..df945d0 100644 --- a/sw/n64/src/error.c +++ b/sw/n64/src/error.c @@ -1,12 +1,17 @@ +#include #include "exception.h" void error_display (const char *fmt, ...) { + va_list args; + + va_start(args, fmt); EXCEPTION_TRIGGER(TRIGGER_CODE_ERROR); + va_end(args); + while (1); } void __assert_func (const char *file, int line, const char *func, const char *failedexpr) { - EXCEPTION_TRIGGER(TRIGGER_CODE_ASSERT); while (1); } diff --git a/sw/n64/src/exception.S b/sw/n64/src/exception.S index d3f08a4..8203f3e 100644 --- a/sw/n64/src/exception.S +++ b/sw/n64/src/exception.S @@ -182,16 +182,6 @@ exception_install: jr $ra -.section .text.exception_disable_interrupts -exception_disable_interrupts: - .global exception_disable_interrupts - mfc0 $t0, C0_STATUS - li $t1, ~(C0_SR_IE) - and $t0, $t0, $t1 - mtc0 $t0, C0_STATUS - jr $ra - - .section .text.exception_enable_interrupts exception_enable_interrupts: .global exception_enable_interrupts @@ -202,6 +192,16 @@ exception_enable_interrupts: jr $ra +.section .text.exception_disable_interrupts +exception_disable_interrupts: + .global exception_disable_interrupts + mfc0 $t0, C0_STATUS + li $t1, ~(C0_SR_IE) + and $t0, $t0, $t1 + mtc0 $t0, C0_STATUS + jr $ra + + .section .text.exception_enable_watchdog exception_enable_watchdog: .global exception_enable_watchdog diff --git a/sw/n64/src/exception.c b/sw/n64/src/exception.c index c2625cc..bf9b485 100644 --- a/sw/n64/src/exception.c +++ b/sw/n64/src/exception.c @@ -72,6 +72,7 @@ typedef struct { #define BACKGROUND_COLOR (0xFFFFFFFFUL) #define FOREGROUND_COLOR (0x000000FFUL) +#define BORDER_COLOR (0x2F2F2FFFUL) #define LINE_HEIGHT (12) @@ -112,8 +113,21 @@ static io32_t *exception_framebuffer = (io32_t *) (0x0026A000UL); static void exception_init_screen (void) { const vi_regs_t *cfg = &vi_config[OS_INFO->tv_type]; - for (int i = 0; i < (SCREEN_WIDTH * SCREEN_HEIGHT); i++) { - io_write(&exception_framebuffer[i], BACKGROUND_COLOR); + for (int y = 0; y < SCREEN_HEIGHT; y++) { + for (int x = 0; x < SCREEN_WIDTH; x++) { + uint32_t color; + if ( + (x < (BORDER_WIDTH - FONT_WIDTH)) || + (x > (SCREEN_WIDTH - BORDER_WIDTH + FONT_WIDTH)) || + (y < (BORDER_HEIGHT - FONT_HEIGHT)) || + (y > (SCREEN_HEIGHT - BORDER_HEIGHT + FONT_HEIGHT)) + ) { + color = BORDER_COLOR; + } else { + color = BACKGROUND_COLOR; + } + io_write(&exception_framebuffer[x + (y * SCREEN_WIDTH)], color); + } } io_write(&VI->MADDR, (uint32_t) (exception_framebuffer)); @@ -235,14 +249,9 @@ void exception_fatal_handler (uint32_t exception_code, uint32_t interrupt_mask, uint32_t code = (((*instruction_address) & SYSCALL_CODE_MASK) >> SYSCALL_CODE_BIT); if (code == TRIGGER_CODE_ERROR) { - exception_vprint((const char *) (e->a0.u32), (va_list) (e->sp.u32 + 8)); - } else if (code == TRIGGER_CODE_ASSERT) { - const char *file = (const char *) (e->a0.u32); - int line = (int) (e->a1.u32); - const char *func = (const char *) (e->a2.u32); - const char *failedexpr = (const char *) (e->a3.u32); - exception_print("Assertion \"%s\" failed:\n", failedexpr); - exception_print(" file \"%s\", line %d, %s%s\n", file, line, func ? "function: " : "", func); + const char *fmt = (const char *) (e->a0.u32); + va_list args = *((va_list *) (e->sp.u32)); + exception_vprint(fmt, args); } } diff --git a/sw/n64/src/exception.h b/sw/n64/src/exception.h index 6a75299..7b3873e 100644 --- a/sw/n64/src/exception.h +++ b/sw/n64/src/exception.h @@ -3,7 +3,6 @@ #define TRIGGER_CODE_ERROR (0) -#define TRIGGER_CODE_ASSERT (16) #define EXCEPTION_TRIGGER(code) { asm volatile ("syscall %[c]\n" :: [c] "i" (code)); }