diff --git a/src/boot.c b/src/boot.c index 4281c49..7e55610 100644 --- a/src/boot.c +++ b/src/boot.c @@ -25,6 +25,7 @@ #include "vicky_general.h" #include "rsrc/sprites/boot_sprites.h" #include "rsrc/tiles/boot_tiles.h" +#include "syscalls.h" #include #include @@ -562,34 +563,36 @@ void boot_screen() { } } - sprintf(message, "\nPress \e[93mSPACE\e[37m to boot from default source.\n"); + sprintf(message, "\nPress \e[93mSPACE\e[37m to boot from default source.\nPress \e[93m<=\e[37m to rescan for boot sources.\n"); chan_write(0, (uint8_t *)message, strlen(message)); - // Give the user time to press a key to select a boot source - // If the time expires, boot the default source (earliest in the boot chain) + // Let the user select a boot source - jiffies_target = timers_jiffies() + 60 * 15; - while (jiffies_target > timers_jiffies()) { + while (true) { unsigned short scancode = kbd_get_scancode(); if (scancode > 0) { + if (scancode == 1) { + printf("Rebooting ...\n"); + sys_reboot(); + } + short selected = sc_to_function(scancode); if (selected == 0x20) { + printf("Booting from default ...\n"); // SPACE was pressed... just boot the default - break; + boot_from(boot_source, boot_record[0]); } else if (selected > 0) { + printf("Booting from %d ...\n", selected); if (bootable[selected - 1]) { boot_position = selected - 1; boot_source = boot_chain[boot_position]; - break; + boot_from(boot_source, boot_record[boot_position]); + } else { + printf("Nothing bootable at device %d.\n", selected); } } } - } - - // And launch the system - - boot_from(boot_source, boot_record[boot_position]); }