]> git.proxmox.com Git - mirror_edk2.git/blame_incremental - MdeModulePkg/Universal/Console/TerminalDxe/Terminal.h
MdeModulePkg TerminalDxe: Remove a redundant 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 - 2018, 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. If KeyData.Key, KeyData.KeyState.KeyToggleState\r
347 and KeyData.KeyState.KeyShiftState are 0, then any incomplete\r
348 keystroke will trigger a notification of the KeyNotificationFunction.\r
349 @param KeyNotificationFunction Points to the function to be called when the key\r
350 sequence is typed specified by KeyData. This notification function\r
351 should be called at <=TPL_CALLBACK.\r
352 @param NotifyHandle Points to the unique handle assigned to the\r
353 registered notification.\r
354\r
355 @retval EFI_SUCCESS The notification function was registered\r
356 successfully.\r
357 @retval EFI_OUT_OF_RESOURCES Unable to allocate resources for necesssary data\r
358 structures.\r
359 @retval EFI_INVALID_PARAMETER KeyData or NotifyHandle is NULL.\r
360\r
361**/\r
362EFI_STATUS\r
363EFIAPI\r
364TerminalConInRegisterKeyNotify (\r
365 IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *This,\r
366 IN EFI_KEY_DATA *KeyData,\r
367 IN EFI_KEY_NOTIFY_FUNCTION KeyNotificationFunction,\r
368 OUT VOID **NotifyHandle\r
369 );\r
370\r
371/**\r
372 Remove a registered notification function from a particular keystroke.\r
373\r
374 @param This Protocol instance pointer.\r
375 @param NotificationHandle The handle of the notification function being\r
376 unregistered.\r
377\r
378 @retval EFI_SUCCESS The notification function was unregistered\r
379 successfully.\r
380 @retval EFI_INVALID_PARAMETER The NotificationHandle is invalid.\r
381 @retval EFI_NOT_FOUND Can not find the matching entry in database.\r
382\r
383**/\r
384EFI_STATUS\r
385EFIAPI\r
386TerminalConInUnregisterKeyNotify (\r
387 IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *This,\r
388 IN VOID *NotificationHandle\r
389 );\r
390\r
391/**\r
392 Event notification function for EFI_SIMPLE_TEXT_INPUT_PROTOCOL.WaitForKey event\r
393 Signal the event if there is key available\r
394\r
395 @param Event Indicates the event that invoke this function.\r
396 @param Context Indicates the calling context.\r
397\r
398**/\r
399VOID\r
400EFIAPI\r
401TerminalConInWaitForKey (\r
402 IN EFI_EVENT Event,\r
403 IN VOID *Context\r
404 );\r
405\r
406/**\r
407 Implements EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.Reset().\r
408 If ExtendeVerification is TRUE, then perform dependent serial device reset,\r
409 and set display mode to mode 0.\r
410 If ExtendedVerification is FALSE, only set display mode to mode 0.\r
411\r
412 @param This Indicates the calling context.\r
413 @param ExtendedVerification Indicates that the driver may perform a more\r
414 exhaustive verification operation of the device\r
415 during reset.\r
416\r
417 @retval EFI_SUCCESS The reset operation succeeds.\r
418 @retval EFI_DEVICE_ERROR The terminal is not functioning correctly or the serial port reset fails.\r
419\r
420**/\r
421EFI_STATUS\r
422EFIAPI\r
423TerminalConOutReset (\r
424 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,\r
425 IN BOOLEAN ExtendedVerification\r
426 );\r
427\r
428/**\r
429 Implements EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.OutputString().\r
430 The Unicode string will be converted to terminal expressible data stream\r
431 and send to terminal via serial port.\r
432\r
433 @param This Indicates the calling context.\r
434 @param WString The Null-terminated Unicode string to be displayed\r
435 on the terminal screen.\r
436\r
437 @retval EFI_SUCCESS The string is output successfully.\r
438 @retval EFI_DEVICE_ERROR The serial port fails to send the string out.\r
439 @retval EFI_WARN_UNKNOWN_GLYPH Indicates that some of the characters in the Unicode string could not\r
440 be rendered and are skipped.\r
441 @retval EFI_UNSUPPORTED If current display mode is out of range.\r
442\r
443**/\r
444EFI_STATUS\r
445EFIAPI\r
446TerminalConOutOutputString (\r
447 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,\r
448 IN CHAR16 *WString\r
449 );\r
450\r
451/**\r
452 Implements EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.TestString().\r
453 If one of the characters in the *Wstring is\r
454 neither valid Unicode drawing characters,\r
455 not ASCII code, then this function will return\r
456 EFI_UNSUPPORTED.\r
457\r
458 @param This Indicates the calling context.\r
459 @param WString The Null-terminated Unicode string to be tested.\r
460\r
461 @retval EFI_SUCCESS The terminal is capable of rendering the output string.\r
462 @retval EFI_UNSUPPORTED Some of the characters in the Unicode string cannot be rendered.\r
463\r
464**/\r
465EFI_STATUS\r
466EFIAPI\r
467TerminalConOutTestString (\r
468 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,\r
469 IN CHAR16 *WString\r
470 );\r
471\r
472/**\r
473 Implements EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.QueryMode().\r
474 It returns information for an available text mode\r
475 that the terminal supports.\r
476 In this driver, we support text mode 80x25 (mode 0),\r
477 80x50 (mode 1), 100x31 (mode 2).\r
478\r
479 @param This Indicates the calling context.\r
480 @param ModeNumber The mode number to return information on.\r
481 @param Columns The returned columns of the requested mode.\r
482 @param Rows The returned rows of the requested mode.\r
483\r
484 @retval EFI_SUCCESS The requested mode information is returned.\r
485 @retval EFI_UNSUPPORTED The mode number is not valid.\r
486 @retval EFI_DEVICE_ERROR\r
487\r
488**/\r
489EFI_STATUS\r
490EFIAPI\r
491TerminalConOutQueryMode (\r
492 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,\r
493 IN UINTN ModeNumber,\r
494 OUT UINTN *Columns,\r
495 OUT UINTN *Rows\r
496 );\r
497\r
498/**\r
499 Implements EFI_SIMPLE_TEXT_OUT.SetMode().\r
500 Set the terminal to a specified display mode.\r
501 In this driver, we only support mode 0.\r
502\r
503 @param This Indicates the calling context.\r
504 @param ModeNumber The text mode to set.\r
505\r
506 @retval EFI_SUCCESS The requested text mode is set.\r
507 @retval EFI_DEVICE_ERROR The requested text mode cannot be set\r
508 because of serial device error.\r
509 @retval EFI_UNSUPPORTED The text mode number is not valid.\r
510\r
511**/\r
512EFI_STATUS\r
513EFIAPI\r
514TerminalConOutSetMode (\r
515 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,\r
516 IN UINTN ModeNumber\r
517 );\r
518\r
519/**\r
520 Implements EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.SetAttribute().\r
521\r
522 @param This Indicates the calling context.\r
523 @param Attribute The attribute to set. Only bit0..6 are valid, all other bits\r
524 are undefined and must be zero.\r
525\r
526 @retval EFI_SUCCESS The requested attribute is set.\r
527 @retval EFI_DEVICE_ERROR The requested attribute cannot be set due to serial port error.\r
528 @retval EFI_UNSUPPORTED The attribute requested is not defined by EFI spec.\r
529\r
530**/\r
531EFI_STATUS\r
532EFIAPI\r
533TerminalConOutSetAttribute (\r
534 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,\r
535 IN UINTN Attribute\r
536 );\r
537\r
538/**\r
539 Implements EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.ClearScreen().\r
540 It clears the ANSI terminal's display to the\r
541 currently selected background color.\r
542\r
543 @param This Indicates the calling context.\r
544\r
545 @retval EFI_SUCCESS The operation completed successfully.\r
546 @retval EFI_DEVICE_ERROR The terminal screen cannot be cleared due to serial port error.\r
547 @retval EFI_UNSUPPORTED The terminal is not in a valid display mode.\r
548\r
549**/\r
550EFI_STATUS\r
551EFIAPI\r
552TerminalConOutClearScreen (\r
553 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This\r
554 );\r
555\r
556/**\r
557 Implements EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.SetCursorPosition().\r
558\r
559 @param This Indicates the calling context.\r
560 @param Column The row to set cursor to.\r
561 @param Row The column to set cursor to.\r
562\r
563 @retval EFI_SUCCESS The operation completed successfully.\r
564 @retval EFI_DEVICE_ERROR The request fails due to serial port error.\r
565 @retval EFI_UNSUPPORTED The terminal is not in a valid text mode, or the cursor position\r
566 is invalid for current mode.\r
567\r
568**/\r
569EFI_STATUS\r
570EFIAPI\r
571TerminalConOutSetCursorPosition (\r
572 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,\r
573 IN UINTN Column,\r
574 IN UINTN Row\r
575 );\r
576\r
577/**\r
578 Implements SIMPLE_TEXT_OUTPUT.EnableCursor().\r
579 In this driver, the cursor cannot be hidden.\r
580\r
581 @param This Indicates the calling context.\r
582 @param Visible If TRUE, the cursor is set to be visible,\r
583 If FALSE, the cursor is set to be invisible.\r
584\r
585 @retval EFI_SUCCESS The request is valid.\r
586 @retval EFI_UNSUPPORTED The terminal does not support cursor hidden.\r
587\r
588**/\r
589EFI_STATUS\r
590EFIAPI\r
591TerminalConOutEnableCursor (\r
592 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,\r
593 IN BOOLEAN Visible\r
594 );\r
595\r
596/**\r
597 Test to see if this driver supports Controller.\r
598\r
599 @param This Protocol instance pointer.\r
600 @param ControllerHandle Handle of device to test\r
601 @param RemainingDevicePath Optional parameter use to pick a specific child\r
602 device to start.\r
603\r
604 @retval EFI_SUCCESS This driver supports this device.\r
605 @retval EFI_ALREADY_STARTED This driver is already running on this device.\r
606 @retval other This driver does not support this device.\r
607\r
608**/\r
609EFI_STATUS\r
610EFIAPI\r
611TerminalDriverBindingSupported (\r
612 IN EFI_DRIVER_BINDING_PROTOCOL *This,\r
613 IN EFI_HANDLE ControllerHandle,\r
614 IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath\r
615 );\r
616\r
617/**\r
618 Start this driver on Controller by opening a Serial IO protocol,\r
619 reading Device Path, and creating a child handle with a Simple Text In,\r
620 Simple Text In Ex and Simple Text Out protocol, and device path protocol.\r
621 And store Console Device Environment Variables.\r
622\r
623 @param This Protocol instance pointer.\r
624 @param Controller Handle of device to bind driver to\r
625 @param RemainingDevicePath Optional parameter use to pick a specific child\r
626 device to start.\r
627\r
628 @retval EFI_SUCCESS This driver is added to Controller.\r
629 @retval EFI_ALREADY_STARTED This driver is already running on Controller.\r
630 @retval other This driver does not support this device.\r
631\r
632**/\r
633EFI_STATUS\r
634EFIAPI\r
635TerminalDriverBindingStart (\r
636 IN EFI_DRIVER_BINDING_PROTOCOL *This,\r
637 IN EFI_HANDLE Controller,\r
638 IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath\r
639 );\r
640\r
641\r
642/**\r
643 Stop this driver on Controller by closing Simple Text In, Simple Text\r
644 In Ex, Simple Text Out protocol, and removing parent device path from\r
645 Console Device Environment Variables.\r
646\r
647 @param This Protocol instance pointer.\r
648 @param Controller Handle of device to stop driver on\r
649 @param NumberOfChildren Number of Handles in ChildHandleBuffer. If number of\r
650 children is zero stop the entire bus driver.\r
651 @param ChildHandleBuffer List of Child Handles to Stop.\r
652\r
653 @retval EFI_SUCCESS This driver is removed Controller.\r
654 @retval other This driver could not be removed from this device.\r
655\r
656**/\r
657EFI_STATUS\r
658EFIAPI\r
659TerminalDriverBindingStop (\r
660 IN EFI_DRIVER_BINDING_PROTOCOL *This,\r
661 IN EFI_HANDLE Controller,\r
662 IN UINTN NumberOfChildren,\r
663 IN EFI_HANDLE *ChildHandleBuffer\r
664 );\r
665\r
666/**\r
667 Free notify functions list.\r
668\r
669 @param ListHead The list head\r
670\r
671 @retval EFI_SUCCESS Free the notify list successfully.\r
672 @retval EFI_INVALID_PARAMETER ListHead is NULL.\r
673\r
674**/\r
675EFI_STATUS\r
676TerminalFreeNotifyList (\r
677 IN OUT LIST_ENTRY *ListHead\r
678 );\r
679\r
680/**\r
681 Retrieves a Unicode string that is the user readable name of the driver.\r
682\r
683 This function retrieves the user readable name of a driver in the form of a\r
684 Unicode string. If the driver specified by This has a user readable name in\r
685 the language specified by Language, then a pointer to the driver name is\r
686 returned in DriverName, and EFI_SUCCESS is returned. If the driver specified\r
687 by This does not support the language specified by Language,\r
688 then EFI_UNSUPPORTED is returned.\r
689\r
690 @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or\r
691 EFI_COMPONENT_NAME_PROTOCOL instance.\r
692\r
693 @param Language[in] A pointer to a Null-terminated ASCII string\r
694 array indicating the language. This is the\r
695 language of the driver name that the caller is\r
696 requesting, and it must match one of the\r
697 languages specified in SupportedLanguages. The\r
698 number of languages supported by a driver is up\r
699 to the driver writer. Language is specified\r
700 in RFC 4646 or ISO 639-2 language code format.\r
701\r
702 @param DriverName[out] A pointer to the Unicode string to return.\r
703 This Unicode string is the name of the\r
704 driver specified by This in the language\r
705 specified by Language.\r
706\r
707 @retval EFI_SUCCESS The Unicode string for the Driver specified by\r
708 This and the language specified by Language was\r
709 returned in DriverName.\r
710\r
711 @retval EFI_INVALID_PARAMETER Language is NULL.\r
712\r
713 @retval EFI_INVALID_PARAMETER DriverName is NULL.\r
714\r
715 @retval EFI_UNSUPPORTED The driver specified by This does not support\r
716 the language specified by Language.\r
717\r
718**/\r
719EFI_STATUS\r
720EFIAPI\r
721TerminalComponentNameGetDriverName (\r
722 IN EFI_COMPONENT_NAME_PROTOCOL *This,\r
723 IN CHAR8 *Language,\r
724 OUT CHAR16 **DriverName\r
725 );\r
726\r
727\r
728/**\r
729 Retrieves a Unicode string that is the user readable name of the controller\r
730 that is being managed by a driver.\r
731\r
732 This function retrieves the user readable name of the controller specified by\r
733 ControllerHandle and ChildHandle in the form of a Unicode string. If the\r
734 driver specified by This has a user readable name in the language specified by\r
735 Language, then a pointer to the controller name is returned in ControllerName,\r
736 and EFI_SUCCESS is returned. If the driver specified by This is not currently\r
737 managing the controller specified by ControllerHandle and ChildHandle,\r
738 then EFI_UNSUPPORTED is returned. If the driver specified by This does not\r
739 support the language specified by Language, then EFI_UNSUPPORTED is returned.\r
740\r
741 @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or\r
742 EFI_COMPONENT_NAME_PROTOCOL instance.\r
743\r
744 @param ControllerHandle[in] The handle of a controller that the driver\r
745 specified by This is managing. This handle\r
746 specifies the controller whose name is to be\r
747 returned.\r
748\r
749 @param ChildHandle[in] The handle of the child controller to retrieve\r
750 the name of. This is an optional parameter that\r
751 may be NULL. It will be NULL for device\r
752 drivers. It will also be NULL for a bus drivers\r
753 that wish to retrieve the name of the bus\r
754 controller. It will not be NULL for a bus\r
755 driver that wishes to retrieve the name of a\r
756 child controller.\r
757\r
758 @param Language[in] A pointer to a Null-terminated ASCII string\r
759 array indicating the language. This is the\r
760 language of the driver name that the caller is\r
761 requesting, and it must match one of the\r
762 languages specified in SupportedLanguages. The\r
763 number of languages supported by a driver is up\r
764 to the driver writer. Language is specified in\r
765 RFC 4646 or ISO 639-2 language code format.\r
766\r
767 @param ControllerName[out] A pointer to the Unicode string to return.\r
768 This Unicode string is the name of the\r
769 controller specified by ControllerHandle and\r
770 ChildHandle in the language specified by\r
771 Language from the point of view of the driver\r
772 specified by This.\r
773\r
774 @retval EFI_SUCCESS The Unicode string for the user readable name in\r
775 the language specified by Language for the\r
776 driver specified by This was returned in\r
777 DriverName.\r
778\r
779 @retval EFI_INVALID_PARAMETER ControllerHandle is NULL.\r
780\r
781 @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid\r
782 EFI_HANDLE.\r
783\r
784 @retval EFI_INVALID_PARAMETER Language is NULL.\r
785\r
786 @retval EFI_INVALID_PARAMETER ControllerName is NULL.\r
787\r
788 @retval EFI_UNSUPPORTED The driver specified by This is not currently\r
789 managing the controller specified by\r
790 ControllerHandle and ChildHandle.\r
791\r
792 @retval EFI_UNSUPPORTED The driver specified by This does not support\r
793 the language specified by Language.\r
794\r
795**/\r
796EFI_STATUS\r
797EFIAPI\r
798TerminalComponentNameGetControllerName (\r
799 IN EFI_COMPONENT_NAME_PROTOCOL *This,\r
800 IN EFI_HANDLE ControllerHandle,\r
801 IN EFI_HANDLE ChildHandle OPTIONAL,\r
802 IN CHAR8 *Language,\r
803 OUT CHAR16 **ControllerName\r
804 );\r
805\r
806\r
807//\r
808// internal functions\r
809//\r
810\r
811/**\r
812 Check for a pending key in the Efi Key FIFO or Serial device buffer.\r
813\r
814 @param This Indicates the calling context.\r
815\r
816 @retval EFI_SUCCESS There is key pending.\r
817 @retval EFI_NOT_READY There is no key pending.\r
818 @retval EFI_DEVICE_ERROR If Serial IO is not attached to serial device.\r
819\r
820**/\r
821EFI_STATUS\r
822TerminalConInCheckForKey (\r
823 IN EFI_SIMPLE_TEXT_INPUT_PROTOCOL *This\r
824 );\r
825\r
826/**\r
827 Update terminal device path in Console Device Environment Variables.\r
828\r
829 @param VariableName The Console Device Environment Variable.\r
830 @param ParentDevicePath The terminal device path to be updated.\r
831\r
832 @return None.\r
833\r
834**/\r
835VOID\r
836TerminalUpdateConsoleDevVariable (\r
837 IN CHAR16 *VariableName,\r
838 IN EFI_DEVICE_PATH_PROTOCOL *ParentDevicePath\r
839 );\r
840\r
841/**\r
842 Remove console device variable.\r
843\r
844 @param VariableName A pointer to the variable name.\r
845 @param ParentDevicePath A pointer to the parent device path.\r
846\r
847**/\r
848VOID\r
849TerminalRemoveConsoleDevVariable (\r
850 IN CHAR16 *VariableName,\r
851 IN EFI_DEVICE_PATH_PROTOCOL *ParentDevicePath\r
852 );\r
853\r
854/**\r
855 Build termial device path according to terminal type.\r
856\r
857 @param TerminalType The terminal type is PC ANSI, VT100, VT100+ or VT-UTF8.\r
858 @param ParentDevicePath Parent device path.\r
859 @param TerminalDevicePath Returned terminal device path, if building successfully.\r
860\r
861 @retval EFI_UNSUPPORTED Terminal does not belong to the supported type.\r
862 @retval EFI_OUT_OF_RESOURCES Generate terminal device path failed.\r
863 @retval EFI_SUCCESS Build terminal device path successfully.\r
864\r
865**/\r
866EFI_STATUS\r
867SetTerminalDevicePath (\r
868 IN TERMINAL_TYPE TerminalType,\r
869 IN EFI_DEVICE_PATH_PROTOCOL *ParentDevicePath,\r
870 OUT EFI_DEVICE_PATH_PROTOCOL **TerminalDevicePath\r
871 );\r
872\r
873/**\r
874 Get one key out of serial buffer.\r
875\r
876 @param SerialIo Serial I/O protocl attached to the serial device.\r
877 @param Input The fetched key.\r
878\r
879 @retval EFI_NOT_READY If serial buffer is empty.\r
880 @retval EFI_DEVICE_ERROR If reading serial buffer encounter error.\r
881 @retval EFI_SUCCESS If reading serial buffer successfully, put\r
882 the fetched key to the parameter output.\r
883\r
884**/\r
885EFI_STATUS\r
886GetOneKeyFromSerial (\r
887 EFI_SERIAL_IO_PROTOCOL *SerialIo,\r
888 UINT8 *Input\r
889 );\r
890\r
891/**\r
892 Insert one byte raw data into the Raw Data FIFO.\r
893\r
894 @param TerminalDevice Terminal driver private structure.\r
895 @param Input The key will be input.\r
896\r
897 @retval TRUE If insert successfully.\r
898 @retval FALSE If Raw Data buffer is full before key insertion,\r
899 and the key is lost.\r
900\r
901**/\r
902BOOLEAN\r
903RawFiFoInsertOneKey (\r
904 TERMINAL_DEV *TerminalDevice,\r
905 UINT8 Input\r
906 );\r
907\r
908/**\r
909 Remove one pre-fetched key out of the Raw Data FIFO.\r
910\r
911 @param TerminalDevice Terminal driver private structure.\r
912 @param Output The key will be removed.\r
913\r
914 @retval TRUE If insert successfully.\r
915 @retval FALSE If Raw Data FIFO buffer is empty before remove operation.\r
916\r
917**/\r
918BOOLEAN\r
919RawFiFoRemoveOneKey (\r
920 TERMINAL_DEV *TerminalDevice,\r
921 UINT8 *Output\r
922 );\r
923\r
924/**\r
925 Clarify whether Raw Data FIFO buffer is empty.\r
926\r
927 @param TerminalDevice Terminal driver private structure\r
928\r
929 @retval TRUE If Raw Data FIFO buffer is empty.\r
930 @retval FALSE If Raw Data FIFO buffer is not empty.\r
931\r
932**/\r
933BOOLEAN\r
934IsRawFiFoEmpty (\r
935 TERMINAL_DEV *TerminalDevice\r
936 );\r
937\r
938/**\r
939 Clarify whether Raw Data FIFO buffer is full.\r
940\r
941 @param TerminalDevice Terminal driver private structure\r
942\r
943 @retval TRUE If Raw Data FIFO buffer is full.\r
944 @retval FALSE If Raw Data FIFO buffer is not full.\r
945\r
946**/\r
947BOOLEAN\r
948IsRawFiFoFull (\r
949 TERMINAL_DEV *TerminalDevice\r
950 );\r
951\r
952/**\r
953 Insert one pre-fetched key into the FIFO buffer.\r
954\r
955 @param EfiKeyFiFo Pointer to instance of EFI_KEY_FIFO.\r
956 @param Input The key will be input.\r
957\r
958 @retval TRUE If insert successfully.\r
959 @retval FALSE If FIFO buffer is full before key insertion,\r
960 and the key is lost.\r
961\r
962**/\r
963BOOLEAN\r
964EfiKeyFiFoForNotifyInsertOneKey (\r
965 EFI_KEY_FIFO *EfiKeyFiFo,\r
966 EFI_INPUT_KEY *Input\r
967 );\r
968\r
969/**\r
970 Remove one pre-fetched key out of the FIFO buffer.\r
971\r
972 @param EfiKeyFiFo Pointer to instance of EFI_KEY_FIFO.\r
973 @param Output The key will be removed.\r
974\r
975 @retval TRUE If insert successfully.\r
976 @retval FALSE If FIFO buffer is empty before remove operation.\r
977\r
978**/\r
979BOOLEAN\r
980EfiKeyFiFoForNotifyRemoveOneKey (\r
981 EFI_KEY_FIFO *EfiKeyFiFo,\r
982 EFI_INPUT_KEY *Output\r
983 );\r
984\r
985/**\r
986 Clarify whether FIFO buffer is empty.\r
987\r
988 @param EfiKeyFiFo Pointer to instance of EFI_KEY_FIFO.\r
989\r
990 @retval TRUE If FIFO buffer is empty.\r
991 @retval FALSE If FIFO buffer is not empty.\r
992\r
993**/\r
994BOOLEAN\r
995IsEfiKeyFiFoForNotifyEmpty (\r
996 IN EFI_KEY_FIFO *EfiKeyFiFo\r
997 );\r
998\r
999/**\r
1000 Clarify whether FIFO buffer is full.\r
1001\r
1002 @param EfiKeyFiFo Pointer to instance of EFI_KEY_FIFO.\r
1003\r
1004 @retval TRUE If FIFO buffer is full.\r
1005 @retval FALSE If FIFO buffer is not full.\r
1006\r
1007**/\r
1008BOOLEAN\r
1009IsEfiKeyFiFoForNotifyFull (\r
1010 EFI_KEY_FIFO *EfiKeyFiFo\r
1011 );\r
1012\r
1013/**\r
1014 Insert one pre-fetched key into the FIFO buffer.\r
1015\r
1016 @param TerminalDevice Terminal driver private structure.\r
1017 @param Key The key will be input.\r
1018\r
1019 @retval TRUE If insert successfully.\r
1020 @retval FALSE If FIFO buffer is full before key insertion,\r
1021 and the key is lost.\r
1022\r
1023**/\r
1024BOOLEAN\r
1025EfiKeyFiFoInsertOneKey (\r
1026 TERMINAL_DEV *TerminalDevice,\r
1027 EFI_INPUT_KEY *Key\r
1028 );\r
1029\r
1030/**\r
1031 Remove one pre-fetched key out of the FIFO buffer.\r
1032\r
1033 @param TerminalDevice Terminal driver private structure.\r
1034 @param Output The key will be removed.\r
1035\r
1036 @retval TRUE If insert successfully.\r
1037 @retval FALSE If FIFO buffer is empty before remove operation.\r
1038\r
1039**/\r
1040BOOLEAN\r
1041EfiKeyFiFoRemoveOneKey (\r
1042 TERMINAL_DEV *TerminalDevice,\r
1043 EFI_INPUT_KEY *Output\r
1044 );\r
1045\r
1046/**\r
1047 Clarify whether FIFO buffer is empty.\r
1048\r
1049 @param TerminalDevice Terminal driver private structure\r
1050\r
1051 @retval TRUE If FIFO buffer is empty.\r
1052 @retval FALSE If FIFO buffer is not empty.\r
1053\r
1054**/\r
1055BOOLEAN\r
1056IsEfiKeyFiFoEmpty (\r
1057 TERMINAL_DEV *TerminalDevice\r
1058 );\r
1059\r
1060/**\r
1061 Clarify whether FIFO buffer is full.\r
1062\r
1063 @param TerminalDevice Terminal driver private structure\r
1064\r
1065 @retval TRUE If FIFO buffer is full.\r
1066 @retval FALSE If FIFO buffer is not full.\r
1067\r
1068**/\r
1069BOOLEAN\r
1070IsEfiKeyFiFoFull (\r
1071 TERMINAL_DEV *TerminalDevice\r
1072 );\r
1073\r
1074/**\r
1075 Insert one pre-fetched key into the Unicode FIFO buffer.\r
1076\r
1077 @param TerminalDevice Terminal driver private structure.\r
1078 @param Input The key will be input.\r
1079\r
1080 @retval TRUE If insert successfully.\r
1081 @retval FALSE If Unicode FIFO buffer is full before key insertion,\r
1082 and the key is lost.\r
1083\r
1084**/\r
1085BOOLEAN\r
1086UnicodeFiFoInsertOneKey (\r
1087 TERMINAL_DEV *TerminalDevice,\r
1088 UINT16 Input\r
1089 );\r
1090\r
1091/**\r
1092 Remove one pre-fetched key out of the Unicode FIFO buffer.\r
1093 The caller should guarantee that Unicode FIFO buffer is not empty\r
1094 by IsUnicodeFiFoEmpty ().\r
1095\r
1096 @param TerminalDevice Terminal driver private structure.\r
1097 @param Output The key will be removed.\r
1098\r
1099**/\r
1100VOID\r
1101UnicodeFiFoRemoveOneKey (\r
1102 TERMINAL_DEV *TerminalDevice,\r
1103 UINT16 *Output\r
1104 );\r
1105\r
1106/**\r
1107 Clarify whether Unicode FIFO buffer is empty.\r
1108\r
1109 @param TerminalDevice Terminal driver private structure\r
1110\r
1111 @retval TRUE If Unicode FIFO buffer is empty.\r
1112 @retval FALSE If Unicode FIFO buffer is not empty.\r
1113\r
1114**/\r
1115BOOLEAN\r
1116IsUnicodeFiFoEmpty (\r
1117 TERMINAL_DEV *TerminalDevice\r
1118 );\r
1119\r
1120/**\r
1121 Clarify whether Unicode FIFO buffer is full.\r
1122\r
1123 @param TerminalDevice Terminal driver private structure\r
1124\r
1125 @retval TRUE If Unicode FIFO buffer is full.\r
1126 @retval FALSE If Unicode FIFO buffer is not full.\r
1127\r
1128**/\r
1129BOOLEAN\r
1130IsUnicodeFiFoFull (\r
1131 TERMINAL_DEV *TerminalDevice\r
1132 );\r
1133\r
1134\r
1135/**\r
1136 Translate raw data into Unicode (according to different encode), and\r
1137 translate Unicode into key information. (according to different standard).\r
1138\r
1139 @param TerminalDevice Terminal driver private structure.\r
1140\r
1141**/\r
1142VOID\r
1143TranslateRawDataToEfiKey (\r
1144 IN TERMINAL_DEV *TerminalDevice\r
1145 );\r
1146\r
1147//\r
1148// internal functions for PC ANSI\r
1149//\r
1150\r
1151/**\r
1152 Translate all raw data in the Raw FIFI into unicode, and insert\r
1153 them into Unicode FIFO.\r
1154\r
1155 @param TerminalDevice The terminal device.\r
1156\r
1157**/\r
1158VOID\r
1159AnsiRawDataToUnicode (\r
1160 IN TERMINAL_DEV *TerminalDevice\r
1161 );\r
1162\r
1163/**\r
1164 Converts a stream of Unicode characters from a terminal input device into EFI Keys that\r
1165 can be read through the Simple Input Protocol.\r
1166\r
1167 The table below shows the keyboard input mappings that this function supports.\r
1168 If the ESC sequence listed in one of the columns is presented, then it is translated\r
1169 into the coorespoding EFI Scan Code. If a matching sequence is not found, then the raw\r
1170 key strokes are converted into EFI Keys.\r
1171\r
1172 2 seconds are allowed for an ESC sequence to be completed. If the ESC sequence is not\r
1173 completed in 2 seconds, then the raw key strokes of the partial ESC sequence are\r
1174 converted into EFI Keys.\r
1175 There is one special input sequence that will force the system to reset.\r
1176 This is ESC R ESC r ESC R.\r
1177\r
1178 Symbols used in table below\r
1179 ===========================\r
1180 ESC = 0x1B\r
1181 CSI = 0x9B\r
1182 DEL = 0x7f\r
1183 ^ = CTRL\r
1184 +=========+======+===========+==========+==========+\r
1185 | | EFI | UEFI 2.0 | | |\r
1186 | | Scan | | VT100+ | |\r
1187 | KEY | Code | PC ANSI | VTUTF8 | VT100 |\r
1188 +=========+======+===========+==========+==========+\r
1189 | NULL | 0x00 | | | |\r
1190 | UP | 0x01 | ESC [ A | ESC [ A | ESC [ A |\r
1191 | DOWN | 0x02 | ESC [ B | ESC [ B | ESC [ B |\r
1192 | RIGHT | 0x03 | ESC [ C | ESC [ C | ESC [ C |\r
1193 | LEFT | 0x04 | ESC [ D | ESC [ D | ESC [ D |\r
1194 | HOME | 0x05 | ESC [ H | ESC h | ESC [ H |\r
1195 | END | 0x06 | ESC [ F | ESC k | ESC [ K |\r
1196 | INSERT | 0x07 | ESC [ @ | ESC + | ESC [ @ |\r
1197 | | | ESC [ L | | ESC [ L |\r
1198 | DELETE | 0x08 | ESC [ X | ESC - | ESC [ P |\r
1199 | PG UP | 0x09 | ESC [ I | ESC ? | ESC [ V |\r
1200 | | | | | ESC [ ? |\r
1201 | PG DOWN | 0x0A | ESC [ G | ESC / | ESC [ U |\r
1202 | | | | | ESC [ / |\r
1203 | F1 | 0x0B | ESC [ M | ESC 1 | ESC O P |\r
1204 | F2 | 0x0C | ESC [ N | ESC 2 | ESC O Q |\r
1205 | F3 | 0x0D | ESC [ O | ESC 3 | ESC O w |\r
1206 | F4 | 0x0E | ESC [ P | ESC 4 | ESC O x |\r
1207 | F5 | 0x0F | ESC [ Q | ESC 5 | ESC O t |\r
1208 | F6 | 0x10 | ESC [ R | ESC 6 | ESC O u |\r
1209 | F7 | 0x11 | ESC [ S | ESC 7 | ESC O q |\r
1210 | F8 | 0x12 | ESC [ T | ESC 8 | ESC O r |\r
1211 | F9 | 0x13 | ESC [ U | ESC 9 | ESC O p |\r
1212 | F10 | 0x14 | ESC [ V | ESC 0 | ESC O M |\r
1213 | Escape | 0x17 | ESC | ESC | ESC |\r
1214 | F11 | 0x15 | | ESC ! | |\r
1215 | F12 | 0x16 | | ESC @ | |\r
1216 +=========+======+===========+==========+==========+\r
1217\r
1218 Special Mappings\r
1219 ================\r
1220 ESC R ESC r ESC R = Reset System\r
1221\r
1222\r
1223 @param TerminalDevice The terminal device to use to translate raw input into EFI Keys\r
1224\r
1225**/\r
1226VOID\r
1227UnicodeToEfiKey (\r
1228 IN TERMINAL_DEV *TerminalDevice\r
1229 );\r
1230\r
1231/**\r
1232 Check if input string is valid Ascii string, valid EFI control characters\r
1233 or valid text graphics.\r
1234\r
1235 @param TerminalDevice The terminal device.\r
1236 @param WString The input string.\r
1237\r
1238 @retval EFI_UNSUPPORTED If not all input characters are valid.\r
1239 @retval EFI_SUCCESS If all input characters are valid.\r
1240\r
1241**/\r
1242EFI_STATUS\r
1243AnsiTestString (\r
1244 IN TERMINAL_DEV *TerminalDevice,\r
1245 IN CHAR16 *WString\r
1246 );\r
1247\r
1248//\r
1249// internal functions for VTUTF8\r
1250//\r
1251\r
1252/**\r
1253 Translate all VT-UTF8 characters in the Raw FIFI into unicode characters,\r
1254 and insert them into Unicode FIFO.\r
1255\r
1256 @param VtUtf8Device The terminal device.\r
1257\r
1258**/\r
1259VOID\r
1260VTUTF8RawDataToUnicode (\r
1261 IN TERMINAL_DEV *VtUtf8Device\r
1262 );\r
1263\r
1264/**\r
1265 Check if input string is valid VT-UTF8 string.\r
1266\r
1267 @param TerminalDevice The terminal device.\r
1268 @param WString The input string.\r
1269\r
1270 @retval EFI_SUCCESS If all input characters are valid.\r
1271\r
1272**/\r
1273EFI_STATUS\r
1274VTUTF8TestString (\r
1275 IN TERMINAL_DEV *TerminalDevice,\r
1276 IN CHAR16 *WString\r
1277 );\r
1278\r
1279/**\r
1280 Translate one Unicode character into VT-UTF8 characters.\r
1281\r
1282 UTF8 Encoding Table\r
1283 Bits per Character | Unicode Character Range | Unicode Binary Encoding | UTF8 Binary Encoding\r
1284 0-7 | 0x0000 - 0x007F | 00000000 0xxxxxxx | 0xxxxxxx\r
1285 8-11 | 0x0080 - 0x07FF | 00000xxx xxxxxxxx | 110xxxxx 10xxxxxx\r
1286 12-16 | 0x0800 - 0xFFFF | xxxxxxxx xxxxxxxx | 1110xxxx 10xxxxxx 10xxxxxx\r
1287\r
1288\r
1289 @param Unicode Unicode character need translating.\r
1290 @param Utf8Char Return VT-UTF8 character set.\r
1291 @param ValidBytes The count of valid VT-UTF8 characters. If\r
1292 ValidBytes is zero, no valid VT-UTF8 returned.\r
1293\r
1294**/\r
1295VOID\r
1296UnicodeToUtf8 (\r
1297 IN CHAR16 Unicode,\r
1298 OUT UTF8_CHAR *Utf8Char,\r
1299 OUT UINT8 *ValidBytes\r
1300 );\r
1301\r
1302/**\r
1303 Get one valid VT-UTF8 characters set from Raw Data FIFO.\r
1304\r
1305 @param Utf8Device The terminal device.\r
1306 @param Utf8Char Returned valid VT-UTF8 characters set.\r
1307 @param ValidBytes The count of returned VT-VTF8 characters.\r
1308 If ValidBytes is zero, no valid VT-UTF8 returned.\r
1309\r
1310**/\r
1311VOID\r
1312GetOneValidUtf8Char (\r
1313 IN TERMINAL_DEV *Utf8Device,\r
1314 OUT UTF8_CHAR *Utf8Char,\r
1315 OUT UINT8 *ValidBytes\r
1316 );\r
1317\r
1318/**\r
1319 Translate VT-UTF8 characters into one Unicode character.\r
1320\r
1321 UTF8 Encoding Table\r
1322 Bits per Character | Unicode Character Range | Unicode Binary Encoding | UTF8 Binary Encoding\r
1323 0-7 | 0x0000 - 0x007F | 00000000 0xxxxxxx | 0xxxxxxx\r
1324 8-11 | 0x0080 - 0x07FF | 00000xxx xxxxxxxx | 110xxxxx 10xxxxxx\r
1325 12-16 | 0x0800 - 0xFFFF | xxxxxxxx xxxxxxxx | 1110xxxx 10xxxxxx 10xxxxxx\r
1326\r
1327\r
1328 @param Utf8Char VT-UTF8 character set needs translating.\r
1329 @param ValidBytes The count of valid VT-UTF8 characters.\r
1330 @param UnicodeChar Returned unicode character.\r
1331\r
1332**/\r
1333VOID\r
1334Utf8ToUnicode (\r
1335 IN UTF8_CHAR Utf8Char,\r
1336 IN UINT8 ValidBytes,\r
1337 OUT CHAR16 *UnicodeChar\r
1338 );\r
1339\r
1340//\r
1341// functions for boxdraw unicode\r
1342//\r
1343\r
1344/**\r
1345 Detects if a Unicode char is for Box Drawing text graphics.\r
1346\r
1347 @param Graphic Unicode char to test.\r
1348 @param PcAnsi Optional pointer to return PCANSI equivalent of\r
1349 Graphic.\r
1350 @param Ascii Optional pointer to return ASCII equivalent of\r
1351 Graphic.\r
1352\r
1353 @retval TRUE If Graphic is a supported Unicode Box Drawing character.\r
1354\r
1355**/\r
1356BOOLEAN\r
1357TerminalIsValidTextGraphics (\r
1358 IN CHAR16 Graphic,\r
1359 OUT CHAR8 *PcAnsi, OPTIONAL\r
1360 OUT CHAR8 *Ascii OPTIONAL\r
1361 );\r
1362\r
1363/**\r
1364 Detects if a valid ASCII char.\r
1365\r
1366 @param Ascii An ASCII character.\r
1367\r
1368 @retval TRUE If it is a valid ASCII character.\r
1369 @retval FALSE If it is not a valid ASCII character.\r
1370\r
1371**/\r
1372BOOLEAN\r
1373TerminalIsValidAscii (\r
1374 IN CHAR16 Ascii\r
1375 );\r
1376\r
1377/**\r
1378 Detects if a valid EFI control character.\r
1379\r
1380 @param CharC An input EFI Control character.\r
1381\r
1382 @retval TRUE If it is a valid EFI control character.\r
1383 @retval FALSE If it is not a valid EFI control character.\r
1384\r
1385**/\r
1386BOOLEAN\r
1387TerminalIsValidEfiCntlChar (\r
1388 IN CHAR16 CharC\r
1389 );\r
1390\r
1391/**\r
1392 Check if the device supports hot-plug through its device path.\r
1393\r
1394 This function could be updated to check more types of Hot Plug devices.\r
1395 Currently, it checks USB and PCCard device.\r
1396\r
1397 @param DevicePath Pointer to device's device path.\r
1398\r
1399 @retval TRUE The devcie is a hot-plug device\r
1400 @retval FALSE The devcie is not a hot-plug device.\r
1401\r
1402**/\r
1403BOOLEAN\r
1404IsHotPlugDevice (\r
1405 IN EFI_DEVICE_PATH_PROTOCOL *DevicePath\r
1406 );\r
1407\r
1408/**\r
1409 Timer handler to poll the key from serial.\r
1410\r
1411 @param Event Indicates the event that invoke this function.\r
1412 @param Context Indicates the calling context.\r
1413**/\r
1414VOID\r
1415EFIAPI\r
1416TerminalConInTimerHandler (\r
1417 IN EFI_EVENT Event,\r
1418 IN VOID *Context\r
1419 );\r
1420\r
1421\r
1422/**\r
1423 Process key notify.\r
1424\r
1425 @param Event Indicates the event that invoke this function.\r
1426 @param Context Indicates the calling context.\r
1427**/\r
1428VOID\r
1429EFIAPI\r
1430KeyNotifyProcessHandler (\r
1431 IN EFI_EVENT Event,\r
1432 IN VOID *Context\r
1433 );\r
1434\r
1435#endif\r