2 Console Platform DXE Driver, install Console Device Guids and update Console
5 Copyright (c) 2006 - 2012, Intel Corporation. All rights reserved.<BR>
6 This program and the accompanying materials
7 are licensed and made available under the terms and conditions of the BSD License
8 which accompanies this distribution. The full text of the license may be found at
9 http://opensource.org/licenses/bsd-license.php
11 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
12 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
16 #include "ConPlatform.h"
19 EFI_DRIVER_BINDING_PROTOCOL gConPlatformTextInDriverBinding
= {
20 ConPlatformTextInDriverBindingSupported
,
21 ConPlatformTextInDriverBindingStart
,
22 ConPlatformTextInDriverBindingStop
,
28 EFI_DRIVER_BINDING_PROTOCOL gConPlatformTextOutDriverBinding
= {
29 ConPlatformTextOutDriverBindingSupported
,
30 ConPlatformTextOutDriverBindingStart
,
31 ConPlatformTextOutDriverBindingStop
,
38 Entrypoint of this module.
40 This function is the entrypoint of this module. It installs Driver Binding
41 Protocols together with Component Name Protocols.
43 @param ImageHandle The firmware allocated handle for the EFI image.
44 @param SystemTable A pointer to the EFI System Table.
46 @retval EFI_SUCCESS The entry point is executed successfully.
51 InitializeConPlatform(
52 IN EFI_HANDLE ImageHandle
,
53 IN EFI_SYSTEM_TABLE
*SystemTable
58 Status
= EfiLibInstallDriverBindingComponentName2 (
61 &gConPlatformTextInDriverBinding
,
63 &gConPlatformComponentName
,
64 &gConPlatformComponentName2
66 ASSERT_EFI_ERROR (Status
);
68 Status
= EfiLibInstallDriverBindingComponentName2 (
71 &gConPlatformTextOutDriverBinding
,
73 &gConPlatformComponentName
,
74 &gConPlatformComponentName2
76 ASSERT_EFI_ERROR (Status
);
83 Test to see if EFI_SIMPLE_TEXT_INPUT_PROTOCOL is supported on ControllerHandle.
85 @param This Protocol instance pointer.
86 @param ControllerHandle Handle of device to test.
87 @param RemainingDevicePath Optional parameter use to pick a specific child
90 @retval EFI_SUCCESS This driver supports this device.
91 @retval other This driver does not support this device.
96 ConPlatformTextInDriverBindingSupported (
97 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
98 IN EFI_HANDLE ControllerHandle
,
99 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath OPTIONAL
102 return ConPlatformDriverBindingSupported (
105 &gEfiSimpleTextInProtocolGuid
111 Test to see if EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL is supported on ControllerHandle.
113 @param This Protocol instance pointer.
114 @param ControllerHandle Handle of device to test.
115 @param RemainingDevicePath Optional parameter use to pick a specific child
118 @retval EFI_SUCCESS This driver supports this device.
119 @retval other This driver does not support this device.
124 ConPlatformTextOutDriverBindingSupported (
125 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
126 IN EFI_HANDLE ControllerHandle
,
127 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath OPTIONAL
130 return ConPlatformDriverBindingSupported (
133 &gEfiSimpleTextOutProtocolGuid
139 Test to see if the specified protocol is supported on ControllerHandle.
141 @param This Protocol instance pointer.
142 @param ControllerHandle Handle of device to test.
143 @param ProtocolGuid The specfic protocol.
145 @retval EFI_SUCCESS This driver supports this device.
146 @retval other This driver does not support this device.
150 ConPlatformDriverBindingSupported (
151 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
152 IN EFI_HANDLE ControllerHandle
,
153 IN EFI_GUID
*ProtocolGuid
160 // Test to see if this is a physical device by checking if
161 // it has a Device Path Protocol.
163 Status
= gBS
->OpenProtocol (
165 &gEfiDevicePathProtocolGuid
,
167 This
->DriverBindingHandle
,
169 EFI_OPEN_PROTOCOL_TEST_PROTOCOL
171 if (EFI_ERROR (Status
)) {
175 // Test to see if this device supports the specified Protocol.
177 Status
= gBS
->OpenProtocol (
180 (VOID
**) &Interface
,
181 This
->DriverBindingHandle
,
183 EFI_OPEN_PROTOCOL_BY_DRIVER
185 if (EFI_ERROR (Status
)) {
192 This
->DriverBindingHandle
,
200 Start this driver on the device for console input.
202 Start this driver on ControllerHandle by opening Simple Text Input Protocol,
203 reading Device Path, and installing Console In Devcice GUID on ControllerHandle.
205 If this devcie is not one hot-plug devce, append its device path into the
206 console environment variables ConInDev.
208 @param This Protocol instance pointer.
209 @param ControllerHandle Handle of device to bind driver to
210 @param RemainingDevicePath Optional parameter use to pick a specific child
213 @retval EFI_SUCCESS This driver is added to ControllerHandle
214 @retval EFI_ALREADY_STARTED This driver is already running on ControllerHandle
215 @retval other This driver does not support this device.
220 ConPlatformTextInDriverBindingStart (
221 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
222 IN EFI_HANDLE ControllerHandle
,
223 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
227 EFI_DEVICE_PATH_PROTOCOL
*DevicePath
;
228 EFI_SIMPLE_TEXT_INPUT_PROTOCOL
*TextIn
;
229 BOOLEAN IsInConInVariable
;
232 // Get the Device Path Protocol so the environment variables can be updated
234 Status
= gBS
->OpenProtocol (
236 &gEfiDevicePathProtocolGuid
,
237 (VOID
**) &DevicePath
,
238 This
->DriverBindingHandle
,
240 EFI_OPEN_PROTOCOL_GET_PROTOCOL
242 if (EFI_ERROR (Status
)) {
246 // Open the Simple Text Input Protocol BY_DRIVER
248 Status
= gBS
->OpenProtocol (
250 &gEfiSimpleTextInProtocolGuid
,
252 This
->DriverBindingHandle
,
254 EFI_OPEN_PROTOCOL_BY_DRIVER
256 if (EFI_ERROR (Status
)) {
260 // Check if the device path is in ConIn Variable
262 IsInConInVariable
= FALSE
;
263 Status
= ConPlatformUpdateDeviceVariable (
268 if (!EFI_ERROR (Status
)) {
269 IsInConInVariable
= TRUE
;
273 // Check the device path, if it is a hot plug device,
274 // do not put the device path into ConInDev, and install
275 // gEfiConsoleInDeviceGuid to the device handle directly.
276 // The policy is, make hot plug device plug in and play immediately.
278 if (IsHotPlugDevice (DevicePath
)) {
279 gBS
->InstallMultipleProtocolInterfaces (
281 &gEfiConsoleInDeviceGuid
,
286 // Append the device path to ConInDev only if it is in ConIn variable.
288 if (IsInConInVariable
) {
289 ConPlatformUpdateDeviceVariable (
297 // If it is not a hot-plug device, append the device path to the
298 // ConInDev environment variable
300 ConPlatformUpdateDeviceVariable (
307 // If the device path is an instance in the ConIn environment variable,
308 // then install EfiConsoleInDeviceGuid onto ControllerHandle
310 if (IsInConInVariable
) {
311 gBS
->InstallMultipleProtocolInterfaces (
313 &gEfiConsoleInDeviceGuid
,
320 &gEfiSimpleTextInProtocolGuid
,
321 This
->DriverBindingHandle
,
331 Start this driver on the device for console output and stardard error output.
333 Start this driver on ControllerHandle by opening Simple Text Output Protocol,
334 reading Device Path, and installing Console Out Devcic GUID, Standard Error
335 Device GUID on ControllerHandle.
337 If this devcie is not one hot-plug devce, append its device path into the
338 console environment variables ConOutDev, ErrOutDev.
340 @param This Protocol instance pointer.
341 @param ControllerHandle Handle of device to bind driver to
342 @param RemainingDevicePath Optional parameter use to pick a specific child
345 @retval EFI_SUCCESS This driver is added to ControllerHandle
346 @retval EFI_ALREADY_STARTED This driver is already running on ControllerHandle
347 @retval other This driver does not support this device
352 ConPlatformTextOutDriverBindingStart (
353 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
354 IN EFI_HANDLE ControllerHandle
,
355 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
359 EFI_DEVICE_PATH_PROTOCOL
*DevicePath
;
360 EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*TextOut
;
362 BOOLEAN IsInConOutVariable
;
363 BOOLEAN IsInErrOutVariable
;
368 // Get the Device Path Protocol so the environment variables can be updated
370 Status
= gBS
->OpenProtocol (
372 &gEfiDevicePathProtocolGuid
,
373 (VOID
**) &DevicePath
,
374 This
->DriverBindingHandle
,
376 EFI_OPEN_PROTOCOL_GET_PROTOCOL
378 if (EFI_ERROR (Status
)) {
382 // Open the Simple Text Output Protocol BY_DRIVER
384 Status
= gBS
->OpenProtocol (
386 &gEfiSimpleTextOutProtocolGuid
,
388 This
->DriverBindingHandle
,
390 EFI_OPEN_PROTOCOL_BY_DRIVER
392 if (EFI_ERROR (Status
)) {
396 // Check if the device path is in ConOut & ErrOut Variable
398 IsInConOutVariable
= FALSE
;
399 Status
= ConPlatformUpdateDeviceVariable (
404 if (!EFI_ERROR (Status
)) {
405 IsInConOutVariable
= TRUE
;
408 IsInErrOutVariable
= FALSE
;
409 Status
= ConPlatformUpdateDeviceVariable (
414 if (!EFI_ERROR (Status
)) {
415 IsInErrOutVariable
= TRUE
;
419 // Check the device path, if it is a hot plug device,
420 // do not put the device path into ConOutDev and ErrOutDev,
421 // and install gEfiConsoleOutDeviceGuid to the device handle directly.
422 // The policy is, make hot plug device plug in and play immediately.
424 if (IsHotPlugDevice (DevicePath
)) {
425 gBS
->InstallMultipleProtocolInterfaces (
427 &gEfiConsoleOutDeviceGuid
,
432 // Append the device path to ConOutDev only if it is in ConOut variable.
434 if (IsInConOutVariable
) {
435 ConPlatformUpdateDeviceVariable (
442 // Append the device path to ErrOutDev only if it is in ErrOut variable.
444 if (IsInErrOutVariable
) {
445 ConPlatformUpdateDeviceVariable (
453 // If it is not a hot-plug device, append the device path to
454 // the ConOutDev and ErrOutDev environment variable.
455 // For GOP device path, append the sibling device path as well.
457 if (!ConPlatformUpdateGopCandidate (DevicePath
)) {
458 ConPlatformUpdateDeviceVariable (
464 // Then append the device path to the ErrOutDev environment variable
466 ConPlatformUpdateDeviceVariable (
474 // If the device path is an instance in the ConOut environment variable,
475 // then install EfiConsoleOutDeviceGuid onto ControllerHandle
477 if (IsInConOutVariable
) {
479 Status
= gBS
->InstallMultipleProtocolInterfaces (
481 &gEfiConsoleOutDeviceGuid
,
487 // If the device path is an instance in the ErrOut environment variable,
488 // then install EfiStandardErrorDeviceGuid onto ControllerHandle
490 if (IsInErrOutVariable
) {
492 gBS
->InstallMultipleProtocolInterfaces (
494 &gEfiStandardErrorDeviceGuid
,
503 &gEfiSimpleTextOutProtocolGuid
,
504 This
->DriverBindingHandle
,
514 Stop this driver on ControllerHandle by removing Console In Devcice GUID
515 and closing the Simple Text Input protocol on ControllerHandle.
517 @param This Protocol instance pointer.
518 @param ControllerHandle Handle of device to stop driver on
519 @param NumberOfChildren Number of Handles in ChildHandleBuffer. If number of
520 children is zero stop the entire bus driver.
521 @param ChildHandleBuffer List of Child Handles to Stop.
523 @retval EFI_SUCCESS This driver is removed ControllerHandle
524 @retval other This driver was not removed from this device
529 ConPlatformTextInDriverBindingStop (
530 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
531 IN EFI_HANDLE ControllerHandle
,
532 IN UINTN NumberOfChildren
,
533 IN EFI_HANDLE
*ChildHandleBuffer
537 EFI_DEVICE_PATH_PROTOCOL
*DevicePath
;
540 // Get the Device Path Protocol firstly
542 Status
= gBS
->OpenProtocol (
544 &gEfiDevicePathProtocolGuid
,
545 (VOID
**) &DevicePath
,
546 This
->DriverBindingHandle
,
548 EFI_OPEN_PROTOCOL_GET_PROTOCOL
551 // If there is device path on ControllerHandle
553 if (!EFI_ERROR (Status
)) {
555 // Remove DevicePath from ConInDev if exists.
557 ConPlatformUpdateDeviceVariable (
565 // Uninstall the Console Device GUIDs from Controller Handle
567 ConPlatformUnInstallProtocol (
570 &gEfiConsoleInDeviceGuid
574 // Close the Simple Text Input Protocol
578 &gEfiSimpleTextInProtocolGuid
,
579 This
->DriverBindingHandle
,
588 Stop this driver on ControllerHandle by removing Console Out Devcice GUID
589 and closing the Simple Text Output protocol on ControllerHandle.
591 @param This Protocol instance pointer.
592 @param ControllerHandle Handle of device to stop driver on
593 @param NumberOfChildren Number of Handles in ChildHandleBuffer. If number of
594 children is zero stop the entire bus driver.
595 @param ChildHandleBuffer List of Child Handles to Stop.
597 @retval EFI_SUCCESS This driver is removed ControllerHandle
598 @retval other This driver was not removed from this device
603 ConPlatformTextOutDriverBindingStop (
604 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
605 IN EFI_HANDLE ControllerHandle
,
606 IN UINTN NumberOfChildren
,
607 IN EFI_HANDLE
*ChildHandleBuffer
611 EFI_DEVICE_PATH_PROTOCOL
*DevicePath
;
614 // Get the Device Path Protocol firstly
616 Status
= gBS
->OpenProtocol (
618 &gEfiDevicePathProtocolGuid
,
619 (VOID
**) &DevicePath
,
620 This
->DriverBindingHandle
,
622 EFI_OPEN_PROTOCOL_GET_PROTOCOL
624 if (!EFI_ERROR (Status
)) {
626 // Remove DevicePath from ConOutDev and ErrOutDev if exists.
628 ConPlatformUpdateDeviceVariable (
633 ConPlatformUpdateDeviceVariable (
641 // Uninstall the Console Device GUIDs from Controller Handle
643 ConPlatformUnInstallProtocol (
646 &gEfiConsoleOutDeviceGuid
649 ConPlatformUnInstallProtocol (
652 &gEfiStandardErrorDeviceGuid
656 // Close the Simple Text Output Protocol
660 &gEfiSimpleTextOutProtocolGuid
,
661 This
->DriverBindingHandle
,
670 Uninstall the specified protocol.
672 @param This Protocol instance pointer.
673 @param Handle Handle of device to uninstall protocol on.
674 @param ProtocolGuid The specified protocol need to be uninstalled.
678 ConPlatformUnInstallProtocol (
679 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
680 IN EFI_HANDLE Handle
,
681 IN EFI_GUID
*ProtocolGuid
686 Status
= gBS
->OpenProtocol (
690 This
->DriverBindingHandle
,
692 EFI_OPEN_PROTOCOL_TEST_PROTOCOL
695 if (!EFI_ERROR (Status
)) {
696 gBS
->UninstallMultipleProtocolInterfaces (
708 Get the necessary size of buffer and read the variable.
710 First get the necessary size of buffer. Then read the
711 EFI variable (Name) and return a dynamically allocated
712 buffer. On failure return NULL.
714 @param Name String part of EFI variable name
716 @return Dynamically allocated memory that contains a copy of the EFI variable.
717 Caller is repsoncible freeing the buffer. Return NULL means Variable
722 ConPlatformGetVariable (
734 // Test to see if the variable exists. If it doesn't, return NULL.
736 Status
= gRT
->GetVariable (
738 &gEfiGlobalVariableGuid
,
744 if (Status
== EFI_BUFFER_TOO_SMALL
) {
746 // Allocate the buffer to return
748 Buffer
= AllocatePool (BufferSize
);
749 if (Buffer
== NULL
) {
753 // Read variable into the allocated buffer.
755 Status
= gRT
->GetVariable (
757 &gEfiGlobalVariableGuid
,
762 if (EFI_ERROR (Status
)) {
765 // To make sure Buffer is NULL if any error occurs.
775 Function returns TRUE when the two input device paths point to the two
776 GOP child handles that have the same parent.
778 @param Left A pointer to a device path data structure.
779 @param Right A pointer to a device path data structure.
781 @retval TRUE Left and Right share the same parent.
782 @retval FALSE Left and Right don't share the same parent or either of them is not
787 IN EFI_DEVICE_PATH_PROTOCOL
*Left
,
788 IN EFI_DEVICE_PATH_PROTOCOL
*Right
791 EFI_DEVICE_PATH_PROTOCOL
*NodeLeft
;
792 EFI_DEVICE_PATH_PROTOCOL
*NodeRight
;
794 for (NodeLeft
= Left
; !IsDevicePathEndType (NodeLeft
); NodeLeft
= NextDevicePathNode (NodeLeft
)) {
795 if (DevicePathType (NodeLeft
) == ACPI_DEVICE_PATH
&& DevicePathSubType (NodeLeft
) == ACPI_ADR_DP
) {
800 if (IsDevicePathEndType (NodeLeft
)) {
804 for (NodeRight
= Right
; !IsDevicePathEndType (NodeRight
); NodeRight
= NextDevicePathNode (NodeRight
)) {
805 if (DevicePathType (NodeRight
) == ACPI_DEVICE_PATH
&& DevicePathSubType (NodeRight
) == ACPI_ADR_DP
) {
810 if (IsDevicePathEndType (NodeRight
)) {
814 if (((UINTN
) NodeLeft
- (UINTN
) Left
) != ((UINTN
) NodeRight
- (UINTN
) Right
)) {
818 return (BOOLEAN
) (CompareMem (Left
, Right
, (UINTN
) NodeLeft
- (UINTN
) Left
) == 0);
822 Function compares a device path data structure to that of all the nodes of a
823 second device path instance.
825 @param Multi A pointer to a multi-instance device path data structure.
826 @param Single A pointer to a single-instance device path data structure.
827 @param NewDevicePath If Delete is TRUE, this parameter must not be null, and it
828 points to the remaining device path data structure.
829 (remaining device path = Multi - Single.)
830 @param Delete If TRUE, means removing Single from Multi.
831 If FALSE, the routine just check whether Single matches
832 with any instance in Multi.
834 @retval EFI_SUCCESS If the Single is contained within Multi.
835 @retval EFI_NOT_FOUND If the Single is not contained within Multi.
836 @retval EFI_INVALID_PARAMETER Multi is NULL.
837 @retval EFI_INVALID_PARAMETER Single is NULL.
838 @retval EFI_INVALID_PARAMETER NewDevicePath is NULL when Delete is TRUE.
842 ConPlatformMatchDevicePaths (
843 IN EFI_DEVICE_PATH_PROTOCOL
*Multi
,
844 IN EFI_DEVICE_PATH_PROTOCOL
*Single
,
845 OUT EFI_DEVICE_PATH_PROTOCOL
**NewDevicePath OPTIONAL
,
849 EFI_DEVICE_PATH_PROTOCOL
*DevicePath
;
850 EFI_DEVICE_PATH_PROTOCOL
*TempDevicePath1
;
851 EFI_DEVICE_PATH_PROTOCOL
*TempDevicePath2
;
852 EFI_DEVICE_PATH_PROTOCOL
*DevicePathInst
;
856 // The passed in DevicePath should not be NULL
858 if ((Multi
== NULL
) || (Single
== NULL
)) {
859 return EFI_INVALID_PARAMETER
;
863 // If performing Delete operation, the NewDevicePath must not be NULL.
866 if (NewDevicePath
== NULL
) {
867 return EFI_INVALID_PARAMETER
;
871 TempDevicePath1
= NULL
;
874 DevicePathInst
= GetNextDevicePathInstance (&DevicePath
, &Size
);
877 // Search for the match of 'Single' in 'Multi'
879 while (DevicePathInst
!= NULL
) {
880 if ((CompareMem (Single
, DevicePathInst
, Size
) == 0) || IsGopSibling (Single
, DevicePathInst
)) {
883 // If Delete is FALSE, return EFI_SUCCESS if Single is found in Multi.
885 FreePool (DevicePathInst
);
891 // If the node of Multi does not match Single, then added it back to the result.
892 // That is, the node matching Single will be dropped and deleted from result.
894 TempDevicePath2
= AppendDevicePathInstance (
898 if (TempDevicePath1
!= NULL
) {
899 FreePool (TempDevicePath1
);
901 TempDevicePath1
= TempDevicePath2
;
905 FreePool (DevicePathInst
);
906 DevicePathInst
= GetNextDevicePathInstance (&DevicePath
, &Size
);
911 // Return the new device path data structure with specified node deleted.
913 *NewDevicePath
= TempDevicePath1
;
917 return EFI_NOT_FOUND
;
921 Update console environment variables.
923 @param VariableName Console environment variables, ConOutDev, ConInDev
924 ErrOutDev, ConIn ,ConOut or ErrOut.
925 @param DevicePath Console devcie's device path.
926 @param Operation Variable operations, including APPEND, CHECK and DELETE.
928 @retval EFI_SUCCESS Variable operates successfully.
929 @retval EFI_OUT_OF_RESOURCES If variable cannot be appended.
930 @retval other Variable updating failed.
934 ConPlatformUpdateDeviceVariable (
935 IN CHAR16
*VariableName
,
936 IN EFI_DEVICE_PATH_PROTOCOL
*DevicePath
,
937 IN CONPLATFORM_VAR_OPERATION Operation
941 EFI_DEVICE_PATH_PROTOCOL
*VariableDevicePath
;
942 EFI_DEVICE_PATH_PROTOCOL
*NewVariableDevicePath
;
944 VariableDevicePath
= NULL
;
945 NewVariableDevicePath
= NULL
;
948 // Get Variable according to variable name.
949 // The memory for Variable is allocated within ConPlatformGetVarible(),
950 // it is the caller's responsibility to free the memory before return.
952 VariableDevicePath
= ConPlatformGetVariable (VariableName
);
954 if (Operation
!= Delete
) {
956 // Match specified DevicePath in Console Variable.
958 Status
= ConPlatformMatchDevicePaths (
965 if ((Operation
== Check
) || (!EFI_ERROR (Status
))) {
967 // Branch here includes 2 cases:
968 // 1. Operation is CHECK, simply return Status.
969 // 2. Operation is APPEND, and device path already exists in variable, also return.
971 if (VariableDevicePath
!= NULL
) {
972 FreePool (VariableDevicePath
);
978 // We reach here to append a device path that does not exist in variable.
980 Status
= EFI_SUCCESS
;
981 NewVariableDevicePath
= AppendDevicePathInstance (
985 if (NewVariableDevicePath
== NULL
) {
986 Status
= EFI_OUT_OF_RESOURCES
;
991 // We reach here to remove DevicePath from the environment variable that
992 // is a multi-instance device path.
994 Status
= ConPlatformMatchDevicePaths (
997 &NewVariableDevicePath
,
1002 if (VariableDevicePath
!= NULL
) {
1003 FreePool (VariableDevicePath
);
1006 if (EFI_ERROR (Status
)) {
1010 if (NewVariableDevicePath
!= NULL
) {
1012 // Update Console Environment Variable.
1014 Status
= gRT
->SetVariable (
1016 &gEfiGlobalVariableGuid
,
1017 EFI_VARIABLE_BOOTSERVICE_ACCESS
| EFI_VARIABLE_RUNTIME_ACCESS
,
1018 GetDevicePathSize (NewVariableDevicePath
),
1019 NewVariableDevicePath
1022 FreePool (NewVariableDevicePath
);
1029 Check if the device supports hot-plug through its device path.
1031 This function could be updated to check more types of Hot Plug devices.
1032 Currently, it checks USB and PCCard device.
1034 @param DevicePath Pointer to device's device path.
1036 @retval TRUE The devcie is a hot-plug device
1037 @retval FALSE The devcie is not a hot-plug device.
1042 IN EFI_DEVICE_PATH_PROTOCOL
*DevicePath
1045 EFI_DEVICE_PATH_PROTOCOL
*CheckDevicePath
;
1047 CheckDevicePath
= DevicePath
;
1048 while (!IsDevicePathEnd (CheckDevicePath
)) {
1050 // Check device whether is hot plug device or not throught Device Path
1052 if ((DevicePathType (CheckDevicePath
) == MESSAGING_DEVICE_PATH
) &&
1053 (DevicePathSubType (CheckDevicePath
) == MSG_USB_DP
||
1054 DevicePathSubType (CheckDevicePath
) == MSG_USB_CLASS_DP
||
1055 DevicePathSubType (CheckDevicePath
) == MSG_USB_WWID_DP
)) {
1057 // If Device is USB device
1061 if ((DevicePathType (CheckDevicePath
) == HARDWARE_DEVICE_PATH
) &&
1062 (DevicePathSubType (CheckDevicePath
) == HW_PCCARD_DP
)) {
1064 // If Device is PCCard
1069 CheckDevicePath
= NextDevicePathNode (CheckDevicePath
);
1076 Update ConOutDev and ErrOutDev variables to add the device path of
1077 GOP controller itself and the sibling controllers.
1079 @param DevicePath Pointer to device's device path.
1081 @retval TRUE The devcie is a GOP device.
1082 @retval FALSE The devcie is not a GOP device.
1086 ConPlatformUpdateGopCandidate (
1087 IN EFI_DEVICE_PATH_PROTOCOL
*DevicePath
1091 EFI_HANDLE PciHandle
;
1092 EFI_HANDLE GopHandle
;
1093 EFI_OPEN_PROTOCOL_INFORMATION_ENTRY
*OpenInfoBuffer
;
1096 EFI_DEVICE_PATH_PROTOCOL
*ChildDevicePath
;
1097 EFI_DEVICE_PATH_PROTOCOL
*TempDevicePath
;
1100 // Check whether it's a GOP device.
1102 TempDevicePath
= DevicePath
;
1103 Status
= gBS
->LocateDevicePath (&gEfiGraphicsOutputProtocolGuid
, &TempDevicePath
, &GopHandle
);
1104 if (EFI_ERROR (Status
)) {
1108 // Get the parent PciIo handle in order to find all the children
1110 Status
= gBS
->LocateDevicePath (&gEfiPciIoProtocolGuid
, &DevicePath
, &PciHandle
);
1111 if (EFI_ERROR (Status
)) {
1115 Status
= gBS
->OpenProtocolInformation (
1117 &gEfiPciIoProtocolGuid
,
1121 if (EFI_ERROR (Status
)) {
1125 for (Index
= 0; Index
< EntryCount
; Index
++) {
1127 // Query all the children created by the GOP driver
1129 if ((OpenInfoBuffer
[Index
].Attributes
& EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER
) != 0) {
1130 Status
= gBS
->OpenProtocol (
1131 OpenInfoBuffer
[Index
].ControllerHandle
,
1132 &gEfiDevicePathProtocolGuid
,
1133 (VOID
**) &ChildDevicePath
,
1136 EFI_OPEN_PROTOCOL_GET_PROTOCOL
1138 if (!EFI_ERROR (Status
)) {
1140 // Append the device path to ConOutDev and ErrOutDev
1142 ConPlatformUpdateDeviceVariable (L
"ConOutDev", ChildDevicePath
, Append
);
1143 ConPlatformUpdateDeviceVariable (L
"ErrOutDev", ChildDevicePath
, Append
);
1147 FreePool (OpenInfoBuffer
);