]> git.proxmox.com Git - mirror_edk2.git/blame - MdeModulePkg/Universal/Console/TerminalDxe/Terminal.h
edk2/MdePkg/Include/Ia32/ProcessorBind.h:
[mirror_edk2.git] / MdeModulePkg / Universal / Console / TerminalDxe / Terminal.h
CommitLineData
fb0b259e 1/** @file\r
2 Header file for Terminal driver.\r
95276127 3\r
fb0b259e 4Copyright (c) 2006 - 2008, Intel Corporation. <BR>\r
5All rights reserved. This program and the accompanying materials\r
6are licensed and made available under the terms and conditions of the BSD License\r
7which accompanies this distribution. The full text of the license may be found at\r
8http://opensource.org/licenses/bsd-license.php\r
95276127 9\r
fb0b259e 10THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
11WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
95276127 12\r
fb0b259e 13**/\r
95276127 14\r
e49ef433 15#ifndef _TERMINAL_H_\r
16#define _TERMINAL_H_\r
95276127 17\r
97a079ed
A
18\r
19#include <PiDxe.h>\r
20#include <Protocol/SimpleTextOut.h>\r
21#include <Protocol/SerialIo.h>\r
22#include <Guid/GlobalVariable.h>\r
23#include <Protocol/DevicePath.h>\r
24#include <Protocol/SimpleTextIn.h>\r
66aa04e4 25#include <Protocol/SimpleTextInEx.h>\r
97a079ed
A
26#include <Guid/HotPlugDevice.h>\r
27#include <Guid/PcAnsi.h>\r
28#include <Library/DebugLib.h>\r
29#include <Library/UefiDriverEntryPoint.h>\r
30#include <Library/UefiLib.h>\r
31#include <Library/ReportStatusCodeLib.h>\r
32#include <Library/BaseMemoryLib.h>\r
33#include <Library/MemoryAllocationLib.h>\r
34#include <Library/UefiBootServicesTableLib.h>\r
35#include <Library/UefiRuntimeServicesTableLib.h>\r
36#include <Library/DevicePathLib.h>\r
37#include <Library/PcdLib.h>\r
66aa04e4 38#include <Library/BaseLib.h>\r
97a079ed 39\r
95276127 40\r
41#define RAW_FIFO_MAX_NUMBER 256\r
42#define FIFO_MAX_NUMBER 128\r
43\r
44typedef struct {\r
45 UINT8 Head;\r
46 UINT8 Tail;\r
47 UINT8 Data[RAW_FIFO_MAX_NUMBER + 1];\r
48} RAW_DATA_FIFO;\r
49\r
50typedef struct {\r
51 UINT8 Head;\r
52 UINT8 Tail;\r
53 UINT16 Data[FIFO_MAX_NUMBER + 1];\r
54} UNICODE_FIFO;\r
55\r
56typedef struct {\r
57 UINT8 Head;\r
58 UINT8 Tail;\r
59 EFI_INPUT_KEY Data[FIFO_MAX_NUMBER + 1];\r
60} EFI_KEY_FIFO;\r
61\r
62#define TERMINAL_DEV_SIGNATURE EFI_SIGNATURE_32 ('t', 'm', 'n', 'l')\r
63\r
66aa04e4 64#define TERMINAL_CONSOLE_IN_EX_NOTIFY_SIGNATURE EFI_SIGNATURE_32 ('t', 'm', 'e', 'n')\r
65\r
66typedef struct _TERMINAL_CONSOLE_IN_EX_NOTIFY {\r
67 UINTN Signature;\r
68 EFI_HANDLE NotifyHandle;\r
69 EFI_KEY_DATA KeyData;\r
70 EFI_KEY_NOTIFY_FUNCTION KeyNotificationFn;\r
71 LIST_ENTRY NotifyEntry;\r
72} TERMINAL_CONSOLE_IN_EX_NOTIFY;\r
95276127 73typedef struct {\r
74 UINTN Signature;\r
75 EFI_HANDLE Handle;\r
76 UINT8 TerminalType;\r
77 EFI_SERIAL_IO_PROTOCOL *SerialIo;\r
78 EFI_DEVICE_PATH_PROTOCOL *DevicePath;\r
95276127 79 EFI_SIMPLE_TEXT_INPUT_PROTOCOL SimpleInput;\r
80 EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL SimpleTextOutput;\r
81 EFI_SIMPLE_TEXT_OUTPUT_MODE SimpleTextOutputMode;\r
82 UINTN SerialInTimeOut;\r
83 RAW_DATA_FIFO RawFiFo;\r
84 UNICODE_FIFO UnicodeFiFo;\r
85 EFI_KEY_FIFO EfiKeyFiFo;\r
86 EFI_UNICODE_STRING_TABLE *ControllerNameTable;\r
87 EFI_EVENT TwoSecondTimeOut;\r
88 UINT32 InputState;\r
6b88ceec 89 UINT32 ResetState;\r
95276127 90\r
91 //\r
92 // Esc could not be output to the screen by user,\r
93 // but the terminal driver need to output it to\r
94 // the terminal emulation software to send control sequence.\r
95 // This boolean is used by the terminal driver only\r
96 // to indicate whether the Esc could be sent or not.\r
97 //\r
6b88ceec 98 BOOLEAN OutputEscChar;\r
66aa04e4 99 EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL SimpleInputEx;\r
100 LIST_ENTRY NotifyList;\r
95276127 101} TERMINAL_DEV;\r
102\r
103#define INPUT_STATE_DEFAULT 0x00\r
104#define INPUT_STATE_ESC 0x01\r
105#define INPUT_STATE_CSI 0x02\r
106#define INPUT_STATE_LEFTOPENBRACKET 0x04\r
107#define INPUT_STATE_O 0x08\r
108#define INPUT_STATE_2 0x10\r
109\r
110#define RESET_STATE_DEFAULT 0x00\r
111#define RESET_STATE_ESC_R 0x01\r
112#define RESET_STATE_ESC_R_ESC_r 0x02\r
113\r
114#define TERMINAL_CON_IN_DEV_FROM_THIS(a) CR (a, TERMINAL_DEV, SimpleInput, TERMINAL_DEV_SIGNATURE)\r
115#define TERMINAL_CON_OUT_DEV_FROM_THIS(a) CR (a, TERMINAL_DEV, SimpleTextOutput, TERMINAL_DEV_SIGNATURE)\r
66aa04e4 116#define TERMINAL_CON_IN_EX_DEV_FROM_THIS(a) CR (a, TERMINAL_DEV, SimpleInputEx, TERMINAL_DEV_SIGNATURE)\r
95276127 117\r
118typedef union {\r
119 UINT8 Utf8_1;\r
120 UINT8 Utf8_2[2];\r
121 UINT8 Utf8_3[3];\r
122} UTF8_CHAR;\r
123\r
e49ef433 124#define PCANSITYPE 0\r
125#define VT100TYPE 1\r
126#define VT100PLUSTYPE 2\r
127#define VTUTF8TYPE 3\r
95276127 128\r
129#define LEFTOPENBRACKET 0x5b // '['\r
130#define ACAP 0x41\r
131#define BCAP 0x42\r
132#define CCAP 0x43\r
133#define DCAP 0x44\r
134\r
135#define MODE0_COLUMN_COUNT 80\r
136#define MODE0_ROW_COUNT 25\r
137\r
7347d5d6 138#define MODE1_COLUMN_COUNT 80\r
139#define MODE1_ROW_COUNT 50\r
140\r
141#define MODE2_COLUMN_COUNT 100\r
142#define MODE2_ROW_COUNT 31\r
143\r
95276127 144#define BACKSPACE 8\r
145#define ESC 27\r
146#define CSI 0x9B\r
147#define DEL 127\r
148#define BRIGHT_CONTROL_OFFSET 2\r
149#define FOREGROUND_CONTROL_OFFSET 6\r
150#define BACKGROUND_CONTROL_OFFSET 11\r
151#define ROW_OFFSET 2\r
152#define COLUMN_OFFSET 5\r
153\r
154typedef struct {\r
155 UINT16 Unicode;\r
156 CHAR8 PcAnsi;\r
157 CHAR8 Ascii;\r
158} UNICODE_TO_CHAR;\r
159\r
95276127 160//\r
161// Global Variables\r
162//\r
5bca971e 163extern EFI_DRIVER_BINDING_PROTOCOL gTerminalDriverBinding;\r
164extern EFI_COMPONENT_NAME_PROTOCOL gTerminalComponentName;\r
165extern EFI_COMPONENT_NAME2_PROTOCOL gTerminalComponentName2;\r
95276127 166\r
66aa04e4 167extern EFI_GUID gSimpleTextInExNotifyGuid;\r
e49ef433 168\r
169/**\r
170 The user Entry Point for module Terminal. The user code starts with this function.\r
171\r
172 @param[in] ImageHandle The firmware allocated handle for the EFI image.\r
173 @param[in] SystemTable A pointer to the EFI System Table.\r
174\r
175 @retval EFI_SUCCESS The entry point is executed successfully.\r
176 @retval other Some error occurs when executing this entry point.\r
177\r
178**/\r
95276127 179EFI_STATUS\r
180EFIAPI\r
181InitializeTerminal (\r
182 IN EFI_HANDLE ImageHandle,\r
183 IN EFI_SYSTEM_TABLE *SystemTable\r
184 )\r
185;\r
186\r
e49ef433 187/**\r
188 Implements EFI_SIMPLE_TEXT_INPUT_PROTOCOL.Reset().\r
189 This driver only perform dependent serial device reset regardless of\r
190 the value of ExtendeVerification\r
191\r
192 @param This Indicates the calling context.\r
193 @param ExtendedVerification Skip by this driver.\r
194\r
8fd98315 195 @return EFI_SUCCESS The reset operation succeeds.\r
196 @return EFI_DEVICE_ERROR The dependent serial port reset fails.\r
e49ef433 197\r
198**/\r
95276127 199EFI_STATUS\r
200EFIAPI\r
201TerminalConInReset (\r
202 IN EFI_SIMPLE_TEXT_INPUT_PROTOCOL *This,\r
203 IN BOOLEAN ExtendedVerification\r
204 )\r
205;\r
206\r
e49ef433 207\r
208/**\r
209 Implements EFI_SIMPLE_TEXT_INPUT_PROTOCOL.ReadKeyStroke().\r
210\r
8fd98315 211 @param This Indicates the calling context.\r
212 @param Key A pointer to a buffer that is filled in with the\r
213 keystroke information for the key that was sent\r
214 from terminal.\r
215\r
216 @return EFI_SUCCESS The keystroke information is returned successfully.\r
217 @return EFI_NOT_READY There is no keystroke data available.\r
218 @return EFI_DEVICE_ERROR The dependent serial device encounters error.\r
e49ef433 219\r
220**/\r
95276127 221EFI_STATUS\r
222EFIAPI\r
223TerminalConInReadKeyStroke (\r
224 IN EFI_SIMPLE_TEXT_INPUT_PROTOCOL *This,\r
225 OUT EFI_INPUT_KEY *Key\r
226 )\r
227;\r
228\r
e49ef433 229/**\r
8fd98315 230 Check if the key already has been registered.\r
e49ef433 231\r
232 @param RegsiteredData A pointer to a buffer that is filled in with the\r
233 keystroke state data for the key that was\r
234 registered.\r
235 @param InputData A pointer to a buffer that is filled in with the\r
236 keystroke state data for the key that was\r
237 pressed.\r
238\r
239 @retval TRUE Key be pressed matches a registered key.\r
240 @retval FLASE Match failed.\r
241\r
242**/\r
66aa04e4 243BOOLEAN\r
244IsKeyRegistered (\r
245 IN EFI_KEY_DATA *RegsiteredData,\r
246 IN EFI_KEY_DATA *InputData\r
247 )\r
e49ef433 248;\r
66aa04e4 249\r
e49ef433 250/**\r
251 Event notification function for EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL.WaitForKeyEx event\r
252 Signal the event if there is key available\r
66aa04e4 253\r
e49ef433 254 @param Event Indicates the event that invoke this function.\r
255 @param Context Indicates the calling context.\r
fb0b259e 256\r
e49ef433 257 @return none.\r
66aa04e4 258\r
e49ef433 259**/\r
66aa04e4 260VOID\r
261EFIAPI\r
262TerminalConInWaitForKeyEx (\r
263 IN EFI_EVENT Event,\r
264 IN VOID *Context\r
265 )\r
fb0b259e 266;\r
e49ef433 267\r
66aa04e4 268//\r
269// Simple Text Input Ex protocol prototypes\r
270//\r
271\r
e49ef433 272/**\r
273 Reset the input device and optionaly run diagnostics\r
274\r
275 @param This Protocol instance pointer.\r
276 @param ExtendedVerification Driver may perform diagnostics on reset.\r
277\r
278 @retval EFI_SUCCESS The device was reset.\r
279 @retval EFI_DEVICE_ERROR The device is not functioning properly and could\r
280 not be reset.\r
281\r
282**/\r
66aa04e4 283EFI_STATUS\r
284EFIAPI\r
285TerminalConInResetEx (\r
286 IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *This,\r
287 IN BOOLEAN ExtendedVerification\r
288 )\r
e49ef433 289;\r
66aa04e4 290\r
e49ef433 291/**\r
292 Reads the next keystroke from the input device. The WaitForKey Event can\r
293 be used to test for existance of a keystroke via WaitForEvent () call.\r
66aa04e4 294\r
e49ef433 295 @param This Protocol instance pointer.\r
296 @param KeyData A pointer to a buffer that is filled in with the\r
297 keystroke state data for the key that was\r
298 pressed.\r
66aa04e4 299\r
e49ef433 300 @retval EFI_SUCCESS The keystroke information was returned.\r
301 @retval EFI_NOT_READY There was no keystroke data availiable.\r
302 @retval EFI_DEVICE_ERROR The keystroke information was not returned due\r
303 to hardware errors.\r
304 @retval EFI_INVALID_PARAMETER KeyData is NULL.\r
66aa04e4 305\r
e49ef433 306**/\r
66aa04e4 307EFI_STATUS\r
308EFIAPI\r
309TerminalConInReadKeyStrokeEx (\r
310 IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *This,\r
311 OUT EFI_KEY_DATA *KeyData\r
312 )\r
e49ef433 313;\r
66aa04e4 314\r
e49ef433 315/**\r
316 Set certain state for the input device.\r
66aa04e4 317\r
e49ef433 318 @param This Protocol instance pointer.\r
319 @param KeyToggleState A pointer to the EFI_KEY_TOGGLE_STATE to set the\r
320 state for the input device.\r
66aa04e4 321\r
e49ef433 322 @retval EFI_SUCCESS The device state was set successfully.\r
323 @retval EFI_DEVICE_ERROR The device is not functioning correctly and\r
324 could not have the setting adjusted.\r
325 @retval EFI_UNSUPPORTED The device does not have the ability to set its\r
326 state.\r
327 @retval EFI_INVALID_PARAMETER KeyToggleState is NULL.\r
66aa04e4 328\r
e49ef433 329**/\r
66aa04e4 330EFI_STATUS\r
331EFIAPI\r
332TerminalConInSetState (\r
333 IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *This,\r
334 IN EFI_KEY_TOGGLE_STATE *KeyToggleState\r
335 )\r
66aa04e4 336;\r
337\r
e49ef433 338/**\r
339 Register a notification function for a particular keystroke for the input device.\r
340\r
341 @param This Protocol instance pointer.\r
342 @param KeyData A pointer to a buffer that is filled in with the\r
343 keystroke information data for the key that was\r
344 pressed.\r
345 @param KeyNotificationFunction Points to the function to be called when the key\r
346 sequence is typed specified by KeyData.\r
347 @param NotifyHandle Points to the unique handle assigned to the\r
348 registered notification.\r
349\r
350 @retval EFI_SUCCESS The notification function was registered\r
351 successfully.\r
352 @retval EFI_OUT_OF_RESOURCES Unable to allocate resources for necesssary data\r
353 structures.\r
354 @retval EFI_INVALID_PARAMETER KeyData or NotifyHandle is NULL.\r
355\r
356**/\r
66aa04e4 357EFI_STATUS\r
358EFIAPI\r
359TerminalConInRegisterKeyNotify (\r
360 IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *This,\r
361 IN EFI_KEY_DATA *KeyData,\r
362 IN EFI_KEY_NOTIFY_FUNCTION KeyNotificationFunction,\r
363 OUT EFI_HANDLE *NotifyHandle\r
364 )\r
e49ef433 365;\r
66aa04e4 366\r
e49ef433 367/**\r
368 Remove a registered notification function from a particular keystroke.\r
66aa04e4 369\r
e49ef433 370 @param This Protocol instance pointer.\r
371 @param NotificationHandle The handle of the notification function being\r
372 unregistered.\r
fb0b259e 373\r
e49ef433 374 @retval EFI_SUCCESS The notification function was unregistered\r
375 successfully.\r
376 @retval EFI_INVALID_PARAMETER The NotificationHandle is invalid.\r
377 @retval EFI_NOT_FOUND Can not find the matching entry in database.\r
66aa04e4 378\r
e49ef433 379**/\r
66aa04e4 380EFI_STATUS\r
381EFIAPI\r
382TerminalConInUnregisterKeyNotify (\r
383 IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *This,\r
384 IN EFI_HANDLE NotificationHandle\r
385 )\r
e49ef433 386;\r
66aa04e4 387\r
e49ef433 388/**\r
389 Event notification function for EFI_SIMPLE_TEXT_INPUT_PROTOCOL.WaitForKey event\r
390 Signal the event if there is key available\r
66aa04e4 391\r
e49ef433 392 @param Event Indicates the event that invoke this function.\r
393 @param Context Indicates the calling context.\r
fb0b259e 394\r
e49ef433 395 @return None\r
66aa04e4 396\r
e49ef433 397**/\r
95276127 398VOID\r
399EFIAPI\r
400TerminalConInWaitForKey (\r
401 IN EFI_EVENT Event,\r
402 IN VOID *Context\r
403 )\r
404;\r
405\r
e49ef433 406/**\r
407 Implements EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.Reset().\r
408 If ExtendeVerification is TRUE, then perform dependent serial device reset,\r
409 and set display mode to mode 0.\r
410 If ExtendedVerification is FALSE, only set display mode to mode 0.\r
411\r
412 @param This Indicates the calling context.\r
413 @param ExtendedVerification Indicates that the driver may perform a more\r
414 exhaustive verification operation of the device\r
415 during reset.\r
416\r
8fd98315 417 @return EFI_SUCCESS The reset operation succeeds.\r
418 @return EFI_DEVICE_ERROR The terminal is not functioning correctly or the serial port reset fails.\r
e49ef433 419\r
420**/\r
95276127 421EFI_STATUS\r
422EFIAPI\r
423TerminalConOutReset (\r
424 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,\r
425 IN BOOLEAN ExtendedVerification\r
426 )\r
427;\r
428\r
e49ef433 429/**\r
430 Implements EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.OutputString().\r
431 The Unicode string will be converted to terminal expressible data stream\r
432 and send to terminal via serial port.\r
433\r
434 @param This Indicates the calling context.\r
435 @param WString The Null-terminated Unicode string to be displayed\r
436 on the terminal screen.\r
437\r
8fd98315 438 @retval EFI_SUCCESS The string is output successfully.\r
439 @retval EFI_DEVICE_ERROR The serial port fails to send the string out.\r
440 @retval EFI_WARN_UNKNOWN_GLYPH Indicates that some of the characters in the Unicode string could not\r
e49ef433 441 be rendered and are skipped.\r
8fd98315 442 @retval EFI_UNSUPPORTED If current display mode is out of range.\r
e49ef433 443\r
444**/\r
95276127 445EFI_STATUS\r
446EFIAPI\r
447TerminalConOutOutputString (\r
448 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,\r
449 IN CHAR16 *WString\r
450 )\r
451;\r
452\r
e49ef433 453/**\r
454 Implements EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.TestString().\r
455 If one of the characters in the *Wstring is\r
456 neither valid Unicode drawing characters,\r
457 not ASCII code, then this function will return\r
458 EFI_UNSUPPORTED.\r
459\r
460 @param This Indicates the calling context.\r
461 @param WString The Null-terminated Unicode string to be tested.\r
462\r
463 @return EFI_SUCCESS The terminal is capable of rendering the output string.\r
464 @return EFI_UNSUPPORTED Some of the characters in the Unicode string cannot be rendered.\r
465\r
466**/\r
95276127 467EFI_STATUS\r
468EFIAPI\r
469TerminalConOutTestString (\r
470 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,\r
471 IN CHAR16 *WString\r
472 )\r
473;\r
474\r
e49ef433 475/**\r
476 Implements EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.QueryMode().\r
477 It returns information for an available text mode\r
478 that the terminal supports.\r
479 In this driver, we support text mode 80x25 (mode 0),\r
480 80x50 (mode 1), 100x31 (mode 2).\r
481\r
482 @param This Indicates the calling context.\r
483 @param ModeNumber The mode number to return information on.\r
484 @param Columns The returned columns of the requested mode.\r
485 @param Rows The returned rows of the requested mode.\r
486\r
487 @return EFI_SUCCESS The requested mode information is returned.\r
488 @return EFI_UNSUPPORTED The mode number is not valid.\r
489 @return EFI_DEVICE_ERROR\r
490\r
491**/\r
95276127 492EFI_STATUS\r
493EFIAPI\r
494TerminalConOutQueryMode (\r
495 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,\r
496 IN UINTN ModeNumber,\r
497 OUT UINTN *Columns,\r
498 OUT UINTN *Rows\r
499 )\r
500;\r
501\r
e49ef433 502/**\r
503 Implements EFI_SIMPLE_TEXT_OUT.SetMode().\r
504 Set the terminal to a specified display mode.\r
505 In this driver, we only support mode 0.\r
506\r
507 @param This Indicates the calling context.\r
508 @param ModeNumber The text mode to set.\r
509\r
510 @return EFI_SUCCESS The requested text mode is set.\r
511 @return EFI_DEVICE_ERROR The requested text mode cannot be set \r
512 because of serial device error.\r
513 @return EFI_UNSUPPORTED The text mode number is not valid.\r
514\r
515**/\r
95276127 516EFI_STATUS\r
517EFIAPI\r
518TerminalConOutSetMode (\r
519 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,\r
520 IN UINTN ModeNumber\r
521 )\r
522;\r
523\r
e49ef433 524/**\r
525 Implements EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.SetAttribute().\r
526\r
527 @param This Indicates the calling context.\r
528 @param Attribute The attribute to set. Only bit0..6 are valid, all other bits\r
529 are undefined and must be zero.\r
530\r
531 @return EFI_SUCCESS The requested attribute is set.\r
532 @return EFI_DEVICE_ERROR The requested attribute cannot be set due to serial port error.\r
533 @return EFI_UNSUPPORTED The attribute requested is not defined by EFI spec.\r
534\r
535**/\r
95276127 536EFI_STATUS\r
537EFIAPI\r
538TerminalConOutSetAttribute (\r
539 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,\r
540 IN UINTN Attribute\r
541 )\r
542;\r
543\r
e49ef433 544/**\r
545 Implements EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.ClearScreen().\r
546 It clears the ANSI terminal's display to the\r
547 currently selected background color.\r
548\r
549 @param This Indicates the calling context.\r
550\r
551 @return EFI_SUCCESS The operation completed successfully.\r
552 @return EFI_DEVICE_ERROR The terminal screen cannot be cleared due to serial port error.\r
553 @return EFI_UNSUPPORTED The terminal is not in a valid display mode.\r
554\r
555**/\r
95276127 556EFI_STATUS\r
557EFIAPI\r
558TerminalConOutClearScreen (\r
559 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This\r
560 )\r
561;\r
562\r
e49ef433 563/**\r
564 Implements EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.SetCursorPosition().\r
565\r
566 @param This Indicates the calling context.\r
567 @param Column The row to set cursor to.\r
568 @param Row The column to set cursor to.\r
569\r
570 @return EFI_SUCCESS The operation completed successfully.\r
571 @return EFI_DEVICE_ERROR The request fails due to serial port error.\r
572 @return EFI_UNSUPPORTED The terminal is not in a valid text mode, or the cursor position\r
573 is invalid for current mode.\r
574\r
575**/\r
95276127 576EFI_STATUS\r
577EFIAPI\r
578TerminalConOutSetCursorPosition (\r
579 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,\r
580 IN UINTN Column,\r
581 IN UINTN Row\r
582 )\r
583;\r
584\r
e49ef433 585/**\r
586 Implements SIMPLE_TEXT_OUTPUT.EnableCursor().\r
587 In this driver, the cursor cannot be hidden.\r
588\r
589 @param This Indicates the calling context.\r
590 @param Visible If TRUE, the cursor is set to be visible,\r
591 If FALSE, the cursor is set to be invisible.\r
592\r
593 @return EFI_SUCCESS The request is valid.\r
594 @return EFI_UNSUPPORTED The terminal does not support cursor hidden.\r
595\r
596**/\r
95276127 597EFI_STATUS\r
598EFIAPI\r
599TerminalConOutEnableCursor (\r
600 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,\r
601 IN BOOLEAN Visible\r
602 )\r
603;\r
604\r
8fd98315 605/**\r
ab76200c 606 Test to see if this driver supports Controller. \r
8fd98315 607\r
608 @param This Protocol instance pointer.\r
ab76200c 609 @param Controller Handle of device to test\r
8fd98315 610 @param RemainingDevicePath Optional parameter use to pick a specific child\r
611 device to start.\r
612\r
ab76200c 613 @retval EFI_SUCCESS This driver supports this device.\r
614 @retval EFI_ALREADY_STARTED This driver is already running on this device.\r
615 @retval other This driver does not support this device.\r
8fd98315 616\r
617**/\r
95276127 618EFI_STATUS\r
619EFIAPI\r
620TerminalDriverBindingSupported (\r
621 IN EFI_DRIVER_BINDING_PROTOCOL *This,\r
ab76200c 622 IN EFI_HANDLE ControllerHandle,\r
95276127 623 IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath\r
624 );\r
625\r
8fd98315 626/**\r
ab76200c 627 Start this driver on Controller by opening a Serial IO protocol,\r
8fd98315 628 reading Device Path, and creating a child handle with a Simple Text In,\r
629 Simple Text In Ex and Simple Text Out protocol, and device path protocol.\r
630 And store Console Device Environment Variables.\r
631\r
632 @param This Protocol instance pointer.\r
ab76200c 633 @param Controller Handle of device to bind driver to\r
8fd98315 634 @param RemainingDevicePath Optional parameter use to pick a specific child\r
635 device to start.\r
636\r
ab76200c 637 @retval EFI_SUCCESS This driver is added to Controller.\r
638 @retval EFI_ALREADY_STARTED This driver is already running on Controller.\r
639 @retval other This driver does not support this device.\r
8fd98315 640\r
641**/\r
95276127 642EFI_STATUS\r
643EFIAPI\r
644TerminalDriverBindingStart (\r
645 IN EFI_DRIVER_BINDING_PROTOCOL *This,\r
646 IN EFI_HANDLE Controller,\r
647 IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath\r
648 );\r
649\r
ab76200c 650\r
8fd98315 651/**\r
ab76200c 652 Stop this driver on Controller by closing Simple Text In, Simple Text\r
8fd98315 653 In Ex, Simple Text Out protocol, and removing parent device path from\r
654 Console Device Environment Variables. \r
655\r
656 @param This Protocol instance pointer.\r
ab76200c 657 @param Controller Handle of device to stop driver on\r
8fd98315 658 @param NumberOfChildren Number of Handles in ChildHandleBuffer. If number of\r
659 children is zero stop the entire bus driver.\r
660 @param ChildHandleBuffer List of Child Handles to Stop.\r
661\r
ab76200c 662 @retval EFI_SUCCESS This driver is removed Controller.\r
8fd98315 663 @retval other This driver could not be removed from this device.\r
664\r
665**/\r
95276127 666EFI_STATUS\r
667EFIAPI\r
668TerminalDriverBindingStop (\r
669 IN EFI_DRIVER_BINDING_PROTOCOL *This,\r
670 IN EFI_HANDLE Controller,\r
671 IN UINTN NumberOfChildren,\r
672 IN EFI_HANDLE *ChildHandleBuffer\r
673 );\r
674\r
5bca971e 675/**\r
676 Retrieves a Unicode string that is the user readable name of the driver.\r
677\r
678 This function retrieves the user readable name of a driver in the form of a\r
679 Unicode string. If the driver specified by This has a user readable name in\r
680 the language specified by Language, then a pointer to the driver name is\r
681 returned in DriverName, and EFI_SUCCESS is returned. If the driver specified\r
682 by This does not support the language specified by Language,\r
683 then EFI_UNSUPPORTED is returned.\r
684\r
685 @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or\r
686 EFI_COMPONENT_NAME_PROTOCOL instance.\r
687\r
688 @param Language[in] A pointer to a Null-terminated ASCII string\r
689 array indicating the language. This is the\r
690 language of the driver name that the caller is\r
691 requesting, and it must match one of the\r
692 languages specified in SupportedLanguages. The\r
693 number of languages supported by a driver is up\r
694 to the driver writer. Language is specified\r
695 in RFC 3066 or ISO 639-2 language code format.\r
696\r
697 @param DriverName[out] A pointer to the Unicode string to return.\r
698 This Unicode string is the name of the\r
699 driver specified by This in the language\r
700 specified by Language.\r
701\r
702 @retval EFI_SUCCESS The Unicode string for the Driver specified by\r
703 This and the language specified by Language was\r
704 returned in DriverName.\r
705\r
706 @retval EFI_INVALID_PARAMETER Language is NULL.\r
707\r
708 @retval EFI_INVALID_PARAMETER DriverName is NULL.\r
709\r
710 @retval EFI_UNSUPPORTED The driver specified by This does not support\r
711 the language specified by Language.\r
712\r
713**/\r
95276127 714EFI_STATUS\r
715EFIAPI\r
716TerminalComponentNameGetDriverName (\r
717 IN EFI_COMPONENT_NAME_PROTOCOL *This,\r
718 IN CHAR8 *Language,\r
719 OUT CHAR16 **DriverName\r
720 );\r
721\r
5bca971e 722\r
723/**\r
724 Retrieves a Unicode string that is the user readable name of the controller\r
725 that is being managed by a driver.\r
726\r
727 This function retrieves the user readable name of the controller specified by\r
728 ControllerHandle and ChildHandle in the form of a Unicode string. If the\r
729 driver specified by This has a user readable name in the language specified by\r
730 Language, then a pointer to the controller name is returned in ControllerName,\r
731 and EFI_SUCCESS is returned. If the driver specified by This is not currently\r
732 managing the controller specified by ControllerHandle and ChildHandle,\r
733 then EFI_UNSUPPORTED is returned. If the driver specified by This does not\r
734 support the language specified by Language, then EFI_UNSUPPORTED is returned.\r
735\r
736 @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or\r
737 EFI_COMPONENT_NAME_PROTOCOL instance.\r
738\r
739 @param ControllerHandle[in] The handle of a controller that the driver\r
740 specified by This is managing. This handle\r
741 specifies the controller whose name is to be\r
742 returned.\r
743\r
744 @param ChildHandle[in] The handle of the child controller to retrieve\r
745 the name of. This is an optional parameter that\r
746 may be NULL. It will be NULL for device\r
747 drivers. It will also be NULL for a bus drivers\r
748 that wish to retrieve the name of the bus\r
749 controller. It will not be NULL for a bus\r
750 driver that wishes to retrieve the name of a\r
751 child controller.\r
752\r
753 @param Language[in] A pointer to a Null-terminated ASCII string\r
754 array indicating the language. This is the\r
755 language of the driver name that the caller is\r
756 requesting, and it must match one of the\r
757 languages specified in SupportedLanguages. The\r
758 number of languages supported by a driver is up\r
759 to the driver writer. Language is specified in\r
760 RFC 3066 or ISO 639-2 language code format.\r
761\r
762 @param ControllerName[out] A pointer to the Unicode string to return.\r
763 This Unicode string is the name of the\r
764 controller specified by ControllerHandle and\r
765 ChildHandle in the language specified by\r
766 Language from the point of view of the driver\r
767 specified by This.\r
768\r
769 @retval EFI_SUCCESS The Unicode string for the user readable name in\r
770 the language specified by Language for the\r
771 driver specified by This was returned in\r
772 DriverName.\r
773\r
774 @retval EFI_INVALID_PARAMETER ControllerHandle is not a valid EFI_HANDLE.\r
775\r
776 @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid\r
777 EFI_HANDLE.\r
778\r
779 @retval EFI_INVALID_PARAMETER Language is NULL.\r
780\r
781 @retval EFI_INVALID_PARAMETER ControllerName is NULL.\r
782\r
783 @retval EFI_UNSUPPORTED The driver specified by This is not currently\r
784 managing the controller specified by\r
785 ControllerHandle and ChildHandle.\r
786\r
787 @retval EFI_UNSUPPORTED The driver specified by This does not support\r
788 the language specified by Language.\r
789\r
790**/\r
95276127 791EFI_STATUS\r
792EFIAPI\r
793TerminalComponentNameGetControllerName (\r
794 IN EFI_COMPONENT_NAME_PROTOCOL *This,\r
795 IN EFI_HANDLE ControllerHandle,\r
796 IN EFI_HANDLE ChildHandle OPTIONAL,\r
797 IN CHAR8 *Language,\r
798 OUT CHAR16 **ControllerName\r
799 );\r
800\r
5bca971e 801\r
95276127 802//\r
803// internal functions\r
804//\r
e49ef433 805\r
806/**\r
807 Check for a pending key in the Efi Key FIFO or Serial device buffer.\r
808\r
809 @param This Indicates the calling context.\r
810\r
8fd98315 811 @retval EFI_SUCCESS There is key pending.\r
812 @retval EFI_NOT_READY There is no key pending.\r
813 @retval EFI_DEVICE_ERROR If Serial IO is not attched to serial device.\r
e49ef433 814\r
815**/\r
95276127 816EFI_STATUS\r
817TerminalConInCheckForKey (\r
818 IN EFI_SIMPLE_TEXT_INPUT_PROTOCOL *This\r
819 )\r
820;\r
821\r
8fd98315 822/**\r
823 Update terminal device path in Console Device Environment Variables.\r
824\r
825 @param VariableName The Console Device Environment Variable.\r
826 @param ParentDevicePath The terminal devcie path to be updated.\r
827\r
828 @return None.\r
829\r
830**/\r
95276127 831VOID\r
832TerminalUpdateConsoleDevVariable (\r
833 IN CHAR16 *VariableName,\r
834 IN EFI_DEVICE_PATH_PROTOCOL *ParentDevicePath\r
835 )\r
836;\r
837\r
e49ef433 838/**\r
839 Remove console device variable.\r
840\r
841 @param VariableName A pointer to the variable name.\r
842 @param ParentDevicePath A pointer to the parent device path.\r
843\r
844 @return None.\r
845\r
846**/\r
95276127 847VOID\r
848TerminalRemoveConsoleDevVariable (\r
849 IN CHAR16 *VariableName,\r
850 IN EFI_DEVICE_PATH_PROTOCOL *ParentDevicePath\r
851 )\r
852;\r
853\r
e49ef433 854/**\r
855 Read the EFI variable (VendorGuid/Name) and return a dynamically allocated\r
856 buffer, and the size of the buffer. On failure return NULL.\r
857\r
858 @param Name String part of EFI variable name\r
859 @param VendorGuid GUID part of EFI variable name\r
860 @param VariableSize Returns the size of the EFI variable that was read\r
861\r
862 @return Dynamically allocated memory that contains a copy of the EFI variable.\r
ab76200c 863 Caller is repsoncible freeing the buffer. If variable was not read, \r
864 NULL regturned.\r
e49ef433 865\r
866**/\r
95276127 867VOID *\r
868TerminalGetVariableAndSize (\r
869 IN CHAR16 *Name,\r
870 IN EFI_GUID *VendorGuid,\r
871 OUT UINTN *VariableSize\r
872 )\r
873;\r
874\r
8fd98315 875/**\r
876 Build termial device path according to terminal type.\r
877\r
878 @param TerminalType The terminal type is PC ANSI, VT100, VT100+ or VT-UTF8.\r
879 @param ParentDevicePath Parent devcie path.\r
880 @param TerminalDevicePath Returned terminal device path, if building successfully.\r
881\r
882 @retval EFI_UNSUPPORTED Terminal does not belong to the supported type.\r
883 @retval EFI_OUT_OF_RESOURCES Generate terminal device path failed.\r
884 @retval EFI_SUCCESS Build terminal device path successfully.\r
885\r
886**/\r
95276127 887EFI_STATUS\r
888SetTerminalDevicePath (\r
889 IN UINT8 TerminalType,\r
890 IN EFI_DEVICE_PATH_PROTOCOL *ParentDevicePath,\r
891 OUT EFI_DEVICE_PATH_PROTOCOL **TerminalDevicePath\r
892 )\r
893;\r
894\r
8fd98315 895/**\r
896 Initialize the Raw Data FIFO.\r
897\r
898 @param TerminalDevice The terminal device.\r
899\r
900 @return None.\r
901\r
902**/\r
95276127 903VOID\r
904InitializeRawFiFo (\r
905 IN TERMINAL_DEV *TerminalDevice\r
906 )\r
907;\r
908\r
8fd98315 909/**\r
910 Initialize the Unicode FIFO.\r
911\r
912 @param TerminalDevice The terminal device.\r
913\r
914 @return None.\r
915\r
916**/\r
95276127 917VOID\r
918InitializeUnicodeFiFo (\r
919 IN TERMINAL_DEV *TerminalDevice\r
920 )\r
921;\r
922\r
8fd98315 923/**\r
924 Initialize the EFI Key FIFO.\r
925\r
926 @param TerminalDevice The terminal device.\r
927\r
928 @return None.\r
929\r
930**/\r
95276127 931VOID\r
932InitializeEfiKeyFiFo (\r
933 IN TERMINAL_DEV *TerminalDevice\r
934 )\r
935;\r
936\r
e49ef433 937/**\r
938 Get one key out of serial buffer.\r
939\r
940 @param SerialIo Serial I/O protocl attached to the serial device.\r
941 @param Input The fetched key.\r
942\r
943 @return EFI_NOT_READY If serial buffer is empty.\r
944 @return EFI_DEVICE_ERROR If reading serial buffer encounter error.\r
945 @return EFI_SUCCESS If reading serial buffer successfully, put\r
946 the fetched key to the parameter output.\r
947\r
948**/\r
95276127 949EFI_STATUS\r
950GetOneKeyFromSerial (\r
951 EFI_SERIAL_IO_PROTOCOL *SerialIo,\r
952 UINT8 *Input\r
953 )\r
954;\r
955\r
e49ef433 956/**\r
957 Insert one byte raw data into the Raw Data FIFO.\r
958\r
959 @param TerminalDevice Terminal driver private structure.\r
960 @param Input The key will be input.\r
961\r
962 @return TRUE If insert successfully.\r
963 @return FLASE If Raw Data buffer is full before key insertion,\r
964 and the key is lost.\r
965\r
966**/\r
95276127 967BOOLEAN\r
968RawFiFoInsertOneKey (\r
969 TERMINAL_DEV *TerminalDevice,\r
970 UINT8 Input\r
971 )\r
972;\r
973\r
e49ef433 974/**\r
975 Remove one pre-fetched key out of the Raw Data FIFO.\r
976\r
977 @param TerminalDevice Terminal driver private structure.\r
978 @param Output The key will be removed.\r
979\r
980 @return TRUE If insert successfully.\r
981 @return FLASE If Raw Data FIFO buffer is empty before remove operation.\r
982\r
983**/\r
95276127 984BOOLEAN\r
985RawFiFoRemoveOneKey (\r
986 TERMINAL_DEV *TerminalDevice,\r
987 UINT8 *Output\r
988 )\r
989;\r
990\r
e49ef433 991/**\r
992 Clarify whether Raw Data FIFO buffer is empty.\r
993\r
994 @param TerminalDevice Terminal driver private structure\r
995\r
996 @return TRUE If Raw Data FIFO buffer is empty.\r
997 @return FLASE If Raw Data FIFO buffer is not empty.\r
998\r
999**/\r
95276127 1000BOOLEAN\r
1001IsRawFiFoEmpty (\r
1002 TERMINAL_DEV *TerminalDevice\r
1003 )\r
1004;\r
1005\r
e49ef433 1006/**\r
1007 Clarify whether Raw Data FIFO buffer is full.\r
1008\r
1009 @param TerminalDevice Terminal driver private structure\r
1010\r
1011 @return TRUE If Raw Data FIFO buffer is full.\r
1012 @return FLASE If Raw Data FIFO buffer is not full.\r
1013\r
1014**/\r
95276127 1015BOOLEAN\r
1016IsRawFiFoFull (\r
1017 TERMINAL_DEV *TerminalDevice\r
1018 )\r
1019;\r
1020\r
e49ef433 1021/**\r
1022 Insert one pre-fetched key into the FIFO buffer.\r
1023\r
1024 @param TerminalDevice Terminal driver private structure.\r
1025 @param Key The key will be input.\r
1026\r
1027 @return TRUE If insert successfully.\r
1028 @return FLASE If FIFO buffer is full before key insertion,\r
1029 and the key is lost.\r
1030\r
1031**/\r
95276127 1032BOOLEAN\r
1033EfiKeyFiFoInsertOneKey (\r
1034 TERMINAL_DEV *TerminalDevice,\r
1035 EFI_INPUT_KEY Key\r
1036 )\r
1037;\r
1038\r
e49ef433 1039/**\r
1040 Remove one pre-fetched key out of the FIFO buffer.\r
1041\r
1042 @param TerminalDevice Terminal driver private structure.\r
1043 @param Output The key will be removed.\r
1044\r
1045 @return TRUE If insert successfully.\r
1046 @return FLASE If FIFO buffer is empty before remove operation.\r
1047\r
1048**/\r
95276127 1049BOOLEAN\r
1050EfiKeyFiFoRemoveOneKey (\r
1051 TERMINAL_DEV *TerminalDevice,\r
1052 EFI_INPUT_KEY *Output\r
1053 )\r
1054;\r
1055\r
e49ef433 1056/**\r
1057 Clarify whether FIFO buffer is empty.\r
1058\r
1059 @param TerminalDevice Terminal driver private structure\r
1060\r
1061 @return TRUE If FIFO buffer is empty.\r
1062 @return FLASE If FIFO buffer is not empty.\r
1063\r
1064**/\r
95276127 1065BOOLEAN\r
1066IsEfiKeyFiFoEmpty (\r
1067 TERMINAL_DEV *TerminalDevice\r
1068 )\r
1069;\r
1070\r
e49ef433 1071/**\r
1072 Clarify whether FIFO buffer is full.\r
1073\r
1074 @param TerminalDevice Terminal driver private structure\r
1075\r
1076 @return TRUE If FIFO buffer is full.\r
1077 @return FLASE If FIFO buffer is not full.\r
1078\r
1079**/\r
95276127 1080BOOLEAN\r
1081IsEfiKeyFiFoFull (\r
1082 TERMINAL_DEV *TerminalDevice\r
1083 )\r
1084;\r
1085\r
e49ef433 1086/**\r
1087 Insert one pre-fetched key into the Unicode FIFO buffer.\r
1088\r
1089 @param TerminalDevice Terminal driver private structure.\r
1090 @param Input The key will be input.\r
1091\r
1092 @return TRUE If insert successfully.\r
1093 @return FLASE If Unicode FIFO buffer is full before key insertion,\r
1094 and the key is lost.\r
1095\r
1096**/\r
95276127 1097BOOLEAN\r
1098UnicodeFiFoInsertOneKey (\r
1099 TERMINAL_DEV *TerminalDevice,\r
1100 UINT16 Input\r
1101 )\r
1102;\r
1103\r
e49ef433 1104/**\r
1105 Remove one pre-fetched key out of the Unicode FIFO buffer.\r
1106\r
1107 @param TerminalDevice Terminal driver private structure.\r
1108 @param Output The key will be removed.\r
1109\r
1110 @return TRUE If insert successfully.\r
1111 @return FLASE If Unicode FIFO buffer is empty before remove operation.\r
1112\r
1113**/\r
95276127 1114BOOLEAN\r
1115UnicodeFiFoRemoveOneKey (\r
1116 TERMINAL_DEV *TerminalDevice,\r
1117 UINT16 *Output\r
1118 )\r
1119;\r
1120\r
e49ef433 1121/**\r
1122 Clarify whether Unicode FIFO buffer is empty.\r
1123\r
1124 @param TerminalDevice Terminal driver private structure\r
1125\r
1126 @return TRUE If Unicode FIFO buffer is empty.\r
1127 @return FLASE If Unicode FIFO buffer is not empty.\r
1128\r
1129**/\r
95276127 1130BOOLEAN\r
1131IsUnicodeFiFoEmpty (\r
1132 TERMINAL_DEV *TerminalDevice\r
1133 )\r
1134;\r
1135\r
e49ef433 1136/**\r
1137 Clarify whether Unicode FIFO buffer is full.\r
1138\r
1139 @param TerminalDevice Terminal driver private structure\r
1140\r
1141 @return TRUE If Unicode FIFO buffer is full.\r
1142 @return FLASE If Unicode FIFO buffer is not full.\r
1143\r
1144**/\r
95276127 1145BOOLEAN\r
1146IsUnicodeFiFoFull (\r
1147 TERMINAL_DEV *TerminalDevice\r
1148 )\r
1149;\r
1150\r
8fd98315 1151/**\r
1152 Count Unicode FIFO buffer.\r
1153\r
1154 @param TerminalDevice Terminal driver private structure\r
1155\r
1156 @return The count in bytes of Unicode FIFO.\r
1157\r
1158**/\r
95276127 1159UINT8\r
1160UnicodeFiFoGetKeyCount (\r
1161 TERMINAL_DEV *TerminalDevice\r
1162 )\r
1163;\r
1164\r
8fd98315 1165/**\r
1166 Translate raw data into Unicode (according to different encode), and \r
1167 translate Unicode into key information. (according to different standard). \r
1168\r
1169 @param TerminalDevice Terminal driver private structure.\r
1170\r
1171 @return none.\r
1172\r
1173**/\r
95276127 1174VOID\r
1175TranslateRawDataToEfiKey (\r
1176 IN TERMINAL_DEV *TerminalDevice\r
1177 )\r
1178;\r
1179\r
1180//\r
1181// internal functions for PC ANSI\r
1182//\r
8fd98315 1183\r
1184/**\r
1185 Translate all raw data in the Raw FIFI into unicode, and insert\r
1186 them into Unicode FIFO.\r
1187\r
1188 @param TerminalDevice The terminal device.\r
1189\r
1190 @return None.\r
1191\r
1192**/\r
95276127 1193VOID\r
1194AnsiRawDataToUnicode (\r
8fd98315 1195 IN TERMINAL_DEV *TerminalDevice\r
95276127 1196 )\r
1197;\r
1198\r
8fd98315 1199/**\r
1200 Converts a stream of Unicode characters from a terminal input device into EFI Keys that\r
1201 can be read through the Simple Input Protocol. \r
1202 \r
1203 The table below shows the keyboard input mappings that this function supports.\r
1204 If the ESC sequence listed in one of the columns is presented, then it is translated\r
1205 into the coorespoding EFI Scan Code. If a matching sequence is not found, then the raw\r
1206 key strokes are converted into EFI Keys.\r
1207\r
1208 2 seconds are allowed for an ESC sequence to be completed. If the ESC sequence is not\r
1209 completed in 2 seconds, then the raw key strokes of the partial ESC sequence are\r
1210 converted into EFI Keys.\r
1211 There is one special input sequence that will force the system to reset.\r
1212 This is ESC R ESC r ESC R.\r
1213\r
1214 Symbols used in table below\r
1215 ===========================\r
1216 ESC = 0x1B\r
1217 CSI = 0x9B\r
1218 DEL = 0x7f\r
1219 ^ = CTRL\r
1220 +=========+======+===========+==========+==========+\r
1221 | | EFI | UEFI 2.0 | | |\r
1222 | | Scan | | VT100+ | |\r
1223 | KEY | Code | PC ANSI | VTUTF8 | VT100 |\r
1224 +=========+======+===========+==========+==========+\r
1225 | NULL | 0x00 | | | |\r
1226 | UP | 0x01 | ESC [ A | ESC [ A | ESC [ A |\r
1227 | DOWN | 0x02 | ESC [ B | ESC [ B | ESC [ B |\r
1228 | RIGHT | 0x03 | ESC [ C | ESC [ C | ESC [ C |\r
1229 | LEFT | 0x04 | ESC [ D | ESC [ D | ESC [ D |\r
1230 | HOME | 0x05 | ESC [ H | ESC h | ESC [ H |\r
1231 | END | 0x06 | ESC [ F | ESC k | ESC [ K |\r
1232 | INSERT | 0x07 | ESC [ @ | ESC + | ESC [ @ |\r
1233 | | | ESC [ L | | ESC [ L |\r
1234 | DELETE | 0x08 | ESC [ X | ESC - | ESC [ P |\r
1235 | PG UP | 0x09 | ESC [ I | ESC ? | ESC [ V |\r
1236 | | | | | ESC [ ? |\r
1237 | PG DOWN | 0x0A | ESC [ G | ESC / | ESC [ U |\r
1238 | | | | | ESC [ / |\r
1239 | F1 | 0x0B | ESC [ M | ESC 1 | ESC O P |\r
1240 | F2 | 0x0C | ESC [ N | ESC 2 | ESC O Q |\r
1241 | F3 | 0x0D | ESC [ O | ESC 3 | ESC O w |\r
1242 | F4 | 0x0E | ESC [ P | ESC 4 | ESC O x |\r
1243 | F5 | 0x0F | ESC [ Q | ESC 5 | ESC O t |\r
1244 | F6 | 0x10 | ESC [ R | ESC 6 | ESC O u |\r
1245 | F7 | 0x11 | ESC [ S | ESC 7 | ESC O q |\r
1246 | F8 | 0x12 | ESC [ T | ESC 8 | ESC O r |\r
1247 | F9 | 0x13 | ESC [ U | ESC 9 | ESC O p |\r
1248 | F10 | 0x14 | ESC [ V | ESC 0 | ESC O M |\r
1249 | Escape | 0x17 | ESC | ESC | ESC |\r
1250 | F11 | 0x15 | | ESC ! | |\r
1251 | F12 | 0x16 | | ESC @ | |\r
1252 +=========+======+===========+==========+==========+\r
1253 \r
1254 Special Mappings\r
1255 ================\r
1256 ESC R ESC r ESC R = Reset System\r
1257\r
1258\r
1259 @param TerminalDevice The terminal device to use to translate raw input into EFI Keys\r
1260\r
1261 @return None.\r
1262\r
1263**/\r
95276127 1264VOID\r
1265UnicodeToEfiKey (\r
ab76200c 1266 IN TERMINAL_DEV *TerminalDevice\r
95276127 1267 )\r
1268;\r
1269\r
8fd98315 1270/**\r
1271 Check if input string is valid Ascii string, valid EFI control characters\r
1272 or valid text graphics.\r
1273\r
1274 @param TerminalDevice The terminal device.\r
1275 @param WString The input string. \r
1276 \r
1277 @retval EFI_UNSUPPORTED If not all input characters are valid.\r
1278 @retval EFI_SUCCESS If all input characters are valid.\r
1279\r
1280**/\r
95276127 1281EFI_STATUS\r
1282AnsiTestString (\r
1283 IN TERMINAL_DEV *TerminalDevice,\r
95276127 1284 IN CHAR16 *WString\r
1285 )\r
1286;\r
1287\r
1288//\r
1289// internal functions for VTUTF8\r
1290//\r
8fd98315 1291\r
1292/**\r
1293 Translate all VT-UTF8 characters in the Raw FIFI into unicode characters, \r
1294 and insert them into Unicode FIFO.\r
1295\r
1296 @param VtUtf8Device The terminal device.\r
1297\r
1298 @return None.\r
1299\r
1300**/\r
95276127 1301VOID\r
1302VTUTF8RawDataToUnicode (\r
1303 IN TERMINAL_DEV *VtUtf8Device\r
1304 )\r
1305;\r
1306\r
8fd98315 1307/**\r
1308 Check if input string is valid VT-UTF8 string.\r
1309\r
1310 @param TerminalDevice The terminal device.\r
1311 @param WString The input string. \r
1312 \r
1313 @retval EFI_SUCCESS If all input characters are valid.\r
1314\r
1315**/\r
95276127 1316EFI_STATUS\r
1317VTUTF8TestString (\r
1318 IN TERMINAL_DEV *TerminalDevice,\r
1319 IN CHAR16 *WString\r
1320 )\r
1321;\r
1322\r
8fd98315 1323/** \r
1324 Translate one Unicode character into VT-UTF8 characters.\r
1325\r
1326 UTF8 Encoding Table\r
1327 Bits per Character | Unicode Character Range | Unicode Binary Encoding | UTF8 Binary Encoding\r
1328 0-7 | 0x0000 - 0x007F | 00000000 0xxxxxxx | 0xxxxxxx\r
1329 8-11 | 0x0080 - 0x07FF | 00000xxx xxxxxxxx | 110xxxxx 10xxxxxx\r
1330 12-16 | 0x0800 - 0xFFFF | xxxxxxxx xxxxxxxx | 1110xxxx 10xxxxxx 10xxxxxx\r
1331\r
1332\r
1333 @param Unicode Unicode character need translating.\r
1334 @param Utf8Char Return VT-UTF8 character set.\r
1335 @param ValidBytes The count of valid VT-UTF8 characters. If\r
1336 ValidBytes is zero, no valid VT-UTF8 returned.\r
1337 \r
1338 @return None.\r
1339\r
1340**/\r
95276127 1341VOID\r
1342UnicodeToUtf8 (\r
1343 IN CHAR16 Unicode,\r
1344 OUT UTF8_CHAR *Utf8Char,\r
1345 OUT UINT8 *ValidBytes\r
1346 )\r
1347;\r
1348\r
8fd98315 1349/**\r
1350 Get one valid VT-UTF8 characters set from Raw Data FIFO.\r
1351\r
1352 @param Utf8Device The terminal device.\r
1353 @param Utf8Char Returned valid VT-UTF8 characters set.\r
1354 @param ValidBytes The count of returned VT-VTF8 characters. \r
1355 If ValidBytes is zero, no valid VT-UTF8 returned.\r
1356\r
1357 @retval None.\r
1358\r
1359**/\r
95276127 1360VOID\r
1361GetOneValidUtf8Char (\r
1362 IN TERMINAL_DEV *Utf8Device,\r
1363 OUT UTF8_CHAR *Utf8Char,\r
1364 OUT UINT8 *ValidBytes\r
1365 )\r
1366;\r
1367\r
8fd98315 1368/** \r
1369 Translate VT-UTF8 characters into one Unicode character.\r
1370\r
1371 UTF8 Encoding Table\r
1372 Bits per Character | Unicode Character Range | Unicode Binary Encoding | UTF8 Binary Encoding\r
1373 0-7 | 0x0000 - 0x007F | 00000000 0xxxxxxx | 0xxxxxxx\r
1374 8-11 | 0x0080 - 0x07FF | 00000xxx xxxxxxxx | 110xxxxx 10xxxxxx\r
1375 12-16 | 0x0800 - 0xFFFF | xxxxxxxx xxxxxxxx | 1110xxxx 10xxxxxx 10xxxxxx\r
1376\r
1377\r
1378 @param Utf8Char VT-UTF8 character set needs translating.\r
1379 @param ValidBytes The count of valid VT-UTF8 characters.\r
1380 @param UnicodeChar Returned unicode character. \r
1381 \r
1382 @return None.\r
1383\r
1384**/\r
95276127 1385VOID\r
1386Utf8ToUnicode (\r
1387 IN UTF8_CHAR Utf8Char,\r
1388 IN UINT8 ValidBytes,\r
1389 OUT CHAR16 *UnicodeChar\r
1390 )\r
1391;\r
1392\r
1393//\r
1394// functions for boxdraw unicode\r
1395//\r
8fd98315 1396\r
1397/**\r
1398 Detects if a Unicode char is for Box Drawing text graphics.\r
1399\r
1400 @param Graphic Unicode char to test.\r
1401 @param PcAnsi Optional pointer to return PCANSI equivalent of\r
1402 Graphic.\r
1403 @param Ascii Optional pointer to return ASCII equivalent of\r
1404 Graphic.\r
1405\r
1406 @return TRUE If Graphic is a supported Unicode Box Drawing character.\r
1407\r
1408**/\r
95276127 1409BOOLEAN\r
1410TerminalIsValidTextGraphics (\r
1411 IN CHAR16 Graphic,\r
1412 OUT CHAR8 *PcAnsi, OPTIONAL\r
1413 OUT CHAR8 *Ascii OPTIONAL\r
1414 )\r
1415;\r
1416\r
8fd98315 1417/**\r
1418 Detects if a valid ASCII char.\r
1419\r
1420 @param Ascii An ASCII character.\r
1421 \r
1422 @retval TRUE If it is a valid ASCII character.\r
1423 @retval FALSE If it is not a valid ASCII character.\r
1424\r
1425**/\r
95276127 1426BOOLEAN\r
1427TerminalIsValidAscii (\r
1428 IN CHAR16 Ascii\r
1429 )\r
1430;\r
1431\r
8fd98315 1432/**\r
1433 Detects if a valid EFI control character.\r
1434\r
1435 @param CharC An input EFI Control character.\r
1436 \r
1437 @retval TRUE If it is a valid EFI control character.\r
1438 @retval FALSE If it is not a valid EFI control character.\r
1439\r
1440**/\r
95276127 1441BOOLEAN\r
1442TerminalIsValidEfiCntlChar (\r
1443 IN CHAR16 CharC\r
1444 )\r
1445;\r
1446\r
1447#endif\r