]> git.proxmox.com Git - mirror_edk2.git/blob - MdeModulePkg/Universal/Console/TerminalDxe/Terminal.h
MdeModulePkg: Clean up source files
[mirror_edk2.git] / MdeModulePkg / Universal / Console / TerminalDxe / Terminal.h
1 /** @file
2 Header file for Terminal driver.
3
4 Copyright (c) 2006 - 2018, 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
85 typedef enum {
86 TerminalTypePcAnsi,
87 TerminalTypeVt100,
88 TerminalTypeVt100Plus,
89 TerminalTypeVtUtf8,
90 TerminalTypeTtyTerm
91 } TERMINAL_TYPE;
92
93 typedef struct {
94 UINTN Signature;
95 EFI_HANDLE Handle;
96 TERMINAL_TYPE TerminalType;
97 EFI_SERIAL_IO_PROTOCOL *SerialIo;
98 EFI_DEVICE_PATH_PROTOCOL *DevicePath;
99 EFI_SIMPLE_TEXT_INPUT_PROTOCOL SimpleInput;
100 EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL SimpleTextOutput;
101 EFI_SIMPLE_TEXT_OUTPUT_MODE SimpleTextOutputMode;
102 TERMINAL_CONSOLE_MODE_DATA *TerminalConsoleModeData;
103 UINTN SerialInTimeOut;
104 RAW_DATA_FIFO *RawFiFo;
105 UNICODE_FIFO *UnicodeFiFo;
106 EFI_KEY_FIFO *EfiKeyFiFo;
107 EFI_KEY_FIFO *EfiKeyFiFoForNotify;
108 EFI_UNICODE_STRING_TABLE *ControllerNameTable;
109 EFI_EVENT TimerEvent;
110 EFI_EVENT TwoSecondTimeOut;
111 UINT32 InputState;
112 UINT32 ResetState;
113 UINT16 TtyEscapeStr[3];
114 INTN TtyEscapeIndex;
115
116 //
117 // Esc could not be output to the screen by user,
118 // but the terminal driver need to output it to
119 // the terminal emulation software to send control sequence.
120 // This boolean is used by the terminal driver only
121 // to indicate whether the Esc could be sent or not.
122 //
123 BOOLEAN OutputEscChar;
124 EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL SimpleInputEx;
125 LIST_ENTRY NotifyList;
126 EFI_EVENT KeyNotifyProcessEvent;
127 } TERMINAL_DEV;
128
129 #define INPUT_STATE_DEFAULT 0x00
130 #define INPUT_STATE_ESC 0x01
131 #define INPUT_STATE_CSI 0x02
132 #define INPUT_STATE_LEFTOPENBRACKET 0x04
133 #define INPUT_STATE_O 0x08
134 #define INPUT_STATE_2 0x10
135 #define INPUT_STATE_LEFTOPENBRACKET_2 0x20
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+ or VT-UTF8.
858 @param ParentDevicePath Parent device path.
859 @param TerminalDevicePath Returned terminal device path, if building successfully.
860
861 @retval EFI_UNSUPPORTED Terminal does not belong to the supported type.
862 @retval EFI_OUT_OF_RESOURCES Generate terminal device path failed.
863 @retval EFI_SUCCESS Build terminal device path successfully.
864
865 **/
866 EFI_STATUS
867 SetTerminalDevicePath (
868 IN TERMINAL_TYPE TerminalType,
869 IN EFI_DEVICE_PATH_PROTOCOL *ParentDevicePath,
870 OUT EFI_DEVICE_PATH_PROTOCOL **TerminalDevicePath
871 );
872
873 /**
874 Get one key out of serial buffer.
875
876 @param SerialIo Serial I/O protocl attached to the serial device.
877 @param Input The fetched key.
878
879 @retval EFI_NOT_READY If serial buffer is empty.
880 @retval EFI_DEVICE_ERROR If reading serial buffer encounter error.
881 @retval EFI_SUCCESS If reading serial buffer successfully, put
882 the fetched key to the parameter output.
883
884 **/
885 EFI_STATUS
886 GetOneKeyFromSerial (
887 EFI_SERIAL_IO_PROTOCOL *SerialIo,
888 UINT8 *Input
889 );
890
891 /**
892 Insert one byte raw data into the Raw Data FIFO.
893
894 @param TerminalDevice Terminal driver private structure.
895 @param Input The key will be input.
896
897 @retval TRUE If insert successfully.
898 @retval FALSE If Raw Data buffer is full before key insertion,
899 and the key is lost.
900
901 **/
902 BOOLEAN
903 RawFiFoInsertOneKey (
904 TERMINAL_DEV *TerminalDevice,
905 UINT8 Input
906 );
907
908 /**
909 Remove one pre-fetched key out of the Raw Data FIFO.
910
911 @param TerminalDevice Terminal driver private structure.
912 @param Output The key will be removed.
913
914 @retval TRUE If insert successfully.
915 @retval FALSE If Raw Data FIFO buffer is empty before remove operation.
916
917 **/
918 BOOLEAN
919 RawFiFoRemoveOneKey (
920 TERMINAL_DEV *TerminalDevice,
921 UINT8 *Output
922 );
923
924 /**
925 Clarify whether Raw Data FIFO buffer is empty.
926
927 @param TerminalDevice Terminal driver private structure
928
929 @retval TRUE If Raw Data FIFO buffer is empty.
930 @retval FALSE If Raw Data FIFO buffer is not empty.
931
932 **/
933 BOOLEAN
934 IsRawFiFoEmpty (
935 TERMINAL_DEV *TerminalDevice
936 );
937
938 /**
939 Clarify whether Raw Data FIFO buffer is full.
940
941 @param TerminalDevice Terminal driver private structure
942
943 @retval TRUE If Raw Data FIFO buffer is full.
944 @retval FALSE If Raw Data FIFO buffer is not full.
945
946 **/
947 BOOLEAN
948 IsRawFiFoFull (
949 TERMINAL_DEV *TerminalDevice
950 );
951
952 /**
953 Insert one pre-fetched key into the FIFO buffer.
954
955 @param EfiKeyFiFo Pointer to instance of EFI_KEY_FIFO.
956 @param Input The key will be input.
957
958 @retval TRUE If insert successfully.
959 @retval FALSE If FIFO buffer is full before key insertion,
960 and the key is lost.
961
962 **/
963 BOOLEAN
964 EfiKeyFiFoForNotifyInsertOneKey (
965 EFI_KEY_FIFO *EfiKeyFiFo,
966 EFI_INPUT_KEY *Input
967 );
968
969 /**
970 Remove one pre-fetched key out of the FIFO buffer.
971
972 @param EfiKeyFiFo Pointer to instance of EFI_KEY_FIFO.
973 @param Output The key will be removed.
974
975 @retval TRUE If insert successfully.
976 @retval FALSE If FIFO buffer is empty before remove operation.
977
978 **/
979 BOOLEAN
980 EfiKeyFiFoForNotifyRemoveOneKey (
981 EFI_KEY_FIFO *EfiKeyFiFo,
982 EFI_INPUT_KEY *Output
983 );
984
985 /**
986 Clarify whether FIFO buffer is empty.
987
988 @param EfiKeyFiFo Pointer to instance of EFI_KEY_FIFO.
989
990 @retval TRUE If FIFO buffer is empty.
991 @retval FALSE If FIFO buffer is not empty.
992
993 **/
994 BOOLEAN
995 IsEfiKeyFiFoForNotifyEmpty (
996 IN EFI_KEY_FIFO *EfiKeyFiFo
997 );
998
999 /**
1000 Clarify whether FIFO buffer is full.
1001
1002 @param EfiKeyFiFo Pointer to instance of EFI_KEY_FIFO.
1003
1004 @retval TRUE If FIFO buffer is full.
1005 @retval FALSE If FIFO buffer is not full.
1006
1007 **/
1008 BOOLEAN
1009 IsEfiKeyFiFoForNotifyFull (
1010 EFI_KEY_FIFO *EfiKeyFiFo
1011 );
1012
1013 /**
1014 Insert one pre-fetched key into the FIFO buffer.
1015
1016 @param TerminalDevice Terminal driver private structure.
1017 @param Key The key will be input.
1018
1019 @retval TRUE If insert successfully.
1020 @retval FALSE If FIFO buffer is full before key insertion,
1021 and the key is lost.
1022
1023 **/
1024 BOOLEAN
1025 EfiKeyFiFoInsertOneKey (
1026 TERMINAL_DEV *TerminalDevice,
1027 EFI_INPUT_KEY *Key
1028 );
1029
1030 /**
1031 Remove one pre-fetched key out of the FIFO buffer.
1032
1033 @param TerminalDevice Terminal driver private structure.
1034 @param Output The key will be removed.
1035
1036 @retval TRUE If insert successfully.
1037 @retval FALSE If FIFO buffer is empty before remove operation.
1038
1039 **/
1040 BOOLEAN
1041 EfiKeyFiFoRemoveOneKey (
1042 TERMINAL_DEV *TerminalDevice,
1043 EFI_INPUT_KEY *Output
1044 );
1045
1046 /**
1047 Clarify whether FIFO buffer is empty.
1048
1049 @param TerminalDevice Terminal driver private structure
1050
1051 @retval TRUE If FIFO buffer is empty.
1052 @retval FALSE If FIFO buffer is not empty.
1053
1054 **/
1055 BOOLEAN
1056 IsEfiKeyFiFoEmpty (
1057 TERMINAL_DEV *TerminalDevice
1058 );
1059
1060 /**
1061 Clarify whether FIFO buffer is full.
1062
1063 @param TerminalDevice Terminal driver private structure
1064
1065 @retval TRUE If FIFO buffer is full.
1066 @retval FALSE If FIFO buffer is not full.
1067
1068 **/
1069 BOOLEAN
1070 IsEfiKeyFiFoFull (
1071 TERMINAL_DEV *TerminalDevice
1072 );
1073
1074 /**
1075 Insert one pre-fetched key into the Unicode FIFO buffer.
1076
1077 @param TerminalDevice Terminal driver private structure.
1078 @param Input The key will be input.
1079
1080 @retval TRUE If insert successfully.
1081 @retval FALSE If Unicode FIFO buffer is full before key insertion,
1082 and the key is lost.
1083
1084 **/
1085 BOOLEAN
1086 UnicodeFiFoInsertOneKey (
1087 TERMINAL_DEV *TerminalDevice,
1088 UINT16 Input
1089 );
1090
1091 /**
1092 Remove one pre-fetched key out of the Unicode FIFO buffer.
1093 The caller should guarantee that Unicode FIFO buffer is not empty
1094 by IsUnicodeFiFoEmpty ().
1095
1096 @param TerminalDevice Terminal driver private structure.
1097 @param Output The key will be removed.
1098
1099 **/
1100 VOID
1101 UnicodeFiFoRemoveOneKey (
1102 TERMINAL_DEV *TerminalDevice,
1103 UINT16 *Output
1104 );
1105
1106 /**
1107 Clarify whether Unicode FIFO buffer is empty.
1108
1109 @param TerminalDevice Terminal driver private structure
1110
1111 @retval TRUE If Unicode FIFO buffer is empty.
1112 @retval FALSE If Unicode FIFO buffer is not empty.
1113
1114 **/
1115 BOOLEAN
1116 IsUnicodeFiFoEmpty (
1117 TERMINAL_DEV *TerminalDevice
1118 );
1119
1120 /**
1121 Clarify whether Unicode FIFO buffer is full.
1122
1123 @param TerminalDevice Terminal driver private structure
1124
1125 @retval TRUE If Unicode FIFO buffer is full.
1126 @retval FALSE If Unicode FIFO buffer is not full.
1127
1128 **/
1129 BOOLEAN
1130 IsUnicodeFiFoFull (
1131 TERMINAL_DEV *TerminalDevice
1132 );
1133
1134 /**
1135 Count Unicode FIFO buffer.
1136
1137 @param TerminalDevice Terminal driver private structure
1138
1139 @return The count in bytes of Unicode FIFO.
1140
1141 **/
1142 UINT8
1143 UnicodeFiFoGetKeyCount (
1144 TERMINAL_DEV *TerminalDevice
1145 );
1146
1147 /**
1148 Translate raw data into Unicode (according to different encode), and
1149 translate Unicode into key information. (according to different standard).
1150
1151 @param TerminalDevice Terminal driver private structure.
1152
1153 **/
1154 VOID
1155 TranslateRawDataToEfiKey (
1156 IN TERMINAL_DEV *TerminalDevice
1157 );
1158
1159 //
1160 // internal functions for PC ANSI
1161 //
1162
1163 /**
1164 Translate all raw data in the Raw FIFI into unicode, and insert
1165 them into Unicode FIFO.
1166
1167 @param TerminalDevice The terminal device.
1168
1169 **/
1170 VOID
1171 AnsiRawDataToUnicode (
1172 IN TERMINAL_DEV *TerminalDevice
1173 );
1174
1175 /**
1176 Converts a stream of Unicode characters from a terminal input device into EFI Keys that
1177 can be read through the Simple Input Protocol.
1178
1179 The table below shows the keyboard input mappings that this function supports.
1180 If the ESC sequence listed in one of the columns is presented, then it is translated
1181 into the coorespoding EFI Scan Code. If a matching sequence is not found, then the raw
1182 key strokes are converted into EFI Keys.
1183
1184 2 seconds are allowed for an ESC sequence to be completed. If the ESC sequence is not
1185 completed in 2 seconds, then the raw key strokes of the partial ESC sequence are
1186 converted into EFI Keys.
1187 There is one special input sequence that will force the system to reset.
1188 This is ESC R ESC r ESC R.
1189
1190 Symbols used in table below
1191 ===========================
1192 ESC = 0x1B
1193 CSI = 0x9B
1194 DEL = 0x7f
1195 ^ = CTRL
1196 +=========+======+===========+==========+==========+
1197 | | EFI | UEFI 2.0 | | |
1198 | | Scan | | VT100+ | |
1199 | KEY | Code | PC ANSI | VTUTF8 | VT100 |
1200 +=========+======+===========+==========+==========+
1201 | NULL | 0x00 | | | |
1202 | UP | 0x01 | ESC [ A | ESC [ A | ESC [ A |
1203 | DOWN | 0x02 | ESC [ B | ESC [ B | ESC [ B |
1204 | RIGHT | 0x03 | ESC [ C | ESC [ C | ESC [ C |
1205 | LEFT | 0x04 | ESC [ D | ESC [ D | ESC [ D |
1206 | HOME | 0x05 | ESC [ H | ESC h | ESC [ H |
1207 | END | 0x06 | ESC [ F | ESC k | ESC [ K |
1208 | INSERT | 0x07 | ESC [ @ | ESC + | ESC [ @ |
1209 | | | ESC [ L | | ESC [ L |
1210 | DELETE | 0x08 | ESC [ X | ESC - | ESC [ P |
1211 | PG UP | 0x09 | ESC [ I | ESC ? | ESC [ V |
1212 | | | | | ESC [ ? |
1213 | PG DOWN | 0x0A | ESC [ G | ESC / | ESC [ U |
1214 | | | | | ESC [ / |
1215 | F1 | 0x0B | ESC [ M | ESC 1 | ESC O P |
1216 | F2 | 0x0C | ESC [ N | ESC 2 | ESC O Q |
1217 | F3 | 0x0D | ESC [ O | ESC 3 | ESC O w |
1218 | F4 | 0x0E | ESC [ P | ESC 4 | ESC O x |
1219 | F5 | 0x0F | ESC [ Q | ESC 5 | ESC O t |
1220 | F6 | 0x10 | ESC [ R | ESC 6 | ESC O u |
1221 | F7 | 0x11 | ESC [ S | ESC 7 | ESC O q |
1222 | F8 | 0x12 | ESC [ T | ESC 8 | ESC O r |
1223 | F9 | 0x13 | ESC [ U | ESC 9 | ESC O p |
1224 | F10 | 0x14 | ESC [ V | ESC 0 | ESC O M |
1225 | Escape | 0x17 | ESC | ESC | ESC |
1226 | F11 | 0x15 | | ESC ! | |
1227 | F12 | 0x16 | | ESC @ | |
1228 +=========+======+===========+==========+==========+
1229
1230 Special Mappings
1231 ================
1232 ESC R ESC r ESC R = Reset System
1233
1234
1235 @param TerminalDevice The terminal device to use to translate raw input into EFI Keys
1236
1237 **/
1238 VOID
1239 UnicodeToEfiKey (
1240 IN TERMINAL_DEV *TerminalDevice
1241 );
1242
1243 /**
1244 Check if input string is valid Ascii string, valid EFI control characters
1245 or valid text graphics.
1246
1247 @param TerminalDevice The terminal device.
1248 @param WString The input string.
1249
1250 @retval EFI_UNSUPPORTED If not all input characters are valid.
1251 @retval EFI_SUCCESS If all input characters are valid.
1252
1253 **/
1254 EFI_STATUS
1255 AnsiTestString (
1256 IN TERMINAL_DEV *TerminalDevice,
1257 IN CHAR16 *WString
1258 );
1259
1260 //
1261 // internal functions for VTUTF8
1262 //
1263
1264 /**
1265 Translate all VT-UTF8 characters in the Raw FIFI into unicode characters,
1266 and insert them into Unicode FIFO.
1267
1268 @param VtUtf8Device The terminal device.
1269
1270 **/
1271 VOID
1272 VTUTF8RawDataToUnicode (
1273 IN TERMINAL_DEV *VtUtf8Device
1274 );
1275
1276 /**
1277 Check if input string is valid VT-UTF8 string.
1278
1279 @param TerminalDevice The terminal device.
1280 @param WString The input string.
1281
1282 @retval EFI_SUCCESS If all input characters are valid.
1283
1284 **/
1285 EFI_STATUS
1286 VTUTF8TestString (
1287 IN TERMINAL_DEV *TerminalDevice,
1288 IN CHAR16 *WString
1289 );
1290
1291 /**
1292 Translate one Unicode character into VT-UTF8 characters.
1293
1294 UTF8 Encoding Table
1295 Bits per Character | Unicode Character Range | Unicode Binary Encoding | UTF8 Binary Encoding
1296 0-7 | 0x0000 - 0x007F | 00000000 0xxxxxxx | 0xxxxxxx
1297 8-11 | 0x0080 - 0x07FF | 00000xxx xxxxxxxx | 110xxxxx 10xxxxxx
1298 12-16 | 0x0800 - 0xFFFF | xxxxxxxx xxxxxxxx | 1110xxxx 10xxxxxx 10xxxxxx
1299
1300
1301 @param Unicode Unicode character need translating.
1302 @param Utf8Char Return VT-UTF8 character set.
1303 @param ValidBytes The count of valid VT-UTF8 characters. If
1304 ValidBytes is zero, no valid VT-UTF8 returned.
1305
1306 **/
1307 VOID
1308 UnicodeToUtf8 (
1309 IN CHAR16 Unicode,
1310 OUT UTF8_CHAR *Utf8Char,
1311 OUT UINT8 *ValidBytes
1312 );
1313
1314 /**
1315 Get one valid VT-UTF8 characters set from Raw Data FIFO.
1316
1317 @param Utf8Device The terminal device.
1318 @param Utf8Char Returned valid VT-UTF8 characters set.
1319 @param ValidBytes The count of returned VT-VTF8 characters.
1320 If ValidBytes is zero, no valid VT-UTF8 returned.
1321
1322 **/
1323 VOID
1324 GetOneValidUtf8Char (
1325 IN TERMINAL_DEV *Utf8Device,
1326 OUT UTF8_CHAR *Utf8Char,
1327 OUT UINT8 *ValidBytes
1328 );
1329
1330 /**
1331 Translate VT-UTF8 characters into one Unicode character.
1332
1333 UTF8 Encoding Table
1334 Bits per Character | Unicode Character Range | Unicode Binary Encoding | UTF8 Binary Encoding
1335 0-7 | 0x0000 - 0x007F | 00000000 0xxxxxxx | 0xxxxxxx
1336 8-11 | 0x0080 - 0x07FF | 00000xxx xxxxxxxx | 110xxxxx 10xxxxxx
1337 12-16 | 0x0800 - 0xFFFF | xxxxxxxx xxxxxxxx | 1110xxxx 10xxxxxx 10xxxxxx
1338
1339
1340 @param Utf8Char VT-UTF8 character set needs translating.
1341 @param ValidBytes The count of valid VT-UTF8 characters.
1342 @param UnicodeChar Returned unicode character.
1343
1344 **/
1345 VOID
1346 Utf8ToUnicode (
1347 IN UTF8_CHAR Utf8Char,
1348 IN UINT8 ValidBytes,
1349 OUT CHAR16 *UnicodeChar
1350 );
1351
1352 //
1353 // functions for boxdraw unicode
1354 //
1355
1356 /**
1357 Detects if a Unicode char is for Box Drawing text graphics.
1358
1359 @param Graphic Unicode char to test.
1360 @param PcAnsi Optional pointer to return PCANSI equivalent of
1361 Graphic.
1362 @param Ascii Optional pointer to return ASCII equivalent of
1363 Graphic.
1364
1365 @retval TRUE If Graphic is a supported Unicode Box Drawing character.
1366
1367 **/
1368 BOOLEAN
1369 TerminalIsValidTextGraphics (
1370 IN CHAR16 Graphic,
1371 OUT CHAR8 *PcAnsi, OPTIONAL
1372 OUT CHAR8 *Ascii OPTIONAL
1373 );
1374
1375 /**
1376 Detects if a valid ASCII char.
1377
1378 @param Ascii An ASCII character.
1379
1380 @retval TRUE If it is a valid ASCII character.
1381 @retval FALSE If it is not a valid ASCII character.
1382
1383 **/
1384 BOOLEAN
1385 TerminalIsValidAscii (
1386 IN CHAR16 Ascii
1387 );
1388
1389 /**
1390 Detects if a valid EFI control character.
1391
1392 @param CharC An input EFI Control character.
1393
1394 @retval TRUE If it is a valid EFI control character.
1395 @retval FALSE If it is not a valid EFI control character.
1396
1397 **/
1398 BOOLEAN
1399 TerminalIsValidEfiCntlChar (
1400 IN CHAR16 CharC
1401 );
1402
1403 /**
1404 Check if the device supports hot-plug through its device path.
1405
1406 This function could be updated to check more types of Hot Plug devices.
1407 Currently, it checks USB and PCCard device.
1408
1409 @param DevicePath Pointer to device's device path.
1410
1411 @retval TRUE The devcie is a hot-plug device
1412 @retval FALSE The devcie is not a hot-plug device.
1413
1414 **/
1415 BOOLEAN
1416 IsHotPlugDevice (
1417 IN EFI_DEVICE_PATH_PROTOCOL *DevicePath
1418 );
1419
1420 /**
1421 Timer handler to poll the key from serial.
1422
1423 @param Event Indicates the event that invoke this function.
1424 @param Context Indicates the calling context.
1425 **/
1426 VOID
1427 EFIAPI
1428 TerminalConInTimerHandler (
1429 IN EFI_EVENT Event,
1430 IN VOID *Context
1431 );
1432
1433
1434 /**
1435 Process key notify.
1436
1437 @param Event Indicates the event that invoke this function.
1438 @param Context Indicates the calling context.
1439 **/
1440 VOID
1441 EFIAPI
1442 KeyNotifyProcessHandler (
1443 IN EFI_EVENT Event,
1444 IN VOID *Context
1445 );
1446
1447 #endif