]> git.proxmox.com Git - mirror_edk2.git/blame_incremental - MdeModulePkg/Universal/Console/TerminalDxe/Terminal.h
MdeModulePkg/TerminalDxe: Add TerminalTypeFromGuid internal function
[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 - 2017, 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
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
93typedef struct {\r
94 UINTN Signature;\r
95 EFI_HANDLE Handle;\r
96 TERMINAL_TYPE TerminalType;\r
97 EFI_SERIAL_IO_PROTOCOL *SerialIo;\r
98 EFI_DEVICE_PATH_PROTOCOL *DevicePath;\r
99 EFI_SIMPLE_TEXT_INPUT_PROTOCOL SimpleInput;\r
100 EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL SimpleTextOutput;\r
101 EFI_SIMPLE_TEXT_OUTPUT_MODE SimpleTextOutputMode;\r
102 TERMINAL_CONSOLE_MODE_DATA *TerminalConsoleModeData;\r
103 UINTN SerialInTimeOut;\r
104 RAW_DATA_FIFO *RawFiFo;\r
105 UNICODE_FIFO *UnicodeFiFo;\r
106 EFI_KEY_FIFO *EfiKeyFiFo;\r
107 EFI_KEY_FIFO *EfiKeyFiFoForNotify;\r
108 EFI_UNICODE_STRING_TABLE *ControllerNameTable;\r
109 EFI_EVENT TimerEvent;\r
110 EFI_EVENT TwoSecondTimeOut;\r
111 UINT32 InputState;\r
112 UINT32 ResetState;\r
113 UINT16 TtyEscapeStr[3];\r
114 INTN TtyEscapeIndex;\r
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
123 BOOLEAN OutputEscChar;\r
124 EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL SimpleInputEx;\r
125 LIST_ENTRY NotifyList;\r
126 EFI_EVENT KeyNotifyProcessEvent;\r
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
135#define INPUT_STATE_LEFTOPENBRACKET_2 0x20\r
136\r
137#define RESET_STATE_DEFAULT 0x00\r
138#define RESET_STATE_ESC_R 0x01\r
139#define RESET_STATE_ESC_R_ESC_R 0x02\r
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
143#define TERMINAL_CON_IN_EX_DEV_FROM_THIS(a) CR (a, TERMINAL_DEV, SimpleInputEx, TERMINAL_DEV_SIGNATURE)\r
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
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
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
166#define FW_BACK_OFFSET 2\r
167\r
168typedef struct {\r
169 UINT16 Unicode;\r
170 CHAR8 PcAnsi;\r
171 CHAR8 Ascii;\r
172} UNICODE_TO_CHAR;\r
173\r
174//\r
175// Global Variables\r
176//\r
177extern EFI_DRIVER_BINDING_PROTOCOL gTerminalDriverBinding;\r
178extern EFI_COMPONENT_NAME_PROTOCOL gTerminalComponentName;\r
179extern EFI_COMPONENT_NAME2_PROTOCOL gTerminalComponentName2;\r
180\r
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
191EFI_STATUS\r
192EFIAPI\r
193InitializeTerminal (\r
194 IN EFI_HANDLE ImageHandle,\r
195 IN EFI_SYSTEM_TABLE *SystemTable\r
196 );\r
197\r
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
206 @retval EFI_SUCCESS The reset operation succeeds.\r
207 @retval EFI_DEVICE_ERROR The dependent serial port reset fails.\r
208\r
209**/\r
210EFI_STATUS\r
211EFIAPI\r
212TerminalConInReset (\r
213 IN EFI_SIMPLE_TEXT_INPUT_PROTOCOL *This,\r
214 IN BOOLEAN ExtendedVerification\r
215 );\r
216\r
217\r
218/**\r
219 Implements EFI_SIMPLE_TEXT_INPUT_PROTOCOL.ReadKeyStroke().\r
220\r
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
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
229\r
230**/\r
231EFI_STATUS\r
232EFIAPI\r
233TerminalConInReadKeyStroke (\r
234 IN EFI_SIMPLE_TEXT_INPUT_PROTOCOL *This,\r
235 OUT EFI_INPUT_KEY *Key\r
236 );\r
237\r
238/**\r
239 Check if the key already has been registered.\r
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
249 @retval FALSE Match failed.\r
250\r
251**/\r
252BOOLEAN\r
253IsKeyRegistered (\r
254 IN EFI_KEY_DATA *RegsiteredData,\r
255 IN EFI_KEY_DATA *InputData\r
256 );\r
257\r
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
261\r
262 @param Event Indicates the event that invoke this function.\r
263 @param Context Indicates the calling context.\r
264\r
265**/\r
266VOID\r
267EFIAPI\r
268TerminalConInWaitForKeyEx (\r
269 IN EFI_EVENT Event,\r
270 IN VOID *Context\r
271 );\r
272\r
273//\r
274// Simple Text Input Ex protocol prototypes\r
275//\r
276\r
277/**\r
278 Reset the input device and optionally run diagnostics\r
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
288EFI_STATUS\r
289EFIAPI\r
290TerminalConInResetEx (\r
291 IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *This,\r
292 IN BOOLEAN ExtendedVerification\r
293 );\r
294\r
295/**\r
296 Reads the next keystroke from the input device. The WaitForKey Event can\r
297 be used to test for existence of a keystroke via WaitForEvent () call.\r
298\r
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
303\r
304 @retval EFI_SUCCESS The keystroke information was returned.\r
305 @retval EFI_NOT_READY There was no keystroke data available.\r
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
309\r
310**/\r
311EFI_STATUS\r
312EFIAPI\r
313TerminalConInReadKeyStrokeEx (\r
314 IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *This,\r
315 OUT EFI_KEY_DATA *KeyData\r
316 );\r
317\r
318/**\r
319 Set certain state for the input device.\r
320\r
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
324\r
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
331\r
332**/\r
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
338 );\r
339\r
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
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
365 OUT VOID **NotifyHandle\r
366 );\r
367\r
368/**\r
369 Remove a registered notification function from a particular keystroke.\r
370\r
371 @param This Protocol instance pointer.\r
372 @param NotificationHandle The handle of the notification function being\r
373 unregistered.\r
374\r
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
379\r
380**/\r
381EFI_STATUS\r
382EFIAPI\r
383TerminalConInUnregisterKeyNotify (\r
384 IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *This,\r
385 IN VOID *NotificationHandle\r
386 );\r
387\r
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
391\r
392 @param Event Indicates the event that invoke this function.\r
393 @param Context Indicates the calling context.\r
394\r
395**/\r
396VOID\r
397EFIAPI\r
398TerminalConInWaitForKey (\r
399 IN EFI_EVENT Event,\r
400 IN VOID *Context\r
401 );\r
402\r
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
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
416\r
417**/\r
418EFI_STATUS\r
419EFIAPI\r
420TerminalConOutReset (\r
421 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,\r
422 IN BOOLEAN ExtendedVerification\r
423 );\r
424\r
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
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
437 be rendered and are skipped.\r
438 @retval EFI_UNSUPPORTED If current display mode is out of range.\r
439\r
440**/\r
441EFI_STATUS\r
442EFIAPI\r
443TerminalConOutOutputString (\r
444 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,\r
445 IN CHAR16 *WString\r
446 );\r
447\r
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
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
460\r
461**/\r
462EFI_STATUS\r
463EFIAPI\r
464TerminalConOutTestString (\r
465 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,\r
466 IN CHAR16 *WString\r
467 );\r
468\r
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
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
484\r
485**/\r
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
493 );\r
494\r
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
503 @retval EFI_SUCCESS The requested text mode is set.\r
504 @retval EFI_DEVICE_ERROR The requested text mode cannot be set\r
505 because of serial device error.\r
506 @retval EFI_UNSUPPORTED The text mode number is not valid.\r
507\r
508**/\r
509EFI_STATUS\r
510EFIAPI\r
511TerminalConOutSetMode (\r
512 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,\r
513 IN UINTN ModeNumber\r
514 );\r
515\r
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
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
526\r
527**/\r
528EFI_STATUS\r
529EFIAPI\r
530TerminalConOutSetAttribute (\r
531 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,\r
532 IN UINTN Attribute\r
533 );\r
534\r
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
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
545\r
546**/\r
547EFI_STATUS\r
548EFIAPI\r
549TerminalConOutClearScreen (\r
550 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This\r
551 );\r
552\r
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
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
563 is invalid for current mode.\r
564\r
565**/\r
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
572 );\r
573\r
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
582 @retval EFI_SUCCESS The request is valid.\r
583 @retval EFI_UNSUPPORTED The terminal does not support cursor hidden.\r
584\r
585**/\r
586EFI_STATUS\r
587EFIAPI\r
588TerminalConOutEnableCursor (\r
589 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,\r
590 IN BOOLEAN Visible\r
591 );\r
592\r
593/**\r
594 Test to see if this driver supports Controller.\r
595\r
596 @param This Protocol instance pointer.\r
597 @param ControllerHandle Handle of device to test\r
598 @param RemainingDevicePath Optional parameter use to pick a specific child\r
599 device to start.\r
600\r
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
604\r
605**/\r
606EFI_STATUS\r
607EFIAPI\r
608TerminalDriverBindingSupported (\r
609 IN EFI_DRIVER_BINDING_PROTOCOL *This,\r
610 IN EFI_HANDLE ControllerHandle,\r
611 IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath\r
612 );\r
613\r
614/**\r
615 Start this driver on Controller by opening a Serial IO protocol,\r
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
621 @param Controller Handle of device to bind driver to\r
622 @param RemainingDevicePath Optional parameter use to pick a specific child\r
623 device to start.\r
624\r
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
628\r
629**/\r
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
638\r
639/**\r
640 Stop this driver on Controller by closing Simple Text In, Simple Text\r
641 In Ex, Simple Text Out protocol, and removing parent device path from\r
642 Console Device Environment Variables.\r
643\r
644 @param This Protocol instance pointer.\r
645 @param Controller Handle of device to stop driver on\r
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
650 @retval EFI_SUCCESS This driver is removed Controller.\r
651 @retval other This driver could not be removed from this device.\r
652\r
653**/\r
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
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
674 IN OUT LIST_ENTRY *ListHead\r
675 );\r
676\r
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
697 in RFC 4646 or ISO 639-2 language code format.\r
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
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
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
762 RFC 4646 or ISO 639-2 language code format.\r
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
776 @retval EFI_INVALID_PARAMETER ControllerHandle is NULL.\r
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
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
803\r
804//\r
805// internal functions\r
806//\r
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
813 @retval EFI_SUCCESS There is key pending.\r
814 @retval EFI_NOT_READY There is no key pending.\r
815 @retval EFI_DEVICE_ERROR If Serial IO is not attached to serial device.\r
816\r
817**/\r
818EFI_STATUS\r
819TerminalConInCheckForKey (\r
820 IN EFI_SIMPLE_TEXT_INPUT_PROTOCOL *This\r
821 );\r
822\r
823/**\r
824 Update terminal device path in Console Device Environment Variables.\r
825\r
826 @param VariableName The Console Device Environment Variable.\r
827 @param ParentDevicePath The terminal device path to be updated.\r
828\r
829 @return None.\r
830\r
831**/\r
832VOID\r
833TerminalUpdateConsoleDevVariable (\r
834 IN CHAR16 *VariableName,\r
835 IN EFI_DEVICE_PATH_PROTOCOL *ParentDevicePath\r
836 );\r
837\r
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
844**/\r
845VOID\r
846TerminalRemoveConsoleDevVariable (\r
847 IN CHAR16 *VariableName,\r
848 IN EFI_DEVICE_PATH_PROTOCOL *ParentDevicePath\r
849 );\r
850\r
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
855 @param ParentDevicePath Parent device path.\r
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
863EFI_STATUS\r
864SetTerminalDevicePath (\r
865 IN TERMINAL_TYPE TerminalType,\r
866 IN EFI_DEVICE_PATH_PROTOCOL *ParentDevicePath,\r
867 OUT EFI_DEVICE_PATH_PROTOCOL **TerminalDevicePath\r
868 );\r
869\r
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
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
879 the fetched key to the parameter output.\r
880\r
881**/\r
882EFI_STATUS\r
883GetOneKeyFromSerial (\r
884 EFI_SERIAL_IO_PROTOCOL *SerialIo,\r
885 UINT8 *Input\r
886 );\r
887\r
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
894 @retval TRUE If insert successfully.\r
895 @retval FALSE If Raw Data buffer is full before key insertion,\r
896 and the key is lost.\r
897\r
898**/\r
899BOOLEAN\r
900RawFiFoInsertOneKey (\r
901 TERMINAL_DEV *TerminalDevice,\r
902 UINT8 Input\r
903 );\r
904\r
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
911 @retval TRUE If insert successfully.\r
912 @retval FALSE If Raw Data FIFO buffer is empty before remove operation.\r
913\r
914**/\r
915BOOLEAN\r
916RawFiFoRemoveOneKey (\r
917 TERMINAL_DEV *TerminalDevice,\r
918 UINT8 *Output\r
919 );\r
920\r
921/**\r
922 Clarify whether Raw Data FIFO buffer is empty.\r
923\r
924 @param TerminalDevice Terminal driver private structure\r
925\r
926 @retval TRUE If Raw Data FIFO buffer is empty.\r
927 @retval FALSE If Raw Data FIFO buffer is not empty.\r
928\r
929**/\r
930BOOLEAN\r
931IsRawFiFoEmpty (\r
932 TERMINAL_DEV *TerminalDevice\r
933 );\r
934\r
935/**\r
936 Clarify whether Raw Data FIFO buffer is full.\r
937\r
938 @param TerminalDevice Terminal driver private structure\r
939\r
940 @retval TRUE If Raw Data FIFO buffer is full.\r
941 @retval FALSE If Raw Data FIFO buffer is not full.\r
942\r
943**/\r
944BOOLEAN\r
945IsRawFiFoFull (\r
946 TERMINAL_DEV *TerminalDevice\r
947 );\r
948\r
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
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
1016 @retval TRUE If insert successfully.\r
1017 @retval FALSE If FIFO buffer is full before key insertion,\r
1018 and the key is lost.\r
1019\r
1020**/\r
1021BOOLEAN\r
1022EfiKeyFiFoInsertOneKey (\r
1023 TERMINAL_DEV *TerminalDevice,\r
1024 EFI_INPUT_KEY *Key\r
1025 );\r
1026\r
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
1033 @retval TRUE If insert successfully.\r
1034 @retval FALSE If FIFO buffer is empty before remove operation.\r
1035\r
1036**/\r
1037BOOLEAN\r
1038EfiKeyFiFoRemoveOneKey (\r
1039 TERMINAL_DEV *TerminalDevice,\r
1040 EFI_INPUT_KEY *Output\r
1041 );\r
1042\r
1043/**\r
1044 Clarify whether FIFO buffer is empty.\r
1045\r
1046 @param TerminalDevice Terminal driver private structure\r
1047\r
1048 @retval TRUE If FIFO buffer is empty.\r
1049 @retval FALSE If FIFO buffer is not empty.\r
1050\r
1051**/\r
1052BOOLEAN\r
1053IsEfiKeyFiFoEmpty (\r
1054 TERMINAL_DEV *TerminalDevice\r
1055 );\r
1056\r
1057/**\r
1058 Clarify whether FIFO buffer is full.\r
1059\r
1060 @param TerminalDevice Terminal driver private structure\r
1061\r
1062 @retval TRUE If FIFO buffer is full.\r
1063 @retval FALSE If FIFO buffer is not full.\r
1064\r
1065**/\r
1066BOOLEAN\r
1067IsEfiKeyFiFoFull (\r
1068 TERMINAL_DEV *TerminalDevice\r
1069 );\r
1070\r
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
1077 @retval TRUE If insert successfully.\r
1078 @retval FALSE If Unicode FIFO buffer is full before key insertion,\r
1079 and the key is lost.\r
1080\r
1081**/\r
1082BOOLEAN\r
1083UnicodeFiFoInsertOneKey (\r
1084 TERMINAL_DEV *TerminalDevice,\r
1085 UINT16 Input\r
1086 );\r
1087\r
1088/**\r
1089 Remove one pre-fetched key out of the Unicode FIFO buffer.\r
1090 The caller should guarantee that Unicode FIFO buffer is not empty \r
1091 by IsUnicodeFiFoEmpty ().\r
1092\r
1093 @param TerminalDevice Terminal driver private structure.\r
1094 @param Output The key will be removed.\r
1095\r
1096**/\r
1097VOID\r
1098UnicodeFiFoRemoveOneKey (\r
1099 TERMINAL_DEV *TerminalDevice,\r
1100 UINT16 *Output\r
1101 );\r
1102\r
1103/**\r
1104 Clarify whether Unicode FIFO buffer is empty.\r
1105\r
1106 @param TerminalDevice Terminal driver private structure\r
1107\r
1108 @retval TRUE If Unicode FIFO buffer is empty.\r
1109 @retval FALSE If Unicode FIFO buffer is not empty.\r
1110\r
1111**/\r
1112BOOLEAN\r
1113IsUnicodeFiFoEmpty (\r
1114 TERMINAL_DEV *TerminalDevice\r
1115 );\r
1116\r
1117/**\r
1118 Clarify whether Unicode FIFO buffer is full.\r
1119\r
1120 @param TerminalDevice Terminal driver private structure\r
1121\r
1122 @retval TRUE If Unicode FIFO buffer is full.\r
1123 @retval FALSE If Unicode FIFO buffer is not full.\r
1124\r
1125**/\r
1126BOOLEAN\r
1127IsUnicodeFiFoFull (\r
1128 TERMINAL_DEV *TerminalDevice\r
1129 );\r
1130\r
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
1139UINT8\r
1140UnicodeFiFoGetKeyCount (\r
1141 TERMINAL_DEV *TerminalDevice\r
1142 );\r
1143\r
1144/**\r
1145 Translate raw data into Unicode (according to different encode), and\r
1146 translate Unicode into key information. (according to different standard).\r
1147\r
1148 @param TerminalDevice Terminal driver private structure.\r
1149\r
1150**/\r
1151VOID\r
1152TranslateRawDataToEfiKey (\r
1153 IN TERMINAL_DEV *TerminalDevice\r
1154 );\r
1155\r
1156//\r
1157// internal functions for PC ANSI\r
1158//\r
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
1166**/\r
1167VOID\r
1168AnsiRawDataToUnicode (\r
1169 IN TERMINAL_DEV *TerminalDevice\r
1170 );\r
1171\r
1172/**\r
1173 Converts a stream of Unicode characters from a terminal input device into EFI Keys that\r
1174 can be read through the Simple Input Protocol.\r
1175\r
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
1226\r
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
1234**/\r
1235VOID\r
1236UnicodeToEfiKey (\r
1237 IN TERMINAL_DEV *TerminalDevice\r
1238 );\r
1239\r
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
1245 @param WString The input string.\r
1246\r
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
1251EFI_STATUS\r
1252AnsiTestString (\r
1253 IN TERMINAL_DEV *TerminalDevice,\r
1254 IN CHAR16 *WString\r
1255 );\r
1256\r
1257//\r
1258// internal functions for VTUTF8\r
1259//\r
1260\r
1261/**\r
1262 Translate all VT-UTF8 characters in the Raw FIFI into unicode characters,\r
1263 and insert them into Unicode FIFO.\r
1264\r
1265 @param VtUtf8Device The terminal device.\r
1266\r
1267**/\r
1268VOID\r
1269VTUTF8RawDataToUnicode (\r
1270 IN TERMINAL_DEV *VtUtf8Device\r
1271 );\r
1272\r
1273/**\r
1274 Check if input string is valid VT-UTF8 string.\r
1275\r
1276 @param TerminalDevice The terminal device.\r
1277 @param WString The input string.\r
1278\r
1279 @retval EFI_SUCCESS If all input characters are valid.\r
1280\r
1281**/\r
1282EFI_STATUS\r
1283VTUTF8TestString (\r
1284 IN TERMINAL_DEV *TerminalDevice,\r
1285 IN CHAR16 *WString\r
1286 );\r
1287\r
1288/**\r
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
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
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
1302\r
1303**/\r
1304VOID\r
1305UnicodeToUtf8 (\r
1306 IN CHAR16 Unicode,\r
1307 OUT UTF8_CHAR *Utf8Char,\r
1308 OUT UINT8 *ValidBytes\r
1309 );\r
1310\r
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
1316 @param ValidBytes The count of returned VT-VTF8 characters.\r
1317 If ValidBytes is zero, no valid VT-UTF8 returned.\r
1318\r
1319**/\r
1320VOID\r
1321GetOneValidUtf8Char (\r
1322 IN TERMINAL_DEV *Utf8Device,\r
1323 OUT UTF8_CHAR *Utf8Char,\r
1324 OUT UINT8 *ValidBytes\r
1325 );\r
1326\r
1327/**\r
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
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
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
1339 @param UnicodeChar Returned unicode character.\r
1340\r
1341**/\r
1342VOID\r
1343Utf8ToUnicode (\r
1344 IN UTF8_CHAR Utf8Char,\r
1345 IN UINT8 ValidBytes,\r
1346 OUT CHAR16 *UnicodeChar\r
1347 );\r
1348\r
1349//\r
1350// functions for boxdraw unicode\r
1351//\r
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
1362 @retval TRUE If Graphic is a supported Unicode Box Drawing character.\r
1363\r
1364**/\r
1365BOOLEAN\r
1366TerminalIsValidTextGraphics (\r
1367 IN CHAR16 Graphic,\r
1368 OUT CHAR8 *PcAnsi, OPTIONAL\r
1369 OUT CHAR8 *Ascii OPTIONAL\r
1370 );\r
1371\r
1372/**\r
1373 Detects if a valid ASCII char.\r
1374\r
1375 @param Ascii An ASCII character.\r
1376\r
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
1381BOOLEAN\r
1382TerminalIsValidAscii (\r
1383 IN CHAR16 Ascii\r
1384 );\r
1385\r
1386/**\r
1387 Detects if a valid EFI control character.\r
1388\r
1389 @param CharC An input EFI Control character.\r
1390\r
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
1395BOOLEAN\r
1396TerminalIsValidEfiCntlChar (\r
1397 IN CHAR16 CharC\r
1398 );\r
1399\r
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
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
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
1444#endif\r