Files
super6502/sw/boot/load_bootsect.c
Byron Lathi 12284d19a9 Create boot environment
The boot environment will read the boot sector from the sd card, verify
that it has the boot signature at the end, then jump to the start of it.

From there, there should be a bootloader written to the boot segment
that can handle the rest.

It might be tight to fit everything into the boot sector but do remember
that you do not have to initialize or select the sd card, and those
functions take up a lot of space.
2022-04-18 12:43:29 -05:00

29 lines
613 B
C

#include <stdint.h>
#include "devices/sd_card.h"
#define BOOTSECTOR_LOAD_ADDRESS 0x1000
#define BOOTSIG_0 0x55
#define BOOTSIG_1 0xaa
//Should probably do this in asm
void load_bootsect() {
uint32_t rca;
uint8_t sig[2];
sd_init();
rca = sd_get_rca();
sd_select_card(rca);
sd_readblock(0, (uint8_t*)BOOTSECTOR_LOAD_ADDRESS);
sig[0] = ((uint8_t*)BOOTSECTOR_LOAD_ADDRESS)[510];
sig[1] = ((uint8_t*)BOOTSECTOR_LOAD_ADDRESS)[511];
if (sig[0] != BOOTSIG_0 || sig[1] != BOOTSIG_1) {
for(;;); //maybe figure out a way to have an error message here
}
return;
}