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