F11 and F12 are trapped by some terminal emulators, and sgabios does not always recognize function keys very well.
Real-world machines often provide replacements for function keys for use on the serial console: ESC+1...ESC+0 for F1...F10, ESC+SHIFT+1 and ESC+SHIFT+2 for F11...F12. Accept all of them, which can be useful in case the user has set boot-menu-key.
Signed-off-by: Paolo Bonzini pbonzini@redhat.com --- src/boot.c | 52 +++++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 47 insertions(+), 5 deletions(-)
diff --git a/src/boot.c b/src/boot.c index f23e9e1..3f1ea4a 100644 --- a/src/boot.c +++ b/src/boot.c @@ -422,7 +422,21 @@ get_raw_keystroke(void) memset(&br, 0, sizeof(br)); br.flags = F_IF; call16_int(0x16, &br); - return br.ah; + return br.ax; +} + +// Read a keystroke - waiting up to 'msec' milliseconds. +static int +get_keystroke_ascii(int msec) +{ + u32 end = irqtimer_calc(msec); + for (;;) { + if (check_for_keystroke()) + return get_raw_keystroke() & 255; + if (irqtimer_check(end)) + return -1; + yield_toirq(); + } }
// Read a keystroke - waiting up to 'msec' milliseconds. @@ -432,7 +446,7 @@ get_keystroke(int msec) u32 end = irqtimer_calc(msec); for (;;) { if (check_for_keystroke()) - return get_raw_keystroke(); + return get_raw_keystroke() >> 8; if (irqtimer_check(end)) return -1; yield_toirq(); @@ -446,6 +460,35 @@ get_keystroke(int msec)
#define DEFAULT_BOOTMENU_WAIT 2500
+static int +get_bootmenu_keystroke(void) +{ + u32 menutime = romfile_loadint("etc/boot-menu-wait", DEFAULT_BOOTMENU_WAIT); + int scan_code = get_keystroke(menutime); + if (scan_code == 0x01) { + while (get_keystroke(0) >= 0) + ; + int ascii = get_keystroke_ascii(menutime * 2); + switch (ascii) { + case '1' ... '9': + scan_code = 0x3a + ascii - '0'; + break; + case '0': + scan_code = 0x3a + 10; + break; + case '!': + scan_code = 0x85; + break; + case '@': + scan_code = 0x86; + break; + default: + break; + } + } + return scan_code; +} + // Show IPL option menu. void interactive_bootmenu(void) @@ -460,12 +503,11 @@ interactive_bootmenu(void)
char *bootmsg = romfile_loadfile("etc/boot-menu-message", NULL); int menukey = romfile_loadint("etc/boot-menu-key", 0x86); - printf("%s", bootmsg ?: "\nPress F12 for boot menu.\n\n"); + printf("%s", bootmsg ?: "\nPress ESC+@ or F12 for boot menu.\n\n"); free(bootmsg);
- u32 menutime = romfile_loadint("etc/boot-menu-wait", DEFAULT_BOOTMENU_WAIT); enable_bootsplash(); - int scan_code = get_keystroke(menutime); + int scan_code = get_bootmenu_keystroke(); disable_bootsplash(); if (scan_code != menukey) return;
On Wed, Mar 04, 2015 at 05:57:02PM +0100, Paolo Bonzini wrote:
F11 and F12 are trapped by some terminal emulators, and sgabios does not always recognize function keys very well.
Real-world machines often provide replacements for function keys for use on the serial console: ESC+1...ESC+0 for F1...F10, ESC+SHIFT+1 and ESC+SHIFT+2 for F11...F12. Accept all of them, which can be useful in case the user has set boot-menu-key.
Thanks. Did you encounter this problem with QEMU or on a real machine with coreboot?
Out of curiosity, is there a reason why one can't modify boot-menu-key/boot-menu-message for those machines that don't support F12?
BTW, several chromebooks change boot-menu-key to 0x01 (ESC) and I think that would conflict with your patch.
-Kevin
On 04/03/2015 22:42, Kevin O'Connor wrote:
On Wed, Mar 04, 2015 at 05:57:02PM +0100, Paolo Bonzini wrote:
F11 and F12 are trapped by some terminal emulators, and sgabios does not always recognize function keys very well.
Real-world machines often provide replacements for function keys for use on the serial console: ESC+1...ESC+0 for F1...F10, ESC+SHIFT+1 and ESC+SHIFT+2 for F11...F12. Accept all of them, which can be useful in case the user has set boot-menu-key.
Thanks. Did you encounter this problem with QEMU or on a real machine with coreboot?
With QEMU.
Out of curiosity, is there a reason why one can't modify boot-menu-key/boot-menu-message for those machines that don't support F12?
The trivial reason is that right now, QEMU doesn't support customizing the menu key and message (also there are several management layers between QEMU and the user, such as libvirt/oVirt/OpenStack, and you'd have to add support in all of them).
But more important, which keys are and are not available depends on the client, not on the server. So for VNC all keys work but on at least a viewer F8 is inconvenient because it brings up a menu (thankfully one item in the menu is "Send F8"); for the serial console on a Unix machine F12 is okay but F11 might bring the terminal full screen; on older Mac OS X machine F9-F12 were intercepted by the OS, but on newer OS X releases function keys are basically gone for good. A configuration that always works might be broken by the addition of a new client.
BTW, several chromebooks change boot-menu-key to 0x01 (ESC) and I think that would conflict with your patch.
Yes, that definitely warrants a v2.
Paolo
Hi Paolo,
Sorry for the delay in responding.
On Thu, Mar 05, 2015 at 10:13:30AM +0100, Paolo Bonzini wrote:
On 04/03/2015 22:42, Kevin O'Connor wrote:
On Wed, Mar 04, 2015 at 05:57:02PM +0100, Paolo Bonzini wrote:
F11 and F12 are trapped by some terminal emulators, and sgabios does not always recognize function keys very well.
Real-world machines often provide replacements for function keys for use on the serial console: ESC+1...ESC+0 for F1...F10, ESC+SHIFT+1 and ESC+SHIFT+2 for F11...F12. Accept all of them, which can be useful in case the user has set boot-menu-key.
Thanks. Did you encounter this problem with QEMU or on a real machine with coreboot?
With QEMU.
Out of curiosity, is there a reason why one can't modify boot-menu-key/boot-menu-message for those machines that don't support F12?
The trivial reason is that right now, QEMU doesn't support customizing the menu key and message (also there are several management layers between QEMU and the user, such as libvirt/oVirt/OpenStack, and you'd have to add support in all of them).
But more important, which keys are and are not available depends on the client, not on the server. So for VNC all keys work but on at least a viewer F8 is inconvenient because it brings up a menu (thankfully one item in the menu is "Send F8"); for the serial console on a Unix machine F12 is okay but F11 might bring the terminal full screen; on older Mac OS X machine F9-F12 were intercepted by the OS, but on newer OS X releases function keys are basically gone for good. A configuration that always works might be broken by the addition of a new client.
The above makes sense. The F12 key comes from Bochs bios. Given the difficulties in using F-keys (on QEMU as well as on real machines) I wonder if we should just change the SeaBIOS default to ESC?
I don't like changing the default message to "Press ESC+@ or F12 for boot menu." as I think the description becomes confusing when multiple options are given. So, ESC+@ could be a hidden feature, but admittedly that's not a great option. Otherwise the technical parts of the patch looks okay to me.
-Kevin
On 03/11/2015 11:09 AM, Kevin O'Connor wrote:
The above makes sense. The F12 key comes from Bochs bios. Given the difficulties in using F-keys (on QEMU as well as on real machines) I wonder if we should just change the SeaBIOS default to ESC?
I don't like changing the default message to "Press ESC+@ or F12 for boot menu." as I think the description becomes confusing when multiple options are given. So, ESC+@ could be a hidden feature, but admittedly that's not a great option. Otherwise the technical parts of the patch looks okay to me.
-Kevin
For what it's worth uing only the Esc makes a lot of sense; the user is "Escaping" from the automated boot sequence. I always had issues with the proprietary BIOSes where it was F1, F2, F8. F12, DEL, TAB, or something else based on the manufacturer. As there is rarely enough time for the CRT to warm up before POST completes I usually end up pressing all of those keys in sequence multiple times until I see the configuration menu.
On 11/03/2015 17:09, Kevin O'Connor wrote:
But more important, which keys are and are not available depends on the client, not on the server. So for VNC all keys work but on at least a viewer F8 is inconvenient because it brings up a menu (thankfully one item in the menu is "Send F8"); for the serial console on a Unix machine F12 is okay but F11 might bring the terminal full screen; on older Mac OS X machine F9-F12 were intercepted by the OS, but on newer OS X releases function keys are basically gone for good. A configuration that always works might be broken by the addition of a new client.
The above makes sense. The F12 key comes from Bochs bios. Given the difficulties in using F-keys (on QEMU as well as on real machines) I wonder if we should just change the SeaBIOS default to ESC?
I don't like changing the default message to "Press ESC+@ or F12 for boot menu." as I think the description becomes confusing when multiple options are given. So, ESC+@ could be a hidden feature, but admittedly that's not a great option. Otherwise the technical parts of the patch looks okay to me.
I have no problem with changing the key; the problem I have with ESC is that I'm going to add F12 for network boot, and then I would like ESC+@ to trigger network boot. ESC for the boot menu would clash. With my full patches, the default message would be like this:
Press ESC+6 or F6 for boot menu. Press ESC+@ or F12 for network boot.
Hmm... what about just adding quotes like this:
Press "ESC+6" or "F6" for boot menu. Press "ESC+@" or "F12" for network boot.
or like this:
Press <F6>, or <ESC><6>, for boot menu. Press <F12>, or <ESC><@>, for network boot.
Paolo
On Wed, Mar 11, 2015 at 05:42:18PM +0100, Paolo Bonzini wrote:
On 11/03/2015 17:09, Kevin O'Connor wrote:
But more important, which keys are and are not available depends on the client, not on the server. So for VNC all keys work but on at least a viewer F8 is inconvenient because it brings up a menu (thankfully one item in the menu is "Send F8"); for the serial console on a Unix machine F12 is okay but F11 might bring the terminal full screen; on older Mac OS X machine F9-F12 were intercepted by the OS, but on newer OS X releases function keys are basically gone for good. A configuration that always works might be broken by the addition of a new client.
The above makes sense. The F12 key comes from Bochs bios. Given the difficulties in using F-keys (on QEMU as well as on real machines) I wonder if we should just change the SeaBIOS default to ESC?
I don't like changing the default message to "Press ESC+@ or F12 for boot menu." as I think the description becomes confusing when multiple options are given. So, ESC+@ could be a hidden feature, but admittedly that's not a great option. Otherwise the technical parts of the patch looks okay to me.
I have no problem with changing the key; the problem I have with ESC is that I'm going to add F12 for network boot, and then I would like ESC+@ to trigger network boot. ESC for the boot menu would clash. With my full patches, the default message would be like this:
Can you explain that "network boot" feature further?
Couldn't the user hit ESC to bring up the boot menu, and then select the network option from the menu?
Press ESC+6 or F6 for boot menu. Press ESC+@ or F12 for network boot.
Hmm... what about just adding quotes like this:
Press "ESC+6" or "F6" for boot menu. Press "ESC+@" or "F12" for network boot.
or like this:
Press <F6>, or <ESC><6>, for boot menu. Press <F12>, or <ESC><@>, for network boot.
On a real machine, these messages fly by pretty quick (the video doesn't necessarily come up instantly). I think the message should be as succinct as possible - hit this key to stop the default boot - otherwise the default boot is going to happen. I don't think we should make that initial prompt any more complex. Once the user stops the default boot (by hitting ESC, F12, whatever) then a more detailed explanation and more detailed options can be provided.
So, my concern is not with the placement of the quotes or order of the text, but that in the second or so that it is on the screen the directions should be succinct.
Everyone seems to want something slightly different for the boot splash, which is why there are so many fw_cfg/cbfs entries that allow customization of it. I'm leery of adding more complexity to it, because I fear that's going to lead to even more complexity as users desire further customization.
-Kevin
On 11/03/2015 18:24, Kevin O'Connor wrote:
On Wed, Mar 11, 2015 at 05:42:18PM +0100, Paolo Bonzini wrote:
I have no problem with changing the key; the problem I have with ESC is that I'm going to add F12 for network boot, and then I would like ESC+@ to trigger network boot. ESC for the boot menu would clash. With my full patches, the default message would be like this:
Can you explain that "network boot" feature further?
It prioritizes NIC option ROMs over other options, trying all network cards before falling back to HD, CD/DVD and non-NIC option ROMs.
It's a common feature on a real machine, to the point that the SMBIOS tables have a special bit for "network boot can be done with F12". This makes sense mostly for Coreboot, though some people requested it on virtual machines as well.
I think the message should be as succinct as possible - hit this key to stop the default boot - otherwise the default boot is going to happen. I don't think we should make that initial prompt any more complex. Once the user stops the default boot (by hitting ESC, F12, whatever) then a more detailed explanation and more detailed options can be provided.
What about this:
- for now, change the default key to "ESC" and the default message to "Press ESC for boot menu".
- in my next round of patches, add "Press N for network boot" in the boot menu.
- also in my next round of patches, support the F12 key for direct network boot but keep it "secret". It's the same as real machines anyway. Maybe support ESC+@ in addition to ESC+N too, but that seems overengineered.
Everyone seems to want something slightly different for the boot splash, which is why there are so many fw_cfg/cbfs entries that allow customization of it. I'm leery of adding more complexity to it, because I fear that's going to lead to even more complexity as users desire further customization.
I understand.
Paolo
On Wed, Mar 11, 2015 at 06:39:44PM +0100, Paolo Bonzini wrote:
On 11/03/2015 18:24, Kevin O'Connor wrote:
On Wed, Mar 11, 2015 at 05:42:18PM +0100, Paolo Bonzini wrote:
I have no problem with changing the key; the problem I have with ESC is that I'm going to add F12 for network boot, and then I would like ESC+@ to trigger network boot. ESC for the boot menu would clash. With my full patches, the default message would be like this:
Can you explain that "network boot" feature further?
It prioritizes NIC option ROMs over other options, trying all network cards before falling back to HD, CD/DVD and non-NIC option ROMs.
How will you know which option ROMs are NIC option roms?
It's a common feature on a real machine, to the point that the SMBIOS tables have a special bit for "network boot can be done with F12". This makes sense mostly for Coreboot, though some people requested it on virtual machines as well.
I think the message should be as succinct as possible - hit this key to stop the default boot - otherwise the default boot is going to happen. I don't think we should make that initial prompt any more complex. Once the user stops the default boot (by hitting ESC, F12, whatever) then a more detailed explanation and more detailed options can be provided.
What about this:
- for now, change the default key to "ESC" and the default message to
"Press ESC for boot menu".
- in my next round of patches, add "Press N for network boot" in the
boot menu.
Works for me.
- also in my next round of patches, support the F12 key for direct
network boot but keep it "secret". It's the same as real machines anyway. Maybe support ESC+@ in addition to ESC+N too, but that seems overengineered.
If you want, but I'd personally hold off on that until someone screems for it.
Thanks, -Kevin
On 3/11/2015 2:45 PM, Kevin O'Connor wrote:
On Wed, Mar 11, 2015 at 06:39:44PM +0100, Paolo Bonzini wrote:
On 11/03/2015 18:24, Kevin O'Connor wrote:
On Wed, Mar 11, 2015 at 05:42:18PM +0100, Paolo Bonzini wrote:
I have no problem with changing the key; the problem I have with ESC is that I'm going to add F12 for network boot, and then I would like ESC+@ to trigger network boot. ESC for the boot menu would clash. With my full patches, the default message would be like this:
Can you explain that "network boot" feature further?
It prioritizes NIC option ROMs over other options, trying all network cards before falling back to HD, CD/DVD and non-NIC option ROMs.
How will you know which option ROMs are NIC option roms?
It's a common feature on a real machine, to the point that the SMBIOS tables have a special bit for "network boot can be done with F12". This makes sense mostly for Coreboot, though some people requested it on virtual machines as well.
I think the message should be as succinct as possible - hit this key to stop the default boot - otherwise the default boot is going to happen. I don't think we should make that initial prompt any more complex. Once the user stops the default boot (by hitting ESC, F12, whatever) then a more detailed explanation and more detailed options can be provided.
What about this:
- for now, change the default key to "ESC" and the default message to
"Press ESC for boot menu".
- in my next round of patches, add "Press N for network boot" in the
boot menu.
Works for me.
Here we also want to disable the use of ESC to short-circuit the boot menu, otherwise users (trained by years of repeatedly hitting keys to enter the BIOS) will often end up hitting ESC multiple times and immediately booting the primary boot device. I've already done this on my own branch (used for ChromeOS devices): https://github.com/MattDevo/SeaBIOS/commit/7772166bf90e0bb1a49860d7913817652...
- also in my next round of patches, support the F12 key for direct
network boot but keep it "secret". It's the same as real machines anyway. Maybe support ESC+@ in addition to ESC+N too, but that seems overengineered.
If you want, but I'd personally hold off on that until someone screems for it.
2nd
Thanks, -Kevin
SeaBIOS mailing list SeaBIOS@seabios.org http://www.seabios.org/mailman/listinfo/seabios
regards, Matt
On 11/03/2015 20:45, Kevin O'Connor wrote:
On Wed, Mar 11, 2015 at 06:39:44PM +0100, Paolo Bonzini wrote:
On 11/03/2015 18:24, Kevin O'Connor wrote:
On Wed, Mar 11, 2015 at 05:42:18PM +0100, Paolo Bonzini wrote:
I have no problem with changing the key; the problem I have with ESC is that I'm going to add F12 for network boot, and then I would like ESC+@ to trigger network boot. ESC for the boot menu would clash. With my full patches, the default message would be like this:
Can you explain that "network boot" feature further?
It prioritizes NIC option ROMs over other options, trying all network cards before falling back to HD, CD/DVD and non-NIC option ROMs.
How will you know which option ROMs are NIC option roms?
The PnP header includes the PCI class.
Paolo