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