bootloader improvements

This commit is contained in:
Polprzewodnikowy 2022-09-18 20:48:10 +02:00
parent ad802282b7
commit 0f42c6e0d7
11 changed files with 42 additions and 43 deletions

View File

@ -40,7 +40,7 @@ SRC_FILES = \
fatfs/ffunicode.c
ASSET_FILES = \
exception_background.png
sc64_logo_640_240_dimmed.png
SRCS = $(SRC_FILES) $(ASSET_FILES)
SRC_OBJS = $(patsubst %,%.o,$(SRC_FILES))

View File

@ -1,6 +1,7 @@
MEMORY {
rdram (rwx) : org = 0x80300000, len = 1M
flash (r) : org = 0xB0000000, len = 1028k
framebuffer (rw) : org = 0x8026A000, len = 600k
ram (rwx) : org = 0x80300000, len = 1M
rom (r) : org = 0xB0000000, len = 1028k
}
ENTRY(entry_handler)
@ -9,23 +10,28 @@ __exception_stack_size = 8k;
__stack_size = 16k;
SECTIONS {
.flash : {
.boot : {
KEEP(*(.text.rom_header));
KEEP(*(.text.ipl3));
} > flash
} > rom
.framebuffer (NOLOAD) : SUBALIGN(64) {
*(.framebuffer .framebuffer.*)
} > framebuffer
.text : SUBALIGN(4) {
*(.text.entry_handler)
*(.text .text.* .gnu.linkonce.t.*)
*(.assets .assets.*)
*(.rodata .rodata.* .gnu.linkonce.r.*)
*(.data .data.* .gnu.linkonce.d.*)
_gp = . + 0x8000;
*(.sdata .sdata.* .gnu.linkonce.s.*)
*(.lit8 .lit4)
. = ALIGN(8);
} > rdram AT > flash
} > ram AT > rom
.bss : {
. = ALIGN(8);
_sbss = .;
*(.sbss .sbss.* .gnu.linkonce.sb.*)
*(.scommon .scommon.*)
@ -33,10 +39,10 @@ SECTIONS {
*(COMMON)
. = ALIGN(8);
_ebss = .;
} > rdram
} > ram
_sheap = .;
. = ORIGIN(rdram) + LENGTH(rdram) - __exception_stack_size - __stack_size;
. = ORIGIN(ram) + LENGTH(ram) - __exception_stack_size - __stack_size;
_eheap = .;
. += __exception_stack_size;

View File

@ -1,3 +1,4 @@
.section .assets.@sym@
.global assets_@sym@
assets_@sym@:
.incbin "@file@"

View File

@ -5,7 +5,7 @@
#include <stdint.h>
extern const uint32_t assets_exception_background;
extern const uint32_t assets_sc64_logo_640_240_dimmed;
#endif

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 42 KiB

View File

