aboutsummaryrefslogtreecommitdiff
path: root/lib/efi_loader/efi_console.c
AgeCommit message (Collapse)AuthorFilesLines
2019-12-02common: Move get_ticks() function out of common.hSimon Glass1-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>
2019-09-05doc: UEFI API documentationHeinrich Schuchardt1-5/+6
Add some more files to the UEFI API documentation. Correct some Sphinx comments. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2019-09-05efi_loader: do not set invalid screen modeHeinrich Schuchardt1-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>
2019-09-05efi_loader: cursor positioningHeinrich Schuchardt1-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>
2019-08-11env: Move env_get() to env.hSimon Glass1-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>
2019-06-20efi_loader: console incorrectly advertised left logo keyHeinrich Schuchardt1-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>
2019-06-20efi_loader: alternative scan codes for F5, END, HOMEHeinrich Schuchardt1-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>
2019-06-14efi_loader: fix SetAttribute()Heinrich Schuchardt1-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>
2019-06-14efi_loader: fix SetMode()Heinrich Schuchardt1-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>
2019-06-10efi_loader: event signaling in ExitBootServicesHeinrich Schuchardt1-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>
2019-06-04efi_loader: fix EnableCursor()Heinrich Schuchardt1-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>
2019-05-19efi_loader: parameter check OutputStringHeinrich Schuchardt1-0/+5
Check the parameters against NULL. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2019-05-19efi_loader: EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL.SetState() correct parameterHeinrich Schuchardt1-3/+3
KeyToggleState is a pointer according to UEFI spec 2.8. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2019-04-07efi_loader: correct CTRL-A - CTRL-Z console inputHeinrich Schuchardt1-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>
2019-03-10efi_loader: Fix serial console size detectionMatthias Brugger1-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>
2018-12-02efi_loader: fix typosHeinrich Schuchardt1-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>
2018-12-02efi_loader: eliminate handle memberHeinrich Schuchardt1-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>
2018-10-16efi_loader: return type efi_console_register()Heinrich Schuchardt1-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>
2018-09-23efi_loader: query serial console size reliablyHeinrich Schuchardt1-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>
2018-09-23efi_loader: terminal left upper corner is [1, 1]Heinrich Schuchardt1-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>
2018-09-23efi_loader: implement key notify functionsHeinrich Schuchardt1-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>
2018-09-23efi_loader: support modifiers for F1 - F4Heinrich Schuchardt1-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>
2018-09-23efi_loader: EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOLHeinrich Schuchardt1-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>
2018-09-23efi_loader: rework event handling for consoleHeinrich Schuchardt1-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>
2018-09-23efi_loader: support Unicode text inputHeinrich Schuchardt1-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>
2018-09-23efi_loader: typos in efi_console.cHeinrich Schuchardt1-4/+4
Fix a few typos. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
2018-09-23efi_loader: struct efi_simple_text_input_protocolHeinrich Schuchardt1-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>
2018-09-23efi_loader: Add console handle references to in/out/errAlexander Graf1-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>
2018-09-23efi_loader: don't use unlimited stack as bufferHeinrich Schuchardt1-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>
2018-09-23efi_loader: rename utf16_strlen, utf16_strnlenHeinrich Schuchardt1-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>
2018-08-21efi_loader: EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.Reset()Heinrich Schuchardt1-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>
2018-07-25efi_loader: clear screen has to reset cursor positionHeinrich Schuchardt1-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>
2018-07-25efi_loader: EFI_SIMPLE_TEXT_INPUT_PROTOCOL.Reset()Heinrich Schuchardt1-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>
2018-06-03efi_loader: Fix warning in raw/cols queryAlexander Graf1-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>
2018-06-03efi_loader: avoid using unitialized values as console sizeHeinrich Schuchardt1-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>
2018-06-03efi_loader: always check parameters in efi_cout_query_mode()Heinrich Schuchardt1-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>
2018-06-03efi_loader: updating the cursor positionHeinrich Schuchardt1-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>
2018-05-10SPDX: Convert a few files that were missed beforeTom Rini1-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>
2018-04-04efi_loader: implement event groupsHeinrich Schuchardt1-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>
2018-04-04efi_loader: correct input of special keysHeinrich Schuchardt1-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>
2018-04-04efi_loader: remove deprecated ConsoleControlProtocolHeinrich Schuchardt1-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>
2018-01-22efi_loader: add check_tpl parameter to efi_signal_eventHeinrich Schuchardt1-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>
2018-01-22efi_loader: consistently use efi_handle_t for handlesHeinrich Schuchardt1-3/+3
We should consistently use the efi_handle_t typedef when referring to handles. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Reviewed-by: Simon Glass <sjg@chromium.org> Signed-off-by: Alexander Graf <agraf@suse.de>
2017-12-01efi_loader: efi_console: use helper functionsHeinrich Schuchardt1-13/+35
Use helper functions efi_created_handle and efi_add_protocol for creating the console handles and instaling the respective protocols. This change is needed if we want to move from an array of protocols to a linked list of protocols. Eliminate EFI_PROTOCOL_OBJECT which is not used anymore. Currently we have not defined protocol interfaces to be const. So efi_con_out and efi_console_control cannot be defined as const. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
2017-10-12efi_loader: console support for color attributesRob Clark1-2/+25
Shell.efi uses this, and supporting color attributes makes things look nicer. Map the EFI fg/bg color attributes to ANSI escape sequences. Not all colors have a perfect match, but spec just says "Devices supporting a different number of text colors are required to emulate the above colors to the best of the device’s capabilities". Signed-off-by: Rob Clark <robdclark@gmail.com> Tested-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Reviewed-by: Alexander Graf <agraf@suse.de> [agraf: s/unsigned/unsigned int/] Signed-off-by: Alexander Graf <agraf@suse.de>
2017-10-09efi_loader: use type bool for event statesHeinrich Schuchardt1-1/+1
Queued and signaled describe boolean states of events. So let's use type bool and rename the structure members to is_queued and is_signaled. Update the comments for is_queued and is_signaled. Reported-by: Simon Glass <sjg@chromium.org> Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Reviewed-by: Rob Clark <robdclark@gmail.com> Reviewed-by: Rob Clark <robdclark@gmail.com> Signed-off-by: Alexander Graf <agraf@suse.de>
2017-09-20efi_loader: Some console improvements for vidconsoleRob Clark1-23/+35
1) use fputs() to reduce cache flushes from once-per-char to once-per-string 2) handle \r, \t, and \b in addition to just \n for tracking cursor position 3) cursor row/col are zero based, not one based Signed-off-by: Rob Clark <robdclark@gmail.com> [agraf: s/unsigned/unsigned int/] Signed-off-by: Alexander Graf <agraf@suse.de>
2017-09-20efi_loader: Correctly figure out size for vidconsoleRob Clark1-1/+15
If stdout is vidconsole, we cannot rely on ANSI escape sequences to query the size, as vidconsole cannot reply on stdin. Instead special- case this if stdout is vidconsole. Signed-off-by: Rob Clark <robdclark@gmail.com> Signed-off-by: Alexander Graf <agraf@suse.de>
2017-09-20efi_loader: split out escape sequence based size queryRob Clark1-23/+30
We need to do something different for vidconsole, since it cannot respond to the query on stdin. Prep work for next patch. Signed-off-by: Rob Clark <robdclark@gmail.com> Signed-off-by: Alexander Graf <agraf@suse.de>
2017-09-18efi_loader: implement queueing of the notification functionHeinrich Schuchardt1-1/+3
For the correct implementation of the task priority level (TPL) calling the notification function must be queued. Add a status field 'queued' to events. In function efi_signal_event set status queued if a notification function exists and reset it after we have called the function. A later patch will add a check of the TPL here. In efi_create_event and efi_close_event unset the queued status. In function efi_wait_for_event and efi_check_event queue the notification function. In efi_timer_check call the efi_notify_event if the status queued is set. For all timer events set status signaled. In efi_console_timer_notify set the signaled state of the WaitForKey event. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>