/** @file\r
Support functions to connect/disconnect UEFI Driver model Protocol\r
\r
-Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>\r
-This program and the accompanying materials\r
-are licensed and made available under the terms and conditions of the BSD License\r
-which accompanies this distribution. The full text of the license may be found at\r
-http://opensource.org/licenses/bsd-license.php\r
-\r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>\r
+SPDX-License-Identifier: BSD-2-Clause-Patent\r
\r
**/\r
\r
/**\r
Connects one or more drivers to a controller.\r
\r
- @param ControllerHandle Handle of the controller to be\r
- connected.\r
- @param DriverImageHandle DriverImageHandle A pointer to an\r
- ordered list of driver image\r
- handles.\r
- @param RemainingDevicePath RemainingDevicePath A pointer to\r
- the device path that specifies a\r
- child of the controller specified\r
- by ControllerHandle.\r
- @param Recursive Whether the function would be\r
- called recursively or not.\r
-\r
- @return Status code.\r
+ @param ControllerHandle The handle of the controller to which driver(s) are to be connected.\r
+ @param DriverImageHandle A pointer to an ordered list handles that support the\r
+ EFI_DRIVER_BINDING_PROTOCOL.\r
+ @param RemainingDevicePath A pointer to the device path that specifies a child of the\r
+ controller specified by ControllerHandle.\r
+ @param Recursive If TRUE, then ConnectController() is called recursively\r
+ until the entire tree of controllers below the controller specified\r
+ by ControllerHandle have been created. If FALSE, then\r
+ the tree of controllers is only expanded one level.\r
+\r
+ @retval EFI_SUCCESS 1) One or more drivers were connected to ControllerHandle.\r
+ 2) No drivers were connected to ControllerHandle, but\r
+ RemainingDevicePath is not NULL, and it is an End Device\r
+ Path Node.\r
+ @retval EFI_INVALID_PARAMETER ControllerHandle is NULL.\r
+ @retval EFI_NOT_FOUND 1) There are no EFI_DRIVER_BINDING_PROTOCOL instances\r
+ present in the system.\r
+ 2) No drivers were connected to ControllerHandle.\r
+ @retval EFI_SECURITY_VIOLATION\r
+ The user has no permission to start UEFI device drivers on the device path\r
+ associated with the ControllerHandle or specified by the RemainingDevicePath.\r
\r
**/\r
EFI_STATUS\r
EFI_HANDLE *ChildHandleBuffer;\r
UINTN ChildHandleCount;\r
UINTN Index;\r
+ UINTN HandleFilePathSize;\r
+ UINTN RemainingDevicePathSize;\r
+ EFI_DEVICE_PATH_PROTOCOL *HandleFilePath;\r
+ EFI_DEVICE_PATH_PROTOCOL *FilePath;\r
+ EFI_DEVICE_PATH_PROTOCOL *TempFilePath;\r
\r
//\r
// Make sure ControllerHandle is valid\r
return Status;\r
}\r
\r
+ if (gSecurity2 != NULL) {\r
+ //\r
+ // Check whether the user has permission to start UEFI device drivers.\r
+ //\r
+ Status = CoreHandleProtocol (ControllerHandle, &gEfiDevicePathProtocolGuid, (VOID **)&HandleFilePath);\r
+ if (!EFI_ERROR (Status)) {\r
+ ASSERT (HandleFilePath != NULL);\r
+ FilePath = HandleFilePath;\r
+ TempFilePath = NULL;\r
+ if (RemainingDevicePath != NULL && !Recursive) {\r
+ HandleFilePathSize = GetDevicePathSize (HandleFilePath) - sizeof (EFI_DEVICE_PATH_PROTOCOL);\r
+ RemainingDevicePathSize = GetDevicePathSize (RemainingDevicePath);\r
+ TempFilePath = AllocateZeroPool (HandleFilePathSize + RemainingDevicePathSize);\r
+ ASSERT (TempFilePath != NULL);\r
+ CopyMem (TempFilePath, HandleFilePath, HandleFilePathSize);\r
+ CopyMem ((UINT8 *) TempFilePath + HandleFilePathSize, RemainingDevicePath, RemainingDevicePathSize);\r
+ FilePath = TempFilePath;\r
+ }\r
+ Status = gSecurity2->FileAuthentication (\r
+ gSecurity2,\r
+ FilePath,\r
+ NULL,\r
+ 0,\r
+ FALSE\r
+ );\r
+ if (TempFilePath != NULL) {\r
+ FreePool (TempFilePath);\r
+ }\r
+ if (EFI_ERROR (Status)) {\r
+ return Status;\r
+ }\r
+ }\r
+ }\r
+\r
Handle = ControllerHandle;\r
\r
//\r
DriverBindingHandleBuffer = NULL;\r
NumberOfSortedDriverBindingProtocols = 0;\r
SortedDriverBindingProtocols = NULL;\r
+ PlatformDriverOverride = NULL;\r
+ NewDriverBindingHandleBuffer = NULL;\r
\r
//\r
// Get list of all Driver Binding Protocol Instances\r
for (Index = 0; (Index < NumberOfSortedDriverBindingProtocols) && !DriverFound; Index++) {\r
if (SortedDriverBindingProtocols[Index] != NULL) {\r
DriverBinding = SortedDriverBindingProtocols[Index];\r
- PERF_START (DriverBinding->DriverBindingHandle, "DB:Support:", NULL, 0);\r
+ PERF_DRIVER_BINDING_SUPPORT_BEGIN (DriverBinding->DriverBindingHandle, ControllerHandle);\r
Status = DriverBinding->Supported(\r
DriverBinding,\r
ControllerHandle,\r
RemainingDevicePath\r
);\r
- PERF_END (DriverBinding->DriverBindingHandle, "DB:Support:", NULL, 0);\r
+ PERF_DRIVER_BINDING_SUPPORT_END (DriverBinding->DriverBindingHandle, ControllerHandle);\r
if (!EFI_ERROR (Status)) {\r
SortedDriverBindingProtocols[Index] = NULL;\r
DriverFound = TRUE;\r
// A driver was found that supports ControllerHandle, so attempt to start the driver\r
// on ControllerHandle.\r
//\r
- PERF_START (DriverBinding->DriverBindingHandle, "DB:Start:", NULL, 0);\r
+ PERF_DRIVER_BINDING_START_BEGIN (DriverBinding->DriverBindingHandle, ControllerHandle);\r
Status = DriverBinding->Start (\r
DriverBinding,\r
ControllerHandle,\r
RemainingDevicePath\r
);\r
- PERF_END (DriverBinding->DriverBindingHandle, "DB:Start:", NULL, 0);\r
+ PERF_DRIVER_BINDING_START_END (DriverBinding->DriverBindingHandle, ControllerHandle);\r
\r
if (!EFI_ERROR (Status)) {\r
//\r
@retval EFI_SUCCESS DriverImageHandle is not NULL,\r
and on entry DriverImageHandle is\r
not managing ControllerHandle.\r
- @retval EFI_INVALID_PARAMETER ControllerHandle is not a valid\r
- EFI_HANDLE.\r
+ @retval EFI_INVALID_PARAMETER ControllerHandle is NULL.\r
@retval EFI_INVALID_PARAMETER DriverImageHandle is not NULL,\r
and it is not a valid EFI_HANDLE.\r
@retval EFI_INVALID_PARAMETER ChildHandle is not NULL, and it\r