@ -66,14 +66,9 @@ bool boot_get_tv_type (boot_info_t *info) {
bool boot_get_cic_seed_version (boot_info_t *info) {
io32_t *base = boot_get_device_base(info);
uint32_t ipl3[1008];
uint32_t ipl3[1008] __attribute__((aligned(8)));
io32_t *ipl3_src = &base[16];
uint32_t *ipl3_dst = ipl3;
for (int i = 0; i < sizeof(ipl3); i += sizeof(uint32_t)) {
*ipl3_dst++ = pi_io_read(ipl3_src++);
}
pi_dma_read(&base[16], ipl3, sizeof(ipl3));
uint32_t crc32 = crc32_calculate(ipl3, sizeof(ipl3));

View File

@ -6,15 +6,15 @@
#define SCREEN_WIDTH (640)
#define SCREEN_HEIGHT (240)
#define BORDER_WIDTH (32)
#define BORDER_HEIGHT (16)
#define BORDER_WIDTH (64)
#define BORDER_HEIGHT (24)
#define BACKGROUND_COLOR (0x00000000UL)
#define TEXT_COLOR (0xFFFFFFFFUL)
#define LINE_HEIGHT (10)
#define LINE_SPACING (2)
static io32_t display_framebuffer[SCREEN_WIDTH * SCREEN_HEIGHT] __attribute__((aligned(64)));
static io32_t display_framebuffer[SCREEN_WIDTH * SCREEN_HEIGHT] __attribute__((section(".framebuffer")));
static int char_x;
static int char_y;
static const vi_regs_t vi_config[] = {{
@ -63,13 +63,13 @@ static const vi_regs_t vi_config[] = {{
static void display_draw_character (char c) {
if (c == '\n') {
char_x = BORDER_WIDTH;
char_y += LINE_HEIGHT;
char_y += FONT_HEIGHT + LINE_SPACING;
return;
}
if ((char_x + FONT_WIDTH) > (SCREEN_WIDTH - BORDER_WIDTH)) {
char_x = BORDER_WIDTH;
char_y += LINE_HEIGHT;
char_y += FONT_HEIGHT + LINE_SPACING;
}
if ((c < ' ') || (c > '~')) {
@ -107,14 +107,12 @@ void display_init (uint32_t *background) {
char_y = BORDER_HEIGHT;
if (background == NULL) {
for (int i = 0; i < (SCREEN_WIDTH * SCREEN_HEIGHT); i += 1) {
for (int i = 0; i < (SCREEN_WIDTH * SCREEN_HEIGHT); i++) {
io_write(&display_framebuffer[i], BACKGROUND_COLOR);
}
} else {
for (int i = 0; i < (SCREEN_WIDTH * SCREEN_HEIGHT); i += 2) {
io_write(&display_framebuffer[i], *background);
io_write(&display_framebuffer[i + 1], *background);
background++;
for (int i = 0; i < (SCREEN_WIDTH * SCREEN_HEIGHT); i++) {
io_write(&display_framebuffer[i], *background++);
}
}

View File

@ -45,14 +45,13 @@ void exception_fatal_handler (uint32_t exception_code, uint32_t interrupt_mask,
version_t *version = version_get();
uint32_t *instruction_address = (((uint32_t *) (e->epc.u32)) + ((e->cr & C0_CR_BD) ? 1 : 0));
display_init((uint32_t *) (&assets_exception_background));
display_init((uint32_t *) (&assets_sc64_logo_640_240_dimmed));
display_printf("branch: %s | tag: %s\n", version->git_branch, version->git_tag);
display_printf("sha: %s\n", version->git_sha);
display_printf("%s\n\n", version->git_message);
display_printf("%s\n\n", exception_get_description(exception_code));
display_printf("%s\n", exception_get_description(exception_code));
display_printf(" pc: 0x%08lX sr: 0x%08lX cr: 0x%08lX va: 0x%08lX\n", e->epc.u32, e->sr, e->cr, e->badvaddr.u32);
display_printf(" zr: 0x%08lX at: 0x%08lX v0: 0x%08lX v1: 0x%08lX\n", e->zr.u32, e->at.u32, e->v0.u32, e->v1.u32);
display_printf(" a0: 0x%08lX a1: 0x%08lX a2: 0x%08lX a3: 0x%08lX\n", e->a0.u32, e->a1.u32, e->a2.u32, e->a3.u32);

View File

@ -201,8 +201,8 @@ bool sc64_sd_read_sectors (uint32_t *address, uint32_t sector, uint32_t count) {
return sc64_execute_cmd(SC64_CMD_SD_READ, read_args, NULL);
}
bool sc64_dd_set_sd_disk_info (uint32_t *address, uint32_t count) {
uint32_t args[2] = { (uint32_t) (address), count };
bool sc64_dd_set_sd_disk_info (uint32_t *address, uint32_t length) {
uint32_t args[2] = { (uint32_t) (address), length };
if (sc64_execute_cmd(SC64_CMD_DD_SD_DISK_INFO, args, NULL)) {
return true;
}

View File

@ -111,7 +111,7 @@ bool sc64_sd_card_get_status (void);
bool sc64_sd_card_get_info (uint32_t *address);
bool sc64_sd_write_sectors (uint32_t *address, uint32_t sector, uint32_t count);
bool sc64_sd_read_sectors (uint32_t *address, uint32_t sector, uint32_t count);
bool sc64_dd_set_sd_disk_info (uint32_t *address, uint32_t count);
bool sc64_dd_set_sd_disk_info (uint32_t *address, uint32_t length);
#endif