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