+++ /dev/null
-/*++\r
-\r
-Copyright (c) 2006 - 2007, Intel Corporation\r
-All rights reserved. This program and the accompanying materials\r
-are licensed and made available under the terms and conditions of the BSD License\r
-which accompanies this distribution. The full text of the license may be found at\r
-http://opensource.org/licenses/bsd-license.php\r
-\r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-\r
-Module Name:\r
-\r
- PciDriverOverride.c\r
-\r
-Abstract:\r
-\r
- PCI Bus Driver\r
-\r
-Revision History\r
-\r
---*/\r
-\r
-#include "pcibus.h"\r
-\r
-EFI_STATUS\r
-InitializePciDriverOverrideInstance (\r
- PCI_IO_DEVICE *PciIoDevice\r
- )\r
-/*++\r
-\r
-Routine Description:\r
-\r
- Initializes a PCI Driver Override Instance\r
-\r
-Arguments:\r
-\r
-Returns:\r
-\r
- None\r
-\r
---*/\r
-// TODO: PciIoDevice - add argument and description to function comment\r
-// TODO: EFI_SUCCESS - add return value to function comment\r
-{\r
- PciIoDevice->PciDriverOverride.GetDriver = GetDriver;\r
- return EFI_SUCCESS;\r
-}\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-GetDriver (\r
- IN EFI_BUS_SPECIFIC_DRIVER_OVERRIDE_PROTOCOL *This,\r
- IN OUT EFI_HANDLE *DriverImageHandle\r
- )\r
-/*++\r
-\r
-Routine Description:\r
-\r
- Get a overriding driver image\r
-\r
-Arguments:\r
-\r
-Returns:\r
-\r
- None\r
-\r
---*/\r
-// TODO: This - add argument and description to function comment\r
-// TODO: DriverImageHandle - add argument and description to function comment\r
-// TODO: EFI_SUCCESS - add return value to function comment\r
-// TODO: EFI_NOT_FOUND - add return value to function comment\r
-// TODO: EFI_SUCCESS - add return value to function comment\r
-// TODO: EFI_INVALID_PARAMETER - add return value to function comment\r
-{\r
- PCI_IO_DEVICE *PciIoDevice;\r
- LIST_ENTRY *CurrentLink;\r
- PCI_DRIVER_OVERRIDE_LIST *Node;\r
-\r
- PciIoDevice = PCI_IO_DEVICE_FROM_PCI_DRIVER_OVERRIDE_THIS (This);\r
-\r
- CurrentLink = PciIoDevice->OptionRomDriverList.ForwardLink;\r
-\r
- while (CurrentLink && CurrentLink != &PciIoDevice->OptionRomDriverList) {\r
-\r
- Node = DRIVER_OVERRIDE_FROM_LINK (CurrentLink);\r
-\r
- if (*DriverImageHandle == NULL) {\r
-\r
- *DriverImageHandle = Node->DriverImageHandle;\r
- return EFI_SUCCESS;\r
- }\r
-\r
- if (*DriverImageHandle == Node->DriverImageHandle) {\r
-\r
- if (CurrentLink->ForwardLink == &PciIoDevice->OptionRomDriverList ||\r
- CurrentLink->ForwardLink == NULL) {\r
- return EFI_NOT_FOUND;\r
- }\r
-\r
- //\r
- // Get next node\r
- //\r
- Node = DRIVER_OVERRIDE_FROM_LINK (CurrentLink->ForwardLink);\r
- *DriverImageHandle = Node->DriverImageHandle;\r
- return EFI_SUCCESS;\r
- }\r
-\r
- CurrentLink = CurrentLink->ForwardLink;\r
- }\r
-\r
- return EFI_INVALID_PARAMETER;\r
-}\r
-\r
-EFI_STATUS\r
-AddDriver (\r
- IN PCI_IO_DEVICE *PciIoDevice,\r
- IN EFI_HANDLE DriverImageHandle\r
- )\r
-/*++\r
-\r
-Routine Description:\r
-\r
- Add a overriding driver image\r
-\r
-Arguments:\r
-\r
-Returns:\r
-\r
- None\r
-\r
---*/\r
-// TODO: PciIoDevice - add argument and description to function comment\r
-// TODO: DriverImageHandle - add argument and description to function comment\r
-// TODO: EFI_OUT_OF_RESOURCES - add return value to function comment\r
-// TODO: EFI_SUCCESS - add return value to function comment\r
-// TODO: EFI_SUCCESS - add return value to function comment\r
-// TODO: EFI_SUCCESS - add return value to function comment\r
-// TODO: EFI_SUCCESS - add return value to function comment\r
-{\r
- EFI_STATUS Status;\r
- EFI_IMAGE_DOS_HEADER *DosHdr;\r
- EFI_IMAGE_NT_HEADERS *PeHdr;\r
- EFI_LOADED_IMAGE_PROTOCOL *LoadedImage;\r
- PCI_DRIVER_OVERRIDE_LIST *Node;\r
-\r
- Status = gBS->HandleProtocol (DriverImageHandle, &gEfiLoadedImageProtocolGuid, (VOID **) &LoadedImage);\r
- if (EFI_ERROR (Status)) {\r
- return Status;\r
- }\r
-\r
- Node = AllocatePool (sizeof (PCI_DRIVER_OVERRIDE_LIST));\r
- if (Node == NULL) {\r
- return EFI_OUT_OF_RESOURCES;\r
- }\r
-\r
- Node->Signature = DRIVER_OVERRIDE_SIGNATURE;\r
- Node->DriverImageHandle = DriverImageHandle;\r
-\r
- InsertTailList (&PciIoDevice->OptionRomDriverList, &(Node->Link));\r
-\r
- PciIoDevice->BusOverride = TRUE;\r
-\r
- DosHdr = (EFI_IMAGE_DOS_HEADER *) LoadedImage->ImageBase;\r
- if (DosHdr->e_magic != EFI_IMAGE_DOS_SIGNATURE) {\r
- return EFI_SUCCESS;\r
- }\r
-\r
- PeHdr = (EFI_IMAGE_NT_HEADERS *) ((UINTN) LoadedImage->ImageBase + DosHdr->e_lfanew);\r
-\r
- if (PeHdr->FileHeader.Machine != EFI_IMAGE_MACHINE_EBC) {\r
- return EFI_SUCCESS;\r
- }\r
- return EFI_SUCCESS;\r
-}\r