2021-02-09 23:58:02 +01:00
|
|
|
#include "boot/boot.h"
|
2021-02-01 00:40:56 +01:00
|
|
|
|
2021-08-23 21:40:37 +02:00
|
|
|
typedef struct sc64_cart_registers {
|
|
|
|
__IO reg_t SCR;
|
|
|
|
__IO reg_t COMMAND;
|
|
|
|
__IO reg_t ARG[2];
|
|
|
|
__IO reg_t RESPONSE;
|
|
|
|
__IO reg_t BOOTSTRAP;
|
|
|
|
} sc64_cfg_registers_t;
|
2021-02-01 00:40:56 +01:00
|
|
|
|
2021-08-23 21:40:37 +02:00
|
|
|
#define SC64_CFG_BASE (0x1FFF0000)
|
2021-02-14 21:56:50 +01:00
|
|
|
|
2021-08-23 21:40:37 +02:00
|
|
|
#define SC64_CFG ((__IO sc64_cfg_registers_t *) SC64_CFG_BASE)
|
2021-02-14 21:56:50 +01:00
|
|
|
|
2021-08-23 21:40:37 +02:00
|
|
|
#define SC64_CFG_SCR_CPU_BOOTSTRAPPED (1 << 31)
|
|
|
|
#define SC64_CFG_SCR_CPU_BUSY (1 << 30)
|
2021-02-01 00:40:56 +01:00
|
|
|
|
2021-08-23 21:40:37 +02:00
|
|
|
#define CMD_SDRAM_SWITCH 'S'
|
2021-08-26 00:22:39 +02:00
|
|
|
#define CMD_DEBUG 'D'
|
|
|
|
|
|
|
|
void print_debug(uint32_t a1, uint32_t a2) {
|
|
|
|
|
|
|
|
uint32_t scr = 0;
|
|
|
|
do {
|
|
|
|
scr = platform_pi_io_read(&SC64_CFG->SCR);
|
|
|
|
} while (scr & SC64_CFG_SCR_CPU_BUSY);
|
|
|
|
|
|
|
|
platform_pi_io_write(&SC64_CFG->ARG[0], a1);
|
|
|
|
platform_pi_io_write(&SC64_CFG->ARG[1], a2);
|
|
|
|
platform_pi_io_write(&SC64_CFG->COMMAND, (uint32_t) CMD_DEBUG);
|
|
|
|
}
|
2020-10-08 02:04:42 +02:00
|
|
|
|
|
|
|
int main(void) {
|
2021-08-23 21:40:37 +02:00
|
|
|
OS_BOOT_CONFIG->tv_type = TV_NTSC;
|
2021-02-14 21:56:50 +01:00
|
|
|
|
2021-08-23 21:40:37 +02:00
|
|
|
uint32_t scr = 0;
|
2021-02-14 21:56:50 +01:00
|
|
|
|
2021-08-23 21:40:37 +02:00
|
|
|
do {
|
|
|
|
scr = platform_pi_io_read(&SC64_CFG->SCR);
|
|
|
|
} while (!(scr & SC64_CFG_SCR_CPU_BOOTSTRAPPED));
|
2020-10-08 02:04:42 +02:00
|
|
|
|
2021-08-23 21:40:37 +02:00
|
|
|
do {
|
|
|
|
scr = platform_pi_io_read(&SC64_CFG->SCR);
|
|
|
|
} while (scr & SC64_CFG_SCR_CPU_BUSY);
|
2021-02-01 00:40:56 +01:00
|
|
|
|
2021-08-23 21:40:37 +02:00
|
|
|
platform_pi_io_write(&SC64_CFG->ARG[0], 1);
|
|
|
|
platform_pi_io_write(&SC64_CFG->COMMAND, (uint32_t) CMD_SDRAM_SWITCH);
|
2021-02-01 00:40:56 +01:00
|
|
|
|
2021-08-23 21:40:37 +02:00
|
|
|
do {
|
|
|
|
scr = platform_pi_io_read(&SC64_CFG->SCR);
|
|
|
|
} while (scr & SC64_CFG_SCR_CPU_BUSY);
|
2021-02-01 00:40:56 +01:00
|
|
|
|
2021-08-23 21:40:37 +02:00
|
|
|
cart_header_t *cart_header = boot_load_cart_header();
|
|
|
|
uint16_t cic_seed = boot_get_cic_seed(cart_header);
|
|
|
|
tv_type_t tv_type = boot_get_tv_type(cart_header);
|
2020-10-08 02:04:42 +02:00
|
|
|
|
2021-08-26 00:22:39 +02:00
|
|
|
print_debug(cic_seed << 16 | (tv_type & 0x03), cart_header->pi_conf);
|
|
|
|
|
2021-08-23 21:40:37 +02:00
|
|
|
boot(cart_header, cic_seed, tv_type);
|
2020-10-08 02:04:42 +02:00
|
|
|
}
|