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