Fixed SD card fault display + ROM boot changes

This commit is contained in:
Mateusz Faderewski 2023-07-29 11:52:24 +02:00
parent 9f5557ff36
commit 25bb6f343c
5 changed files with 173 additions and 169 deletions

View File

@ -5,6 +5,11 @@
#include "crc32.h"
#define C0_STATUS_FR (1 << 26)
#define C0_STATUS_CU0 (1 << 28)
#define C0_STATUS_CU1 (1 << 29)
extern uint32_t ipl2 __attribute__((section(".data")));
@ -75,14 +80,10 @@ void boot (boot_params_t *params) {
}
}
// asm volatile (
// "li $t1, %[status] \n"
// "mtc0 $t1, $12 \n" ::
// [status] "i" (C0_SR_CU1 | C0_SR_CU0 | C0_SR_FR)
// );
OS_INFO->mem_size_6105 = OS_INFO->mem_size;
C0_WRITE_STATUS(C0_STATUS_CU1 | C0_STATUS_CU0 | C0_STATUS_FR);
while (!(cpu_io_read(&SP->SR) & SP_SR_HALT));
cpu_io_write(&SP->SR, SP_SR_CLR_INTR | SP_SR_SET_HALT);

View File

@ -39,6 +39,7 @@ static flashcart_t *flashcart = &((flashcart_t) {
flashcart_error_t flashcart_init (void) {
bool sd_initialized;
flashcart_error_t error;
// HACK: Because libcart reads PI config from address 0x10000000 when initializing
@ -48,9 +49,7 @@ flashcart_error_t flashcart_init (void) {
extern uint32_t cart_dom1;
cart_dom1 = 0x80371240;
if (!debug_init_sdfs("sd:/", -1)) {
return FLASHCART_ERROR_NOT_DETECTED;
}
sd_initialized = debug_init_sdfs("sd:/", -1);
// NOTE: Flashcart model is extracted from libcart after debug_init_sdfs call is made
extern int cart_type;
@ -66,13 +65,17 @@ flashcart_error_t flashcart_init (void) {
break;
default:
return FLASHCART_ERROR_UNSUPPORTED;
return FLASHCART_ERROR_NOT_DETECTED;
}
if ((error = flashcart->init()) != FLASHCART_OK) {
return error;
}
if (!sd_initialized) {
return FLASHCART_ERROR_SD_CARD;
}
#ifndef MENU_NO_USB_LOG
// NOTE: Some flashcarts doesn't have USB port, can't throw error here
debug_init_usblog();

View File

@ -16,8 +16,8 @@
typedef enum {
FLASHCART_OK,
FLASHCART_ERROR_NOT_DETECTED,
FLASHCART_ERROR_UNSUPPORTED,
FLASHCART_ERROR_OUTDATED,
FLASHCART_ERROR_SD_CARD,
FLASHCART_ERROR_ARGS,
FLASHCART_ERROR_LOAD,
FLASHCART_ERROR_INT,

View File

@ -11,10 +11,10 @@ static char *format_flashcart_error (flashcart_error_t error) {
return "No error";
case FLASHCART_ERROR_NOT_DETECTED:
return "No flashcart hardware was detected";
case FLASHCART_ERROR_UNSUPPORTED:
return "Unsupported flashcart";
case FLASHCART_ERROR_OUTDATED:
return "Outdated flashcart firmware";
case FLASHCART_ERROR_SD_CARD:
return "Error during SD card initialization";
case FLASHCART_ERROR_ARGS:
return "Invalid argument passed to flashcart function";
case FLASHCART_ERROR_LOAD:

View File

@ -181,7 +181,7 @@ static void load (menu_t *menu) {
path_free(path);
menu->boot_params->device_type = BOOT_DEVICE_TYPE_ROM;
menu->boot_params->reset_type = BOOT_RESET_TYPE_COLD;
menu->boot_params->reset_type = BOOT_RESET_TYPE_NMI;
menu->boot_params->tv_type = BOOT_TV_TYPE_PASSTHROUGH;
menu->boot_params->detect_cic_seed = true;
}