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