Compare commits
4 commits
ac8b242987
...
d6297305cf
Author | SHA1 | Date | |
---|---|---|---|
Gered | d6297305cf | ||
Gered | 47e0462368 | ||
Gered | c099d9bae1 | ||
Gered | 27e096e03b |
5
.gitignore
vendored
5
.gitignore
vendored
|
@ -53,6 +53,11 @@ dkms.conf
|
|||
.vscode/settings.json
|
||||
/misc/F256xE_Kernal_Code
|
||||
|
||||
# lsp / clangd
|
||||
/.cache/
|
||||
/.clangd
|
||||
/compile_commands.json
|
||||
|
||||
obj/
|
||||
/foenixmgr.ini
|
||||
/*.s37
|
||||
|
|
16
src/boot.c
16
src/boot.c
|
@ -168,6 +168,7 @@ bool is_bootable(enum boot_src_e device, boot_record_p * boot_record) {
|
|||
|
||||
switch(device) {
|
||||
case BOOT_SRC_RAM:
|
||||
DEBUG("Scanning boot source BOOT_SRC_RAM");
|
||||
top_ram = (uint32_t)mem_get_ramtop();
|
||||
for (uint32_t address = 0; address < top_ram; address += boot_record_alignment) {
|
||||
record = (boot_record_p)address;
|
||||
|
@ -180,6 +181,7 @@ bool is_bootable(enum boot_src_e device, boot_record_p * boot_record) {
|
|||
break;
|
||||
|
||||
case BOOT_SRC_ROM:
|
||||
DEBUG("Scanning boot source BOOT_SRC_ROM");
|
||||
record = (boot_record_p)boot_rom_location;
|
||||
if (is_valid_boot_record(record)) {
|
||||
*boot_record = record;
|
||||
|
@ -188,6 +190,7 @@ bool is_bootable(enum boot_src_e device, boot_record_p * boot_record) {
|
|||
break;
|
||||
|
||||
case BOOT_SRC_CARTRIDGE:
|
||||
DEBUG("Scanning boot source BOOT_SRC_CARTRIDGE");
|
||||
record = (boot_record_p)boot_cart_location;
|
||||
if (is_valid_boot_record(record)) {
|
||||
*boot_record = record;
|
||||
|
@ -196,18 +199,21 @@ bool is_bootable(enum boot_src_e device, boot_record_p * boot_record) {
|
|||
break;
|
||||
|
||||
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)) {
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
|
||||
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)) {
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
DEBUG1("Unknown boot source type to scan %d, skipping", device);
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -435,6 +441,8 @@ static short sc_to_function(unsigned short scancode) {
|
|||
*
|
||||
*/
|
||||
void boot_screen() {
|
||||
INFO("Starting boot screen");
|
||||
|
||||
enum boot_src_e boot_source = BOOT_SRC_NONE;
|
||||
boot_record_p boot_record[MAX_BOOT_SRC];
|
||||
short boot_position = 0;
|
||||
|
@ -520,6 +528,7 @@ void boot_screen() {
|
|||
bootable[position] = false;
|
||||
boot_icon(position, boot_chain[position]);
|
||||
if (is_bootable(boot_chain[position], &boot_record[position])) {
|
||||
DEBUG1("Determined that boot source %d is bootable", position);
|
||||
boot_icon_highlight(position);
|
||||
bootable[position] = true;
|
||||
bootable_count++;
|
||||
|
@ -550,6 +559,7 @@ void boot_screen() {
|
|||
}
|
||||
}
|
||||
}
|
||||
DEBUG("Finished scanning boot sources");
|
||||
|
||||
// List out all the selectable boot sources
|
||||
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));
|
||||
|
||||
// Let the user select a boot source
|
||||
|
@ -579,11 +591,13 @@ void boot_screen() {
|
|||
short selected = sc_to_function(scancode);
|
||||
|
||||
if (selected == 0x20) {
|
||||
INFO("Booting from default ...");
|
||||
printf("Booting from default ...\n");
|
||||
// SPACE was pressed... just boot the default
|
||||
boot_from(boot_source, boot_record[0]);
|
||||
|
||||
} else if (selected > 0) {
|
||||
INFO1("Booting from device %d", selected);
|
||||
printf("Booting from %d ...\n", selected);
|
||||
if (bootable[selected - 1]) {
|
||||
boot_position = selected - 1;
|
||||
|
|
|
@ -15,11 +15,7 @@
|
|||
* @return the smallest short c such that c >= a / b
|
||||
*/
|
||||
short ceil_div_short(short a, short b) {
|
||||
if (a % b) {
|
||||
return (a / b) + 1;
|
||||
} else {
|
||||
return a / b;
|
||||
}
|
||||
return (a + (b - 1)) / b;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in a new issue