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