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