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