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