Compare commits

...

4 commits

Author SHA1 Message Date
Gered d6297305cf fix buffer overrun. message is only big enough to hold 80 chars. oops! 2025-02-04 21:20:00 -05:00
Gered 47e0462368 add some boot screen and scanning debug output 2025-02-04 21:19:34 -05:00
Gered c099d9bae1 undo
as i should've guessed initially, this had nothing to do with the
earlier issues i noticed which seemed to disappear once i started
fiddling with this function. that appeared to be coincidence.

the actual issue lies somewhere else it seems ... ugh
2025-02-04 21:14:30 -05:00
Gered 27e096e03b update gitignore 2025-02-04 18:47:56 -05:00
3 changed files with 21 additions and 6 deletions

5
.gitignore vendored
View file

@ -53,6 +53,11 @@ dkms.conf
.vscode/settings.json .vscode/settings.json
/misc/F256xE_Kernal_Code /misc/F256xE_Kernal_Code
# lsp / clangd
/.cache/
/.clangd
/compile_commands.json
obj/ obj/
/foenixmgr.ini /foenixmgr.ini
/*.s37 /*.s37

View file

@ -168,6 +168,7 @@ bool is_bootable(enum boot_src_e device, boot_record_p * boot_record) {
switch(device) { switch(device) {
case BOOT_SRC_RAM: case BOOT_SRC_RAM:
DEBUG("Scanning boot source BOOT_SRC_RAM");
top_ram = (uint32_t)mem_get_ramtop(); top_ram = (uint32_t)mem_get_ramtop();
for (uint32_t address = 0; address < top_ram; address += boot_record_alignment) { for (uint32_t address = 0; address < top_ram; address += boot_record_alignment) {
record = (boot_record_p)address; record = (boot_record_p)address;
@ -180,6 +181,7 @@ bool is_bootable(enum boot_src_e device, boot_record_p * boot_record) {
break; break;
case BOOT_SRC_ROM: case BOOT_SRC_ROM:
DEBUG("Scanning boot source BOOT_SRC_ROM");
record = (boot_record_p)boot_rom_location; record = (boot_record_p)boot_rom_location;
if (is_valid_boot_record(record)) { if (is_valid_boot_record(record)) {
*boot_record = record; *boot_record = record;
@ -188,6 +190,7 @@ bool is_bootable(enum boot_src_e device, boot_record_p * boot_record) {
break; break;
case BOOT_SRC_CARTRIDGE: case BOOT_SRC_CARTRIDGE:
DEBUG("Scanning boot source BOOT_SRC_CARTRIDGE");
record = (boot_record_p)boot_cart_location; record = (boot_record_p)boot_cart_location;
if (is_valid_boot_record(record)) { if (is_valid_boot_record(record)) {
*boot_record = record; *boot_record = record;
@ -196,18 +199,21 @@ bool is_bootable(enum boot_src_e device, boot_record_p * boot_record) {
break; break;
case BOOT_SRC_SD0: case BOOT_SRC_SD0:
DEBUG("Scanning boot source BOOT_SRC_SD0");
if ((fsys_stat("/sd0/fnxboot.pgx", &file_info) >= 0) || (fsys_stat("/sd0/fnxboot.pgz", &file_info) >= 0)) { if ((fsys_stat("/sd0/fnxboot.pgx", &file_info) >= 0) || (fsys_stat("/sd0/fnxboot.pgz", &file_info) >= 0)) {
return true; return true;
} }
break; break;
case BOOT_SRC_SD1: case BOOT_SRC_SD1:
DEBUG("Scanning boot source BOOT_SRC_SD1");
if ((fsys_stat("/sd1/fnxboot.pgx", &file_info) >= 0) || (fsys_stat("/sd1/fnxboot.pgz", &file_info) >= 0)) { if ((fsys_stat("/sd1/fnxboot.pgx", &file_info) >= 0) || (fsys_stat("/sd1/fnxboot.pgz", &file_info) >= 0)) {
return true; return true;
} }
break; break;
default: default:
DEBUG1("Unknown boot source type to scan %d, skipping", device);
break; break;
} }
@ -435,6 +441,8 @@ static short sc_to_function(unsigned short scancode) {
* *
*/ */
void boot_screen() { void boot_screen() {
INFO("Starting boot screen");
enum boot_src_e boot_source = BOOT_SRC_NONE; enum boot_src_e boot_source = BOOT_SRC_NONE;
boot_record_p boot_record[MAX_BOOT_SRC]; boot_record_p boot_record[MAX_BOOT_SRC];
short boot_position = 0; short boot_position = 0;
@ -520,6 +528,7 @@ void boot_screen() {
bootable[position] = false; bootable[position] = false;
boot_icon(position, boot_chain[position]); boot_icon(position, boot_chain[position]);
if (is_bootable(boot_chain[position], &boot_record[position])) { if (is_bootable(boot_chain[position], &boot_record[position])) {
DEBUG1("Determined that boot source %d is bootable", position);
boot_icon_highlight(position); boot_icon_highlight(position);
bootable[position] = true; bootable[position] = true;
bootable_count++; bootable_count++;
@ -550,6 +559,7 @@ void boot_screen() {
} }
} }
} }
DEBUG("Finished scanning boot sources");
// List out all the selectable boot sources // List out all the selectable boot sources
if (bootable_count > 1) { if (bootable_count > 1) {
@ -563,7 +573,9 @@ void boot_screen() {
} }
} }
sprintf(message, "\nPress \e[93mSPACE\e[37m to boot from default source.\nPress \e[93m<=\e[37m to rescan for boot sources.\n"); sprintf(message, "\nPress \e[93mSPACE\e[37m to boot from default source.\n");
chan_write(0, (uint8_t *)message, strlen(message));
sprintf(message, "Press \e[93m<=\e[37m to rescan for boot sources.\n");
chan_write(0, (uint8_t *)message, strlen(message)); chan_write(0, (uint8_t *)message, strlen(message));
// Let the user select a boot source // Let the user select a boot source
@ -579,11 +591,13 @@ void boot_screen() {
short selected = sc_to_function(scancode); short selected = sc_to_function(scancode);
if (selected == 0x20) { if (selected == 0x20) {
INFO("Booting from default ...");
printf("Booting from default ...\n"); printf("Booting from default ...\n");
// SPACE was pressed... just boot the default // SPACE was pressed... just boot the default
boot_from(boot_source, boot_record[0]); boot_from(boot_source, boot_record[0]);
} else if (selected > 0) { } else if (selected > 0) {
INFO1("Booting from device %d", selected);
printf("Booting from %d ...\n", selected); printf("Booting from %d ...\n", selected);
if (bootable[selected - 1]) { if (bootable[selected - 1]) {
boot_position = selected - 1; boot_position = selected - 1;

View file

@ -15,11 +15,7 @@
* @return the smallest short c such that c >= a / b * @return the smallest short c such that c >= a / b
*/ */
short ceil_div_short(short a, short b) { short ceil_div_short(short a, short b) {
if (a % b) { return (a + (b - 1)) / b;
return (a / b) + 1;
} else {
return a / b;
}
} }
/** /**