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