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 InitializePciDriverOverrideInstance (
19 PCI_IO_DEVICE
*PciIoDevice
25 Initializes a PCI Driver Override Instance
34 // TODO: PciIoDevice - add argument and description to function comment
35 // TODO: EFI_SUCCESS - add return value to function comment
37 PciIoDevice
->PciDriverOverride
.GetDriver
= GetDriver
;
44 IN EFI_BUS_SPECIFIC_DRIVER_OVERRIDE_PROTOCOL
*This
,
45 IN OUT EFI_HANDLE
*DriverImageHandle
51 Get a overriding driver image
60 // TODO: This - add argument and description to function comment
61 // TODO: DriverImageHandle - add argument and description to function comment
62 // TODO: EFI_SUCCESS - add return value to function comment
63 // TODO: EFI_NOT_FOUND - add return value to function comment
64 // TODO: EFI_SUCCESS - add return value to function comment
65 // TODO: EFI_INVALID_PARAMETER - add return value to function comment
67 PCI_IO_DEVICE
*PciIoDevice
;
68 LIST_ENTRY
*CurrentLink
;
69 PCI_DRIVER_OVERRIDE_LIST
*Node
;
71 PciIoDevice
= PCI_IO_DEVICE_FROM_PCI_DRIVER_OVERRIDE_THIS (This
);
73 CurrentLink
= PciIoDevice
->OptionRomDriverList
.ForwardLink
;
75 while (CurrentLink
&& CurrentLink
!= &PciIoDevice
->OptionRomDriverList
) {
77 Node
= DRIVER_OVERRIDE_FROM_LINK (CurrentLink
);
79 if (*DriverImageHandle
== NULL
) {
81 *DriverImageHandle
= Node
->DriverImageHandle
;
85 if (*DriverImageHandle
== Node
->DriverImageHandle
) {
87 if (CurrentLink
->ForwardLink
== &PciIoDevice
->OptionRomDriverList
||
88 CurrentLink
->ForwardLink
== NULL
) {
95 Node
= DRIVER_OVERRIDE_FROM_LINK (CurrentLink
->ForwardLink
);
96 *DriverImageHandle
= Node
->DriverImageHandle
;
100 CurrentLink
= CurrentLink
->ForwardLink
;
103 return EFI_INVALID_PARAMETER
;
108 IN PCI_IO_DEVICE
*PciIoDevice
,
109 IN EFI_HANDLE DriverImageHandle
115 Add a overriding driver image
124 // TODO: PciIoDevice - add argument and description to function comment
125 // TODO: DriverImageHandle - add argument and description to function comment
126 // TODO: EFI_OUT_OF_RESOURCES - add return value to function comment
127 // TODO: EFI_SUCCESS - add return value to function comment
128 // TODO: EFI_SUCCESS - add return value to function comment
129 // TODO: EFI_SUCCESS - add return value to function comment
130 // TODO: EFI_SUCCESS - add return value to function comment
133 EFI_IMAGE_DOS_HEADER
*DosHdr
;
134 EFI_IMAGE_NT_HEADERS
*PeHdr
;
135 EFI_LOADED_IMAGE_PROTOCOL
*LoadedImage
;
136 PCI_DRIVER_OVERRIDE_LIST
*Node
;
138 Status
= gBS
->HandleProtocol (DriverImageHandle
, &gEfiLoadedImageProtocolGuid
, (VOID
**) &LoadedImage
);
139 if (EFI_ERROR (Status
)) {
143 Node
= AllocatePool (sizeof (PCI_DRIVER_OVERRIDE_LIST
));
145 return EFI_OUT_OF_RESOURCES
;
148 Node
->Signature
= DRIVER_OVERRIDE_SIGNATURE
;
149 Node
->DriverImageHandle
= DriverImageHandle
;
151 InsertTailList (&PciIoDevice
->OptionRomDriverList
, &(Node
->Link
));
153 PciIoDevice
->BusOverride
= TRUE
;
155 DosHdr
= (EFI_IMAGE_DOS_HEADER
*) LoadedImage
->ImageBase
;
156 if (DosHdr
->e_magic
!= EFI_IMAGE_DOS_SIGNATURE
) {
160 PeHdr
= (EFI_IMAGE_NT_HEADERS
*) ((UINTN
) LoadedImage
->ImageBase
+ DosHdr
->e_lfanew
);
162 if (PeHdr
->FileHeader
.Machine
!= EFI_IMAGE_MACHINE_EBC
) {