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