3 Copyright (c) 2006, Intel Corporation
4 All rights reserved. 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.
18 Initializes a PCI Driver Override Instance.
20 @param PciIoDevice Device instance.
22 @retval EFI_SUCCESS Operation success.
25 InitializePciDriverOverrideInstance (
26 PCI_IO_DEVICE
*PciIoDevice
29 PciIoDevice
->PciDriverOverride
.GetDriver
= GetDriver
;
34 Get a overriding driver image.
35 @param This Pointer to instance of EFI_BUS_SPECIFIC_DRIVER_OVERRIDE_PROTOCOL.
36 @param DriverImageHandle Override driver image.
38 @retval EFI_SUCCESS Success to get driver image handle.
39 @retval EFI_NOT_FOUND can not find override driver image.
40 @retval EFI_INVALID_PARAMETER Invalid parameter.
45 IN EFI_BUS_SPECIFIC_DRIVER_OVERRIDE_PROTOCOL
*This
,
46 IN OUT EFI_HANDLE
*DriverImageHandle
49 PCI_IO_DEVICE
*PciIoDevice
;
50 LIST_ENTRY
*CurrentLink
;
51 PCI_DRIVER_OVERRIDE_LIST
*Node
;
53 PciIoDevice
= PCI_IO_DEVICE_FROM_PCI_DRIVER_OVERRIDE_THIS (This
);
55 CurrentLink
= PciIoDevice
->OptionRomDriverList
.ForwardLink
;
57 while (CurrentLink
!= NULL
&& CurrentLink
!= &PciIoDevice
->OptionRomDriverList
) {
59 Node
= DRIVER_OVERRIDE_FROM_LINK (CurrentLink
);
61 if (*DriverImageHandle
== NULL
) {
63 *DriverImageHandle
= Node
->DriverImageHandle
;
67 if (*DriverImageHandle
== Node
->DriverImageHandle
) {
69 if (CurrentLink
->ForwardLink
== &PciIoDevice
->OptionRomDriverList
||
70 CurrentLink
->ForwardLink
== NULL
) {
77 Node
= DRIVER_OVERRIDE_FROM_LINK (CurrentLink
->ForwardLink
);
78 *DriverImageHandle
= Node
->DriverImageHandle
;
82 CurrentLink
= CurrentLink
->ForwardLink
;
85 return EFI_INVALID_PARAMETER
;
89 Add an overriding driver image
91 @param PciIoDevice Instance of PciIo device.
92 @param DriverImageHandle new added driver image.
94 @retval EFI_OUT_OF_RESOURCES no memory resource for new driver instance.
95 @retval EFI_SUCCESS Success add driver.
99 IN PCI_IO_DEVICE
*PciIoDevice
,
100 IN EFI_HANDLE DriverImageHandle
104 EFI_LOADED_IMAGE_PROTOCOL
*LoadedImage
;
105 PE_COFF_LOADER_IMAGE_CONTEXT ImageContext
;
106 PCI_DRIVER_OVERRIDE_LIST
*Node
;
108 Status
= gBS
->HandleProtocol (DriverImageHandle
, &gEfiLoadedImageProtocolGuid
, (VOID
**) &LoadedImage
);
109 if (EFI_ERROR (Status
)) {
113 Node
= AllocatePool (sizeof (PCI_DRIVER_OVERRIDE_LIST
));
115 return EFI_OUT_OF_RESOURCES
;
118 Node
->Signature
= DRIVER_OVERRIDE_SIGNATURE
;
119 Node
->DriverImageHandle
= DriverImageHandle
;
121 InsertTailList (&PciIoDevice
->OptionRomDriverList
, &(Node
->Link
));
123 PciIoDevice
->BusOverride
= TRUE
;
125 ImageContext
.Handle
= LoadedImage
->ImageBase
;
126 ImageContext
.ImageRead
= PeCoffLoaderImageReadFromMemory
;
129 // Get information about the image
131 Status
= PeCoffLoaderGetImageInfo (&ImageContext
);
132 if (EFI_ERROR (Status
)) {
136 if (ImageContext
.Machine
!= EFI_IMAGE_MACHINE_EBC
) {