2 Internal include file for Platform Driver Override Library implementation.
4 Copyright (c) 2007 - 2008, Intel Corporation
5 All rights reserved. This program and the accompanying materials
6 are licensed and made available under the terms and conditions of the BSD License
7 which accompanies this distribution. The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.php
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
15 #ifndef _PLAT_DRI_OVER_H_
16 #define _PLAT_DRI_OVER_H_
20 #include <Protocol/FirmwareVolume2.h>
21 #include <Protocol/LoadedImage.h>
22 #include <Protocol/PlatformDriverOverride.h>
23 #include <Protocol/DevicePath.h>
24 #include <Protocol/DriverBinding.h>
25 #include <Protocol/BusSpecificDriverOverride.h>
27 #include <Library/BaseLib.h>
28 #include <Library/DebugLib.h>
29 #include <Library/BaseMemoryLib.h>
30 #include <Library/PrintLib.h>
31 #include <Library/UefiRuntimeServicesTableLib.h>
32 #include <Library/UefiBootServicesTableLib.h>
33 #include <Library/UefiLib.h>
34 #include <Library/DevicePathLib.h>
35 #include <Library/MemoryAllocationLib.h>
36 #include <Library/DxeServicesTableLib.h>
37 #include <Library/PlatDriOverLib.h>
39 #include <Guid/OverrideVariable.h>
42 #define PLATFORM_OVERRIDE_ITEM_SIGNATURE EFI_SIGNATURE_32('p','d','o','i')
43 typedef struct _PLATFORM_OVERRIDE_ITEM
{
47 EFI_DEVICE_PATH_PROTOCOL
*ControllerDevicePath
;
49 /// List of DRIVER_IMAGE_INFO
51 LIST_ENTRY DriverInfoList
;
52 EFI_HANDLE LastReturnedImageHandle
;
53 } PLATFORM_OVERRIDE_ITEM
;
55 #define DRIVER_IMAGE_INFO_SIGNATURE EFI_SIGNATURE_32('p','d','i','i')
56 typedef struct _DRIVER_IMAGE_INFO
{
59 EFI_HANDLE ImageHandle
;
60 EFI_DEVICE_PATH_PROTOCOL
*DriverImagePath
;
65 #define DEVICE_PATH_STACK_ITEM_SIGNATURE EFI_SIGNATURE_32('d','p','s','i')
66 typedef struct _DEVICE_PATH_STACK_ITEM
{
69 EFI_DEVICE_PATH_PROTOCOL
*DevicePath
;
70 } DEVICE_PATH_STACK_ITEM
;
73 Push a controller device path into a globle device path list.
75 @param DevicePath The controller device path to push into stack
77 @retval EFI_SUCCESS Device path successfully pushed into the stack.
83 IN EFI_DEVICE_PATH_PROTOCOL
*DevicePath
87 Pop a controller device path from a globle device path list
89 @param DevicePath The controller device path popped from stack
91 @retval EFI_SUCCESS Controller device path successfully popped.
92 @retval EFI_NOT_FOUND Stack is empty.
98 OUT EFI_DEVICE_PATH_PROTOCOL
**DevicePath
102 Check whether a controller device path is in a globle device path list
104 @param DevicePath The controller device path to check
106 @retval TRUE DevicePath exists in the stack.
107 @retval FALSE DevicePath does not exist in the stack.
113 IN EFI_DEVICE_PATH_PROTOCOL
*DevicePath
117 Update the FV file device path if it is not valid.
119 According to a file GUID, check a Fv file device path is valid. If it is invalid,
120 try to return the valid device path.
121 FV address maybe changes for memory layout adjust from time to time, use this funciton
122 could promise the Fv file device path is right.
124 @param DevicePath On input, the FV file device path to check
125 On output, the updated valid FV file device path
126 @param FileGuid The FV file GUID
127 @param CallerImageHandle Image handle of the caller
129 @retval EFI_INVALID_PARAMETER the input DevicePath or FileGuid is invalid
131 @retval EFI_UNSUPPORTED the input DevicePath does not contain FV file
133 @retval EFI_ALREADY_STARTED the input DevicePath has pointed to FV file, it
135 @retval EFI_SUCCESS Successfully updated the invalid DevicePath,
136 and return the updated device path in DevicePath
141 UpdateFvFileDevicePath (
142 IN OUT EFI_DEVICE_PATH_PROTOCOL
**DevicePath
,
143 IN EFI_GUID
*FileGuid
,
144 IN EFI_HANDLE CallerImageHandle
148 Gets the data and size of a variable.
150 Read the EFI variable (VendorGuid/Name) and return a dynamically allocated
151 buffer, and the size of the buffer. If failure return NULL.
153 @param Name String part of EFI variable name
154 @param VendorGuid GUID part of EFI variable name
155 @param VariableSize Returns the size of the EFI variable that was
158 @return Dynamically allocated memory that contains a copy of the EFI variable.
159 Caller is responsible freeing the buffer.
160 @retval NULL Variable was not read
167 IN EFI_GUID
*VendorGuid
,
168 OUT UINTN
*VariableSize
172 Connect to the handle to a device on the device path.
174 This function will create all handles associate with every device
175 path node. If the handle associate with one device path node can not
176 be created success, then still give one chance to do the dispatch,
177 which load the missing drivers if possible.
179 @param DevicePathToConnect The device path which will be connected, it can
180 be a multi-instance device path
182 @retval EFI_SUCCESS All handles associate with every device path
183 node have been created
184 @retval EFI_OUT_OF_RESOURCES There is no resource to create new handles
185 @retval EFI_NOT_FOUND Create the handle associate with one device
192 IN EFI_DEVICE_PATH_PROTOCOL
*DevicePathToConnect