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