]>
Commit | Line | Data |
---|---|---|
a4d608d1 | 1 | /** @file\r |
fc753d3b | 2 | Console Splitter Driver. Any Handle that attatched console I/O protocols\r |
3 | (Console In device, Console Out device, Console Error device, Simple Pointer\r | |
4 | protocol, Absolute Pointer protocol) can be bound by this driver.\r | |
95276127 | 5 | \r |
6 | So far it works like any other driver by opening a SimpleTextIn and/or\r | |
7 | SimpleTextOut protocol with EFI_OPEN_PROTOCOL_BY_DRIVER attributes. The big\r | |
8 | difference is this driver does not layer a protocol on the passed in\r | |
9 | handle, or construct a child handle like a standard device or bus driver.\r | |
10 | This driver produces three virtual handles as children, one for console input\r | |
11 | splitter, one for console output splitter and one for error output splitter.\r | |
fc753d3b | 12 | These 3 virtual handles would be installed on gST.\r |
95276127 | 13 | \r |
fc753d3b | 14 | Each virtual handle, that supports the Console I/O protocol, will be produced\r |
c33add67 | 15 | in the driver entry point. The virtual handle are added on driver entry and\r |
16 | never removed. Such design ensures sytem function well during none console\r | |
fc753d3b | 17 | device situation.\r |
95276127 | 18 | \r |
fe339651 | 19 | Copyright (c) 2006 - 2012, Intel Corporation. All rights reserved.<BR>\r |
e5eed7d3 | 20 | This program and the accompanying materials\r |
95276127 | 21 | are licensed and made available under the terms and conditions of the BSD License\r |
22 | which accompanies this distribution. The full text of the license may be found at\r | |
23 | http://opensource.org/licenses/bsd-license.php\r | |
24 | \r | |
25 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r | |
26 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r | |
27 | \r | |
28 | **/\r | |
29 | \r | |
95276127 | 30 | #include "ConSplitter.h"\r |
31 | \r | |
838a9c58 | 32 | //\r |
33 | // Identify if ConIn is connected in PcdConInConnectOnDemand enabled mode. \r | |
34 | // default not connect\r | |
35 | //\r | |
36 | BOOLEAN mConInIsConnect = FALSE;\r | |
37 | \r | |
95276127 | 38 | //\r |
fc753d3b | 39 | // Text In Splitter Private Data template\r |
95276127 | 40 | //\r |
fc753d3b | 41 | GLOBAL_REMOVE_IF_UNREFERENCED TEXT_IN_SPLITTER_PRIVATE_DATA mConIn = {\r |
95276127 | 42 | TEXT_IN_SPLITTER_PRIVATE_DATA_SIGNATURE,\r |
43 | (EFI_HANDLE) NULL,\r | |
9937b365 | 44 | \r |
95276127 | 45 | {\r |
46 | ConSplitterTextInReset,\r | |
47 | ConSplitterTextInReadKeyStroke,\r | |
48 | (EFI_EVENT) NULL\r | |
49 | },\r | |
50 | 0,\r | |
51 | (EFI_SIMPLE_TEXT_INPUT_PROTOCOL **) NULL,\r | |
52 | 0,\r | |
9937b365 | 53 | \r |
66aa04e4 | 54 | {\r |
55 | ConSplitterTextInResetEx,\r | |
56 | ConSplitterTextInReadKeyStrokeEx,\r | |
57 | (EFI_EVENT) NULL,\r | |
58 | ConSplitterTextInSetState,\r | |
59 | ConSplitterTextInRegisterKeyNotify,\r | |
60 | ConSplitterTextInUnregisterKeyNotify\r | |
61 | },\r | |
62 | 0,\r | |
63 | (EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL **) NULL,\r | |
64 | 0,\r | |
65 | {\r | |
a4d608d1 | 66 | (LIST_ENTRY *) NULL,\r |
67 | (LIST_ENTRY *) NULL\r | |
66aa04e4 | 68 | },\r |
95276127 | 69 | \r |
70 | {\r | |
71 | ConSplitterSimplePointerReset,\r | |
72 | ConSplitterSimplePointerGetState,\r | |
73 | (EFI_EVENT) NULL,\r | |
74 | (EFI_SIMPLE_POINTER_MODE *) NULL\r | |
75 | },\r | |
76 | {\r | |
77 | 0x10000,\r | |
78 | 0x10000,\r | |
79 | 0x10000,\r | |
80 | TRUE,\r | |
81 | TRUE\r | |
82 | },\r | |
83 | 0,\r | |
84 | (EFI_SIMPLE_POINTER_PROTOCOL **) NULL,\r | |
85 | 0,\r | |
86 | \r | |
8ae0b360 | 87 | {\r |
88 | ConSplitterAbsolutePointerReset,\r | |
89 | ConSplitterAbsolutePointerGetState,\r | |
90 | (EFI_EVENT) NULL,\r | |
91 | (EFI_ABSOLUTE_POINTER_MODE *) NULL\r | |
92 | },\r | |
8ae0b360 | 93 | {\r |
fc753d3b | 94 | 0, // AbsoluteMinX\r |
95 | 0, // AbsoluteMinY\r | |
96 | 0, // AbsoluteMinZ\r | |
97 | 0x10000, // AbsoluteMaxX\r | |
98 | 0x10000, // AbsoluteMaxY\r | |
99 | 0x10000, // AbsoluteMaxZ\r | |
100 | 0 // Attributes\r | |
8ae0b360 | 101 | },\r |
102 | 0,\r | |
103 | (EFI_ABSOLUTE_POINTER_PROTOCOL **) NULL,\r | |
104 | 0,\r | |
105 | FALSE,\r | |
106 | \r | |
95276127 | 107 | FALSE,\r |
108 | FALSE\r | |
109 | };\r | |
110 | \r | |
fc753d3b | 111 | \r |
4b5c4fba | 112 | //\r |
fc753d3b | 113 | // Uga Draw Protocol Private Data template\r |
4b5c4fba | 114 | //\r |
115 | GLOBAL_REMOVE_IF_UNREFERENCED EFI_UGA_DRAW_PROTOCOL mUgaDrawProtocolTemplate = {\r | |
d6e11f22 | 116 | ConSplitterUgaDrawGetMode,\r |
117 | ConSplitterUgaDrawSetMode,\r | |
118 | ConSplitterUgaDrawBlt\r | |
7a5064ce | 119 | };\r |
120 | \r | |
4b5c4fba | 121 | //\r |
fc753d3b | 122 | // Graphics Output Protocol Private Data template\r |
4b5c4fba | 123 | //\r |
124 | GLOBAL_REMOVE_IF_UNREFERENCED EFI_GRAPHICS_OUTPUT_PROTOCOL mGraphicsOutputProtocolTemplate = {\r | |
d6e11f22 | 125 | ConSplitterGraphicsOutputQueryMode,\r |
126 | ConSplitterGraphicsOutputSetMode,\r | |
127 | ConSplitterGraphicsOutputBlt,\r | |
7a5064ce | 128 | NULL\r |
129 | };\r | |
130 | \r | |
fc753d3b | 131 | \r |
4b5c4fba | 132 | //\r |
fc753d3b | 133 | // Text Out Splitter Private Data template\r |
4b5c4fba | 134 | //\r |
fc753d3b | 135 | GLOBAL_REMOVE_IF_UNREFERENCED TEXT_OUT_SPLITTER_PRIVATE_DATA mConOut = {\r |
95276127 | 136 | TEXT_OUT_SPLITTER_PRIVATE_DATA_SIGNATURE,\r |
137 | (EFI_HANDLE) NULL,\r | |
138 | {\r | |
139 | ConSplitterTextOutReset,\r | |
140 | ConSplitterTextOutOutputString,\r | |
141 | ConSplitterTextOutTestString,\r | |
142 | ConSplitterTextOutQueryMode,\r | |
143 | ConSplitterTextOutSetMode,\r | |
144 | ConSplitterTextOutSetAttribute,\r | |
145 | ConSplitterTextOutClearScreen,\r | |
146 | ConSplitterTextOutSetCursorPosition,\r | |
147 | ConSplitterTextOutEnableCursor,\r | |
148 | (EFI_SIMPLE_TEXT_OUTPUT_MODE *) NULL\r | |
149 | },\r | |
150 | {\r | |
151 | 1,\r | |
152 | 0,\r | |
153 | 0,\r | |
154 | 0,\r | |
155 | 0,\r | |
156 | FALSE,\r | |
157 | },\r | |
9937b365 | 158 | \r |
d0c64728 | 159 | {\r |
7a5064ce | 160 | NULL,\r |
161 | NULL,\r | |
162 | NULL\r | |
d0c64728 | 163 | },\r |
164 | 0,\r | |
165 | 0,\r | |
166 | 0,\r | |
167 | 0,\r | |
9937b365 | 168 | \r |
95276127 | 169 | {\r |
7a5064ce | 170 | NULL,\r |
171 | NULL,\r | |
172 | NULL,\r | |
95276127 | 173 | NULL\r |
174 | },\r | |
aec072ad | 175 | (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION *) NULL,\r |
176 | 0,\r | |
95276127 | 177 | 0,\r |
95276127 | 178 | \r |
179 | 0,\r | |
180 | (TEXT_OUT_AND_GOP_DATA *) NULL,\r | |
181 | 0,\r | |
182 | (TEXT_OUT_SPLITTER_QUERY_DATA *) NULL,\r | |
183 | 0,\r | |
95276127 | 184 | (INT32 *) NULL\r |
185 | };\r | |
186 | \r | |
4b5c4fba | 187 | //\r |
fc753d3b | 188 | // Standard Error Text Out Splitter Data Template\r |
4b5c4fba | 189 | //\r |
fc753d3b | 190 | GLOBAL_REMOVE_IF_UNREFERENCED TEXT_OUT_SPLITTER_PRIVATE_DATA mStdErr = {\r |
95276127 | 191 | TEXT_OUT_SPLITTER_PRIVATE_DATA_SIGNATURE,\r |
192 | (EFI_HANDLE) NULL,\r | |
193 | {\r | |
194 | ConSplitterTextOutReset,\r | |
195 | ConSplitterTextOutOutputString,\r | |
196 | ConSplitterTextOutTestString,\r | |
197 | ConSplitterTextOutQueryMode,\r | |
198 | ConSplitterTextOutSetMode,\r | |
199 | ConSplitterTextOutSetAttribute,\r | |
200 | ConSplitterTextOutClearScreen,\r | |
201 | ConSplitterTextOutSetCursorPosition,\r | |
202 | ConSplitterTextOutEnableCursor,\r | |
203 | (EFI_SIMPLE_TEXT_OUTPUT_MODE *) NULL\r | |
204 | },\r | |
205 | {\r | |
206 | 1,\r | |
207 | 0,\r | |
208 | 0,\r | |
209 | 0,\r | |
210 | 0,\r | |
211 | FALSE,\r | |
212 | },\r | |
9937b365 | 213 | \r |
d0c64728 | 214 | {\r |
7a5064ce | 215 | NULL,\r |
216 | NULL,\r | |
217 | NULL\r | |
d0c64728 | 218 | },\r |
219 | 0,\r | |
220 | 0,\r | |
221 | 0,\r | |
222 | 0,\r | |
9937b365 | 223 | \r |
95276127 | 224 | {\r |
7a5064ce | 225 | NULL,\r |
226 | NULL,\r | |
227 | NULL,\r | |
95276127 | 228 | NULL\r |
229 | },\r | |
aec072ad | 230 | (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION *) NULL,\r |
231 | 0,\r | |
95276127 | 232 | 0,\r |
95276127 | 233 | \r |
234 | 0,\r | |
235 | (TEXT_OUT_AND_GOP_DATA *) NULL,\r | |
236 | 0,\r | |
237 | (TEXT_OUT_SPLITTER_QUERY_DATA *) NULL,\r | |
238 | 0,\r | |
95276127 | 239 | (INT32 *) NULL\r |
240 | };\r | |
241 | \r | |
4b5c4fba | 242 | //\r |
243 | // Driver binding instance for Console Input Device\r | |
244 | //\r | |
95276127 | 245 | EFI_DRIVER_BINDING_PROTOCOL gConSplitterConInDriverBinding = {\r |
246 | ConSplitterConInDriverBindingSupported,\r | |
247 | ConSplitterConInDriverBindingStart,\r | |
248 | ConSplitterConInDriverBindingStop,\r | |
249 | 0xa,\r | |
250 | NULL,\r | |
251 | NULL\r | |
252 | };\r | |
253 | \r | |
4b5c4fba | 254 | //\r |
fc753d3b | 255 | // Driver binding instance for Console Out device\r |
4b5c4fba | 256 | //\r |
fc753d3b | 257 | EFI_DRIVER_BINDING_PROTOCOL gConSplitterConOutDriverBinding = {\r |
258 | ConSplitterConOutDriverBindingSupported,\r | |
259 | ConSplitterConOutDriverBindingStart,\r | |
260 | ConSplitterConOutDriverBindingStop,\r | |
95276127 | 261 | 0xa,\r |
262 | NULL,\r | |
263 | NULL\r | |
264 | };\r | |
265 | \r | |
8ae0b360 | 266 | //\r |
fc753d3b | 267 | // Driver binding instance for Standard Error device\r |
8ae0b360 | 268 | //\r |
fc753d3b | 269 | EFI_DRIVER_BINDING_PROTOCOL gConSplitterStdErrDriverBinding = {\r |
270 | ConSplitterStdErrDriverBindingSupported,\r | |
271 | ConSplitterStdErrDriverBindingStart,\r | |
272 | ConSplitterStdErrDriverBindingStop,\r | |
8ae0b360 | 273 | 0xa,\r |
274 | NULL,\r | |
275 | NULL\r | |
276 | };\r | |
277 | \r | |
4b5c4fba | 278 | //\r |
fc753d3b | 279 | // Driver binding instance for Simple Pointer protocol\r |
4b5c4fba | 280 | //\r |
fc753d3b | 281 | EFI_DRIVER_BINDING_PROTOCOL gConSplitterSimplePointerDriverBinding = {\r |
282 | ConSplitterSimplePointerDriverBindingSupported,\r | |
283 | ConSplitterSimplePointerDriverBindingStart,\r | |
284 | ConSplitterSimplePointerDriverBindingStop,\r | |
95276127 | 285 | 0xa,\r |
286 | NULL,\r | |
287 | NULL\r | |
288 | };\r | |
289 | \r | |
4b5c4fba | 290 | //\r |
fc753d3b | 291 | // Driver binding instance for Absolute Pointer protocol\r |
4b5c4fba | 292 | //\r |
fc753d3b | 293 | EFI_DRIVER_BINDING_PROTOCOL gConSplitterAbsolutePointerDriverBinding = {\r |
294 | ConSplitterAbsolutePointerDriverBindingSupported,\r | |
295 | ConSplitterAbsolutePointerDriverBindingStart,\r | |
296 | ConSplitterAbsolutePointerDriverBindingStop,\r | |
95276127 | 297 | 0xa,\r |
298 | NULL,\r | |
299 | NULL\r | |
300 | };\r | |
301 | \r | |
302 | /**\r | |
fc753d3b | 303 | The Entry Point for module ConSplitter. The user code starts with this function.\r |
95276127 | 304 | \r |
415df2a3 | 305 | Installs driver module protocols and. Creates virtual device handles for ConIn,\r |
306 | ConOut, and StdErr. Installs Simple Text In protocol, Simple Text In Ex protocol,\r | |
c33add67 | 307 | Simple Pointer protocol, Absolute Pointer protocol on those virtual handlers.\r |
415df2a3 | 308 | Installs Graphics Output protocol and/or UGA Draw protocol if needed.\r |
309 | \r | |
d0c64728 | 310 | @param[in] ImageHandle The firmware allocated handle for the EFI image.\r |
95276127 | 311 | @param[in] SystemTable A pointer to the EFI System Table.\r |
d0c64728 | 312 | \r |
95276127 | 313 | @retval EFI_SUCCESS The entry point is executed successfully.\r |
314 | @retval other Some error occurs when executing this entry point.\r | |
315 | \r | |
316 | **/\r | |
317 | EFI_STATUS\r | |
318 | EFIAPI\r | |
415df2a3 | 319 | ConSplitterDriverEntry(\r |
95276127 | 320 | IN EFI_HANDLE ImageHandle,\r |
321 | IN EFI_SYSTEM_TABLE *SystemTable\r | |
322 | )\r | |
323 | {\r | |
324 | EFI_STATUS Status;\r | |
325 | \r | |
326 | //\r | |
327 | // Install driver model protocol(s).\r | |
328 | //\r | |
5bca971e | 329 | Status = EfiLibInstallDriverBindingComponentName2 (\r |
95276127 | 330 | ImageHandle,\r |
331 | SystemTable,\r | |
332 | &gConSplitterConInDriverBinding,\r | |
333 | ImageHandle,\r | |
334 | &gConSplitterConInComponentName,\r | |
5bca971e | 335 | &gConSplitterConInComponentName2\r |
95276127 | 336 | );\r |
337 | ASSERT_EFI_ERROR (Status);\r | |
338 | \r | |
5bca971e | 339 | Status = EfiLibInstallDriverBindingComponentName2 (\r |
95276127 | 340 | ImageHandle,\r |
341 | SystemTable,\r | |
342 | &gConSplitterSimplePointerDriverBinding,\r | |
343 | NULL,\r | |
344 | &gConSplitterSimplePointerComponentName,\r | |
5bca971e | 345 | &gConSplitterSimplePointerComponentName2\r |
95276127 | 346 | );\r |
347 | ASSERT_EFI_ERROR (Status);\r | |
348 | \r | |
8ae0b360 | 349 | Status = EfiLibInstallDriverBindingComponentName2 (\r |
350 | ImageHandle,\r | |
351 | SystemTable,\r | |
352 | &gConSplitterAbsolutePointerDriverBinding,\r | |
353 | NULL,\r | |
354 | &gConSplitterAbsolutePointerComponentName,\r | |
355 | &gConSplitterAbsolutePointerComponentName2\r | |
356 | );\r | |
357 | ASSERT_EFI_ERROR (Status);\r | |
358 | \r | |
5bca971e | 359 | Status = EfiLibInstallDriverBindingComponentName2 (\r |
95276127 | 360 | ImageHandle,\r |
361 | SystemTable,\r | |
362 | &gConSplitterConOutDriverBinding,\r | |
363 | NULL,\r | |
364 | &gConSplitterConOutComponentName,\r | |
5bca971e | 365 | &gConSplitterConOutComponentName2\r |
95276127 | 366 | );\r |
367 | ASSERT_EFI_ERROR (Status);\r | |
368 | \r | |
5bca971e | 369 | Status = EfiLibInstallDriverBindingComponentName2 (\r |
95276127 | 370 | ImageHandle,\r |
371 | SystemTable,\r | |
372 | &gConSplitterStdErrDriverBinding,\r | |
373 | NULL,\r | |
374 | &gConSplitterStdErrComponentName,\r | |
5bca971e | 375 | &gConSplitterStdErrComponentName2\r |
95276127 | 376 | );\r |
377 | ASSERT_EFI_ERROR (Status);\r | |
378 | \r | |
fc753d3b | 379 | //\r |
2da292f6 | 380 | // Either Graphics Output protocol or UGA Draw protocol must be supported.\r |
fc753d3b | 381 | //\r |
d0c64728 | 382 | ASSERT (FeaturePcdGet (PcdConOutGopSupport) ||\r |
383 | FeaturePcdGet (PcdConOutUgaSupport));\r | |
fc753d3b | 384 | \r |
95276127 | 385 | //\r |
fe339651 | 386 | // The driver creates virtual handles for ConIn, ConOut, StdErr.\r |
95276127 | 387 | // The virtual handles will always exist even if no console exist in the\r |
388 | // system. This is need to support hotplug devices like USB.\r | |
389 | //\r | |
390 | //\r | |
95276127 | 391 | // Create virtual device handle for ConIn Splitter\r |
392 | //\r | |
393 | Status = ConSplitterTextInConstructor (&mConIn);\r | |
394 | if (!EFI_ERROR (Status)) {\r | |
395 | Status = gBS->InstallMultipleProtocolInterfaces (\r | |
396 | &mConIn.VirtualHandle,\r | |
397 | &gEfiSimpleTextInProtocolGuid,\r | |
398 | &mConIn.TextIn,\r | |
66aa04e4 | 399 | &gEfiSimpleTextInputExProtocolGuid,\r |
400 | &mConIn.TextInEx,\r | |
95276127 | 401 | &gEfiSimplePointerProtocolGuid,\r |
402 | &mConIn.SimplePointer,\r | |
b819abbb | 403 | &gEfiAbsolutePointerProtocolGuid,\r |
404 | &mConIn.AbsolutePointer,\r | |
95276127 | 405 | NULL\r |
406 | );\r | |
407 | if (!EFI_ERROR (Status)) {\r | |
408 | //\r | |
409 | // Update the EFI System Table with new virtual console\r | |
fc753d3b | 410 | // and update the pointer to Simple Text Input protocol.\r |
95276127 | 411 | //\r |
412 | gST->ConsoleInHandle = mConIn.VirtualHandle;\r | |
413 | gST->ConIn = &mConIn.TextIn;\r | |
414 | }\r | |
415 | }\r | |
416 | //\r | |
417 | // Create virtual device handle for ConOut Splitter\r | |
418 | //\r | |
419 | Status = ConSplitterTextOutConstructor (&mConOut);\r | |
420 | if (!EFI_ERROR (Status)) {\r | |
d0c64728 | 421 | if (!FeaturePcdGet (PcdConOutGopSupport)) {\r |
422 | //\r | |
c33add67 | 423 | // If Graphics Outpurt protocol not supported, UGA Draw protocol is installed\r |
fc753d3b | 424 | // on the virtual handle.\r |
d0c64728 | 425 | //\r |
426 | Status = gBS->InstallMultipleProtocolInterfaces (\r | |
427 | &mConOut.VirtualHandle,\r | |
428 | &gEfiSimpleTextOutProtocolGuid,\r | |
429 | &mConOut.TextOut,\r | |
430 | &gEfiUgaDrawProtocolGuid,\r | |
431 | &mConOut.UgaDraw,\r | |
d0c64728 | 432 | NULL\r |
433 | );\r | |
434 | } else if (!FeaturePcdGet (PcdConOutUgaSupport)) {\r | |
435 | //\r | |
fc753d3b | 436 | // If UGA Draw protocol not supported, Graphics Output Protocol is installed\r |
437 | // on virtual handle.\r | |
d0c64728 | 438 | //\r |
439 | Status = gBS->InstallMultipleProtocolInterfaces (\r | |
440 | &mConOut.VirtualHandle,\r | |
441 | &gEfiSimpleTextOutProtocolGuid,\r | |
442 | &mConOut.TextOut,\r | |
443 | &gEfiGraphicsOutputProtocolGuid,\r | |
444 | &mConOut.GraphicsOutput,\r | |
d0c64728 | 445 | NULL\r |
446 | );\r | |
447 | } else {\r | |
448 | //\r | |
fc753d3b | 449 | // Boot Graphics Output protocol and UGA Draw protocol are supported,\r |
450 | // both they will be installed on virtual handle.\r | |
d0c64728 | 451 | //\r |
452 | Status = gBS->InstallMultipleProtocolInterfaces (\r | |
453 | &mConOut.VirtualHandle,\r | |
454 | &gEfiSimpleTextOutProtocolGuid,\r | |
455 | &mConOut.TextOut,\r | |
456 | &gEfiGraphicsOutputProtocolGuid,\r | |
457 | &mConOut.GraphicsOutput,\r | |
458 | &gEfiUgaDrawProtocolGuid,\r | |
459 | &mConOut.UgaDraw,\r | |
d0c64728 | 460 | NULL\r |
461 | );\r | |
462 | }\r | |
95276127 | 463 | \r |
464 | if (!EFI_ERROR (Status)) {\r | |
465 | //\r | |
466 | // Update the EFI System Table with new virtual console\r | |
fc753d3b | 467 | // and Update the pointer to Text Output protocol.\r |
95276127 | 468 | //\r |
469 | gST->ConsoleOutHandle = mConOut.VirtualHandle;\r | |
470 | gST->ConOut = &mConOut.TextOut;\r | |
471 | }\r | |
472 | \r | |
473 | }\r | |
fe339651 | 474 | \r |
475 | //\r | |
476 | // Create virtual device handle for StdErr Splitter\r | |
477 | //\r | |
478 | Status = ConSplitterTextOutConstructor (&mStdErr);\r | |
479 | if (!EFI_ERROR (Status)) {\r | |
480 | Status = gBS->InstallMultipleProtocolInterfaces (\r | |
481 | &mStdErr.VirtualHandle,\r | |
482 | &gEfiSimpleTextOutProtocolGuid,\r | |
483 | &mStdErr.TextOut,\r | |
484 | NULL\r | |
485 | );\r | |
486 | if (!EFI_ERROR (Status)) { \r | |
487 | //\r | |
488 | // Update the EFI System Table with new virtual console\r | |
489 | // and update the pointer to Text Output protocol.\r | |
490 | //\r | |
491 | gST->StandardErrorHandle = mStdErr.VirtualHandle;\r | |
492 | gST->StdErr = &mStdErr.TextOut;\r | |
493 | }\r | |
494 | }\r | |
495 | \r | |
95276127 | 496 | //\r |
497 | // Update the CRC32 in the EFI System Table header\r | |
498 | //\r | |
499 | gST->Hdr.CRC32 = 0;\r | |
500 | gBS->CalculateCrc32 (\r | |
501 | (UINT8 *) &gST->Hdr,\r | |
502 | gST->Hdr.HeaderSize,\r | |
503 | &gST->Hdr.CRC32\r | |
504 | );\r | |
505 | \r | |
506 | return EFI_SUCCESS;\r | |
415df2a3 | 507 | \r |
95276127 | 508 | }\r |
509 | \r | |
a4d608d1 | 510 | /**\r |
415df2a3 | 511 | Construct console input devices' private data.\r |
95276127 | 512 | \r |
a4d608d1 | 513 | @param ConInPrivate A pointer to the TEXT_IN_SPLITTER_PRIVATE_DATA\r |
514 | structure.\r | |
95276127 | 515 | \r |
a4d608d1 | 516 | @retval EFI_OUT_OF_RESOURCES Out of resources.\r |
4b5c4fba | 517 | @retval EFI_SUCCESS Text Input Devcie's private data has been constructed.\r |
518 | @retval other Failed to construct private data.\r | |
95276127 | 519 | \r |
a4d608d1 | 520 | **/\r |
521 | EFI_STATUS\r | |
522 | ConSplitterTextInConstructor (\r | |
523 | TEXT_IN_SPLITTER_PRIVATE_DATA *ConInPrivate\r | |
524 | )\r | |
95276127 | 525 | {\r |
526 | EFI_STATUS Status;\r | |
527 | \r | |
528 | //\r | |
c33add67 | 529 | // Allocate buffer for Simple Text Input device\r |
95276127 | 530 | //\r |
531 | Status = ConSplitterGrowBuffer (\r | |
532 | sizeof (EFI_SIMPLE_TEXT_INPUT_PROTOCOL *),\r | |
533 | &ConInPrivate->TextInListCount,\r | |
534 | (VOID **) &ConInPrivate->TextInList\r | |
535 | );\r | |
536 | if (EFI_ERROR (Status)) {\r | |
537 | return EFI_OUT_OF_RESOURCES;\r | |
538 | }\r | |
9937b365 | 539 | \r |
fc753d3b | 540 | //\r |
c33add67 | 541 | // Create Event to wait for a key\r |
fc753d3b | 542 | //\r |
95276127 | 543 | Status = gBS->CreateEvent (\r |
544 | EVT_NOTIFY_WAIT,\r | |
545 | TPL_NOTIFY,\r | |
546 | ConSplitterTextInWaitForKey,\r | |
547 | ConInPrivate,\r | |
548 | &ConInPrivate->TextIn.WaitForKey\r | |
549 | );\r | |
550 | ASSERT_EFI_ERROR (Status);\r | |
551 | \r | |
66aa04e4 | 552 | //\r |
c33add67 | 553 | // Allocate buffer for Simple Text Input Ex device\r |
7a5064ce | 554 | //\r |
66aa04e4 | 555 | Status = ConSplitterGrowBuffer (\r |
556 | sizeof (EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *),\r | |
557 | &ConInPrivate->TextInExListCount,\r | |
558 | (VOID **) &ConInPrivate->TextInExList\r | |
559 | );\r | |
560 | if (EFI_ERROR (Status)) {\r | |
561 | return EFI_OUT_OF_RESOURCES;\r | |
562 | }\r | |
fc753d3b | 563 | //\r |
564 | // Create Event to wait for a key Ex\r | |
565 | //\r | |
66aa04e4 | 566 | Status = gBS->CreateEvent (\r |
567 | EVT_NOTIFY_WAIT,\r | |
568 | TPL_NOTIFY,\r | |
569 | ConSplitterTextInWaitForKey,\r | |
570 | ConInPrivate,\r | |
571 | &ConInPrivate->TextInEx.WaitForKeyEx\r | |
572 | );\r | |
573 | ASSERT_EFI_ERROR (Status);\r | |
574 | \r | |
7a5064ce | 575 | InitializeListHead (&ConInPrivate->NotifyList);\r |
66aa04e4 | 576 | \r |
fc753d3b | 577 | ConInPrivate->AbsolutePointer.Mode = &ConInPrivate->AbsolutePointerMode;\r |
8ae0b360 | 578 | //\r |
c33add67 | 579 | // Allocate buffer for Absolute Pointer device\r |
8ae0b360 | 580 | //\r |
8ae0b360 | 581 | Status = ConSplitterGrowBuffer (\r |
b819abbb | 582 | sizeof (EFI_ABSOLUTE_POINTER_PROTOCOL *),\r |
583 | &ConInPrivate->AbsolutePointerListCount,\r | |
584 | (VOID **) &ConInPrivate->AbsolutePointerList\r | |
585 | );\r | |
8ae0b360 | 586 | if (EFI_ERROR (Status)) {\r |
b819abbb | 587 | return EFI_OUT_OF_RESOURCES;\r |
8ae0b360 | 588 | }\r |
fc753d3b | 589 | //\r |
590 | // Create Event to wait for device input for Absolute pointer device\r | |
591 | //\r | |
8ae0b360 | 592 | Status = gBS->CreateEvent (\r |
b819abbb | 593 | EVT_NOTIFY_WAIT,\r |
594 | TPL_NOTIFY,\r | |
595 | ConSplitterAbsolutePointerWaitForInput,\r | |
596 | ConInPrivate,\r | |
597 | &ConInPrivate->AbsolutePointer.WaitForInput\r | |
598 | );\r | |
8ae0b360 | 599 | ASSERT_EFI_ERROR (Status);\r |
66aa04e4 | 600 | \r |
95276127 | 601 | ConInPrivate->SimplePointer.Mode = &ConInPrivate->SimplePointerMode;\r |
fc753d3b | 602 | //\r |
c33add67 | 603 | // Allocate buffer for Simple Pointer device\r |
fc753d3b | 604 | //\r |
95276127 | 605 | Status = ConSplitterGrowBuffer (\r |
606 | sizeof (EFI_SIMPLE_POINTER_PROTOCOL *),\r | |
607 | &ConInPrivate->PointerListCount,\r | |
608 | (VOID **) &ConInPrivate->PointerList\r | |
609 | );\r | |
610 | if (EFI_ERROR (Status)) {\r | |
611 | return EFI_OUT_OF_RESOURCES;\r | |
612 | }\r | |
fc753d3b | 613 | //\r |
614 | // Create Event to wait for device input for Simple pointer device\r | |
615 | //\r | |
95276127 | 616 | Status = gBS->CreateEvent (\r |
617 | EVT_NOTIFY_WAIT,\r | |
618 | TPL_NOTIFY,\r | |
619 | ConSplitterSimplePointerWaitForInput,\r | |
620 | ConInPrivate,\r | |
621 | &ConInPrivate->SimplePointer.WaitForInput\r | |
622 | );\r | |
623 | \r | |
624 | return Status;\r | |
625 | }\r | |
626 | \r | |
415df2a3 | 627 | /**\r |
628 | Construct console output devices' private data.\r | |
629 | \r | |
fc753d3b | 630 | @param ConOutPrivate A pointer to the TEXT_OUT_SPLITTER_PRIVATE_DATA\r |
415df2a3 | 631 | structure.\r |
632 | \r | |
633 | @retval EFI_OUT_OF_RESOURCES Out of resources.\r | |
4b5c4fba | 634 | @retval EFI_SUCCESS Text Input Devcie's private data has been constructed.\r |
415df2a3 | 635 | \r |
636 | **/\r | |
95276127 | 637 | EFI_STATUS\r |
638 | ConSplitterTextOutConstructor (\r | |
639 | TEXT_OUT_SPLITTER_PRIVATE_DATA *ConOutPrivate\r | |
640 | )\r | |
641 | {\r | |
642 | EFI_STATUS Status;\r | |
aec072ad | 643 | EFI_GRAPHICS_OUTPUT_MODE_INFORMATION *Info;\r |
95276127 | 644 | \r |
7a5064ce | 645 | //\r |
646 | // Copy protocols template\r | |
647 | //\r | |
648 | if (FeaturePcdGet (PcdConOutUgaSupport)) {\r | |
4b5c4fba | 649 | CopyMem (&ConOutPrivate->UgaDraw, &mUgaDrawProtocolTemplate, sizeof (EFI_UGA_DRAW_PROTOCOL));\r |
7a5064ce | 650 | }\r |
7a5064ce | 651 | if (FeaturePcdGet (PcdConOutGopSupport)) {\r |
4b5c4fba | 652 | CopyMem (&ConOutPrivate->GraphicsOutput, &mGraphicsOutputProtocolTemplate, sizeof (EFI_GRAPHICS_OUTPUT_PROTOCOL));\r |
7a5064ce | 653 | }\r |
654 | \r | |
95276127 | 655 | //\r |
656 | // Initilize console output splitter's private data.\r | |
657 | //\r | |
658 | ConOutPrivate->TextOut.Mode = &ConOutPrivate->TextOutMode;\r | |
659 | \r | |
189eac21 | 660 | //\r |
661 | // When new console device is added, the new mode will be set later,\r | |
662 | // so put current mode back to init state.\r | |
8541adab | 663 | //\r |
189eac21 | 664 | ConOutPrivate->TextOutMode.Mode = 0xFF;\r |
fc753d3b | 665 | //\r |
c33add67 | 666 | // Allocate buffer for Console Out device\r |
fc753d3b | 667 | //\r |
95276127 | 668 | Status = ConSplitterGrowBuffer (\r |
669 | sizeof (TEXT_OUT_AND_GOP_DATA),\r | |
670 | &ConOutPrivate->TextOutListCount,\r | |
671 | (VOID **) &ConOutPrivate->TextOutList\r | |
672 | );\r | |
673 | if (EFI_ERROR (Status)) {\r | |
674 | return EFI_OUT_OF_RESOURCES;\r | |
675 | }\r | |
fc753d3b | 676 | //\r |
677 | // Allocate buffer for Text Out query data\r | |
678 | //\r | |
95276127 | 679 | Status = ConSplitterGrowBuffer (\r |
680 | sizeof (TEXT_OUT_SPLITTER_QUERY_DATA),\r | |
681 | &ConOutPrivate->TextOutQueryDataCount,\r | |
682 | (VOID **) &ConOutPrivate->TextOutQueryData\r | |
683 | );\r | |
684 | if (EFI_ERROR (Status)) {\r | |
685 | return EFI_OUT_OF_RESOURCES;\r | |
686 | }\r | |
fc753d3b | 687 | \r |
95276127 | 688 | //\r |
9937b365 | 689 | // Setup the default console to 80 x 25 and mode to 0\r |
95276127 | 690 | //\r |
691 | ConOutPrivate->TextOutQueryData[0].Columns = 80;\r | |
692 | ConOutPrivate->TextOutQueryData[0].Rows = 25;\r | |
9937b365 | 693 | TextOutSetMode (ConOutPrivate, 0);\r |
694 | \r | |
95276127 | 695 | \r |
d0c64728 | 696 | if (FeaturePcdGet (PcdConOutUgaSupport)) {\r |
697 | //\r | |
9937b365 | 698 | // Setup the UgaDraw to 800 x 600 x 32 bits per pixel, 60Hz.\r |
d0c64728 | 699 | //\r |
d6e11f22 | 700 | ConSplitterUgaDrawSetMode (&ConOutPrivate->UgaDraw, 800, 600, 32, 60);\r |
95276127 | 701 | }\r |
d0c64728 | 702 | if (FeaturePcdGet (PcdConOutGopSupport)) {\r |
703 | //\r | |
704 | // Setup resource for mode information in Graphics Output Protocol interface\r | |
705 | //\r | |
706 | if ((ConOutPrivate->GraphicsOutput.Mode = AllocateZeroPool (sizeof (EFI_GRAPHICS_OUTPUT_PROTOCOL_MODE))) == NULL) {\r | |
707 | return EFI_OUT_OF_RESOURCES;\r | |
708 | }\r | |
709 | if ((ConOutPrivate->GraphicsOutput.Mode->Info = AllocateZeroPool (sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION))) == NULL) {\r | |
710 | return EFI_OUT_OF_RESOURCES;\r | |
711 | }\r | |
712 | //\r | |
713 | // Setup the DevNullGraphicsOutput to 800 x 600 x 32 bits per pixel\r | |
aec072ad | 714 | // DevNull will be updated to user-defined mode after driver has started.\r |
d0c64728 | 715 | //\r |
aec072ad | 716 | if ((ConOutPrivate->GraphicsOutputModeBuffer = AllocateZeroPool (sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION))) == NULL) {\r |
d0c64728 | 717 | return EFI_OUT_OF_RESOURCES;\r |
718 | }\r | |
aec072ad | 719 | Info = &ConOutPrivate->GraphicsOutputModeBuffer[0];\r |
720 | Info->Version = 0;\r | |
721 | Info->HorizontalResolution = 800;\r | |
722 | Info->VerticalResolution = 600;\r | |
723 | Info->PixelFormat = PixelBltOnly;\r | |
724 | Info->PixelsPerScanLine = 800;\r | |
725 | CopyMem (ConOutPrivate->GraphicsOutput.Mode->Info, Info, sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION));\r | |
726 | ConOutPrivate->GraphicsOutput.Mode->SizeOfInfo = sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION);\r | |
95276127 | 727 | \r |
d0c64728 | 728 | //\r |
729 | // Initialize the following items, theset items remain unchanged in GraphicsOutput->SetMode()\r | |
aec072ad | 730 | // GraphicsOutputMode->FrameBufferBase, GraphicsOutputMode->FrameBufferSize\r |
d0c64728 | 731 | //\r |
1be0dda6 | 732 | ConOutPrivate->GraphicsOutput.Mode->FrameBufferBase = (EFI_PHYSICAL_ADDRESS) (UINTN) NULL;\r |
d0c64728 | 733 | ConOutPrivate->GraphicsOutput.Mode->FrameBufferSize = 0;\r |
95276127 | 734 | \r |
d0c64728 | 735 | ConOutPrivate->GraphicsOutput.Mode->MaxMode = 1;\r |
736 | //\r | |
4b5c4fba | 737 | // Initial current mode to unknown state, and then set to mode 0\r |
d0c64728 | 738 | //\r |
739 | ConOutPrivate->GraphicsOutput.Mode->Mode = 0xffff;\r | |
740 | ConOutPrivate->GraphicsOutput.SetMode (&ConOutPrivate->GraphicsOutput, 0);\r | |
741 | }\r | |
95276127 | 742 | \r |
4b5c4fba | 743 | return EFI_SUCCESS;\r |
95276127 | 744 | }\r |
745 | \r | |
a4d608d1 | 746 | \r |
747 | /**\r | |
c33add67 | 748 | Test to see if the specified protocol could be supported on the specified device.\r |
a4d608d1 | 749 | \r |
fc753d3b | 750 | @param This Driver Binding protocol pointer.\r |
415df2a3 | 751 | @param ControllerHandle Handle of device to test.\r |
fc753d3b | 752 | @param Guid The specified protocol.\r |
a4d608d1 | 753 | \r |
415df2a3 | 754 | @retval EFI_SUCCESS The specified protocol is supported on this device.\r |
fc753d3b | 755 | @retval EFI_UNSUPPORTED The specified protocol attempts to be installed on virtul handle.\r |
756 | @retval other Failed to open specified protocol on this device.\r | |
a4d608d1 | 757 | \r |
758 | **/\r | |
95276127 | 759 | EFI_STATUS\r |
760 | ConSplitterSupported (\r | |
761 | IN EFI_DRIVER_BINDING_PROTOCOL *This,\r | |
762 | IN EFI_HANDLE ControllerHandle,\r | |
763 | IN EFI_GUID *Guid\r | |
764 | )\r | |
95276127 | 765 | {\r |
766 | EFI_STATUS Status;\r | |
767 | VOID *Instance;\r | |
768 | \r | |
769 | //\r | |
770 | // Make sure the Console Splitter does not attempt to attach to itself\r | |
771 | //\r | |
fc753d3b | 772 | if (ControllerHandle == mConIn.VirtualHandle ||\r |
773 | ControllerHandle == mConOut.VirtualHandle ||\r | |
c33add67 | 774 | ControllerHandle == mStdErr.VirtualHandle\r |
fc753d3b | 775 | ) {\r |
95276127 | 776 | return EFI_UNSUPPORTED;\r |
777 | }\r | |
778 | \r | |
95276127 | 779 | //\r |
fc753d3b | 780 | // Check to see whether the specific protocol could be opened BY_DRIVER\r |
95276127 | 781 | //\r |
782 | Status = gBS->OpenProtocol (\r | |
783 | ControllerHandle,\r | |
784 | Guid,\r | |
785 | &Instance,\r | |
786 | This->DriverBindingHandle,\r | |
787 | ControllerHandle,\r | |
788 | EFI_OPEN_PROTOCOL_BY_DRIVER\r | |
789 | );\r | |
790 | \r | |
791 | if (EFI_ERROR (Status)) {\r | |
792 | return Status;\r | |
793 | }\r | |
794 | \r | |
795 | gBS->CloseProtocol (\r | |
796 | ControllerHandle,\r | |
797 | Guid,\r | |
798 | This->DriverBindingHandle,\r | |
799 | ControllerHandle\r | |
800 | );\r | |
801 | \r | |
802 | return EFI_SUCCESS;\r | |
803 | }\r | |
804 | \r | |
a4d608d1 | 805 | /**\r |
c33add67 | 806 | Test to see if Console In Device could be supported on the Controller.\r |
a4d608d1 | 807 | \r |
fc753d3b | 808 | @param This Driver Binding protocol instance pointer.\r |
415df2a3 | 809 | @param ControllerHandle Handle of device to test.\r |
810 | @param RemainingDevicePath Optional parameter use to pick a specific child\r | |
811 | device to start.\r | |
a4d608d1 | 812 | \r |
4b5c4fba | 813 | @retval EFI_SUCCESS This driver supports this device.\r |
814 | @retval other This driver does not support this device.\r | |
a4d608d1 | 815 | \r |
816 | **/\r | |
95276127 | 817 | EFI_STATUS\r |
818 | EFIAPI\r | |
819 | ConSplitterConInDriverBindingSupported (\r | |
820 | IN EFI_DRIVER_BINDING_PROTOCOL *This,\r | |
821 | IN EFI_HANDLE ControllerHandle,\r | |
822 | IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath\r | |
823 | )\r | |
95276127 | 824 | {\r |
825 | return ConSplitterSupported (\r | |
826 | This,\r | |
827 | ControllerHandle,\r | |
828 | &gEfiConsoleInDeviceGuid\r | |
829 | );\r | |
830 | }\r | |
831 | \r | |
a4d608d1 | 832 | /**\r |
c33add67 | 833 | Test to see if Simple Pointer protocol could be supported on the Controller.\r |
a4d608d1 | 834 | \r |
fc753d3b | 835 | @param This Driver Binding protocol instance pointer.\r |
415df2a3 | 836 | @param ControllerHandle Handle of device to test.\r |
837 | @param RemainingDevicePath Optional parameter use to pick a specific child\r | |
838 | device to start.\r | |
a4d608d1 | 839 | \r |
4b5c4fba | 840 | @retval EFI_SUCCESS This driver supports this device.\r |
841 | @retval other This driver does not support this device.\r | |
a4d608d1 | 842 | \r |
843 | **/\r | |
95276127 | 844 | EFI_STATUS\r |
845 | EFIAPI\r | |
846 | ConSplitterSimplePointerDriverBindingSupported (\r | |
847 | IN EFI_DRIVER_BINDING_PROTOCOL *This,\r | |
848 | IN EFI_HANDLE ControllerHandle,\r | |
849 | IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath\r | |
850 | )\r | |
95276127 | 851 | {\r |
852 | return ConSplitterSupported (\r | |
853 | This,\r | |
854 | ControllerHandle,\r | |
855 | &gEfiSimplePointerProtocolGuid\r | |
856 | );\r | |
857 | }\r | |
858 | \r | |
a4d608d1 | 859 | /**\r |
c33add67 | 860 | Test to see if Absolute Pointer protocol could be supported on the Controller.\r |
a4d608d1 | 861 | \r |
fc753d3b | 862 | @param This Driver Binding protocol instance pointer.\r |
415df2a3 | 863 | @param ControllerHandle Handle of device to test.\r |
864 | @param RemainingDevicePath Optional parameter use to pick a specific child\r | |
865 | device to start.\r | |
a4d608d1 | 866 | \r |
4b5c4fba | 867 | @retval EFI_SUCCESS This driver supports this device.\r |
868 | @retval other This driver does not support this device.\r | |
a4d608d1 | 869 | \r |
870 | **/\r | |
8ae0b360 | 871 | EFI_STATUS\r |
872 | EFIAPI\r | |
873 | ConSplitterAbsolutePointerDriverBindingSupported (\r | |
874 | IN EFI_DRIVER_BINDING_PROTOCOL *This,\r | |
875 | IN EFI_HANDLE ControllerHandle,\r | |
876 | IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath\r | |
877 | )\r | |
8ae0b360 | 878 | {\r |
879 | return ConSplitterSupported (\r | |
880 | This,\r | |
881 | ControllerHandle,\r | |
882 | &gEfiAbsolutePointerProtocolGuid\r | |
883 | );\r | |
884 | }\r | |
885 | \r | |
a4d608d1 | 886 | \r |
887 | /**\r | |
c33add67 | 888 | Test to see if Console Out Device could be supported on the Controller.\r |
a4d608d1 | 889 | \r |
fc753d3b | 890 | @param This Driver Binding protocol instance pointer.\r |
415df2a3 | 891 | @param ControllerHandle Handle of device to test.\r |
892 | @param RemainingDevicePath Optional parameter use to pick a specific child\r | |
893 | device to start.\r | |
a4d608d1 | 894 | \r |
4b5c4fba | 895 | @retval EFI_SUCCESS This driver supports this device.\r |
896 | @retval other This driver does not support this device.\r | |
a4d608d1 | 897 | \r |
898 | **/\r | |
95276127 | 899 | EFI_STATUS\r |
900 | EFIAPI\r | |
901 | ConSplitterConOutDriverBindingSupported (\r | |
902 | IN EFI_DRIVER_BINDING_PROTOCOL *This,\r | |
903 | IN EFI_HANDLE ControllerHandle,\r | |
904 | IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath\r | |
905 | )\r | |
95276127 | 906 | {\r |
907 | return ConSplitterSupported (\r | |
908 | This,\r | |
909 | ControllerHandle,\r | |
910 | &gEfiConsoleOutDeviceGuid\r | |
911 | );\r | |
912 | }\r | |
913 | \r | |
a4d608d1 | 914 | /**\r |
c33add67 | 915 | Test to see if Standard Error Device could be supported on the Controller.\r |
a4d608d1 | 916 | \r |
fc753d3b | 917 | @param This Driver Binding protocol instance pointer.\r |
415df2a3 | 918 | @param ControllerHandle Handle of device to test.\r |
919 | @param RemainingDevicePath Optional parameter use to pick a specific child\r | |
920 | device to start.\r | |
a4d608d1 | 921 | \r |
4b5c4fba | 922 | @retval EFI_SUCCESS This driver supports this device.\r |
923 | @retval other This driver does not support this device.\r | |
a4d608d1 | 924 | \r |
925 | **/\r | |
95276127 | 926 | EFI_STATUS\r |
927 | EFIAPI\r | |
928 | ConSplitterStdErrDriverBindingSupported (\r | |
929 | IN EFI_DRIVER_BINDING_PROTOCOL *This,\r | |
930 | IN EFI_HANDLE ControllerHandle,\r | |
931 | IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath\r | |
932 | )\r | |
95276127 | 933 | {\r |
934 | return ConSplitterSupported (\r | |
935 | This,\r | |
936 | ControllerHandle,\r | |
937 | &gEfiStandardErrorDeviceGuid\r | |
938 | );\r | |
939 | }\r | |
940 | \r | |
a4d608d1 | 941 | \r |
942 | /**\r | |
c33add67 | 943 | Start ConSplitter on devcie handle by opening Console Device Guid on device handle\r |
415df2a3 | 944 | and the console virtual handle. And Get the console interface on controller handle.\r |
c33add67 | 945 | \r |
fc753d3b | 946 | @param This Driver Binding protocol instance pointer.\r |
415df2a3 | 947 | @param ControllerHandle Handle of device.\r |
948 | @param ConSplitterVirtualHandle Console virtual Handle.\r | |
949 | @param DeviceGuid The specified Console Device, such as ConInDev,\r | |
950 | ConOutDev.\r | |
951 | @param InterfaceGuid The specified protocol to be opened.\r | |
952 | @param Interface Protocol interface returned.\r | |
953 | \r | |
4b5c4fba | 954 | @retval EFI_SUCCESS This driver supports this device.\r |
415df2a3 | 955 | @retval other Failed to open the specified Console Device Guid\r |
956 | or specified protocol.\r | |
a4d608d1 | 957 | \r |
958 | **/\r | |
95276127 | 959 | EFI_STATUS\r |
95276127 | 960 | ConSplitterStart (\r |
961 | IN EFI_DRIVER_BINDING_PROTOCOL *This,\r | |
962 | IN EFI_HANDLE ControllerHandle,\r | |
963 | IN EFI_HANDLE ConSplitterVirtualHandle,\r | |
964 | IN EFI_GUID *DeviceGuid,\r | |
965 | IN EFI_GUID *InterfaceGuid,\r | |
415df2a3 | 966 | OUT VOID **Interface\r |
95276127 | 967 | )\r |
95276127 | 968 | {\r |
969 | EFI_STATUS Status;\r | |
970 | VOID *Instance;\r | |
971 | \r | |
972 | //\r | |
fc753d3b | 973 | // Check to see whether the ControllerHandle has the DeviceGuid on it.\r |
95276127 | 974 | //\r |
975 | Status = gBS->OpenProtocol (\r | |
976 | ControllerHandle,\r | |
977 | DeviceGuid,\r | |
978 | &Instance,\r | |
979 | This->DriverBindingHandle,\r | |
980 | ControllerHandle,\r | |
981 | EFI_OPEN_PROTOCOL_BY_DRIVER\r | |
982 | );\r | |
983 | if (EFI_ERROR (Status)) {\r | |
984 | return Status;\r | |
985 | }\r | |
c33add67 | 986 | \r |
fc753d3b | 987 | //\r |
76649bf4 | 988 | // Open the Parent Handle for the child.\r |
fc753d3b | 989 | //\r |
95276127 | 990 | Status = gBS->OpenProtocol (\r |
991 | ControllerHandle,\r | |
992 | DeviceGuid,\r | |
993 | &Instance,\r | |
994 | This->DriverBindingHandle,\r | |
995 | ConSplitterVirtualHandle,\r | |
996 | EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER\r | |
997 | );\r | |
998 | if (EFI_ERROR (Status)) {\r | |
fc753d3b | 999 | goto Err;\r |
95276127 | 1000 | }\r |
1001 | \r | |
fc753d3b | 1002 | //\r |
1003 | // Open InterfaceGuid on the virtul handle.\r | |
1004 | //\r | |
1005 | Status = gBS->OpenProtocol (\r | |
95276127 | 1006 | ControllerHandle,\r |
1007 | InterfaceGuid,\r | |
1008 | Interface,\r | |
1009 | This->DriverBindingHandle,\r | |
1010 | ConSplitterVirtualHandle,\r | |
1011 | EFI_OPEN_PROTOCOL_GET_PROTOCOL\r | |
1012 | );\r | |
fc753d3b | 1013 | \r |
1014 | if (!EFI_ERROR (Status)) {\r | |
1015 | return EFI_SUCCESS;\r | |
1016 | }\r | |
1017 | \r | |
1018 | //\r | |
1019 | // close the DeviceGuid on ConSplitter VirtualHandle.\r | |
1020 | //\r | |
1021 | gBS->CloseProtocol (\r | |
1022 | ControllerHandle,\r | |
1023 | DeviceGuid,\r | |
1024 | This->DriverBindingHandle,\r | |
1025 | ConSplitterVirtualHandle\r | |
1026 | );\r | |
1027 | \r | |
1028 | Err:\r | |
1029 | //\r | |
1030 | // close the DeviceGuid on ControllerHandle.\r | |
1031 | //\r | |
1032 | gBS->CloseProtocol (\r | |
1033 | ControllerHandle,\r | |
1034 | DeviceGuid,\r | |
1035 | This->DriverBindingHandle,\r | |
1036 | ControllerHandle\r | |
1037 | );\r | |
1038 | \r | |
1039 | return Status;\r | |
95276127 | 1040 | }\r |
1041 | \r | |
a4d608d1 | 1042 | \r |
1043 | /**\r | |
c33add67 | 1044 | Start Console In Consplitter on device handle.\r |
1045 | \r | |
fc753d3b | 1046 | @param This Driver Binding protocol instance pointer.\r |
415df2a3 | 1047 | @param ControllerHandle Handle of device to bind driver to.\r |
1048 | @param RemainingDevicePath Optional parameter use to pick a specific child\r | |
1049 | device to start.\r | |
a4d608d1 | 1050 | \r |
415df2a3 | 1051 | @retval EFI_SUCCESS Console In Consplitter is added to ControllerHandle.\r |
1052 | @retval other Console In Consplitter does not support this device.\r | |
a4d608d1 | 1053 | \r |
1054 | **/\r | |
95276127 | 1055 | EFI_STATUS\r |
1056 | EFIAPI\r | |
1057 | ConSplitterConInDriverBindingStart (\r | |
1058 | IN EFI_DRIVER_BINDING_PROTOCOL *This,\r | |
1059 | IN EFI_HANDLE ControllerHandle,\r | |
1060 | IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath\r | |
1061 | )\r | |
95276127 | 1062 | {\r |
415df2a3 | 1063 | EFI_STATUS Status;\r |
1064 | EFI_SIMPLE_TEXT_INPUT_PROTOCOL *TextIn;\r | |
1065 | EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *TextInEx;\r | |
95276127 | 1066 | \r |
1067 | //\r | |
1068 | // Start ConSplitter on ControllerHandle, and create the virtual\r | |
1069 | // agrogated console device on first call Start for a SimpleTextIn handle.\r | |
1070 | //\r | |
1071 | Status = ConSplitterStart (\r | |
1072 | This,\r | |
1073 | ControllerHandle,\r | |
1074 | mConIn.VirtualHandle,\r | |
1075 | &gEfiConsoleInDeviceGuid,\r | |
1076 | &gEfiSimpleTextInProtocolGuid,\r | |
1077 | (VOID **) &TextIn\r | |
1078 | );\r | |
1079 | if (EFI_ERROR (Status)) {\r | |
1080 | return Status;\r | |
1081 | }\r | |
1082 | \r | |
4b5c4fba | 1083 | //\r |
1084 | // Add this device into Text In devices list.\r | |
1085 | //\r | |
0cadafc8 | 1086 | Status = ConSplitterTextInAddDevice (&mConIn, TextIn);\r |
1087 | if (EFI_ERROR (Status)) {\r | |
1088 | return Status;\r | |
1089 | }\r | |
1090 | \r | |
66aa04e4 | 1091 | Status = gBS->OpenProtocol (\r |
1092 | ControllerHandle,\r | |
1093 | &gEfiSimpleTextInputExProtocolGuid,\r | |
1094 | (VOID **) &TextInEx,\r | |
1095 | This->DriverBindingHandle,\r | |
1096 | mConIn.VirtualHandle,\r | |
1097 | EFI_OPEN_PROTOCOL_GET_PROTOCOL\r | |
1098 | );\r | |
04b9f763 | 1099 | if (!EFI_ERROR (Status)) {\r |
1100 | //\r | |
1101 | // If Simple Text Input Ex protocol exists,\r | |
1102 | // add this device into Text In Ex devices list.\r | |
1103 | //\r | |
1104 | Status = ConSplitterTextInExAddDevice (&mConIn, TextInEx);\r | |
66aa04e4 | 1105 | }\r |
1106 | \r | |
0cadafc8 | 1107 | return Status;\r |
95276127 | 1108 | }\r |
1109 | \r | |
a4d608d1 | 1110 | \r |
1111 | /**\r | |
c33add67 | 1112 | Start Simple Pointer Consplitter on device handle.\r |
1113 | \r | |
fc753d3b | 1114 | @param This Driver Binding protocol instance pointer.\r |
415df2a3 | 1115 | @param ControllerHandle Handle of device to bind driver to.\r |
1116 | @param RemainingDevicePath Optional parameter use to pick a specific child\r | |
1117 | device to start.\r | |
a4d608d1 | 1118 | \r |
415df2a3 | 1119 | @retval EFI_SUCCESS Simple Pointer Consplitter is added to ControllerHandle.\r |
1120 | @retval other Simple Pointer Consplitter does not support this device.\r | |
a4d608d1 | 1121 | \r |
1122 | **/\r | |
95276127 | 1123 | EFI_STATUS\r |
1124 | EFIAPI\r | |
1125 | ConSplitterSimplePointerDriverBindingStart (\r | |
1126 | IN EFI_DRIVER_BINDING_PROTOCOL *This,\r | |
1127 | IN EFI_HANDLE ControllerHandle,\r | |
1128 | IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath\r | |
1129 | )\r | |
95276127 | 1130 | {\r |
1131 | EFI_STATUS Status;\r | |
1132 | EFI_SIMPLE_POINTER_PROTOCOL *SimplePointer;\r | |
1133 | \r | |
4b5c4fba | 1134 | //\r |
1135 | // Start ConSplitter on ControllerHandle, and create the virtual\r | |
1136 | // agrogated console device on first call Start for a SimplePointer handle.\r | |
1137 | //\r | |
95276127 | 1138 | Status = ConSplitterStart (\r |
1139 | This,\r | |
1140 | ControllerHandle,\r | |
1141 | mConIn.VirtualHandle,\r | |
1142 | &gEfiSimplePointerProtocolGuid,\r | |
1143 | &gEfiSimplePointerProtocolGuid,\r | |
1144 | (VOID **) &SimplePointer\r | |
1145 | );\r | |
1146 | if (EFI_ERROR (Status)) {\r | |
1147 | return Status;\r | |
1148 | }\r | |
1149 | \r | |
4b5c4fba | 1150 | //\r |
1151 | // Add this devcie into Simple Pointer devices list.\r | |
1152 | //\r | |
95276127 | 1153 | return ConSplitterSimplePointerAddDevice (&mConIn, SimplePointer);\r |
1154 | }\r | |
1155 | \r | |
a4d608d1 | 1156 | \r |
1157 | /**\r | |
c33add67 | 1158 | Start Absolute Pointer Consplitter on device handle.\r |
1159 | \r | |
fc753d3b | 1160 | @param This Driver Binding protocol instance pointer.\r |
415df2a3 | 1161 | @param ControllerHandle Handle of device to bind driver to.\r |
1162 | @param RemainingDevicePath Optional parameter use to pick a specific child\r | |
1163 | device to start.\r | |
a4d608d1 | 1164 | \r |
415df2a3 | 1165 | @retval EFI_SUCCESS Absolute Pointer Consplitter is added to ControllerHandle.\r |
1166 | @retval other Absolute Pointer Consplitter does not support this device.\r | |
a4d608d1 | 1167 | \r |
1168 | **/\r | |
8ae0b360 | 1169 | EFI_STATUS\r |
1170 | EFIAPI\r | |
1171 | ConSplitterAbsolutePointerDriverBindingStart (\r | |
1172 | IN EFI_DRIVER_BINDING_PROTOCOL *This,\r | |
1173 | IN EFI_HANDLE ControllerHandle,\r | |
1174 | IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath\r | |
1175 | )\r | |
8ae0b360 | 1176 | {\r |
1177 | EFI_STATUS Status;\r | |
1178 | EFI_ABSOLUTE_POINTER_PROTOCOL *AbsolutePointer;\r | |
1179 | \r | |
4b5c4fba | 1180 | //\r |
1181 | // Start ConSplitter on ControllerHandle, and create the virtual\r | |
1182 | // agrogated console device on first call Start for a AbsolutePointer handle.\r | |
1183 | //\r | |
8ae0b360 | 1184 | Status = ConSplitterStart (\r |
1185 | This,\r | |
1186 | ControllerHandle,\r | |
1187 | mConIn.VirtualHandle,\r | |
1188 | &gEfiAbsolutePointerProtocolGuid,\r | |
1189 | &gEfiAbsolutePointerProtocolGuid,\r | |
1190 | (VOID **) &AbsolutePointer\r | |
1191 | );\r | |
7a5064ce | 1192 | \r |
8ae0b360 | 1193 | if (EFI_ERROR (Status)) {\r |
1194 | return Status;\r | |
1195 | }\r | |
1196 | \r | |
4b5c4fba | 1197 | //\r |
1198 | // Add this devcie into Absolute Pointer devices list.\r | |
1199 | //\r | |
8ae0b360 | 1200 | return ConSplitterAbsolutePointerAddDevice (&mConIn, AbsolutePointer);\r |
1201 | }\r | |
1202 | \r | |
a4d608d1 | 1203 | \r |
1204 | /**\r | |
c33add67 | 1205 | Start Console Out Consplitter on device handle.\r |
1206 | \r | |
fc753d3b | 1207 | @param This Driver Binding protocol instance pointer.\r |
415df2a3 | 1208 | @param ControllerHandle Handle of device to bind driver to.\r |
1209 | @param RemainingDevicePath Optional parameter use to pick a specific child\r | |
1210 | device to start.\r | |
a4d608d1 | 1211 | \r |
415df2a3 | 1212 | @retval EFI_SUCCESS Console Out Consplitter is added to ControllerHandle.\r |
1213 | @retval other Console Out Consplitter does not support this device.\r | |
a4d608d1 | 1214 | \r |
1215 | **/\r | |
95276127 | 1216 | EFI_STATUS\r |
1217 | EFIAPI\r | |
1218 | ConSplitterConOutDriverBindingStart (\r | |
1219 | IN EFI_DRIVER_BINDING_PROTOCOL *This,\r | |
1220 | IN EFI_HANDLE ControllerHandle,\r | |
1221 | IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath\r | |
1222 | )\r | |
95276127 | 1223 | {\r |
2da292f6 | 1224 | EFI_STATUS Status;\r |
1225 | EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *TextOut;\r | |
1226 | EFI_GRAPHICS_OUTPUT_PROTOCOL *GraphicsOutput;\r | |
1227 | EFI_UGA_DRAW_PROTOCOL *UgaDraw;\r | |
1228 | UINTN SizeOfInfo;\r | |
1229 | EFI_GRAPHICS_OUTPUT_MODE_INFORMATION *Info;\r | |
95276127 | 1230 | \r |
4b5c4fba | 1231 | //\r |
1232 | // Start ConSplitter on ControllerHandle, and create the virtual\r | |
1233 | // agrogated console device on first call Start for a ConsoleOut handle.\r | |
1234 | //\r | |
95276127 | 1235 | Status = ConSplitterStart (\r |
1236 | This,\r | |
1237 | ControllerHandle,\r | |
1238 | mConOut.VirtualHandle,\r | |
1239 | &gEfiConsoleOutDeviceGuid,\r | |
1240 | &gEfiSimpleTextOutProtocolGuid,\r | |
1241 | (VOID **) &TextOut\r | |
1242 | );\r | |
1243 | if (EFI_ERROR (Status)) {\r | |
1244 | return Status;\r | |
1245 | }\r | |
8541adab | 1246 | \r |
1247 | GraphicsOutput = NULL;\r | |
1248 | UgaDraw = NULL;\r | |
95276127 | 1249 | //\r |
1250 | // Try to Open Graphics Output protocol\r | |
1251 | //\r | |
1252 | Status = gBS->OpenProtocol (\r | |
1253 | ControllerHandle,\r | |
1254 | &gEfiGraphicsOutputProtocolGuid,\r | |
1255 | (VOID **) &GraphicsOutput,\r | |
1256 | This->DriverBindingHandle,\r | |
1257 | mConOut.VirtualHandle,\r | |
1258 | EFI_OPEN_PROTOCOL_GET_PROTOCOL\r | |
1259 | );\r | |
8541adab | 1260 | \r |
1261 | if (EFI_ERROR (Status) && FeaturePcdGet (PcdUgaConsumeSupport)) {\r | |
1262 | //\r | |
4b5c4fba | 1263 | // Open UGA DRAW protocol\r |
8541adab | 1264 | //\r |
2da292f6 | 1265 | gBS->OpenProtocol (\r |
1266 | ControllerHandle,\r | |
1267 | &gEfiUgaDrawProtocolGuid,\r | |
1268 | (VOID **) &UgaDraw,\r | |
1269 | This->DriverBindingHandle,\r | |
1270 | mConOut.VirtualHandle,\r | |
1271 | EFI_OPEN_PROTOCOL_GET_PROTOCOL\r | |
1272 | );\r | |
95276127 | 1273 | }\r |
189eac21 | 1274 | \r |
1275 | //\r | |
1276 | // When new console device is added, the new mode will be set later,\r | |
1277 | // so put current mode back to init state.\r | |
1278 | //\r | |
1279 | mConOut.TextOutMode.Mode = 0xFF;\r | |
8541adab | 1280 | \r |
95276127 | 1281 | //\r |
1282 | // If both ConOut and StdErr incorporate the same Text Out device,\r | |
1283 | // their MaxMode and QueryData should be the intersection of both.\r | |
1284 | //\r | |
1285 | Status = ConSplitterTextOutAddDevice (&mConOut, TextOut, GraphicsOutput, UgaDraw);\r | |
1286 | ConSplitterTextOutSetAttribute (&mConOut.TextOut, EFI_TEXT_ATTR (EFI_LIGHTGRAY, EFI_BLACK));\r | |
1287 | \r | |
2da292f6 | 1288 | if (FeaturePcdGet (PcdConOutUgaSupport)) {\r |
d0c64728 | 1289 | //\r |
2da292f6 | 1290 | // Get the UGA mode data of ConOut from the current mode\r |
d0c64728 | 1291 | //\r |
2da292f6 | 1292 | if (GraphicsOutput != NULL) {\r |
1293 | Status = GraphicsOutput->QueryMode (GraphicsOutput, GraphicsOutput->Mode->Mode, &SizeOfInfo, &Info);\r | |
1294 | if (EFI_ERROR (Status)) {\r | |
1295 | return Status;\r | |
1296 | }\r | |
1297 | ASSERT ( SizeOfInfo <= sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION));\r | |
c33add67 | 1298 | \r |
2da292f6 | 1299 | mConOut.UgaHorizontalResolution = Info->HorizontalResolution;\r |
1300 | mConOut.UgaVerticalResolution = Info->VerticalResolution;\r | |
c33add67 | 1301 | mConOut.UgaColorDepth = 32;\r |
2da292f6 | 1302 | mConOut.UgaRefreshRate = 60;\r |
1303 | \r | |
1304 | FreePool (Info);\r | |
1305 | \r | |
1306 | } else if (UgaDraw != NULL && FeaturePcdGet (PcdUgaConsumeSupport)) {\r | |
1307 | Status = UgaDraw->GetMode (\r | |
d0c64728 | 1308 | UgaDraw,\r |
1309 | &mConOut.UgaHorizontalResolution,\r | |
1310 | &mConOut.UgaVerticalResolution,\r | |
1311 | &mConOut.UgaColorDepth,\r | |
1312 | &mConOut.UgaRefreshRate\r | |
1313 | );\r | |
1314 | }\r | |
1315 | }\r | |
2da292f6 | 1316 | \r |
95276127 | 1317 | return Status;\r |
1318 | }\r | |
1319 | \r | |
a4d608d1 | 1320 | \r |
1321 | /**\r | |
c33add67 | 1322 | Start Standard Error Consplitter on device handle.\r |
1323 | \r | |
fc753d3b | 1324 | @param This Driver Binding protocol instance pointer.\r |
415df2a3 | 1325 | @param ControllerHandle Handle of device to bind driver to.\r |
1326 | @param RemainingDevicePath Optional parameter use to pick a specific child\r | |
1327 | device to start.\r | |
a4d608d1 | 1328 | \r |
415df2a3 | 1329 | @retval EFI_SUCCESS Standard Error Consplitter is added to ControllerHandle.\r |
1330 | @retval other Standard Error Consplitter does not support this device.\r | |
a4d608d1 | 1331 | \r |
1332 | **/\r | |
95276127 | 1333 | EFI_STATUS\r |
1334 | EFIAPI\r | |
1335 | ConSplitterStdErrDriverBindingStart (\r | |
1336 | IN EFI_DRIVER_BINDING_PROTOCOL *This,\r | |
1337 | IN EFI_HANDLE ControllerHandle,\r | |
1338 | IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath\r | |
1339 | )\r | |
95276127 | 1340 | {\r |
1341 | EFI_STATUS Status;\r | |
1342 | EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *TextOut;\r | |
1343 | \r | |
4b5c4fba | 1344 | //\r |
1345 | // Start ConSplitter on ControllerHandle, and create the virtual\r | |
1346 | // agrogated console device on first call Start for a StandardError handle.\r | |
1347 | //\r | |
95276127 | 1348 | Status = ConSplitterStart (\r |
1349 | This,\r | |
1350 | ControllerHandle,\r | |
1351 | mStdErr.VirtualHandle,\r | |
1352 | &gEfiStandardErrorDeviceGuid,\r | |
1353 | &gEfiSimpleTextOutProtocolGuid,\r | |
1354 | (VOID **) &TextOut\r | |
1355 | );\r | |
1356 | if (EFI_ERROR (Status)) {\r | |
1357 | return Status;\r | |
1358 | }\r | |
8541adab | 1359 | \r |
189eac21 | 1360 | //\r |
1361 | // When new console device is added, the new mode will be set later,\r | |
1362 | // so put current mode back to init state.\r | |
1363 | //\r | |
1364 | mStdErr.TextOutMode.Mode = 0xFF;\r | |
8541adab | 1365 | \r |
95276127 | 1366 | //\r |
1367 | // If both ConOut and StdErr incorporate the same Text Out device,\r | |
1368 | // their MaxMode and QueryData should be the intersection of both.\r | |
1369 | //\r | |
1370 | Status = ConSplitterTextOutAddDevice (&mStdErr, TextOut, NULL, NULL);\r | |
1371 | ConSplitterTextOutSetAttribute (&mStdErr.TextOut, EFI_TEXT_ATTR (EFI_MAGENTA, EFI_BLACK));\r | |
1372 | if (EFI_ERROR (Status)) {\r | |
1373 | return Status;\r | |
1374 | }\r | |
1375 | \r | |
95276127 | 1376 | return Status;\r |
1377 | }\r | |
1378 | \r | |
a4d608d1 | 1379 | \r |
1380 | /**\r | |
c33add67 | 1381 | Stop ConSplitter on device handle by closing Console Device Guid on device handle\r |
415df2a3 | 1382 | and the console virtual handle.\r |
c33add67 | 1383 | \r |
415df2a3 | 1384 | @param This Protocol instance pointer.\r |
1385 | @param ControllerHandle Handle of device.\r | |
1386 | @param ConSplitterVirtualHandle Console virtual Handle.\r | |
1387 | @param DeviceGuid The specified Console Device, such as ConInDev,\r | |
1388 | ConOutDev.\r | |
1389 | @param InterfaceGuid The specified protocol to be opened.\r | |
1390 | @param Interface Protocol interface returned.\r | |
1391 | \r | |
1392 | @retval EFI_SUCCESS Stop ConSplitter on ControllerHandle successfully.\r | |
1393 | @retval other Failed to Stop ConSplitter on ControllerHandle.\r | |
a4d608d1 | 1394 | \r |
1395 | **/\r | |
95276127 | 1396 | EFI_STATUS\r |
95276127 | 1397 | ConSplitterStop (\r |
1398 | IN EFI_DRIVER_BINDING_PROTOCOL *This,\r | |
1399 | IN EFI_HANDLE ControllerHandle,\r | |
1400 | IN EFI_HANDLE ConSplitterVirtualHandle,\r | |
1401 | IN EFI_GUID *DeviceGuid,\r | |
1402 | IN EFI_GUID *InterfaceGuid,\r | |
1403 | IN VOID **Interface\r | |
1404 | )\r | |
95276127 | 1405 | {\r |
1406 | EFI_STATUS Status;\r | |
1407 | \r | |
1408 | Status = gBS->OpenProtocol (\r | |
1409 | ControllerHandle,\r | |
1410 | InterfaceGuid,\r | |
1411 | Interface,\r | |
1412 | This->DriverBindingHandle,\r | |
1413 | ControllerHandle,\r | |
1414 | EFI_OPEN_PROTOCOL_GET_PROTOCOL\r | |
1415 | );\r | |
1416 | if (EFI_ERROR (Status)) {\r | |
1417 | return Status;\r | |
1418 | }\r | |
1419 | //\r | |
1420 | // close the protocol refered.\r | |
1421 | //\r | |
1422 | gBS->CloseProtocol (\r | |
1423 | ControllerHandle,\r | |
1424 | DeviceGuid,\r | |
1425 | This->DriverBindingHandle,\r | |
1426 | ConSplitterVirtualHandle\r | |
1427 | );\r | |
4b5c4fba | 1428 | \r |
95276127 | 1429 | gBS->CloseProtocol (\r |
1430 | ControllerHandle,\r | |
1431 | DeviceGuid,\r | |
1432 | This->DriverBindingHandle,\r | |
1433 | ControllerHandle\r | |
1434 | );\r | |
1435 | \r | |
1436 | return EFI_SUCCESS;\r | |
1437 | }\r | |
1438 | \r | |
a4d608d1 | 1439 | \r |
1440 | /**\r | |
415df2a3 | 1441 | Stop Console In ConSplitter on ControllerHandle by closing Console In Devcice GUID.\r |
a4d608d1 | 1442 | \r |
fc753d3b | 1443 | @param This Driver Binding protocol instance pointer.\r |
415df2a3 | 1444 | @param ControllerHandle Handle of device to stop driver on\r |
1445 | @param NumberOfChildren Number of Handles in ChildHandleBuffer. If number of\r | |
1446 | children is zero stop the entire bus driver.\r | |
1447 | @param ChildHandleBuffer List of Child Handles to Stop.\r | |
a4d608d1 | 1448 | \r |
415df2a3 | 1449 | @retval EFI_SUCCESS This driver is removed ControllerHandle\r |
1450 | @retval other This driver was not removed from this device\r | |
a4d608d1 | 1451 | \r |
1452 | **/\r | |
95276127 | 1453 | EFI_STATUS\r |
1454 | EFIAPI\r | |
1455 | ConSplitterConInDriverBindingStop (\r | |
1456 | IN EFI_DRIVER_BINDING_PROTOCOL *This,\r | |
1457 | IN EFI_HANDLE ControllerHandle,\r | |
1458 | IN UINTN NumberOfChildren,\r | |
1459 | IN EFI_HANDLE *ChildHandleBuffer\r | |
1460 | )\r | |
95276127 | 1461 | {\r |
04b9f763 | 1462 | EFI_STATUS Status;\r |
1463 | EFI_SIMPLE_TEXT_INPUT_PROTOCOL *TextIn;\r | |
66aa04e4 | 1464 | EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *TextInEx;\r |
04b9f763 | 1465 | \r |
95276127 | 1466 | if (NumberOfChildren == 0) {\r |
1467 | return EFI_SUCCESS;\r | |
1468 | }\r | |
1469 | \r | |
66aa04e4 | 1470 | Status = gBS->OpenProtocol (\r |
1471 | ControllerHandle,\r | |
1472 | &gEfiSimpleTextInputExProtocolGuid,\r | |
1473 | (VOID **) &TextInEx,\r | |
1474 | This->DriverBindingHandle,\r | |
1475 | ControllerHandle,\r | |
1476 | EFI_OPEN_PROTOCOL_GET_PROTOCOL\r | |
1477 | );\r | |
04b9f763 | 1478 | if (!EFI_ERROR (Status)) {\r |
1479 | //\r | |
1480 | // If Simple Text Input Ex protocol exists,\r | |
1481 | // remove device from Text Input Ex devices list.\r | |
c33add67 | 1482 | //\r |
04b9f763 | 1483 | Status = ConSplitterTextInExDeleteDevice (&mConIn, TextInEx);\r |
1484 | if (EFI_ERROR (Status)) {\r | |
1485 | return Status;\r | |
1486 | }\r | |
66aa04e4 | 1487 | }\r |
7a5064ce | 1488 | \r |
4b5c4fba | 1489 | //\r |
1490 | // Close Simple Text In protocol on controller handle and virtual handle.\r | |
1491 | //\r | |
95276127 | 1492 | Status = ConSplitterStop (\r |
1493 | This,\r | |
1494 | ControllerHandle,\r | |
1495 | mConIn.VirtualHandle,\r | |
1496 | &gEfiConsoleInDeviceGuid,\r | |
1497 | &gEfiSimpleTextInProtocolGuid,\r | |
1498 | (VOID **) &TextIn\r | |
1499 | );\r | |
1500 | if (EFI_ERROR (Status)) {\r | |
1501 | return Status;\r | |
1502 | }\r | |
4b5c4fba | 1503 | \r |
95276127 | 1504 | //\r |
4b5c4fba | 1505 | // Remove device from Text Input devices list.\r |
c33add67 | 1506 | //\r |
95276127 | 1507 | return ConSplitterTextInDeleteDevice (&mConIn, TextIn);\r |
1508 | }\r | |
1509 | \r | |
a4d608d1 | 1510 | \r |
1511 | /**\r | |
415df2a3 | 1512 | Stop Simple Pointer protocol ConSplitter on ControllerHandle by closing\r |
1513 | Simple Pointer protocol.\r | |
a4d608d1 | 1514 | \r |
fc753d3b | 1515 | @param This Driver Binding protocol instance pointer.\r |
415df2a3 | 1516 | @param ControllerHandle Handle of device to stop driver on\r |
1517 | @param NumberOfChildren Number of Handles in ChildHandleBuffer. If number of\r | |
1518 | children is zero stop the entire bus driver.\r | |
1519 | @param ChildHandleBuffer List of Child Handles to Stop.\r | |
a4d608d1 | 1520 | \r |
415df2a3 | 1521 | @retval EFI_SUCCESS This driver is removed ControllerHandle\r |
1522 | @retval other This driver was not removed from this device\r | |
a4d608d1 | 1523 | \r |
1524 | **/\r | |
95276127 | 1525 | EFI_STATUS\r |
1526 | EFIAPI\r | |
1527 | ConSplitterSimplePointerDriverBindingStop (\r | |
1528 | IN EFI_DRIVER_BINDING_PROTOCOL *This,\r | |
1529 | IN EFI_HANDLE ControllerHandle,\r | |
1530 | IN UINTN NumberOfChildren,\r | |
1531 | IN EFI_HANDLE *ChildHandleBuffer\r | |
1532 | )\r | |
95276127 | 1533 | {\r |
1534 | EFI_STATUS Status;\r | |
1535 | EFI_SIMPLE_POINTER_PROTOCOL *SimplePointer;\r | |
1536 | \r | |
1537 | if (NumberOfChildren == 0) {\r | |
1538 | return EFI_SUCCESS;\r | |
1539 | }\r | |
1540 | \r | |
4b5c4fba | 1541 | //\r |
1542 | // Close Simple Pointer protocol on controller handle and virtual handle.\r | |
1543 | //\r | |
95276127 | 1544 | Status = ConSplitterStop (\r |
1545 | This,\r | |
1546 | ControllerHandle,\r | |
1547 | mConIn.VirtualHandle,\r | |
1548 | &gEfiSimplePointerProtocolGuid,\r | |
1549 | &gEfiSimplePointerProtocolGuid,\r | |
1550 | (VOID **) &SimplePointer\r | |
1551 | );\r | |
1552 | if (EFI_ERROR (Status)) {\r | |
1553 | return Status;\r | |
1554 | }\r | |
4b5c4fba | 1555 | \r |
95276127 | 1556 | //\r |
4b5c4fba | 1557 | // Remove this device from Simple Pointer device list.\r |
95276127 | 1558 | //\r |
1559 | return ConSplitterSimplePointerDeleteDevice (&mConIn, SimplePointer);\r | |
1560 | }\r | |
1561 | \r | |
a4d608d1 | 1562 | \r |
1563 | /**\r | |
415df2a3 | 1564 | Stop Absolute Pointer protocol ConSplitter on ControllerHandle by closing\r |
1565 | Absolute Pointer protocol.\r | |
a4d608d1 | 1566 | \r |
fc753d3b | 1567 | @param This Driver Binding protocol instance pointer.\r |
415df2a3 | 1568 | @param ControllerHandle Handle of device to stop driver on\r |
1569 | @param NumberOfChildren Number of Handles in ChildHandleBuffer. If number of\r | |
1570 | children is zero stop the entire bus driver.\r | |
1571 | @param ChildHandleBuffer List of Child Handles to Stop.\r | |
a4d608d1 | 1572 | \r |
415df2a3 | 1573 | @retval EFI_SUCCESS This driver is removed ControllerHandle\r |
1574 | @retval other This driver was not removed from this device\r | |
a4d608d1 | 1575 | \r |
1576 | **/\r | |
8ae0b360 | 1577 | EFI_STATUS\r |
1578 | EFIAPI\r | |
1579 | ConSplitterAbsolutePointerDriverBindingStop (\r | |
1580 | IN EFI_DRIVER_BINDING_PROTOCOL *This,\r | |
1581 | IN EFI_HANDLE ControllerHandle,\r | |
1582 | IN UINTN NumberOfChildren,\r | |
1583 | IN EFI_HANDLE *ChildHandleBuffer\r | |
1584 | )\r | |
8ae0b360 | 1585 | {\r |
1586 | EFI_STATUS Status;\r | |
1587 | EFI_ABSOLUTE_POINTER_PROTOCOL *AbsolutePointer;\r | |
1588 | \r | |
1589 | if (NumberOfChildren == 0) {\r | |
1590 | return EFI_SUCCESS;\r | |
1591 | }\r | |
1592 | \r | |
4b5c4fba | 1593 | //\r |
1594 | // Close Absolute Pointer protocol on controller handle and virtual handle.\r | |
1595 | //\r | |
8ae0b360 | 1596 | Status = ConSplitterStop (\r |
1597 | This,\r | |
1598 | ControllerHandle,\r | |
1599 | mConIn.VirtualHandle,\r | |
1600 | &gEfiAbsolutePointerProtocolGuid,\r | |
1601 | &gEfiAbsolutePointerProtocolGuid,\r | |
1602 | (VOID **) &AbsolutePointer\r | |
1603 | );\r | |
1604 | if (EFI_ERROR (Status)) {\r | |
1605 | return Status;\r | |
1606 | }\r | |
4b5c4fba | 1607 | \r |
8ae0b360 | 1608 | //\r |
4b5c4fba | 1609 | // Remove this device from Absolute Pointer device list.\r |
8ae0b360 | 1610 | //\r |
1611 | return ConSplitterAbsolutePointerDeleteDevice (&mConIn, AbsolutePointer);\r | |
1612 | }\r | |
1613 | \r | |
a4d608d1 | 1614 | \r |
1615 | /**\r | |
415df2a3 | 1616 | Stop Console Out ConSplitter on device handle by closing Console Out Devcice GUID.\r |
a4d608d1 | 1617 | \r |
fc753d3b | 1618 | @param This Driver Binding protocol instance pointer.\r |
415df2a3 | 1619 | @param ControllerHandle Handle of device to stop driver on\r |
1620 | @param NumberOfChildren Number of Handles in ChildHandleBuffer. If number of\r | |
1621 | children is zero stop the entire bus driver.\r | |
1622 | @param ChildHandleBuffer List of Child Handles to Stop.\r | |
a4d608d1 | 1623 | \r |
415df2a3 | 1624 | @retval EFI_SUCCESS This driver is removed ControllerHandle\r |
1625 | @retval other This driver was not removed from this device\r | |
a4d608d1 | 1626 | \r |
1627 | **/\r | |
95276127 | 1628 | EFI_STATUS\r |
1629 | EFIAPI\r | |
1630 | ConSplitterConOutDriverBindingStop (\r | |
1631 | IN EFI_DRIVER_BINDING_PROTOCOL *This,\r | |
1632 | IN EFI_HANDLE ControllerHandle,\r | |
1633 | IN UINTN NumberOfChildren,\r | |
1634 | IN EFI_HANDLE *ChildHandleBuffer\r | |
1635 | )\r | |
95276127 | 1636 | {\r |
1637 | EFI_STATUS Status;\r | |
1638 | EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *TextOut;\r | |
1639 | \r | |
1640 | if (NumberOfChildren == 0) {\r | |
1641 | return EFI_SUCCESS;\r | |
1642 | }\r | |
1643 | \r | |
4b5c4fba | 1644 | //\r |
1645 | // Close Absolute Pointer protocol on controller handle and virtual handle.\r | |
1646 | //\r | |
95276127 | 1647 | Status = ConSplitterStop (\r |
1648 | This,\r | |
1649 | ControllerHandle,\r | |
1650 | mConOut.VirtualHandle,\r | |
1651 | &gEfiConsoleOutDeviceGuid,\r | |
1652 | &gEfiSimpleTextOutProtocolGuid,\r | |
1653 | (VOID **) &TextOut\r | |
1654 | );\r | |
1655 | if (EFI_ERROR (Status)) {\r | |
1656 | return Status;\r | |
1657 | }\r | |
1658 | \r | |
1659 | //\r | |
4b5c4fba | 1660 | // Remove this device from Text Out device list.\r |
95276127 | 1661 | //\r |
1662 | return ConSplitterTextOutDeleteDevice (&mConOut, TextOut);\r | |
1663 | }\r | |
1664 | \r | |
a4d608d1 | 1665 | \r |
1666 | /**\r | |
415df2a3 | 1667 | Stop Standard Error ConSplitter on ControllerHandle by closing Standard Error GUID.\r |
a4d608d1 | 1668 | \r |
fc753d3b | 1669 | @param This Driver Binding protocol instance pointer.\r |
415df2a3 | 1670 | @param ControllerHandle Handle of device to stop driver on\r |
1671 | @param NumberOfChildren Number of Handles in ChildHandleBuffer. If number of\r | |
1672 | children is zero stop the entire bus driver.\r | |
1673 | @param ChildHandleBuffer List of Child Handles to Stop.\r | |
a4d608d1 | 1674 | \r |
415df2a3 | 1675 | @retval EFI_SUCCESS This driver is removed ControllerHandle\r |
1676 | @retval other This driver was not removed from this device\r | |
a4d608d1 | 1677 | \r |
1678 | **/\r | |
95276127 | 1679 | EFI_STATUS\r |
1680 | EFIAPI\r | |
1681 | ConSplitterStdErrDriverBindingStop (\r | |
1682 | IN EFI_DRIVER_BINDING_PROTOCOL *This,\r | |
1683 | IN EFI_HANDLE ControllerHandle,\r | |
1684 | IN UINTN NumberOfChildren,\r | |
1685 | IN EFI_HANDLE *ChildHandleBuffer\r | |
1686 | )\r | |
95276127 | 1687 | {\r |
1688 | EFI_STATUS Status;\r | |
1689 | EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *TextOut;\r | |
1690 | \r | |
1691 | if (NumberOfChildren == 0) {\r | |
1692 | return EFI_SUCCESS;\r | |
1693 | }\r | |
1694 | \r | |
4b5c4fba | 1695 | //\r |
1696 | // Close Standard Error Device on controller handle and virtual handle.\r | |
1697 | //\r | |
95276127 | 1698 | Status = ConSplitterStop (\r |
1699 | This,\r | |
1700 | ControllerHandle,\r | |
1701 | mStdErr.VirtualHandle,\r | |
1702 | &gEfiStandardErrorDeviceGuid,\r | |
1703 | &gEfiSimpleTextOutProtocolGuid,\r | |
1704 | (VOID **) &TextOut\r | |
1705 | );\r | |
1706 | if (EFI_ERROR (Status)) {\r | |
1707 | return Status;\r | |
1708 | }\r | |
1709 | //\r | |
1710 | // Delete this console error out device's data structures.\r | |
1711 | //\r | |
fe339651 | 1712 | return ConSplitterTextOutDeleteDevice (&mStdErr, TextOut);\r |
95276127 | 1713 | }\r |
1714 | \r | |
95276127 | 1715 | \r |
a4d608d1 | 1716 | /**\r |
a9746199 RN |
1717 | Take the passed in Buffer of size ElementSize and grow the buffer\r |
1718 | by CONSOLE_SPLITTER_ALLOC_UNIT * ElementSize bytes.\r | |
1719 | Copy the current data in Buffer to the new version of Buffer and\r | |
1720 | free the old version of buffer.\r | |
95276127 | 1721 | \r |
a9746199 | 1722 | @param ElementSize Size of element in array.\r |
fc753d3b | 1723 | @param Count Current number of elements in array.\r |
a4d608d1 | 1724 | @param Buffer Bigger version of passed in Buffer with all the\r |
fc753d3b | 1725 | data.\r |
95276127 | 1726 | \r |
fc753d3b | 1727 | @retval EFI_SUCCESS Buffer size has grown.\r |
415df2a3 | 1728 | @retval EFI_OUT_OF_RESOURCES Could not grow the buffer size.\r |
95276127 | 1729 | \r |
a4d608d1 | 1730 | **/\r |
1731 | EFI_STATUS\r | |
1732 | ConSplitterGrowBuffer (\r | |
a9746199 | 1733 | IN UINTN ElementSize,\r |
406ddad3 | 1734 | IN OUT UINTN *Count,\r |
a4d608d1 | 1735 | IN OUT VOID **Buffer\r |
1736 | )\r | |
95276127 | 1737 | {\r |
95276127 | 1738 | VOID *Ptr;\r |
1739 | \r | |
1740 | //\r | |
1741 | // grow the buffer to new buffer size,\r | |
1742 | // copy the old buffer's content to the new-size buffer,\r | |
1743 | // then free the old buffer.\r | |
1744 | //\r | |
c4648495 | 1745 | Ptr = ReallocatePool (\r |
a9746199 RN |
1746 | ElementSize * (*Count),\r |
1747 | ElementSize * ((*Count) + CONSOLE_SPLITTER_ALLOC_UNIT),\r | |
c4648495 | 1748 | *Buffer\r |
1749 | );\r | |
95276127 | 1750 | if (Ptr == NULL) {\r |
1751 | return EFI_OUT_OF_RESOURCES;\r | |
1752 | }\r | |
a9746199 | 1753 | *Count += CONSOLE_SPLITTER_ALLOC_UNIT;\r |
95276127 | 1754 | *Buffer = Ptr;\r |
95276127 | 1755 | return EFI_SUCCESS;\r |
1756 | }\r | |
1757 | \r | |
a4d608d1 | 1758 | \r |
1759 | /**\r | |
415df2a3 | 1760 | Add Text Input Device in Consplitter Text Input list.\r |
a4d608d1 | 1761 | \r |
415df2a3 | 1762 | @param Private Text In Splitter pointer.\r |
1763 | @param TextIn Simple Text Input protocol pointer.\r | |
a4d608d1 | 1764 | \r |
415df2a3 | 1765 | @retval EFI_SUCCESS Text Input Device added successfully.\r |
1766 | @retval EFI_OUT_OF_RESOURCES Could not grow the buffer size.\r | |
a4d608d1 | 1767 | \r |
1768 | **/\r | |
95276127 | 1769 | EFI_STATUS\r |
1770 | ConSplitterTextInAddDevice (\r | |
1771 | IN TEXT_IN_SPLITTER_PRIVATE_DATA *Private,\r | |
1772 | IN EFI_SIMPLE_TEXT_INPUT_PROTOCOL *TextIn\r | |
1773 | )\r | |
95276127 | 1774 | {\r |
1775 | EFI_STATUS Status;\r | |
1776 | \r | |
1777 | //\r | |
fc753d3b | 1778 | // If the Text In List is full, enlarge it by calling ConSplitterGrowBuffer().\r |
95276127 | 1779 | //\r |
1780 | if (Private->CurrentNumberOfConsoles >= Private->TextInListCount) {\r | |
1781 | Status = ConSplitterGrowBuffer (\r | |
1782 | sizeof (EFI_SIMPLE_TEXT_INPUT_PROTOCOL *),\r | |
1783 | &Private->TextInListCount,\r | |
1784 | (VOID **) &Private->TextInList\r | |
1785 | );\r | |
1786 | if (EFI_ERROR (Status)) {\r | |
1787 | return EFI_OUT_OF_RESOURCES;\r | |
1788 | }\r | |
1789 | }\r | |
1790 | //\r | |
1791 | // Add the new text-in device data structure into the Text In List.\r | |
1792 | //\r | |
1793 | Private->TextInList[Private->CurrentNumberOfConsoles] = TextIn;\r | |
1794 | Private->CurrentNumberOfConsoles++;\r | |
1795 | \r | |
1796 | //\r | |
fc753d3b | 1797 | // Extra CheckEvent added to reduce the double CheckEvent().\r |
95276127 | 1798 | //\r |
1799 | gBS->CheckEvent (TextIn->WaitForKey);\r | |
1800 | \r | |
1801 | return EFI_SUCCESS;\r | |
1802 | }\r | |
1803 | \r | |
a4d608d1 | 1804 | \r |
1805 | /**\r | |
fc753d3b | 1806 | Remove Text Input Device from Consplitter Text Input list.\r |
a4d608d1 | 1807 | \r |
415df2a3 | 1808 | @param Private Text In Splitter pointer.\r |
1809 | @param TextIn Simple Text protocol pointer.\r | |
a4d608d1 | 1810 | \r |
415df2a3 | 1811 | @retval EFI_SUCCESS Simple Text Device removed successfully.\r |
1812 | @retval EFI_NOT_FOUND No Simple Text Device found.\r | |
a4d608d1 | 1813 | \r |
1814 | **/\r | |
95276127 | 1815 | EFI_STATUS\r |
1816 | ConSplitterTextInDeleteDevice (\r | |
1817 | IN TEXT_IN_SPLITTER_PRIVATE_DATA *Private,\r | |
1818 | IN EFI_SIMPLE_TEXT_INPUT_PROTOCOL *TextIn\r | |
1819 | )\r | |
95276127 | 1820 | {\r |
1821 | UINTN Index;\r | |
1822 | //\r | |
1823 | // Remove the specified text-in device data structure from the Text In List,\r | |
1824 | // and rearrange the remaining data structures in the Text In List.\r | |
1825 | //\r | |
1826 | for (Index = 0; Index < Private->CurrentNumberOfConsoles; Index++) {\r | |
1827 | if (Private->TextInList[Index] == TextIn) {\r | |
63e78d52 | 1828 | for (; Index < Private->CurrentNumberOfConsoles - 1; Index++) {\r |
95276127 | 1829 | Private->TextInList[Index] = Private->TextInList[Index + 1];\r |
1830 | }\r | |
1831 | \r | |
1832 | Private->CurrentNumberOfConsoles--;\r | |
1833 | return EFI_SUCCESS;\r | |
1834 | }\r | |
1835 | }\r | |
1836 | \r | |
1837 | return EFI_NOT_FOUND;\r | |
1838 | }\r | |
1839 | \r | |
415df2a3 | 1840 | /**\r |
1841 | Add Text Input Ex Device in Consplitter Text Input Ex list.\r | |
1842 | \r | |
1843 | @param Private Text In Splitter pointer.\r | |
fc753d3b | 1844 | @param TextInEx Simple Text Input Ex Input protocol pointer.\r |
415df2a3 | 1845 | \r |
1846 | @retval EFI_SUCCESS Text Input Ex Device added successfully.\r | |
1847 | @retval EFI_OUT_OF_RESOURCES Could not grow the buffer size.\r | |
1848 | \r | |
1849 | **/\r | |
66aa04e4 | 1850 | EFI_STATUS\r |
1851 | ConSplitterTextInExAddDevice (\r | |
1852 | IN TEXT_IN_SPLITTER_PRIVATE_DATA *Private,\r | |
1853 | IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *TextInEx\r | |
1854 | )\r | |
1855 | {\r | |
a9746199 RN |
1856 | EFI_STATUS Status;\r |
1857 | LIST_ENTRY *Link;\r | |
1858 | TEXT_IN_EX_SPLITTER_NOTIFY *CurrentNotify;\r | |
1859 | UINTN TextInExListCount;\r | |
66aa04e4 | 1860 | \r |
1861 | //\r | |
a9746199 | 1862 | // Enlarge the NotifyHandleList and the TextInExList\r |
66aa04e4 | 1863 | //\r |
1864 | if (Private->CurrentNumberOfExConsoles >= Private->TextInExListCount) {\r | |
a9746199 RN |
1865 | for (Link = Private->NotifyList.ForwardLink; Link != &Private->NotifyList; Link = Link->ForwardLink) {\r |
1866 | CurrentNotify = TEXT_IN_EX_SPLITTER_NOTIFY_FROM_THIS (Link);\r | |
1867 | TextInExListCount = Private->TextInExListCount;\r | |
1868 | \r | |
1869 | Status = ConSplitterGrowBuffer (\r | |
1870 | sizeof (EFI_HANDLE),\r | |
1871 | &TextInExListCount,\r | |
1872 | (VOID **) &CurrentNotify->NotifyHandleList\r | |
1873 | );\r | |
1874 | if (EFI_ERROR (Status)) {\r | |
1875 | return EFI_OUT_OF_RESOURCES;\r | |
1876 | }\r | |
1877 | }\r | |
66aa04e4 | 1878 | Status = ConSplitterGrowBuffer (\r |
1879 | sizeof (EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *),\r | |
1880 | &Private->TextInExListCount,\r | |
1881 | (VOID **) &Private->TextInExList\r | |
1882 | );\r | |
1883 | if (EFI_ERROR (Status)) {\r | |
1884 | return EFI_OUT_OF_RESOURCES;\r | |
1885 | }\r | |
1886 | }\r | |
a9746199 RN |
1887 | \r |
1888 | //\r | |
1889 | // Register the key notify in the new text-in device\r | |
1890 | //\r | |
1891 | for (Link = Private->NotifyList.ForwardLink; Link != &Private->NotifyList; Link = Link->ForwardLink) {\r | |
1892 | CurrentNotify = TEXT_IN_EX_SPLITTER_NOTIFY_FROM_THIS (Link);\r | |
1893 | Status = TextInEx->RegisterKeyNotify (\r | |
1894 | TextInEx,\r | |
1895 | &CurrentNotify->KeyData,\r | |
1896 | CurrentNotify->KeyNotificationFn,\r | |
1897 | &CurrentNotify->NotifyHandleList[Private->CurrentNumberOfExConsoles]\r | |
1898 | );\r | |
1899 | if (EFI_ERROR (Status)) {\r | |
1900 | for (Link = Link->BackLink; Link != &Private->NotifyList; Link = Link->BackLink) {\r | |
1901 | CurrentNotify = TEXT_IN_EX_SPLITTER_NOTIFY_FROM_THIS (Link);\r | |
1902 | TextInEx->UnregisterKeyNotify (\r | |
1903 | TextInEx,\r | |
1904 | CurrentNotify->NotifyHandleList[Private->CurrentNumberOfExConsoles]\r | |
1905 | );\r | |
1906 | }\r | |
1907 | return Status;\r | |
1908 | }\r | |
1909 | }\r | |
1910 | \r | |
66aa04e4 | 1911 | //\r |
fc753d3b | 1912 | // Add the new text-in device data structure into the Text Input Ex List.\r |
66aa04e4 | 1913 | //\r |
1914 | Private->TextInExList[Private->CurrentNumberOfExConsoles] = TextInEx;\r | |
1915 | Private->CurrentNumberOfExConsoles++;\r | |
1916 | \r | |
1917 | //\r | |
fc753d3b | 1918 | // Extra CheckEvent added to reduce the double CheckEvent().\r |
66aa04e4 | 1919 | //\r |
1920 | gBS->CheckEvent (TextInEx->WaitForKeyEx);\r | |
1921 | \r | |
1922 | return EFI_SUCCESS;\r | |
1923 | }\r | |
1924 | \r | |
415df2a3 | 1925 | /**\r |
fc753d3b | 1926 | Remove Text Ex Device from Consplitter Text Input Ex list.\r |
415df2a3 | 1927 | \r |
1928 | @param Private Text In Splitter pointer.\r | |
1929 | @param TextInEx Simple Text Ex protocol pointer.\r | |
1930 | \r | |
fc753d3b | 1931 | @retval EFI_SUCCESS Simple Text Input Ex Device removed successfully.\r |
1932 | @retval EFI_NOT_FOUND No Simple Text Input Ex Device found.\r | |
415df2a3 | 1933 | \r |
1934 | **/\r | |
66aa04e4 | 1935 | EFI_STATUS\r |
1936 | ConSplitterTextInExDeleteDevice (\r | |
1937 | IN TEXT_IN_SPLITTER_PRIVATE_DATA *Private,\r | |
1938 | IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *TextInEx\r | |
1939 | )\r | |
1940 | {\r | |
1941 | UINTN Index;\r | |
1942 | //\r | |
fc753d3b | 1943 | // Remove the specified text-in device data structure from the Text Input Ex List,\r |
66aa04e4 | 1944 | // and rearrange the remaining data structures in the Text In List.\r |
1945 | //\r | |
1946 | for (Index = 0; Index < Private->CurrentNumberOfExConsoles; Index++) {\r | |
1947 | if (Private->TextInExList[Index] == TextInEx) {\r | |
63e78d52 | 1948 | for (; Index < Private->CurrentNumberOfExConsoles - 1; Index++) {\r |
66aa04e4 | 1949 | Private->TextInExList[Index] = Private->TextInExList[Index + 1];\r |
1950 | }\r | |
1951 | \r | |
1952 | Private->CurrentNumberOfExConsoles--;\r | |
1953 | return EFI_SUCCESS;\r | |
1954 | }\r | |
1955 | }\r | |
1956 | \r | |
1957 | return EFI_NOT_FOUND;\r | |
1958 | }\r | |
1959 | \r | |
a4d608d1 | 1960 | \r |
1961 | /**\r | |
415df2a3 | 1962 | Add Simple Pointer Device in Consplitter Simple Pointer list.\r |
a4d608d1 | 1963 | \r |
415df2a3 | 1964 | @param Private Text In Splitter pointer.\r |
1965 | @param SimplePointer Simple Pointer protocol pointer.\r | |
a4d608d1 | 1966 | \r |
415df2a3 | 1967 | @retval EFI_SUCCESS Simple Pointer Device added successfully.\r |
1968 | @retval EFI_OUT_OF_RESOURCES Could not grow the buffer size.\r | |
a4d608d1 | 1969 | \r |
1970 | **/\r | |
95276127 | 1971 | EFI_STATUS\r |
1972 | ConSplitterSimplePointerAddDevice (\r | |
1973 | IN TEXT_IN_SPLITTER_PRIVATE_DATA *Private,\r | |
1974 | IN EFI_SIMPLE_POINTER_PROTOCOL *SimplePointer\r | |
1975 | )\r | |
95276127 | 1976 | {\r |
1977 | EFI_STATUS Status;\r | |
1978 | \r | |
1979 | //\r | |
fc753d3b | 1980 | // If the Simple Pointer List is full, enlarge it by calling ConSplitterGrowBuffer().\r |
95276127 | 1981 | //\r |
1982 | if (Private->CurrentNumberOfPointers >= Private->PointerListCount) {\r | |
1983 | Status = ConSplitterGrowBuffer (\r | |
1984 | sizeof (EFI_SIMPLE_POINTER_PROTOCOL *),\r | |
1985 | &Private->PointerListCount,\r | |
1986 | (VOID **) &Private->PointerList\r | |
1987 | );\r | |
1988 | if (EFI_ERROR (Status)) {\r | |
1989 | return EFI_OUT_OF_RESOURCES;\r | |
1990 | }\r | |
1991 | }\r | |
1992 | //\r | |
fc753d3b | 1993 | // Add the new text-in device data structure into the Simple Pointer List.\r |
95276127 | 1994 | //\r |
1995 | Private->PointerList[Private->CurrentNumberOfPointers] = SimplePointer;\r | |
1996 | Private->CurrentNumberOfPointers++;\r | |
fc753d3b | 1997 | \r |
95276127 | 1998 | return EFI_SUCCESS;\r |
1999 | }\r | |
2000 | \r | |
a4d608d1 | 2001 | \r |
2002 | /**\r | |
fc753d3b | 2003 | Remove Simple Pointer Device from Consplitter Simple Pointer list.\r |
a4d608d1 | 2004 | \r |
415df2a3 | 2005 | @param Private Text In Splitter pointer.\r |
2006 | @param SimplePointer Simple Pointer protocol pointer.\r | |
a4d608d1 | 2007 | \r |
415df2a3 | 2008 | @retval EFI_SUCCESS Simple Pointer Device removed successfully.\r |
2009 | @retval EFI_NOT_FOUND No Simple Pointer Device found.\r | |
a4d608d1 | 2010 | \r |
2011 | **/\r | |
95276127 | 2012 | EFI_STATUS\r |
2013 | ConSplitterSimplePointerDeleteDevice (\r | |
2014 | IN TEXT_IN_SPLITTER_PRIVATE_DATA *Private,\r | |
2015 | IN EFI_SIMPLE_POINTER_PROTOCOL *SimplePointer\r | |
2016 | )\r | |
95276127 | 2017 | {\r |
2018 | UINTN Index;\r | |
2019 | //\r | |
fc753d3b | 2020 | // Remove the specified text-in device data structure from the Simple Pointer List,\r |
95276127 | 2021 | // and rearrange the remaining data structures in the Text In List.\r |
2022 | //\r | |
2023 | for (Index = 0; Index < Private->CurrentNumberOfPointers; Index++) {\r | |
2024 | if (Private->PointerList[Index] == SimplePointer) {\r | |
63e78d52 | 2025 | for (; Index < Private->CurrentNumberOfPointers - 1; Index++) {\r |
95276127 | 2026 | Private->PointerList[Index] = Private->PointerList[Index + 1];\r |
2027 | }\r | |
2028 | \r | |
2029 | Private->CurrentNumberOfPointers--;\r | |
2030 | return EFI_SUCCESS;\r | |
2031 | }\r | |
2032 | }\r | |
2033 | \r | |
2034 | return EFI_NOT_FOUND;\r | |
2035 | }\r | |
2036 | \r | |
a4d608d1 | 2037 | \r |
2038 | /**\r | |
415df2a3 | 2039 | Add Absolute Pointer Device in Consplitter Absolute Pointer list.\r |
a4d608d1 | 2040 | \r |
415df2a3 | 2041 | @param Private Text In Splitter pointer.\r |
2042 | @param AbsolutePointer Absolute Pointer protocol pointer.\r | |
a4d608d1 | 2043 | \r |
415df2a3 | 2044 | @retval EFI_SUCCESS Absolute Pointer Device added successfully.\r |
2045 | @retval EFI_OUT_OF_RESOURCES Could not grow the buffer size.\r | |
a4d608d1 | 2046 | \r |
2047 | **/\r | |
8ae0b360 | 2048 | EFI_STATUS\r |
2049 | ConSplitterAbsolutePointerAddDevice (\r | |
2050 | IN TEXT_IN_SPLITTER_PRIVATE_DATA *Private,\r | |
2051 | IN EFI_ABSOLUTE_POINTER_PROTOCOL *AbsolutePointer\r | |
2052 | )\r | |
8ae0b360 | 2053 | {\r |
2054 | EFI_STATUS Status;\r | |
2055 | \r | |
2056 | //\r | |
fc753d3b | 2057 | // If the Absolute Pointer List is full, enlarge it by calling ConSplitterGrowBuffer().\r |
8ae0b360 | 2058 | //\r |
2059 | if (Private->CurrentNumberOfAbsolutePointers >= Private->AbsolutePointerListCount) {\r | |
2060 | Status = ConSplitterGrowBuffer (\r | |
2061 | sizeof (EFI_ABSOLUTE_POINTER_PROTOCOL *),\r | |
2062 | &Private->AbsolutePointerListCount,\r | |
2063 | (VOID **) &Private->AbsolutePointerList\r | |
2064 | );\r | |
2065 | if (EFI_ERROR (Status)) {\r | |
2066 | return EFI_OUT_OF_RESOURCES;\r | |
2067 | }\r | |
2068 | }\r | |
2069 | //\r | |
fc753d3b | 2070 | // Add the new text-in device data structure into the Absolute Pointer List.\r |
8ae0b360 | 2071 | //\r |
2072 | Private->AbsolutePointerList[Private->CurrentNumberOfAbsolutePointers] = AbsolutePointer;\r | |
2073 | Private->CurrentNumberOfAbsolutePointers++;\r | |
fc753d3b | 2074 | \r |
8ae0b360 | 2075 | return EFI_SUCCESS;\r |
2076 | }\r | |
2077 | \r | |
a4d608d1 | 2078 | \r |
2079 | /**\r | |
fc753d3b | 2080 | Remove Absolute Pointer Device from Consplitter Absolute Pointer list.\r |
a4d608d1 | 2081 | \r |
415df2a3 | 2082 | @param Private Text In Splitter pointer.\r |
2083 | @param AbsolutePointer Absolute Pointer protocol pointer.\r | |
a4d608d1 | 2084 | \r |
415df2a3 | 2085 | @retval EFI_SUCCESS Absolute Pointer Device removed successfully.\r |
2086 | @retval EFI_NOT_FOUND No Absolute Pointer Device found.\r | |
a4d608d1 | 2087 | \r |
2088 | **/\r | |
8ae0b360 | 2089 | EFI_STATUS\r |
2090 | ConSplitterAbsolutePointerDeleteDevice (\r | |
2091 | IN TEXT_IN_SPLITTER_PRIVATE_DATA *Private,\r | |
2092 | IN EFI_ABSOLUTE_POINTER_PROTOCOL *AbsolutePointer\r | |
2093 | )\r | |
8ae0b360 | 2094 | {\r |
2095 | UINTN Index;\r | |
2096 | //\r | |
fc753d3b | 2097 | // Remove the specified text-in device data structure from the Absolute Pointer List,\r |
2098 | // and rearrange the remaining data structures from the Absolute Pointer List.\r | |
8ae0b360 | 2099 | //\r |
2100 | for (Index = 0; Index < Private->CurrentNumberOfAbsolutePointers; Index++) {\r | |
2101 | if (Private->AbsolutePointerList[Index] == AbsolutePointer) {\r | |
63e78d52 | 2102 | for (; Index < Private->CurrentNumberOfAbsolutePointers - 1; Index++) {\r |
8ae0b360 | 2103 | Private->AbsolutePointerList[Index] = Private->AbsolutePointerList[Index + 1];\r |
2104 | }\r | |
2105 | \r | |
2106 | Private->CurrentNumberOfAbsolutePointers--;\r | |
2107 | return EFI_SUCCESS;\r | |
2108 | }\r | |
2109 | }\r | |
2110 | \r | |
2111 | return EFI_NOT_FOUND;\r | |
2112 | }\r | |
2113 | \r | |
33019a71 | 2114 | /**\r |
2115 | Reallocate Text Out mode map.\r | |
2116 | \r | |
fc753d3b | 2117 | Allocate new buffer and copy original buffer into the new buffer.\r |
2118 | \r | |
33019a71 | 2119 | @param Private Consplitter Text Out pointer.\r |
2120 | \r | |
2121 | @retval EFI_SUCCESS Buffer size has grown\r | |
2122 | @retval EFI_OUT_OF_RESOURCES Could not grow the buffer size.\r | |
2123 | \r | |
2124 | **/\r | |
a4d608d1 | 2125 | EFI_STATUS\r |
2126 | ConSplitterGrowMapTable (\r | |
2127 | IN TEXT_OUT_SPLITTER_PRIVATE_DATA *Private\r | |
2128 | )\r | |
95276127 | 2129 | {\r |
2130 | UINTN Size;\r | |
2131 | UINTN NewSize;\r | |
2132 | UINTN TotalSize;\r | |
2133 | INT32 *TextOutModeMap;\r | |
2134 | INT32 *OldTextOutModeMap;\r | |
2135 | INT32 *SrcAddress;\r | |
2136 | INT32 Index;\r | |
2137 | \r | |
2138 | NewSize = Private->TextOutListCount * sizeof (INT32);\r | |
2139 | OldTextOutModeMap = Private->TextOutModeMap;\r | |
fc753d3b | 2140 | TotalSize = NewSize * (Private->TextOutQueryDataCount);\r |
95276127 | 2141 | \r |
fc753d3b | 2142 | //\r |
2143 | // Allocate new buffer for Text Out List.\r | |
2144 | //\r | |
2145 | TextOutModeMap = AllocatePool (TotalSize);\r | |
95276127 | 2146 | if (TextOutModeMap == NULL) {\r |
2147 | return EFI_OUT_OF_RESOURCES;\r | |
2148 | }\r | |
2149 | \r | |
2150 | SetMem (TextOutModeMap, TotalSize, 0xFF);\r | |
2151 | Private->TextOutModeMap = TextOutModeMap;\r | |
2152 | \r | |
2153 | //\r | |
2154 | // If TextOutList has been enlarged, need to realloc the mode map table\r | |
2155 | // The mode map table is regarded as a two dimension array.\r | |
2156 | //\r | |
2157 | // Old New\r | |
2158 | // 0 ---------> TextOutListCount ----> TextOutListCount\r | |
2159 | // | -------------------------------------------\r | |
2160 | // | | | |\r | |
2161 | // | | | |\r | |
2162 | // | | | |\r | |
2163 | // | | | |\r | |
2164 | // | | | |\r | |
2165 | // \/ | | |\r | |
2166 | // -------------------------------------------\r | |
2167 | // QueryDataCount\r | |
2168 | //\r | |
2169 | if (OldTextOutModeMap != NULL) {\r | |
2170 | \r | |
2171 | Size = Private->CurrentNumberOfConsoles * sizeof (INT32);\r | |
2172 | Index = 0;\r | |
2173 | SrcAddress = OldTextOutModeMap;\r | |
2174 | \r | |
2175 | //\r | |
2176 | // Copy the old data to the new one\r | |
2177 | //\r | |
2178 | while (Index < Private->TextOutMode.MaxMode) {\r | |
2179 | CopyMem (TextOutModeMap, SrcAddress, Size);\r | |
2180 | TextOutModeMap += NewSize;\r | |
2181 | SrcAddress += Size;\r | |
2182 | Index++;\r | |
2183 | }\r | |
2184 | //\r | |
2185 | // Free the old buffer\r | |
2186 | //\r | |
2187 | FreePool (OldTextOutModeMap);\r | |
2188 | }\r | |
2189 | \r | |
2190 | return EFI_SUCCESS;\r | |
2191 | }\r | |
2192 | \r | |
a4d608d1 | 2193 | \r |
2194 | /**\r | |
fc753d3b | 2195 | Add new device's output mode to console splitter's mode list.\r |
a4d608d1 | 2196 | \r |
415df2a3 | 2197 | @param Private Text Out Splitter pointer\r |
2198 | @param TextOut Simple Text Output protocol pointer.\r | |
c33add67 | 2199 | \r |
415df2a3 | 2200 | @retval EFI_SUCCESS Device added successfully.\r |
2201 | @retval EFI_OUT_OF_RESOURCES Could not grow the buffer size.\r | |
a4d608d1 | 2202 | \r |
2203 | **/\r | |
95276127 | 2204 | EFI_STATUS\r |
2205 | ConSplitterAddOutputMode (\r | |
2206 | IN TEXT_OUT_SPLITTER_PRIVATE_DATA *Private,\r | |
2207 | IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *TextOut\r | |
2208 | )\r | |
95276127 | 2209 | {\r |
2210 | EFI_STATUS Status;\r | |
2211 | INT32 MaxMode;\r | |
2212 | INT32 Mode;\r | |
2213 | UINTN Index;\r | |
2214 | \r | |
2215 | MaxMode = TextOut->Mode->MaxMode;\r | |
2216 | Private->TextOutMode.MaxMode = MaxMode;\r | |
2217 | \r | |
2218 | //\r | |
2219 | // Grow the buffer if query data buffer is not large enough to\r | |
2220 | // hold all the mode supported by the first console.\r | |
2221 | //\r | |
2222 | while (MaxMode > (INT32) Private->TextOutQueryDataCount) {\r | |
2223 | Status = ConSplitterGrowBuffer (\r | |
2224 | sizeof (TEXT_OUT_SPLITTER_QUERY_DATA),\r | |
2225 | &Private->TextOutQueryDataCount,\r | |
2226 | (VOID **) &Private->TextOutQueryData\r | |
2227 | );\r | |
2228 | if (EFI_ERROR (Status)) {\r | |
2229 | return EFI_OUT_OF_RESOURCES;\r | |
2230 | }\r | |
2231 | }\r | |
2232 | //\r | |
2233 | // Allocate buffer for the output mode map\r | |
2234 | //\r | |
2235 | Status = ConSplitterGrowMapTable (Private);\r | |
2236 | if (EFI_ERROR (Status)) {\r | |
2237 | return EFI_OUT_OF_RESOURCES;\r | |
2238 | }\r | |
2239 | //\r | |
2240 | // As the first textout device, directly add the mode in to QueryData\r | |
2241 | // and at the same time record the mapping between QueryData and TextOut.\r | |
2242 | //\r | |
2243 | Mode = 0;\r | |
2244 | Index = 0;\r | |
2245 | while (Mode < MaxMode) {\r | |
7347d5d6 | 2246 | Status = TextOut->QueryMode (\r |
2247 | TextOut,\r | |
2248 | Mode,\r | |
2249 | &Private->TextOutQueryData[Mode].Columns,\r | |
2250 | &Private->TextOutQueryData[Mode].Rows\r | |
2251 | );\r | |
2252 | //\r | |
2253 | // If mode 1 (80x50) is not supported, make sure mode 1 in TextOutQueryData\r | |
2254 | // is clear to 0x0.\r | |
2255 | //\r | |
2256 | if ((EFI_ERROR(Status)) && (Mode == 1)) {\r | |
2257 | Private->TextOutQueryData[Mode].Columns = 0;\r | |
2258 | Private->TextOutQueryData[Mode].Rows = 0;\r | |
2259 | }\r | |
95276127 | 2260 | Private->TextOutModeMap[Index] = Mode;\r |
2261 | Mode++;\r | |
2262 | Index += Private->TextOutListCount;\r | |
2263 | }\r | |
2264 | \r | |
2265 | return EFI_SUCCESS;\r | |
2266 | }\r | |
2267 | \r | |
7347d5d6 | 2268 | /**\r |
9e604fe4 | 2269 | Reconstruct TextOutModeMap to get intersection of modes.\r |
7347d5d6 | 2270 | \r |
2271 | This routine reconstruct TextOutModeMap to get the intersection\r | |
2272 | of modes for all console out devices. Because EFI/UEFI spec require\r | |
2273 | mode 0 is 80x25, mode 1 is 80x50, this routine will not check the\r | |
2274 | intersection for mode 0 and mode 1.\r | |
2275 | \r | |
a4d608d1 | 2276 | @param TextOutModeMap Current text out mode map, begin with the mode 80x25\r |
2277 | @param NewlyAddedMap New text out mode map, begin with the mode 80x25\r | |
2278 | @param MapStepSize Mode step size for one console device\r | |
fc753d3b | 2279 | @param NewMapStepSize New Mode step size for one console device\r |
2280 | @param MaxMode IN: Current max text mode, OUT: Updated max text mode.\r | |
2281 | @param CurrentMode IN: Current text mode, OUT: Updated current text mode.\r | |
7347d5d6 | 2282 | \r |
7347d5d6 | 2283 | **/\r |
95276127 | 2284 | VOID\r |
2285 | ConSplitterGetIntersection (\r | |
fc753d3b | 2286 | IN INT32 *TextOutModeMap,\r |
2287 | IN INT32 *NewlyAddedMap,\r | |
2288 | IN UINTN MapStepSize,\r | |
2289 | IN UINTN NewMapStepSize,\r | |
2290 | IN OUT INT32 *MaxMode,\r | |
2291 | IN OUT INT32 *CurrentMode\r | |
95276127 | 2292 | )\r |
2293 | {\r | |
2294 | INT32 Index;\r | |
2295 | INT32 *CurrentMapEntry;\r | |
2296 | INT32 *NextMapEntry;\r | |
fc753d3b | 2297 | INT32 *NewMapEntry;\r |
95276127 | 2298 | INT32 CurrentMaxMode;\r |
2299 | INT32 Mode;\r | |
2300 | \r | |
7347d5d6 | 2301 | //\r |
2302 | // According to EFI/UEFI spec, mode 0 and mode 1 have been reserved\r | |
2303 | // for 80x25 and 80x50 in Simple Text Out protocol, so don't make intersection\r | |
2304 | // for mode 0 and mode 1, mode number starts from 2.\r | |
2305 | //\r | |
2306 | Index = 2;\r | |
2307 | CurrentMapEntry = &TextOutModeMap[MapStepSize * 2];\r | |
fc753d3b | 2308 | NextMapEntry = CurrentMapEntry;\r |
2309 | NewMapEntry = &NewlyAddedMap[NewMapStepSize * 2];\r | |
7347d5d6 | 2310 | \r |
95276127 | 2311 | CurrentMaxMode = *MaxMode;\r |
2312 | Mode = *CurrentMode;\r | |
2313 | \r | |
2314 | while (Index < CurrentMaxMode) {\r | |
fc753d3b | 2315 | if (*NewMapEntry == -1) {\r |
95276127 | 2316 | //\r |
2317 | // This mode is not supported any more. Remove it. Special care\r | |
2318 | // must be taken as this remove will also affect current mode;\r | |
2319 | //\r | |
2320 | if (Index == *CurrentMode) {\r | |
2321 | Mode = -1;\r | |
2322 | } else if (Index < *CurrentMode) {\r | |
2323 | Mode--;\r | |
2324 | }\r | |
2325 | (*MaxMode)--;\r | |
2326 | } else {\r | |
2327 | if (CurrentMapEntry != NextMapEntry) {\r | |
2328 | CopyMem (NextMapEntry, CurrentMapEntry, MapStepSize * sizeof (INT32));\r | |
2329 | }\r | |
2330 | \r | |
2331 | NextMapEntry += MapStepSize;\r | |
2332 | }\r | |
2333 | \r | |
2334 | CurrentMapEntry += MapStepSize;\r | |
fc753d3b | 2335 | NewMapEntry += NewMapStepSize;\r |
95276127 | 2336 | Index++;\r |
2337 | }\r | |
2338 | \r | |
2339 | *CurrentMode = Mode;\r | |
2340 | \r | |
2341 | return ;\r | |
2342 | }\r | |
2343 | \r | |
a4d608d1 | 2344 | /**\r |
2da292f6 | 2345 | Sync the device's output mode to console splitter's mode list.\r |
a4d608d1 | 2346 | \r |
33019a71 | 2347 | @param Private Text Out Splitter pointer.\r |
415df2a3 | 2348 | @param TextOut Simple Text Output protocol pointer.\r |
c33add67 | 2349 | \r |
a4d608d1 | 2350 | **/\r |
95276127 | 2351 | VOID\r |
2352 | ConSplitterSyncOutputMode (\r | |
2353 | IN TEXT_OUT_SPLITTER_PRIVATE_DATA *Private,\r | |
2354 | IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *TextOut\r | |
2355 | )\r | |
95276127 | 2356 | {\r |
2357 | INT32 CurrentMaxMode;\r | |
2358 | INT32 Mode;\r | |
2359 | INT32 Index;\r | |
2360 | INT32 *TextOutModeMap;\r | |
2361 | INT32 *MapTable;\r | |
3012ce5c | 2362 | INT32 QueryMode;\r |
95276127 | 2363 | TEXT_OUT_SPLITTER_QUERY_DATA *TextOutQueryData;\r |
2364 | UINTN Rows;\r | |
2365 | UINTN Columns;\r | |
2366 | UINTN StepSize;\r | |
7347d5d6 | 2367 | EFI_STATUS Status;\r |
95276127 | 2368 | \r |
2369 | //\r | |
2370 | // Must make sure that current mode won't change even if mode number changes\r | |
2371 | //\r | |
2372 | CurrentMaxMode = Private->TextOutMode.MaxMode;\r | |
2373 | TextOutModeMap = Private->TextOutModeMap;\r | |
2374 | StepSize = Private->TextOutListCount;\r | |
2375 | TextOutQueryData = Private->TextOutQueryData;\r | |
2376 | \r | |
2377 | //\r | |
2378 | // Query all the mode that the newly added TextOut supports\r | |
2379 | //\r | |
2380 | Mode = 0;\r | |
2381 | MapTable = TextOutModeMap + Private->CurrentNumberOfConsoles;\r | |
2382 | while (Mode < TextOut->Mode->MaxMode) {\r | |
7347d5d6 | 2383 | Status = TextOut->QueryMode (TextOut, Mode, &Columns, &Rows);\r |
fc753d3b | 2384 | \r |
7347d5d6 | 2385 | if (EFI_ERROR(Status)) {\r |
2386 | if (Mode == 1) {\r | |
fc753d3b | 2387 | //\r |
2388 | // If mode 1 (80x50) is not supported, make sure mode 1 in TextOutQueryData\r | |
2389 | // is clear to 0x0.\r | |
2390 | //\r | |
3012ce5c | 2391 | MapTable[StepSize] = Mode;\r |
7347d5d6 | 2392 | TextOutQueryData[Mode].Columns = 0;\r |
2393 | TextOutQueryData[Mode].Rows = 0;\r | |
2394 | }\r | |
2395 | Mode++;\r | |
2396 | continue;\r | |
2397 | }\r | |
95276127 | 2398 | //\r |
3012ce5c | 2399 | // Search the intersection map and QueryData database to see if they intersects\r |
95276127 | 2400 | //\r |
2401 | Index = 0;\r | |
2402 | while (Index < CurrentMaxMode) {\r | |
3012ce5c | 2403 | QueryMode = *(TextOutModeMap + Index * StepSize);\r |
2404 | if ((TextOutQueryData[QueryMode].Rows == Rows) && (TextOutQueryData[QueryMode].Columns == Columns)) {\r | |
95276127 | 2405 | MapTable[Index * StepSize] = Mode;\r |
2406 | break;\r | |
2407 | }\r | |
95276127 | 2408 | Index++;\r |
2409 | }\r | |
95276127 | 2410 | Mode++;\r |
2411 | }\r | |
2412 | //\r | |
2413 | // Now search the TextOutModeMap table to find the intersection of supported\r | |
2414 | // mode between ConSplitter and the newly added device.\r | |
2415 | //\r | |
2416 | ConSplitterGetIntersection (\r | |
2417 | TextOutModeMap,\r | |
2418 | MapTable,\r | |
2419 | StepSize,\r | |
2420 | StepSize,\r | |
2421 | &Private->TextOutMode.MaxMode,\r | |
2422 | &Private->TextOutMode.Mode\r | |
2423 | );\r | |
2424 | \r | |
2425 | return ;\r | |
2426 | }\r | |
2427 | \r | |
95276127 | 2428 | \r |
a4d608d1 | 2429 | /**\r |
415df2a3 | 2430 | Sync output device between ConOut and StdErr output.\r |
95276127 | 2431 | \r |
415df2a3 | 2432 | @retval EFI_SUCCESS Sync implemented successfully.\r |
2433 | @retval EFI_OUT_OF_RESOURCES Could not grow the buffer size.\r | |
95276127 | 2434 | \r |
a4d608d1 | 2435 | **/\r |
2436 | EFI_STATUS\r | |
2437 | ConSplitterGetIntersectionBetweenConOutAndStrErr (\r | |
2438 | VOID\r | |
2439 | )\r | |
95276127 | 2440 | {\r |
2441 | UINTN ConOutNumOfConsoles;\r | |
2442 | UINTN StdErrNumOfConsoles;\r | |
2443 | TEXT_OUT_AND_GOP_DATA *ConOutTextOutList;\r | |
2444 | TEXT_OUT_AND_GOP_DATA *StdErrTextOutList;\r | |
2445 | UINTN Indexi;\r | |
2446 | UINTN Indexj;\r | |
3012ce5c | 2447 | UINTN ConOutRows;\r |
2448 | UINTN ConOutColumns;\r | |
2449 | UINTN StdErrRows;\r | |
2450 | UINTN StdErrColumns;\r | |
95276127 | 2451 | INT32 ConOutMaxMode;\r |
2452 | INT32 StdErrMaxMode;\r | |
3012ce5c | 2453 | INT32 ConOutMode;\r |
2454 | INT32 StdErrMode;\r | |
95276127 | 2455 | INT32 Mode;\r |
2456 | INT32 Index;\r | |
2457 | INT32 *ConOutModeMap;\r | |
2458 | INT32 *StdErrModeMap;\r | |
2459 | INT32 *ConOutMapTable;\r | |
2460 | INT32 *StdErrMapTable;\r | |
2461 | TEXT_OUT_SPLITTER_QUERY_DATA *ConOutQueryData;\r | |
2462 | TEXT_OUT_SPLITTER_QUERY_DATA *StdErrQueryData;\r | |
3012ce5c | 2463 | UINTN ConOutStepSize;\r |
2464 | UINTN StdErrStepSize;\r | |
95276127 | 2465 | BOOLEAN FoundTheSameTextOut;\r |
2466 | UINTN ConOutMapTableSize;\r | |
2467 | UINTN StdErrMapTableSize;\r | |
2468 | \r | |
2469 | ConOutNumOfConsoles = mConOut.CurrentNumberOfConsoles;\r | |
2470 | StdErrNumOfConsoles = mStdErr.CurrentNumberOfConsoles;\r | |
2471 | ConOutTextOutList = mConOut.TextOutList;\r | |
2472 | StdErrTextOutList = mStdErr.TextOutList;\r | |
2473 | \r | |
2474 | Indexi = 0;\r | |
2475 | FoundTheSameTextOut = FALSE;\r | |
2476 | while ((Indexi < ConOutNumOfConsoles) && (!FoundTheSameTextOut)) {\r | |
2477 | Indexj = 0;\r | |
2478 | while (Indexj < StdErrNumOfConsoles) {\r | |
2479 | if (ConOutTextOutList->TextOut == StdErrTextOutList->TextOut) {\r | |
2480 | FoundTheSameTextOut = TRUE;\r | |
2481 | break;\r | |
2482 | }\r | |
2483 | \r | |
2484 | Indexj++;\r | |
2485 | StdErrTextOutList++;\r | |
2486 | }\r | |
2487 | \r | |
2488 | Indexi++;\r | |
2489 | ConOutTextOutList++;\r | |
2490 | }\r | |
2491 | \r | |
2492 | if (!FoundTheSameTextOut) {\r | |
2493 | return EFI_SUCCESS;\r | |
2494 | }\r | |
2495 | //\r | |
2496 | // Must make sure that current mode won't change even if mode number changes\r | |
2497 | //\r | |
2498 | ConOutMaxMode = mConOut.TextOutMode.MaxMode;\r | |
2499 | ConOutModeMap = mConOut.TextOutModeMap;\r | |
3012ce5c | 2500 | ConOutStepSize = mConOut.TextOutListCount;\r |
95276127 | 2501 | ConOutQueryData = mConOut.TextOutQueryData;\r |
2502 | \r | |
2503 | StdErrMaxMode = mStdErr.TextOutMode.MaxMode;\r | |
2504 | StdErrModeMap = mStdErr.TextOutModeMap;\r | |
3012ce5c | 2505 | StdErrStepSize = mStdErr.TextOutListCount;\r |
95276127 | 2506 | StdErrQueryData = mStdErr.TextOutQueryData;\r |
2507 | \r | |
2508 | //\r | |
2509 | // Allocate the map table and set the map table's index to -1.\r | |
2510 | //\r | |
2511 | ConOutMapTableSize = ConOutMaxMode * sizeof (INT32);\r | |
2512 | ConOutMapTable = AllocateZeroPool (ConOutMapTableSize);\r | |
2513 | if (ConOutMapTable == NULL) {\r | |
2514 | return EFI_OUT_OF_RESOURCES;\r | |
2515 | }\r | |
2516 | \r | |
2517 | SetMem (ConOutMapTable, ConOutMapTableSize, 0xFF);\r | |
2518 | \r | |
2519 | StdErrMapTableSize = StdErrMaxMode * sizeof (INT32);\r | |
2520 | StdErrMapTable = AllocateZeroPool (StdErrMapTableSize);\r | |
2521 | if (StdErrMapTable == NULL) {\r | |
2522 | return EFI_OUT_OF_RESOURCES;\r | |
2523 | }\r | |
2524 | \r | |
2525 | SetMem (StdErrMapTable, StdErrMapTableSize, 0xFF);\r | |
2526 | \r | |
2527 | //\r | |
2528 | // Find the intersection of the two set of modes. If they actually intersect, the\r | |
2529 | // correponding entry in the map table is set to 1.\r | |
2530 | //\r | |
2531 | Mode = 0;\r | |
2532 | while (Mode < ConOutMaxMode) {\r | |
2533 | //\r | |
3012ce5c | 2534 | // Search the intersection map and QueryData database to see if they intersect\r |
95276127 | 2535 | //\r |
3012ce5c | 2536 | Index = 0;\r |
2537 | ConOutMode = *(ConOutModeMap + Mode * ConOutStepSize);\r | |
2538 | ConOutRows = ConOutQueryData[ConOutMode].Rows;\r | |
2539 | ConOutColumns = ConOutQueryData[ConOutMode].Columns;\r | |
95276127 | 2540 | while (Index < StdErrMaxMode) {\r |
3012ce5c | 2541 | StdErrMode = *(StdErrModeMap + Index * StdErrStepSize);\r |
2542 | StdErrRows = StdErrQueryData[StdErrMode].Rows;\r | |
2543 | StdErrColumns = StdErrQueryData[StdErrMode].Columns;\r | |
2544 | if ((StdErrRows == ConOutRows) && (StdErrColumns == ConOutColumns)) {\r | |
95276127 | 2545 | ConOutMapTable[Mode] = 1;\r |
2546 | StdErrMapTable[Index] = 1;\r | |
2547 | break;\r | |
2548 | }\r | |
2549 | \r | |
2550 | Index++;\r | |
2551 | }\r | |
2552 | \r | |
2553 | Mode++;\r | |
2554 | }\r | |
2555 | //\r | |
2556 | // Now search the TextOutModeMap table to find the intersection of supported\r | |
2557 | // mode between ConSplitter and the newly added device.\r | |
2558 | //\r | |
2559 | ConSplitterGetIntersection (\r | |
2560 | ConOutModeMap,\r | |
2561 | ConOutMapTable,\r | |
2562 | mConOut.TextOutListCount,\r | |
2563 | 1,\r | |
2564 | &(mConOut.TextOutMode.MaxMode),\r | |
2565 | &(mConOut.TextOutMode.Mode)\r | |
2566 | );\r | |
fc753d3b | 2567 | \r |
95276127 | 2568 | if (mConOut.TextOutMode.Mode < 0) {\r |
2569 | mConOut.TextOut.SetMode (&(mConOut.TextOut), 0);\r | |
2570 | }\r | |
2571 | \r | |
2572 | ConSplitterGetIntersection (\r | |
2573 | StdErrModeMap,\r | |
2574 | StdErrMapTable,\r | |
2575 | mStdErr.TextOutListCount,\r | |
2576 | 1,\r | |
2577 | &(mStdErr.TextOutMode.MaxMode),\r | |
2578 | &(mStdErr.TextOutMode.Mode)\r | |
2579 | );\r | |
fc753d3b | 2580 | \r |
95276127 | 2581 | if (mStdErr.TextOutMode.Mode < 0) {\r |
2582 | mStdErr.TextOut.SetMode (&(mStdErr.TextOut), 0);\r | |
2583 | }\r | |
2584 | \r | |
2585 | FreePool (ConOutMapTable);\r | |
2586 | FreePool (StdErrMapTable);\r | |
2587 | \r | |
2588 | return EFI_SUCCESS;\r | |
2589 | }\r | |
2590 | \r | |
a4d608d1 | 2591 | \r |
2592 | /**\r | |
2da292f6 | 2593 | Add Grahpics Output modes into Consplitter Text Out list.\r |
a4d608d1 | 2594 | \r |
415df2a3 | 2595 | @param Private Text Out Splitter pointer.\r |
2596 | @param GraphicsOutput Graphics Output protocol pointer.\r | |
2597 | @param UgaDraw UGA Draw protocol pointer.\r | |
a4d608d1 | 2598 | \r |
415df2a3 | 2599 | @retval EFI_SUCCESS Output mode added successfully.\r |
2600 | @retval other Failed to add output mode.\r | |
a4d608d1 | 2601 | \r |
2602 | **/\r | |
95276127 | 2603 | EFI_STATUS\r |
2da292f6 | 2604 | ConSplitterAddGraphicsOutputMode (\r |
95276127 | 2605 | IN TEXT_OUT_SPLITTER_PRIVATE_DATA *Private,\r |
2606 | IN EFI_GRAPHICS_OUTPUT_PROTOCOL *GraphicsOutput,\r | |
2607 | IN EFI_UGA_DRAW_PROTOCOL *UgaDraw\r | |
2608 | )\r | |
95276127 | 2609 | {\r |
2610 | EFI_STATUS Status;\r | |
2611 | UINTN Index;\r | |
3012ce5c | 2612 | UINTN CurrentIndex;\r |
aec072ad | 2613 | EFI_GRAPHICS_OUTPUT_MODE_INFORMATION *Mode;\r |
95276127 | 2614 | UINTN SizeOfInfo;\r |
2615 | EFI_GRAPHICS_OUTPUT_MODE_INFORMATION *Info;\r | |
2616 | EFI_GRAPHICS_OUTPUT_PROTOCOL_MODE *CurrentGraphicsOutputMode;\r | |
aec072ad | 2617 | EFI_GRAPHICS_OUTPUT_MODE_INFORMATION *ModeBuffer;\r |
2618 | EFI_GRAPHICS_OUTPUT_MODE_INFORMATION *MatchedMode;\r | |
95276127 | 2619 | UINTN NumberIndex;\r |
2620 | BOOLEAN Match;\r | |
aec072ad | 2621 | BOOLEAN AlreadyExist;\r |
3012ce5c | 2622 | UINT32 UgaHorizontalResolution;\r |
2623 | UINT32 UgaVerticalResolution;\r | |
2624 | UINT32 UgaColorDepth;\r | |
2625 | UINT32 UgaRefreshRate;\r | |
95276127 | 2626 | \r |
2da292f6 | 2627 | ASSERT (GraphicsOutput != NULL || UgaDraw != NULL);\r |
95276127 | 2628 | \r |
2629 | CurrentGraphicsOutputMode = Private->GraphicsOutput.Mode;\r | |
2630 | \r | |
aec072ad | 2631 | Index = 0;\r |
3012ce5c | 2632 | CurrentIndex = 0;\r |
46f0e2a9 | 2633 | Status = EFI_SUCCESS;\r |
aec072ad | 2634 | \r |
2635 | if (Private->CurrentNumberOfUgaDraw != 0) {\r | |
2636 | //\r | |
2637 | // If any UGA device has already been added, then there is no need to\r | |
2638 | // calculate intersection of display mode of different GOP/UGA device,\r | |
2639 | // since only one display mode will be exported (i.e. user-defined mode)\r | |
2640 | //\r | |
2641 | goto Done;\r | |
2642 | }\r | |
2643 | \r | |
95276127 | 2644 | if (GraphicsOutput != NULL) {\r |
2645 | if (Private->CurrentNumberOfGraphicsOutput == 0) {\r | |
2646 | //\r | |
2647 | // This is the first Graphics Output device added\r | |
2648 | //\r | |
f890b1e0 | 2649 | CurrentGraphicsOutputMode->MaxMode = GraphicsOutput->Mode->MaxMode;\r |
2650 | CurrentGraphicsOutputMode->Mode = GraphicsOutput->Mode->Mode;\r | |
95276127 | 2651 | CopyMem (CurrentGraphicsOutputMode->Info, GraphicsOutput->Mode->Info, GraphicsOutput->Mode->SizeOfInfo);\r |
f890b1e0 | 2652 | CurrentGraphicsOutputMode->SizeOfInfo = GraphicsOutput->Mode->SizeOfInfo;\r |
2653 | CurrentGraphicsOutputMode->FrameBufferBase = GraphicsOutput->Mode->FrameBufferBase;\r | |
2654 | CurrentGraphicsOutputMode->FrameBufferSize = GraphicsOutput->Mode->FrameBufferSize;\r | |
76649bf4 | 2655 | \r |
95276127 | 2656 | //\r |
2657 | // Allocate resource for the private mode buffer\r | |
2658 | //\r | |
fc753d3b | 2659 | ModeBuffer = AllocatePool (sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION) * GraphicsOutput->Mode->MaxMode);\r |
95276127 | 2660 | if (ModeBuffer == NULL) {\r |
2661 | return EFI_OUT_OF_RESOURCES;\r | |
2662 | }\r | |
2663 | FreePool (Private->GraphicsOutputModeBuffer);\r | |
2664 | Private->GraphicsOutputModeBuffer = ModeBuffer;\r | |
2665 | \r | |
2666 | //\r | |
2667 | // Store all supported display modes to the private mode buffer\r | |
2668 | //\r | |
2669 | Mode = ModeBuffer;\r | |
2670 | for (Index = 0; Index < GraphicsOutput->Mode->MaxMode; Index++) {\r | |
fc753d3b | 2671 | //\r |
2672 | // The Info buffer would be allocated by callee\r | |
2673 | //\r | |
95276127 | 2674 | Status = GraphicsOutput->QueryMode (GraphicsOutput, (UINT32) Index, &SizeOfInfo, &Info);\r |
2675 | if (EFI_ERROR (Status)) {\r | |
2676 | return Status;\r | |
2677 | }\r | |
fc753d3b | 2678 | ASSERT ( SizeOfInfo <= sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION));\r |
aec072ad | 2679 | CopyMem (Mode, Info, SizeOfInfo);\r |
95276127 | 2680 | Mode++;\r |
2681 | FreePool (Info);\r | |
2682 | }\r | |
2683 | } else {\r | |
2684 | //\r | |
2685 | // Check intersection of display mode\r | |
2686 | //\r | |
aec072ad | 2687 | ModeBuffer = AllocatePool (sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION) * CurrentGraphicsOutputMode->MaxMode);\r |
95276127 | 2688 | if (ModeBuffer == NULL) {\r |
2689 | return EFI_OUT_OF_RESOURCES;\r | |
2690 | }\r | |
2691 | \r | |
2692 | MatchedMode = ModeBuffer;\r | |
2693 | Mode = &Private->GraphicsOutputModeBuffer[0];\r | |
2694 | for (Index = 0; Index < CurrentGraphicsOutputMode->MaxMode; Index++) {\r | |
2695 | Match = FALSE;\r | |
2696 | \r | |
2697 | for (NumberIndex = 0; NumberIndex < GraphicsOutput->Mode->MaxMode; NumberIndex++) {\r | |
fc753d3b | 2698 | //\r |
2699 | // The Info buffer would be allocated by callee\r | |
2700 | //\r | |
95276127 | 2701 | Status = GraphicsOutput->QueryMode (GraphicsOutput, (UINT32) NumberIndex, &SizeOfInfo, &Info);\r |
2702 | if (EFI_ERROR (Status)) {\r | |
2703 | return Status;\r | |
2704 | }\r | |
2705 | if ((Info->HorizontalResolution == Mode->HorizontalResolution) &&\r | |
aec072ad | 2706 | (Info->VerticalResolution == Mode->VerticalResolution)) {\r |
fc753d3b | 2707 | //\r |
c33add67 | 2708 | // If GOP device supports one mode in current mode buffer,\r |
fc753d3b | 2709 | // it will be added into matched mode buffer\r |
2710 | //\r | |
95276127 | 2711 | Match = TRUE;\r |
2712 | FreePool (Info);\r | |
2713 | break;\r | |
2714 | }\r | |
2715 | FreePool (Info);\r | |
2716 | }\r | |
2717 | \r | |
2718 | if (Match) {\r | |
aec072ad | 2719 | AlreadyExist = FALSE;\r |
c33add67 | 2720 | \r |
fc753d3b | 2721 | //\r |
2722 | // Check if GOP mode has been in the mode buffer, ModeBuffer = MatchedMode at begin.\r | |
2723 | //\r | |
aec072ad | 2724 | for (Info = ModeBuffer; Info < MatchedMode; Info++) {\r |
2725 | if ((Info->HorizontalResolution == Mode->HorizontalResolution) &&\r | |
2726 | (Info->VerticalResolution == Mode->VerticalResolution)) {\r | |
2727 | AlreadyExist = TRUE;\r | |
2728 | break;\r | |
2729 | }\r | |
2730 | }\r | |
2731 | \r | |
2732 | if (!AlreadyExist) {\r | |
2733 | CopyMem (MatchedMode, Mode, sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION));\r | |
2734 | \r | |
2735 | //\r | |
2736 | // Physical frame buffer is no longer available, change PixelFormat to PixelBltOnly\r | |
2737 | //\r | |
2738 | MatchedMode->Version = 0;\r | |
2739 | MatchedMode->PixelFormat = PixelBltOnly;\r | |
2740 | ZeroMem (&MatchedMode->PixelInformation, sizeof (EFI_PIXEL_BITMASK));\r | |
2741 | \r | |
2742 | MatchedMode++;\r | |
2743 | }\r | |
95276127 | 2744 | }\r |
2745 | \r | |
2746 | Mode++;\r | |
2747 | }\r | |
2748 | \r | |
2749 | //\r | |
2750 | // Drop the old mode buffer, assign it to a new one\r | |
2751 | //\r | |
2752 | FreePool (Private->GraphicsOutputModeBuffer);\r | |
2753 | Private->GraphicsOutputModeBuffer = ModeBuffer;\r | |
2754 | \r | |
2755 | //\r | |
2756 | // Physical frame buffer is no longer available when there are more than one physical GOP devices\r | |
2757 | //\r | |
aec072ad | 2758 | CurrentGraphicsOutputMode->MaxMode = (UINT32) (((UINTN) MatchedMode - (UINTN) ModeBuffer) / sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION));\r |
95276127 | 2759 | CurrentGraphicsOutputMode->Info->PixelFormat = PixelBltOnly;\r |
2760 | ZeroMem (&CurrentGraphicsOutputMode->Info->PixelInformation, sizeof (EFI_PIXEL_BITMASK));\r | |
2761 | CurrentGraphicsOutputMode->SizeOfInfo = sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION);\r | |
1be0dda6 | 2762 | CurrentGraphicsOutputMode->FrameBufferBase = (EFI_PHYSICAL_ADDRESS) (UINTN) NULL;\r |
95276127 | 2763 | CurrentGraphicsOutputMode->FrameBufferSize = 0;\r |
2764 | }\r | |
2765 | \r | |
2766 | //\r | |
3012ce5c | 2767 | // Graphics console driver can ensure the same mode for all GOP devices\r |
95276127 | 2768 | //\r |
2769 | for (Index = 0; Index < CurrentGraphicsOutputMode->MaxMode; Index++) {\r | |
2770 | Mode = &Private->GraphicsOutputModeBuffer[Index];\r | |
3012ce5c | 2771 | if ((Mode->HorizontalResolution == GraphicsOutput->Mode->Info->HorizontalResolution) &&\r |
2772 | (Mode->VerticalResolution == GraphicsOutput->Mode->Info->VerticalResolution)) {\r | |
2773 | CurrentIndex = Index;\r | |
95276127 | 2774 | break;\r |
2775 | }\r | |
2776 | }\r | |
95276127 | 2777 | if (Index >= CurrentGraphicsOutputMode->MaxMode) {\r |
3012ce5c | 2778 | //\r |
2779 | // if user defined mode is not found, set to default mode 800x600\r | |
2780 | //\r | |
2781 | for (Index = 0; Index < CurrentGraphicsOutputMode->MaxMode; Index++) {\r | |
2782 | Mode = &Private->GraphicsOutputModeBuffer[Index];\r | |
2783 | if ((Mode->HorizontalResolution == 800) && (Mode->VerticalResolution == 600)) {\r | |
2784 | CurrentIndex = Index;\r | |
2785 | break;\r | |
2786 | }\r | |
2787 | }\r | |
95276127 | 2788 | }\r |
2da292f6 | 2789 | } else if (UgaDraw != NULL && FeaturePcdGet (PcdUgaConsumeSupport)) {\r |
95276127 | 2790 | //\r |
3012ce5c | 2791 | // Graphics console driver can ensure the same mode for all GOP devices\r |
2792 | // so we can get the current mode from this video device\r | |
95276127 | 2793 | //\r |
3012ce5c | 2794 | UgaDraw->GetMode (\r |
2795 | UgaDraw,\r | |
2796 | &UgaHorizontalResolution,\r | |
2797 | &UgaVerticalResolution,\r | |
2798 | &UgaColorDepth,\r | |
2799 | &UgaRefreshRate\r | |
2800 | );\r | |
2801 | \r | |
95276127 | 2802 | CurrentGraphicsOutputMode->MaxMode = 1;\r |
aec072ad | 2803 | Info = CurrentGraphicsOutputMode->Info;\r |
2804 | Info->Version = 0;\r | |
2da292f6 | 2805 | Info->HorizontalResolution = UgaHorizontalResolution;\r |
2806 | Info->VerticalResolution = UgaVerticalResolution;\r | |
2807 | Info->PixelFormat = PixelBltOnly;\r | |
2808 | Info->PixelsPerScanLine = UgaHorizontalResolution;\r | |
2809 | CurrentGraphicsOutputMode->SizeOfInfo = sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION);\r | |
1be0dda6 | 2810 | CurrentGraphicsOutputMode->FrameBufferBase = (EFI_PHYSICAL_ADDRESS) (UINTN) NULL;\r |
95276127 | 2811 | CurrentGraphicsOutputMode->FrameBufferSize = 0;\r |
2812 | \r | |
2813 | //\r | |
2814 | // Update the private mode buffer\r | |
2815 | //\r | |
aec072ad | 2816 | CopyMem (&Private->GraphicsOutputModeBuffer[0], Info, sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION));\r |
95276127 | 2817 | \r |
2818 | //\r | |
aec072ad | 2819 | // Only mode 0 is available to be set\r |
95276127 | 2820 | //\r |
3012ce5c | 2821 | CurrentIndex = 0;\r |
95276127 | 2822 | }\r |
2823 | \r | |
aec072ad | 2824 | Done:\r |
2825 | \r | |
2826 | if (GraphicsOutput != NULL) {\r | |
2827 | Private->CurrentNumberOfGraphicsOutput++;\r | |
2828 | }\r | |
8541adab | 2829 | if (UgaDraw != NULL && FeaturePcdGet (PcdUgaConsumeSupport)) {\r |
aec072ad | 2830 | Private->CurrentNumberOfUgaDraw++;\r |
2831 | }\r | |
2832 | \r | |
95276127 | 2833 | //\r |
2834 | // Force GraphicsOutput mode to be set,\r | |
95276127 | 2835 | //\r |
46f0e2a9 | 2836 | \r |
2837 | Mode = &Private->GraphicsOutputModeBuffer[CurrentIndex];\r | |
2838 | if ((GraphicsOutput != NULL) &&\r | |
2839 | (Mode->HorizontalResolution == CurrentGraphicsOutputMode->Info->HorizontalResolution) &&\r | |
2840 | (Mode->VerticalResolution == CurrentGraphicsOutputMode->Info->VerticalResolution)) {\r | |
2841 | CurrentGraphicsOutputMode->Mode = (UINT32) CurrentIndex;\r | |
2842 | if ((Mode->HorizontalResolution != GraphicsOutput->Mode->Info->HorizontalResolution) ||\r | |
2843 | (Mode->VerticalResolution != GraphicsOutput->Mode->Info->VerticalResolution)) {\r | |
2844 | //\r | |
2845 | // If all existing video device has been set to common mode, only set new GOP device to\r | |
2846 | // the common mode\r | |
2847 | //\r | |
2848 | for (NumberIndex = 0; NumberIndex < GraphicsOutput->Mode->MaxMode; NumberIndex ++) {\r | |
2849 | Status = GraphicsOutput->QueryMode (GraphicsOutput, (UINT32) NumberIndex, &SizeOfInfo, &Info);\r | |
2850 | if (EFI_ERROR (Status)) {\r | |
2851 | return Status;\r | |
2852 | }\r | |
2853 | if ((Info->HorizontalResolution == Mode->HorizontalResolution) && (Info->VerticalResolution == Mode->VerticalResolution)) {\r | |
2854 | FreePool (Info);\r | |
2855 | break;\r | |
2856 | }\r | |
2857 | FreePool (Info);\r | |
2858 | }\r | |
2859 | Status = GraphicsOutput->SetMode (GraphicsOutput, (UINT32) NumberIndex);\r | |
2860 | }\r | |
2861 | } else {\r | |
2862 | //\r | |
2863 | // Current mode number may need update now, so set it to an invalid mode number\r | |
fc753d3b | 2864 | //\r |
46f0e2a9 | 2865 | CurrentGraphicsOutputMode->Mode = 0xffff;\r |
fc753d3b | 2866 | //\r |
46f0e2a9 | 2867 | // Graphics console can ensure all GOP devices have the same mode which can be taken as current mode.\r |
2868 | //\r | |
2869 | Status = Private->GraphicsOutput.SetMode (&Private->GraphicsOutput, (UINT32) CurrentIndex);\r | |
2870 | if (EFI_ERROR(Status)) {\r | |
2871 | //\r | |
2872 | // If user defined mode is not valid for display device, set to the default mode 800x600.\r | |
2873 | //\r | |
2874 | (Private->GraphicsOutputModeBuffer[0]).HorizontalResolution = 800;\r | |
2875 | (Private->GraphicsOutputModeBuffer[0]).VerticalResolution = 600;\r | |
2876 | Status = Private->GraphicsOutput.SetMode (&Private->GraphicsOutput, 0);\r | |
2877 | }\r | |
3012ce5c | 2878 | }\r |
95276127 | 2879 | \r |
95276127 | 2880 | return Status;\r |
2881 | }\r | |
2882 | \r | |
a4d608d1 | 2883 | /**\r |
2da292f6 | 2884 | Set the current console out mode.\r |
2885 | \r | |
189eac21 | 2886 | This routine will get the current console mode information (column, row)\r |
2887 | from ConsoleOutMode variable and set it; if the variable does not exist,\r | |
2888 | set to user defined console mode.\r | |
2889 | \r | |
33019a71 | 2890 | @param Private Consplitter Text Out pointer.\r |
189eac21 | 2891 | \r |
a4d608d1 | 2892 | **/\r |
2893 | VOID\r | |
2894 | ConsplitterSetConsoleOutMode (\r | |
2895 | IN TEXT_OUT_SPLITTER_PRIVATE_DATA *Private\r | |
2896 | )\r | |
189eac21 | 2897 | {\r |
2da292f6 | 2898 | UINTN Col;\r |
2899 | UINTN Row;\r | |
2900 | UINTN Mode;\r | |
2901 | UINTN PreferMode;\r | |
2902 | UINTN BaseMode;\r | |
2903 | UINTN MaxMode;\r | |
2904 | EFI_STATUS Status;\r | |
2905 | CONSOLE_OUT_MODE ModeInfo;\r | |
b9b5e307 | 2906 | CONSOLE_OUT_MODE MaxModeInfo;\r |
189eac21 | 2907 | EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *TextOut;\r |
8541adab | 2908 | \r |
189eac21 | 2909 | PreferMode = 0xFF;\r |
2910 | BaseMode = 0xFF;\r | |
2911 | TextOut = &Private->TextOut;\r | |
2912 | MaxMode = (UINTN) (TextOut->Mode->MaxMode);\r | |
189eac21 | 2913 | \r |
b9b5e307 | 2914 | MaxModeInfo.Column = 0;\r |
2915 | MaxModeInfo.Row = 0; \r | |
2916 | ModeInfo.Column = PcdGet32 (PcdConOutColumn);\r | |
2917 | ModeInfo.Row = PcdGet32 (PcdConOutRow);\r | |
8541adab | 2918 | \r |
2da292f6 | 2919 | //\r |
2920 | // To find the prefer mode and basic mode from Text Out mode list\r | |
2921 | //\r | |
189eac21 | 2922 | for (Mode = 0; Mode < MaxMode; Mode++) {\r |
2923 | Status = TextOut->QueryMode (TextOut, Mode, &Col, &Row);\r | |
2924 | if (!EFI_ERROR(Status)) {\r | |
b9b5e307 | 2925 | if ((ModeInfo.Column != 0) && (ModeInfo.Row != 0)) {\r |
2926 | //\r | |
2927 | // Use user defined column and row\r | |
2928 | //\r | |
2929 | if (Col == ModeInfo.Column && Row == ModeInfo.Row) {\r | |
2930 | PreferMode = Mode;\r | |
2931 | }\r | |
2932 | } else {\r | |
2933 | //\r | |
2934 | // If user sets PcdConOutColumn or PcdConOutRow to 0,\r | |
2935 | // find and set the highest text mode.\r | |
2936 | //\r | |
2937 | if ((Col >= MaxModeInfo.Column) && (Row >= MaxModeInfo.Row)) {\r | |
2938 | MaxModeInfo.Column = Col;\r | |
2939 | MaxModeInfo.Row = Row;\r | |
2940 | PreferMode = Mode;\r | |
2941 | }\r | |
189eac21 | 2942 | }\r |
2943 | if (Col == 80 && Row == 25) {\r | |
2944 | BaseMode = Mode;\r | |
2945 | }\r | |
2946 | }\r | |
2947 | }\r | |
8541adab | 2948 | \r |
189eac21 | 2949 | //\r |
589f16d2 | 2950 | // Set prefer mode to Text Out devices.\r |
189eac21 | 2951 | //\r |
2da292f6 | 2952 | Status = TextOut->SetMode (TextOut, PreferMode);\r |
189eac21 | 2953 | if (EFI_ERROR(Status)) {\r |
2da292f6 | 2954 | //\r |
2955 | // if current mode setting is failed, default 80x25 mode will be set.\r | |
2956 | //\r | |
189eac21 | 2957 | Status = TextOut->SetMode (TextOut, BaseMode);\r |
2958 | ASSERT(!EFI_ERROR(Status));\r | |
76649bf4 | 2959 | \r |
589f16d2 | 2960 | PcdSet32 (PcdConOutColumn, 80);\r |
2961 | PcdSet32 (PcdConOutRow, 25);\r | |
189eac21 | 2962 | }\r |
2963 | \r | |
2da292f6 | 2964 | return ;\r |
189eac21 | 2965 | }\r |
2966 | \r | |
2967 | \r | |
a4d608d1 | 2968 | /**\r |
415df2a3 | 2969 | Add Text Output Device in Consplitter Text Output list.\r |
a4d608d1 | 2970 | \r |
415df2a3 | 2971 | @param Private Text Out Splitter pointer.\r |
2972 | @param TextOut Simple Text Output protocol pointer.\r | |
2973 | @param GraphicsOutput Graphics Output protocol pointer.\r | |
2974 | @param UgaDraw UGA Draw protocol pointer.\r | |
a4d608d1 | 2975 | \r |
415df2a3 | 2976 | @retval EFI_SUCCESS Text Output Device added successfully.\r |
2977 | @retval EFI_OUT_OF_RESOURCES Could not grow the buffer size.\r | |
a4d608d1 | 2978 | \r |
2979 | **/\r | |
95276127 | 2980 | EFI_STATUS\r |
2981 | ConSplitterTextOutAddDevice (\r | |
2982 | IN TEXT_OUT_SPLITTER_PRIVATE_DATA *Private,\r | |
2983 | IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *TextOut,\r | |
2984 | IN EFI_GRAPHICS_OUTPUT_PROTOCOL *GraphicsOutput,\r | |
2985 | IN EFI_UGA_DRAW_PROTOCOL *UgaDraw\r | |
2986 | )\r | |
95276127 | 2987 | {\r |
2da292f6 | 2988 | EFI_STATUS Status;\r |
2989 | UINTN CurrentNumOfConsoles;\r | |
2da292f6 | 2990 | INT32 MaxMode;\r |
2991 | UINT32 UgaHorizontalResolution;\r | |
2992 | UINT32 UgaVerticalResolution;\r | |
2993 | UINT32 UgaColorDepth;\r | |
2994 | UINT32 UgaRefreshRate;\r | |
2995 | TEXT_OUT_AND_GOP_DATA *TextAndGop;\r | |
2996 | UINTN SizeOfInfo;\r | |
2997 | EFI_GRAPHICS_OUTPUT_MODE_INFORMATION *Info;\r | |
d6e11f22 | 2998 | EFI_STATUS DeviceStatus;\r |
95276127 | 2999 | \r |
3000 | Status = EFI_SUCCESS;\r | |
3001 | CurrentNumOfConsoles = Private->CurrentNumberOfConsoles;\r | |
3002 | \r | |
3003 | //\r | |
fc753d3b | 3004 | // If the Text Out List is full, enlarge it by calling ConSplitterGrowBuffer().\r |
95276127 | 3005 | //\r |
3006 | while (CurrentNumOfConsoles >= Private->TextOutListCount) {\r | |
3007 | Status = ConSplitterGrowBuffer (\r | |
3008 | sizeof (TEXT_OUT_AND_GOP_DATA),\r | |
3009 | &Private->TextOutListCount,\r | |
3010 | (VOID **) &Private->TextOutList\r | |
3011 | );\r | |
3012 | if (EFI_ERROR (Status)) {\r | |
3013 | return EFI_OUT_OF_RESOURCES;\r | |
3014 | }\r | |
3015 | //\r | |
3016 | // Also need to reallocate the TextOutModeMap table\r | |
3017 | //\r | |
3018 | Status = ConSplitterGrowMapTable (Private);\r | |
3019 | if (EFI_ERROR (Status)) {\r | |
3020 | return EFI_OUT_OF_RESOURCES;\r | |
3021 | }\r | |
3022 | }\r | |
3023 | \r | |
3024 | TextAndGop = &Private->TextOutList[CurrentNumOfConsoles];\r | |
3025 | \r | |
2da292f6 | 3026 | TextAndGop->TextOut = TextOut;\r |
95276127 | 3027 | TextAndGop->GraphicsOutput = GraphicsOutput;\r |
2da292f6 | 3028 | TextAndGop->UgaDraw = UgaDraw;\r |
95276127 | 3029 | \r |
95276127 | 3030 | if (CurrentNumOfConsoles == 0) {\r |
3031 | //\r | |
3032 | // Add the first device's output mode to console splitter's mode list\r | |
3033 | //\r | |
3034 | Status = ConSplitterAddOutputMode (Private, TextOut);\r | |
3035 | } else {\r | |
3036 | ConSplitterSyncOutputMode (Private, TextOut);\r | |
3037 | }\r | |
3038 | \r | |
3039 | Private->CurrentNumberOfConsoles++;\r | |
3040 | \r | |
3041 | //\r | |
3042 | // Scan both TextOutList, for the intersection TextOut device\r | |
3043 | // maybe both ConOut and StdErr incorporate the same Text Out\r | |
3044 | // device in them, thus the output of both should be synced.\r | |
3045 | //\r | |
3046 | ConSplitterGetIntersectionBetweenConOutAndStrErr ();\r | |
3047 | \r | |
95276127 | 3048 | MaxMode = Private->TextOutMode.MaxMode;\r |
3049 | ASSERT (MaxMode >= 1);\r | |
3050 | \r | |
d6e11f22 | 3051 | DeviceStatus = EFI_DEVICE_ERROR;\r |
d0c64728 | 3052 | if (FeaturePcdGet (PcdConOutGopSupport)) {\r |
2da292f6 | 3053 | //\r |
3054 | // If GOP is produced by Consplitter, this device display mode will be added into Graphics Ouput modes.\r | |
3055 | //\r | |
3056 | if ((GraphicsOutput != NULL) || (UgaDraw != NULL && FeaturePcdGet (PcdUgaConsumeSupport))) {\r | |
d6e11f22 | 3057 | DeviceStatus = ConSplitterAddGraphicsOutputMode (Private, GraphicsOutput, UgaDraw);\r |
d0c64728 | 3058 | }\r |
95276127 | 3059 | }\r |
2da292f6 | 3060 | \r |
3012ce5c | 3061 | if (FeaturePcdGet (PcdConOutUgaSupport)) {\r |
2da292f6 | 3062 | //\r |
3063 | // If UGA is produced by Consplitter\r | |
3064 | //\r | |
3065 | if (GraphicsOutput != NULL) {\r | |
3066 | Status = GraphicsOutput->QueryMode (GraphicsOutput, GraphicsOutput->Mode->Mode, &SizeOfInfo, &Info);\r | |
3067 | if (EFI_ERROR (Status)) {\r | |
3068 | return Status;\r | |
3069 | }\r | |
3070 | ASSERT ( SizeOfInfo <= sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION));\r | |
3071 | \r | |
3072 | UgaHorizontalResolution = Info->HorizontalResolution;\r | |
3073 | UgaVerticalResolution = Info->VerticalResolution;\r | |
3074 | \r | |
3075 | FreePool (Info);\r | |
c33add67 | 3076 | \r |
2da292f6 | 3077 | } else if (UgaDraw != NULL && FeaturePcdGet (PcdUgaConsumeSupport)) {\r |
3012ce5c | 3078 | Status = UgaDraw->GetMode (\r |
3079 | UgaDraw,\r | |
3080 | &UgaHorizontalResolution,\r | |
3081 | &UgaVerticalResolution,\r | |
3082 | &UgaColorDepth,\r | |
3083 | &UgaRefreshRate\r | |
3084 | );\r | |
d6e11f22 | 3085 | if (!EFI_ERROR (Status) && EFI_ERROR (DeviceStatus)) {\r |
3086 | //\r | |
3087 | // if GetMode is successfully and UGA device hasn't been set, set it\r | |
3088 | //\r | |
3089 | Status = ConSplitterUgaDrawSetMode (\r | |
76649bf4 | 3090 | &Private->UgaDraw,\r |
3091 | UgaHorizontalResolution,\r | |
3092 | UgaVerticalResolution,\r | |
3093 | UgaColorDepth,\r | |
d6e11f22 | 3094 | UgaRefreshRate\r |
3095 | );\r | |
3096 | }\r | |
3097 | //\r | |
3098 | // If GetMode/SetMode is failed, set to 800x600 mode\r | |
3099 | //\r | |
3100 | if(EFI_ERROR (Status)) {\r | |
3101 | Status = ConSplitterUgaDrawSetMode (\r | |
76649bf4 | 3102 | &Private->UgaDraw,\r |
3103 | 800,\r | |
3104 | 600,\r | |
3105 | 32,\r | |
d6e11f22 | 3106 | 60\r |
3107 | );\r | |
3108 | }\r | |
3012ce5c | 3109 | }\r |
3110 | }\r | |
95276127 | 3111 | \r |
189eac21 | 3112 | //\r |
8541adab | 3113 | // After adding new console device, all existing console devices should be\r |
189eac21 | 3114 | // synced to the current shared mode.\r |
3115 | //\r | |
3116 | ConsplitterSetConsoleOutMode (Private);\r | |
3117 | \r | |
95276127 | 3118 | return Status;\r |
3119 | }\r | |
3120 | \r | |
a4d608d1 | 3121 | \r |
3122 | /**\r | |
415df2a3 | 3123 | Remove Text Out Device in Consplitter Text Out list.\r |
a4d608d1 | 3124 | \r |
415df2a3 | 3125 | @param Private Text Out Splitter pointer.\r |
3126 | @param TextOut Simple Text Output Pointer protocol pointer.\r | |
a4d608d1 | 3127 | \r |
415df2a3 | 3128 | @retval EFI_SUCCESS Text Out Device removed successfully.\r |
3129 | @retval EFI_NOT_FOUND No Text Out Device found.\r | |
a4d608d1 | 3130 | \r |
3131 | **/\r | |
95276127 | 3132 | EFI_STATUS\r |
3133 | ConSplitterTextOutDeleteDevice (\r | |
3134 | IN TEXT_OUT_SPLITTER_PRIVATE_DATA *Private,\r | |
3135 | IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *TextOut\r | |
3136 | )\r | |
95276127 | 3137 | {\r |
3138 | INT32 Index;\r | |
3139 | UINTN CurrentNumOfConsoles;\r | |
3140 | TEXT_OUT_AND_GOP_DATA *TextOutList;\r | |
3141 | EFI_STATUS Status;\r | |
3142 | \r | |
3143 | //\r | |
3144 | // Remove the specified text-out device data structure from the Text out List,\r | |
3145 | // and rearrange the remaining data structures in the Text out List.\r | |
3146 | //\r | |
3147 | CurrentNumOfConsoles = Private->CurrentNumberOfConsoles;\r | |
3148 | Index = (INT32) CurrentNumOfConsoles - 1;\r | |
3149 | TextOutList = Private->TextOutList;\r | |
3150 | while (Index >= 0) {\r | |
3151 | if (TextOutList->TextOut == TextOut) {\r | |
8541adab | 3152 | if (TextOutList->UgaDraw != NULL && FeaturePcdGet (PcdUgaConsumeSupport)) {\r |
aec072ad | 3153 | Private->CurrentNumberOfUgaDraw--;\r |
3154 | }\r | |
3155 | if (TextOutList->GraphicsOutput != NULL) {\r | |
3156 | Private->CurrentNumberOfGraphicsOutput--;\r | |
3157 | }\r | |
54699671 | 3158 | CopyMem (TextOutList, TextOutList + 1, sizeof (TEXT_OUT_AND_GOP_DATA) * Index);\r |
3159 | CurrentNumOfConsoles--;\r | |
95276127 | 3160 | break;\r |
3161 | }\r | |
3162 | \r | |
3163 | Index--;\r | |
3164 | TextOutList++;\r | |
3165 | }\r | |
3166 | //\r | |
3167 | // The specified TextOut is not managed by the ConSplitter driver\r | |
3168 | //\r | |
3169 | if (Index < 0) {\r | |
3170 | return EFI_NOT_FOUND;\r | |
3171 | }\r | |
3172 | \r | |
3173 | if (CurrentNumOfConsoles == 0) {\r | |
3174 | //\r | |
9937b365 | 3175 | // If the number of consoles is zero, reset all parameters\r |
95276127 | 3176 | //\r |
3177 | Private->CurrentNumberOfConsoles = 0;\r | |
3178 | Private->TextOutMode.MaxMode = 1;\r | |
3179 | Private->TextOutQueryData[0].Columns = 80;\r | |
3180 | Private->TextOutQueryData[0].Rows = 25;\r | |
9937b365 | 3181 | TextOutSetMode (Private, 0);\r |
95276127 | 3182 | \r |
3183 | return EFI_SUCCESS;\r | |
3184 | }\r | |
3185 | //\r | |
3186 | // Max Mode is realy an intersection of the QueryMode command to all\r | |
3187 | // devices. So we must copy the QueryMode of the first device to\r | |
3188 | // QueryData.\r | |
3189 | //\r | |
3190 | ZeroMem (\r | |
3191 | Private->TextOutQueryData,\r | |
3192 | Private->TextOutQueryDataCount * sizeof (TEXT_OUT_SPLITTER_QUERY_DATA)\r | |
3193 | );\r | |
3194 | \r | |
3195 | FreePool (Private->TextOutModeMap);\r | |
3196 | Private->TextOutModeMap = NULL;\r | |
3197 | TextOutList = Private->TextOutList;\r | |
3198 | \r | |
3199 | //\r | |
3200 | // Add the first TextOut to the QueryData array and ModeMap table\r | |
3201 | //\r | |
3202 | Status = ConSplitterAddOutputMode (Private, TextOutList->TextOut);\r | |
3203 | \r | |
3204 | //\r | |
3205 | // Now add one by one\r | |
3206 | //\r | |
3207 | Index = 1;\r | |
3208 | Private->CurrentNumberOfConsoles = 1;\r | |
3209 | TextOutList++;\r | |
3210 | while ((UINTN) Index < CurrentNumOfConsoles) {\r | |
3211 | ConSplitterSyncOutputMode (Private, TextOutList->TextOut);\r | |
3212 | Index++;\r | |
3213 | Private->CurrentNumberOfConsoles++;\r | |
3214 | TextOutList++;\r | |
3215 | }\r | |
3216 | \r | |
3217 | ConSplitterGetIntersectionBetweenConOutAndStrErr ();\r | |
3218 | \r | |
3219 | return Status;\r | |
3220 | }\r | |
4b5c4fba | 3221 | \r |
a4d608d1 | 3222 | \r |
3223 | /**\r | |
3224 | Reset the input device and optionaly run diagnostics\r | |
3225 | \r | |
3226 | @param This Protocol instance pointer.\r | |
3227 | @param ExtendedVerification Driver may perform diagnostics on reset.\r | |
3228 | \r | |
3229 | @retval EFI_SUCCESS The device was reset.\r | |
3230 | @retval EFI_DEVICE_ERROR The device is not functioning properly and could\r | |
3231 | not be reset.\r | |
3232 | \r | |
3233 | **/\r | |
95276127 | 3234 | EFI_STATUS\r |
3235 | EFIAPI\r | |
3236 | ConSplitterTextInReset (\r | |
3237 | IN EFI_SIMPLE_TEXT_INPUT_PROTOCOL *This,\r | |
3238 | IN BOOLEAN ExtendedVerification\r | |
3239 | )\r | |
95276127 | 3240 | {\r |
3241 | EFI_STATUS Status;\r | |
3242 | EFI_STATUS ReturnStatus;\r | |
3243 | TEXT_IN_SPLITTER_PRIVATE_DATA *Private;\r | |
3244 | UINTN Index;\r | |
3245 | \r | |
3246 | Private = TEXT_IN_SPLITTER_PRIVATE_DATA_FROM_THIS (This);\r | |
3247 | \r | |
3248 | Private->KeyEventSignalState = FALSE;\r | |
3249 | \r | |
3250 | //\r | |
3251 | // return the worst status met\r | |
3252 | //\r | |
3253 | for (Index = 0, ReturnStatus = EFI_SUCCESS; Index < Private->CurrentNumberOfConsoles; Index++) {\r | |
3254 | Status = Private->TextInList[Index]->Reset (\r | |
3255 | Private->TextInList[Index],\r | |
3256 | ExtendedVerification\r | |
3257 | );\r | |
3258 | if (EFI_ERROR (Status)) {\r | |
3259 | ReturnStatus = Status;\r | |
3260 | }\r | |
3261 | }\r | |
3262 | \r | |
3263 | return ReturnStatus;\r | |
3264 | }\r | |
3265 | \r | |
a4d608d1 | 3266 | \r |
3267 | /**\r | |
3268 | Reads the next keystroke from the input device. The WaitForKey Event can\r | |
3269 | be used to test for existance of a keystroke via WaitForEvent () call.\r | |
3270 | \r | |
33019a71 | 3271 | @param Private Protocol instance pointer.\r |
a4d608d1 | 3272 | @param Key Driver may perform diagnostics on reset.\r |
3273 | \r | |
3274 | @retval EFI_SUCCESS The keystroke information was returned.\r | |
3275 | @retval EFI_NOT_READY There was no keystroke data availiable.\r | |
3276 | @retval EFI_DEVICE_ERROR The keydtroke information was not returned due\r | |
3277 | to hardware errors.\r | |
3278 | \r | |
3279 | **/\r | |
95276127 | 3280 | EFI_STATUS\r |
3281 | EFIAPI\r | |
3282 | ConSplitterTextInPrivateReadKeyStroke (\r | |
3283 | IN TEXT_IN_SPLITTER_PRIVATE_DATA *Private,\r | |
3284 | OUT EFI_INPUT_KEY *Key\r | |
3285 | )\r | |
95276127 | 3286 | {\r |
3287 | EFI_STATUS Status;\r | |
3288 | UINTN Index;\r | |
3289 | EFI_INPUT_KEY CurrentKey;\r | |
3290 | \r | |
3291 | Key->UnicodeChar = 0;\r | |
3292 | Key->ScanCode = SCAN_NULL;\r | |
3293 | \r | |
3294 | //\r | |
3295 | // if no physical console input device exists, return EFI_NOT_READY;\r | |
3296 | // if any physical console input device has key input,\r | |
3297 | // return the key and EFI_SUCCESS.\r | |
3298 | //\r | |
3299 | for (Index = 0; Index < Private->CurrentNumberOfConsoles; Index++) {\r | |
3300 | Status = Private->TextInList[Index]->ReadKeyStroke (\r | |
3301 | Private->TextInList[Index],\r | |
3302 | &CurrentKey\r | |
3303 | );\r | |
3304 | if (!EFI_ERROR (Status)) {\r | |
3305 | *Key = CurrentKey;\r | |
3306 | return Status;\r | |
3307 | }\r | |
3308 | }\r | |
3309 | \r | |
3310 | return EFI_NOT_READY;\r | |
3311 | }\r | |
3312 | \r | |
9b78227a | 3313 | /**\r |
838a9c58 | 3314 | Connect the specific Usb device which match the short form device path,\r |
3315 | and whose bus is determined by Host Controller.\r | |
3316 | \r | |
3317 | @param DevicePath A short-form device path that starts with the first\r | |
3318 | element being a USB WWID or a USB Class device\r | |
3319 | path\r | |
3320 | \r | |
3321 | @return EFI_INVALID_PARAMETER DevicePath is NULL pointer.\r | |
3322 | DevicePath is not a USB device path.\r | |
3323 | \r | |
3324 | @return EFI_SUCCESS Success to connect USB device\r | |
3325 | @return EFI_NOT_FOUND Fail to find handle for USB controller to connect.\r | |
3326 | \r | |
3327 | **/\r | |
3328 | EFI_STATUS\r | |
3329 | EFIAPI\r | |
3330 | ConSplitterConnectUsbShortFormDevicePath (\r | |
3331 | IN EFI_DEVICE_PATH_PROTOCOL *DevicePath\r | |
3332 | )\r | |
3333 | {\r | |
3334 | EFI_STATUS Status;\r | |
3335 | EFI_HANDLE *Handles;\r | |
3336 | UINTN HandleCount;\r | |
3337 | UINTN Index;\r | |
3338 | EFI_PCI_IO_PROTOCOL *PciIo;\r | |
3339 | UINT8 Class[3];\r | |
3340 | BOOLEAN AtLeastOneConnected;\r | |
3341 | \r | |
3342 | //\r | |
3343 | // Check the passed in parameters\r | |
3344 | //\r | |
3345 | if (DevicePath == NULL) {\r | |
3346 | return EFI_INVALID_PARAMETER;\r | |
3347 | }\r | |
3348 | \r | |
3349 | if ((DevicePathType (DevicePath) != MESSAGING_DEVICE_PATH) ||\r | |
3350 | ((DevicePathSubType (DevicePath) != MSG_USB_CLASS_DP) && (DevicePathSubType (DevicePath) != MSG_USB_WWID_DP))\r | |
3351 | ) {\r | |
3352 | return EFI_INVALID_PARAMETER;\r | |
3353 | }\r | |
3354 | \r | |
3355 | //\r | |
3356 | // Find the usb host controller firstly, then connect with the remaining device path\r | |
3357 | //\r | |
3358 | AtLeastOneConnected = FALSE;\r | |
3359 | Status = gBS->LocateHandleBuffer (\r | |
3360 | ByProtocol,\r | |
3361 | &gEfiPciIoProtocolGuid,\r | |
3362 | NULL,\r | |
3363 | &HandleCount,\r | |
3364 | &Handles\r | |
3365 | );\r | |
3366 | for (Index = 0; Index < HandleCount; Index++) {\r | |
3367 | Status = gBS->HandleProtocol (\r | |
3368 | Handles[Index],\r | |
3369 | &gEfiPciIoProtocolGuid,\r | |
3370 | (VOID **) &PciIo\r | |
3371 | );\r | |
3372 | if (!EFI_ERROR (Status)) {\r | |
3373 | //\r | |
3374 | // Check whether the Pci device is the wanted usb host controller\r | |
3375 | //\r | |
3376 | Status = PciIo->Pci.Read (PciIo, EfiPciIoWidthUint8, 0x09, 3, &Class);\r | |
3377 | if (!EFI_ERROR (Status) &&\r | |
3378 | ((PCI_CLASS_SERIAL == Class[2]) && (PCI_CLASS_SERIAL_USB == Class[1]))\r | |
3379 | ) {\r | |
3380 | Status = gBS->ConnectController (\r | |
3381 | Handles[Index],\r | |
3382 | NULL,\r | |
3383 | DevicePath,\r | |
3384 | FALSE\r | |
3385 | );\r | |
3386 | if (!EFI_ERROR(Status)) {\r | |
3387 | AtLeastOneConnected = TRUE;\r | |
3388 | }\r | |
3389 | }\r | |
3390 | }\r | |
3391 | }\r | |
3392 | \r | |
3393 | return AtLeastOneConnected ? EFI_SUCCESS : EFI_NOT_FOUND;\r | |
3394 | }\r | |
3395 | \r | |
3396 | \r | |
3397 | /**\r | |
3398 | This function will create all handles associate with every device\r | |
3399 | path node. If the handle associate with one device path node can not\r | |
3400 | be created successfully, then still give one chance to do the dispatch,\r | |
3401 | which load the missing drivers if possible.\r | |
3402 | \r | |
3403 | @param DevicePathToConnect The device path which will be connected, it CANNOT be\r | |
3404 | a multi-instance device path\r | |
3405 | @param MatchingHandle Return the controller handle closest to the DevicePathToConnect\r | |
3406 | \r | |
3407 | @retval EFI_INVALID_PARAMETER DevicePathToConnect is NULL.\r | |
3408 | @retval EFI_NOT_FOUND Failed to create all handles associate with every device path node.\r | |
3409 | @retval EFI_SUCCESS Successful to create all handles associate with every device path node.\r | |
3410 | \r | |
3411 | **/\r | |
3412 | EFI_STATUS\r | |
3413 | EFIAPI\r | |
3414 | ConSplitterConnectDevicePath (\r | |
3415 | IN EFI_DEVICE_PATH_PROTOCOL *DevicePathToConnect,\r | |
3416 | OUT EFI_HANDLE *MatchingHandle OPTIONAL\r | |
3417 | )\r | |
3418 | {\r | |
3419 | EFI_STATUS Status;\r | |
3420 | EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath;\r | |
3421 | EFI_HANDLE Handle;\r | |
3422 | EFI_HANDLE PreviousHandle;\r | |
3423 | \r | |
3424 | if (DevicePathToConnect == NULL) {\r | |
3425 | return EFI_INVALID_PARAMETER;\r | |
3426 | }\r | |
3427 | \r | |
3428 | //\r | |
3429 | // Start the real work of connect with RemainingDevicePath\r | |
3430 | //\r | |
3431 | PreviousHandle = NULL;\r | |
3432 | do {\r | |
3433 | //\r | |
3434 | // Find the handle that best matches the Device Path. If it is only a\r | |
3435 | // partial match the remaining part of the device path is returned in\r | |
3436 | // RemainingDevicePath.\r | |
3437 | //\r | |
3438 | RemainingDevicePath = DevicePathToConnect;\r | |
3439 | Status = gBS->LocateDevicePath (&gEfiDevicePathProtocolGuid, &RemainingDevicePath, &Handle);\r | |
3440 | if (!EFI_ERROR (Status)) {\r | |
3441 | if (Handle == PreviousHandle) {\r | |
3442 | //\r | |
3443 | // If no forward progress is made try invoking the Dispatcher.\r | |
3444 | // A new FV may have been added to the system an new drivers\r | |
3445 | // may now be found.\r | |
3446 | // Status == EFI_SUCCESS means a driver was dispatched\r | |
3447 | // Status == EFI_NOT_FOUND means no new drivers were dispatched\r | |
3448 | //\r | |
3449 | Status = gDS->Dispatch ();\r | |
3450 | }\r | |
3451 | \r | |
3452 | if (!EFI_ERROR (Status)) {\r | |
3453 | PreviousHandle = Handle;\r | |
3454 | //\r | |
3455 | // Connect all drivers that apply to Handle and RemainingDevicePath,\r | |
3456 | // the Recursive flag is FALSE so only one level will be expanded.\r | |
3457 | //\r | |
3458 | // Do not check the connect status here, if the connect controller fail,\r | |
3459 | // then still give the chance to do dispatch, because partial\r | |
3460 | // RemainingDevicepath may be in the new FV\r | |
3461 | //\r | |
3462 | // 1. If the connect fail, RemainingDevicepath and handle will not\r | |
3463 | // change, so next time will do the dispatch, then dispatch's status\r | |
3464 | // will take effect\r | |
3465 | // 2. If the connect success, the RemainingDevicepath and handle will\r | |
3466 | // change, then avoid the dispatch, we have chance to continue the\r | |
3467 | // next connection\r | |
3468 | //\r | |
3469 | gBS->ConnectController (Handle, NULL, RemainingDevicePath, FALSE);\r | |
3470 | if (MatchingHandle != NULL) {\r | |
3471 | *MatchingHandle = Handle;\r | |
3472 | }\r | |
3473 | }\r | |
3474 | }\r | |
3475 | //\r | |
3476 | // Loop until RemainingDevicePath is an empty device path\r | |
3477 | //\r | |
3478 | } while (!EFI_ERROR (Status) && !IsDevicePathEnd (RemainingDevicePath));\r | |
3479 | \r | |
3480 | ASSERT (EFI_ERROR (Status) || IsDevicePathEnd (RemainingDevicePath));\r | |
3481 | \r | |
3482 | return Status;\r | |
3483 | }\r | |
3484 | \r | |
3485 | \r | |
3486 | /**\r | |
3487 | Connect to all ConIn device which is in the ConIn variable.\r | |
3488 | \r | |
3489 | @param DevicePath A short-form device path that starts with the first\r | |
3490 | element being a USB WWID or a USB Class device\r | |
3491 | path\r | |
3492 | \r | |
3493 | @return EFI_INVALID_PARAMETER DevicePath is NULL pointer.\r | |
3494 | DevicePath is not a USB device path.\r | |
3495 | \r | |
3496 | @return EFI_SUCCESS Success to connect USB device\r | |
3497 | @return EFI_NOT_FOUND Fail to find handle for USB controller to connect.\r | |
3498 | \r | |
3499 | **/\r | |
3500 | EFI_STATUS\r | |
3501 | EFIAPI\r | |
3502 | ConSplitterConnectConInDevicePath (\r | |
3503 | \r | |
3504 | )\r | |
3505 | {\r | |
3506 | EFI_DEVICE_PATH_PROTOCOL *DevicePath;\r | |
3507 | EFI_DEVICE_PATH_PROTOCOL *DevicePathInst;\r | |
3508 | EFI_DEVICE_PATH_PROTOCOL *CopyDevicePath;\r | |
3509 | UINTN Size;\r | |
3510 | EFI_DEVICE_PATH_PROTOCOL *Next;\r | |
3511 | \r | |
3512 | DevicePath = GetEfiGlobalVariable (L"ConIn");\r | |
3513 | \r | |
3514 | //\r | |
3515 | // Check the passed in parameters\r | |
3516 | //\r | |
3517 | if (DevicePath == NULL) {\r | |
3518 | return EFI_NOT_FOUND;\r | |
3519 | }\r | |
3520 | \r | |
3521 | CopyDevicePath = DevicePath;\r | |
3522 | \r | |
3523 | DevicePathInst = GetNextDevicePathInstance (&DevicePath, &Size);\r | |
3524 | while (DevicePathInst != NULL) {\r | |
3525 | \r | |
3526 | Next = DevicePathInst;\r | |
3527 | while (!IsDevicePathEndType (Next)) {\r | |
3528 | Next = NextDevicePathNode (Next);\r | |
3529 | }\r | |
3530 | \r | |
3531 | SetDevicePathEndNode (Next);\r | |
3532 | \r | |
3533 | //\r | |
3534 | // Connect the USB console\r | |
3535 | // USB console device path is a short-form device path that \r | |
3536 | // starts with the first element being a USB WWID\r | |
3537 | // or a USB Class device path\r | |
3538 | //\r | |
3539 | if ((DevicePathType (DevicePathInst) == MESSAGING_DEVICE_PATH) &&\r | |
3540 | ((DevicePathSubType (DevicePathInst) == MSG_USB_CLASS_DP)\r | |
3541 | || (DevicePathSubType (DevicePathInst) == MSG_USB_WWID_DP)\r | |
3542 | )) {\r | |
3543 | ConSplitterConnectUsbShortFormDevicePath (DevicePathInst);\r | |
3544 | } else {\r | |
3545 | ConSplitterConnectDevicePath (DevicePathInst, NULL);\r | |
3546 | } \r | |
3547 | DevicePathInst = GetNextDevicePathInstance (&DevicePath, &Size);\r | |
3548 | }\r | |
3549 | return EFI_SUCCESS;\r | |
3550 | }\r | |
3551 | \r | |
3552 | \r | |
a4d608d1 | 3553 | \r |
3554 | /**\r | |
3555 | Reads the next keystroke from the input device. The WaitForKey Event can\r | |
3556 | be used to test for existance of a keystroke via WaitForEvent () call.\r | |
a4d608d1 | 3557 | \r |
3558 | @param This Protocol instance pointer.\r | |
3559 | @param Key Driver may perform diagnostics on reset.\r | |
3560 | \r | |
3561 | @retval EFI_SUCCESS The keystroke information was returned.\r | |
3562 | @retval EFI_NOT_READY There was no keystroke data availiable.\r | |
3563 | @retval EFI_DEVICE_ERROR The keydtroke information was not returned due\r | |
3564 | to hardware errors.\r | |
3565 | \r | |
3566 | **/\r | |
95276127 | 3567 | EFI_STATUS\r |
3568 | EFIAPI\r | |
3569 | ConSplitterTextInReadKeyStroke (\r | |
3570 | IN EFI_SIMPLE_TEXT_INPUT_PROTOCOL *This,\r | |
3571 | OUT EFI_INPUT_KEY *Key\r | |
3572 | )\r | |
95276127 | 3573 | {\r |
3574 | TEXT_IN_SPLITTER_PRIVATE_DATA *Private;\r | |
3575 | \r | |
3576 | Private = TEXT_IN_SPLITTER_PRIVATE_DATA_FROM_THIS (This);\r | |
95276127 | 3577 | \r |
3578 | Private->KeyEventSignalState = FALSE;\r | |
3579 | \r | |
838a9c58 | 3580 | //\r |
3581 | // Connect ConIn when first call in Lazy ConIn mode\r | |
3582 | //\r | |
3583 | if (!mConInIsConnect && PcdGetBool (PcdConInConnectOnDemand)) {\r | |
3584 | DEBUG ((EFI_D_INFO, "Connect ConIn in first ReadKeyStoke in Lazy ConIn mode.\n")); \r | |
3585 | ConSplitterConnectConInDevicePath ();\r | |
3586 | mConInIsConnect = TRUE;\r | |
3587 | }\r | |
3588 | \r | |
95276127 | 3589 | return ConSplitterTextInPrivateReadKeyStroke (Private, Key);\r |
3590 | }\r | |
3591 | \r | |
95276127 | 3592 | \r |
a4d608d1 | 3593 | /**\r |
f890b1e0 | 3594 | This event aggregates all the events of the ConIn devices in the spliter.\r |
3595 | \r | |
95276127 | 3596 | If any events of physical ConIn devices are signaled, signal the ConIn\r |
3597 | spliter event. This will cause the calling code to call\r | |
3598 | ConSplitterTextInReadKeyStroke ().\r | |
3599 | \r | |
a4d608d1 | 3600 | @param Event The Event assoicated with callback.\r |
3601 | @param Context Context registered when Event was created.\r | |
95276127 | 3602 | \r |
a4d608d1 | 3603 | **/\r |
3604 | VOID\r | |
3605 | EFIAPI\r | |
3606 | ConSplitterTextInWaitForKey (\r | |
3607 | IN EFI_EVENT Event,\r | |
3608 | IN VOID *Context\r | |
3609 | )\r | |
95276127 | 3610 | {\r |
3611 | EFI_STATUS Status;\r | |
3612 | TEXT_IN_SPLITTER_PRIVATE_DATA *Private;\r | |
3613 | UINTN Index;\r | |
3614 | \r | |
3615 | Private = (TEXT_IN_SPLITTER_PRIVATE_DATA *) Context;\r | |
f890b1e0 | 3616 | \r |
95276127 | 3617 | if (Private->KeyEventSignalState) {\r |
f890b1e0 | 3618 | //\r |
3619 | // If KeyEventSignalState is flagged before, and not cleared by Reset() or ReadKeyStroke()\r | |
3620 | //\r | |
95276127 | 3621 | gBS->SignalEvent (Event);\r |
3622 | return ;\r | |
3623 | }\r | |
f890b1e0 | 3624 | \r |
95276127 | 3625 | //\r |
f890b1e0 | 3626 | // If any physical console input device has key input, signal the event.\r |
95276127 | 3627 | //\r |
3628 | for (Index = 0; Index < Private->CurrentNumberOfConsoles; Index++) {\r | |
3629 | Status = gBS->CheckEvent (Private->TextInList[Index]->WaitForKey);\r | |
3630 | if (!EFI_ERROR (Status)) {\r | |
3631 | gBS->SignalEvent (Event);\r | |
3632 | Private->KeyEventSignalState = TRUE;\r | |
3633 | }\r | |
3634 | }\r | |
3635 | }\r | |
3636 | \r | |
66aa04e4 | 3637 | \r |
a4d608d1 | 3638 | \r |
3639 | /**\r | |
4b5c4fba | 3640 | Test if the key has been registered on input device.\r |
a4d608d1 | 3641 | \r |
3642 | @param RegsiteredData A pointer to a buffer that is filled in with the\r | |
3643 | keystroke state data for the key that was\r | |
3644 | registered.\r | |
3645 | @param InputData A pointer to a buffer that is filled in with the\r | |
3646 | keystroke state data for the key that was\r | |
3647 | pressed.\r | |
3648 | \r | |
3649 | @retval TRUE Key be pressed matches a registered key.\r | |
3650 | @retval FLASE Match failed.\r | |
3651 | \r | |
3652 | **/\r | |
66aa04e4 | 3653 | BOOLEAN\r |
3654 | IsKeyRegistered (\r | |
3655 | IN EFI_KEY_DATA *RegsiteredData,\r | |
3656 | IN EFI_KEY_DATA *InputData\r | |
3657 | )\r | |
66aa04e4 | 3658 | {\r |
3659 | ASSERT (RegsiteredData != NULL && InputData != NULL);\r | |
7a5064ce | 3660 | \r |
66aa04e4 | 3661 | if ((RegsiteredData->Key.ScanCode != InputData->Key.ScanCode) ||\r |
3662 | (RegsiteredData->Key.UnicodeChar != InputData->Key.UnicodeChar)) {\r | |
7a5064ce | 3663 | return FALSE;\r |
3664 | }\r | |
3665 | \r | |
66aa04e4 | 3666 | //\r |
3667 | // Assume KeyShiftState/KeyToggleState = 0 in Registered key data means these state could be ignored.\r | |
3668 | //\r | |
3669 | if (RegsiteredData->KeyState.KeyShiftState != 0 &&\r | |
3670 | RegsiteredData->KeyState.KeyShiftState != InputData->KeyState.KeyShiftState) {\r | |
7a5064ce | 3671 | return FALSE;\r |
3672 | }\r | |
66aa04e4 | 3673 | if (RegsiteredData->KeyState.KeyToggleState != 0 &&\r |
3674 | RegsiteredData->KeyState.KeyToggleState != InputData->KeyState.KeyToggleState) {\r | |
7a5064ce | 3675 | return FALSE;\r |
3676 | }\r | |
3677 | \r | |
66aa04e4 | 3678 | return TRUE;\r |
3679 | \r | |
3680 | }\r | |
3681 | \r | |
a4d608d1 | 3682 | \r |
3683 | /**\r | |
3684 | Reset the input device and optionaly run diagnostics\r | |
3685 | \r | |
3686 | @param This Protocol instance pointer.\r | |
3687 | @param ExtendedVerification Driver may perform diagnostics on reset.\r | |
3688 | \r | |
3689 | @retval EFI_SUCCESS The device was reset.\r | |
3690 | @retval EFI_DEVICE_ERROR The device is not functioning properly and could\r | |
3691 | not be reset.\r | |
3692 | \r | |
3693 | **/\r | |
66aa04e4 | 3694 | EFI_STATUS\r |
3695 | EFIAPI\r | |
3696 | ConSplitterTextInResetEx (\r | |
3697 | IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *This,\r | |
3698 | IN BOOLEAN ExtendedVerification\r | |
3699 | )\r | |
66aa04e4 | 3700 | {\r |
3701 | EFI_STATUS Status;\r | |
3702 | EFI_STATUS ReturnStatus;\r | |
3703 | TEXT_IN_SPLITTER_PRIVATE_DATA *Private;\r | |
3704 | UINTN Index;\r | |
3705 | \r | |
3706 | Private = TEXT_IN_EX_SPLITTER_PRIVATE_DATA_FROM_THIS (This);\r | |
3707 | \r | |
3708 | Private->KeyEventSignalState = FALSE;\r | |
3709 | \r | |
3710 | //\r | |
3711 | // return the worst status met\r | |
3712 | //\r | |
3713 | for (Index = 0, ReturnStatus = EFI_SUCCESS; Index < Private->CurrentNumberOfExConsoles; Index++) {\r | |
3714 | Status = Private->TextInExList[Index]->Reset (\r | |
3715 | Private->TextInExList[Index],\r | |
3716 | ExtendedVerification\r | |
3717 | );\r | |
3718 | if (EFI_ERROR (Status)) {\r | |
3719 | ReturnStatus = Status;\r | |
3720 | }\r | |
3721 | }\r | |
3722 | \r | |
3723 | return ReturnStatus;\r | |
3724 | \r | |
3725 | }\r | |
3726 | \r | |
a4d608d1 | 3727 | \r |
3728 | /**\r | |
3729 | Reads the next keystroke from the input device. The WaitForKey Event can\r | |
3730 | be used to test for existance of a keystroke via WaitForEvent () call.\r | |
3731 | \r | |
3732 | @param This Protocol instance pointer.\r | |
3733 | @param KeyData A pointer to a buffer that is filled in with the\r | |
3734 | keystroke state data for the key that was\r | |
3735 | pressed.\r | |
3736 | \r | |
3737 | @retval EFI_SUCCESS The keystroke information was returned.\r | |
3738 | @retval EFI_NOT_READY There was no keystroke data availiable.\r | |
3739 | @retval EFI_DEVICE_ERROR The keystroke information was not returned due\r | |
3740 | to hardware errors.\r | |
3741 | @retval EFI_INVALID_PARAMETER KeyData is NULL.\r | |
3742 | \r | |
3743 | **/\r | |
66aa04e4 | 3744 | EFI_STATUS\r |
3745 | EFIAPI\r | |
3746 | ConSplitterTextInReadKeyStrokeEx (\r | |
3747 | IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *This,\r | |
3748 | OUT EFI_KEY_DATA *KeyData\r | |
3749 | )\r | |
66aa04e4 | 3750 | {\r |
3751 | TEXT_IN_SPLITTER_PRIVATE_DATA *Private;\r | |
3752 | EFI_STATUS Status;\r | |
3753 | UINTN Index;\r | |
3754 | EFI_KEY_DATA CurrentKeyData;\r | |
3755 | \r | |
7a5064ce | 3756 | \r |
66aa04e4 | 3757 | if (KeyData == NULL) {\r |
3758 | return EFI_INVALID_PARAMETER;\r | |
3759 | }\r | |
3760 | \r | |
838a9c58 | 3761 | //\r |
3762 | // Connect ConIn when first call in Lazy ConIn mode\r | |
3763 | //\r | |
3764 | if (!mConInIsConnect && PcdGetBool (PcdConInConnectOnDemand)) {\r | |
3765 | DEBUG ((EFI_D_INFO, "Connect ConIn in first ReadKeyStoke in Lazy ConIn mode.\n")); \r | |
3766 | ConSplitterConnectConInDevicePath ();\r | |
3767 | mConInIsConnect = TRUE;\r | |
3768 | }\r | |
3769 | \r | |
66aa04e4 | 3770 | Private = TEXT_IN_EX_SPLITTER_PRIVATE_DATA_FROM_THIS (This);\r |
66aa04e4 | 3771 | \r |
3772 | Private->KeyEventSignalState = FALSE;\r | |
3773 | \r | |
3774 | KeyData->Key.UnicodeChar = 0;\r | |
3775 | KeyData->Key.ScanCode = SCAN_NULL;\r | |
3776 | \r | |
3777 | //\r | |
3778 | // if no physical console input device exists, return EFI_NOT_READY;\r | |
3779 | // if any physical console input device has key input,\r | |
3780 | // return the key and EFI_SUCCESS.\r | |
3781 | //\r | |
3782 | for (Index = 0; Index < Private->CurrentNumberOfExConsoles; Index++) {\r | |
3783 | Status = Private->TextInExList[Index]->ReadKeyStrokeEx (\r | |
3784 | Private->TextInExList[Index],\r | |
3785 | &CurrentKeyData\r | |
3786 | );\r | |
3787 | if (!EFI_ERROR (Status)) {\r | |
3788 | CopyMem (KeyData, &CurrentKeyData, sizeof (CurrentKeyData));\r | |
3789 | return Status;\r | |
3790 | }\r | |
3791 | }\r | |
3792 | \r | |
7a5064ce | 3793 | return EFI_NOT_READY;\r |
66aa04e4 | 3794 | }\r |
3795 | \r | |
a4d608d1 | 3796 | \r |
3797 | /**\r | |
3798 | Set certain state for the input device.\r | |
3799 | \r | |
3800 | @param This Protocol instance pointer.\r | |
3801 | @param KeyToggleState A pointer to the EFI_KEY_TOGGLE_STATE to set the\r | |
3802 | state for the input device.\r | |
3803 | \r | |
3804 | @retval EFI_SUCCESS The device state was set successfully.\r | |
3805 | @retval EFI_DEVICE_ERROR The device is not functioning correctly and\r | |
3806 | could not have the setting adjusted.\r | |
3807 | @retval EFI_UNSUPPORTED The device does not have the ability to set its\r | |
3808 | state.\r | |
3809 | @retval EFI_INVALID_PARAMETER KeyToggleState is NULL.\r | |
3810 | \r | |
3811 | **/\r | |
66aa04e4 | 3812 | EFI_STATUS\r |
3813 | EFIAPI\r | |
3814 | ConSplitterTextInSetState (\r | |
3815 | IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *This,\r | |
3816 | IN EFI_KEY_TOGGLE_STATE *KeyToggleState\r | |
3817 | )\r | |
66aa04e4 | 3818 | {\r |
3819 | TEXT_IN_SPLITTER_PRIVATE_DATA *Private;\r | |
3820 | EFI_STATUS Status;\r | |
3821 | UINTN Index;\r | |
3822 | \r | |
3823 | if (KeyToggleState == NULL) {\r | |
3824 | return EFI_INVALID_PARAMETER;\r | |
3825 | }\r | |
3826 | \r | |
3827 | Private = TEXT_IN_EX_SPLITTER_PRIVATE_DATA_FROM_THIS (This);\r | |
3828 | \r | |
3829 | //\r | |
3830 | // if no physical console input device exists, return EFI_SUCCESS;\r | |
3831 | // otherwise return the status of setting state of physical console input device\r | |
3832 | //\r | |
3833 | for (Index = 0; Index < Private->CurrentNumberOfExConsoles; Index++) {\r | |
3834 | Status = Private->TextInExList[Index]->SetState (\r | |
3835 | Private->TextInExList[Index],\r | |
3836 | KeyToggleState\r | |
3837 | );\r | |
3838 | if (EFI_ERROR (Status)) {\r | |
3839 | return Status;\r | |
3840 | }\r | |
3841 | }\r | |
3842 | \r | |
7a5064ce | 3843 | return EFI_SUCCESS;\r |
66aa04e4 | 3844 | \r |
3845 | }\r | |
3846 | \r | |
a4d608d1 | 3847 | \r |
3848 | /**\r | |
3849 | Register a notification function for a particular keystroke for the input device.\r | |
3850 | \r | |
3851 | @param This Protocol instance pointer.\r | |
3852 | @param KeyData A pointer to a buffer that is filled in with the\r | |
3853 | keystroke information data for the key that was\r | |
3854 | pressed.\r | |
3855 | @param KeyNotificationFunction Points to the function to be called when the key\r | |
3856 | sequence is typed specified by KeyData.\r | |
3857 | @param NotifyHandle Points to the unique handle assigned to the\r | |
3858 | registered notification.\r | |
3859 | \r | |
3860 | @retval EFI_SUCCESS The notification function was registered\r | |
3861 | successfully.\r | |
3862 | @retval EFI_OUT_OF_RESOURCES Unable to allocate resources for necesssary data\r | |
3863 | structures.\r | |
f890b1e0 | 3864 | @retval EFI_INVALID_PARAMETER KeyData or KeyNotificationFunction or NotifyHandle is NULL.\r |
a4d608d1 | 3865 | \r |
3866 | **/\r | |
66aa04e4 | 3867 | EFI_STATUS\r |
3868 | EFIAPI\r | |
3869 | ConSplitterTextInRegisterKeyNotify (\r | |
3870 | IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *This,\r | |
3871 | IN EFI_KEY_DATA *KeyData,\r | |
3872 | IN EFI_KEY_NOTIFY_FUNCTION KeyNotificationFunction,\r | |
402e4a9d | 3873 | OUT VOID **NotifyHandle\r |
66aa04e4 | 3874 | )\r |
66aa04e4 | 3875 | {\r |
3876 | TEXT_IN_SPLITTER_PRIVATE_DATA *Private;\r | |
3877 | EFI_STATUS Status;\r | |
3878 | UINTN Index;\r | |
3879 | TEXT_IN_EX_SPLITTER_NOTIFY *NewNotify;\r | |
3880 | LIST_ENTRY *Link;\r | |
7a5064ce | 3881 | TEXT_IN_EX_SPLITTER_NOTIFY *CurrentNotify;\r |
3882 | \r | |
66aa04e4 | 3883 | \r |
3884 | if (KeyData == NULL || NotifyHandle == NULL || KeyNotificationFunction == NULL) {\r | |
3885 | return EFI_INVALID_PARAMETER;\r | |
3886 | }\r | |
3887 | \r | |
3888 | Private = TEXT_IN_EX_SPLITTER_PRIVATE_DATA_FROM_THIS (This);\r | |
3889 | \r | |
66aa04e4 | 3890 | //\r |
3891 | // Return EFI_SUCCESS if the (KeyData, NotificationFunction) is already registered.\r | |
3892 | //\r | |
3893 | for (Link = Private->NotifyList.ForwardLink; Link != &Private->NotifyList; Link = Link->ForwardLink) {\r | |
fc753d3b | 3894 | CurrentNotify = TEXT_IN_EX_SPLITTER_NOTIFY_FROM_THIS (Link);\r |
7a5064ce | 3895 | if (IsKeyRegistered (&CurrentNotify->KeyData, KeyData)) {\r |
66aa04e4 | 3896 | if (CurrentNotify->KeyNotificationFn == KeyNotificationFunction) {\r |
402e4a9d | 3897 | *NotifyHandle = CurrentNotify;\r |
66aa04e4 | 3898 | return EFI_SUCCESS;\r |
3899 | }\r | |
3900 | }\r | |
3901 | }\r | |
7a5064ce | 3902 | \r |
66aa04e4 | 3903 | //\r |
3904 | // Allocate resource to save the notification function\r | |
7a5064ce | 3905 | //\r |
66aa04e4 | 3906 | NewNotify = (TEXT_IN_EX_SPLITTER_NOTIFY *) AllocateZeroPool (sizeof (TEXT_IN_EX_SPLITTER_NOTIFY));\r |
3907 | if (NewNotify == NULL) {\r | |
3908 | return EFI_OUT_OF_RESOURCES;\r | |
3909 | }\r | |
a9746199 | 3910 | NewNotify->NotifyHandleList = (EFI_HANDLE *) AllocateZeroPool (sizeof (EFI_HANDLE) * Private->TextInExListCount);\r |
66aa04e4 | 3911 | if (NewNotify->NotifyHandleList == NULL) {\r |
3912 | gBS->FreePool (NewNotify);\r | |
3913 | return EFI_OUT_OF_RESOURCES;\r | |
3914 | }\r | |
7a5064ce | 3915 | NewNotify->Signature = TEXT_IN_EX_SPLITTER_NOTIFY_SIGNATURE;\r |
66aa04e4 | 3916 | NewNotify->KeyNotificationFn = KeyNotificationFunction;\r |
f0384583 | 3917 | CopyMem (&NewNotify->KeyData, KeyData, sizeof (EFI_KEY_DATA));\r |
7a5064ce | 3918 | \r |
66aa04e4 | 3919 | //\r |
7a5064ce | 3920 | // Return the wrong status of registering key notify of\r |
66aa04e4 | 3921 | // physical console input device if meet problems\r |
3922 | //\r | |
3923 | for (Index = 0; Index < Private->CurrentNumberOfExConsoles; Index++) {\r | |
3924 | Status = Private->TextInExList[Index]->RegisterKeyNotify (\r | |
3925 | Private->TextInExList[Index],\r | |
3926 | KeyData,\r | |
3927 | KeyNotificationFunction,\r | |
3928 | &NewNotify->NotifyHandleList[Index]\r | |
3929 | );\r | |
3930 | if (EFI_ERROR (Status)) {\r | |
a9746199 RN |
3931 | //\r |
3932 | // Un-register the key notify on all physical console input devices\r | |
3933 | //\r | |
3934 | while (Index-- != 0) {\r | |
3935 | Private->TextInExList[Index]->UnregisterKeyNotify (\r | |
3936 | Private->TextInExList[Index],\r | |
3937 | NewNotify->NotifyHandleList[Index]\r | |
3938 | );\r | |
3939 | }\r | |
66aa04e4 | 3940 | gBS->FreePool (NewNotify->NotifyHandleList);\r |
3941 | gBS->FreePool (NewNotify);\r | |
3942 | return Status;\r | |
3943 | }\r | |
3944 | }\r | |
3945 | \r | |
66aa04e4 | 3946 | InsertTailList (&mConIn.NotifyList, &NewNotify->NotifyEntry);\r |
7a5064ce | 3947 | \r |
402e4a9d | 3948 | *NotifyHandle = NewNotify;\r |
7a5064ce | 3949 | \r |
3950 | return EFI_SUCCESS;\r | |
3951 | \r | |
66aa04e4 | 3952 | }\r |
3953 | \r | |
a4d608d1 | 3954 | \r |
3955 | /**\r | |
3956 | Remove a registered notification function from a particular keystroke.\r | |
3957 | \r | |
3958 | @param This Protocol instance pointer.\r | |
3959 | @param NotificationHandle The handle of the notification function being\r | |
3960 | unregistered.\r | |
3961 | \r | |
3962 | @retval EFI_SUCCESS The notification function was unregistered\r | |
3963 | successfully.\r | |
3964 | @retval EFI_INVALID_PARAMETER The NotificationHandle is invalid.\r | |
a4d608d1 | 3965 | \r |
3966 | **/\r | |
66aa04e4 | 3967 | EFI_STATUS\r |
3968 | EFIAPI\r | |
3969 | ConSplitterTextInUnregisterKeyNotify (\r | |
3970 | IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *This,\r | |
402e4a9d | 3971 | IN VOID *NotificationHandle\r |
66aa04e4 | 3972 | )\r |
66aa04e4 | 3973 | {\r |
3974 | TEXT_IN_SPLITTER_PRIVATE_DATA *Private;\r | |
66aa04e4 | 3975 | UINTN Index;\r |
3976 | TEXT_IN_EX_SPLITTER_NOTIFY *CurrentNotify;\r | |
7a5064ce | 3977 | LIST_ENTRY *Link;\r |
66aa04e4 | 3978 | \r |
3979 | if (NotificationHandle == NULL) {\r | |
3980 | return EFI_INVALID_PARAMETER;\r | |
3981 | }\r | |
3982 | \r | |
66aa04e4 | 3983 | Private = TEXT_IN_EX_SPLITTER_PRIVATE_DATA_FROM_THIS (This);\r |
3984 | \r | |
66aa04e4 | 3985 | for (Link = Private->NotifyList.ForwardLink; Link != &Private->NotifyList; Link = Link->ForwardLink) {\r |
fc753d3b | 3986 | CurrentNotify = TEXT_IN_EX_SPLITTER_NOTIFY_FROM_THIS (Link);\r |
402e4a9d | 3987 | if (CurrentNotify == NotificationHandle) {\r |
66aa04e4 | 3988 | for (Index = 0; Index < Private->CurrentNumberOfExConsoles; Index++) {\r |
a9746199 RN |
3989 | Private->TextInExList[Index]->UnregisterKeyNotify (\r |
3990 | Private->TextInExList[Index],\r | |
3991 | CurrentNotify->NotifyHandleList[Index]\r | |
3992 | );\r | |
66aa04e4 | 3993 | }\r |
7a5064ce | 3994 | RemoveEntryList (&CurrentNotify->NotifyEntry);\r |
7fc80d44 | 3995 | \r |
66aa04e4 | 3996 | gBS->FreePool (CurrentNotify->NotifyHandleList);\r |
3997 | gBS->FreePool (CurrentNotify);\r | |
7a5064ce | 3998 | return EFI_SUCCESS;\r |
3999 | }\r | |
66aa04e4 | 4000 | }\r |
4001 | \r | |
8a67d804 | 4002 | //\r |
4003 | // NotificationHandle is not found in database\r | |
4004 | //\r | |
4005 | return EFI_INVALID_PARAMETER;\r | |
66aa04e4 | 4006 | }\r |
4007 | \r | |
a4d608d1 | 4008 | \r |
4009 | /**\r | |
4010 | Reset the input device and optionaly run diagnostics\r | |
4011 | \r | |
4012 | @param This Protocol instance pointer.\r | |
4013 | @param ExtendedVerification Driver may perform diagnostics on reset.\r | |
4014 | \r | |
4015 | @retval EFI_SUCCESS The device was reset.\r | |
4016 | @retval EFI_DEVICE_ERROR The device is not functioning properly and could\r | |
4017 | not be reset.\r | |
4018 | \r | |
4019 | **/\r | |
95276127 | 4020 | EFI_STATUS\r |
4021 | EFIAPI\r | |
4022 | ConSplitterSimplePointerReset (\r | |
4023 | IN EFI_SIMPLE_POINTER_PROTOCOL *This,\r | |
4024 | IN BOOLEAN ExtendedVerification\r | |
4025 | )\r | |
95276127 | 4026 | {\r |
4027 | EFI_STATUS Status;\r | |
4028 | EFI_STATUS ReturnStatus;\r | |
4029 | TEXT_IN_SPLITTER_PRIVATE_DATA *Private;\r | |
4030 | UINTN Index;\r | |
4031 | \r | |
4032 | Private = TEXT_IN_SPLITTER_PRIVATE_DATA_FROM_SIMPLE_POINTER_THIS (This);\r | |
4033 | \r | |
4034 | Private->InputEventSignalState = FALSE;\r | |
4035 | \r | |
4036 | if (Private->CurrentNumberOfPointers == 0) {\r | |
4037 | return EFI_SUCCESS;\r | |
4038 | }\r | |
4039 | //\r | |
4040 | // return the worst status met\r | |
4041 | //\r | |
4042 | for (Index = 0, ReturnStatus = EFI_SUCCESS; Index < Private->CurrentNumberOfPointers; Index++) {\r | |
4043 | Status = Private->PointerList[Index]->Reset (\r | |
4044 | Private->PointerList[Index],\r | |
4045 | ExtendedVerification\r | |
4046 | );\r | |
4047 | if (EFI_ERROR (Status)) {\r | |
4048 | ReturnStatus = Status;\r | |
4049 | }\r | |
4050 | }\r | |
4051 | \r | |
4052 | return ReturnStatus;\r | |
4053 | }\r | |
4054 | \r | |
a4d608d1 | 4055 | \r |
4056 | /**\r | |
4057 | Reads the next keystroke from the input device. The WaitForKey Event can\r | |
4058 | be used to test for existance of a keystroke via WaitForEvent () call.\r | |
4059 | \r | |
33019a71 | 4060 | @param Private Protocol instance pointer.\r |
4061 | @param State The state information of simple pointer device.\r | |
a4d608d1 | 4062 | \r |
4063 | @retval EFI_SUCCESS The keystroke information was returned.\r | |
4064 | @retval EFI_NOT_READY There was no keystroke data availiable.\r | |
4065 | @retval EFI_DEVICE_ERROR The keydtroke information was not returned due\r | |
4066 | to hardware errors.\r | |
4067 | \r | |
4068 | **/\r | |
95276127 | 4069 | EFI_STATUS\r |
4070 | EFIAPI\r | |
4071 | ConSplitterSimplePointerPrivateGetState (\r | |
4072 | IN TEXT_IN_SPLITTER_PRIVATE_DATA *Private,\r | |
4073 | IN OUT EFI_SIMPLE_POINTER_STATE *State\r | |
4074 | )\r | |
95276127 | 4075 | {\r |
4076 | EFI_STATUS Status;\r | |
4077 | EFI_STATUS ReturnStatus;\r | |
4078 | UINTN Index;\r | |
4079 | EFI_SIMPLE_POINTER_STATE CurrentState;\r | |
4080 | \r | |
4081 | State->RelativeMovementX = 0;\r | |
4082 | State->RelativeMovementY = 0;\r | |
4083 | State->RelativeMovementZ = 0;\r | |
4084 | State->LeftButton = FALSE;\r | |
4085 | State->RightButton = FALSE;\r | |
4086 | \r | |
4087 | //\r | |
4088 | // if no physical console input device exists, return EFI_NOT_READY;\r | |
4089 | // if any physical console input device has key input,\r | |
4090 | // return the key and EFI_SUCCESS.\r | |
4091 | //\r | |
4092 | ReturnStatus = EFI_NOT_READY;\r | |
4093 | for (Index = 0; Index < Private->CurrentNumberOfPointers; Index++) {\r | |
4094 | \r | |
4095 | Status = Private->PointerList[Index]->GetState (\r | |
4096 | Private->PointerList[Index],\r | |
4097 | &CurrentState\r | |
4098 | );\r | |
4099 | if (!EFI_ERROR (Status)) {\r | |
4100 | if (ReturnStatus == EFI_NOT_READY) {\r | |
4101 | ReturnStatus = EFI_SUCCESS;\r | |
4102 | }\r | |
4103 | \r | |
4104 | if (CurrentState.LeftButton) {\r | |
4105 | State->LeftButton = TRUE;\r | |
4106 | }\r | |
4107 | \r | |
4108 | if (CurrentState.RightButton) {\r | |
4109 | State->RightButton = TRUE;\r | |
4110 | }\r | |
4111 | \r | |
4112 | if (CurrentState.RelativeMovementX != 0 && Private->PointerList[Index]->Mode->ResolutionX != 0) {\r | |
4113 | State->RelativeMovementX += (CurrentState.RelativeMovementX * (INT32) Private->SimplePointerMode.ResolutionX) / (INT32) Private->PointerList[Index]->Mode->ResolutionX;\r | |
4114 | }\r | |
4115 | \r | |
4116 | if (CurrentState.RelativeMovementY != 0 && Private->PointerList[Index]->Mode->ResolutionY != 0) {\r | |
4117 | State->RelativeMovementY += (CurrentState.RelativeMovementY * (INT32) Private->SimplePointerMode.ResolutionY) / (INT32) Private->PointerList[Index]->Mode->ResolutionY;\r | |
4118 | }\r | |
4119 | \r | |
4120 | if (CurrentState.RelativeMovementZ != 0 && Private->PointerList[Index]->Mode->ResolutionZ != 0) {\r | |
4121 | State->RelativeMovementZ += (CurrentState.RelativeMovementZ * (INT32) Private->SimplePointerMode.ResolutionZ) / (INT32) Private->PointerList[Index]->Mode->ResolutionZ;\r | |
4122 | }\r | |
4123 | } else if (Status == EFI_DEVICE_ERROR) {\r | |
4124 | ReturnStatus = EFI_DEVICE_ERROR;\r | |
4125 | }\r | |
4126 | }\r | |
4127 | \r | |
4128 | return ReturnStatus;\r | |
4129 | }\r | |
4130 | \r | |
a4d608d1 | 4131 | \r |
4132 | /**\r | |
4133 | Reads the next keystroke from the input device. The WaitForKey Event can\r | |
4134 | be used to test for existance of a keystroke via WaitForEvent () call.\r | |
a4d608d1 | 4135 | \r |
415df2a3 | 4136 | @param This A pointer to protocol instance.\r |
4137 | @param State A pointer to state information on the pointer device\r | |
a4d608d1 | 4138 | \r |
415df2a3 | 4139 | @retval EFI_SUCCESS The keystroke information was returned in State.\r |
a4d608d1 | 4140 | @retval EFI_NOT_READY There was no keystroke data availiable.\r |
4141 | @retval EFI_DEVICE_ERROR The keydtroke information was not returned due\r | |
4142 | to hardware errors.\r | |
4143 | \r | |
4144 | **/\r | |
95276127 | 4145 | EFI_STATUS\r |
4146 | EFIAPI\r | |
4147 | ConSplitterSimplePointerGetState (\r | |
4148 | IN EFI_SIMPLE_POINTER_PROTOCOL *This,\r | |
4149 | IN OUT EFI_SIMPLE_POINTER_STATE *State\r | |
4150 | )\r | |
95276127 | 4151 | {\r |
4152 | TEXT_IN_SPLITTER_PRIVATE_DATA *Private;\r | |
4153 | \r | |
4154 | Private = TEXT_IN_SPLITTER_PRIVATE_DATA_FROM_SIMPLE_POINTER_THIS (This);\r | |
95276127 | 4155 | \r |
4156 | Private->InputEventSignalState = FALSE;\r | |
4157 | \r | |
4158 | return ConSplitterSimplePointerPrivateGetState (Private, State);\r | |
4159 | }\r | |
4160 | \r | |
95276127 | 4161 | \r |
a4d608d1 | 4162 | /**\r |
95276127 | 4163 | This event agregates all the events of the ConIn devices in the spliter.\r |
95276127 | 4164 | If any events of physical ConIn devices are signaled, signal the ConIn\r |
4165 | spliter event. This will cause the calling code to call\r | |
4166 | ConSplitterTextInReadKeyStroke ().\r | |
4167 | \r | |
a4d608d1 | 4168 | @param Event The Event assoicated with callback.\r |
4169 | @param Context Context registered when Event was created.\r | |
95276127 | 4170 | \r |
a4d608d1 | 4171 | **/\r |
4172 | VOID\r | |
4173 | EFIAPI\r | |
4174 | ConSplitterSimplePointerWaitForInput (\r | |
4175 | IN EFI_EVENT Event,\r | |
4176 | IN VOID *Context\r | |
4177 | )\r | |
95276127 | 4178 | {\r |
4179 | EFI_STATUS Status;\r | |
4180 | TEXT_IN_SPLITTER_PRIVATE_DATA *Private;\r | |
4181 | UINTN Index;\r | |
4182 | \r | |
4183 | Private = (TEXT_IN_SPLITTER_PRIVATE_DATA *) Context;\r | |
95276127 | 4184 | \r |
4185 | //\r | |
4186 | // if InputEventSignalState is flagged before, and not cleared by Reset() or ReadKeyStroke()\r | |
4187 | //\r | |
4188 | if (Private->InputEventSignalState) {\r | |
4189 | gBS->SignalEvent (Event);\r | |
4190 | return ;\r | |
4191 | }\r | |
4192 | //\r | |
4193 | // if any physical console input device has key input, signal the event.\r | |
4194 | //\r | |
4195 | for (Index = 0; Index < Private->CurrentNumberOfPointers; Index++) {\r | |
4196 | Status = gBS->CheckEvent (Private->PointerList[Index]->WaitForInput);\r | |
4197 | if (!EFI_ERROR (Status)) {\r | |
4198 | gBS->SignalEvent (Event);\r | |
4199 | Private->InputEventSignalState = TRUE;\r | |
4200 | }\r | |
4201 | }\r | |
4202 | }\r | |
4203 | \r | |
a4d608d1 | 4204 | /**\r |
4205 | Resets the pointer device hardware.\r | |
4206 | \r | |
4207 | @param This Protocol instance pointer.\r | |
4208 | @param ExtendedVerification Driver may perform diagnostics on reset.\r | |
4209 | \r | |
4210 | @retval EFI_SUCCESS The device was reset.\r | |
4211 | @retval EFI_DEVICE_ERROR The device is not functioning correctly and\r | |
4212 | could not be reset.\r | |
4213 | \r | |
4214 | **/\r | |
8ae0b360 | 4215 | EFI_STATUS\r |
4216 | EFIAPI\r | |
4217 | ConSplitterAbsolutePointerReset (\r | |
4218 | IN EFI_ABSOLUTE_POINTER_PROTOCOL *This,\r | |
4219 | IN BOOLEAN ExtendedVerification\r | |
4220 | )\r | |
8ae0b360 | 4221 | {\r |
4222 | EFI_STATUS Status;\r | |
4223 | EFI_STATUS ReturnStatus;\r | |
4224 | TEXT_IN_SPLITTER_PRIVATE_DATA *Private;\r | |
4225 | UINTN Index;\r | |
4226 | \r | |
4227 | Private = TEXT_IN_SPLITTER_PRIVATE_DATA_FROM_ABSOLUTE_POINTER_THIS (This);\r | |
4228 | \r | |
4229 | Private->AbsoluteInputEventSignalState = FALSE;\r | |
7a5064ce | 4230 | \r |
8ae0b360 | 4231 | if (Private->CurrentNumberOfAbsolutePointers == 0) {\r |
4232 | return EFI_SUCCESS;\r | |
4233 | }\r | |
4234 | //\r | |
4235 | // return the worst status met\r | |
4236 | //\r | |
4237 | for (Index = 0, ReturnStatus = EFI_SUCCESS; Index < Private->CurrentNumberOfAbsolutePointers; Index++) {\r | |
4238 | Status = Private->AbsolutePointerList[Index]->Reset (\r | |
4239 | Private->AbsolutePointerList[Index],\r | |
4240 | ExtendedVerification\r | |
4241 | );\r | |
4242 | if (EFI_ERROR (Status)) {\r | |
4243 | ReturnStatus = Status;\r | |
4244 | }\r | |
4245 | }\r | |
4246 | \r | |
4247 | return ReturnStatus;\r | |
4248 | }\r | |
4249 | \r | |
a4d608d1 | 4250 | \r |
4251 | /**\r | |
4252 | Retrieves the current state of a pointer device.\r | |
4253 | \r | |
4254 | @param This Protocol instance pointer.\r | |
4255 | @param State A pointer to the state information on the\r | |
4256 | pointer device.\r | |
4257 | \r | |
4258 | @retval EFI_SUCCESS The state of the pointer device was returned in\r | |
4259 | State..\r | |
4260 | @retval EFI_NOT_READY The state of the pointer device has not changed\r | |
4261 | since the last call to GetState().\r | |
4262 | @retval EFI_DEVICE_ERROR A device error occurred while attempting to\r | |
4263 | retrieve the pointer device's current state.\r | |
4264 | \r | |
4265 | **/\r | |
8ae0b360 | 4266 | EFI_STATUS\r |
7a5064ce | 4267 | EFIAPI\r |
8ae0b360 | 4268 | ConSplitterAbsolutePointerGetState (\r |
4269 | IN EFI_ABSOLUTE_POINTER_PROTOCOL *This,\r | |
4270 | IN OUT EFI_ABSOLUTE_POINTER_STATE *State\r | |
4271 | )\r | |
8ae0b360 | 4272 | {\r |
4273 | TEXT_IN_SPLITTER_PRIVATE_DATA *Private;\r | |
4274 | EFI_STATUS Status;\r | |
4275 | EFI_STATUS ReturnStatus;\r | |
4276 | UINTN Index;\r | |
4277 | EFI_ABSOLUTE_POINTER_STATE CurrentState;\r | |
4278 | \r | |
4279 | \r | |
4280 | Private = TEXT_IN_SPLITTER_PRIVATE_DATA_FROM_ABSOLUTE_POINTER_THIS (This);\r | |
8ae0b360 | 4281 | \r |
4282 | Private->AbsoluteInputEventSignalState = FALSE;\r | |
4283 | \r | |
4284 | State->CurrentX = 0;\r | |
4285 | State->CurrentY = 0;\r | |
4286 | State->CurrentZ = 0;\r | |
4287 | State->ActiveButtons = 0;\r | |
7a5064ce | 4288 | \r |
8ae0b360 | 4289 | //\r |
4290 | // if no physical pointer device exists, return EFI_NOT_READY;\r | |
4291 | // if any physical pointer device has changed state,\r | |
4292 | // return the state and EFI_SUCCESS.\r | |
4293 | //\r | |
4294 | ReturnStatus = EFI_NOT_READY;\r | |
4295 | for (Index = 0; Index < Private->CurrentNumberOfAbsolutePointers; Index++) {\r | |
4296 | \r | |
4297 | Status = Private->AbsolutePointerList[Index]->GetState (\r | |
4298 | Private->AbsolutePointerList[Index],\r | |
4299 | &CurrentState\r | |
4300 | );\r | |
4301 | if (!EFI_ERROR (Status)) {\r | |
4302 | if (ReturnStatus == EFI_NOT_READY) {\r | |
4303 | ReturnStatus = EFI_SUCCESS;\r | |
4304 | }\r | |
4305 | \r | |
4306 | State->ActiveButtons = CurrentState.ActiveButtons;\r | |
4307 | \r | |
4308 | if (!(Private->AbsolutePointerMode.AbsoluteMinX == 0 && Private->AbsolutePointerMode.AbsoluteMaxX == 0)) {\r | |
4309 | State->CurrentX = CurrentState.CurrentX;\r | |
4310 | }\r | |
4311 | if (!(Private->AbsolutePointerMode.AbsoluteMinY == 0 && Private->AbsolutePointerMode.AbsoluteMaxY == 0)) {\r | |
4312 | State->CurrentY = CurrentState.CurrentY;\r | |
4313 | }\r | |
4314 | if (!(Private->AbsolutePointerMode.AbsoluteMinZ == 0 && Private->AbsolutePointerMode.AbsoluteMaxZ == 0)) {\r | |
4315 | State->CurrentZ = CurrentState.CurrentZ;\r | |
4316 | }\r | |
7a5064ce | 4317 | \r |
8ae0b360 | 4318 | } else if (Status == EFI_DEVICE_ERROR) {\r |
4319 | ReturnStatus = EFI_DEVICE_ERROR;\r | |
4320 | }\r | |
4321 | }\r | |
4322 | \r | |
4323 | return ReturnStatus;\r | |
4324 | }\r | |
4325 | \r | |
8ae0b360 | 4326 | \r |
a4d608d1 | 4327 | /**\r |
8ae0b360 | 4328 | This event agregates all the events of the pointer devices in the splitter.\r |
8ae0b360 | 4329 | If any events of physical pointer devices are signaled, signal the pointer\r |
4330 | splitter event. This will cause the calling code to call\r | |
4331 | ConSplitterAbsolutePointerGetState ().\r | |
4332 | \r | |
a4d608d1 | 4333 | @param Event The Event assoicated with callback.\r |
4334 | @param Context Context registered when Event was created.\r | |
8ae0b360 | 4335 | \r |
a4d608d1 | 4336 | **/\r |
4337 | VOID\r | |
4338 | EFIAPI\r | |
4339 | ConSplitterAbsolutePointerWaitForInput (\r | |
4340 | IN EFI_EVENT Event,\r | |
4341 | IN VOID *Context\r | |
4342 | )\r | |
8ae0b360 | 4343 | {\r |
4344 | EFI_STATUS Status;\r | |
4345 | TEXT_IN_SPLITTER_PRIVATE_DATA *Private;\r | |
4346 | UINTN Index;\r | |
4347 | \r | |
4348 | Private = (TEXT_IN_SPLITTER_PRIVATE_DATA *) Context;\r | |
8ae0b360 | 4349 | \r |
4350 | //\r | |
7a5064ce | 4351 | // if AbsoluteInputEventSignalState is flagged before,\r |
8ae0b360 | 4352 | // and not cleared by Reset() or GetState(), signal it\r |
4353 | //\r | |
4354 | if (Private->AbsoluteInputEventSignalState) {\r | |
4355 | gBS->SignalEvent (Event);\r | |
4356 | return ;\r | |
4357 | }\r | |
4358 | //\r | |
4359 | // if any physical console input device has key input, signal the event.\r | |
4360 | //\r | |
4361 | for (Index = 0; Index < Private->CurrentNumberOfAbsolutePointers; Index++) {\r | |
4362 | Status = gBS->CheckEvent (Private->AbsolutePointerList[Index]->WaitForInput);\r | |
4363 | if (!EFI_ERROR (Status)) {\r | |
4364 | gBS->SignalEvent (Event);\r | |
4365 | Private->AbsoluteInputEventSignalState = TRUE;\r | |
4366 | }\r | |
4367 | }\r | |
4368 | }\r | |
4369 | \r | |
a4d608d1 | 4370 | \r |
4371 | /**\r | |
4372 | Reset the text output device hardware and optionaly run diagnostics\r | |
4373 | \r | |
4374 | @param This Protocol instance pointer.\r | |
4375 | @param ExtendedVerification Driver may perform more exhaustive verfication\r | |
4376 | operation of the device during reset.\r | |
4377 | \r | |
4378 | @retval EFI_SUCCESS The text output device was reset.\r | |
4379 | @retval EFI_DEVICE_ERROR The text output device is not functioning\r | |
4380 | correctly and could not be reset.\r | |
4381 | \r | |
4382 | **/\r | |
95276127 | 4383 | EFI_STATUS\r |
4384 | EFIAPI\r | |
4385 | ConSplitterTextOutReset (\r | |
4386 | IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,\r | |
4387 | IN BOOLEAN ExtendedVerification\r | |
4388 | )\r | |
95276127 | 4389 | {\r |
4390 | EFI_STATUS Status;\r | |
4391 | TEXT_OUT_SPLITTER_PRIVATE_DATA *Private;\r | |
4392 | UINTN Index;\r | |
4393 | EFI_STATUS ReturnStatus;\r | |
4394 | \r | |
4395 | Private = TEXT_OUT_SPLITTER_PRIVATE_DATA_FROM_THIS (This);\r | |
4396 | \r | |
4397 | //\r | |
4398 | // return the worst status met\r | |
4399 | //\r | |
4400 | for (Index = 0, ReturnStatus = EFI_SUCCESS; Index < Private->CurrentNumberOfConsoles; Index++) {\r | |
9937b365 | 4401 | Status = Private->TextOutList[Index].TextOut->Reset (\r |
4402 | Private->TextOutList[Index].TextOut,\r | |
4403 | ExtendedVerification\r | |
4404 | );\r | |
4405 | if (EFI_ERROR (Status)) {\r | |
4406 | ReturnStatus = Status;\r | |
95276127 | 4407 | }\r |
4408 | }\r | |
4409 | \r | |
0ce1dd70 | 4410 | This->SetAttribute (This, EFI_TEXT_ATTR (This->Mode->Attribute & 0x0F, EFI_BLACK));\r |
95276127 | 4411 | \r |
9937b365 | 4412 | //\r |
4413 | // reset all mode parameters\r | |
4414 | //\r | |
4415 | TextOutSetMode (Private, 0);\r | |
95276127 | 4416 | \r |
4417 | return ReturnStatus;\r | |
4418 | }\r | |
4419 | \r | |
a4d608d1 | 4420 | \r |
4421 | /**\r | |
4422 | Write a Unicode string to the output device.\r | |
4423 | \r | |
4424 | @param This Protocol instance pointer.\r | |
33019a71 | 4425 | @param WString The NULL-terminated Unicode string to be\r |
a4d608d1 | 4426 | displayed on the output device(s). All output\r |
4427 | devices must also support the Unicode drawing\r | |
4428 | defined in this file.\r | |
4429 | \r | |
4430 | @retval EFI_SUCCESS The string was output to the device.\r | |
4431 | @retval EFI_DEVICE_ERROR The device reported an error while attempting to\r | |
4432 | output the text.\r | |
4433 | @retval EFI_UNSUPPORTED The output device's mode is not currently in a\r | |
4434 | defined text mode.\r | |
4435 | @retval EFI_WARN_UNKNOWN_GLYPH This warning code indicates that some of the\r | |
4436 | characters in the Unicode string could not be\r | |
4437 | rendered and were skipped.\r | |
4438 | \r | |
4439 | **/\r | |
95276127 | 4440 | EFI_STATUS\r |
4441 | EFIAPI\r | |
4442 | ConSplitterTextOutOutputString (\r | |
4443 | IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,\r | |
4444 | IN CHAR16 *WString\r | |
4445 | )\r | |
95276127 | 4446 | {\r |
4447 | EFI_STATUS Status;\r | |
4448 | TEXT_OUT_SPLITTER_PRIVATE_DATA *Private;\r | |
4449 | UINTN Index;\r | |
95276127 | 4450 | EFI_STATUS ReturnStatus;\r |
fe339651 | 4451 | UINTN MaxColumn;\r |
4452 | UINTN MaxRow;\r | |
95276127 | 4453 | \r |
4454 | This->SetAttribute (This, This->Mode->Attribute);\r | |
4455 | \r | |
4456 | Private = TEXT_OUT_SPLITTER_PRIVATE_DATA_FROM_THIS (This);\r | |
4457 | \r | |
95276127 | 4458 | //\r |
4459 | // return the worst status met\r | |
4460 | //\r | |
95276127 | 4461 | for (Index = 0, ReturnStatus = EFI_SUCCESS; Index < Private->CurrentNumberOfConsoles; Index++) {\r |
9937b365 | 4462 | Status = Private->TextOutList[Index].TextOut->OutputString (\r |
4463 | Private->TextOutList[Index].TextOut,\r | |
fe339651 | 4464 | WString\r |
9937b365 | 4465 | );\r |
4466 | if (EFI_ERROR (Status)) {\r | |
4467 | ReturnStatus = Status;\r | |
95276127 | 4468 | }\r |
4469 | }\r | |
4470 | \r | |
7389f649 | 4471 | if (Private->CurrentNumberOfConsoles > 0) {\r |
4472 | Private->TextOutMode.CursorColumn = Private->TextOutList[0].TextOut->Mode->CursorColumn;\r | |
4473 | Private->TextOutMode.CursorRow = Private->TextOutList[0].TextOut->Mode->CursorRow;\r | |
fe339651 | 4474 | } else {\r |
4475 | //\r | |
4476 | // When there is no real console devices in system, \r | |
4477 | // update cursor position for the virtual device in consplitter.\r | |
4478 | //\r | |
4479 | Private->TextOut.QueryMode (\r | |
4480 | &Private->TextOut,\r | |
4481 | Private->TextOutMode.Mode,\r | |
4482 | &MaxColumn,\r | |
4483 | &MaxRow\r | |
4484 | ); \r | |
4485 | for (; *WString != CHAR_NULL; WString++) {\r | |
4486 | switch (*WString) {\r | |
4487 | case CHAR_BACKSPACE:\r | |
4488 | if (Private->TextOutMode.CursorColumn == 0 && Private->TextOutMode.CursorRow > 0) {\r | |
4489 | Private->TextOutMode.CursorRow--;\r | |
4490 | Private->TextOutMode.CursorColumn = (INT32) (MaxColumn - 1); \r | |
4491 | } else if (Private->TextOutMode.CursorColumn > 0) {\r | |
4492 | Private->TextOutMode.CursorColumn--;\r | |
4493 | }\r | |
4494 | break;\r | |
4495 | \r | |
4496 | case CHAR_LINEFEED:\r | |
4497 | if (Private->TextOutMode.CursorRow < (INT32) (MaxRow - 1)) {\r | |
4498 | Private->TextOutMode.CursorRow++;\r | |
4499 | }\r | |
4500 | break;\r | |
4501 | \r | |
4502 | case CHAR_CARRIAGE_RETURN:\r | |
4503 | Private->TextOutMode.CursorColumn = 0;\r | |
4504 | break;\r | |
4505 | \r | |
4506 | default:\r | |
4507 | if (Private->TextOutMode.CursorColumn < (INT32) (MaxColumn - 1)) {\r | |
4508 | Private->TextOutMode.CursorColumn++;\r | |
4509 | } else {\r | |
4510 | Private->TextOutMode.CursorColumn = 0;\r | |
4511 | if (Private->TextOutMode.CursorRow < (INT32) (MaxRow - 1)) {\r | |
4512 | Private->TextOutMode.CursorRow++;\r | |
4513 | }\r | |
4514 | }\r | |
4515 | break;\r | |
4516 | }\r | |
4517 | }\r | |
95276127 | 4518 | }\r |
4519 | \r | |
4520 | return ReturnStatus;\r | |
4521 | }\r | |
4522 | \r | |
a4d608d1 | 4523 | \r |
4524 | /**\r | |
4525 | Verifies that all characters in a Unicode string can be output to the\r | |
4526 | target device.\r | |
4527 | \r | |
4528 | @param This Protocol instance pointer.\r | |
33019a71 | 4529 | @param WString The NULL-terminated Unicode string to be\r |
a4d608d1 | 4530 | examined for the output device(s).\r |
4531 | \r | |
4532 | @retval EFI_SUCCESS The device(s) are capable of rendering the\r | |
4533 | output string.\r | |
4534 | @retval EFI_UNSUPPORTED Some of the characters in the Unicode string\r | |
4535 | cannot be rendered by one or more of the output\r | |
4536 | devices mapped by the EFI handle.\r | |
4537 | \r | |
4538 | **/\r | |
95276127 | 4539 | EFI_STATUS\r |
4540 | EFIAPI\r | |
4541 | ConSplitterTextOutTestString (\r | |
4542 | IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,\r | |
4543 | IN CHAR16 *WString\r | |
4544 | )\r | |
95276127 | 4545 | {\r |
4546 | EFI_STATUS Status;\r | |
4547 | TEXT_OUT_SPLITTER_PRIVATE_DATA *Private;\r | |
4548 | UINTN Index;\r | |
4549 | EFI_STATUS ReturnStatus;\r | |
4550 | \r | |
4551 | Private = TEXT_OUT_SPLITTER_PRIVATE_DATA_FROM_THIS (This);\r | |
4552 | \r | |
4553 | //\r | |
4554 | // return the worst status met\r | |
4555 | //\r | |
4556 | for (Index = 0, ReturnStatus = EFI_SUCCESS; Index < Private->CurrentNumberOfConsoles; Index++) {\r | |
9937b365 | 4557 | Status = Private->TextOutList[Index].TextOut->TestString (\r |
4558 | Private->TextOutList[Index].TextOut,\r | |
4559 | WString\r | |
4560 | );\r | |
4561 | if (EFI_ERROR (Status)) {\r | |
4562 | ReturnStatus = Status;\r | |
95276127 | 4563 | }\r |
4564 | }\r | |
4565 | //\r | |
4566 | // There is no DevNullTextOutTestString () since a Unicode buffer would\r | |
4567 | // always return EFI_SUCCESS.\r | |
4568 | // ReturnStatus will be EFI_SUCCESS if no consoles are present\r | |
4569 | //\r | |
4570 | return ReturnStatus;\r | |
4571 | }\r | |
4572 | \r | |
a4d608d1 | 4573 | \r |
4574 | /**\r | |
4575 | Returns information for an available text mode that the output device(s)\r | |
4576 | supports.\r | |
4577 | \r | |
4578 | @param This Protocol instance pointer.\r | |
4579 | @param ModeNumber The mode number to return information on.\r | |
33019a71 | 4580 | @param Columns Returns the columns of the text output device\r |
4581 | for the requested ModeNumber.\r | |
4582 | @param Rows Returns the rows of the text output device\r | |
a4d608d1 | 4583 | for the requested ModeNumber.\r |
4584 | \r | |
4585 | @retval EFI_SUCCESS The requested mode information was returned.\r | |
4586 | @retval EFI_DEVICE_ERROR The device had an error and could not complete\r | |
4587 | the request.\r | |
4588 | @retval EFI_UNSUPPORTED The mode number was not valid.\r | |
4589 | \r | |
4590 | **/\r | |
95276127 | 4591 | EFI_STATUS\r |
4592 | EFIAPI\r | |
4593 | ConSplitterTextOutQueryMode (\r | |
4594 | IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,\r | |
4595 | IN UINTN ModeNumber,\r | |
4596 | OUT UINTN *Columns,\r | |
4597 | OUT UINTN *Rows\r | |
4598 | )\r | |
95276127 | 4599 | {\r |
4600 | TEXT_OUT_SPLITTER_PRIVATE_DATA *Private;\r | |
3012ce5c | 4601 | UINTN CurrentMode;\r |
4602 | INT32 *TextOutModeMap;\r | |
95276127 | 4603 | \r |
4604 | Private = TEXT_OUT_SPLITTER_PRIVATE_DATA_FROM_THIS (This);\r | |
4605 | \r | |
4606 | //\r | |
4607 | // Check whether param ModeNumber is valid.\r | |
4608 | // ModeNumber should be within range 0 ~ MaxMode - 1.\r | |
4609 | //\r | |
4610 | if ( (ModeNumber > (UINTN)(((UINT32)-1)>>1)) ) {\r | |
4611 | return EFI_UNSUPPORTED;\r | |
4612 | }\r | |
4613 | \r | |
4614 | if ((INT32) ModeNumber >= This->Mode->MaxMode) {\r | |
4615 | return EFI_UNSUPPORTED;\r | |
4616 | }\r | |
4617 | \r | |
3012ce5c | 4618 | //\r |
4619 | // We get the available mode from mode intersection map if it's available\r | |
4620 | //\r | |
4621 | if (Private->TextOutModeMap != NULL) {\r | |
4622 | TextOutModeMap = Private->TextOutModeMap + Private->TextOutListCount * ModeNumber;\r | |
4623 | CurrentMode = (UINTN)(*TextOutModeMap);\r | |
4624 | *Columns = Private->TextOutQueryData[CurrentMode].Columns;\r | |
4625 | *Rows = Private->TextOutQueryData[CurrentMode].Rows;\r | |
4626 | } else {\r | |
4627 | *Columns = Private->TextOutQueryData[ModeNumber].Columns;\r | |
4628 | *Rows = Private->TextOutQueryData[ModeNumber].Rows;\r | |
4629 | }\r | |
95276127 | 4630 | \r |
4631 | if (*Columns <= 0 && *Rows <= 0) {\r | |
4632 | return EFI_UNSUPPORTED;\r | |
4633 | \r | |
4634 | }\r | |
4635 | \r | |
4636 | return EFI_SUCCESS;\r | |
4637 | }\r | |
4638 | \r | |
a4d608d1 | 4639 | \r |
4640 | /**\r | |
4641 | Sets the output device(s) to a specified mode.\r | |
4642 | \r | |
4643 | @param This Protocol instance pointer.\r | |
4644 | @param ModeNumber The mode number to set.\r | |
4645 | \r | |
4646 | @retval EFI_SUCCESS The requested text mode was set.\r | |
4647 | @retval EFI_DEVICE_ERROR The device had an error and could not complete\r | |
4648 | the request.\r | |
4649 | @retval EFI_UNSUPPORTED The mode number was not valid.\r | |
4650 | \r | |
4651 | **/\r | |
95276127 | 4652 | EFI_STATUS\r |
4653 | EFIAPI\r | |
4654 | ConSplitterTextOutSetMode (\r | |
4655 | IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,\r | |
4656 | IN UINTN ModeNumber\r | |
4657 | )\r | |
95276127 | 4658 | {\r |
4659 | EFI_STATUS Status;\r | |
4660 | TEXT_OUT_SPLITTER_PRIVATE_DATA *Private;\r | |
4661 | UINTN Index;\r | |
4662 | INT32 *TextOutModeMap;\r | |
4663 | EFI_STATUS ReturnStatus;\r | |
4664 | \r | |
4665 | Private = TEXT_OUT_SPLITTER_PRIVATE_DATA_FROM_THIS (This);\r | |
4666 | \r | |
4667 | //\r | |
4668 | // Check whether param ModeNumber is valid.\r | |
4669 | // ModeNumber should be within range 0 ~ MaxMode - 1.\r | |
4670 | //\r | |
4671 | if ( (ModeNumber > (UINTN)(((UINT32)-1)>>1)) ) {\r | |
4672 | return EFI_UNSUPPORTED;\r | |
4673 | }\r | |
4674 | \r | |
4675 | if ((INT32) ModeNumber >= This->Mode->MaxMode) {\r | |
4676 | return EFI_UNSUPPORTED;\r | |
4677 | }\r | |
4678 | //\r | |
4679 | // If the mode is being set to the curent mode, then just clear the screen and return.\r | |
4680 | //\r | |
4681 | if (Private->TextOutMode.Mode == (INT32) ModeNumber) {\r | |
4682 | return ConSplitterTextOutClearScreen (This);\r | |
4683 | }\r | |
4684 | //\r | |
4685 | // return the worst status met\r | |
4686 | //\r | |
4687 | TextOutModeMap = Private->TextOutModeMap + Private->TextOutListCount * ModeNumber;\r | |
4688 | for (Index = 0, ReturnStatus = EFI_SUCCESS; Index < Private->CurrentNumberOfConsoles; Index++) {\r | |
9937b365 | 4689 | Status = Private->TextOutList[Index].TextOut->SetMode (\r |
4690 | Private->TextOutList[Index].TextOut,\r | |
4691 | TextOutModeMap[Index]\r | |
4692 | );\r | |
9937b365 | 4693 | if (EFI_ERROR (Status)) {\r |
4694 | ReturnStatus = Status;\r | |
95276127 | 4695 | }\r |
4696 | }\r | |
9937b365 | 4697 | \r |
95276127 | 4698 | //\r |
9937b365 | 4699 | // Set mode parameter to specified mode number\r |
95276127 | 4700 | //\r |
9937b365 | 4701 | TextOutSetMode (Private, ModeNumber);\r |
95276127 | 4702 | \r |
4703 | return ReturnStatus;\r | |
4704 | }\r | |
4705 | \r | |
a4d608d1 | 4706 | \r |
4707 | /**\r | |
4708 | Sets the background and foreground colors for the OutputString () and\r | |
4709 | ClearScreen () functions.\r | |
4710 | \r | |
4711 | @param This Protocol instance pointer.\r | |
4712 | @param Attribute The attribute to set. Bits 0..3 are the\r | |
4713 | foreground color, and bits 4..6 are the\r | |
4714 | background color. All other bits are undefined\r | |
4715 | and must be zero. The valid Attributes are\r | |
4716 | defined in this file.\r | |
4717 | \r | |
4718 | @retval EFI_SUCCESS The attribute was set.\r | |
4719 | @retval EFI_DEVICE_ERROR The device had an error and could not complete\r | |
4720 | the request.\r | |
4721 | @retval EFI_UNSUPPORTED The attribute requested is not defined.\r | |
4722 | \r | |
4723 | **/\r | |
95276127 | 4724 | EFI_STATUS\r |
4725 | EFIAPI\r | |
4726 | ConSplitterTextOutSetAttribute (\r | |
4727 | IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,\r | |
4728 | IN UINTN Attribute\r | |
4729 | )\r | |
95276127 | 4730 | {\r |
4731 | EFI_STATUS Status;\r | |
4732 | TEXT_OUT_SPLITTER_PRIVATE_DATA *Private;\r | |
4733 | UINTN Index;\r | |
4734 | EFI_STATUS ReturnStatus;\r | |
4735 | \r | |
4736 | Private = TEXT_OUT_SPLITTER_PRIVATE_DATA_FROM_THIS (This);\r | |
4737 | \r | |
4738 | //\r | |
4739 | // Check whether param Attribute is valid.\r | |
4740 | //\r | |
4741 | if ( (Attribute > (UINTN)(((UINT32)-1)>>1)) ) {\r | |
4742 | return EFI_UNSUPPORTED;\r | |
4743 | }\r | |
4744 | \r | |
4745 | //\r | |
4746 | // return the worst status met\r | |
4747 | //\r | |
4748 | for (Index = 0, ReturnStatus = EFI_SUCCESS; Index < Private->CurrentNumberOfConsoles; Index++) {\r | |
9937b365 | 4749 | Status = Private->TextOutList[Index].TextOut->SetAttribute (\r |
4750 | Private->TextOutList[Index].TextOut,\r | |
4751 | Attribute\r | |
4752 | );\r | |
4753 | if (EFI_ERROR (Status)) {\r | |
4754 | ReturnStatus = Status;\r | |
95276127 | 4755 | }\r |
4756 | }\r | |
4757 | \r | |
4758 | Private->TextOutMode.Attribute = (INT32) Attribute;\r | |
4759 | \r | |
4760 | return ReturnStatus;\r | |
4761 | }\r | |
4762 | \r | |
a4d608d1 | 4763 | \r |
4764 | /**\r | |
4765 | Clears the output device(s) display to the currently selected background\r | |
4766 | color.\r | |
4767 | \r | |
4768 | @param This Protocol instance pointer.\r | |
4769 | \r | |
4770 | @retval EFI_SUCCESS The operation completed successfully.\r | |
4771 | @retval EFI_DEVICE_ERROR The device had an error and could not complete\r | |
4772 | the request.\r | |
4773 | @retval EFI_UNSUPPORTED The output device is not in a valid text mode.\r | |
4774 | \r | |
4775 | **/\r | |
95276127 | 4776 | EFI_STATUS\r |
4777 | EFIAPI\r | |
4778 | ConSplitterTextOutClearScreen (\r | |
4779 | IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This\r | |
4780 | )\r | |
95276127 | 4781 | {\r |
4782 | EFI_STATUS Status;\r | |
4783 | TEXT_OUT_SPLITTER_PRIVATE_DATA *Private;\r | |
4784 | UINTN Index;\r | |
4785 | EFI_STATUS ReturnStatus;\r | |
4786 | \r | |
4787 | Private = TEXT_OUT_SPLITTER_PRIVATE_DATA_FROM_THIS (This);\r | |
4788 | \r | |
4789 | //\r | |
4790 | // return the worst status met\r | |
4791 | //\r | |
4792 | for (Index = 0, ReturnStatus = EFI_SUCCESS; Index < Private->CurrentNumberOfConsoles; Index++) {\r | |
9937b365 | 4793 | Status = Private->TextOutList[Index].TextOut->ClearScreen (Private->TextOutList[Index].TextOut);\r |
4794 | if (EFI_ERROR (Status)) {\r | |
4795 | ReturnStatus = Status;\r | |
95276127 | 4796 | }\r |
4797 | }\r | |
4798 | \r | |
9937b365 | 4799 | //\r |
4800 | // No need to do extra check here as whether (Column, Row) is valid has\r | |
4801 | // been checked in ConSplitterTextOutSetCursorPosition. And (0, 0) should\r | |
4802 | // always be supported.\r | |
4803 | //\r | |
4804 | Private->TextOutMode.CursorColumn = 0;\r | |
4805 | Private->TextOutMode.CursorRow = 0;\r | |
4806 | Private->TextOutMode.CursorVisible = TRUE;\r | |
95276127 | 4807 | \r |
4808 | return ReturnStatus;\r | |
4809 | }\r | |
4810 | \r | |
a4d608d1 | 4811 | \r |
4812 | /**\r | |
4813 | Sets the current coordinates of the cursor position\r | |
4814 | \r | |
4815 | @param This Protocol instance pointer.\r | |
33019a71 | 4816 | @param Column The column position to set the cursor to. Must be\r |
4817 | greater than or equal to zero and less than the\r | |
4818 | number of columns by QueryMode ().\r | |
4819 | @param Row The row position to set the cursor to. Must be\r | |
a4d608d1 | 4820 | greater than or equal to zero and less than the\r |
33019a71 | 4821 | number of rows by QueryMode ().\r |
a4d608d1 | 4822 | \r |
4823 | @retval EFI_SUCCESS The operation completed successfully.\r | |
4824 | @retval EFI_DEVICE_ERROR The device had an error and could not complete\r | |
4825 | the request.\r | |
4826 | @retval EFI_UNSUPPORTED The output device is not in a valid text mode,\r | |
4827 | or the cursor position is invalid for the\r | |
4828 | current mode.\r | |
4829 | \r | |
4830 | **/\r | |
95276127 | 4831 | EFI_STATUS\r |
4832 | EFIAPI\r | |
4833 | ConSplitterTextOutSetCursorPosition (\r | |
4834 | IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,\r | |
4835 | IN UINTN Column,\r | |
4836 | IN UINTN Row\r | |
4837 | )\r | |
95276127 | 4838 | {\r |
4839 | EFI_STATUS Status;\r | |
4840 | TEXT_OUT_SPLITTER_PRIVATE_DATA *Private;\r | |
4841 | UINTN Index;\r | |
4842 | EFI_STATUS ReturnStatus;\r | |
4843 | UINTN MaxColumn;\r | |
4844 | UINTN MaxRow;\r | |
de8fe2c2 | 4845 | INT32 *TextOutModeMap;\r |
4846 | INT32 ModeNumber;\r | |
4847 | INT32 CurrentMode;\r | |
95276127 | 4848 | \r |
4849 | Private = TEXT_OUT_SPLITTER_PRIVATE_DATA_FROM_THIS (This);\r | |
de8fe2c2 | 4850 | TextOutModeMap = NULL;\r |
4851 | ModeNumber = Private->TextOutMode.Mode;\r | |
7a5064ce | 4852 | \r |
de8fe2c2 | 4853 | //\r |
4854 | // Get current MaxColumn and MaxRow from intersection map\r | |
4855 | //\r | |
4856 | if (Private->TextOutModeMap != NULL) {\r | |
4857 | TextOutModeMap = Private->TextOutModeMap + Private->TextOutListCount * ModeNumber;\r | |
4858 | CurrentMode = *TextOutModeMap;\r | |
4859 | } else {\r | |
4860 | CurrentMode = ModeNumber;\r | |
4861 | }\r | |
7a5064ce | 4862 | \r |
de8fe2c2 | 4863 | MaxColumn = Private->TextOutQueryData[CurrentMode].Columns;\r |
4864 | MaxRow = Private->TextOutQueryData[CurrentMode].Rows;\r | |
95276127 | 4865 | \r |
4866 | if (Column >= MaxColumn || Row >= MaxRow) {\r | |
4867 | return EFI_UNSUPPORTED;\r | |
4868 | }\r | |
4869 | //\r | |
4870 | // return the worst status met\r | |
4871 | //\r | |
4872 | for (Index = 0, ReturnStatus = EFI_SUCCESS; Index < Private->CurrentNumberOfConsoles; Index++) {\r | |
9937b365 | 4873 | Status = Private->TextOutList[Index].TextOut->SetCursorPosition (\r |
4874 | Private->TextOutList[Index].TextOut,\r | |
4875 | Column,\r | |
4876 | Row\r | |
4877 | );\r | |
4878 | if (EFI_ERROR (Status)) {\r | |
4879 | ReturnStatus = Status;\r | |
95276127 | 4880 | }\r |
4881 | }\r | |
4882 | \r | |
9937b365 | 4883 | //\r |
4884 | // No need to do extra check here as whether (Column, Row) is valid has\r | |
4885 | // been checked in ConSplitterTextOutSetCursorPosition. And (0, 0) should\r | |
4886 | // always be supported.\r | |
4887 | //\r | |
4888 | Private->TextOutMode.CursorColumn = (INT32) Column;\r | |
4889 | Private->TextOutMode.CursorRow = (INT32) Row;\r | |
95276127 | 4890 | \r |
4891 | return ReturnStatus;\r | |
4892 | }\r | |
4893 | \r | |
a4d608d1 | 4894 | \r |
4895 | /**\r | |
4896 | Makes the cursor visible or invisible\r | |
4897 | \r | |
4898 | @param This Protocol instance pointer.\r | |
4899 | @param Visible If TRUE, the cursor is set to be visible. If\r | |
4900 | FALSE, the cursor is set to be invisible.\r | |
4901 | \r | |
4902 | @retval EFI_SUCCESS The operation completed successfully.\r | |
4903 | @retval EFI_DEVICE_ERROR The device had an error and could not complete\r | |
4904 | the request, or the device does not support\r | |
4905 | changing the cursor mode.\r | |
4906 | @retval EFI_UNSUPPORTED The output device is not in a valid text mode.\r | |
4907 | \r | |
4908 | **/\r | |
95276127 | 4909 | EFI_STATUS\r |
4910 | EFIAPI\r | |
4911 | ConSplitterTextOutEnableCursor (\r | |
4912 | IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,\r | |
4913 | IN BOOLEAN Visible\r | |
4914 | )\r | |
95276127 | 4915 | {\r |
4916 | EFI_STATUS Status;\r | |
4917 | TEXT_OUT_SPLITTER_PRIVATE_DATA *Private;\r | |
4918 | UINTN Index;\r | |
4919 | EFI_STATUS ReturnStatus;\r | |
4920 | \r | |
4921 | Private = TEXT_OUT_SPLITTER_PRIVATE_DATA_FROM_THIS (This);\r | |
4922 | \r | |
4923 | //\r | |
4924 | // return the worst status met\r | |
4925 | //\r | |
4926 | for (Index = 0, ReturnStatus = EFI_SUCCESS; Index < Private->CurrentNumberOfConsoles; Index++) {\r | |
9937b365 | 4927 | Status = Private->TextOutList[Index].TextOut->EnableCursor (\r |
4928 | Private->TextOutList[Index].TextOut,\r | |
4929 | Visible\r | |
4930 | );\r | |
4931 | if (EFI_ERROR (Status)) {\r | |
4932 | ReturnStatus = Status;\r | |
95276127 | 4933 | }\r |
4934 | }\r | |
4935 | \r | |
9937b365 | 4936 | Private->TextOutMode.CursorVisible = Visible;\r |
95276127 | 4937 | \r |
4938 | return ReturnStatus;\r | |
4939 | }\r | |
3012ce5c | 4940 | \r |