3 Copyright (c) 2005 - 2007, Intel Corporation. All rights reserved.<BR>
4 This program and the accompanying materials
5 are licensed and made available under the terms and conditions of the BSD License
6 which accompanies this distribution. The full text of the license may be found at
7 http://opensource.org/licenses/bsd-license.php
9 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
10 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
29 IN EFI_BUS_SPECIFIC_DRIVER_OVERRIDE_PROTOCOL
*This
,
30 IN OUT EFI_HANDLE
*DriverImageHandle
36 InitializePciDriverOverrideInstance (
37 PCI_IO_DEVICE
*PciIoDevice
43 Initializes a PCI Driver Override Instance
54 PciIoDevice
->PciDriverOverride
.GetDriver
= GetDriver
;
61 IN EFI_BUS_SPECIFIC_DRIVER_OVERRIDE_PROTOCOL
*This
,
62 IN OUT EFI_HANDLE
*DriverImageHandle
68 Get a overriding driver image
78 PCI_IO_DEVICE
*PciIoDevice
;
79 LIST_ENTRY
*CurrentLink
;
80 PCI_DRIVER_OVERRIDE_LIST
*Node
;
82 PciIoDevice
= PCI_IO_DEVICE_FROM_PCI_DRIVER_OVERRIDE_THIS (This
);
84 CurrentLink
= PciIoDevice
->OptionRomDriverList
.ForwardLink
;
86 while (CurrentLink
&& CurrentLink
!= &PciIoDevice
->OptionRomDriverList
) {
88 Node
= DRIVER_OVERRIDE_FROM_LINK (CurrentLink
);
90 if (*DriverImageHandle
== NULL
) {
92 *DriverImageHandle
= Node
->DriverImageHandle
;
96 if (*DriverImageHandle
== Node
->DriverImageHandle
) {
98 if (CurrentLink
->ForwardLink
== &PciIoDevice
->OptionRomDriverList
||
99 CurrentLink
->ForwardLink
== NULL
) {
100 return EFI_NOT_FOUND
;
106 Node
= DRIVER_OVERRIDE_FROM_LINK (CurrentLink
->ForwardLink
);
107 *DriverImageHandle
= Node
->DriverImageHandle
;
111 CurrentLink
= CurrentLink
->ForwardLink
;
114 return EFI_INVALID_PARAMETER
;
119 IN PCI_IO_DEVICE
*PciIoDevice
,
120 IN EFI_HANDLE DriverImageHandle
126 Add a overriding driver image
138 EFI_LOADED_IMAGE_PROTOCOL
*LoadedImage
;
139 PE_COFF_LOADER_IMAGE_CONTEXT ImageContext
;
140 PCI_DRIVER_OVERRIDE_LIST
*Node
;
142 Status
= gBS
->HandleProtocol (DriverImageHandle
, &gEfiLoadedImageProtocolGuid
, (VOID
**) &LoadedImage
);
143 if (EFI_ERROR (Status
)) {
147 Node
= AllocatePool (sizeof (PCI_DRIVER_OVERRIDE_LIST
));
149 return EFI_OUT_OF_RESOURCES
;
152 Node
->Signature
= DRIVER_OVERRIDE_SIGNATURE
;
153 Node
->DriverImageHandle
= DriverImageHandle
;
155 InsertTailList (&PciIoDevice
->OptionRomDriverList
, &(Node
->Link
));
157 PciIoDevice
->BusOverride
= TRUE
;
160 ImageContext
.Handle
= LoadedImage
->ImageBase
;
161 ImageContext
.ImageRead
= PeCoffLoaderImageReadFromMemory
;
164 // Get information about the image
166 Status
= PeCoffLoaderGetImageInfo (&ImageContext
);
167 if (EFI_ERROR (Status
)) {
171 if (ImageContext
.Machine
!= EFI_IMAGE_MACHINE_EBC
) {