]> git.proxmox.com Git - mirror_edk2.git/blame - IntelFrameworkModulePkg/Bus/Pci/PciBus/Dxe/PciDriverOverride.c
Fix UINT64 multi const issues.
[mirror_edk2.git] / IntelFrameworkModulePkg / Bus / Pci / PciBus / Dxe / PciDriverOverride.c
CommitLineData
ead42efc 1/*++\r
2\r
3Copyright (c) 2006 - 2007, Intel Corporation\r
4All rights reserved. This program and the accompanying materials\r
5are licensed and made available under the terms and conditions of the BSD License\r
6which accompanies this distribution. The full text of the license may be found at\r
7http://opensource.org/licenses/bsd-license.php\r
8\r
9THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
10WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
11\r
12Module Name:\r
13\r
14 PciDriverOverride.c\r
15\r
16Abstract:\r
17\r
18 PCI Bus Driver\r
19\r
20Revision History\r
21\r
22--*/\r
23\r
24#include "pcibus.h"\r
25\r
26EFI_STATUS\r
27InitializePciDriverOverrideInstance (\r
28 PCI_IO_DEVICE *PciIoDevice\r
29 )\r
30/*++\r
31\r
32Routine Description:\r
33\r
34 Initializes a PCI Driver Override Instance\r
35\r
36Arguments:\r
37\r
38Returns:\r
39\r
40 None\r
41\r
42--*/\r
43// TODO: PciIoDevice - add argument and description to function comment\r
44// TODO: EFI_SUCCESS - add return value to function comment\r
45{\r
46 PciIoDevice->PciDriverOverride.GetDriver = GetDriver;\r
47 return EFI_SUCCESS;\r
48}\r
49\r
50EFI_STATUS\r
51EFIAPI\r
52GetDriver (\r
53 IN EFI_BUS_SPECIFIC_DRIVER_OVERRIDE_PROTOCOL *This,\r
54 IN OUT EFI_HANDLE *DriverImageHandle\r
55 )\r
56/*++\r
57\r
58Routine Description:\r
59\r
60 Get a overriding driver image\r
61\r
62Arguments:\r
63\r
64Returns:\r
65\r
66 None\r
67\r
68--*/\r
69// TODO: This - add argument and description to function comment\r
70// TODO: DriverImageHandle - add argument and description to function comment\r
71// TODO: EFI_SUCCESS - add return value to function comment\r
72// TODO: EFI_NOT_FOUND - add return value to function comment\r
73// TODO: EFI_SUCCESS - add return value to function comment\r
74// TODO: EFI_INVALID_PARAMETER - add return value to function comment\r
75{\r
76 PCI_IO_DEVICE *PciIoDevice;\r
77 LIST_ENTRY *CurrentLink;\r
78 PCI_DRIVER_OVERRIDE_LIST *Node;\r
79\r
80 PciIoDevice = PCI_IO_DEVICE_FROM_PCI_DRIVER_OVERRIDE_THIS (This);\r
81\r
82 CurrentLink = PciIoDevice->OptionRomDriverList.ForwardLink;\r
83\r
84 while (CurrentLink && CurrentLink != &PciIoDevice->OptionRomDriverList) {\r
85\r
86 Node = DRIVER_OVERRIDE_FROM_LINK (CurrentLink);\r
87\r
88 if (*DriverImageHandle == NULL) {\r
89\r
90 *DriverImageHandle = Node->DriverImageHandle;\r
91 return EFI_SUCCESS;\r
92 }\r
93\r
94 if (*DriverImageHandle == Node->DriverImageHandle) {\r
95\r
96 if (CurrentLink->ForwardLink == &PciIoDevice->OptionRomDriverList ||\r
97 CurrentLink->ForwardLink == NULL) {\r
98 return EFI_NOT_FOUND;\r
99 }\r
100\r
101 //\r
102 // Get next node\r
103 //\r
104 Node = DRIVER_OVERRIDE_FROM_LINK (CurrentLink->ForwardLink);\r
105 *DriverImageHandle = Node->DriverImageHandle;\r
106 return EFI_SUCCESS;\r
107 }\r
108\r
109 CurrentLink = CurrentLink->ForwardLink;\r
110 }\r
111\r
112 return EFI_INVALID_PARAMETER;\r
113}\r
114\r
115EFI_STATUS\r
116AddDriver (\r
117 IN PCI_IO_DEVICE *PciIoDevice,\r
118 IN EFI_HANDLE DriverImageHandle\r
119 )\r
120/*++\r
121\r
122Routine Description:\r
123\r
124 Add a overriding driver image\r
125\r
126Arguments:\r
127\r
128Returns:\r
129\r
130 None\r
131\r
132--*/\r
133// TODO: PciIoDevice - add argument and description to function comment\r
134// TODO: DriverImageHandle - add argument and description to function comment\r
135// TODO: EFI_OUT_OF_RESOURCES - add return value to function comment\r
136// TODO: EFI_SUCCESS - add return value to function comment\r
137// TODO: EFI_SUCCESS - add return value to function comment\r
138// TODO: EFI_SUCCESS - add return value to function comment\r
139// TODO: EFI_SUCCESS - add return value to function comment\r
140{\r
141 EFI_STATUS Status;\r
142 EFI_IMAGE_DOS_HEADER *DosHdr;\r
143 EFI_IMAGE_NT_HEADERS *PeHdr;\r
144 EFI_LOADED_IMAGE_PROTOCOL *LoadedImage;\r
145 PCI_DRIVER_OVERRIDE_LIST *Node;\r
146\r
147 Status = gBS->HandleProtocol (DriverImageHandle, &gEfiLoadedImageProtocolGuid, (VOID **) &LoadedImage);\r
148 if (EFI_ERROR (Status)) {\r
149 return Status;\r
150 }\r
151\r
152 Node = AllocatePool (sizeof (PCI_DRIVER_OVERRIDE_LIST));\r
153 if (Node == NULL) {\r
154 return EFI_OUT_OF_RESOURCES;\r
155 }\r
156\r
157 Node->Signature = DRIVER_OVERRIDE_SIGNATURE;\r
158 Node->DriverImageHandle = DriverImageHandle;\r
159\r
160 InsertTailList (&PciIoDevice->OptionRomDriverList, &(Node->Link));\r
161\r
162 PciIoDevice->BusOverride = TRUE;\r
163\r
164 DosHdr = (EFI_IMAGE_DOS_HEADER *) LoadedImage->ImageBase;\r
165 if (DosHdr->e_magic != EFI_IMAGE_DOS_SIGNATURE) {\r
166 return EFI_SUCCESS;\r
167 }\r
168\r
169 PeHdr = (EFI_IMAGE_NT_HEADERS *) ((UINTN) LoadedImage->ImageBase + DosHdr->e_lfanew);\r
170\r
171 if (PeHdr->FileHeader.Machine != EFI_IMAGE_MACHINE_EBC) {\r
172 return EFI_SUCCESS;\r
173 }\r
174 return EFI_SUCCESS;\r
175}\r