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