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