]> git.proxmox.com Git - mirror_edk2.git/blob - MdeModulePkg/Universal/Console/TerminalDxe/Terminal.h
Clean codes per ECC for TerminalDxe module.
[mirror_edk2.git] / MdeModulePkg / Universal / Console / TerminalDxe / Terminal.h
1 /** @file
2 Header file for Terminal driver.
3
4 Copyright (c) 2006 - 2008, Intel Corporation. <BR>
5 All rights reserved. This program and the accompanying materials
6 are licensed and made available under the terms and conditions of the BSD License
7 which accompanies this distribution. The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.php
9
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
12
13 **/
14
15 #ifndef _TERMINAL_H_
16 #define _TERMINAL_H_
17
18
19 #include <PiDxe.h>
20 #include <Protocol/SimpleTextOut.h>
21 #include <Protocol/SerialIo.h>
22 #include <Guid/GlobalVariable.h>
23 #include <Protocol/DevicePath.h>
24 #include <Protocol/SimpleTextIn.h>
25 #include <Protocol/SimpleTextInEx.h>
26 #include <Guid/HotPlugDevice.h>
27 #include <Guid/PcAnsi.h>
28 #include <Library/DebugLib.h>
29 #include <Library/UefiDriverEntryPoint.h>
30 #include <Library/UefiLib.h>
31 #include <Library/ReportStatusCodeLib.h>
32 #include <Library/BaseMemoryLib.h>
33 #include <Library/MemoryAllocationLib.h>
34 #include <Library/UefiBootServicesTableLib.h>
35 #include <Library/UefiRuntimeServicesTableLib.h>
36 #include <Library/DevicePathLib.h>
37 #include <Library/PcdLib.h>
38 #include <Library/BaseLib.h>
39
40
41 #define RAW_FIFO_MAX_NUMBER 256
42 #define FIFO_MAX_NUMBER 128
43
44 typedef struct {
45 UINT8 Head;
46 UINT8 Tail;
47 UINT8 Data[RAW_FIFO_MAX_NUMBER + 1];
48 } RAW_DATA_FIFO;
49
50 typedef struct {
51 UINT8 Head;
52 UINT8 Tail;
53 UINT16 Data[FIFO_MAX_NUMBER + 1];
54 } UNICODE_FIFO;
55
56 typedef struct {
57 UINT8 Head;
58 UINT8 Tail;
59 EFI_INPUT_KEY Data[FIFO_MAX_NUMBER + 1];
60 } EFI_KEY_FIFO;
61
62 #define TERMINAL_DEV_SIGNATURE EFI_SIGNATURE_32 ('t', 'm', 'n', 'l')
63
64 #define TERMINAL_CONSOLE_IN_EX_NOTIFY_SIGNATURE EFI_SIGNATURE_32 ('t', 'm', 'e', 'n')
65
66 typedef struct _TERMINAL_CONSOLE_IN_EX_NOTIFY {
67 UINTN Signature;
68 EFI_HANDLE NotifyHandle;
69 EFI_KEY_DATA KeyData;
70 EFI_KEY_NOTIFY_FUNCTION KeyNotificationFn;
71 LIST_ENTRY NotifyEntry;
72 } TERMINAL_CONSOLE_IN_EX_NOTIFY;
73 typedef struct {
74 UINTN Signature;
75 EFI_HANDLE Handle;
76 UINT8 TerminalType;
77 EFI_SERIAL_IO_PROTOCOL *SerialIo;
78 EFI_DEVICE_PATH_PROTOCOL *DevicePath;
79 EFI_SIMPLE_TEXT_INPUT_PROTOCOL SimpleInput;
80 EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL SimpleTextOutput;
81 EFI_SIMPLE_TEXT_OUTPUT_MODE SimpleTextOutputMode;
82 UINTN SerialInTimeOut;
83 RAW_DATA_FIFO RawFiFo;
84 UNICODE_FIFO UnicodeFiFo;
85 EFI_KEY_FIFO EfiKeyFiFo;
86 EFI_UNICODE_STRING_TABLE *ControllerNameTable;
87 EFI_EVENT TwoSecondTimeOut;
88 UINT32 InputState;
89 UINT32 ResetState;
90
91 //
92 // Esc could not be output to the screen by user,
93 // but the terminal driver need to output it to
94 // the terminal emulation software to send control sequence.
95 // This boolean is used by the terminal driver only
96 // to indicate whether the Esc could be sent or not.
97 //
98 BOOLEAN OutputEscChar;
99 EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL SimpleInputEx;
100 LIST_ENTRY NotifyList;
101 } TERMINAL_DEV;
102
103 #define INPUT_STATE_DEFAULT 0x00
104 #define INPUT_STATE_ESC 0x01
105 #define INPUT_STATE_CSI 0x02
106 #define INPUT_STATE_LEFTOPENBRACKET 0x04
107 #define INPUT_STATE_O 0x08
108 #define INPUT_STATE_2 0x10
109
110 #define RESET_STATE_DEFAULT 0x00
111 #define RESET_STATE_ESC_R 0x01
112 #define RESET_STATE_ESC_R_ESC_r 0x02
113
114 #define TERMINAL_CON_IN_DEV_FROM_THIS(a) CR (a, TERMINAL_DEV, SimpleInput, TERMINAL_DEV_SIGNATURE)
115 #define TERMINAL_CON_OUT_DEV_FROM_THIS(a) CR (a, TERMINAL_DEV, SimpleTextOutput, TERMINAL_DEV_SIGNATURE)
116 #define TERMINAL_CON_IN_EX_DEV_FROM_THIS(a) CR (a, TERMINAL_DEV, SimpleInputEx, TERMINAL_DEV_SIGNATURE)
117
118 typedef union {
119 UINT8 Utf8_1;
120 UINT8 Utf8_2[2];
121 UINT8 Utf8_3[3];
122 } UTF8_CHAR;
123
124 #define PCANSITYPE 0
125 #define VT100TYPE 1
126 #define VT100PLUSTYPE 2
127 #define VTUTF8TYPE 3
128
129 #define LEFTOPENBRACKET 0x5b // '['
130 #define ACAP 0x41
131 #define BCAP 0x42
132 #define CCAP 0x43
133 #define DCAP 0x44
134
135 #define MODE0_COLUMN_COUNT 80
136 #define MODE0_ROW_COUNT 25
137
138 #define MODE1_COLUMN_COUNT 80
139 #define MODE1_ROW_COUNT 50
140
141 #define MODE2_COLUMN_COUNT 100
142 #define MODE2_ROW_COUNT 31
143
144 #define BACKSPACE 8
145 #define ESC 27
146 #define CSI 0x9B
147 #define DEL 127
148 #define BRIGHT_CONTROL_OFFSET 2
149 #define FOREGROUND_CONTROL_OFFSET 6
150 #define BACKGROUND_CONTROL_OFFSET 11
151 #define ROW_OFFSET 2
152 #define COLUMN_OFFSET 5
153
154 typedef struct {
155 UINT16 Unicode;
156 CHAR8 PcAnsi;
157 CHAR8 Ascii;
158 } UNICODE_TO_CHAR;
159
160 //
161 // Global Variables
162 //
163 extern EFI_DRIVER_BINDING_PROTOCOL gTerminalDriverBinding;
164 extern EFI_COMPONENT_NAME_PROTOCOL gTerminalComponentName;
165 extern EFI_COMPONENT_NAME2_PROTOCOL gTerminalComponentName2;
166
167 extern EFI_GUID gSimpleTextInExNotifyGuid;
168
169 /**
170 The user Entry Point for module Terminal. The user code starts with this function.
171
172 @param[in] ImageHandle The firmware allocated handle for the EFI image.
173 @param[in] SystemTable A pointer to the EFI System Table.
174
175 @retval EFI_SUCCESS The entry point is executed successfully.
176 @retval other Some error occurs when executing this entry point.
177
178 **/
179 EFI_STATUS
180 EFIAPI
181 InitializeTerminal (
182 IN EFI_HANDLE ImageHandle,
183 IN EFI_SYSTEM_TABLE *SystemTable
184 )
185 ;
186
187 /**
188 Implements EFI_SIMPLE_TEXT_INPUT_PROTOCOL.Reset().
189 This driver only perform dependent serial device reset regardless of
190 the value of ExtendeVerification
191
192 @param This Indicates the calling context.
193 @param ExtendedVerification Skip by this driver.
194
195 @return EFI_SUCCESS
196 @return The reset operation succeeds.
197 @return EFI_DEVICE_ERROR
198 @return The dependent serial port reset fails.
199
200 **/
201 EFI_STATUS
202 EFIAPI
203 TerminalConInReset (
204 IN EFI_SIMPLE_TEXT_INPUT_PROTOCOL *This,
205 IN BOOLEAN ExtendedVerification
206 )
207 ;
208
209
210 /**
211 Implements EFI_SIMPLE_TEXT_INPUT_PROTOCOL.ReadKeyStroke().
212
213 @param This Indicates the calling context.
214 @param Key A pointer to a buffer that is filled in with the
215 keystroke information for the key that was sent
216 from terminal.
217
218 @return EFI_SUCCESS
219 @return The keystroke information is returned successfully.
220 @return EFI_NOT_READY
221 @return There is no keystroke data available.
222 @return EFI_DEVICE_ERROR
223 @return The dependent serial device encounters error.
224
225 **/
226 EFI_STATUS
227 EFIAPI
228 TerminalConInReadKeyStroke (
229 IN EFI_SIMPLE_TEXT_INPUT_PROTOCOL *This,
230 OUT EFI_INPUT_KEY *Key
231 )
232 ;
233
234
235 /**
236
237 @param RegsiteredData A pointer to a buffer that is filled in with the
238 keystroke state data for the key that was
239 registered.
240 @param InputData A pointer to a buffer that is filled in with the
241 keystroke state data for the key that was
242 pressed.
243
244 @retval TRUE Key be pressed matches a registered key.
245 @retval FLASE Match failed.
246
247 **/
248 BOOLEAN
249 IsKeyRegistered (
250 IN EFI_KEY_DATA *RegsiteredData,
251 IN EFI_KEY_DATA *InputData
252 )
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 @return none.
263
264 **/
265 VOID
266 EFIAPI
267 TerminalConInWaitForKeyEx (
268 IN EFI_EVENT Event,
269 IN VOID *Context
270 )
271 ;
272
273 //
274 // Simple Text Input Ex protocol prototypes
275 //
276
277 /**
278 Reset the input device and optionaly 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 /**
297 Reads the next keystroke from the input device. The WaitForKey Event can
298 be used to test for existance of a keystroke via WaitForEvent () call.
299
300 @param This Protocol instance pointer.
301 @param KeyData A pointer to a buffer that is filled in with the
302 keystroke state data for the key that was
303 pressed.
304
305 @retval EFI_SUCCESS The keystroke information was returned.
306 @retval EFI_NOT_READY There was no keystroke data availiable.
307 @retval EFI_DEVICE_ERROR The keystroke information was not returned due
308 to hardware errors.
309 @retval EFI_INVALID_PARAMETER KeyData is NULL.
310
311 **/
312 EFI_STATUS
313 EFIAPI
314 TerminalConInReadKeyStrokeEx (
315 IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *This,
316 OUT EFI_KEY_DATA *KeyData
317 )
318 ;
319
320 /**
321 Set certain state for the input device.
322
323 @param This Protocol instance pointer.
324 @param KeyToggleState A pointer to the EFI_KEY_TOGGLE_STATE to set the
325 state for the input device.
326
327 @retval EFI_SUCCESS The device state was set successfully.
328 @retval EFI_DEVICE_ERROR The device is not functioning correctly and
329 could not have the setting adjusted.
330 @retval EFI_UNSUPPORTED The device does not have the ability to set its
331 state.
332 @retval EFI_INVALID_PARAMETER KeyToggleState is NULL.
333
334 **/
335 EFI_STATUS
336 EFIAPI
337 TerminalConInSetState (
338 IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *This,
339 IN EFI_KEY_TOGGLE_STATE *KeyToggleState
340 )
341 ;
342
343 /**
344 Register a notification function for a particular keystroke for the input device.
345
346 @param This Protocol instance pointer.
347 @param KeyData A pointer to a buffer that is filled in with the
348 keystroke information data for the key that was
349 pressed.
350 @param KeyNotificationFunction Points to the function to be called when the key
351 sequence is typed specified by KeyData.
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 EFI_HANDLE *NotifyHandle
369 )
370 ;
371
372 /**
373 Remove a registered notification function from a particular keystroke.
374
375 @param This Protocol instance pointer.
376 @param NotificationHandle The handle of the notification function being
377 unregistered.
378
379 @retval EFI_SUCCESS The notification function was unregistered
380 successfully.
381 @retval EFI_INVALID_PARAMETER The NotificationHandle is invalid.
382 @retval EFI_NOT_FOUND Can not find the matching entry in database.
383
384 **/
385 EFI_STATUS
386 EFIAPI
387 TerminalConInUnregisterKeyNotify (
388 IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *This,
389 IN EFI_HANDLE NotificationHandle
390 )
391 ;
392
393 /**
394 Event notification function for EFI_SIMPLE_TEXT_INPUT_PROTOCOL.WaitForKey event
395 Signal the event if there is key available
396
397 @param Event Indicates the event that invoke this function.
398 @param Context Indicates the calling context.
399
400 @return None
401
402 **/
403 VOID
404 EFIAPI
405 TerminalConInWaitForKey (
406 IN EFI_EVENT Event,
407 IN VOID *Context
408 )
409 ;
410
411 /**
412 Implements EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.Reset().
413 If ExtendeVerification is TRUE, then perform dependent serial device reset,
414 and set display mode to mode 0.
415 If ExtendedVerification is FALSE, only set display mode to mode 0.
416
417 @param This Indicates the calling context.
418 @param ExtendedVerification Indicates that the driver may perform a more
419 exhaustive verification operation of the device
420 during reset.
421
422 @return EFI_SUCCESS
423 @return The reset operation succeeds.
424 @return EFI_DEVICE_ERROR
425 @return The terminal is not functioning correctly or the serial port reset fails.
426
427 **/
428 EFI_STATUS
429 EFIAPI
430 TerminalConOutReset (
431 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,
432 IN BOOLEAN ExtendedVerification
433 )
434 ;
435
436 /**
437 Implements EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.OutputString().
438 The Unicode string will be converted to terminal expressible data stream
439 and send to terminal via serial port.
440
441 @param This Indicates the calling context.
442 @param WString The Null-terminated Unicode string to be displayed
443 on the terminal screen.
444
445 @return EFI_SUCCESS The string is output successfully.
446 @return EFI_DEVICE_ERROR The serial port fails to send the string out.
447 @return EFI_WARN_UNKNOWN_GLYPH Indicates that some of the characters in the Unicode string could not
448 be rendered and are skipped.
449 @return EFI_UNSUPPORTED
450
451 **/
452 EFI_STATUS
453 EFIAPI
454 TerminalConOutOutputString (
455 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,
456 IN CHAR16 *WString
457 )
458 ;
459
460 /**
461 Implements EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.TestString().
462 If one of the characters in the *Wstring is
463 neither valid Unicode drawing characters,
464 not ASCII code, then this function will return
465 EFI_UNSUPPORTED.
466
467 @param This Indicates the calling context.
468 @param WString The Null-terminated Unicode string to be tested.
469
470 @return EFI_SUCCESS The terminal is capable of rendering the output string.
471 @return EFI_UNSUPPORTED Some of the characters in the Unicode string cannot be rendered.
472
473 **/
474 EFI_STATUS
475 EFIAPI
476 TerminalConOutTestString (
477 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,
478 IN CHAR16 *WString
479 )
480 ;
481
482 /**
483 Implements EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.QueryMode().
484 It returns information for an available text mode
485 that the terminal supports.
486 In this driver, we support text mode 80x25 (mode 0),
487 80x50 (mode 1), 100x31 (mode 2).
488
489 @param This Indicates the calling context.
490 @param ModeNumber The mode number to return information on.
491 @param Columns The returned columns of the requested mode.
492 @param Rows The returned rows of the requested mode.
493
494 @return EFI_SUCCESS The requested mode information is returned.
495 @return EFI_UNSUPPORTED The mode number is not valid.
496 @return EFI_DEVICE_ERROR
497
498 **/
499 EFI_STATUS
500 EFIAPI
501 TerminalConOutQueryMode (
502 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,
503 IN UINTN ModeNumber,
504 OUT UINTN *Columns,
505 OUT UINTN *Rows
506 )
507 ;
508
509 /**
510 Implements EFI_SIMPLE_TEXT_OUT.SetMode().
511 Set the terminal to a specified display mode.
512 In this driver, we only support mode 0.
513
514 @param This Indicates the calling context.
515 @param ModeNumber The text mode to set.
516
517 @return EFI_SUCCESS The requested text mode is set.
518 @return EFI_DEVICE_ERROR The requested text mode cannot be set
519 because of serial device error.
520 @return EFI_UNSUPPORTED The text mode number is not valid.
521
522 **/
523 EFI_STATUS
524 EFIAPI
525 TerminalConOutSetMode (
526 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,
527 IN UINTN ModeNumber
528 )
529 ;
530
531 /**
532 Implements EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.SetAttribute().
533
534 @param This Indicates the calling context.
535 @param Attribute The attribute to set. Only bit0..6 are valid, all other bits
536 are undefined and must be zero.
537
538 @return EFI_SUCCESS The requested attribute is set.
539 @return EFI_DEVICE_ERROR The requested attribute cannot be set due to serial port error.
540 @return EFI_UNSUPPORTED The attribute requested is not defined by EFI spec.
541
542 **/
543 EFI_STATUS
544 EFIAPI
545 TerminalConOutSetAttribute (
546 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,
547 IN UINTN Attribute
548 )
549 ;
550
551 /**
552 Implements EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.ClearScreen().
553 It clears the ANSI terminal's display to the
554 currently selected background color.
555
556 @param This Indicates the calling context.
557
558 @return EFI_SUCCESS The operation completed successfully.
559 @return EFI_DEVICE_ERROR The terminal screen cannot be cleared due to serial port error.
560 @return EFI_UNSUPPORTED The terminal is not in a valid display mode.
561
562 **/
563 EFI_STATUS
564 EFIAPI
565 TerminalConOutClearScreen (
566 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This
567 )
568 ;
569
570 /**
571 Implements EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.SetCursorPosition().
572
573 @param This Indicates the calling context.
574 @param Column The row to set cursor to.
575 @param Row The column to set cursor to.
576
577 @return EFI_SUCCESS The operation completed successfully.
578 @return EFI_DEVICE_ERROR The request fails due to serial port error.
579 @return EFI_UNSUPPORTED The terminal is not in a valid text mode, or the cursor position
580 is invalid for current mode.
581
582 **/
583 EFI_STATUS
584 EFIAPI
585 TerminalConOutSetCursorPosition (
586 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,
587 IN UINTN Column,
588 IN UINTN Row
589 )
590 ;
591
592 /**
593 Implements SIMPLE_TEXT_OUTPUT.EnableCursor().
594 In this driver, the cursor cannot be hidden.
595
596 @param This Indicates the calling context.
597 @param Visible If TRUE, the cursor is set to be visible,
598 If FALSE, the cursor is set to be invisible.
599
600 @return EFI_SUCCESS The request is valid.
601 @return EFI_UNSUPPORTED The terminal does not support cursor hidden.
602
603 **/
604 EFI_STATUS
605 EFIAPI
606 TerminalConOutEnableCursor (
607 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,
608 IN BOOLEAN Visible
609 )
610 ;
611
612 EFI_STATUS
613 EFIAPI
614 TerminalDriverBindingSupported (
615 IN EFI_DRIVER_BINDING_PROTOCOL *This,
616 IN EFI_HANDLE Controller,
617 IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
618 );
619
620 EFI_STATUS
621 EFIAPI
622 TerminalDriverBindingStart (
623 IN EFI_DRIVER_BINDING_PROTOCOL *This,
624 IN EFI_HANDLE Controller,
625 IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
626 );
627
628 EFI_STATUS
629 EFIAPI
630 TerminalDriverBindingStop (
631 IN EFI_DRIVER_BINDING_PROTOCOL *This,
632 IN EFI_HANDLE Controller,
633 IN UINTN NumberOfChildren,
634 IN EFI_HANDLE *ChildHandleBuffer
635 );
636
637 /**
638 Retrieves a Unicode string that is the user readable name of the driver.
639
640 This function retrieves the user readable name of a driver in the form of a
641 Unicode string. If the driver specified by This has a user readable name in
642 the language specified by Language, then a pointer to the driver name is
643 returned in DriverName, and EFI_SUCCESS is returned. If the driver specified
644 by This does not support the language specified by Language,
645 then EFI_UNSUPPORTED is returned.
646
647 @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
648 EFI_COMPONENT_NAME_PROTOCOL instance.
649
650 @param Language[in] A pointer to a Null-terminated ASCII string
651 array indicating the language. This is the
652 language of the driver name that the caller is
653 requesting, and it must match one of the
654 languages specified in SupportedLanguages. The
655 number of languages supported by a driver is up
656 to the driver writer. Language is specified
657 in RFC 3066 or ISO 639-2 language code format.
658
659 @param DriverName[out] A pointer to the Unicode string to return.
660 This Unicode string is the name of the
661 driver specified by This in the language
662 specified by Language.
663
664 @retval EFI_SUCCESS The Unicode string for the Driver specified by
665 This and the language specified by Language was
666 returned in DriverName.
667
668 @retval EFI_INVALID_PARAMETER Language is NULL.
669
670 @retval EFI_INVALID_PARAMETER DriverName is NULL.
671
672 @retval EFI_UNSUPPORTED The driver specified by This does not support
673 the language specified by Language.
674
675 **/
676 EFI_STATUS
677 EFIAPI
678 TerminalComponentNameGetDriverName (
679 IN EFI_COMPONENT_NAME_PROTOCOL *This,
680 IN CHAR8 *Language,
681 OUT CHAR16 **DriverName
682 );
683
684
685 /**
686 Retrieves a Unicode string that is the user readable name of the controller
687 that is being managed by a driver.
688
689 This function retrieves the user readable name of the controller specified by
690 ControllerHandle and ChildHandle in the form of a Unicode string. If the
691 driver specified by This has a user readable name in the language specified by
692 Language, then a pointer to the controller name is returned in ControllerName,
693 and EFI_SUCCESS is returned. If the driver specified by This is not currently
694 managing the controller specified by ControllerHandle and ChildHandle,
695 then EFI_UNSUPPORTED is returned. If the driver specified by This does not
696 support the language specified by Language, then EFI_UNSUPPORTED is returned.
697
698 @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
699 EFI_COMPONENT_NAME_PROTOCOL instance.
700
701 @param ControllerHandle[in] The handle of a controller that the driver
702 specified by This is managing. This handle
703 specifies the controller whose name is to be
704 returned.
705
706 @param ChildHandle[in] The handle of the child controller to retrieve
707 the name of. This is an optional parameter that
708 may be NULL. It will be NULL for device
709 drivers. It will also be NULL for a bus drivers
710 that wish to retrieve the name of the bus
711 controller. It will not be NULL for a bus
712 driver that wishes to retrieve the name of a
713 child controller.
714
715 @param Language[in] A pointer to a Null-terminated ASCII string
716 array indicating the language. This is the
717 language of the driver name that the caller is
718 requesting, and it must match one of the
719 languages specified in SupportedLanguages. The
720 number of languages supported by a driver is up
721 to the driver writer. Language is specified in
722 RFC 3066 or ISO 639-2 language code format.
723
724 @param ControllerName[out] A pointer to the Unicode string to return.
725 This Unicode string is the name of the
726 controller specified by ControllerHandle and
727 ChildHandle in the language specified by
728 Language from the point of view of the driver
729 specified by This.
730
731 @retval EFI_SUCCESS The Unicode string for the user readable name in
732 the language specified by Language for the
733 driver specified by This was returned in
734 DriverName.
735
736 @retval EFI_INVALID_PARAMETER ControllerHandle is not a valid EFI_HANDLE.
737
738 @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid
739 EFI_HANDLE.
740
741 @retval EFI_INVALID_PARAMETER Language is NULL.
742
743 @retval EFI_INVALID_PARAMETER ControllerName is NULL.
744
745 @retval EFI_UNSUPPORTED The driver specified by This is not currently
746 managing the controller specified by
747 ControllerHandle and ChildHandle.
748
749 @retval EFI_UNSUPPORTED The driver specified by This does not support
750 the language specified by Language.
751
752 **/
753 EFI_STATUS
754 EFIAPI
755 TerminalComponentNameGetControllerName (
756 IN EFI_COMPONENT_NAME_PROTOCOL *This,
757 IN EFI_HANDLE ControllerHandle,
758 IN EFI_HANDLE ChildHandle OPTIONAL,
759 IN CHAR8 *Language,
760 OUT CHAR16 **ControllerName
761 );
762
763
764 //
765 // internal functions
766 //
767
768 /**
769 Check for a pending key in the Efi Key FIFO or Serial device buffer.
770
771 @param This Indicates the calling context.
772
773 @return EFI_SUCCESS
774 @return There is key pending.
775 @return EFI_NOT_READY
776 @return There is no key pending.
777 @return EFI_DEVICE_ERROR
778
779 **/
780 EFI_STATUS
781 TerminalConInCheckForKey (
782 IN EFI_SIMPLE_TEXT_INPUT_PROTOCOL *This
783 )
784 ;
785
786 VOID
787 TerminalUpdateConsoleDevVariable (
788 IN CHAR16 *VariableName,
789 IN EFI_DEVICE_PATH_PROTOCOL *ParentDevicePath
790 )
791 ;
792
793 /**
794 Remove console device variable.
795
796 @param VariableName A pointer to the variable name.
797 @param ParentDevicePath A pointer to the parent device path.
798
799 @return None.
800
801 **/
802 VOID
803 TerminalRemoveConsoleDevVariable (
804 IN CHAR16 *VariableName,
805 IN EFI_DEVICE_PATH_PROTOCOL *ParentDevicePath
806 )
807 ;
808
809 /**
810 Read the EFI variable (VendorGuid/Name) and return a dynamically allocated
811 buffer, and the size of the buffer. On failure return NULL.
812
813 @param Name String part of EFI variable name
814 @param VendorGuid GUID part of EFI variable name
815 @param VariableSize Returns the size of the EFI variable that was read
816
817 @return Dynamically allocated memory that contains a copy of the EFI variable.
818 @return Caller is repsoncible freeing the buffer.
819 @retval NULL Variable was not read
820
821 **/
822 VOID *
823 TerminalGetVariableAndSize (
824 IN CHAR16 *Name,
825 IN EFI_GUID *VendorGuid,
826 OUT UINTN *VariableSize
827 )
828 ;
829
830 EFI_STATUS
831 SetTerminalDevicePath (
832 IN UINT8 TerminalType,
833 IN EFI_DEVICE_PATH_PROTOCOL *ParentDevicePath,
834 OUT EFI_DEVICE_PATH_PROTOCOL **TerminalDevicePath
835 )
836 ;
837
838 VOID
839 InitializeRawFiFo (
840 IN TERMINAL_DEV *TerminalDevice
841 )
842 ;
843
844 VOID
845 InitializeUnicodeFiFo (
846 IN TERMINAL_DEV *TerminalDevice
847 )
848 ;
849
850 VOID
851 InitializeEfiKeyFiFo (
852 IN TERMINAL_DEV *TerminalDevice
853 )
854 ;
855
856 /**
857 Get one key out of serial buffer.
858
859 @param SerialIo Serial I/O protocl attached to the serial device.
860 @param Input The fetched key.
861
862 @return EFI_NOT_READY If serial buffer is empty.
863 @return EFI_DEVICE_ERROR If reading serial buffer encounter error.
864 @return EFI_SUCCESS If reading serial buffer successfully, put
865 the fetched key to the parameter output.
866
867 **/
868 EFI_STATUS
869 GetOneKeyFromSerial (
870 EFI_SERIAL_IO_PROTOCOL *SerialIo,
871 UINT8 *Input
872 )
873 ;
874
875 /**
876 Insert one byte raw data into the Raw Data FIFO.
877
878 @param TerminalDevice Terminal driver private structure.
879 @param Input The key will be input.
880
881 @return TRUE If insert successfully.
882 @return FLASE If Raw Data buffer is full before key insertion,
883 and the key is lost.
884
885 **/
886 BOOLEAN
887 RawFiFoInsertOneKey (
888 TERMINAL_DEV *TerminalDevice,
889 UINT8 Input
890 )
891 ;
892
893 /**
894 Remove one pre-fetched key out of the Raw Data FIFO.
895
896 @param TerminalDevice Terminal driver private structure.
897 @param Output The key will be removed.
898
899 @return TRUE If insert successfully.
900 @return FLASE If Raw Data FIFO buffer is empty before remove operation.
901
902 **/
903 BOOLEAN
904 RawFiFoRemoveOneKey (
905 TERMINAL_DEV *TerminalDevice,
906 UINT8 *Output
907 )
908 ;
909
910 /**
911 Clarify whether Raw Data FIFO buffer is empty.
912
913 @param TerminalDevice Terminal driver private structure
914
915 @return TRUE If Raw Data FIFO buffer is empty.
916 @return FLASE If Raw Data FIFO buffer is not empty.
917
918 **/
919 BOOLEAN
920 IsRawFiFoEmpty (
921 TERMINAL_DEV *TerminalDevice
922 )
923 ;
924
925 /**
926 Clarify whether Raw Data FIFO buffer is full.
927
928 @param TerminalDevice Terminal driver private structure
929
930 @return TRUE If Raw Data FIFO buffer is full.
931 @return FLASE If Raw Data FIFO buffer is not full.
932
933 **/
934 BOOLEAN
935 IsRawFiFoFull (
936 TERMINAL_DEV *TerminalDevice
937 )
938 ;
939
940 /**
941 Insert one pre-fetched key into the FIFO buffer.
942
943 @param TerminalDevice Terminal driver private structure.
944 @param Key The key will be input.
945
946 @return TRUE If insert successfully.
947 @return FLASE If FIFO buffer is full before key insertion,
948 and the key is lost.
949
950 **/
951 BOOLEAN
952 EfiKeyFiFoInsertOneKey (
953 TERMINAL_DEV *TerminalDevice,
954 EFI_INPUT_KEY Key
955 )
956 ;
957
958 /**
959 Remove one pre-fetched key out of the FIFO buffer.
960
961 @param TerminalDevice Terminal driver private structure.
962 @param Output The key will be removed.
963
964 @return TRUE If insert successfully.
965 @return FLASE If FIFO buffer is empty before remove operation.
966
967 **/
968 BOOLEAN
969 EfiKeyFiFoRemoveOneKey (
970 TERMINAL_DEV *TerminalDevice,
971 EFI_INPUT_KEY *Output
972 )
973 ;
974
975 /**
976 Clarify whether FIFO buffer is empty.
977
978 @param TerminalDevice Terminal driver private structure
979
980 @return TRUE If FIFO buffer is empty.
981 @return FLASE If FIFO buffer is not empty.
982
983 **/
984 BOOLEAN
985 IsEfiKeyFiFoEmpty (
986 TERMINAL_DEV *TerminalDevice
987 )
988 ;
989
990 /**
991 Clarify whether FIFO buffer is full.
992
993 @param TerminalDevice Terminal driver private structure
994
995 @return TRUE If FIFO buffer is full.
996 @return FLASE If FIFO buffer is not full.
997
998 **/
999 BOOLEAN
1000 IsEfiKeyFiFoFull (
1001 TERMINAL_DEV *TerminalDevice
1002 )
1003 ;
1004
1005 /**
1006 Insert one pre-fetched key into the Unicode FIFO buffer.
1007
1008 @param TerminalDevice Terminal driver private structure.
1009 @param Input The key will be input.
1010
1011 @return TRUE If insert successfully.
1012 @return FLASE If Unicode FIFO buffer is full before key insertion,
1013 and the key is lost.
1014
1015 **/
1016 BOOLEAN
1017 UnicodeFiFoInsertOneKey (
1018 TERMINAL_DEV *TerminalDevice,
1019 UINT16 Input
1020 )
1021 ;
1022
1023 /**
1024 Remove one pre-fetched key out of the Unicode FIFO buffer.
1025
1026 @param TerminalDevice Terminal driver private structure.
1027 @param Output The key will be removed.
1028
1029 @return TRUE If insert successfully.
1030 @return FLASE If Unicode FIFO buffer is empty before remove operation.
1031
1032 **/
1033 BOOLEAN
1034 UnicodeFiFoRemoveOneKey (
1035 TERMINAL_DEV *TerminalDevice,
1036 UINT16 *Output
1037 )
1038 ;
1039
1040 /**
1041 Clarify whether Unicode FIFO buffer is empty.
1042
1043 @param TerminalDevice Terminal driver private structure
1044
1045 @return TRUE If Unicode FIFO buffer is empty.
1046 @return FLASE If Unicode FIFO buffer is not empty.
1047
1048 **/
1049 BOOLEAN
1050 IsUnicodeFiFoEmpty (
1051 TERMINAL_DEV *TerminalDevice
1052 )
1053 ;
1054
1055 /**
1056 Clarify whether Unicode FIFO buffer is full.
1057
1058 @param TerminalDevice Terminal driver private structure
1059
1060 @return TRUE If Unicode FIFO buffer is full.
1061 @return FLASE If Unicode FIFO buffer is not full.
1062
1063 **/
1064 BOOLEAN
1065 IsUnicodeFiFoFull (
1066 TERMINAL_DEV *TerminalDevice
1067 )
1068 ;
1069
1070 UINT8
1071 UnicodeFiFoGetKeyCount (
1072 TERMINAL_DEV *TerminalDevice
1073 )
1074 ;
1075
1076 VOID
1077 TranslateRawDataToEfiKey (
1078 IN TERMINAL_DEV *TerminalDevice
1079 )
1080 ;
1081
1082 //
1083 // internal functions for PC ANSI
1084 //
1085 VOID
1086 AnsiRawDataToUnicode (
1087 IN TERMINAL_DEV *PcAnsiDevice
1088 )
1089 ;
1090
1091 VOID
1092 UnicodeToEfiKey (
1093 IN TERMINAL_DEV *PcAnsiDevice
1094 )
1095 ;
1096
1097 EFI_STATUS
1098 AnsiTestString (
1099 IN TERMINAL_DEV *TerminalDevice,
1100 IN CHAR16 *WString
1101 )
1102 ;
1103
1104 //
1105 // internal functions for VTUTF8
1106 //
1107 VOID
1108 VTUTF8RawDataToUnicode (
1109 IN TERMINAL_DEV *VtUtf8Device
1110 )
1111 ;
1112
1113 EFI_STATUS
1114 VTUTF8TestString (
1115 IN TERMINAL_DEV *TerminalDevice,
1116 IN CHAR16 *WString
1117 )
1118 ;
1119
1120 VOID
1121 UnicodeToUtf8 (
1122 IN CHAR16 Unicode,
1123 OUT UTF8_CHAR *Utf8Char,
1124 OUT UINT8 *ValidBytes
1125 )
1126 ;
1127
1128 VOID
1129 GetOneValidUtf8Char (
1130 IN TERMINAL_DEV *Utf8Device,
1131 OUT UTF8_CHAR *Utf8Char,
1132 OUT UINT8 *ValidBytes
1133 )
1134 ;
1135
1136 VOID
1137 Utf8ToUnicode (
1138 IN UTF8_CHAR Utf8Char,
1139 IN UINT8 ValidBytes,
1140 OUT CHAR16 *UnicodeChar
1141 )
1142 ;
1143
1144 //
1145 // functions for boxdraw unicode
1146 //
1147 BOOLEAN
1148 TerminalIsValidTextGraphics (
1149 IN CHAR16 Graphic,
1150 OUT CHAR8 *PcAnsi, OPTIONAL
1151 OUT CHAR8 *Ascii OPTIONAL
1152 )
1153 ;
1154
1155 BOOLEAN
1156 TerminalIsValidAscii (
1157 IN CHAR16 Ascii
1158 )
1159 ;
1160
1161 BOOLEAN
1162 TerminalIsValidEfiCntlChar (
1163 IN CHAR16 CharC
1164 )
1165 ;
1166
1167 #endif