]> git.proxmox.com Git - mirror_edk2.git/blob - MdeModulePkg/Universal/Console/ConSplitterDxe/ConSplitter.c
Remove some unnecessary clear screen from console drivers.
[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 - 2010, Intel Corporation. All rights reserved.<BR>
20 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 ConSplitterUgaDrawGetMode,
111 ConSplitterUgaDrawSetMode,
112 ConSplitterUgaDrawBlt
113 };
114
115 //
116 // Graphics Output Protocol Private Data template
117 //
118 GLOBAL_REMOVE_IF_UNREFERENCED EFI_GRAPHICS_OUTPUT_PROTOCOL mGraphicsOutputProtocolTemplate = {
119 ConSplitterGraphicsOutputQueryMode,
120 ConSplitterGraphicsOutputSetMode,
121 ConSplitterGraphicsOutputBlt,
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 ConSplitterUgaDrawSetMode (&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 // Open the Parent Handle for the child.
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 // Construct console output devices' private data
1321 //
1322 Status = ConSplitterTextOutConstructor (&mStdErr);
1323 if (!EFI_ERROR (Status)) {
1324 //
1325 // Create virtual device handle for StdErr Splitter
1326 //
1327 Status = gBS->InstallMultipleProtocolInterfaces (
1328 &mStdErr.VirtualHandle,
1329 &gEfiSimpleTextOutProtocolGuid,
1330 &mStdErr.TextOut,
1331 NULL
1332 );
1333 }
1334 if (EFI_ERROR (Status)) {
1335 return Status;
1336 }
1337 }
1338
1339 //
1340 // Start ConSplitter on ControllerHandle, and create the virtual
1341 // agrogated console device on first call Start for a StandardError handle.
1342 //
1343 Status = ConSplitterStart (
1344 This,
1345 ControllerHandle,
1346 mStdErr.VirtualHandle,
1347 &gEfiStandardErrorDeviceGuid,
1348 &gEfiSimpleTextOutProtocolGuid,
1349 (VOID **) &TextOut
1350 );
1351 if (EFI_ERROR (Status)) {
1352 return Status;
1353 }
1354
1355 //
1356 // When new console device is added, the new mode will be set later,
1357 // so put current mode back to init state.
1358 //
1359 mStdErr.TextOutMode.Mode = 0xFF;
1360
1361 //
1362 // If both ConOut and StdErr incorporate the same Text Out device,
1363 // their MaxMode and QueryData should be the intersection of both.
1364 //
1365 Status = ConSplitterTextOutAddDevice (&mStdErr, TextOut, NULL, NULL);
1366 ConSplitterTextOutSetAttribute (&mStdErr.TextOut, EFI_TEXT_ATTR (EFI_MAGENTA, EFI_BLACK));
1367 if (EFI_ERROR (Status)) {
1368 return Status;
1369 }
1370
1371 if (mStdErr.CurrentNumberOfConsoles == 1) {
1372 gST->StandardErrorHandle = mStdErr.VirtualHandle;
1373 gST->StdErr = &mStdErr.TextOut;
1374 //
1375 // Update the CRC32 in the EFI System Table header
1376 //
1377 gST->Hdr.CRC32 = 0;
1378 gBS->CalculateCrc32 (
1379 (UINT8 *) &gST->Hdr,
1380 gST->Hdr.HeaderSize,
1381 &gST->Hdr.CRC32
1382 );
1383 }
1384
1385 return Status;
1386 }
1387
1388
1389 /**
1390 Stop ConSplitter on device handle by closing Console Device Guid on device handle
1391 and the console virtual handle.
1392
1393 @param This Protocol instance pointer.
1394 @param ControllerHandle Handle of device.
1395 @param ConSplitterVirtualHandle Console virtual Handle.
1396 @param DeviceGuid The specified Console Device, such as ConInDev,
1397 ConOutDev.
1398 @param InterfaceGuid The specified protocol to be opened.
1399 @param Interface Protocol interface returned.
1400
1401 @retval EFI_SUCCESS Stop ConSplitter on ControllerHandle successfully.
1402 @retval other Failed to Stop ConSplitter on ControllerHandle.
1403
1404 **/
1405 EFI_STATUS
1406 ConSplitterStop (
1407 IN EFI_DRIVER_BINDING_PROTOCOL *This,
1408 IN EFI_HANDLE ControllerHandle,
1409 IN EFI_HANDLE ConSplitterVirtualHandle,
1410 IN EFI_GUID *DeviceGuid,
1411 IN EFI_GUID *InterfaceGuid,
1412 IN VOID **Interface
1413 )
1414 {
1415 EFI_STATUS Status;
1416
1417 Status = gBS->OpenProtocol (
1418 ControllerHandle,
1419 InterfaceGuid,
1420 Interface,
1421 This->DriverBindingHandle,
1422 ControllerHandle,
1423 EFI_OPEN_PROTOCOL_GET_PROTOCOL
1424 );
1425 if (EFI_ERROR (Status)) {
1426 return Status;
1427 }
1428 //
1429 // close the protocol refered.
1430 //
1431 gBS->CloseProtocol (
1432 ControllerHandle,
1433 DeviceGuid,
1434 This->DriverBindingHandle,
1435 ConSplitterVirtualHandle
1436 );
1437
1438 gBS->CloseProtocol (
1439 ControllerHandle,
1440 DeviceGuid,
1441 This->DriverBindingHandle,
1442 ControllerHandle
1443 );
1444
1445 return EFI_SUCCESS;
1446 }
1447
1448
1449 /**
1450 Stop Console In ConSplitter on ControllerHandle by closing Console In Devcice GUID.
1451
1452 @param This Driver Binding protocol instance pointer.
1453 @param ControllerHandle Handle of device to stop driver on
1454 @param NumberOfChildren Number of Handles in ChildHandleBuffer. If number of
1455 children is zero stop the entire bus driver.
1456 @param ChildHandleBuffer List of Child Handles to Stop.
1457
1458 @retval EFI_SUCCESS This driver is removed ControllerHandle
1459 @retval other This driver was not removed from this device
1460
1461 **/
1462 EFI_STATUS
1463 EFIAPI
1464 ConSplitterConInDriverBindingStop (
1465 IN EFI_DRIVER_BINDING_PROTOCOL *This,
1466 IN EFI_HANDLE ControllerHandle,
1467 IN UINTN NumberOfChildren,
1468 IN EFI_HANDLE *ChildHandleBuffer
1469 )
1470 {
1471 EFI_STATUS Status;
1472 EFI_SIMPLE_TEXT_INPUT_PROTOCOL *TextIn;
1473 EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *TextInEx;
1474
1475 if (NumberOfChildren == 0) {
1476 return EFI_SUCCESS;
1477 }
1478
1479 Status = gBS->OpenProtocol (
1480 ControllerHandle,
1481 &gEfiSimpleTextInputExProtocolGuid,
1482 (VOID **) &TextInEx,
1483 This->DriverBindingHandle,
1484 ControllerHandle,
1485 EFI_OPEN_PROTOCOL_GET_PROTOCOL
1486 );
1487 if (!EFI_ERROR (Status)) {
1488 //
1489 // If Simple Text Input Ex protocol exists,
1490 // remove device from Text Input Ex devices list.
1491 //
1492 Status = ConSplitterTextInExDeleteDevice (&mConIn, TextInEx);
1493 if (EFI_ERROR (Status)) {
1494 return Status;
1495 }
1496 }
1497
1498 //
1499 // Close Simple Text In protocol on controller handle and virtual handle.
1500 //
1501 Status = ConSplitterStop (
1502 This,
1503 ControllerHandle,
1504 mConIn.VirtualHandle,
1505 &gEfiConsoleInDeviceGuid,
1506 &gEfiSimpleTextInProtocolGuid,
1507 (VOID **) &TextIn
1508 );
1509 if (EFI_ERROR (Status)) {
1510 return Status;
1511 }
1512
1513 //
1514 // Remove device from Text Input devices list.
1515 //
1516 return ConSplitterTextInDeleteDevice (&mConIn, TextIn);
1517 }
1518
1519
1520 /**
1521 Stop Simple Pointer protocol ConSplitter on ControllerHandle by closing
1522 Simple Pointer protocol.
1523
1524 @param This Driver Binding protocol instance pointer.
1525 @param ControllerHandle Handle of device to stop driver on
1526 @param NumberOfChildren Number of Handles in ChildHandleBuffer. If number of
1527 children is zero stop the entire bus driver.
1528 @param ChildHandleBuffer List of Child Handles to Stop.
1529
1530 @retval EFI_SUCCESS This driver is removed ControllerHandle
1531 @retval other This driver was not removed from this device
1532
1533 **/
1534 EFI_STATUS
1535 EFIAPI
1536 ConSplitterSimplePointerDriverBindingStop (
1537 IN EFI_DRIVER_BINDING_PROTOCOL *This,
1538 IN EFI_HANDLE ControllerHandle,
1539 IN UINTN NumberOfChildren,
1540 IN EFI_HANDLE *ChildHandleBuffer
1541 )
1542 {
1543 EFI_STATUS Status;
1544 EFI_SIMPLE_POINTER_PROTOCOL *SimplePointer;
1545
1546 if (NumberOfChildren == 0) {
1547 return EFI_SUCCESS;
1548 }
1549
1550 //
1551 // Close Simple Pointer protocol on controller handle and virtual handle.
1552 //
1553 Status = ConSplitterStop (
1554 This,
1555 ControllerHandle,
1556 mConIn.VirtualHandle,
1557 &gEfiSimplePointerProtocolGuid,
1558 &gEfiSimplePointerProtocolGuid,
1559 (VOID **) &SimplePointer
1560 );
1561 if (EFI_ERROR (Status)) {
1562 return Status;
1563 }
1564
1565 //
1566 // Remove this device from Simple Pointer device list.
1567 //
1568 return ConSplitterSimplePointerDeleteDevice (&mConIn, SimplePointer);
1569 }
1570
1571
1572 /**
1573 Stop Absolute Pointer protocol ConSplitter on ControllerHandle by closing
1574 Absolute Pointer protocol.
1575
1576 @param This Driver Binding protocol instance pointer.
1577 @param ControllerHandle Handle of device to stop driver on
1578 @param NumberOfChildren Number of Handles in ChildHandleBuffer. If number of
1579 children is zero stop the entire bus driver.
1580 @param ChildHandleBuffer List of Child Handles to Stop.
1581
1582 @retval EFI_SUCCESS This driver is removed ControllerHandle
1583 @retval other This driver was not removed from this device
1584
1585 **/
1586 EFI_STATUS
1587 EFIAPI
1588 ConSplitterAbsolutePointerDriverBindingStop (
1589 IN EFI_DRIVER_BINDING_PROTOCOL *This,
1590 IN EFI_HANDLE ControllerHandle,
1591 IN UINTN NumberOfChildren,
1592 IN EFI_HANDLE *ChildHandleBuffer
1593 )
1594 {
1595 EFI_STATUS Status;
1596 EFI_ABSOLUTE_POINTER_PROTOCOL *AbsolutePointer;
1597
1598 if (NumberOfChildren == 0) {
1599 return EFI_SUCCESS;
1600 }
1601
1602 //
1603 // Close Absolute Pointer protocol on controller handle and virtual handle.
1604 //
1605 Status = ConSplitterStop (
1606 This,
1607 ControllerHandle,
1608 mConIn.VirtualHandle,
1609 &gEfiAbsolutePointerProtocolGuid,
1610 &gEfiAbsolutePointerProtocolGuid,
1611 (VOID **) &AbsolutePointer
1612 );
1613 if (EFI_ERROR (Status)) {
1614 return Status;
1615 }
1616
1617 //
1618 // Remove this device from Absolute Pointer device list.
1619 //
1620 return ConSplitterAbsolutePointerDeleteDevice (&mConIn, AbsolutePointer);
1621 }
1622
1623
1624 /**
1625 Stop Console Out ConSplitter on device handle by closing Console Out Devcice GUID.
1626
1627 @param This Driver Binding protocol instance pointer.
1628 @param ControllerHandle Handle of device to stop driver on
1629 @param NumberOfChildren Number of Handles in ChildHandleBuffer. If number of
1630 children is zero stop the entire bus driver.
1631 @param ChildHandleBuffer List of Child Handles to Stop.
1632
1633 @retval EFI_SUCCESS This driver is removed ControllerHandle
1634 @retval other This driver was not removed from this device
1635
1636 **/
1637 EFI_STATUS
1638 EFIAPI
1639 ConSplitterConOutDriverBindingStop (
1640 IN EFI_DRIVER_BINDING_PROTOCOL *This,
1641 IN EFI_HANDLE ControllerHandle,
1642 IN UINTN NumberOfChildren,
1643 IN EFI_HANDLE *ChildHandleBuffer
1644 )
1645 {
1646 EFI_STATUS Status;
1647 EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *TextOut;
1648
1649 if (NumberOfChildren == 0) {
1650 return EFI_SUCCESS;
1651 }
1652
1653 //
1654 // Close Absolute Pointer protocol on controller handle and virtual handle.
1655 //
1656 Status = ConSplitterStop (
1657 This,
1658 ControllerHandle,
1659 mConOut.VirtualHandle,
1660 &gEfiConsoleOutDeviceGuid,
1661 &gEfiSimpleTextOutProtocolGuid,
1662 (VOID **) &TextOut
1663 );
1664 if (EFI_ERROR (Status)) {
1665 return Status;
1666 }
1667
1668 //
1669 // Remove this device from Text Out device list.
1670 //
1671 return ConSplitterTextOutDeleteDevice (&mConOut, TextOut);
1672 }
1673
1674
1675 /**
1676 Stop Standard Error ConSplitter on ControllerHandle by closing Standard Error GUID.
1677
1678 @param This Driver Binding protocol instance pointer.
1679 @param ControllerHandle Handle of device to stop driver on
1680 @param NumberOfChildren Number of Handles in ChildHandleBuffer. If number of
1681 children is zero stop the entire bus driver.
1682 @param ChildHandleBuffer List of Child Handles to Stop.
1683
1684 @retval EFI_SUCCESS This driver is removed ControllerHandle
1685 @retval other This driver was not removed from this device
1686
1687 **/
1688 EFI_STATUS
1689 EFIAPI
1690 ConSplitterStdErrDriverBindingStop (
1691 IN EFI_DRIVER_BINDING_PROTOCOL *This,
1692 IN EFI_HANDLE ControllerHandle,
1693 IN UINTN NumberOfChildren,
1694 IN EFI_HANDLE *ChildHandleBuffer
1695 )
1696 {
1697 EFI_STATUS Status;
1698 EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *TextOut;
1699
1700 if (NumberOfChildren == 0) {
1701 return EFI_SUCCESS;
1702 }
1703
1704 //
1705 // Close Standard Error Device on controller handle and virtual handle.
1706 //
1707 Status = ConSplitterStop (
1708 This,
1709 ControllerHandle,
1710 mStdErr.VirtualHandle,
1711 &gEfiStandardErrorDeviceGuid,
1712 &gEfiSimpleTextOutProtocolGuid,
1713 (VOID **) &TextOut
1714 );
1715 if (EFI_ERROR (Status)) {
1716 return Status;
1717 }
1718 //
1719 // Delete this console error out device's data structures.
1720 //
1721 Status = ConSplitterTextOutDeleteDevice (&mStdErr, TextOut);
1722 if (EFI_ERROR (Status)) {
1723 return Status;
1724 }
1725
1726 if (mStdErr.CurrentNumberOfConsoles == 0) {
1727 mStdErr.VirtualHandle = NULL;
1728
1729 gST->StandardErrorHandle = NULL;
1730 gST->StdErr = NULL;
1731 //
1732 // Update the CRC32 in the EFI System Table header
1733 //
1734 gST->Hdr.CRC32 = 0;
1735 gBS->CalculateCrc32 (
1736 (UINT8 *) &gST->Hdr,
1737 gST->Hdr.HeaderSize,
1738 &gST->Hdr.CRC32
1739 );
1740
1741 //
1742 // Uninstall Simple Text Output protocol from StdErr Handle.
1743 //
1744 gBS->UninstallMultipleProtocolInterfaces (
1745 mStdErr.VirtualHandle,
1746 &gEfiSimpleTextOutProtocolGuid,
1747 &mStdErr.TextOut,
1748 NULL
1749 );
1750 }
1751
1752 return Status;
1753 }
1754
1755
1756 /**
1757 Take the passed in Buffer of size SizeOfCount and grow the buffer
1758 by MAX (CONSOLE_SPLITTER_CONSOLES_ALLOC_UNIT, MaxGrow) * SizeOfCount
1759 bytes. Copy the current data in Buffer to the new version of Buffer
1760 and free the old version of buffer.
1761
1762 @param SizeOfCount Size of element in array.
1763 @param Count Current number of elements in array.
1764 @param Buffer Bigger version of passed in Buffer with all the
1765 data.
1766
1767 @retval EFI_SUCCESS Buffer size has grown.
1768 @retval EFI_OUT_OF_RESOURCES Could not grow the buffer size.
1769
1770 **/
1771 EFI_STATUS
1772 ConSplitterGrowBuffer (
1773 IN UINTN SizeOfCount,
1774 IN OUT UINTN *Count,
1775 IN OUT VOID **Buffer
1776 )
1777 {
1778 VOID *Ptr;
1779
1780 //
1781 // grow the buffer to new buffer size,
1782 // copy the old buffer's content to the new-size buffer,
1783 // then free the old buffer.
1784 //
1785 *Count += CONSOLE_SPLITTER_CONSOLES_ALLOC_UNIT;
1786 Ptr = ReallocatePool (
1787 SizeOfCount * ((*Count) - CONSOLE_SPLITTER_CONSOLES_ALLOC_UNIT),
1788 SizeOfCount * (*Count),
1789 *Buffer
1790 );
1791 if (Ptr == NULL) {
1792 return EFI_OUT_OF_RESOURCES;
1793 }
1794 *Buffer = Ptr;
1795 return EFI_SUCCESS;
1796 }
1797
1798
1799 /**
1800 Add Text Input Device in Consplitter Text Input list.
1801
1802 @param Private Text In Splitter pointer.
1803 @param TextIn Simple Text Input protocol pointer.
1804
1805 @retval EFI_SUCCESS Text Input Device added successfully.
1806 @retval EFI_OUT_OF_RESOURCES Could not grow the buffer size.
1807
1808 **/
1809 EFI_STATUS
1810 ConSplitterTextInAddDevice (
1811 IN TEXT_IN_SPLITTER_PRIVATE_DATA *Private,
1812 IN EFI_SIMPLE_TEXT_INPUT_PROTOCOL *TextIn
1813 )
1814 {
1815 EFI_STATUS Status;
1816
1817 //
1818 // If the Text In List is full, enlarge it by calling ConSplitterGrowBuffer().
1819 //
1820 if (Private->CurrentNumberOfConsoles >= Private->TextInListCount) {
1821 Status = ConSplitterGrowBuffer (
1822 sizeof (EFI_SIMPLE_TEXT_INPUT_PROTOCOL *),
1823 &Private->TextInListCount,
1824 (VOID **) &Private->TextInList
1825 );
1826 if (EFI_ERROR (Status)) {
1827 return EFI_OUT_OF_RESOURCES;
1828 }
1829 }
1830 //
1831 // Add the new text-in device data structure into the Text In List.
1832 //
1833 Private->TextInList[Private->CurrentNumberOfConsoles] = TextIn;
1834 Private->CurrentNumberOfConsoles++;
1835
1836 //
1837 // Extra CheckEvent added to reduce the double CheckEvent().
1838 //
1839 gBS->CheckEvent (TextIn->WaitForKey);
1840
1841 return EFI_SUCCESS;
1842 }
1843
1844
1845 /**
1846 Remove Text Input Device from Consplitter Text Input list.
1847
1848 @param Private Text In Splitter pointer.
1849 @param TextIn Simple Text protocol pointer.
1850
1851 @retval EFI_SUCCESS Simple Text Device removed successfully.
1852 @retval EFI_NOT_FOUND No Simple Text Device found.
1853
1854 **/
1855 EFI_STATUS
1856 ConSplitterTextInDeleteDevice (
1857 IN TEXT_IN_SPLITTER_PRIVATE_DATA *Private,
1858 IN EFI_SIMPLE_TEXT_INPUT_PROTOCOL *TextIn
1859 )
1860 {
1861 UINTN Index;
1862 //
1863 // Remove the specified text-in device data structure from the Text In List,
1864 // and rearrange the remaining data structures in the Text In List.
1865 //
1866 for (Index = 0; Index < Private->CurrentNumberOfConsoles; Index++) {
1867 if (Private->TextInList[Index] == TextIn) {
1868 for (Index = Index; Index < Private->CurrentNumberOfConsoles - 1; Index++) {
1869 Private->TextInList[Index] = Private->TextInList[Index + 1];
1870 }
1871
1872 Private->CurrentNumberOfConsoles--;
1873 return EFI_SUCCESS;
1874 }
1875 }
1876
1877 return EFI_NOT_FOUND;
1878 }
1879
1880 /**
1881 Add Text Input Ex Device in Consplitter Text Input Ex list.
1882
1883 @param Private Text In Splitter pointer.
1884 @param TextInEx Simple Text Input Ex Input protocol pointer.
1885
1886 @retval EFI_SUCCESS Text Input Ex Device added successfully.
1887 @retval EFI_OUT_OF_RESOURCES Could not grow the buffer size.
1888
1889 **/
1890 EFI_STATUS
1891 ConSplitterTextInExAddDevice (
1892 IN TEXT_IN_SPLITTER_PRIVATE_DATA *Private,
1893 IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *TextInEx
1894 )
1895 {
1896 EFI_STATUS Status;
1897
1898 //
1899 // If the Text Input Ex List is full, enlarge it by calling ConSplitterGrowBuffer().
1900 //
1901 if (Private->CurrentNumberOfExConsoles >= Private->TextInExListCount) {
1902 Status = ConSplitterGrowBuffer (
1903 sizeof (EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *),
1904 &Private->TextInExListCount,
1905 (VOID **) &Private->TextInExList
1906 );
1907 if (EFI_ERROR (Status)) {
1908 return EFI_OUT_OF_RESOURCES;
1909 }
1910 }
1911 //
1912 // Add the new text-in device data structure into the Text Input Ex List.
1913 //
1914 Private->TextInExList[Private->CurrentNumberOfExConsoles] = TextInEx;
1915 Private->CurrentNumberOfExConsoles++;
1916
1917 //
1918 // Extra CheckEvent added to reduce the double CheckEvent().
1919 //
1920 gBS->CheckEvent (TextInEx->WaitForKeyEx);
1921
1922 return EFI_SUCCESS;
1923 }
1924
1925 /**
1926 Remove Text Ex Device from Consplitter Text Input Ex list.
1927
1928 @param Private Text In Splitter pointer.
1929 @param TextInEx Simple Text Ex protocol pointer.
1930
1931 @retval EFI_SUCCESS Simple Text Input Ex Device removed successfully.
1932 @retval EFI_NOT_FOUND No Simple Text Input Ex Device found.
1933
1934 **/
1935 EFI_STATUS
1936 ConSplitterTextInExDeleteDevice (
1937 IN TEXT_IN_SPLITTER_PRIVATE_DATA *Private,
1938 IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *TextInEx
1939 )
1940 {
1941 UINTN Index;
1942 //
1943 // Remove the specified text-in device data structure from the Text Input Ex List,
1944 // and rearrange the remaining data structures in the Text In List.
1945 //
1946 for (Index = 0; Index < Private->CurrentNumberOfExConsoles; Index++) {
1947 if (Private->TextInExList[Index] == TextInEx) {
1948 for (Index = Index; Index < Private->CurrentNumberOfExConsoles - 1; Index++) {
1949 Private->TextInExList[Index] = Private->TextInExList[Index + 1];
1950 }
1951
1952 Private->CurrentNumberOfExConsoles--;
1953 return EFI_SUCCESS;
1954 }
1955 }
1956
1957 return EFI_NOT_FOUND;
1958 }
1959
1960
1961 /**
1962 Add Simple Pointer Device in Consplitter Simple Pointer list.
1963
1964 @param Private Text In Splitter pointer.
1965 @param SimplePointer Simple Pointer protocol pointer.
1966
1967 @retval EFI_SUCCESS Simple Pointer Device added successfully.
1968 @retval EFI_OUT_OF_RESOURCES Could not grow the buffer size.
1969
1970 **/
1971 EFI_STATUS
1972 ConSplitterSimplePointerAddDevice (
1973 IN TEXT_IN_SPLITTER_PRIVATE_DATA *Private,
1974 IN EFI_SIMPLE_POINTER_PROTOCOL *SimplePointer
1975 )
1976 {
1977 EFI_STATUS Status;
1978
1979 //
1980 // If the Simple Pointer List is full, enlarge it by calling ConSplitterGrowBuffer().
1981 //
1982 if (Private->CurrentNumberOfPointers >= Private->PointerListCount) {
1983 Status = ConSplitterGrowBuffer (
1984 sizeof (EFI_SIMPLE_POINTER_PROTOCOL *),
1985 &Private->PointerListCount,
1986 (VOID **) &Private->PointerList
1987 );
1988 if (EFI_ERROR (Status)) {
1989 return EFI_OUT_OF_RESOURCES;
1990 }
1991 }
1992 //
1993 // Add the new text-in device data structure into the Simple Pointer List.
1994 //
1995 Private->PointerList[Private->CurrentNumberOfPointers] = SimplePointer;
1996 Private->CurrentNumberOfPointers++;
1997
1998 return EFI_SUCCESS;
1999 }
2000
2001
2002 /**
2003 Remove Simple Pointer Device from Consplitter Simple Pointer list.
2004
2005 @param Private Text In Splitter pointer.
2006 @param SimplePointer Simple Pointer protocol pointer.
2007
2008 @retval EFI_SUCCESS Simple Pointer Device removed successfully.
2009 @retval EFI_NOT_FOUND No Simple Pointer Device found.
2010
2011 **/
2012 EFI_STATUS
2013 ConSplitterSimplePointerDeleteDevice (
2014 IN TEXT_IN_SPLITTER_PRIVATE_DATA *Private,
2015 IN EFI_SIMPLE_POINTER_PROTOCOL *SimplePointer
2016 )
2017 {
2018 UINTN Index;
2019 //
2020 // Remove the specified text-in device data structure from the Simple Pointer List,
2021 // and rearrange the remaining data structures in the Text In List.
2022 //
2023 for (Index = 0; Index < Private->CurrentNumberOfPointers; Index++) {
2024 if (Private->PointerList[Index] == SimplePointer) {
2025 for (Index = Index; Index < Private->CurrentNumberOfPointers - 1; Index++) {
2026 Private->PointerList[Index] = Private->PointerList[Index + 1];
2027 }
2028
2029 Private->CurrentNumberOfPointers--;
2030 return EFI_SUCCESS;
2031 }
2032 }
2033
2034 return EFI_NOT_FOUND;
2035 }
2036
2037
2038 /**
2039 Add Absolute Pointer Device in Consplitter Absolute Pointer list.
2040
2041 @param Private Text In Splitter pointer.
2042 @param AbsolutePointer Absolute Pointer protocol pointer.
2043
2044 @retval EFI_SUCCESS Absolute Pointer Device added successfully.
2045 @retval EFI_OUT_OF_RESOURCES Could not grow the buffer size.
2046
2047 **/
2048 EFI_STATUS
2049 ConSplitterAbsolutePointerAddDevice (
2050 IN TEXT_IN_SPLITTER_PRIVATE_DATA *Private,
2051 IN EFI_ABSOLUTE_POINTER_PROTOCOL *AbsolutePointer
2052 )
2053 {
2054 EFI_STATUS Status;
2055
2056 //
2057 // If the Absolute Pointer List is full, enlarge it by calling ConSplitterGrowBuffer().
2058 //
2059 if (Private->CurrentNumberOfAbsolutePointers >= Private->AbsolutePointerListCount) {
2060 Status = ConSplitterGrowBuffer (
2061 sizeof (EFI_ABSOLUTE_POINTER_PROTOCOL *),
2062 &Private->AbsolutePointerListCount,
2063 (VOID **) &Private->AbsolutePointerList
2064 );
2065 if (EFI_ERROR (Status)) {
2066 return EFI_OUT_OF_RESOURCES;
2067 }
2068 }
2069 //
2070 // Add the new text-in device data structure into the Absolute Pointer List.
2071 //
2072 Private->AbsolutePointerList[Private->CurrentNumberOfAbsolutePointers] = AbsolutePointer;
2073 Private->CurrentNumberOfAbsolutePointers++;
2074
2075 return EFI_SUCCESS;
2076 }
2077
2078
2079 /**
2080 Remove Absolute Pointer Device from Consplitter Absolute Pointer list.
2081
2082 @param Private Text In Splitter pointer.
2083 @param AbsolutePointer Absolute Pointer protocol pointer.
2084
2085 @retval EFI_SUCCESS Absolute Pointer Device removed successfully.
2086 @retval EFI_NOT_FOUND No Absolute Pointer Device found.
2087
2088 **/
2089 EFI_STATUS
2090 ConSplitterAbsolutePointerDeleteDevice (
2091 IN TEXT_IN_SPLITTER_PRIVATE_DATA *Private,
2092 IN EFI_ABSOLUTE_POINTER_PROTOCOL *AbsolutePointer
2093 )
2094 {
2095 UINTN Index;
2096 //
2097 // Remove the specified text-in device data structure from the Absolute Pointer List,
2098 // and rearrange the remaining data structures from the Absolute Pointer List.
2099 //
2100 for (Index = 0; Index < Private->CurrentNumberOfAbsolutePointers; Index++) {
2101 if (Private->AbsolutePointerList[Index] == AbsolutePointer) {
2102 for (Index = Index; Index < Private->CurrentNumberOfAbsolutePointers - 1; Index++) {
2103 Private->AbsolutePointerList[Index] = Private->AbsolutePointerList[Index + 1];
2104 }
2105
2106 Private->CurrentNumberOfAbsolutePointers--;
2107 return EFI_SUCCESS;
2108 }
2109 }
2110
2111 return EFI_NOT_FOUND;
2112 }
2113
2114 /**
2115 Reallocate Text Out mode map.
2116
2117 Allocate new buffer and copy original buffer into the new buffer.
2118
2119 @param Private Consplitter Text Out pointer.
2120
2121 @retval EFI_SUCCESS Buffer size has grown
2122 @retval EFI_OUT_OF_RESOURCES Could not grow the buffer size.
2123
2124 **/
2125 EFI_STATUS
2126 ConSplitterGrowMapTable (
2127 IN TEXT_OUT_SPLITTER_PRIVATE_DATA *Private
2128 )
2129 {
2130 UINTN Size;
2131 UINTN NewSize;
2132 UINTN TotalSize;
2133 INT32 *TextOutModeMap;
2134 INT32 *OldTextOutModeMap;
2135 INT32 *SrcAddress;
2136 INT32 Index;
2137
2138 NewSize = Private->TextOutListCount * sizeof (INT32);
2139 OldTextOutModeMap = Private->TextOutModeMap;
2140 TotalSize = NewSize * (Private->TextOutQueryDataCount);
2141
2142 //
2143 // Allocate new buffer for Text Out List.
2144 //
2145 TextOutModeMap = AllocatePool (TotalSize);
2146 if (TextOutModeMap == NULL) {
2147 return EFI_OUT_OF_RESOURCES;
2148 }
2149
2150 SetMem (TextOutModeMap, TotalSize, 0xFF);
2151 Private->TextOutModeMap = TextOutModeMap;
2152
2153 //
2154 // If TextOutList has been enlarged, need to realloc the mode map table
2155 // The mode map table is regarded as a two dimension array.
2156 //
2157 // Old New
2158 // 0 ---------> TextOutListCount ----> TextOutListCount
2159 // | -------------------------------------------
2160 // | | | |
2161 // | | | |
2162 // | | | |
2163 // | | | |
2164 // | | | |
2165 // \/ | | |
2166 // -------------------------------------------
2167 // QueryDataCount
2168 //
2169 if (OldTextOutModeMap != NULL) {
2170
2171 Size = Private->CurrentNumberOfConsoles * sizeof (INT32);
2172 Index = 0;
2173 SrcAddress = OldTextOutModeMap;
2174
2175 //
2176 // Copy the old data to the new one
2177 //
2178 while (Index < Private->TextOutMode.MaxMode) {
2179 CopyMem (TextOutModeMap, SrcAddress, Size);
2180 TextOutModeMap += NewSize;
2181 SrcAddress += Size;
2182 Index++;
2183 }
2184 //
2185 // Free the old buffer
2186 //
2187 FreePool (OldTextOutModeMap);
2188 }
2189
2190 return EFI_SUCCESS;
2191 }
2192
2193
2194 /**
2195 Add new device's output mode to console splitter's mode list.
2196
2197 @param Private Text Out Splitter pointer
2198 @param TextOut Simple Text Output protocol pointer.
2199
2200 @retval EFI_SUCCESS Device added successfully.
2201 @retval EFI_OUT_OF_RESOURCES Could not grow the buffer size.
2202
2203 **/
2204 EFI_STATUS
2205 ConSplitterAddOutputMode (
2206 IN TEXT_OUT_SPLITTER_PRIVATE_DATA *Private,
2207 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *TextOut
2208 )
2209 {
2210 EFI_STATUS Status;
2211 INT32 MaxMode;
2212 INT32 Mode;
2213 UINTN Index;
2214
2215 MaxMode = TextOut->Mode->MaxMode;
2216 Private->TextOutMode.MaxMode = MaxMode;
2217
2218 //
2219 // Grow the buffer if query data buffer is not large enough to
2220 // hold all the mode supported by the first console.
2221 //
2222 while (MaxMode > (INT32) Private->TextOutQueryDataCount) {
2223 Status = ConSplitterGrowBuffer (
2224 sizeof (TEXT_OUT_SPLITTER_QUERY_DATA),
2225 &Private->TextOutQueryDataCount,
2226 (VOID **) &Private->TextOutQueryData
2227 );
2228 if (EFI_ERROR (Status)) {
2229 return EFI_OUT_OF_RESOURCES;
2230 }
2231 }
2232 //
2233 // Allocate buffer for the output mode map
2234 //
2235 Status = ConSplitterGrowMapTable (Private);
2236 if (EFI_ERROR (Status)) {
2237 return EFI_OUT_OF_RESOURCES;
2238 }
2239 //
2240 // As the first textout device, directly add the mode in to QueryData
2241 // and at the same time record the mapping between QueryData and TextOut.
2242 //
2243 Mode = 0;
2244 Index = 0;
2245 while (Mode < MaxMode) {
2246 Status = TextOut->QueryMode (
2247 TextOut,
2248 Mode,
2249 &Private->TextOutQueryData[Mode].Columns,
2250 &Private->TextOutQueryData[Mode].Rows
2251 );
2252 //
2253 // If mode 1 (80x50) is not supported, make sure mode 1 in TextOutQueryData
2254 // is clear to 0x0.
2255 //
2256 if ((EFI_ERROR(Status)) && (Mode == 1)) {
2257 Private->TextOutQueryData[Mode].Columns = 0;
2258 Private->TextOutQueryData[Mode].Rows = 0;
2259 }
2260 Private->TextOutModeMap[Index] = Mode;
2261 Mode++;
2262 Index += Private->TextOutListCount;
2263 }
2264
2265 return EFI_SUCCESS;
2266 }
2267
2268 /**
2269 Reconstruct TextOutModeMap to get intersection of modes.
2270
2271 This routine reconstruct TextOutModeMap to get the intersection
2272 of modes for all console out devices. Because EFI/UEFI spec require
2273 mode 0 is 80x25, mode 1 is 80x50, this routine will not check the
2274 intersection for mode 0 and mode 1.
2275
2276 @param TextOutModeMap Current text out mode map, begin with the mode 80x25
2277 @param NewlyAddedMap New text out mode map, begin with the mode 80x25
2278 @param MapStepSize Mode step size for one console device
2279 @param NewMapStepSize New Mode step size for one console device
2280 @param MaxMode IN: Current max text mode, OUT: Updated max text mode.
2281 @param CurrentMode IN: Current text mode, OUT: Updated current text mode.
2282
2283 **/
2284 VOID
2285 ConSplitterGetIntersection (
2286 IN INT32 *TextOutModeMap,
2287 IN INT32 *NewlyAddedMap,
2288 IN UINTN MapStepSize,
2289 IN UINTN NewMapStepSize,
2290 IN OUT INT32 *MaxMode,
2291 IN OUT INT32 *CurrentMode
2292 )
2293 {
2294 INT32 Index;
2295 INT32 *CurrentMapEntry;
2296 INT32 *NextMapEntry;
2297 INT32 *NewMapEntry;
2298 INT32 CurrentMaxMode;
2299 INT32 Mode;
2300
2301 //
2302 // According to EFI/UEFI spec, mode 0 and mode 1 have been reserved
2303 // for 80x25 and 80x50 in Simple Text Out protocol, so don't make intersection
2304 // for mode 0 and mode 1, mode number starts from 2.
2305 //
2306 Index = 2;
2307 CurrentMapEntry = &TextOutModeMap[MapStepSize * 2];
2308 NextMapEntry = CurrentMapEntry;
2309 NewMapEntry = &NewlyAddedMap[NewMapStepSize * 2];
2310
2311 CurrentMaxMode = *MaxMode;
2312 Mode = *CurrentMode;
2313
2314 while (Index < CurrentMaxMode) {
2315 if (*NewMapEntry == -1) {
2316 //
2317 // This mode is not supported any more. Remove it. Special care
2318 // must be taken as this remove will also affect current mode;
2319 //
2320 if (Index == *CurrentMode) {
2321 Mode = -1;
2322 } else if (Index < *CurrentMode) {
2323 Mode--;
2324 }
2325 (*MaxMode)--;
2326 } else {
2327 if (CurrentMapEntry != NextMapEntry) {
2328 CopyMem (NextMapEntry, CurrentMapEntry, MapStepSize * sizeof (INT32));
2329 }
2330
2331 NextMapEntry += MapStepSize;
2332 }
2333
2334 CurrentMapEntry += MapStepSize;
2335 NewMapEntry += NewMapStepSize;
2336 Index++;
2337 }
2338
2339 *CurrentMode = Mode;
2340
2341 return ;
2342 }
2343
2344 /**
2345 Sync the device's output mode to console splitter's mode list.
2346
2347 @param Private Text Out Splitter pointer.
2348 @param TextOut Simple Text Output protocol pointer.
2349
2350 **/
2351 VOID
2352 ConSplitterSyncOutputMode (
2353 IN TEXT_OUT_SPLITTER_PRIVATE_DATA *Private,
2354 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *TextOut
2355 )
2356 {
2357 INT32 CurrentMaxMode;
2358 INT32 Mode;
2359 INT32 Index;
2360 INT32 *TextOutModeMap;
2361 INT32 *MapTable;
2362 INT32 QueryMode;
2363 TEXT_OUT_SPLITTER_QUERY_DATA *TextOutQueryData;
2364 UINTN Rows;
2365 UINTN Columns;
2366 UINTN StepSize;
2367 EFI_STATUS Status;
2368
2369 //
2370 // Must make sure that current mode won't change even if mode number changes
2371 //
2372 CurrentMaxMode = Private->TextOutMode.MaxMode;
2373 TextOutModeMap = Private->TextOutModeMap;
2374 StepSize = Private->TextOutListCount;
2375 TextOutQueryData = Private->TextOutQueryData;
2376
2377 //
2378 // Query all the mode that the newly added TextOut supports
2379 //
2380 Mode = 0;
2381 MapTable = TextOutModeMap + Private->CurrentNumberOfConsoles;
2382 while (Mode < TextOut->Mode->MaxMode) {
2383 Status = TextOut->QueryMode (TextOut, Mode, &Columns, &Rows);
2384
2385 if (EFI_ERROR(Status)) {
2386 if (Mode == 1) {
2387 //
2388 // If mode 1 (80x50) is not supported, make sure mode 1 in TextOutQueryData
2389 // is clear to 0x0.
2390 //
2391 MapTable[StepSize] = Mode;
2392 TextOutQueryData[Mode].Columns = 0;
2393 TextOutQueryData[Mode].Rows = 0;
2394 }
2395 Mode++;
2396 continue;
2397 }
2398 //
2399 // Search the intersection map and QueryData database to see if they intersects
2400 //
2401 Index = 0;
2402 while (Index < CurrentMaxMode) {
2403 QueryMode = *(TextOutModeMap + Index * StepSize);
2404 if ((TextOutQueryData[QueryMode].Rows == Rows) && (TextOutQueryData[QueryMode].Columns == Columns)) {
2405 MapTable[Index * StepSize] = Mode;
2406 break;
2407 }
2408 Index++;
2409 }
2410 Mode++;
2411 }
2412 //
2413 // Now search the TextOutModeMap table to find the intersection of supported
2414 // mode between ConSplitter and the newly added device.
2415 //
2416 ConSplitterGetIntersection (
2417 TextOutModeMap,
2418 MapTable,
2419 StepSize,
2420 StepSize,
2421 &Private->TextOutMode.MaxMode,
2422 &Private->TextOutMode.Mode
2423 );
2424
2425 return ;
2426 }
2427
2428
2429 /**
2430 Sync output device between ConOut and StdErr output.
2431
2432 @retval EFI_SUCCESS Sync implemented successfully.
2433 @retval EFI_OUT_OF_RESOURCES Could not grow the buffer size.
2434
2435 **/
2436 EFI_STATUS
2437 ConSplitterGetIntersectionBetweenConOutAndStrErr (
2438 VOID
2439 )
2440 {
2441 UINTN ConOutNumOfConsoles;
2442 UINTN StdErrNumOfConsoles;
2443 TEXT_OUT_AND_GOP_DATA *ConOutTextOutList;
2444 TEXT_OUT_AND_GOP_DATA *StdErrTextOutList;
2445 UINTN Indexi;
2446 UINTN Indexj;
2447 UINTN ConOutRows;
2448 UINTN ConOutColumns;
2449 UINTN StdErrRows;
2450 UINTN StdErrColumns;
2451 INT32 ConOutMaxMode;
2452 INT32 StdErrMaxMode;
2453 INT32 ConOutMode;
2454 INT32 StdErrMode;
2455 INT32 Mode;
2456 INT32 Index;
2457 INT32 *ConOutModeMap;
2458 INT32 *StdErrModeMap;
2459 INT32 *ConOutMapTable;
2460 INT32 *StdErrMapTable;
2461 TEXT_OUT_SPLITTER_QUERY_DATA *ConOutQueryData;
2462 TEXT_OUT_SPLITTER_QUERY_DATA *StdErrQueryData;
2463 UINTN ConOutStepSize;
2464 UINTN StdErrStepSize;
2465 BOOLEAN FoundTheSameTextOut;
2466 UINTN ConOutMapTableSize;
2467 UINTN StdErrMapTableSize;
2468
2469 ConOutNumOfConsoles = mConOut.CurrentNumberOfConsoles;
2470 StdErrNumOfConsoles = mStdErr.CurrentNumberOfConsoles;
2471 ConOutTextOutList = mConOut.TextOutList;
2472 StdErrTextOutList = mStdErr.TextOutList;
2473
2474 Indexi = 0;
2475 FoundTheSameTextOut = FALSE;
2476 while ((Indexi < ConOutNumOfConsoles) && (!FoundTheSameTextOut)) {
2477 Indexj = 0;
2478 while (Indexj < StdErrNumOfConsoles) {
2479 if (ConOutTextOutList->TextOut == StdErrTextOutList->TextOut) {
2480 FoundTheSameTextOut = TRUE;
2481 break;
2482 }
2483
2484 Indexj++;
2485 StdErrTextOutList++;
2486 }
2487
2488 Indexi++;
2489 ConOutTextOutList++;
2490 }
2491
2492 if (!FoundTheSameTextOut) {
2493 return EFI_SUCCESS;
2494 }
2495 //
2496 // Must make sure that current mode won't change even if mode number changes
2497 //
2498 ConOutMaxMode = mConOut.TextOutMode.MaxMode;
2499 ConOutModeMap = mConOut.TextOutModeMap;
2500 ConOutStepSize = mConOut.TextOutListCount;
2501 ConOutQueryData = mConOut.TextOutQueryData;
2502
2503 StdErrMaxMode = mStdErr.TextOutMode.MaxMode;
2504 StdErrModeMap = mStdErr.TextOutModeMap;
2505 StdErrStepSize = mStdErr.TextOutListCount;
2506 StdErrQueryData = mStdErr.TextOutQueryData;
2507
2508 //
2509 // Allocate the map table and set the map table's index to -1.
2510 //
2511 ConOutMapTableSize = ConOutMaxMode * sizeof (INT32);
2512 ConOutMapTable = AllocateZeroPool (ConOutMapTableSize);
2513 if (ConOutMapTable == NULL) {
2514 return EFI_OUT_OF_RESOURCES;
2515 }
2516
2517 SetMem (ConOutMapTable, ConOutMapTableSize, 0xFF);
2518
2519 StdErrMapTableSize = StdErrMaxMode * sizeof (INT32);
2520 StdErrMapTable = AllocateZeroPool (StdErrMapTableSize);
2521 if (StdErrMapTable == NULL) {
2522 return EFI_OUT_OF_RESOURCES;
2523 }
2524
2525 SetMem (StdErrMapTable, StdErrMapTableSize, 0xFF);
2526
2527 //
2528 // Find the intersection of the two set of modes. If they actually intersect, the
2529 // correponding entry in the map table is set to 1.
2530 //
2531 Mode = 0;
2532 while (Mode < ConOutMaxMode) {
2533 //
2534 // Search the intersection map and QueryData database to see if they intersect
2535 //
2536 Index = 0;
2537 ConOutMode = *(ConOutModeMap + Mode * ConOutStepSize);
2538 ConOutRows = ConOutQueryData[ConOutMode].Rows;
2539 ConOutColumns = ConOutQueryData[ConOutMode].Columns;
2540 while (Index < StdErrMaxMode) {
2541 StdErrMode = *(StdErrModeMap + Index * StdErrStepSize);
2542 StdErrRows = StdErrQueryData[StdErrMode].Rows;
2543 StdErrColumns = StdErrQueryData[StdErrMode].Columns;
2544 if ((StdErrRows == ConOutRows) && (StdErrColumns == ConOutColumns)) {
2545 ConOutMapTable[Mode] = 1;
2546 StdErrMapTable[Index] = 1;
2547 break;
2548 }
2549
2550 Index++;
2551 }
2552
2553 Mode++;
2554 }
2555 //
2556 // Now search the TextOutModeMap table to find the intersection of supported
2557 // mode between ConSplitter and the newly added device.
2558 //
2559 ConSplitterGetIntersection (
2560 ConOutModeMap,
2561 ConOutMapTable,
2562 mConOut.TextOutListCount,
2563 1,
2564 &(mConOut.TextOutMode.MaxMode),
2565 &(mConOut.TextOutMode.Mode)
2566 );
2567
2568 if (mConOut.TextOutMode.Mode < 0) {
2569 mConOut.TextOut.SetMode (&(mConOut.TextOut), 0);
2570 }
2571
2572 ConSplitterGetIntersection (
2573 StdErrModeMap,
2574 StdErrMapTable,
2575 mStdErr.TextOutListCount,
2576 1,
2577 &(mStdErr.TextOutMode.MaxMode),
2578 &(mStdErr.TextOutMode.Mode)
2579 );
2580
2581 if (mStdErr.TextOutMode.Mode < 0) {
2582 mStdErr.TextOut.SetMode (&(mStdErr.TextOut), 0);
2583 }
2584
2585 FreePool (ConOutMapTable);
2586 FreePool (StdErrMapTable);
2587
2588 return EFI_SUCCESS;
2589 }
2590
2591
2592 /**
2593 Add Grahpics Output modes into Consplitter Text Out list.
2594
2595 @param Private Text Out Splitter pointer.
2596 @param GraphicsOutput Graphics Output protocol pointer.
2597 @param UgaDraw UGA Draw protocol pointer.
2598
2599 @retval EFI_SUCCESS Output mode added successfully.
2600 @retval other Failed to add output mode.
2601
2602 **/
2603 EFI_STATUS
2604 ConSplitterAddGraphicsOutputMode (
2605 IN TEXT_OUT_SPLITTER_PRIVATE_DATA *Private,
2606 IN EFI_GRAPHICS_OUTPUT_PROTOCOL *GraphicsOutput,
2607 IN EFI_UGA_DRAW_PROTOCOL *UgaDraw
2608 )
2609 {
2610 EFI_STATUS Status;
2611 UINTN Index;
2612 UINTN CurrentIndex;
2613 EFI_GRAPHICS_OUTPUT_MODE_INFORMATION *Mode;
2614 UINTN SizeOfInfo;
2615 EFI_GRAPHICS_OUTPUT_MODE_INFORMATION *Info;
2616 EFI_GRAPHICS_OUTPUT_PROTOCOL_MODE *CurrentGraphicsOutputMode;
2617 EFI_GRAPHICS_OUTPUT_MODE_INFORMATION *ModeBuffer;
2618 EFI_GRAPHICS_OUTPUT_MODE_INFORMATION *MatchedMode;
2619 UINTN NumberIndex;
2620 BOOLEAN Match;
2621 BOOLEAN AlreadyExist;
2622 UINT32 UgaHorizontalResolution;
2623 UINT32 UgaVerticalResolution;
2624 UINT32 UgaColorDepth;
2625 UINT32 UgaRefreshRate;
2626
2627 ASSERT (GraphicsOutput != NULL || UgaDraw != NULL);
2628
2629 CurrentGraphicsOutputMode = Private->GraphicsOutput.Mode;
2630
2631 Index = 0;
2632 CurrentIndex = 0;
2633 Status = EFI_SUCCESS;
2634
2635 if (Private->CurrentNumberOfUgaDraw != 0) {
2636 //
2637 // If any UGA device has already been added, then there is no need to
2638 // calculate intersection of display mode of different GOP/UGA device,
2639 // since only one display mode will be exported (i.e. user-defined mode)
2640 //
2641 goto Done;
2642 }
2643
2644 if (GraphicsOutput != NULL) {
2645 if (Private->CurrentNumberOfGraphicsOutput == 0) {
2646 //
2647 // This is the first Graphics Output device added
2648 //
2649 CurrentGraphicsOutputMode->MaxMode = GraphicsOutput->Mode->MaxMode;
2650 CurrentGraphicsOutputMode->Mode = GraphicsOutput->Mode->Mode;
2651 CopyMem (CurrentGraphicsOutputMode->Info, GraphicsOutput->Mode->Info, GraphicsOutput->Mode->SizeOfInfo);
2652 CurrentGraphicsOutputMode->SizeOfInfo = GraphicsOutput->Mode->SizeOfInfo;
2653 CurrentGraphicsOutputMode->FrameBufferBase = GraphicsOutput->Mode->FrameBufferBase;
2654 CurrentGraphicsOutputMode->FrameBufferSize = GraphicsOutput->Mode->FrameBufferSize;
2655
2656 //
2657 // Allocate resource for the private mode buffer
2658 //
2659 ModeBuffer = AllocatePool (sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION) * GraphicsOutput->Mode->MaxMode);
2660 if (ModeBuffer == NULL) {
2661 return EFI_OUT_OF_RESOURCES;
2662 }
2663 FreePool (Private->GraphicsOutputModeBuffer);
2664 Private->GraphicsOutputModeBuffer = ModeBuffer;
2665
2666 //
2667 // Store all supported display modes to the private mode buffer
2668 //
2669 Mode = ModeBuffer;
2670 for (Index = 0; Index < GraphicsOutput->Mode->MaxMode; Index++) {
2671 //
2672 // The Info buffer would be allocated by callee
2673 //
2674 Status = GraphicsOutput->QueryMode (GraphicsOutput, (UINT32) Index, &SizeOfInfo, &Info);
2675 if (EFI_ERROR (Status)) {
2676 return Status;
2677 }
2678 ASSERT ( SizeOfInfo <= sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION));
2679 CopyMem (Mode, Info, SizeOfInfo);
2680 Mode++;
2681 FreePool (Info);
2682 }
2683 } else {
2684 //
2685 // Check intersection of display mode
2686 //
2687 ModeBuffer = AllocatePool (sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION) * CurrentGraphicsOutputMode->MaxMode);
2688 if (ModeBuffer == NULL) {
2689 return EFI_OUT_OF_RESOURCES;
2690 }
2691
2692 MatchedMode = ModeBuffer;
2693 Mode = &Private->GraphicsOutputModeBuffer[0];
2694 for (Index = 0; Index < CurrentGraphicsOutputMode->MaxMode; Index++) {
2695 Match = FALSE;
2696
2697 for (NumberIndex = 0; NumberIndex < GraphicsOutput->Mode->MaxMode; NumberIndex++) {
2698 //
2699 // The Info buffer would be allocated by callee
2700 //
2701 Status = GraphicsOutput->QueryMode (GraphicsOutput, (UINT32) NumberIndex, &SizeOfInfo, &Info);
2702 if (EFI_ERROR (Status)) {
2703 return Status;
2704 }
2705 if ((Info->HorizontalResolution == Mode->HorizontalResolution) &&
2706 (Info->VerticalResolution == Mode->VerticalResolution)) {
2707 //
2708 // If GOP device supports one mode in current mode buffer,
2709 // it will be added into matched mode buffer
2710 //
2711 Match = TRUE;
2712 FreePool (Info);
2713 break;
2714 }
2715 FreePool (Info);
2716 }
2717
2718 if (Match) {
2719 AlreadyExist = FALSE;
2720
2721 //
2722 // Check if GOP mode has been in the mode buffer, ModeBuffer = MatchedMode at begin.
2723 //
2724 for (Info = ModeBuffer; Info < MatchedMode; Info++) {
2725 if ((Info->HorizontalResolution == Mode->HorizontalResolution) &&
2726 (Info->VerticalResolution == Mode->VerticalResolution)) {
2727 AlreadyExist = TRUE;
2728 break;
2729 }
2730 }
2731
2732 if (!AlreadyExist) {
2733 CopyMem (MatchedMode, Mode, sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION));
2734
2735 //
2736 // Physical frame buffer is no longer available, change PixelFormat to PixelBltOnly
2737 //
2738 MatchedMode->Version = 0;
2739 MatchedMode->PixelFormat = PixelBltOnly;
2740 ZeroMem (&MatchedMode->PixelInformation, sizeof (EFI_PIXEL_BITMASK));
2741
2742 MatchedMode++;
2743 }
2744 }
2745
2746 Mode++;
2747 }
2748
2749 //
2750 // Drop the old mode buffer, assign it to a new one
2751 //
2752 FreePool (Private->GraphicsOutputModeBuffer);
2753 Private->GraphicsOutputModeBuffer = ModeBuffer;
2754
2755 //
2756 // Physical frame buffer is no longer available when there are more than one physical GOP devices
2757 //
2758 CurrentGraphicsOutputMode->MaxMode = (UINT32) (((UINTN) MatchedMode - (UINTN) ModeBuffer) / sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION));
2759 CurrentGraphicsOutputMode->Info->PixelFormat = PixelBltOnly;
2760 ZeroMem (&CurrentGraphicsOutputMode->Info->PixelInformation, sizeof (EFI_PIXEL_BITMASK));
2761 CurrentGraphicsOutputMode->SizeOfInfo = sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION);
2762 CurrentGraphicsOutputMode->FrameBufferBase = (EFI_PHYSICAL_ADDRESS) (UINTN) NULL;
2763 CurrentGraphicsOutputMode->FrameBufferSize = 0;
2764 }
2765
2766 //
2767 // Graphics console driver can ensure the same mode for all GOP devices
2768 //
2769 for (Index = 0; Index < CurrentGraphicsOutputMode->MaxMode; Index++) {
2770 Mode = &Private->GraphicsOutputModeBuffer[Index];
2771 if ((Mode->HorizontalResolution == GraphicsOutput->Mode->Info->HorizontalResolution) &&
2772 (Mode->VerticalResolution == GraphicsOutput->Mode->Info->VerticalResolution)) {
2773 CurrentIndex = Index;
2774 break;
2775 }
2776 }
2777 if (Index >= CurrentGraphicsOutputMode->MaxMode) {
2778 //
2779 // if user defined mode is not found, set to default mode 800x600
2780 //
2781 for (Index = 0; Index < CurrentGraphicsOutputMode->MaxMode; Index++) {
2782 Mode = &Private->GraphicsOutputModeBuffer[Index];
2783 if ((Mode->HorizontalResolution == 800) && (Mode->VerticalResolution == 600)) {
2784 CurrentIndex = Index;
2785 break;
2786 }
2787 }
2788 }
2789 } else if (UgaDraw != NULL && FeaturePcdGet (PcdUgaConsumeSupport)) {
2790 //
2791 // Graphics console driver can ensure the same mode for all GOP devices
2792 // so we can get the current mode from this video device
2793 //
2794 UgaDraw->GetMode (
2795 UgaDraw,
2796 &UgaHorizontalResolution,
2797 &UgaVerticalResolution,
2798 &UgaColorDepth,
2799 &UgaRefreshRate
2800 );
2801
2802 CurrentGraphicsOutputMode->MaxMode = 1;
2803 Info = CurrentGraphicsOutputMode->Info;
2804 Info->Version = 0;
2805 Info->HorizontalResolution = UgaHorizontalResolution;
2806 Info->VerticalResolution = UgaVerticalResolution;
2807 Info->PixelFormat = PixelBltOnly;
2808 Info->PixelsPerScanLine = UgaHorizontalResolution;
2809 CurrentGraphicsOutputMode->SizeOfInfo = sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION);
2810 CurrentGraphicsOutputMode->FrameBufferBase = (EFI_PHYSICAL_ADDRESS) (UINTN) NULL;
2811 CurrentGraphicsOutputMode->FrameBufferSize = 0;
2812
2813 //
2814 // Update the private mode buffer
2815 //
2816 CopyMem (&Private->GraphicsOutputModeBuffer[0], Info, sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION));
2817
2818 //
2819 // Only mode 0 is available to be set
2820 //
2821 CurrentIndex = 0;
2822 }
2823
2824 Done:
2825
2826 if (GraphicsOutput != NULL) {
2827 Private->CurrentNumberOfGraphicsOutput++;
2828 }
2829 if (UgaDraw != NULL && FeaturePcdGet (PcdUgaConsumeSupport)) {
2830 Private->CurrentNumberOfUgaDraw++;
2831 }
2832
2833 //
2834 // Force GraphicsOutput mode to be set,
2835 // regardless whether the console is in EfiConsoleControlScreenGraphics or EfiConsoleControlScreenText mode
2836 //
2837 Private->HardwareNeedsStarting = TRUE;
2838
2839 Mode = &Private->GraphicsOutputModeBuffer[CurrentIndex];
2840 if ((GraphicsOutput != NULL) &&
2841 (Mode->HorizontalResolution == CurrentGraphicsOutputMode->Info->HorizontalResolution) &&
2842 (Mode->VerticalResolution == CurrentGraphicsOutputMode->Info->VerticalResolution)) {
2843 CurrentGraphicsOutputMode->Mode = (UINT32) CurrentIndex;
2844 if ((Mode->HorizontalResolution != GraphicsOutput->Mode->Info->HorizontalResolution) ||
2845 (Mode->VerticalResolution != GraphicsOutput->Mode->Info->VerticalResolution)) {
2846 //
2847 // If all existing video device has been set to common mode, only set new GOP device to
2848 // the common mode
2849 //
2850 for (NumberIndex = 0; NumberIndex < GraphicsOutput->Mode->MaxMode; NumberIndex ++) {
2851 Status = GraphicsOutput->QueryMode (GraphicsOutput, (UINT32) NumberIndex, &SizeOfInfo, &Info);
2852 if (EFI_ERROR (Status)) {
2853 return Status;
2854 }
2855 if ((Info->HorizontalResolution == Mode->HorizontalResolution) && (Info->VerticalResolution == Mode->VerticalResolution)) {
2856 FreePool (Info);
2857 break;
2858 }
2859 FreePool (Info);
2860 }
2861 Status = GraphicsOutput->SetMode (GraphicsOutput, (UINT32) NumberIndex);
2862 }
2863 } else {
2864 //
2865 // Current mode number may need update now, so set it to an invalid mode number
2866 //
2867 CurrentGraphicsOutputMode->Mode = 0xffff;
2868 //
2869 // Graphics console can ensure all GOP devices have the same mode which can be taken as current mode.
2870 //
2871 Status = Private->GraphicsOutput.SetMode (&Private->GraphicsOutput, (UINT32) CurrentIndex);
2872 if (EFI_ERROR(Status)) {
2873 //
2874 // If user defined mode is not valid for display device, set to the default mode 800x600.
2875 //
2876 (Private->GraphicsOutputModeBuffer[0]).HorizontalResolution = 800;
2877 (Private->GraphicsOutputModeBuffer[0]).VerticalResolution = 600;
2878 Status = Private->GraphicsOutput.SetMode (&Private->GraphicsOutput, 0);
2879 }
2880 }
2881
2882 return Status;
2883 }
2884
2885 /**
2886 Set the current console out mode.
2887
2888 This routine will get the current console mode information (column, row)
2889 from ConsoleOutMode variable and set it; if the variable does not exist,
2890 set to user defined console mode.
2891
2892 @param Private Consplitter Text Out pointer.
2893
2894 **/
2895 VOID
2896 ConsplitterSetConsoleOutMode (
2897 IN TEXT_OUT_SPLITTER_PRIVATE_DATA *Private
2898 )
2899 {
2900 UINTN Col;
2901 UINTN Row;
2902 UINTN Mode;
2903 UINTN PreferMode;
2904 UINTN BaseMode;
2905 UINTN MaxMode;
2906 EFI_STATUS Status;
2907 CONSOLE_OUT_MODE ModeInfo;
2908 EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *TextOut;
2909
2910 PreferMode = 0xFF;
2911 BaseMode = 0xFF;
2912 TextOut = &Private->TextOut;
2913 MaxMode = (UINTN) (TextOut->Mode->MaxMode);
2914
2915 ModeInfo.Column = PcdGet32 (PcdConOutColumn);
2916 ModeInfo.Row = PcdGet32 (PcdConOutRow);
2917
2918 //
2919 // To find the prefer mode and basic mode from Text Out mode list
2920 //
2921 for (Mode = 0; Mode < MaxMode; Mode++) {
2922 Status = TextOut->QueryMode (TextOut, Mode, &Col, &Row);
2923 if (!EFI_ERROR(Status)) {
2924 if (Col == ModeInfo.Column && Row == ModeInfo.Row) {
2925 PreferMode = Mode;
2926 }
2927 if (Col == 80 && Row == 25) {
2928 BaseMode = Mode;
2929 }
2930 }
2931 }
2932
2933 //
2934 // Set prefer mode to Text Out devices.
2935 //
2936 Status = TextOut->SetMode (TextOut, PreferMode);
2937 if (EFI_ERROR(Status)) {
2938 //
2939 // if current mode setting is failed, default 80x25 mode will be set.
2940 //
2941 Status = TextOut->SetMode (TextOut, BaseMode);
2942 ASSERT(!EFI_ERROR(Status));
2943
2944 PcdSet32 (PcdConOutColumn, 80);
2945 PcdSet32 (PcdConOutRow, 25);
2946 }
2947
2948 return ;
2949 }
2950
2951
2952 /**
2953 Add Text Output Device in Consplitter Text Output list.
2954
2955 @param Private Text Out Splitter pointer.
2956 @param TextOut Simple Text Output protocol pointer.
2957 @param GraphicsOutput Graphics Output protocol pointer.
2958 @param UgaDraw UGA Draw protocol pointer.
2959
2960 @retval EFI_SUCCESS Text Output Device added successfully.
2961 @retval EFI_OUT_OF_RESOURCES Could not grow the buffer size.
2962
2963 **/
2964 EFI_STATUS
2965 ConSplitterTextOutAddDevice (
2966 IN TEXT_OUT_SPLITTER_PRIVATE_DATA *Private,
2967 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *TextOut,
2968 IN EFI_GRAPHICS_OUTPUT_PROTOCOL *GraphicsOutput,
2969 IN EFI_UGA_DRAW_PROTOCOL *UgaDraw
2970 )
2971 {
2972 EFI_STATUS Status;
2973 UINTN CurrentNumOfConsoles;
2974 INT32 MaxMode;
2975 UINT32 UgaHorizontalResolution;
2976 UINT32 UgaVerticalResolution;
2977 UINT32 UgaColorDepth;
2978 UINT32 UgaRefreshRate;
2979 TEXT_OUT_AND_GOP_DATA *TextAndGop;
2980 UINTN SizeOfInfo;
2981 EFI_GRAPHICS_OUTPUT_MODE_INFORMATION *Info;
2982 EFI_STATUS DeviceStatus;
2983
2984 Status = EFI_SUCCESS;
2985 CurrentNumOfConsoles = Private->CurrentNumberOfConsoles;
2986
2987 //
2988 // If the Text Out List is full, enlarge it by calling ConSplitterGrowBuffer().
2989 //
2990 while (CurrentNumOfConsoles >= Private->TextOutListCount) {
2991 Status = ConSplitterGrowBuffer (
2992 sizeof (TEXT_OUT_AND_GOP_DATA),
2993 &Private->TextOutListCount,
2994 (VOID **) &Private->TextOutList
2995 );
2996 if (EFI_ERROR (Status)) {
2997 return EFI_OUT_OF_RESOURCES;
2998 }
2999 //
3000 // Also need to reallocate the TextOutModeMap table
3001 //
3002 Status = ConSplitterGrowMapTable (Private);
3003 if (EFI_ERROR (Status)) {
3004 return EFI_OUT_OF_RESOURCES;
3005 }
3006 }
3007
3008 TextAndGop = &Private->TextOutList[CurrentNumOfConsoles];
3009
3010 TextAndGop->TextOut = TextOut;
3011 TextAndGop->GraphicsOutput = GraphicsOutput;
3012 TextAndGop->UgaDraw = UgaDraw;
3013
3014 if (CurrentNumOfConsoles == 0) {
3015 //
3016 // Add the first device's output mode to console splitter's mode list
3017 //
3018 Status = ConSplitterAddOutputMode (Private, TextOut);
3019 } else {
3020 ConSplitterSyncOutputMode (Private, TextOut);
3021 }
3022
3023 Private->CurrentNumberOfConsoles++;
3024
3025 //
3026 // Scan both TextOutList, for the intersection TextOut device
3027 // maybe both ConOut and StdErr incorporate the same Text Out
3028 // device in them, thus the output of both should be synced.
3029 //
3030 ConSplitterGetIntersectionBetweenConOutAndStrErr ();
3031
3032 MaxMode = Private->TextOutMode.MaxMode;
3033 ASSERT (MaxMode >= 1);
3034
3035 DeviceStatus = EFI_DEVICE_ERROR;
3036 if (FeaturePcdGet (PcdConOutGopSupport)) {
3037 //
3038 // If GOP is produced by Consplitter, this device display mode will be added into Graphics Ouput modes.
3039 //
3040 if ((GraphicsOutput != NULL) || (UgaDraw != NULL && FeaturePcdGet (PcdUgaConsumeSupport))) {
3041 DeviceStatus = ConSplitterAddGraphicsOutputMode (Private, GraphicsOutput, UgaDraw);
3042 }
3043 }
3044
3045 if (FeaturePcdGet (PcdConOutUgaSupport)) {
3046
3047 Status = EFI_DEVICE_ERROR;
3048 //
3049 // If UGA is produced by Consplitter
3050 //
3051 if (GraphicsOutput != NULL) {
3052 Status = GraphicsOutput->QueryMode (GraphicsOutput, GraphicsOutput->Mode->Mode, &SizeOfInfo, &Info);
3053 if (EFI_ERROR (Status)) {
3054 return Status;
3055 }
3056 ASSERT ( SizeOfInfo <= sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION));
3057
3058 UgaHorizontalResolution = Info->HorizontalResolution;
3059 UgaVerticalResolution = Info->VerticalResolution;
3060
3061 FreePool (Info);
3062
3063 } else if (UgaDraw != NULL && FeaturePcdGet (PcdUgaConsumeSupport)) {
3064 Status = UgaDraw->GetMode (
3065 UgaDraw,
3066 &UgaHorizontalResolution,
3067 &UgaVerticalResolution,
3068 &UgaColorDepth,
3069 &UgaRefreshRate
3070 );
3071 if (!EFI_ERROR (Status) && EFI_ERROR (DeviceStatus)) {
3072 //
3073 // if GetMode is successfully and UGA device hasn't been set, set it
3074 //
3075 Status = ConSplitterUgaDrawSetMode (
3076 &Private->UgaDraw,
3077 UgaHorizontalResolution,
3078 UgaVerticalResolution,
3079 UgaColorDepth,
3080 UgaRefreshRate
3081 );
3082 }
3083 //
3084 // If GetMode/SetMode is failed, set to 800x600 mode
3085 //
3086 if(EFI_ERROR (Status)) {
3087 Status = ConSplitterUgaDrawSetMode (
3088 &Private->UgaDraw,
3089 800,
3090 600,
3091 32,
3092 60
3093 );
3094 }
3095 }
3096 }
3097
3098 //
3099 // After adding new console device, all existing console devices should be
3100 // synced to the current shared mode.
3101 //
3102 ConsplitterSetConsoleOutMode (Private);
3103
3104 return Status;
3105 }
3106
3107
3108 /**
3109 Remove Text Out Device in Consplitter Text Out list.
3110
3111 @param Private Text Out Splitter pointer.
3112 @param TextOut Simple Text Output Pointer protocol pointer.
3113
3114 @retval EFI_SUCCESS Text Out Device removed successfully.
3115 @retval EFI_NOT_FOUND No Text Out Device found.
3116
3117 **/
3118 EFI_STATUS
3119 ConSplitterTextOutDeleteDevice (
3120 IN TEXT_OUT_SPLITTER_PRIVATE_DATA *Private,
3121 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *TextOut
3122 )
3123 {
3124 INT32 Index;
3125 UINTN CurrentNumOfConsoles;
3126 TEXT_OUT_AND_GOP_DATA *TextOutList;
3127 EFI_STATUS Status;
3128
3129 //
3130 // Remove the specified text-out device data structure from the Text out List,
3131 // and rearrange the remaining data structures in the Text out List.
3132 //
3133 CurrentNumOfConsoles = Private->CurrentNumberOfConsoles;
3134 Index = (INT32) CurrentNumOfConsoles - 1;
3135 TextOutList = Private->TextOutList;
3136 while (Index >= 0) {
3137 if (TextOutList->TextOut == TextOut) {
3138 CopyMem (TextOutList, TextOutList + 1, sizeof (TEXT_OUT_AND_GOP_DATA) * Index);
3139 CurrentNumOfConsoles--;
3140 if (TextOutList->UgaDraw != NULL && FeaturePcdGet (PcdUgaConsumeSupport)) {
3141 Private->CurrentNumberOfUgaDraw--;
3142 }
3143 if (TextOutList->GraphicsOutput != NULL) {
3144 Private->CurrentNumberOfGraphicsOutput--;
3145 }
3146 break;
3147 }
3148
3149 Index--;
3150 TextOutList++;
3151 }
3152 //
3153 // The specified TextOut is not managed by the ConSplitter driver
3154 //
3155 if (Index < 0) {
3156 return EFI_NOT_FOUND;
3157 }
3158
3159 if (CurrentNumOfConsoles == 0) {
3160 //
3161 // If the number of consoles is zero, reset all parameters
3162 //
3163 Private->CurrentNumberOfConsoles = 0;
3164 Private->TextOutMode.MaxMode = 1;
3165 Private->TextOutQueryData[0].Columns = 80;
3166 Private->TextOutQueryData[0].Rows = 25;
3167 TextOutSetMode (Private, 0);
3168
3169 return EFI_SUCCESS;
3170 }
3171 //
3172 // Max Mode is realy an intersection of the QueryMode command to all
3173 // devices. So we must copy the QueryMode of the first device to
3174 // QueryData.
3175 //
3176 ZeroMem (
3177 Private->TextOutQueryData,
3178 Private->TextOutQueryDataCount * sizeof (TEXT_OUT_SPLITTER_QUERY_DATA)
3179 );
3180
3181 FreePool (Private->TextOutModeMap);
3182 Private->TextOutModeMap = NULL;
3183 TextOutList = Private->TextOutList;
3184
3185 //
3186 // Add the first TextOut to the QueryData array and ModeMap table
3187 //
3188 Status = ConSplitterAddOutputMode (Private, TextOutList->TextOut);
3189
3190 //
3191 // Now add one by one
3192 //
3193 Index = 1;
3194 Private->CurrentNumberOfConsoles = 1;
3195 TextOutList++;
3196 while ((UINTN) Index < CurrentNumOfConsoles) {
3197 ConSplitterSyncOutputMode (Private, TextOutList->TextOut);
3198 Index++;
3199 Private->CurrentNumberOfConsoles++;
3200 TextOutList++;
3201 }
3202
3203 ConSplitterGetIntersectionBetweenConOutAndStrErr ();
3204
3205 return Status;
3206 }
3207
3208
3209 /**
3210 Reset the input device and optionaly run diagnostics
3211
3212 @param This Protocol instance pointer.
3213 @param ExtendedVerification Driver may perform diagnostics on reset.
3214
3215 @retval EFI_SUCCESS The device was reset.
3216 @retval EFI_DEVICE_ERROR The device is not functioning properly and could
3217 not be reset.
3218
3219 **/
3220 EFI_STATUS
3221 EFIAPI
3222 ConSplitterTextInReset (
3223 IN EFI_SIMPLE_TEXT_INPUT_PROTOCOL *This,
3224 IN BOOLEAN ExtendedVerification
3225 )
3226 {
3227 EFI_STATUS Status;
3228 EFI_STATUS ReturnStatus;
3229 TEXT_IN_SPLITTER_PRIVATE_DATA *Private;
3230 UINTN Index;
3231
3232 Private = TEXT_IN_SPLITTER_PRIVATE_DATA_FROM_THIS (This);
3233
3234 Private->KeyEventSignalState = FALSE;
3235
3236 //
3237 // return the worst status met
3238 //
3239 for (Index = 0, ReturnStatus = EFI_SUCCESS; Index < Private->CurrentNumberOfConsoles; Index++) {
3240 Status = Private->TextInList[Index]->Reset (
3241 Private->TextInList[Index],
3242 ExtendedVerification
3243 );
3244 if (EFI_ERROR (Status)) {
3245 ReturnStatus = Status;
3246 }
3247 }
3248
3249 return ReturnStatus;
3250 }
3251
3252
3253 /**
3254 Reads the next keystroke from the input device. The WaitForKey Event can
3255 be used to test for existance of a keystroke via WaitForEvent () call.
3256
3257 @param Private Protocol instance pointer.
3258 @param Key Driver may perform diagnostics on reset.
3259
3260 @retval EFI_SUCCESS The keystroke information was returned.
3261 @retval EFI_NOT_READY There was no keystroke data availiable.
3262 @retval EFI_DEVICE_ERROR The keydtroke information was not returned due
3263 to hardware errors.
3264
3265 **/
3266 EFI_STATUS
3267 EFIAPI
3268 ConSplitterTextInPrivateReadKeyStroke (
3269 IN TEXT_IN_SPLITTER_PRIVATE_DATA *Private,
3270 OUT EFI_INPUT_KEY *Key
3271 )
3272 {
3273 EFI_STATUS Status;
3274 UINTN Index;
3275 EFI_INPUT_KEY CurrentKey;
3276
3277 Key->UnicodeChar = 0;
3278 Key->ScanCode = SCAN_NULL;
3279
3280 //
3281 // if no physical console input device exists, return EFI_NOT_READY;
3282 // if any physical console input device has key input,
3283 // return the key and EFI_SUCCESS.
3284 //
3285 for (Index = 0; Index < Private->CurrentNumberOfConsoles; Index++) {
3286 Status = Private->TextInList[Index]->ReadKeyStroke (
3287 Private->TextInList[Index],
3288 &CurrentKey
3289 );
3290 if (!EFI_ERROR (Status)) {
3291 *Key = CurrentKey;
3292 return Status;
3293 }
3294 }
3295
3296 return EFI_NOT_READY;
3297 }
3298
3299
3300 /**
3301 Reads the next keystroke from the input device. The WaitForKey Event can
3302 be used to test for existance of a keystroke via WaitForEvent () call.
3303
3304 @param This Protocol instance pointer.
3305 @param Key Driver may perform diagnostics on reset.
3306
3307 @retval EFI_SUCCESS The keystroke information was returned.
3308 @retval EFI_NOT_READY There was no keystroke data availiable.
3309 @retval EFI_DEVICE_ERROR The keydtroke information was not returned due
3310 to hardware errors.
3311
3312 **/
3313 EFI_STATUS
3314 EFIAPI
3315 ConSplitterTextInReadKeyStroke (
3316 IN EFI_SIMPLE_TEXT_INPUT_PROTOCOL *This,
3317 OUT EFI_INPUT_KEY *Key
3318 )
3319 {
3320 TEXT_IN_SPLITTER_PRIVATE_DATA *Private;
3321
3322 Private = TEXT_IN_SPLITTER_PRIVATE_DATA_FROM_THIS (This);
3323
3324 Private->KeyEventSignalState = FALSE;
3325
3326 return ConSplitterTextInPrivateReadKeyStroke (Private, Key);
3327 }
3328
3329
3330 /**
3331 This event aggregates all the events of the ConIn devices in the spliter.
3332
3333 If any events of physical ConIn devices are signaled, signal the ConIn
3334 spliter event. This will cause the calling code to call
3335 ConSplitterTextInReadKeyStroke ().
3336
3337 @param Event The Event assoicated with callback.
3338 @param Context Context registered when Event was created.
3339
3340 **/
3341 VOID
3342 EFIAPI
3343 ConSplitterTextInWaitForKey (
3344 IN EFI_EVENT Event,
3345 IN VOID *Context
3346 )
3347 {
3348 EFI_STATUS Status;
3349 TEXT_IN_SPLITTER_PRIVATE_DATA *Private;
3350 UINTN Index;
3351
3352 Private = (TEXT_IN_SPLITTER_PRIVATE_DATA *) Context;
3353
3354 if (Private->KeyEventSignalState) {
3355 //
3356 // If KeyEventSignalState is flagged before, and not cleared by Reset() or ReadKeyStroke()
3357 //
3358 gBS->SignalEvent (Event);
3359 return ;
3360 }
3361
3362 //
3363 // If any physical console input device has key input, signal the event.
3364 //
3365 for (Index = 0; Index < Private->CurrentNumberOfConsoles; Index++) {
3366 Status = gBS->CheckEvent (Private->TextInList[Index]->WaitForKey);
3367 if (!EFI_ERROR (Status)) {
3368 gBS->SignalEvent (Event);
3369 Private->KeyEventSignalState = TRUE;
3370 }
3371 }
3372 }
3373
3374
3375
3376 /**
3377 Test if the key has been registered on input device.
3378
3379 @param RegsiteredData A pointer to a buffer that is filled in with the
3380 keystroke state data for the key that was
3381 registered.
3382 @param InputData A pointer to a buffer that is filled in with the
3383 keystroke state data for the key that was
3384 pressed.
3385
3386 @retval TRUE Key be pressed matches a registered key.
3387 @retval FLASE Match failed.
3388
3389 **/
3390 BOOLEAN
3391 IsKeyRegistered (
3392 IN EFI_KEY_DATA *RegsiteredData,
3393 IN EFI_KEY_DATA *InputData
3394 )
3395 {
3396 ASSERT (RegsiteredData != NULL && InputData != NULL);
3397
3398 if ((RegsiteredData->Key.ScanCode != InputData->Key.ScanCode) ||
3399 (RegsiteredData->Key.UnicodeChar != InputData->Key.UnicodeChar)) {
3400 return FALSE;
3401 }
3402
3403 //
3404 // Assume KeyShiftState/KeyToggleState = 0 in Registered key data means these state could be ignored.
3405 //
3406 if (RegsiteredData->KeyState.KeyShiftState != 0 &&
3407 RegsiteredData->KeyState.KeyShiftState != InputData->KeyState.KeyShiftState) {
3408 return FALSE;
3409 }
3410 if (RegsiteredData->KeyState.KeyToggleState != 0 &&
3411 RegsiteredData->KeyState.KeyToggleState != InputData->KeyState.KeyToggleState) {
3412 return FALSE;
3413 }
3414
3415 return TRUE;
3416
3417 }
3418
3419
3420 /**
3421 Reset the input device and optionaly run diagnostics
3422
3423 @param This Protocol instance pointer.
3424 @param ExtendedVerification Driver may perform diagnostics on reset.
3425
3426 @retval EFI_SUCCESS The device was reset.
3427 @retval EFI_DEVICE_ERROR The device is not functioning properly and could
3428 not be reset.
3429
3430 **/
3431 EFI_STATUS
3432 EFIAPI
3433 ConSplitterTextInResetEx (
3434 IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *This,
3435 IN BOOLEAN ExtendedVerification
3436 )
3437 {
3438 EFI_STATUS Status;
3439 EFI_STATUS ReturnStatus;
3440 TEXT_IN_SPLITTER_PRIVATE_DATA *Private;
3441 UINTN Index;
3442
3443 Private = TEXT_IN_EX_SPLITTER_PRIVATE_DATA_FROM_THIS (This);
3444
3445 Private->KeyEventSignalState = FALSE;
3446
3447 //
3448 // return the worst status met
3449 //
3450 for (Index = 0, ReturnStatus = EFI_SUCCESS; Index < Private->CurrentNumberOfExConsoles; Index++) {
3451 Status = Private->TextInExList[Index]->Reset (
3452 Private->TextInExList[Index],
3453 ExtendedVerification
3454 );
3455 if (EFI_ERROR (Status)) {
3456 ReturnStatus = Status;
3457 }
3458 }
3459
3460 return ReturnStatus;
3461
3462 }
3463
3464
3465 /**
3466 Reads the next keystroke from the input device. The WaitForKey Event can
3467 be used to test for existance of a keystroke via WaitForEvent () call.
3468
3469 @param This Protocol instance pointer.
3470 @param KeyData A pointer to a buffer that is filled in with the
3471 keystroke state data for the key that was
3472 pressed.
3473
3474 @retval EFI_SUCCESS The keystroke information was returned.
3475 @retval EFI_NOT_READY There was no keystroke data availiable.
3476 @retval EFI_DEVICE_ERROR The keystroke information was not returned due
3477 to hardware errors.
3478 @retval EFI_INVALID_PARAMETER KeyData is NULL.
3479
3480 **/
3481 EFI_STATUS
3482 EFIAPI
3483 ConSplitterTextInReadKeyStrokeEx (
3484 IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *This,
3485 OUT EFI_KEY_DATA *KeyData
3486 )
3487 {
3488 TEXT_IN_SPLITTER_PRIVATE_DATA *Private;
3489 EFI_STATUS Status;
3490 UINTN Index;
3491 EFI_KEY_DATA CurrentKeyData;
3492
3493
3494 if (KeyData == NULL) {
3495 return EFI_INVALID_PARAMETER;
3496 }
3497
3498 Private = TEXT_IN_EX_SPLITTER_PRIVATE_DATA_FROM_THIS (This);
3499
3500 Private->KeyEventSignalState = FALSE;
3501
3502 KeyData->Key.UnicodeChar = 0;
3503 KeyData->Key.ScanCode = SCAN_NULL;
3504
3505 //
3506 // if no physical console input device exists, return EFI_NOT_READY;
3507 // if any physical console input device has key input,
3508 // return the key and EFI_SUCCESS.
3509 //
3510 for (Index = 0; Index < Private->CurrentNumberOfExConsoles; Index++) {
3511 Status = Private->TextInExList[Index]->ReadKeyStrokeEx (
3512 Private->TextInExList[Index],
3513 &CurrentKeyData
3514 );
3515 if (!EFI_ERROR (Status)) {
3516 CopyMem (KeyData, &CurrentKeyData, sizeof (CurrentKeyData));
3517 return Status;
3518 }
3519 }
3520
3521 return EFI_NOT_READY;
3522 }
3523
3524
3525 /**
3526 Set certain state for the input device.
3527
3528 @param This Protocol instance pointer.
3529 @param KeyToggleState A pointer to the EFI_KEY_TOGGLE_STATE to set the
3530 state for the input device.
3531
3532 @retval EFI_SUCCESS The device state was set successfully.
3533 @retval EFI_DEVICE_ERROR The device is not functioning correctly and
3534 could not have the setting adjusted.
3535 @retval EFI_UNSUPPORTED The device does not have the ability to set its
3536 state.
3537 @retval EFI_INVALID_PARAMETER KeyToggleState is NULL.
3538
3539 **/
3540 EFI_STATUS
3541 EFIAPI
3542 ConSplitterTextInSetState (
3543 IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *This,
3544 IN EFI_KEY_TOGGLE_STATE *KeyToggleState
3545 )
3546 {
3547 TEXT_IN_SPLITTER_PRIVATE_DATA *Private;
3548 EFI_STATUS Status;
3549 UINTN Index;
3550
3551 if (KeyToggleState == NULL) {
3552 return EFI_INVALID_PARAMETER;
3553 }
3554
3555 Private = TEXT_IN_EX_SPLITTER_PRIVATE_DATA_FROM_THIS (This);
3556
3557 //
3558 // if no physical console input device exists, return EFI_SUCCESS;
3559 // otherwise return the status of setting state of physical console input device
3560 //
3561 for (Index = 0; Index < Private->CurrentNumberOfExConsoles; Index++) {
3562 Status = Private->TextInExList[Index]->SetState (
3563 Private->TextInExList[Index],
3564 KeyToggleState
3565 );
3566 if (EFI_ERROR (Status)) {
3567 return Status;
3568 }
3569 }
3570
3571 return EFI_SUCCESS;
3572
3573 }
3574
3575
3576 /**
3577 Register a notification function for a particular keystroke for the input device.
3578
3579 @param This Protocol instance pointer.
3580 @param KeyData A pointer to a buffer that is filled in with the
3581 keystroke information data for the key that was
3582 pressed.
3583 @param KeyNotificationFunction Points to the function to be called when the key
3584 sequence is typed specified by KeyData.
3585 @param NotifyHandle Points to the unique handle assigned to the
3586 registered notification.
3587
3588 @retval EFI_SUCCESS The notification function was registered
3589 successfully.
3590 @retval EFI_OUT_OF_RESOURCES Unable to allocate resources for necesssary data
3591 structures.
3592 @retval EFI_INVALID_PARAMETER KeyData or KeyNotificationFunction or NotifyHandle is NULL.
3593
3594 **/
3595 EFI_STATUS
3596 EFIAPI
3597 ConSplitterTextInRegisterKeyNotify (
3598 IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *This,
3599 IN EFI_KEY_DATA *KeyData,
3600 IN EFI_KEY_NOTIFY_FUNCTION KeyNotificationFunction,
3601 OUT EFI_HANDLE *NotifyHandle
3602 )
3603 {
3604 TEXT_IN_SPLITTER_PRIVATE_DATA *Private;
3605 EFI_STATUS Status;
3606 UINTN Index;
3607 TEXT_IN_EX_SPLITTER_NOTIFY *NewNotify;
3608 LIST_ENTRY *Link;
3609 TEXT_IN_EX_SPLITTER_NOTIFY *CurrentNotify;
3610
3611
3612 if (KeyData == NULL || NotifyHandle == NULL || KeyNotificationFunction == NULL) {
3613 return EFI_INVALID_PARAMETER;
3614 }
3615
3616 Private = TEXT_IN_EX_SPLITTER_PRIVATE_DATA_FROM_THIS (This);
3617
3618 //
3619 // If no physical console input device exists,
3620 // return EFI_SUCCESS directly.
3621 //
3622 if (Private->CurrentNumberOfExConsoles <= 0) {
3623 return EFI_SUCCESS;
3624 }
3625
3626 //
3627 // Return EFI_SUCCESS if the (KeyData, NotificationFunction) is already registered.
3628 //
3629 for (Link = Private->NotifyList.ForwardLink; Link != &Private->NotifyList; Link = Link->ForwardLink) {
3630 CurrentNotify = TEXT_IN_EX_SPLITTER_NOTIFY_FROM_THIS (Link);
3631 if (IsKeyRegistered (&CurrentNotify->KeyData, KeyData)) {
3632 if (CurrentNotify->KeyNotificationFn == KeyNotificationFunction) {
3633 *NotifyHandle = CurrentNotify->NotifyHandle;
3634 return EFI_SUCCESS;
3635 }
3636 }
3637 }
3638
3639 //
3640 // Allocate resource to save the notification function
3641 //
3642 NewNotify = (TEXT_IN_EX_SPLITTER_NOTIFY *) AllocateZeroPool (sizeof (TEXT_IN_EX_SPLITTER_NOTIFY));
3643 if (NewNotify == NULL) {
3644 return EFI_OUT_OF_RESOURCES;
3645 }
3646 NewNotify->NotifyHandleList = (EFI_HANDLE *) AllocateZeroPool (sizeof (EFI_HANDLE) * Private->CurrentNumberOfExConsoles);
3647 if (NewNotify->NotifyHandleList == NULL) {
3648 gBS->FreePool (NewNotify);
3649 return EFI_OUT_OF_RESOURCES;
3650 }
3651 NewNotify->Signature = TEXT_IN_EX_SPLITTER_NOTIFY_SIGNATURE;
3652 NewNotify->KeyNotificationFn = KeyNotificationFunction;
3653 NewNotify->NotifyHandle = (EFI_HANDLE) NewNotify;
3654 CopyMem (&NewNotify->KeyData, KeyData, sizeof (KeyData));
3655
3656 //
3657 // Return the wrong status of registering key notify of
3658 // physical console input device if meet problems
3659 //
3660 for (Index = 0; Index < Private->CurrentNumberOfExConsoles; Index++) {
3661 Status = Private->TextInExList[Index]->RegisterKeyNotify (
3662 Private->TextInExList[Index],
3663 KeyData,
3664 KeyNotificationFunction,
3665 &NewNotify->NotifyHandleList[Index]
3666 );
3667 if (EFI_ERROR (Status)) {
3668 gBS->FreePool (NewNotify->NotifyHandleList);
3669 gBS->FreePool (NewNotify);
3670 return Status;
3671 }
3672 }
3673
3674 InsertTailList (&mConIn.NotifyList, &NewNotify->NotifyEntry);
3675
3676 *NotifyHandle = NewNotify->NotifyHandle;
3677
3678 return EFI_SUCCESS;
3679
3680 }
3681
3682
3683 /**
3684 Remove a registered notification function from a particular keystroke.
3685
3686 @param This Protocol instance pointer.
3687 @param NotificationHandle The handle of the notification function being
3688 unregistered.
3689
3690 @retval EFI_SUCCESS The notification function was unregistered
3691 successfully.
3692 @retval EFI_INVALID_PARAMETER The NotificationHandle is invalid.
3693
3694 **/
3695 EFI_STATUS
3696 EFIAPI
3697 ConSplitterTextInUnregisterKeyNotify (
3698 IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *This,
3699 IN EFI_HANDLE NotificationHandle
3700 )
3701 {
3702 TEXT_IN_SPLITTER_PRIVATE_DATA *Private;
3703 EFI_STATUS Status;
3704 UINTN Index;
3705 TEXT_IN_EX_SPLITTER_NOTIFY *CurrentNotify;
3706 LIST_ENTRY *Link;
3707
3708 if (NotificationHandle == NULL) {
3709 return EFI_INVALID_PARAMETER;
3710 }
3711
3712 if (((TEXT_IN_EX_SPLITTER_NOTIFY *) NotificationHandle)->Signature != TEXT_IN_EX_SPLITTER_NOTIFY_SIGNATURE) {
3713 return EFI_INVALID_PARAMETER;
3714 }
3715
3716 Private = TEXT_IN_EX_SPLITTER_PRIVATE_DATA_FROM_THIS (This);
3717
3718 //
3719 // if no physical console input device exists,
3720 // return EFI_SUCCESS directly.
3721 //
3722 if (Private->CurrentNumberOfExConsoles <= 0) {
3723 return EFI_SUCCESS;
3724 }
3725
3726 for (Link = Private->NotifyList.ForwardLink; Link != &Private->NotifyList; Link = Link->ForwardLink) {
3727 CurrentNotify = TEXT_IN_EX_SPLITTER_NOTIFY_FROM_THIS (Link);
3728 if (CurrentNotify->NotifyHandle == NotificationHandle) {
3729 for (Index = 0; Index < Private->CurrentNumberOfExConsoles; Index++) {
3730 Status = Private->TextInExList[Index]->UnregisterKeyNotify (
3731 Private->TextInExList[Index],
3732 CurrentNotify->NotifyHandleList[Index]
3733 );
3734 if (EFI_ERROR (Status)) {
3735 return Status;
3736 }
3737 }
3738 RemoveEntryList (&CurrentNotify->NotifyEntry);
3739
3740 gBS->FreePool (CurrentNotify->NotifyHandleList);
3741 gBS->FreePool (CurrentNotify);
3742 return EFI_SUCCESS;
3743 }
3744 }
3745
3746 //
3747 // NotificationHandle is not found in database
3748 //
3749 return EFI_INVALID_PARAMETER;
3750 }
3751
3752
3753 /**
3754 Reset the input device and optionaly run diagnostics
3755
3756 @param This Protocol instance pointer.
3757 @param ExtendedVerification Driver may perform diagnostics on reset.
3758
3759 @retval EFI_SUCCESS The device was reset.
3760 @retval EFI_DEVICE_ERROR The device is not functioning properly and could
3761 not be reset.
3762
3763 **/
3764 EFI_STATUS
3765 EFIAPI
3766 ConSplitterSimplePointerReset (
3767 IN EFI_SIMPLE_POINTER_PROTOCOL *This,
3768 IN BOOLEAN ExtendedVerification
3769 )
3770 {
3771 EFI_STATUS Status;
3772 EFI_STATUS ReturnStatus;
3773 TEXT_IN_SPLITTER_PRIVATE_DATA *Private;
3774 UINTN Index;
3775
3776 Private = TEXT_IN_SPLITTER_PRIVATE_DATA_FROM_SIMPLE_POINTER_THIS (This);
3777
3778 Private->InputEventSignalState = FALSE;
3779
3780 if (Private->CurrentNumberOfPointers == 0) {
3781 return EFI_SUCCESS;
3782 }
3783 //
3784 // return the worst status met
3785 //
3786 for (Index = 0, ReturnStatus = EFI_SUCCESS; Index < Private->CurrentNumberOfPointers; Index++) {
3787 Status = Private->PointerList[Index]->Reset (
3788 Private->PointerList[Index],
3789 ExtendedVerification
3790 );
3791 if (EFI_ERROR (Status)) {
3792 ReturnStatus = Status;
3793 }
3794 }
3795
3796 return ReturnStatus;
3797 }
3798
3799
3800 /**
3801 Reads the next keystroke from the input device. The WaitForKey Event can
3802 be used to test for existance of a keystroke via WaitForEvent () call.
3803
3804 @param Private Protocol instance pointer.
3805 @param State The state information of simple pointer device.
3806
3807 @retval EFI_SUCCESS The keystroke information was returned.
3808 @retval EFI_NOT_READY There was no keystroke data availiable.
3809 @retval EFI_DEVICE_ERROR The keydtroke information was not returned due
3810 to hardware errors.
3811
3812 **/
3813 EFI_STATUS
3814 EFIAPI
3815 ConSplitterSimplePointerPrivateGetState (
3816 IN TEXT_IN_SPLITTER_PRIVATE_DATA *Private,
3817 IN OUT EFI_SIMPLE_POINTER_STATE *State
3818 )
3819 {
3820 EFI_STATUS Status;
3821 EFI_STATUS ReturnStatus;
3822 UINTN Index;
3823 EFI_SIMPLE_POINTER_STATE CurrentState;
3824
3825 State->RelativeMovementX = 0;
3826 State->RelativeMovementY = 0;
3827 State->RelativeMovementZ = 0;
3828 State->LeftButton = FALSE;
3829 State->RightButton = FALSE;
3830
3831 //
3832 // if no physical console input device exists, return EFI_NOT_READY;
3833 // if any physical console input device has key input,
3834 // return the key and EFI_SUCCESS.
3835 //
3836 ReturnStatus = EFI_NOT_READY;
3837 for (Index = 0; Index < Private->CurrentNumberOfPointers; Index++) {
3838
3839 Status = Private->PointerList[Index]->GetState (
3840 Private->PointerList[Index],
3841 &CurrentState
3842 );
3843 if (!EFI_ERROR (Status)) {
3844 if (ReturnStatus == EFI_NOT_READY) {
3845 ReturnStatus = EFI_SUCCESS;
3846 }
3847
3848 if (CurrentState.LeftButton) {
3849 State->LeftButton = TRUE;
3850 }
3851
3852 if (CurrentState.RightButton) {
3853 State->RightButton = TRUE;
3854 }
3855
3856 if (CurrentState.RelativeMovementX != 0 && Private->PointerList[Index]->Mode->ResolutionX != 0) {
3857 State->RelativeMovementX += (CurrentState.RelativeMovementX * (INT32) Private->SimplePointerMode.ResolutionX) / (INT32) Private->PointerList[Index]->Mode->ResolutionX;
3858 }
3859
3860 if (CurrentState.RelativeMovementY != 0 && Private->PointerList[Index]->Mode->ResolutionY != 0) {
3861 State->RelativeMovementY += (CurrentState.RelativeMovementY * (INT32) Private->SimplePointerMode.ResolutionY) / (INT32) Private->PointerList[Index]->Mode->ResolutionY;
3862 }
3863
3864 if (CurrentState.RelativeMovementZ != 0 && Private->PointerList[Index]->Mode->ResolutionZ != 0) {
3865 State->RelativeMovementZ += (CurrentState.RelativeMovementZ * (INT32) Private->SimplePointerMode.ResolutionZ) / (INT32) Private->PointerList[Index]->Mode->ResolutionZ;
3866 }
3867 } else if (Status == EFI_DEVICE_ERROR) {
3868 ReturnStatus = EFI_DEVICE_ERROR;
3869 }
3870 }
3871
3872 return ReturnStatus;
3873 }
3874
3875
3876 /**
3877 Reads the next keystroke from the input device. The WaitForKey Event can
3878 be used to test for existance of a keystroke via WaitForEvent () call.
3879
3880 @param This A pointer to protocol instance.
3881 @param State A pointer to state information on the pointer device
3882
3883 @retval EFI_SUCCESS The keystroke information was returned in State.
3884 @retval EFI_NOT_READY There was no keystroke data availiable.
3885 @retval EFI_DEVICE_ERROR The keydtroke information was not returned due
3886 to hardware errors.
3887
3888 **/
3889 EFI_STATUS
3890 EFIAPI
3891 ConSplitterSimplePointerGetState (
3892 IN EFI_SIMPLE_POINTER_PROTOCOL *This,
3893 IN OUT EFI_SIMPLE_POINTER_STATE *State
3894 )
3895 {
3896 TEXT_IN_SPLITTER_PRIVATE_DATA *Private;
3897
3898 Private = TEXT_IN_SPLITTER_PRIVATE_DATA_FROM_SIMPLE_POINTER_THIS (This);
3899
3900 Private->InputEventSignalState = FALSE;
3901
3902 return ConSplitterSimplePointerPrivateGetState (Private, State);
3903 }
3904
3905
3906 /**
3907 This event agregates all the events of the ConIn devices in the spliter.
3908 If any events of physical ConIn devices are signaled, signal the ConIn
3909 spliter event. This will cause the calling code to call
3910 ConSplitterTextInReadKeyStroke ().
3911
3912 @param Event The Event assoicated with callback.
3913 @param Context Context registered when Event was created.
3914
3915 **/
3916 VOID
3917 EFIAPI
3918 ConSplitterSimplePointerWaitForInput (
3919 IN EFI_EVENT Event,
3920 IN VOID *Context
3921 )
3922 {
3923 EFI_STATUS Status;
3924 TEXT_IN_SPLITTER_PRIVATE_DATA *Private;
3925 UINTN Index;
3926
3927 Private = (TEXT_IN_SPLITTER_PRIVATE_DATA *) Context;
3928
3929 //
3930 // if InputEventSignalState is flagged before, and not cleared by Reset() or ReadKeyStroke()
3931 //
3932 if (Private->InputEventSignalState) {
3933 gBS->SignalEvent (Event);
3934 return ;
3935 }
3936 //
3937 // if any physical console input device has key input, signal the event.
3938 //
3939 for (Index = 0; Index < Private->CurrentNumberOfPointers; Index++) {
3940 Status = gBS->CheckEvent (Private->PointerList[Index]->WaitForInput);
3941 if (!EFI_ERROR (Status)) {
3942 gBS->SignalEvent (Event);
3943 Private->InputEventSignalState = TRUE;
3944 }
3945 }
3946 }
3947
3948 /**
3949 Resets the pointer device hardware.
3950
3951 @param This Protocol instance pointer.
3952 @param ExtendedVerification Driver may perform diagnostics on reset.
3953
3954 @retval EFI_SUCCESS The device was reset.
3955 @retval EFI_DEVICE_ERROR The device is not functioning correctly and
3956 could not be reset.
3957
3958 **/
3959 EFI_STATUS
3960 EFIAPI
3961 ConSplitterAbsolutePointerReset (
3962 IN EFI_ABSOLUTE_POINTER_PROTOCOL *This,
3963 IN BOOLEAN ExtendedVerification
3964 )
3965 {
3966 EFI_STATUS Status;
3967 EFI_STATUS ReturnStatus;
3968 TEXT_IN_SPLITTER_PRIVATE_DATA *Private;
3969 UINTN Index;
3970
3971 Private = TEXT_IN_SPLITTER_PRIVATE_DATA_FROM_ABSOLUTE_POINTER_THIS (This);
3972
3973 Private->AbsoluteInputEventSignalState = FALSE;
3974
3975 if (Private->CurrentNumberOfAbsolutePointers == 0) {
3976 return EFI_SUCCESS;
3977 }
3978 //
3979 // return the worst status met
3980 //
3981 for (Index = 0, ReturnStatus = EFI_SUCCESS; Index < Private->CurrentNumberOfAbsolutePointers; Index++) {
3982 Status = Private->AbsolutePointerList[Index]->Reset (
3983 Private->AbsolutePointerList[Index],
3984 ExtendedVerification
3985 );
3986 if (EFI_ERROR (Status)) {
3987 ReturnStatus = Status;
3988 }
3989 }
3990
3991 return ReturnStatus;
3992 }
3993
3994
3995 /**
3996 Retrieves the current state of a pointer device.
3997
3998 @param This Protocol instance pointer.
3999 @param State A pointer to the state information on the
4000 pointer device.
4001
4002 @retval EFI_SUCCESS The state of the pointer device was returned in
4003 State..
4004 @retval EFI_NOT_READY The state of the pointer device has not changed
4005 since the last call to GetState().
4006 @retval EFI_DEVICE_ERROR A device error occurred while attempting to
4007 retrieve the pointer device's current state.
4008
4009 **/
4010 EFI_STATUS
4011 EFIAPI
4012 ConSplitterAbsolutePointerGetState (
4013 IN EFI_ABSOLUTE_POINTER_PROTOCOL *This,
4014 IN OUT EFI_ABSOLUTE_POINTER_STATE *State
4015 )
4016 {
4017 TEXT_IN_SPLITTER_PRIVATE_DATA *Private;
4018 EFI_STATUS Status;
4019 EFI_STATUS ReturnStatus;
4020 UINTN Index;
4021 EFI_ABSOLUTE_POINTER_STATE CurrentState;
4022
4023
4024 Private = TEXT_IN_SPLITTER_PRIVATE_DATA_FROM_ABSOLUTE_POINTER_THIS (This);
4025
4026 Private->AbsoluteInputEventSignalState = FALSE;
4027
4028 State->CurrentX = 0;
4029 State->CurrentY = 0;
4030 State->CurrentZ = 0;
4031 State->ActiveButtons = 0;
4032
4033 //
4034 // if no physical pointer device exists, return EFI_NOT_READY;
4035 // if any physical pointer device has changed state,
4036 // return the state and EFI_SUCCESS.
4037 //
4038 ReturnStatus = EFI_NOT_READY;
4039 for (Index = 0; Index < Private->CurrentNumberOfAbsolutePointers; Index++) {
4040
4041 Status = Private->AbsolutePointerList[Index]->GetState (
4042 Private->AbsolutePointerList[Index],
4043 &CurrentState
4044 );
4045 if (!EFI_ERROR (Status)) {
4046 if (ReturnStatus == EFI_NOT_READY) {
4047 ReturnStatus = EFI_SUCCESS;
4048 }
4049
4050 State->ActiveButtons = CurrentState.ActiveButtons;
4051
4052 if (!(Private->AbsolutePointerMode.AbsoluteMinX == 0 && Private->AbsolutePointerMode.AbsoluteMaxX == 0)) {
4053 State->CurrentX = CurrentState.CurrentX;
4054 }
4055 if (!(Private->AbsolutePointerMode.AbsoluteMinY == 0 && Private->AbsolutePointerMode.AbsoluteMaxY == 0)) {
4056 State->CurrentY = CurrentState.CurrentY;
4057 }
4058 if (!(Private->AbsolutePointerMode.AbsoluteMinZ == 0 && Private->AbsolutePointerMode.AbsoluteMaxZ == 0)) {
4059 State->CurrentZ = CurrentState.CurrentZ;
4060 }
4061
4062 } else if (Status == EFI_DEVICE_ERROR) {
4063 ReturnStatus = EFI_DEVICE_ERROR;
4064 }
4065 }
4066
4067 return ReturnStatus;
4068 }
4069
4070
4071 /**
4072 This event agregates all the events of the pointer devices in the splitter.
4073 If any events of physical pointer devices are signaled, signal the pointer
4074 splitter event. This will cause the calling code to call
4075 ConSplitterAbsolutePointerGetState ().
4076
4077 @param Event The Event assoicated with callback.
4078 @param Context Context registered when Event was created.
4079
4080 **/
4081 VOID
4082 EFIAPI
4083 ConSplitterAbsolutePointerWaitForInput (
4084 IN EFI_EVENT Event,
4085 IN VOID *Context
4086 )
4087 {
4088 EFI_STATUS Status;
4089 TEXT_IN_SPLITTER_PRIVATE_DATA *Private;
4090 UINTN Index;
4091
4092 Private = (TEXT_IN_SPLITTER_PRIVATE_DATA *) Context;
4093
4094 //
4095 // if AbsoluteInputEventSignalState is flagged before,
4096 // and not cleared by Reset() or GetState(), signal it
4097 //
4098 if (Private->AbsoluteInputEventSignalState) {
4099 gBS->SignalEvent (Event);
4100 return ;
4101 }
4102 //
4103 // if any physical console input device has key input, signal the event.
4104 //
4105 for (Index = 0; Index < Private->CurrentNumberOfAbsolutePointers; Index++) {
4106 Status = gBS->CheckEvent (Private->AbsolutePointerList[Index]->WaitForInput);
4107 if (!EFI_ERROR (Status)) {
4108 gBS->SignalEvent (Event);
4109 Private->AbsoluteInputEventSignalState = TRUE;
4110 }
4111 }
4112 }
4113
4114
4115 /**
4116 Reset the text output device hardware and optionaly run diagnostics
4117
4118 @param This Protocol instance pointer.
4119 @param ExtendedVerification Driver may perform more exhaustive verfication
4120 operation of the device during reset.
4121
4122 @retval EFI_SUCCESS The text output device was reset.
4123 @retval EFI_DEVICE_ERROR The text output device is not functioning
4124 correctly and could not be reset.
4125
4126 **/
4127 EFI_STATUS
4128 EFIAPI
4129 ConSplitterTextOutReset (
4130 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,
4131 IN BOOLEAN ExtendedVerification
4132 )
4133 {
4134 EFI_STATUS Status;
4135 TEXT_OUT_SPLITTER_PRIVATE_DATA *Private;
4136 UINTN Index;
4137 EFI_STATUS ReturnStatus;
4138
4139 Private = TEXT_OUT_SPLITTER_PRIVATE_DATA_FROM_THIS (This);
4140
4141 //
4142 // return the worst status met
4143 //
4144 for (Index = 0, ReturnStatus = EFI_SUCCESS; Index < Private->CurrentNumberOfConsoles; Index++) {
4145 Status = Private->TextOutList[Index].TextOut->Reset (
4146 Private->TextOutList[Index].TextOut,
4147 ExtendedVerification
4148 );
4149 if (EFI_ERROR (Status)) {
4150 ReturnStatus = Status;
4151 }
4152 }
4153
4154 This->SetAttribute (This, EFI_TEXT_ATTR (This->Mode->Attribute & 0x0F, EFI_BLACK));
4155
4156 //
4157 // reset all mode parameters
4158 //
4159 TextOutSetMode (Private, 0);
4160
4161 return ReturnStatus;
4162 }
4163
4164
4165 /**
4166 Write a Unicode string to the output device.
4167
4168 @param This Protocol instance pointer.
4169 @param WString The NULL-terminated Unicode string to be
4170 displayed on the output device(s). All output
4171 devices must also support the Unicode drawing
4172 defined in this file.
4173
4174 @retval EFI_SUCCESS The string was output to the device.
4175 @retval EFI_DEVICE_ERROR The device reported an error while attempting to
4176 output the text.
4177 @retval EFI_UNSUPPORTED The output device's mode is not currently in a
4178 defined text mode.
4179 @retval EFI_WARN_UNKNOWN_GLYPH This warning code indicates that some of the
4180 characters in the Unicode string could not be
4181 rendered and were skipped.
4182
4183 **/
4184 EFI_STATUS
4185 EFIAPI
4186 ConSplitterTextOutOutputString (
4187 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,
4188 IN CHAR16 *WString
4189 )
4190 {
4191 EFI_STATUS Status;
4192 TEXT_OUT_SPLITTER_PRIVATE_DATA *Private;
4193 UINTN Index;
4194 UINTN BackSpaceCount;
4195 EFI_STATUS ReturnStatus;
4196 CHAR16 *TargetString;
4197
4198 This->SetAttribute (This, This->Mode->Attribute);
4199
4200 Private = TEXT_OUT_SPLITTER_PRIVATE_DATA_FROM_THIS (This);
4201
4202 BackSpaceCount = 0;
4203
4204 for (TargetString = WString; *TargetString != L'\0'; TargetString++) {
4205 if (*TargetString == CHAR_BACKSPACE) {
4206 BackSpaceCount++;
4207 }
4208 }
4209
4210 if (BackSpaceCount == 0) {
4211 TargetString = WString;
4212 } else {
4213 TargetString = AllocatePool (sizeof (CHAR16) * (StrLen (WString) + BackSpaceCount + 1));
4214 ASSERT (TargetString != NULL);
4215
4216 StrCpy (TargetString, WString);
4217 }
4218 //
4219 // return the worst status met
4220 //
4221 for (Index = 0, ReturnStatus = EFI_SUCCESS; Index < Private->CurrentNumberOfConsoles; Index++) {
4222 Status = Private->TextOutList[Index].TextOut->OutputString (
4223 Private->TextOutList[Index].TextOut,
4224 TargetString
4225 );
4226 if (EFI_ERROR (Status)) {
4227 ReturnStatus = Status;
4228 }
4229 }
4230
4231 if (Private->CurrentNumberOfConsoles > 0) {
4232 Private->TextOutMode.CursorColumn = Private->TextOutList[0].TextOut->Mode->CursorColumn;
4233 Private->TextOutMode.CursorRow = Private->TextOutList[0].TextOut->Mode->CursorRow;
4234 }
4235
4236 if (BackSpaceCount > 0) {
4237 FreePool (TargetString);
4238 }
4239
4240 return ReturnStatus;
4241 }
4242
4243
4244 /**
4245 Verifies that all characters in a Unicode string can be output to the
4246 target device.
4247
4248 @param This Protocol instance pointer.
4249 @param WString The NULL-terminated Unicode string to be
4250 examined for the output device(s).
4251
4252 @retval EFI_SUCCESS The device(s) are capable of rendering the
4253 output string.
4254 @retval EFI_UNSUPPORTED Some of the characters in the Unicode string
4255 cannot be rendered by one or more of the output
4256 devices mapped by the EFI handle.
4257
4258 **/
4259 EFI_STATUS
4260 EFIAPI
4261 ConSplitterTextOutTestString (
4262 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,
4263 IN CHAR16 *WString
4264 )
4265 {
4266 EFI_STATUS Status;
4267 TEXT_OUT_SPLITTER_PRIVATE_DATA *Private;
4268 UINTN Index;
4269 EFI_STATUS ReturnStatus;
4270
4271 Private = TEXT_OUT_SPLITTER_PRIVATE_DATA_FROM_THIS (This);
4272
4273 //
4274 // return the worst status met
4275 //
4276 for (Index = 0, ReturnStatus = EFI_SUCCESS; Index < Private->CurrentNumberOfConsoles; Index++) {
4277 Status = Private->TextOutList[Index].TextOut->TestString (
4278 Private->TextOutList[Index].TextOut,
4279 WString
4280 );
4281 if (EFI_ERROR (Status)) {
4282 ReturnStatus = Status;
4283 }
4284 }
4285 //
4286 // There is no DevNullTextOutTestString () since a Unicode buffer would
4287 // always return EFI_SUCCESS.
4288 // ReturnStatus will be EFI_SUCCESS if no consoles are present
4289 //
4290 return ReturnStatus;
4291 }
4292
4293
4294 /**
4295 Returns information for an available text mode that the output device(s)
4296 supports.
4297
4298 @param This Protocol instance pointer.
4299 @param ModeNumber The mode number to return information on.
4300 @param Columns Returns the columns of the text output device
4301 for the requested ModeNumber.
4302 @param Rows Returns the rows of the text output device
4303 for the requested ModeNumber.
4304
4305 @retval EFI_SUCCESS The requested mode information was returned.
4306 @retval EFI_DEVICE_ERROR The device had an error and could not complete
4307 the request.
4308 @retval EFI_UNSUPPORTED The mode number was not valid.
4309
4310 **/
4311 EFI_STATUS
4312 EFIAPI
4313 ConSplitterTextOutQueryMode (
4314 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,
4315 IN UINTN ModeNumber,
4316 OUT UINTN *Columns,
4317 OUT UINTN *Rows
4318 )
4319 {
4320 TEXT_OUT_SPLITTER_PRIVATE_DATA *Private;
4321 UINTN CurrentMode;
4322 INT32 *TextOutModeMap;
4323
4324 Private = TEXT_OUT_SPLITTER_PRIVATE_DATA_FROM_THIS (This);
4325
4326 //
4327 // Check whether param ModeNumber is valid.
4328 // ModeNumber should be within range 0 ~ MaxMode - 1.
4329 //
4330 if ( (ModeNumber > (UINTN)(((UINT32)-1)>>1)) ) {
4331 return EFI_UNSUPPORTED;
4332 }
4333
4334 if ((INT32) ModeNumber >= This->Mode->MaxMode) {
4335 return EFI_UNSUPPORTED;
4336 }
4337
4338 //
4339 // We get the available mode from mode intersection map if it's available
4340 //
4341 if (Private->TextOutModeMap != NULL) {
4342 TextOutModeMap = Private->TextOutModeMap + Private->TextOutListCount * ModeNumber;
4343 CurrentMode = (UINTN)(*TextOutModeMap);
4344 *Columns = Private->TextOutQueryData[CurrentMode].Columns;
4345 *Rows = Private->TextOutQueryData[CurrentMode].Rows;
4346 } else {
4347 *Columns = Private->TextOutQueryData[ModeNumber].Columns;
4348 *Rows = Private->TextOutQueryData[ModeNumber].Rows;
4349 }
4350
4351 if (*Columns <= 0 && *Rows <= 0) {
4352 return EFI_UNSUPPORTED;
4353
4354 }
4355
4356 return EFI_SUCCESS;
4357 }
4358
4359
4360 /**
4361 Sets the output device(s) to a specified mode.
4362
4363 @param This Protocol instance pointer.
4364 @param ModeNumber The mode number to set.
4365
4366 @retval EFI_SUCCESS The requested text mode was set.
4367 @retval EFI_DEVICE_ERROR The device had an error and could not complete
4368 the request.
4369 @retval EFI_UNSUPPORTED The mode number was not valid.
4370
4371 **/
4372 EFI_STATUS
4373 EFIAPI
4374 ConSplitterTextOutSetMode (
4375 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,
4376 IN UINTN ModeNumber
4377 )
4378 {
4379 EFI_STATUS Status;
4380 TEXT_OUT_SPLITTER_PRIVATE_DATA *Private;
4381 UINTN Index;
4382 INT32 *TextOutModeMap;
4383 EFI_STATUS ReturnStatus;
4384
4385 Private = TEXT_OUT_SPLITTER_PRIVATE_DATA_FROM_THIS (This);
4386
4387 //
4388 // Check whether param ModeNumber is valid.
4389 // ModeNumber should be within range 0 ~ MaxMode - 1.
4390 //
4391 if ( (ModeNumber > (UINTN)(((UINT32)-1)>>1)) ) {
4392 return EFI_UNSUPPORTED;
4393 }
4394
4395 if ((INT32) ModeNumber >= This->Mode->MaxMode) {
4396 return EFI_UNSUPPORTED;
4397 }
4398 //
4399 // If the mode is being set to the curent mode, then just clear the screen and return.
4400 //
4401 if (Private->TextOutMode.Mode == (INT32) ModeNumber) {
4402 return ConSplitterTextOutClearScreen (This);
4403 }
4404 //
4405 // return the worst status met
4406 //
4407 TextOutModeMap = Private->TextOutModeMap + Private->TextOutListCount * ModeNumber;
4408 for (Index = 0, ReturnStatus = EFI_SUCCESS; Index < Private->CurrentNumberOfConsoles; Index++) {
4409 Status = Private->TextOutList[Index].TextOut->SetMode (
4410 Private->TextOutList[Index].TextOut,
4411 TextOutModeMap[Index]
4412 );
4413 if (EFI_ERROR (Status)) {
4414 ReturnStatus = Status;
4415 }
4416 }
4417
4418 //
4419 // Set mode parameter to specified mode number
4420 //
4421 TextOutSetMode (Private, ModeNumber);
4422
4423 return ReturnStatus;
4424 }
4425
4426
4427 /**
4428 Sets the background and foreground colors for the OutputString () and
4429 ClearScreen () functions.
4430
4431 @param This Protocol instance pointer.
4432 @param Attribute The attribute to set. Bits 0..3 are the
4433 foreground color, and bits 4..6 are the
4434 background color. All other bits are undefined
4435 and must be zero. The valid Attributes are
4436 defined in this file.
4437
4438 @retval EFI_SUCCESS The attribute was set.
4439 @retval EFI_DEVICE_ERROR The device had an error and could not complete
4440 the request.
4441 @retval EFI_UNSUPPORTED The attribute requested is not defined.
4442
4443 **/
4444 EFI_STATUS
4445 EFIAPI
4446 ConSplitterTextOutSetAttribute (
4447 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,
4448 IN UINTN Attribute
4449 )
4450 {
4451 EFI_STATUS Status;
4452 TEXT_OUT_SPLITTER_PRIVATE_DATA *Private;
4453 UINTN Index;
4454 EFI_STATUS ReturnStatus;
4455
4456 Private = TEXT_OUT_SPLITTER_PRIVATE_DATA_FROM_THIS (This);
4457
4458 //
4459 // Check whether param Attribute is valid.
4460 //
4461 if ( (Attribute > (UINTN)(((UINT32)-1)>>1)) ) {
4462 return EFI_UNSUPPORTED;
4463 }
4464
4465 //
4466 // return the worst status met
4467 //
4468 for (Index = 0, ReturnStatus = EFI_SUCCESS; Index < Private->CurrentNumberOfConsoles; Index++) {
4469 Status = Private->TextOutList[Index].TextOut->SetAttribute (
4470 Private->TextOutList[Index].TextOut,
4471 Attribute
4472 );
4473 if (EFI_ERROR (Status)) {
4474 ReturnStatus = Status;
4475 }
4476 }
4477
4478 Private->TextOutMode.Attribute = (INT32) Attribute;
4479
4480 return ReturnStatus;
4481 }
4482
4483
4484 /**
4485 Clears the output device(s) display to the currently selected background
4486 color.
4487
4488 @param This Protocol instance pointer.
4489
4490 @retval EFI_SUCCESS The operation completed successfully.
4491 @retval EFI_DEVICE_ERROR The device had an error and could not complete
4492 the request.
4493 @retval EFI_UNSUPPORTED The output device is not in a valid text mode.
4494
4495 **/
4496 EFI_STATUS
4497 EFIAPI
4498 ConSplitterTextOutClearScreen (
4499 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This
4500 )
4501 {
4502 EFI_STATUS Status;
4503 TEXT_OUT_SPLITTER_PRIVATE_DATA *Private;
4504 UINTN Index;
4505 EFI_STATUS ReturnStatus;
4506
4507 Private = TEXT_OUT_SPLITTER_PRIVATE_DATA_FROM_THIS (This);
4508
4509 //
4510 // return the worst status met
4511 //
4512 for (Index = 0, ReturnStatus = EFI_SUCCESS; Index < Private->CurrentNumberOfConsoles; Index++) {
4513 Status = Private->TextOutList[Index].TextOut->ClearScreen (Private->TextOutList[Index].TextOut);
4514 if (EFI_ERROR (Status)) {
4515 ReturnStatus = Status;
4516 }
4517 }
4518
4519 //
4520 // No need to do extra check here as whether (Column, Row) is valid has
4521 // been checked in ConSplitterTextOutSetCursorPosition. And (0, 0) should
4522 // always be supported.
4523 //
4524 Private->TextOutMode.CursorColumn = 0;
4525 Private->TextOutMode.CursorRow = 0;
4526 Private->TextOutMode.CursorVisible = TRUE;
4527
4528 return ReturnStatus;
4529 }
4530
4531
4532 /**
4533 Sets the current coordinates of the cursor position
4534
4535 @param This Protocol instance pointer.
4536 @param Column The column position to set the cursor to. Must be
4537 greater than or equal to zero and less than the
4538 number of columns by QueryMode ().
4539 @param Row The row position to set the cursor to. Must be
4540 greater than or equal to zero and less than the
4541 number of rows by QueryMode ().
4542
4543 @retval EFI_SUCCESS The operation completed successfully.
4544 @retval EFI_DEVICE_ERROR The device had an error and could not complete
4545 the request.
4546 @retval EFI_UNSUPPORTED The output device is not in a valid text mode,
4547 or the cursor position is invalid for the
4548 current mode.
4549
4550 **/
4551 EFI_STATUS
4552 EFIAPI
4553 ConSplitterTextOutSetCursorPosition (
4554 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,
4555 IN UINTN Column,
4556 IN UINTN Row
4557 )
4558 {
4559 EFI_STATUS Status;
4560 TEXT_OUT_SPLITTER_PRIVATE_DATA *Private;
4561 UINTN Index;
4562 EFI_STATUS ReturnStatus;
4563 UINTN MaxColumn;
4564 UINTN MaxRow;
4565 INT32 *TextOutModeMap;
4566 INT32 ModeNumber;
4567 INT32 CurrentMode;
4568
4569 Private = TEXT_OUT_SPLITTER_PRIVATE_DATA_FROM_THIS (This);
4570 TextOutModeMap = NULL;
4571 ModeNumber = Private->TextOutMode.Mode;
4572
4573 //
4574 // Get current MaxColumn and MaxRow from intersection map
4575 //
4576 if (Private->TextOutModeMap != NULL) {
4577 TextOutModeMap = Private->TextOutModeMap + Private->TextOutListCount * ModeNumber;
4578 CurrentMode = *TextOutModeMap;
4579 } else {
4580 CurrentMode = ModeNumber;
4581 }
4582
4583 MaxColumn = Private->TextOutQueryData[CurrentMode].Columns;
4584 MaxRow = Private->TextOutQueryData[CurrentMode].Rows;
4585
4586 if (Column >= MaxColumn || Row >= MaxRow) {
4587 return EFI_UNSUPPORTED;
4588 }
4589 //
4590 // return the worst status met
4591 //
4592 for (Index = 0, ReturnStatus = EFI_SUCCESS; Index < Private->CurrentNumberOfConsoles; Index++) {
4593 Status = Private->TextOutList[Index].TextOut->SetCursorPosition (
4594 Private->TextOutList[Index].TextOut,
4595 Column,
4596 Row
4597 );
4598 if (EFI_ERROR (Status)) {
4599 ReturnStatus = Status;
4600 }
4601 }
4602
4603 //
4604 // No need to do extra check here as whether (Column, Row) is valid has
4605 // been checked in ConSplitterTextOutSetCursorPosition. And (0, 0) should
4606 // always be supported.
4607 //
4608 Private->TextOutMode.CursorColumn = (INT32) Column;
4609 Private->TextOutMode.CursorRow = (INT32) Row;
4610
4611 return ReturnStatus;
4612 }
4613
4614
4615 /**
4616 Makes the cursor visible or invisible
4617
4618 @param This Protocol instance pointer.
4619 @param Visible If TRUE, the cursor is set to be visible. If
4620 FALSE, the cursor is set to be invisible.
4621
4622 @retval EFI_SUCCESS The operation completed successfully.
4623 @retval EFI_DEVICE_ERROR The device had an error and could not complete
4624 the request, or the device does not support
4625 changing the cursor mode.
4626 @retval EFI_UNSUPPORTED The output device is not in a valid text mode.
4627
4628 **/
4629 EFI_STATUS
4630 EFIAPI
4631 ConSplitterTextOutEnableCursor (
4632 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,
4633 IN BOOLEAN Visible
4634 )
4635 {
4636 EFI_STATUS Status;
4637 TEXT_OUT_SPLITTER_PRIVATE_DATA *Private;
4638 UINTN Index;
4639 EFI_STATUS ReturnStatus;
4640
4641 Private = TEXT_OUT_SPLITTER_PRIVATE_DATA_FROM_THIS (This);
4642
4643 //
4644 // return the worst status met
4645 //
4646 for (Index = 0, ReturnStatus = EFI_SUCCESS; Index < Private->CurrentNumberOfConsoles; Index++) {
4647 Status = Private->TextOutList[Index].TextOut->EnableCursor (
4648 Private->TextOutList[Index].TextOut,
4649 Visible
4650 );
4651 if (EFI_ERROR (Status)) {
4652 ReturnStatus = Status;
4653 }
4654 }
4655
4656 Private->TextOutMode.CursorVisible = Visible;
4657
4658 return ReturnStatus;
4659 }
4660