diff options
author | vanjeff <vanjeff@6f19259b-4bc3-4df7-8a09-765794883524> | 2008-07-03 05:17:49 +0000 |
---|---|---|
committer | vanjeff <vanjeff@6f19259b-4bc3-4df7-8a09-765794883524> | 2008-07-03 05:17:49 +0000 |
commit | 8fd9831511a7df7a79bfc1de939d7840359856ea (patch) | |
tree | a3acc5ee0aa94d8e9b0656732fcc4cf1eae30c63 /MdeModulePkg/Universal/Console/TerminalDxe | |
parent | a92d4e8a8eb1ab57d86f79a89b733cff6e47235b (diff) | |
download | edk2-platforms-8fd9831511a7df7a79bfc1de939d7840359856ea.tar.xz |
Added some functions header.
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@5406 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'MdeModulePkg/Universal/Console/TerminalDxe')
6 files changed, 557 insertions, 98 deletions
diff --git a/MdeModulePkg/Universal/Console/TerminalDxe/Ansi.c b/MdeModulePkg/Universal/Console/TerminalDxe/Ansi.c index 813779e0d1..3d2982f87e 100644 --- a/MdeModulePkg/Universal/Console/TerminalDxe/Ansi.c +++ b/MdeModulePkg/Universal/Console/TerminalDxe/Ansi.c @@ -1,7 +1,7 @@ /** @file
- Provides misc functions upon ansi.
+ Implementation of translation upon PC ANSI.
-Copyright (c) 2006, Intel Corporation. <BR>
+Copyright (c) 2006 - 2008, Intel Corporation. <BR>
All rights reserved. This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
@@ -15,6 +15,15 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. #include "Terminal.h"
+/**
+ Translate all raw data in the Raw FIFI into unicode, and insert
+ them into Unicode FIFO.
+
+ @param TerminalDevice The terminal device.
+
+ @return None.
+
+**/
VOID
AnsiRawDataToUnicode (
IN TERMINAL_DEV *TerminalDevice
@@ -35,6 +44,17 @@ AnsiRawDataToUnicode ( }
}
+/**
+ Check if input string is valid Ascii string, valid EFI control characters
+ or valid text graphics.
+
+ @param TerminalDevice The terminal device.
+ @param WString The input string.
+
+ @retval EFI_UNSUPPORTED If not all input characters are valid.
+ @retval EFI_SUCCESS If all input characters are valid.
+
+**/
EFI_STATUS
AnsiTestString (
IN TERMINAL_DEV *TerminalDevice,
diff --git a/MdeModulePkg/Universal/Console/TerminalDxe/Terminal.c b/MdeModulePkg/Universal/Console/TerminalDxe/Terminal.c index a1c2d5a63d..21ae6ae860 100644 --- a/MdeModulePkg/Universal/Console/TerminalDxe/Terminal.c +++ b/MdeModulePkg/Universal/Console/TerminalDxe/Terminal.c @@ -16,6 +16,15 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. #include "Terminal.h"
+/**
+ Free notify functions list.
+
+ @param ListHead The list head
+
+ @retval EFI_SUCCESS Free the notify list successfully.
+ @retval EFI_INVALID_PARAMETER ListHead is NULL.
+
+**/
EFI_STATUS
TerminalFreeNotifyList (
IN OUT LIST_ENTRY *ListHead
@@ -109,7 +118,19 @@ TERMINAL_DEV gTerminalDevTemplate = { };
+/**
+ Test to see if this driver supports ControllerHandle.
+
+ @param This Protocol instance pointer.
+ @param ControllerHandle Handle of device to test
+ @param RemainingDevicePath Optional parameter use to pick a specific child
+ device to start.
+
+ @retval EFI_SUCCESS This driver supports this device
+ @retval EFI_ALREADY_STARTED This driver is already running on this device
+ @retval other This driver does not support this device
+**/
EFI_STATUS
EFIAPI
TerminalDriverBindingSupported (
@@ -208,17 +229,20 @@ TerminalDriverBindingSupported ( return Status;
}
-
/**
- Start the controller.
+ Start this driver on ControllerHandle by opening a Serial IO protocol,
+ reading Device Path, and creating a child handle with a Simple Text In,
+ Simple Text In Ex and Simple Text Out protocol, and device path protocol.
+ And store Console Device Environment Variables.
- @param This A pointer to the EFI_DRIVER_BINDING_PROTOCOL
- instance.
- @param Controller The handle of the controller to start.
- @param RemainingDevicePath A pointer to the remaining portion of a devcie
- path.
+ @param This Protocol instance pointer.
+ @param ControllerHandle Handle of device to bind driver to
+ @param RemainingDevicePath Optional parameter use to pick a specific child
+ device to start.
- @return EFI_SUCCESS.
+ @retval EFI_SUCCESS This driver is added to ControllerHandle
+ @retval EFI_ALREADY_STARTED This driver is already running on ControllerHandle
+ @retval other This driver does not support this device
**/
EFI_STATUS
@@ -353,7 +377,9 @@ TerminalDriverBindingStart ( }
TerminalType = FixedPcdGet8 (PcdDefaultTerminalType);
- // must be between PCANSITYPE (0) and VTUTF8TYPE (3)
+ //
+ // Must be between PCANSITYPE (0) and VTUTF8TYPE (3)
+ //
ASSERT (TerminalType <= VTUTF8TYPE);
CopyMem (&DefaultNode->Guid, gTerminalType[TerminalType], sizeof (EFI_GUID));
@@ -726,19 +752,19 @@ Error: return Status;
}
-
/**
- Stop a device controller.
+ Stop this driver on ControllerHandle by closing Simple Text In, Simple Text
+ In Ex, Simple Text Out protocol, and removing parent device path from
+ Console Device Environment Variables.
- @param This A pointer to the EFI_DRIVER_BINDING_PROTOCOL
- instance.
- @param Controller A handle to the device being stopped.
- @param NumberOfChildren The number of child device handles in
- ChildHandleBuffer.
- @param ChildHandleBuffer An array of child handles to be freed.
+ @param This Protocol instance pointer.
+ @param ControllerHandle Handle of device to stop driver on
+ @param NumberOfChildren Number of Handles in ChildHandleBuffer. If number of
+ children is zero stop the entire bus driver.
+ @param ChildHandleBuffer List of Child Handles to Stop.
- @retval EFI_SUCCESS Operation successful.
- @retval EFI_DEVICE_ERROR Devices error.
+ @retval EFI_SUCCESS This driver is removed ControllerHandle.
+ @retval other This driver could not be removed from this device.
**/
EFI_STATUS
@@ -920,11 +946,12 @@ TerminalDriverBindingStop ( /**
+ Free notify functions list.
@param ListHead The list head
- @retval EFI_SUCCESS Free the notify list successfully
- @retval EFI_INVALID_PARAMETER ListHead is invalid.
+ @retval EFI_SUCCESS Free the notify list successfully.
+ @retval EFI_INVALID_PARAMETER ListHead is NULL.
**/
EFI_STATUS
@@ -952,7 +979,15 @@ TerminalFreeNotifyList ( }
+/**
+ Update terminal device path in Console Device Environment Variables.
+
+ @param VariableName The Console Device Environment Variable.
+ @param ParentDevicePath The terminal devcie path to be updated.
+
+ @return None.
+**/
VOID
TerminalUpdateConsoleDevVariable (
IN CHAR16 *VariableName,
@@ -1010,10 +1045,10 @@ TerminalUpdateConsoleDevVariable ( /**
- Remove console device variable.
+ Remove terminal device path from Console Device Environment Variables.
- @param VariableName A pointer to the variable name.
- @param ParentDevicePath A pointer to the parent device path.
+ @param VariableName Console Device Environment Variables.
+ @param ParentDevicePath The terminal devcie path to be updated.
@return None.
@@ -1202,6 +1237,18 @@ TerminalGetVariableAndSize ( return Buffer;
}
+/**
+ Build termial device path according to terminal type.
+
+ @param TerminalType The terminal type is PC ANSI, VT100, VT100+ or VT-UTF8.
+ @param ParentDevicePath Parent devcie path.
+ @param TerminalDevicePath Returned terminal device path, if building successfully.
+
+ @retval EFI_UNSUPPORTED Terminal does not belong to the supported type.
+ @retval EFI_OUT_OF_RESOURCES Generate terminal device path failed.
+ @retval EFI_SUCCESS Build terminal device path successfully.
+
+**/
EFI_STATUS
SetTerminalDevicePath (
IN UINT8 TerminalType,
@@ -1276,6 +1323,14 @@ SetTerminalDevicePath ( return EFI_SUCCESS;
}
+/**
+ Initialize the Raw Data FIFO.
+
+ @param TerminalDevice The terminal device.
+
+ @return None.
+
+**/
VOID
InitializeRawFiFo (
IN TERMINAL_DEV *TerminalDevice
@@ -1287,6 +1342,14 @@ InitializeRawFiFo ( TerminalDevice->RawFiFo.Head = TerminalDevice->RawFiFo.Tail;
}
+/**
+ Initialize the Unicode FIFO.
+
+ @param TerminalDevice The terminal device.
+
+ @return None.
+
+**/
VOID
InitializeUnicodeFiFo (
IN TERMINAL_DEV *TerminalDevice
@@ -1298,6 +1361,14 @@ InitializeUnicodeFiFo ( TerminalDevice->UnicodeFiFo.Head = TerminalDevice->UnicodeFiFo.Tail;
}
+/**
+ Initialize the EFI Key FIFO.
+
+ @param TerminalDevice The terminal device.
+
+ @return None.
+
+**/
VOID
InitializeEfiKeyFiFo (
IN TERMINAL_DEV *TerminalDevice
diff --git a/MdeModulePkg/Universal/Console/TerminalDxe/Terminal.h b/MdeModulePkg/Universal/Console/TerminalDxe/Terminal.h index eaa4a74e27..7410f33e36 100644 --- a/MdeModulePkg/Universal/Console/TerminalDxe/Terminal.h +++ b/MdeModulePkg/Universal/Console/TerminalDxe/Terminal.h @@ -192,10 +192,8 @@ InitializeTerminal ( @param This Indicates the calling context.
@param ExtendedVerification Skip by this driver.
- @return EFI_SUCCESS
- @return The reset operation succeeds.
- @return EFI_DEVICE_ERROR
- @return The dependent serial port reset fails.
+ @return EFI_SUCCESS The reset operation succeeds.
+ @return EFI_DEVICE_ERROR The dependent serial port reset fails.
**/
EFI_STATUS
@@ -210,17 +208,14 @@ TerminalConInReset ( /**
Implements EFI_SIMPLE_TEXT_INPUT_PROTOCOL.ReadKeyStroke().
- @param This Indicates the calling context.
- @param Key A pointer to a buffer that is filled in with the
- keystroke information for the key that was sent
- from terminal.
-
- @return EFI_SUCCESS
- @return The keystroke information is returned successfully.
- @return EFI_NOT_READY
- @return There is no keystroke data available.
- @return EFI_DEVICE_ERROR
- @return The dependent serial device encounters error.
+ @param This Indicates the calling context.
+ @param Key A pointer to a buffer that is filled in with the
+ keystroke information for the key that was sent
+ from terminal.
+
+ @return EFI_SUCCESS The keystroke information is returned successfully.
+ @return EFI_NOT_READY There is no keystroke data available.
+ @return EFI_DEVICE_ERROR The dependent serial device encounters error.
**/
EFI_STATUS
@@ -231,8 +226,8 @@ TerminalConInReadKeyStroke ( )
;
-
/**
+ Check if the key already has been registered.
@param RegsiteredData A pointer to a buffer that is filled in with the
keystroke state data for the key that was
@@ -419,10 +414,8 @@ TerminalConInWaitForKey ( exhaustive verification operation of the device
during reset.
- @return EFI_SUCCESS
- @return The reset operation succeeds.
- @return EFI_DEVICE_ERROR
- @return The terminal is not functioning correctly or the serial port reset fails.
+ @return EFI_SUCCESS The reset operation succeeds.
+ @return EFI_DEVICE_ERROR The terminal is not functioning correctly or the serial port reset fails.
**/
EFI_STATUS
@@ -442,11 +435,11 @@ TerminalConOutReset ( @param WString The Null-terminated Unicode string to be displayed
on the terminal screen.
- @return EFI_SUCCESS The string is output successfully.
- @return EFI_DEVICE_ERROR The serial port fails to send the string out.
- @return EFI_WARN_UNKNOWN_GLYPH Indicates that some of the characters in the Unicode string could not
+ @retval EFI_SUCCESS The string is output successfully.
+ @retval EFI_DEVICE_ERROR The serial port fails to send the string out.
+ @retval EFI_WARN_UNKNOWN_GLYPH Indicates that some of the characters in the Unicode string could not
be rendered and are skipped.
- @return EFI_UNSUPPORTED
+ @retval EFI_UNSUPPORTED If current display mode is out of range.
**/
EFI_STATUS
@@ -609,6 +602,19 @@ TerminalConOutEnableCursor ( )
;
+/**
+ Test to see if this driver supports ControllerHandle.
+
+ @param This Protocol instance pointer.
+ @param ControllerHandle Handle of device to test
+ @param RemainingDevicePath Optional parameter use to pick a specific child
+ device to start.
+
+ @retval EFI_SUCCESS This driver supports this device
+ @retval EFI_ALREADY_STARTED This driver is already running on this device
+ @retval other This driver does not support this device
+
+**/
EFI_STATUS
EFIAPI
TerminalDriverBindingSupported (
@@ -617,6 +623,22 @@ TerminalDriverBindingSupported ( IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
);
+/**
+ Start this driver on ControllerHandle by opening a Serial IO protocol,
+ reading Device Path, and creating a child handle with a Simple Text In,
+ Simple Text In Ex and Simple Text Out protocol, and device path protocol.
+ And store Console Device Environment Variables.
+
+ @param This Protocol instance pointer.
+ @param ControllerHandle Handle of device to bind driver to
+ @param RemainingDevicePath Optional parameter use to pick a specific child
+ device to start.
+
+ @retval EFI_SUCCESS This driver is added to ControllerHandle
+ @retval EFI_ALREADY_STARTED This driver is already running on ControllerHandle
+ @retval other This driver does not support this device
+
+**/
EFI_STATUS
EFIAPI
TerminalDriverBindingStart (
@@ -625,6 +647,21 @@ TerminalDriverBindingStart ( IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
);
+/**
+ Stop this driver on ControllerHandle by closing Simple Text In, Simple Text
+ In Ex, Simple Text Out protocol, and removing parent device path from
+ Console Device Environment Variables.
+
+ @param This Protocol instance pointer.
+ @param ControllerHandle Handle of device to stop driver on
+ @param NumberOfChildren Number of Handles in ChildHandleBuffer. If number of
+ children is zero stop the entire bus driver.
+ @param ChildHandleBuffer List of Child Handles to Stop.
+
+ @retval EFI_SUCCESS This driver is removed ControllerHandle.
+ @retval other This driver could not be removed from this device.
+
+**/
EFI_STATUS
EFIAPI
TerminalDriverBindingStop (
@@ -770,11 +807,9 @@ TerminalComponentNameGetControllerName ( @param This Indicates the calling context.
- @return EFI_SUCCESS
- @return There is key pending.
- @return EFI_NOT_READY
- @return There is no key pending.
- @return EFI_DEVICE_ERROR
+ @retval EFI_SUCCESS There is key pending.
+ @retval EFI_NOT_READY There is no key pending.
+ @retval EFI_DEVICE_ERROR If Serial IO is not attched to serial device.
**/
EFI_STATUS
@@ -783,6 +818,15 @@ TerminalConInCheckForKey ( )
;
+/**
+ Update terminal device path in Console Device Environment Variables.
+
+ @param VariableName The Console Device Environment Variable.
+ @param ParentDevicePath The terminal devcie path to be updated.
+
+ @return None.
+
+**/
VOID
TerminalUpdateConsoleDevVariable (
IN CHAR16 *VariableName,
@@ -827,6 +871,18 @@ TerminalGetVariableAndSize ( )
;
+/**
+ Build termial device path according to terminal type.
+
+ @param TerminalType The terminal type is PC ANSI, VT100, VT100+ or VT-UTF8.
+ @param ParentDevicePath Parent devcie path.
+ @param TerminalDevicePath Returned terminal device path, if building successfully.
+
+ @retval EFI_UNSUPPORTED Terminal does not belong to the supported type.
+ @retval EFI_OUT_OF_RESOURCES Generate terminal device path failed.
+ @retval EFI_SUCCESS Build terminal device path successfully.
+
+**/
EFI_STATUS
SetTerminalDevicePath (
IN UINT8 TerminalType,
@@ -835,18 +891,42 @@ SetTerminalDevicePath ( )
;
+/**
+ Initialize the Raw Data FIFO.
+
+ @param TerminalDevice The terminal device.
+
+ @return None.
+
+**/
VOID
InitializeRawFiFo (
IN TERMINAL_DEV *TerminalDevice
)
;
+/**
+ Initialize the Unicode FIFO.
+
+ @param TerminalDevice The terminal device.
+
+ @return None.
+
+**/
VOID
InitializeUnicodeFiFo (
IN TERMINAL_DEV *TerminalDevice
)
;
+/**
+ Initialize the EFI Key FIFO.
+
+ @param TerminalDevice The terminal device.
+
+ @return None.
+
+**/
VOID
InitializeEfiKeyFiFo (
IN TERMINAL_DEV *TerminalDevice
@@ -1067,12 +1147,29 @@ IsUnicodeFiFoFull ( )
;
+/**
+ Count Unicode FIFO buffer.
+
+ @param TerminalDevice Terminal driver private structure
+
+ @return The count in bytes of Unicode FIFO.
+
+**/
UINT8
UnicodeFiFoGetKeyCount (
TERMINAL_DEV *TerminalDevice
)
;
+/**
+ Translate raw data into Unicode (according to different encode), and
+ translate Unicode into key information. (according to different standard).
+
+ @param TerminalDevice Terminal driver private structure.
+
+ @return none.
+
+**/
VOID
TranslateRawDataToEfiKey (
IN TERMINAL_DEV *TerminalDevice
@@ -1082,18 +1179,104 @@ TranslateRawDataToEfiKey ( //
// internal functions for PC ANSI
//
+
+/**
+ Translate all raw data in the Raw FIFI into unicode, and insert
+ them into Unicode FIFO.
+
+ @param TerminalDevice The terminal device.
+
+ @return None.
+
+**/
VOID
AnsiRawDataToUnicode (
- IN TERMINAL_DEV *PcAnsiDevice
+ IN TERMINAL_DEV *TerminalDevice
)
;
+/**
+ Converts a stream of Unicode characters from a terminal input device into EFI Keys that
+ can be read through the Simple Input Protocol.
+
+ The table below shows the keyboard input mappings that this function supports.
+ If the ESC sequence listed in one of the columns is presented, then it is translated
+ into the coorespoding EFI Scan Code. If a matching sequence is not found, then the raw
+ key strokes are converted into EFI Keys.
+
+ 2 seconds are allowed for an ESC sequence to be completed. If the ESC sequence is not
+ completed in 2 seconds, then the raw key strokes of the partial ESC sequence are
+ converted into EFI Keys.
+ There is one special input sequence that will force the system to reset.
+ This is ESC R ESC r ESC R.
+
+ Symbols used in table below
+ ===========================
+ ESC = 0x1B
+ CSI = 0x9B
+ DEL = 0x7f
+ ^ = CTRL
+ +=========+======+===========+==========+==========+
+ | | EFI | UEFI 2.0 | | |
+ | | Scan | | VT100+ | |
+ | KEY | Code | PC ANSI | VTUTF8 | VT100 |
+ +=========+======+===========+==========+==========+
+ | NULL | 0x00 | | | |
+ | UP | 0x01 | ESC [ A | ESC [ A | ESC [ A |
+ | DOWN | 0x02 | ESC [ B | ESC [ B | ESC [ B |
+ | RIGHT | 0x03 | ESC [ C | ESC [ C | ESC [ C |
+ | LEFT | 0x04 | ESC [ D | ESC [ D | ESC [ D |
+ | HOME | 0x05 | ESC [ H | ESC h | ESC [ H |
+ | END | 0x06 | ESC [ F | ESC k | ESC [ K |
+ | INSERT | 0x07 | ESC [ @ | ESC + | ESC [ @ |
+ | | | ESC [ L | | ESC [ L |
+ | DELETE | 0x08 | ESC [ X | ESC - | ESC [ P |
+ | PG UP | 0x09 | ESC [ I | ESC ? | ESC [ V |
+ | | | | | ESC [ ? |
+ | PG DOWN | 0x0A | ESC [ G | ESC / | ESC [ U |
+ | | | | | ESC [ / |
+ | F1 | 0x0B | ESC [ M | ESC 1 | ESC O P |
+ | F2 | 0x0C | ESC [ N | ESC 2 | ESC O Q |
+ | F3 | 0x0D | ESC [ O | ESC 3 | ESC O w |
+ | F4 | 0x0E | ESC [ P | ESC 4 | ESC O x |
+ | F5 | 0x0F | ESC [ Q | ESC 5 | ESC O t |
+ | F6 | 0x10 | ESC [ R | ESC 6 | ESC O u |
+ | F7 | 0x11 | ESC [ S | ESC 7 | ESC O q |
+ | F8 | 0x12 | ESC [ T | ESC 8 | ESC O r |
+ | F9 | 0x13 | ESC [ U | ESC 9 | ESC O p |
+ | F10 | 0x14 | ESC [ V | ESC 0 | ESC O M |
+ | Escape | 0x17 | ESC | ESC | ESC |
+ | F11 | 0x15 | | ESC ! | |
+ | F12 | 0x16 | | ESC @ | |
+ +=========+======+===========+==========+==========+
+
+ Special Mappings
+ ================
+ ESC R ESC r ESC R = Reset System
+
+
+ @param TerminalDevice The terminal device to use to translate raw input into EFI Keys
+
+ @return None.
+
+**/
VOID
UnicodeToEfiKey (
IN TERMINAL_DEV *PcAnsiDevice
)
;
+/**
+ Check if input string is valid Ascii string, valid EFI control characters
+ or valid text graphics.
+
+ @param TerminalDevice The terminal device.
+ @param WString The input string.
+
+ @retval EFI_UNSUPPORTED If not all input characters are valid.
+ @retval EFI_SUCCESS If all input characters are valid.
+
+**/
EFI_STATUS
AnsiTestString (
IN TERMINAL_DEV *TerminalDevice,
@@ -1104,12 +1287,31 @@ AnsiTestString ( //
// internal functions for VTUTF8
//
+
+/**
+ Translate all VT-UTF8 characters in the Raw FIFI into unicode characters,
+ and insert them into Unicode FIFO.
+
+ @param VtUtf8Device The terminal device.
+
+ @return None.
+
+**/
VOID
VTUTF8RawDataToUnicode (
IN TERMINAL_DEV *VtUtf8Device
)
;
+/**
+ Check if input string is valid VT-UTF8 string.
+
+ @param TerminalDevice The terminal device.
+ @param WString The input string.
+
+ @retval EFI_SUCCESS If all input characters are valid.
+
+**/
EFI_STATUS
VTUTF8TestString (
IN TERMINAL_DEV *TerminalDevice,
@@ -1117,6 +1319,24 @@ VTUTF8TestString ( )
;
+/**
+ Translate one Unicode character into VT-UTF8 characters.
+
+ UTF8 Encoding Table
+ Bits per Character | Unicode Character Range | Unicode Binary Encoding | UTF8 Binary Encoding
+ 0-7 | 0x0000 - 0x007F | 00000000 0xxxxxxx | 0xxxxxxx
+ 8-11 | 0x0080 - 0x07FF | 00000xxx xxxxxxxx | 110xxxxx 10xxxxxx
+ 12-16 | 0x0800 - 0xFFFF | xxxxxxxx xxxxxxxx | 1110xxxx 10xxxxxx 10xxxxxx
+
+
+ @param Unicode Unicode character need translating.
+ @param Utf8Char Return VT-UTF8 character set.
+ @param ValidBytes The count of valid VT-UTF8 characters. If
+ ValidBytes is zero, no valid VT-UTF8 returned.
+
+ @return None.
+
+**/
VOID
UnicodeToUtf8 (
IN CHAR16 Unicode,
@@ -1125,6 +1345,17 @@ UnicodeToUtf8 ( )
;
+/**
+ Get one valid VT-UTF8 characters set from Raw Data FIFO.
+
+ @param Utf8Device The terminal device.
+ @param Utf8Char Returned valid VT-UTF8 characters set.
+ @param ValidBytes The count of returned VT-VTF8 characters.
+ If ValidBytes is zero, no valid VT-UTF8 returned.
+
+ @retval None.
+
+**/
VOID
GetOneValidUtf8Char (
IN TERMINAL_DEV *Utf8Device,
@@ -1133,6 +1364,23 @@ GetOneValidUtf8Char ( )
;
+/**
+ Translate VT-UTF8 characters into one Unicode character.
+
+ UTF8 Encoding Table
+ Bits per Character | Unicode Character Range | Unicode Binary Encoding | UTF8 Binary Encoding
+ 0-7 | 0x0000 - 0x007F | 00000000 0xxxxxxx | 0xxxxxxx
+ 8-11 | 0x0080 - 0x07FF | 00000xxx xxxxxxxx | 110xxxxx 10xxxxxx
+ 12-16 | 0x0800 - 0xFFFF | xxxxxxxx xxxxxxxx | 1110xxxx 10xxxxxx 10xxxxxx
+
+
+ @param Utf8Char VT-UTF8 character set needs translating.
+ @param ValidBytes The count of valid VT-UTF8 characters.
+ @param UnicodeChar Returned unicode character.
+
+ @return None.
+
+**/
VOID
Utf8ToUnicode (
IN UTF8_CHAR Utf8Char,
@@ -1144,6 +1392,19 @@ Utf8ToUnicode ( //
// functions for boxdraw unicode
//
+
+/**
+ Detects if a Unicode char is for Box Drawing text graphics.
+
+ @param Graphic Unicode char to test.
+ @param PcAnsi Optional pointer to return PCANSI equivalent of
+ Graphic.
+ @param Ascii Optional pointer to return ASCII equivalent of
+ Graphic.
+
+ @return TRUE If Graphic is a supported Unicode Box Drawing character.
+
+**/
BOOLEAN
TerminalIsValidTextGraphics (
IN CHAR16 Graphic,
@@ -1152,12 +1413,30 @@ TerminalIsValidTextGraphics ( )
;
+/**
+ Detects if a valid ASCII char.
+
+ @param Ascii An ASCII character.
+
+ @retval TRUE If it is a valid ASCII character.
+ @retval FALSE If it is not a valid ASCII character.
+
+**/
BOOLEAN
TerminalIsValidAscii (
IN CHAR16 Ascii
)
;
+/**
+ Detects if a valid EFI control character.
+
+ @param CharC An input EFI Control character.
+
+ @retval TRUE If it is a valid EFI control character.
+ @retval FALSE If it is not a valid EFI control character.
+
+**/
BOOLEAN
TerminalIsValidEfiCntlChar (
IN CHAR16 CharC
diff --git a/MdeModulePkg/Universal/Console/TerminalDxe/TerminalConIn.c b/MdeModulePkg/Universal/Console/TerminalDxe/TerminalConIn.c index 62abf90762..6d0899d694 100644 --- a/MdeModulePkg/Universal/Console/TerminalDxe/TerminalConIn.c +++ b/MdeModulePkg/Universal/Console/TerminalDxe/TerminalConIn.c @@ -91,10 +91,8 @@ ReadKeyStrokeWorker ( @param This Indicates the calling context.
@param ExtendedVerification Skip by this driver.
- @return EFI_SUCCESS
- @return The reset operation succeeds.
- @return EFI_DEVICE_ERROR
- @return The dependent serial port reset fails.
+ @return EFI_SUCCESS The reset operation succeeds.
+ @return EFI_DEVICE_ERROR The dependent serial port reset fails.
**/
EFI_STATUS
@@ -138,21 +136,17 @@ TerminalConInReset ( return Status;
}
-
/**
Implements EFI_SIMPLE_TEXT_INPUT_PROTOCOL.ReadKeyStroke().
- @param This Indicates the calling context.
- @param Key A pointer to a buffer that is filled in with the
- keystroke information for the key that was sent
- from terminal.
+ @param This Indicates the calling context.
+ @param Key A pointer to a buffer that is filled in with the
+ keystroke information for the key that was sent
+ from terminal.
- @return EFI_SUCCESS
- @return The keystroke information is returned successfully.
- @return EFI_NOT_READY
- @return There is no keystroke data available.
- @return EFI_DEVICE_ERROR
- @return The dependent serial device encounters error.
+ @return EFI_SUCCESS The keystroke information is returned successfully.
+ @return EFI_NOT_READY There is no keystroke data available.
+ @return EFI_DEVICE_ERROR The dependent serial device encounters error.
**/
EFI_STATUS
@@ -182,9 +176,8 @@ TerminalConInReadKeyStroke ( }
-
-
/**
+ Check if the key already has been registered.
@param RegsiteredData A pointer to a buffer that is filled in with the
keystroke state data for the key that was
@@ -244,7 +237,6 @@ TerminalConInWaitForKeyEx ( // Simple Text Input Ex protocol functions
//
-
/**
Reset the input device and optionaly run diagnostics
@@ -501,7 +493,7 @@ TerminalConInUnregisterKeyNotify ( }
/**
- Turn raw data into Unicode (according to different encode), and
+ Translate raw data into Unicode (according to different encode), and
translate Unicode into key information. (according to different standard).
@param TerminalDevice Terminal driver private structure.
@@ -575,11 +567,9 @@ TerminalConInWaitForKey ( @param This Indicates the calling context.
- @return EFI_SUCCESS
- @return There is key pending.
- @return EFI_NOT_READY
- @return There is no key pending.
- @return EFI_DEVICE_ERROR
+ @retval EFI_SUCCESS There is key pending.
+ @retval EFI_NOT_READY There is no key pending.
+ @retval EFI_DEVICE_ERROR If Serial IO is not attched to serial device.
**/
EFI_STATUS
@@ -1088,6 +1078,14 @@ IsUnicodeFiFoFull ( return FALSE;
}
+/**
+ Count Unicode FIFO buffer.
+
+ @param TerminalDevice Terminal driver private structure
+
+ @return The count in bytes of Unicode FIFO.
+
+**/
UINT8
UnicodeFiFoGetKeyCount (
TERMINAL_DEV *TerminalDevice
@@ -1106,6 +1104,14 @@ UnicodeFiFoGetKeyCount ( }
}
+/**
+ Update the Unicode characters from a terminal input device into EFI Keys FIFO.
+
+ @param TerminalDevice The terminal device to use to translate raw input into EFI Keys
+
+ @return None.
+
+**/
VOID
UnicodeToEfiKeyFlushState (
IN TERMINAL_DEV *TerminalDevice
@@ -1155,10 +1161,13 @@ UnicodeToEfiKeyFlushState ( /**
Converts a stream of Unicode characters from a terminal input device into EFI Keys that
- can be read through the Simple Input Protocol. The table below shows the keyboard
- input mappings that this function supports. If the ESC sequence listed in one of the
- columns is presented, then it is translated into the coorespoding EFI Scan Code. If a
- matching sequence is not found, then the raw key strokes are converted into EFI Keys.
+ can be read through the Simple Input Protocol.
+
+ The table below shows the keyboard input mappings that this function supports.
+ If the ESC sequence listed in one of the columns is presented, then it is translated
+ into the coorespoding EFI Scan Code. If a matching sequence is not found, then the raw
+ key strokes are converted into EFI Keys.
+
2 seconds are allowed for an ESC sequence to be completed. If the ESC sequence is not
completed in 2 seconds, then the raw key strokes of the partial ESC sequence are
converted into EFI Keys.
@@ -1171,7 +1180,7 @@ UnicodeToEfiKeyFlushState ( CSI = 0x9B
DEL = 0x7f
^ = CTRL
-
+
+=========+======+===========+==========+==========+
| | EFI | UEFI 2.0 | | |
| | Scan | | VT100+ | |
@@ -1205,15 +1214,14 @@ UnicodeToEfiKeyFlushState ( | F11 | 0x15 | | ESC ! | |
| F12 | 0x16 | | ESC @ | |
+=========+======+===========+==========+==========+
-
+
Special Mappings
================
ESC R ESC r ESC R = Reset System
-
@param TerminalDevice The terminal device to use to translate raw input into EFI Keys
- @return None
+ @return None.
**/
VOID
@@ -1250,7 +1258,7 @@ UnicodeToEfiKey ( //
// Fetch one Unicode character from the Unicode FIFO
//
- UnicodeFiFoRemoveOneKey (TerminalDevice,&UnicodeChar);
+ UnicodeFiFoRemoveOneKey (TerminalDevice, &UnicodeChar);
SetDefaultResetState = TRUE;
diff --git a/MdeModulePkg/Universal/Console/TerminalDxe/TerminalConOut.c b/MdeModulePkg/Universal/Console/TerminalDxe/TerminalConOut.c index f6f78b6b88..c7c94fe029 100644 --- a/MdeModulePkg/Universal/Console/TerminalDxe/TerminalConOut.c +++ b/MdeModulePkg/Universal/Console/TerminalDxe/TerminalConOut.c @@ -98,10 +98,8 @@ CHAR16 mSetCursorPositionString[] = { ESC, '[', '0', '0', ';', '0', '0', 'H', 0 exhaustive verification operation of the device
during reset.
- @return EFI_SUCCESS
- @return The reset operation succeeds.
- @return EFI_DEVICE_ERROR
- @return The terminal is not functioning correctly or the serial port reset fails.
+ @return EFI_SUCCESS The reset operation succeeds.
+ @return EFI_DEVICE_ERROR The terminal is not functioning correctly or the serial port reset fails.
**/
EFI_STATUS
@@ -161,11 +159,11 @@ TerminalConOutReset ( @param WString The Null-terminated Unicode string to be displayed
on the terminal screen.
- @return EFI_SUCCESS The string is output successfully.
- @return EFI_DEVICE_ERROR The serial port fails to send the string out.
- @return EFI_WARN_UNKNOWN_GLYPH Indicates that some of the characters in the Unicode string could not
+ @retval EFI_SUCCESS The string is output successfully.
+ @retval EFI_DEVICE_ERROR The serial port fails to send the string out.
+ @retval EFI_WARN_UNKNOWN_GLYPH Indicates that some of the characters in the Unicode string could not
be rendered and are skipped.
- @return EFI_UNSUPPORTED
+ @retval EFI_UNSUPPORTED If current display mode is out of range.
**/
EFI_STATUS
@@ -855,6 +853,15 @@ TerminalIsValidTextGraphics ( return FALSE;
}
+/**
+ Detects if a valid ASCII char.
+
+ @param Ascii An ASCII character.
+
+ @retval TRUE If it is a valid ASCII character.
+ @retval FALSE If it is not a valid ASCII character.
+
+**/
BOOLEAN
TerminalIsValidAscii (
IN CHAR16 Ascii
@@ -870,6 +877,15 @@ TerminalIsValidAscii ( return FALSE;
}
+/**
+ Detects if a valid EFI control character.
+
+ @param CharC An input EFI Control character.
+
+ @retval TRUE If it is a valid EFI control character.
+ @retval FALSE If it is not a valid EFI control character.
+
+**/
BOOLEAN
TerminalIsValidEfiCntlChar (
IN CHAR16 CharC
diff --git a/MdeModulePkg/Universal/Console/TerminalDxe/Vtutf8.c b/MdeModulePkg/Universal/Console/TerminalDxe/Vtutf8.c index 260ae84899..acdb8ca6f5 100644 --- a/MdeModulePkg/Universal/Console/TerminalDxe/Vtutf8.c +++ b/MdeModulePkg/Universal/Console/TerminalDxe/Vtutf8.c @@ -1,5 +1,5 @@ /** @file
- Implementation translation among different code tyies.
+ Implementation of translation upon VT-UTF8.
Copyright (c) 2006, Intel Corporation. <BR>
All rights reserved. This program and the accompanying materials
@@ -14,6 +14,15 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. #include "Terminal.h"
+/**
+ Translate all VT-UTF8 characters in the Raw FIFI into unicode characters,
+ and insert them into Unicode FIFO.
+
+ @param TerminalDevice The terminal device.
+
+ @return None.
+
+**/
VOID
VTUTF8RawDataToUnicode (
IN TERMINAL_DEV *TerminalDevice
@@ -43,6 +52,17 @@ VTUTF8RawDataToUnicode ( }
}
+/**
+ Get one valid VT-UTF8 characters set from Raw Data FIFO.
+
+ @param Utf8Device The terminal device.
+ @param Utf8Char Returned valid VT-UTF8 characters set.
+ @param ValidBytes The count of returned VT-VTF8 characters.
+ If ValidBytes is zero, no valid VT-UTF8 returned.
+
+ @retval None.
+
+**/
VOID
GetOneValidUtf8Char (
IN TERMINAL_DEV *Utf8Device,
@@ -148,6 +168,23 @@ GetOneValidUtf8Char ( return ;
}
+/**
+ Translate VT-UTF8 characters into one Unicode character.
+
+ UTF8 Encoding Table
+ Bits per Character | Unicode Character Range | Unicode Binary Encoding | UTF8 Binary Encoding
+ 0-7 | 0x0000 - 0x007F | 00000000 0xxxxxxx | 0xxxxxxx
+ 8-11 | 0x0080 - 0x07FF | 00000xxx xxxxxxxx | 110xxxxx 10xxxxxx
+ 12-16 | 0x0800 - 0xFFFF | xxxxxxxx xxxxxxxx | 1110xxxx 10xxxxxx 10xxxxxx
+
+
+ @param Utf8Char VT-UTF8 character set needs translating.
+ @param ValidBytes The count of valid VT-UTF8 characters.
+ @param UnicodeChar Returned unicode character.
+
+ @return None.
+
+**/
VOID
Utf8ToUnicode (
IN UTF8_CHAR Utf8Char,
@@ -206,6 +243,24 @@ Utf8ToUnicode ( return ;
}
+/**
+ Translate one Unicode character into VT-UTF8 characters.
+
+ UTF8 Encoding Table
+ Bits per Character | Unicode Character Range | Unicode Binary Encoding | UTF8 Binary Encoding
+ 0-7 | 0x0000 - 0x007F | 00000000 0xxxxxxx | 0xxxxxxx
+ 8-11 | 0x0080 - 0x07FF | 00000xxx xxxxxxxx | 110xxxxx 10xxxxxx
+ 12-16 | 0x0800 - 0xFFFF | xxxxxxxx xxxxxxxx | 1110xxxx 10xxxxxx 10xxxxxx
+
+
+ @param Unicode Unicode character need translating.
+ @param Utf8Char Return VT-UTF8 character set.
+ @param ValidBytes The count of valid VT-UTF8 characters. If
+ ValidBytes is zero, no valid VT-UTF8 returned.
+
+ @return None.
+
+**/
VOID
UnicodeToUtf8 (
IN CHAR16 Unicode,
@@ -249,6 +304,16 @@ UnicodeToUtf8 ( }
}
+
+/**
+ Check if input string is valid VT-UTF8 string.
+
+ @param TerminalDevice The terminal device.
+ @param WString The input string.
+
+ @retval EFI_SUCCESS If all input characters are valid.
+
+**/
EFI_STATUS
VTUTF8TestString (
IN TERMINAL_DEV *TerminalDevice,
|