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