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