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