efi: Move key decoding into a shared file
Create a new file in lib/efi to handle conversion of keys from EFI format to characters, so we can use it from multiple places. Update the serial_efi driver accordingly. Signed-off-by: Simon Glass <sjg@chromium.org>
This commit is contained in:
@@ -6,6 +6,7 @@
|
||||
obj-y += basename.o
|
||||
obj-y += device_path.o
|
||||
obj-y += helper.o
|
||||
obj-y += input.o
|
||||
obj-y += load_options.o
|
||||
obj-y += memory.o
|
||||
obj-y += run.o
|
||||
|
||||
40
lib/efi/input.c
Normal file
40
lib/efi/input.c
Normal file
@@ -0,0 +1,40 @@
|
||||
// SPDX-License-Identifier: GPL-2.0+
|
||||
/*
|
||||
* EFI input key decoding functions
|
||||
*
|
||||
* Copyright (c) 2015 Google, Inc
|
||||
* Written by Simon Glass <sjg@chromium.org>
|
||||
*/
|
||||
|
||||
#define LOG_CATEGORY LOGC_EFI
|
||||
|
||||
#include <efi.h>
|
||||
#include <efi_api.h>
|
||||
#include <cli.h>
|
||||
|
||||
int efi_decode_key(struct efi_input_key *key)
|
||||
{
|
||||
static const char conv_scan[] = {0, 'p', 'n', 'f', 'b', 'a', 'e', 0, 8};
|
||||
int ch;
|
||||
|
||||
ch = key->unicode_char;
|
||||
|
||||
/*
|
||||
* Unicode char 8 (for backspace) is never returned. Instead we get a
|
||||
* key scan code of 8. Handle this so that backspace works correctly
|
||||
* in the U-Boot command line.
|
||||
*/
|
||||
if (!ch && key->scan_code < sizeof(conv_scan)) {
|
||||
ch = conv_scan[key->scan_code];
|
||||
if (ch >= 'a')
|
||||
ch -= 'a' - 1;
|
||||
}
|
||||
log_debug(" [%x %x %x] ", ch, key->unicode_char, key->scan_code);
|
||||
|
||||
return ch;
|
||||
}
|
||||
|
||||
int efi_decode_key_ex(struct efi_key_data *key_data)
|
||||
{
|
||||
return efi_decode_key(&key_data->key);
|
||||
}
|
||||
Reference in New Issue
Block a user