summaryrefslogtreecommitdiffstats
path: root/lib/efi_loader/efi_console.c
Commit message (Collapse)AuthorAgeFilesLines
* efi_loader: NULL dereference in EFI consoleHeinrich Schuchardt2021-03-191-13/+38
| | | | | | | | | | Even if CONFIG_DM_VIDEO=y and stdout="vidconsole", a video device may not be available. Check the return values of the relevant functions. If no video output device is available, assume that the serial console is in use. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
* efi_loader: console size of vidconsoleHeinrich Schuchardt2021-03-071-1/+1
| | | | | | | | | | If stdout is 'vidconsole', we correctly set the console size. If stdout is 'vidconsole,serial', the video console is ignored. We should always evaluate the size of vidconsole if it is the primary console. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
* efi_loader: typedef efi_string_t text output protocolHeinrich Schuchardt2021-01-131-3/+3
| | | | | | | | We do not want to use typedefs in U-Boot. Do not use efi_string_t in the EFI_TEXT_OUTPUT_PROTOCOL. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
* efi_loader: escape key handlingHeinrich Schuchardt2020-12-291-0/+12
| | | | | | | | | | Up to now the escape key was not correctly detected in UEFI applications. We had to hit it twice for a single escape to be recognized. Use a 10 ms delay to detect if we are dealing with the escape key or an escape sequence. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
* common: rename getc() to getchar()Heinrich Schuchardt2020-10-221-10/+10
| | | | | | | | | | | | | | | | | | | The sandbox is built with the SDL2 library with invokes the X11 library which in turn calls getc(). But getc() in glibc is defined as int getc(FILE *) This does not match our definition. int getc(void) The sandbox crashes when called with parameter -l. Rename our library symbol getc() to getchar(). Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Reviewed-by: Tom Rini <trini@konsulko.com> Reviewed-by: Simon Glass <sjg@chromium.org>
* efi_loader: comments EFI_SIMPLE_TEXT_OUTPUT_PROTOCOLHeinrich Schuchardt2020-06-051-9/+115
| | | | | | | Provide missing comments for the functions implementing the EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
* dm: core: Create a new header file for 'compat' featuresSimon Glass2020-02-051-0/+1
| | | | | | | | | | | | At present dm/device.h includes the linux-compatible features. This requires including linux/compat.h which in turn includes a lot of headers. One of these is malloc.h which we thus end up including in every file in U-Boot. Apart from the inefficiency of this, it is problematic for sandbox which needs to use the system malloc() in some files. Move the compatibility features into a separate header file. Signed-off-by: Simon Glass <sjg@chromium.org>
* efi_loader: clear screen should move cursor to homeHeinrich Schuchardt2020-01-071-1/+15
| | | | | | | | | | | On a VT100 terminal <ESC>[2J should be enough to both clear the whole screen and set the cursor to position (1, 1). But the Linux console does not behave like this. So send an extra <ESC>[H. For reference see the console_codes(4) man page. Add a function description. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
* common: Move get_ticks() function out of common.hSimon Glass2019-12-021-0/+1
| | | | | | | This function belongs in time.h so move it over and add a comment. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Tom Rini <trini@konsulko.com>
* doc: UEFI API documentationHeinrich Schuchardt2019-09-051-5/+6
| | | | | | | | Add some more files to the UEFI API documentation. Correct some Sphinx comments. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
* efi_loader: do not set invalid screen modeHeinrich Schuchardt2019-09-051-0/+4
| | | | | | | | EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.SetMode() should return EFI_UNDEFINED if a screen mode is not available. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Reviewed-by: Alexander Graf <agraf@csgraf.de>
* efi_loader: cursor positioningHeinrich Schuchardt2019-09-051-5/+13
| | | | | | | | | | When backspacing in column 0 do no set the column index to ULONG_MAX. Ensure that the row number is not set to ULONG_MAX even if the row count is advertised as 0. Ignore control characters other the 0x08, 0x0a, 0x0d when updating the column. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
* env: Move env_get() to env.hSimon Glass2019-08-111-0/+1
| | | | | | | Move env_get() over to the new header file. Acked-by: Joe Hershberger <joe.hershberger@ni.com> Signed-off-by: Simon Glass <sjg@chromium.org>
* efi_loader: console incorrectly advertised left logo keyHeinrich Schuchardt2019-06-201-3/+1
| | | | | | Avoid to signal that the left logo key is pressed, when it is not. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
* efi_loader: alternative scan codes for F5, END, HOMEHeinrich Schuchardt2019-06-201-8/+14
| | | | | | | Depending on the key board alternative scan codes are used for F5, END, and HOME. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
* efi_loader: fix SetAttribute()Heinrich Schuchardt2019-06-141-0/+2
| | | | | | | The SetAttribute() service and the Reset() service of the simple text output protocol must update the attribute value in the mode information. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
* efi_loader: fix SetMode()Heinrich Schuchardt2019-06-141-17/+14
| | | | | | | | | Correct the check of the mode number in SetMode() service of the simple text output protocol. Clear the screen in SetMode(). Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
* efi_loader: event signaling in ExitBootServicesHeinrich Schuchardt2019-06-101-2/+2
| | | | | | | | | | ExitBootServices() has to stop timer related activity before calling the events of the EFI_EVENT_GROUP_EXIT_BOOT_SERVICES event group. But our current implementation was stopping all other events. All events have to observe the task priority level. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
* efi_loader: fix EnableCursor()Heinrich Schuchardt2019-06-041-0/+1
| | | | | | | The EnableCursor() service of the simple text output protocol must update the the CursorVisible field of the output mode. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
* efi_loader: parameter check OutputStringHeinrich Schuchardt2019-05-191-0/+5
| | | | | | Check the parameters against NULL. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
* efi_loader: EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL.SetState() correct parameterHeinrich Schuchardt2019-05-191-3/+3
| | | | | | KeyToggleState is a pointer according to UEFI spec 2.8. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
* efi_loader: correct CTRL-A - CTRL-Z console inputHeinrich Schuchardt2019-04-071-0/+17
| | | | | | | | | | | | In the extended text input protocol CTRL-A - CTRL-Z have to be signaled as Unicode characters a-z or A-Z depending on the shift state and not as 0x01 to 0x1a. Update Python unit test. This patch is required for using the EFI shell `edit` command. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
* efi_loader: Fix serial console size detectionMatthias Brugger2019-03-101-27/+35
| | | | | | | | | | | | | | | | | | | Function term_read_reply tries to read from the serial console until the end_char was read. This can hang forever if we are, for some reason, not able to read the full response (e.g. serial buffer too small, frame error). This patch moves the timeout detection into term_read_reply() to assure we will make progress. Fixes: 6bb591f704 ("efi_loader: query serial console size reliably") Signed-off-by: Matthias Brugger <mbrugger@suse.com> Throw missing error when an incomplete reply for the cursor position is received. Change type of argument of term_get_char() *s32. This renders the function reusable in efi_cin_read_key(). Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
* efi_loader: fix typosHeinrich Schuchardt2018-12-021-2/+2
| | | | | | | Fix typos in EFI subsystem comments. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
* efi_loader: eliminate handle memberHeinrich Schuchardt2018-12-021-10/+10
| | | | | | | | A pointer to a struct efi_object is a handle. We do not need any handle member in this structure. Let's eliminate it. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
* efi_loader: return type efi_console_register()Heinrich Schuchardt2018-10-161-1/+3
| | | | | | | | | | Use a return type that can encompass the return value. This fixes CoverityScan CID 184090. Reported-by: Tom Rini <trini@konsulko.com> Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
* efi_loader: query serial console size reliablyHeinrich Schuchardt2018-09-231-13/+37
| | | | | | | | | | | | | Not all terminals understand CSI [18t for querying the console size. We should adhere to escape sequences documented in the console_codes manpage and the ECMA-48 standard. So here we follow a different approach. We position the cursor to the bottom right and query its position. Before leaving the function we restore the original cursor position. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
* efi_loader: terminal left upper corner is [1, 1]Heinrich Schuchardt2018-09-231-3/+21
| | | | | | | | | | | | For the VT102 and the Linux console the left upper corner is [1, 1]. EFI uses [0, 0] as left upper corner. Check parameters of the SetCursorPosition() service. Use CSI H like EDK2 for positioning. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
* efi_loader: implement key notify functionsHeinrich Schuchardt2018-09-231-3/+98
| | | | | | | | Implement registering and unregistreing key notify functions in the EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
* efi_loader: support modifiers for F1 - F4Heinrich Schuchardt2018-09-231-25/+39
| | | | | | | | Support modifiers for F1 - F4. Add support for letters with ALT key. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
* efi_loader: EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOLHeinrich Schuchardt2018-09-231-22/+231
| | | | | | | | | | This patch implements the EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL. The implementation of notification functions is postponed to a later patch. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
* efi_loader: rework event handling for consoleHeinrich Schuchardt2018-09-231-38/+137
| | | | | | | | | | Preread the next key in the console timer event. The EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL requires to trigger registered key notification functions based on the prefetched key. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
* efi_loader: support Unicode text inputHeinrich Schuchardt2018-09-231-6/+7
| | | | | | | | | | | Up to now the EFI_TEXT_INPUT_PROTOCOL only supported ASCII characters. With the patch it can consume UTF-8 from the console. Currently only the serial console and the console can deliver UTF-8. Local consoles are restricted to ASCII. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
* efi_loader: typos in efi_console.cHeinrich Schuchardt2018-09-231-4/+4
| | | | | | | Fix a few typos. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
* efi_loader: struct efi_simple_text_input_protocolHeinrich Schuchardt2018-09-231-3/+3
| | | | | | | | | | | | | | %s/efi_simple_input_interface/efi_simple_text_input_protocol/ We should be consistent in the naming of the EFI protocol interface structures. The protocol is called EFI_SIMPLE_TEXT_INPUT_PROTOCOL. %s/ExtendedVerification/extended_verification/ Use consistent naming of function parameters. Do not use CamelCase. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
* efi_loader: Add console handle references to in/out/errAlexander Graf2018-09-231-0/+6
| | | | | | | | | | | We register the console in/out protocol on the loaded image handle, but never tell anyone about it in the systab. Because of this Shell.efi can not find the input protocol. So let's add a proper reference. Signed-off-by: Alexander Graf <agraf@suse.de> Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
* efi_loader: don't use unlimited stack as bufferHeinrich Schuchardt2018-09-231-7/+13
| | | | | | | | | The length of a string printed to the console by the EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL is not limited by the UEFI spec. Hence should not allocate a buffer for it on the stack. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
* efi_loader: rename utf16_strlen, utf16_strnlenHeinrich Schuchardt2018-09-231-1/+1
| | | | | | | | | | | The function names utf16_strlen() and utf16_strnlen() are misnomers. The functions do not count utf-16 characters but non-zero words. So let's rename them to u16_strlen and u16_strnlen(). In utf16_dup() avoid assignment in if clause. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
* efi_loader: EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.Reset()Heinrich Schuchardt2018-08-211-8/+14
| | | | | | | | | | Implement the reset service of the EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL. This should resolve the error reported by the SCT in Protocol/SimpleTextOut/BlackBoxTest/SimpleTextOutBBTestFunction_uefi.c:639 Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
* efi_loader: clear screen has to reset cursor positionHeinrich Schuchardt2018-07-251-0/+2
| | | | | | | After clearing the screen the cursor position is row 0, column 0. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
* efi_loader: EFI_SIMPLE_TEXT_INPUT_PROTOCOL.Reset()Heinrich Schuchardt2018-07-251-1/+6
| | | | | | | | | | Implement the reset service of the EFI_SIMPLE_TEXT_INPUT_PROTOCOL. This should resolve the error reported by the SCT in Protocol/SimpleTextIn/BlackBoxTest/SimpleTextInBBTestFunction.c:193 Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
* efi_loader: Fix warning in raw/cols queryAlexander Graf2018-06-031-1/+1
| | | | | | | | The code to determine rows / cols on the screen could potentially run into a case where it doesn't know how big the screen is. In that case, assume 80x25. Signed-off-by: Alexander Graf <agraf@suse.de>
* efi_loader: avoid using unitialized values as console sizeHeinrich Schuchardt2018-06-031-2/+12
| | | | | | | | | | If a request for the console size would be answered with a response with less then three values, uninitialized stack memory would be copied to the number of rows and columns of the terminal. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Reviewed-by: Simon Glass <sjg@chromium.org> Signed-off-by: Alexander Graf <agraf@suse.de>
* efi_loader: always check parameters in efi_cout_query_mode()Heinrich Schuchardt2018-06-031-42/+48
| | | | | | | | | | | | If we cannot determine the size of the serial terminal we still have to check the parameters of efi_cout_query_mode(). Querying the size of the serial terminal drains the keyboard buffer. So make sure we do this during the initialization and not in the midst of an EFI application. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
* efi_loader: updating the cursor positionHeinrich Schuchardt2018-06-031-8/+19
| | | | | | | | | | | | The current coding advances the column by the number of UTF-8 bytes. The column should be increased by one per unicode character. The UEFI spec provides advance rules for U+0000, U+0008, U+000A, and U000D. All other characters, including control characters U+0007 (bel) and U+0009 (tab), have to increase the column by one. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
* SPDX: Convert a few files that were missed beforeTom Rini2018-05-101-2/+1
| | | | | | | | | | | As part of the main conversion a few files were missed. These files had additional whitespace after the '*' and before the SPDX tag and my previous regex was too strict. This time I did a grep for all SPDX tags and then filtered out anything that matched the correct styles. Fixes: 83d290c56fab ("SPDX: Convert all of our single license tags to Linux Kernel style") Reported-by: Heinrich Schuchardt <xypron.debian@gmx.de> Signed-off-by: Tom Rini <trini@konsulko.com>
* efi_loader: implement event groupsHeinrich Schuchardt2018-04-041-3/+3
| | | | | | | | | | | | | | If an event of a group event is signaled all other events of the same group are signaled too. Function efi_signal_event is renamed to efi_queue_event. A new function efi_signal_event is introduced that checks if an event belongs to a group and than signals all events of the group. Event group notifciation is implemented for ExitBootServices, InstallConfigurationTable, and ResetSystem. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
* efi_loader: correct input of special keysHeinrich Schuchardt2018-04-041-10/+94
| | | | | | | | | Don't set unicode_char if scan_code is set. Add support for page up, page down, and insert. Correct input of function keys. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
* efi_loader: remove deprecated ConsoleControlProtocolHeinrich Schuchardt2018-04-041-46/+0
| | | | | | | | | | | The console control protocol is not defined in the UEFI standard. It exists in EDK2's EdkCompatiblityPkg package. But this package is deprecated according to https://github.com/tianocore/tianocore.github.io/wiki/Differences-between-EDK-and-EDK-II Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
* efi_loader: add check_tpl parameter to efi_signal_eventHeinrich Schuchardt2018-01-221-3/+11
| | | | | | | | | | In ExitBootServices we need to signal events irrespective of the current TPL level. A new parameter check_tpl is added to efi_signal_event(). Function efi_console_timer_notify() gets some comments. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>