46 lines
1.3 KiB
C
Raw Normal View History

2021-02-09 23:58:02 +01:00
#include "boot/boot.h"
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-08-23 21:40:37 +02:00
#define SC64_CFG_BASE (0x1FFF0000)
2021-08-23 21:40:37 +02:00
#define SC64_CFG ((__IO sc64_cfg_registers_t *) SC64_CFG_BASE)
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-08-23 21:40:37 +02:00
#define CMD_SDRAM_SWITCH 'S'
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-08-23 21:40:37 +02:00
uint32_t scr = 0;
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-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-08-23 21:40:37 +02:00
do {
scr = platform_pi_io_read(&SC64_CFG->SCR);
} while (scr & SC64_CFG_SCR_CPU_BUSY);
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-23 21:40:37 +02:00
boot(cart_header, cic_seed, tv_type);
2020-10-08 02:04:42 +02:00
}