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