[PATCH v2 24/39] efi: serial: Support arrow keys
Simon Glass
sjg at chromium.org
Tue Oct 26 05:29:28 CEST 2021
Hi Heinrich,
On Mon, 18 Oct 2021 at 11:00, Heinrich Schuchardt <xypron.glpk at gmx.de> wrote:
>
> On 9/25/21 2:30 AM, Simon Glass wrote:
> > At present only the backspace key is supported in U-Boot, when running as
> > an EFI app. Add support for arrows, home and end as well, to make the CLI
> > more friendly.
> >
> > Signed-off-by: Simon Glass <sjg at chromium.org>
> > ---
> >
> > (no changes since v1)
> >
> > drivers/serial/serial_efi.c | 11 +++++++++--
> > 1 file changed, 9 insertions(+), 2 deletions(-)
> >
> > diff --git a/drivers/serial/serial_efi.c b/drivers/serial/serial_efi.c
> > index 33ddbd6080c..0067576389d 100644
> > --- a/drivers/serial/serial_efi.c
> > +++ b/drivers/serial/serial_efi.c
> > @@ -24,6 +24,9 @@ struct serial_efi_priv {
> > bool have_key;
> > };
> >
> > +/* Convert a lower-case character to its ctrl-char equivalent */
> > +#define CTL_CH(c) ((c) - 'a' + 1)
> > +
> > int serial_efi_setbrg(struct udevice *dev, int baudrate)
> > {
> > return 0;
> > @@ -49,6 +52,7 @@ static int serial_efi_get_key(struct serial_efi_priv *priv)
> > static int serial_efi_getc(struct udevice *dev)
> > {
> > struct serial_efi_priv *priv = dev_get_priv(dev);
> > + char conv_scan[10] = {0, 'p', 'n', 'f', 'b', 'a', 'e', 0, 8};
> > int ret, ch;
> >
> > ret = serial_efi_get_key(priv);
> > @@ -63,8 +67,11 @@ static int serial_efi_getc(struct udevice *dev)
> > * key scan code of 8. Handle this so that backspace works correctly
> > * in the U-Boot command line.
> > */
> > - if (!ch && priv->key.scan_code == 8)
> > - ch = 8;
> > + if (!ch && priv->key.scan_code < sizeof(conv_scan))
> > + ch = conv_scan[priv->key.scan_code];
> > + if (ch >= 'a')
> > + ch -= 'a' - 1;
>
> All 23 EFI Scan Codes should be supported. Can't we use something like
> kbd_to_ansi364[] from drivers/input/input.c to create the appropriate
> escape sequences?
I think you are referring to this:
Table 107. EFI Scan Codes for EFI_SIMPLE_TEXT_INPUT_PROTOCOL
EFI Scan Code Description
0x00 Null scan code.
0x01 Move cursor up 1 row.
0x02 Move cursor down 1 row.
0x03 Move cursor right 1 column.
0x04 Move cursor left 1 column.
0x05 Home.
0x06 End.
0x07 Insert.
0x08 Delete.
0x09 Page Up.
0x0a Page Down.
0x0b Function 1.
0x0c Function 2.
0x0d Function 3.
0x0e Function 4.
0x0f Function 5.
0x10 Function 6.
0x11 Function 7.
0x12 Function 8.
0x13 Function 9.
0x14 Function 10.
Which ones (other than what I have added) do you think U-Boot
supports? I cannot find any.
Regards,
Simon
More information about the U-Boot
mailing list