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