mirror of https://github.com/acidanthera/audk.git
Clean up meta data and code scrub for PCI Bus module.
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@8624 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
parent
03476bf384
commit
48a9ea7b1b
|
@ -1,7 +1,7 @@
|
|||
/** @file
|
||||
Driver Binding functions for PCI bus module.
|
||||
Driver Binding functions for PCI Bus module.
|
||||
|
||||
Copyright (c) 2006, Intel Corporation
|
||||
Copyright (c) 2006 - 2009, Intel Corporation
|
||||
All rights reserved. This program and the accompanying materials
|
||||
are licensed and made available under the terms and conditions of the BSD License
|
||||
which accompanies this distribution. The full text of the license may be found at
|
||||
|
@ -12,13 +12,11 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
|||
|
||||
**/
|
||||
|
||||
|
||||
#include "PciBus.h"
|
||||
|
||||
//
|
||||
// PCI Bus Driver Global Variables
|
||||
//
|
||||
|
||||
EFI_DRIVER_BINDING_PROTOCOL gPciBusDriverBinding = {
|
||||
PciBusDriverBindingSupported,
|
||||
PciBusDriverBindingStart,
|
||||
|
@ -28,26 +26,32 @@ EFI_DRIVER_BINDING_PROTOCOL gPciBusDriverBinding = {
|
|||
NULL
|
||||
};
|
||||
|
||||
EFI_INCOMPATIBLE_PCI_DEVICE_SUPPORT_PROTOCOL *gEfiIncompatiblePciDeviceSupport = NULL;
|
||||
EFI_HANDLE gPciHostBrigeHandles[PCI_MAX_HOST_BRIDGE_NUM];
|
||||
UINTN gPciHostBridgeNumber;
|
||||
BOOLEAN gFullEnumeration;
|
||||
UINT64 gAllOne = 0xFFFFFFFFFFFFFFFFULL;
|
||||
UINT64 gAllZero = 0;
|
||||
EFI_INCOMPATIBLE_PCI_DEVICE_SUPPORT_PROTOCOL *gEfiIncompatiblePciDeviceSupport = NULL;
|
||||
UINTN gPciHostBridgeNumber = 0;
|
||||
BOOLEAN gFullEnumeration = TRUE;
|
||||
UINT64 gAllOne = 0xFFFFFFFFFFFFFFFFULL;
|
||||
UINT64 gAllZero = 0;
|
||||
|
||||
EFI_PCI_PLATFORM_PROTOCOL *gPciPlatformProtocol;
|
||||
|
||||
//
|
||||
// PCI Bus Driver Support Functions
|
||||
//
|
||||
GLOBAL_REMOVE_IF_UNREFERENCED EFI_PCI_HOTPLUG_REQUEST_PROTOCOL mPciHotPlugRequest = {
|
||||
PciHotPlugRequestNotify
|
||||
};
|
||||
|
||||
/**
|
||||
Initialize the global variables
|
||||
publish the driver binding protocol
|
||||
The Entry Point for PCI Bus module. The user code starts with this function.
|
||||
|
||||
@param[in] ImageHandle,
|
||||
@param[in] *SystemTable
|
||||
Installs driver module protocols and. Creates virtual device handles for ConIn,
|
||||
ConOut, and StdErr. Installs Simple Text In protocol, Simple Text In Ex protocol,
|
||||
Simple Pointer protocol, Absolute Pointer protocol on those virtual handlers.
|
||||
Installs Graphics Output protocol and/or UGA Draw protocol if needed.
|
||||
|
||||
@retval status of installing driver binding component name protocol.
|
||||
@param[in] ImageHandle The firmware allocated handle for the EFI image.
|
||||
@param[in] SystemTable A pointer to the EFI System Table.
|
||||
|
||||
@retval EFI_SUCCESS The entry point is executed successfully.
|
||||
@retval other Some error occurs when executing this entry point.
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
|
@ -58,13 +62,13 @@ PciBusEntryPoint (
|
|||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
|
||||
EFI_HANDLE Handle;
|
||||
|
||||
//
|
||||
// Initializes PCI devices pool
|
||||
//
|
||||
InitializePciDevicePool ();
|
||||
|
||||
gFullEnumeration = TRUE;
|
||||
|
||||
gPciHostBridgeNumber = 0;
|
||||
|
||||
//
|
||||
// Install driver model protocol(s).
|
||||
//
|
||||
|
@ -78,8 +82,19 @@ PciBusEntryPoint (
|
|||
);
|
||||
ASSERT_EFI_ERROR (Status);
|
||||
|
||||
InstallHotPlugRequestProtocol (&Status);
|
||||
|
||||
if (FeaturePcdGet (PcdPciBusHotplugDeviceSupport)) {
|
||||
//
|
||||
// If Hot Plug is supported, install EFI PCI Hot Plug Request protocol.
|
||||
//
|
||||
Handle = NULL;
|
||||
Status = gBS->InstallProtocolInterface (
|
||||
&Handle,
|
||||
&gEfiPciHotPlugRequestProtocolGuid,
|
||||
EFI_NATIVE_INTERFACE,
|
||||
&mPciHotPlugRequest
|
||||
);
|
||||
}
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
@ -88,13 +103,13 @@ PciBusEntryPoint (
|
|||
than contains a gEfiPciRootBridgeIoProtocolGuid protocol can be supported.
|
||||
|
||||
@param This Protocol instance pointer.
|
||||
@param ControllerHandle Handle of device to test
|
||||
@param RemainingDevicePath Optional parameter use to pick a specific child
|
||||
@param Controller Handle of device to test.
|
||||
@param RemainingDevicePath Optional parameter use to pick a specific child.
|
||||
device to start.
|
||||
|
||||
@retval EFI_SUCCESS This driver supports this device
|
||||
@retval EFI_ALREADY_STARTED This driver is already running on this device
|
||||
@retval other This driver does not support this device
|
||||
@retval EFI_SUCCESS This driver supports this device.
|
||||
@retval EFI_ALREADY_STARTED This driver is already running on this device.
|
||||
@retval other This driver does not support this device.
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
|
@ -175,13 +190,13 @@ PciBusDriverBindingSupported (
|
|||
all device under PCI bus.
|
||||
|
||||
@param This Protocol instance pointer.
|
||||
@param ControllerHandle Handle of device to bind driver to
|
||||
@param RemainingDevicePath Optional parameter use to pick a specific child
|
||||
@param Controller Handle of device to bind driver to.
|
||||
@param RemainingDevicePath Optional parameter use to pick a specific child.
|
||||
device to start.
|
||||
|
||||
@retval EFI_SUCCESS This driver is added to ControllerHandle
|
||||
@retval EFI_ALREADY_STARTED This driver is already running on ControllerHandle
|
||||
@retval other This driver does not support this device
|
||||
@retval EFI_SUCCESS This driver is added to ControllerHandle.
|
||||
@retval EFI_ALREADY_STARTED This driver is already running on ControllerHandle.
|
||||
@retval other This driver does not support this device.
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
|
@ -237,13 +252,13 @@ PciBusDriverBindingStart (
|
|||
created by this driver.
|
||||
|
||||
@param This Protocol instance pointer.
|
||||
@param ControllerHandle Handle of device to stop driver on
|
||||
@param Controller Handle of device to stop driver on.
|
||||
@param NumberOfChildren Number of Handles in ChildHandleBuffer. If number of
|
||||
children is zero stop the entire bus driver.
|
||||
@param ChildHandleBuffer List of Child Handles to Stop.
|
||||
|
||||
@retval EFI_SUCCESS This driver is removed ControllerHandle
|
||||
@retval other This driver was not removed from this device
|
||||
@retval EFI_SUCCESS This driver is removed ControllerHandle.
|
||||
@retval other This driver was not removed from this device.
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
/** @file
|
||||
Header files and data structures needed by PCI Bus module.
|
||||
|
||||
Copyright (c) 2006 - 2009, Intel Corporation
|
||||
All rights reserved. This program and the accompanying materials
|
||||
|
@ -15,10 +16,8 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
|||
#ifndef _EFI_PCI_BUS_H_
|
||||
#define _EFI_PCI_BUS_H_
|
||||
|
||||
|
||||
#include <FrameworkDxe.h>
|
||||
|
||||
|
||||
#include <Protocol/LoadedImage.h>
|
||||
#include <Protocol/PciHostBridgeResourceAllocation.h>
|
||||
#include <Protocol/PciIo.h>
|
||||
|
@ -30,7 +29,6 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
|||
#include <Protocol/PciHotPlugInit.h>
|
||||
#include <Protocol/Decompress.h>
|
||||
#include <Protocol/BusSpecificDriverOverride.h>
|
||||
#include <Protocol/UgaIo.h>
|
||||
#include <Protocol/IncompatiblePciDeviceSupport.h>
|
||||
|
||||
#include <Library/DebugLib.h>
|
||||
|
@ -49,20 +47,23 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
|||
#include <IndustryStandard/Pci.h>
|
||||
#include <IndustryStandard/PeImage.h>
|
||||
#include <IndustryStandard/Acpi.h>
|
||||
|
||||
typedef struct _PCI_IO_DEVICE PCI_IO_DEVICE;
|
||||
typedef struct _PCI_BAR PCI_BAR;
|
||||
typedef enum _PCI_BAR_TYPE PCI_BAR_TYPE;
|
||||
|
||||
#include "ComponentName.h"
|
||||
|
||||
|
||||
//
|
||||
// Global Variables
|
||||
//
|
||||
extern EFI_INCOMPATIBLE_PCI_DEVICE_SUPPORT_PROTOCOL *gEfiIncompatiblePciDeviceSupport;
|
||||
extern EFI_DRIVER_BINDING_PROTOCOL gPciBusDriverBinding;
|
||||
extern EFI_COMPONENT_NAME_PROTOCOL gPciBusComponentName;
|
||||
extern EFI_COMPONENT_NAME2_PROTOCOL gPciBusComponentName2;
|
||||
|
||||
//
|
||||
// Driver Produced Protocol Prototypes
|
||||
//
|
||||
#include "PciIo.h"
|
||||
#include "PciCommand.h"
|
||||
#include "PciDeviceSupport.h"
|
||||
#include "PciEnumerator.h"
|
||||
#include "PciEnumeratorSupport.h"
|
||||
#include "PciDriverOverride.h"
|
||||
#include "PciRomTable.h"
|
||||
#include "PciOptionRomSupport.h"
|
||||
#include "PciPowerManagement.h"
|
||||
#include "PciHotPlugSupport.h"
|
||||
#include "PciLib.h"
|
||||
|
||||
#define VGABASE1 0x3B0
|
||||
#define VGALIMIT1 0x3BB
|
||||
|
@ -73,7 +74,7 @@ extern EFI_COMPONENT_NAME2_PROTOCOL gPciBusComponentName2;
|
|||
#define ISABASE 0x100
|
||||
#define ISALIMIT 0x3FF
|
||||
|
||||
typedef enum {
|
||||
enum _PCI_BAR_TYPE {
|
||||
PciBarTypeUnknown = 0,
|
||||
PciBarTypeIo16,
|
||||
PciBarTypeIo32,
|
||||
|
@ -84,9 +85,12 @@ typedef enum {
|
|||
PciBarTypeIo,
|
||||
PciBarTypeMem,
|
||||
PciBarTypeMaxType
|
||||
} PCI_BAR_TYPE;
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
//
|
||||
// PCI BAR parameters
|
||||
//
|
||||
struct _PCI_BAR {
|
||||
UINT64 BaseAddress;
|
||||
UINT64 Length;
|
||||
UINT64 Alignment;
|
||||
|
@ -94,7 +98,7 @@ typedef struct {
|
|||
BOOLEAN Prefetchable;
|
||||
UINT8 MemType;
|
||||
UINT8 Offset;
|
||||
} PCI_BAR;
|
||||
};
|
||||
|
||||
#define PPB_BAR_0 0
|
||||
#define PPB_BAR_1 1
|
||||
|
@ -110,8 +114,6 @@ typedef struct {
|
|||
#define P2C_IO_1 3
|
||||
#define P2C_IO_2 4
|
||||
|
||||
#define PCI_IO_DEVICE_SIGNATURE SIGNATURE_32 ('p', 'c', 'i', 'o')
|
||||
|
||||
#define EFI_BRIDGE_IO32_DECODE_SUPPORTED 0x0001
|
||||
#define EFI_BRIDGE_PMEM32_DECODE_SUPPORTED 0x0002
|
||||
#define EFI_BRIDGE_PMEM64_DECODE_SUPPORTED 0x0004
|
||||
|
@ -128,7 +130,7 @@ typedef struct {
|
|||
#define EFI_SET_SUPPORTS 0
|
||||
#define EFI_SET_ATTRIBUTES 1
|
||||
|
||||
typedef struct _PCI_IO_DEVICE PCI_IO_DEVICE;
|
||||
#define PCI_IO_DEVICE_SIGNATURE SIGNATURE_32 ('p', 'c', 'i', 'o')
|
||||
|
||||
struct _PCI_IO_DEVICE {
|
||||
UINT32 Signature;
|
||||
|
@ -215,7 +217,7 @@ struct _PCI_IO_DEVICE {
|
|||
BOOLEAN BusOverride;
|
||||
|
||||
//
|
||||
// A list tracking reserved resource on a bridge device
|
||||
// A list tracking reserved resource on a bridge device
|
||||
//
|
||||
LIST_ENTRY ReservedResourceList;
|
||||
|
||||
|
@ -231,7 +233,6 @@ struct _PCI_IO_DEVICE {
|
|||
|
||||
};
|
||||
|
||||
|
||||
#define PCI_IO_DEVICE_FROM_PCI_IO_THIS(a) \
|
||||
CR (a, PCI_IO_DEVICE, PciIo, PCI_IO_DEVICE_SIGNATURE)
|
||||
|
||||
|
@ -244,39 +245,40 @@ struct _PCI_IO_DEVICE {
|
|||
#define PCI_IO_DEVICE_FROM_LOAD_FILE2_THIS(a) \
|
||||
CR (a, PCI_IO_DEVICE, LoadFile2, PCI_IO_DEVICE_SIGNATURE)
|
||||
|
||||
|
||||
|
||||
//
|
||||
// Global Variables
|
||||
//
|
||||
extern LIST_ENTRY gPciDevicePool;
|
||||
extern EFI_INCOMPATIBLE_PCI_DEVICE_SUPPORT_PROTOCOL *gEfiIncompatiblePciDeviceSupport;
|
||||
extern EFI_DRIVER_BINDING_PROTOCOL gPciBusDriverBinding;
|
||||
extern EFI_COMPONENT_NAME_PROTOCOL gPciBusComponentName;
|
||||
extern EFI_COMPONENT_NAME2_PROTOCOL gPciBusComponentName2;
|
||||
extern BOOLEAN gFullEnumeration;
|
||||
extern UINTN gPciHostBridgeNumber;
|
||||
extern EFI_HANDLE gPciHostBrigeHandles[PCI_MAX_HOST_BRIDGE_NUM];
|
||||
extern UINT64 gAllOne;
|
||||
extern UINT64 gAllZero;
|
||||
|
||||
extern EFI_PCI_PLATFORM_PROTOCOL *gPciPlatformProtocol;
|
||||
|
||||
#include "PciIo.h"
|
||||
#include "PciCommand.h"
|
||||
#include "PciDeviceSupport.h"
|
||||
#include "PciEnumerator.h"
|
||||
#include "PciEnumeratorSupport.h"
|
||||
#include "PciDriverOverride.h"
|
||||
#include "PciRomTable.h"
|
||||
#include "PciOptionRomSupport.h"
|
||||
#include "PciPowerManagement.h"
|
||||
#include "PciHotPlugSupport.h"
|
||||
#include "PciLib.h"
|
||||
|
||||
//
|
||||
// PCI Bus Support Function Prototypes
|
||||
//
|
||||
/**
|
||||
Macro that checks whether device is a GFX device.
|
||||
|
||||
@param _p Specified device.
|
||||
|
||||
@retval TRUE Device is a a GFX device.
|
||||
@retval FALSE Device is not a a GFX device.
|
||||
|
||||
**/
|
||||
#define IS_PCI_GFX(_p) IS_CLASS2 (_p, PCI_CLASS_DISPLAY, PCI_CLASS_DISPLAY_OTHER)
|
||||
|
||||
/**
|
||||
Test to see if this driver supports ControllerHandle. Any ControllerHandle
|
||||
than contains a gEfiPciRootBridgeIoProtocolGuid protocol can be supported.
|
||||
|
||||
@param This Protocol instance pointer.
|
||||
@param ControllerHandle Handle of device to test.
|
||||
@param Controller Handle of device to test.
|
||||
@param RemainingDevicePath Optional parameter use to pick a specific child.
|
||||
device to start.
|
||||
|
||||
|
@ -298,7 +300,7 @@ PciBusDriverBindingSupported (
|
|||
all device under PCI bus.
|
||||
|
||||
@param This Protocol instance pointer.
|
||||
@param ControllerHandle Handle of device to bind driver to.
|
||||
@param Controller Handle of device to bind driver to.
|
||||
@param RemainingDevicePath Optional parameter use to pick a specific child.
|
||||
device to start.
|
||||
|
||||
|
@ -320,7 +322,7 @@ PciBusDriverBindingStart (
|
|||
created by this driver.
|
||||
|
||||
@param This Protocol instance pointer.
|
||||
@param ControllerHandle Handle of device to stop driver on.
|
||||
@param Controller Handle of device to stop driver on.
|
||||
@param NumberOfChildren Number of Handles in ChildHandleBuffer. If number of
|
||||
children is zero stop the entire bus driver.
|
||||
@param ChildHandleBuffer List of Child Handles to Stop.
|
||||
|
@ -338,6 +340,4 @@ PciBusDriverBindingStop (
|
|||
IN EFI_HANDLE *ChildHandleBuffer
|
||||
);
|
||||
|
||||
#define IS_PCI_GFX(_p) IS_CLASS2 (_p, PCI_CLASS_DISPLAY, PCI_CLASS_DISPLAY_OTHER)
|
||||
|
||||
#endif
|
||||
|
|
|
@ -3,7 +3,8 @@
|
|||
#
|
||||
# PCI bus driver. This module will probe all PCI devices and allocate MMIO and IO
|
||||
# space for these devices. Please use PCD feature flag PcdPciBusHotplugDeviceSupport to enable
|
||||
# support hot plug.
|
||||
# hot plug supporting.
|
||||
#
|
||||
# Copyright (c) 2006 - 2009, Intel Corporation
|
||||
#
|
||||
# All rights reserved. This program and the accompanying materials
|
||||
|
@ -86,18 +87,18 @@
|
|||
PeCoffLib
|
||||
|
||||
[Protocols]
|
||||
gEfiPciHotPlugRequestProtocolGuid # PROTOCOL ALWAYS_PRODUCED
|
||||
gEfiBusSpecificDriverOverrideProtocolGuid # PROTOCOL BY_START
|
||||
gEfiPciIoProtocolGuid # PROTOCOL BY_START
|
||||
gEfiLoadedImageProtocolGuid # PROTOCOL TO_START
|
||||
gEfiDecompressProtocolGuid # PROTOCOL TO_START
|
||||
gEfiPciHotPlugInitProtocolGuid # PROTOCOL TO_START
|
||||
gEfiPciHostBridgeResourceAllocationProtocolGuid # PROTOCOL TO_START
|
||||
gEfiPciPlatformProtocolGuid # PROTOCOL TO_START
|
||||
gEfiPciRootBridgeIoProtocolGuid # PROTOCOL TO_START
|
||||
gEfiDevicePathProtocolGuid # PROTOCOL TO_START
|
||||
gEfiIncompatiblePciDeviceSupportProtocolGuid # PROTOCOL TO_START
|
||||
gEfiLoadFile2ProtocolGuid # SOMETIMES_CONSUMED
|
||||
gEfiPciHotPlugRequestProtocolGuid ## BY_START
|
||||
gEfiPciIoProtocolGuid ## BY_START
|
||||
gEfiDevicePathProtocolGuid ## BY_START
|
||||
gEfiBusSpecificDriverOverrideProtocolGuid ## CONSUMED
|
||||
gEfiLoadedImageProtocolGuid ## CONSUMED
|
||||
gEfiDecompressProtocolGuid ## CONSUMED
|
||||
gEfiPciHotPlugInitProtocolGuid ## CONSUMED
|
||||
gEfiPciHostBridgeResourceAllocationProtocolGuid ## CONSUMED
|
||||
gEfiPciPlatformProtocolGuid ## CONSUMED
|
||||
gEfiPciRootBridgeIoProtocolGuid ## CONSUMED
|
||||
gEfiIncompatiblePciDeviceSupportProtocolGuid ## CONSUMED
|
||||
gEfiLoadFile2ProtocolGuid ## CONSUMED
|
||||
|
||||
[FeaturePcd.common]
|
||||
gEfiIntelFrameworkModulePkgTokenSpaceGuid.PcdPciBusHotplugDeviceSupport
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
/** @file
|
||||
Supporting functions implementaion for PCI devices management.
|
||||
|
||||
Copyright (c) 2006 - 2009, Intel Corporation
|
||||
All rights reserved. This program and the accompanying materials
|
||||
|
@ -11,124 +12,112 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
|||
|
||||
**/
|
||||
|
||||
|
||||
#include "PciBus.h"
|
||||
#include "PciDeviceSupport.h"
|
||||
|
||||
//
|
||||
// This device structure is serviced as a header.
|
||||
// Its Next field points to the first root bridge device node
|
||||
// Its next field points to the first root bridge device node.
|
||||
//
|
||||
LIST_ENTRY gPciDevicePool;
|
||||
LIST_ENTRY mPciDevicePool;
|
||||
|
||||
/**
|
||||
Initialize the gPciDevicePool.
|
||||
Initialize the PCI devices pool.
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
VOID
|
||||
InitializePciDevicePool (
|
||||
VOID
|
||||
)
|
||||
{
|
||||
InitializeListHead (&gPciDevicePool);
|
||||
|
||||
return EFI_SUCCESS;
|
||||
InitializeListHead (&mPciDevicePool);
|
||||
}
|
||||
|
||||
/**
|
||||
Insert a root bridge into PCI device pool
|
||||
Insert a root bridge into PCI device pool.
|
||||
|
||||
@param RootBridge - A pointer to the PCI_IO_DEVICE.
|
||||
@param RootBridge A pointer to the PCI_IO_DEVICE.
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
VOID
|
||||
InsertRootBridge (
|
||||
PCI_IO_DEVICE *RootBridge
|
||||
IN PCI_IO_DEVICE *RootBridge
|
||||
)
|
||||
{
|
||||
|
||||
InsertTailList (&gPciDevicePool, &(RootBridge->Link));
|
||||
|
||||
return EFI_SUCCESS;
|
||||
InsertTailList (&mPciDevicePool, &(RootBridge->Link));
|
||||
}
|
||||
|
||||
/**
|
||||
This function is used to insert a PCI device node under
|
||||
a bridge
|
||||
a bridge.
|
||||
|
||||
@param Bridge A pointer to the PCI_IO_DEVICE.
|
||||
@param PciDeviceNode A pointer to the PCI_IO_DEVICE.
|
||||
@param Bridge The PCI bridge.
|
||||
@param PciDeviceNode The PCI device needs inserting.
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
VOID
|
||||
InsertPciDevice (
|
||||
PCI_IO_DEVICE *Bridge,
|
||||
PCI_IO_DEVICE *PciDeviceNode
|
||||
IN PCI_IO_DEVICE *Bridge,
|
||||
IN PCI_IO_DEVICE *PciDeviceNode
|
||||
)
|
||||
{
|
||||
|
||||
InsertTailList (&Bridge->ChildList, &(PciDeviceNode->Link));
|
||||
PciDeviceNode->Parent = Bridge;
|
||||
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
/**
|
||||
Destroy root bridge and remove it from deivce tree.
|
||||
|
||||
@param RootBridge The bridge want to be removed.
|
||||
@param RootBridge The bridge want to be removed.
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
VOID
|
||||
DestroyRootBridge (
|
||||
IN PCI_IO_DEVICE *RootBridge
|
||||
IN PCI_IO_DEVICE *RootBridge
|
||||
)
|
||||
{
|
||||
DestroyPciDeviceTree (RootBridge);
|
||||
|
||||
FreePciDevice (RootBridge);
|
||||
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
/**
|
||||
Destroy a pci device node.
|
||||
Also all direct or indirect allocated resource for this node will be freed.
|
||||
|
||||
@param PciIoDevice A pointer to the PCI_IO_DEVICE.
|
||||
All direct or indirect allocated resource for this node will be freed.
|
||||
|
||||
@param PciIoDevice A pointer to the PCI_IO_DEVICE to be destoried.
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
VOID
|
||||
FreePciDevice (
|
||||
IN PCI_IO_DEVICE *PciIoDevice
|
||||
IN PCI_IO_DEVICE *PciIoDevice
|
||||
)
|
||||
{
|
||||
|
||||
ASSERT (PciIoDevice != NULL);
|
||||
//
|
||||
// Assume all children have been removed underneath this device
|
||||
//
|
||||
if (PciIoDevice->ResourcePaddingDescriptors != NULL) {
|
||||
gBS->FreePool (PciIoDevice->ResourcePaddingDescriptors);
|
||||
FreePool (PciIoDevice->ResourcePaddingDescriptors);
|
||||
}
|
||||
|
||||
if (PciIoDevice->DevicePath != NULL) {
|
||||
gBS->FreePool (PciIoDevice->DevicePath);
|
||||
FreePool (PciIoDevice->DevicePath);
|
||||
}
|
||||
|
||||
gBS->FreePool (PciIoDevice);
|
||||
|
||||
return EFI_SUCCESS;
|
||||
FreePool (PciIoDevice);
|
||||
}
|
||||
|
||||
/**
|
||||
Destroy all the pci device node under the bridge.
|
||||
Bridge itself is not included.
|
||||
|
||||
@param Bridge A pointer to the PCI_IO_DEVICE.
|
||||
@param Bridge A pointer to the PCI_IO_DEVICE.
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
VOID
|
||||
DestroyPciDeviceTree (
|
||||
IN PCI_IO_DEVICE *Bridge
|
||||
IN PCI_IO_DEVICE *Bridge
|
||||
)
|
||||
{
|
||||
LIST_ENTRY *CurrentLink;
|
||||
|
@ -151,30 +140,33 @@ DestroyPciDeviceTree (
|
|||
|
||||
FreePciDevice (Temp);
|
||||
}
|
||||
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
/**
|
||||
Destroy all device nodes under the root bridge
|
||||
specified by Controller.
|
||||
|
||||
The root bridge itself is also included.
|
||||
|
||||
@param Controller An efi handle.
|
||||
@param Controller Root bridge handle.
|
||||
|
||||
@retval EFI_SUCCESS Destory all devcie nodes successfully.
|
||||
@retval EFI_NOT_FOUND Cannot find any PCI device under specified
|
||||
root bridge.
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
DestroyRootBridgeByHandle (
|
||||
EFI_HANDLE Controller
|
||||
IN EFI_HANDLE Controller
|
||||
)
|
||||
{
|
||||
|
||||
LIST_ENTRY *CurrentLink;
|
||||
PCI_IO_DEVICE *Temp;
|
||||
|
||||
CurrentLink = gPciDevicePool.ForwardLink;
|
||||
CurrentLink = mPciDevicePool.ForwardLink;
|
||||
|
||||
while (CurrentLink != NULL && CurrentLink != &gPciDevicePool) {
|
||||
while (CurrentLink != NULL && CurrentLink != &mPciDevicePool) {
|
||||
Temp = PCI_IO_DEVICE_FROM_LINK (CurrentLink);
|
||||
|
||||
if (Temp->Handle == Controller) {
|
||||
|
@ -195,23 +187,25 @@ DestroyRootBridgeByHandle (
|
|||
}
|
||||
|
||||
/**
|
||||
This function registers the PCI IO device. It creates a handle for this PCI IO device
|
||||
(if the handle does not exist), attaches appropriate protocols onto the handle, does
|
||||
necessary initialization, and sets up parent/child relationship with its bus controller.
|
||||
This function registers the PCI IO device.
|
||||
|
||||
@param Controller - An EFI handle for the PCI bus controller.
|
||||
@param PciIoDevice - A PCI_IO_DEVICE pointer to the PCI IO device to be registered.
|
||||
@param Handle - A pointer to hold the EFI handle for the PCI IO device.
|
||||
It creates a handle for this PCI IO device (if the handle does not exist), attaches
|
||||
appropriate protocols onto the handle, does necessary initialization, and sets up
|
||||
parent/child relationship with its bus controller.
|
||||
|
||||
@retval EFI_SUCCESS - The PCI device is successfully registered.
|
||||
@retval Others - An error occurred when registering the PCI device.
|
||||
@param Controller An EFI handle for the PCI bus controller.
|
||||
@param PciIoDevice A PCI_IO_DEVICE pointer to the PCI IO device to be registered.
|
||||
@param Handle A pointer to hold the returned EFI handle for the PCI IO device.
|
||||
|
||||
@retval EFI_SUCCESS The PCI device is successfully registered.
|
||||
@retval Others An error occurred when registering the PCI device.
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
RegisterPciDevice (
|
||||
IN EFI_HANDLE Controller,
|
||||
IN PCI_IO_DEVICE *PciIoDevice,
|
||||
OUT EFI_HANDLE *Handle OPTIONAL
|
||||
IN EFI_HANDLE Controller,
|
||||
IN PCI_IO_DEVICE *PciIoDevice,
|
||||
OUT EFI_HANDLE *Handle OPTIONAL
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
|
@ -391,21 +385,19 @@ RegisterPciDevice (
|
|||
}
|
||||
|
||||
/**
|
||||
This function is used to remove the whole PCI devices from the bridge.
|
||||
This function is used to remove the whole PCI devices on the specified bridge from
|
||||
the root bridge.
|
||||
|
||||
@param RootBridgeHandle An efi handle.
|
||||
@param Bridge A pointer to the PCI_IO_DEVICE.
|
||||
@param RootBridgeHandle The root bridge device handle.
|
||||
@param Bridge The bridge device to be removed.
|
||||
|
||||
@retval EFI_SUCCESS
|
||||
**/
|
||||
EFI_STATUS
|
||||
VOID
|
||||
RemoveAllPciDeviceOnBridge (
|
||||
EFI_HANDLE RootBridgeHandle,
|
||||
PCI_IO_DEVICE *Bridge
|
||||
)
|
||||
|
||||
{
|
||||
|
||||
LIST_ENTRY *CurrentLink;
|
||||
PCI_IO_DEVICE *Temp;
|
||||
|
||||
|
@ -433,20 +425,20 @@ RemoveAllPciDeviceOnBridge (
|
|||
|
||||
FreePciDevice (Temp);
|
||||
}
|
||||
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
/**
|
||||
This function is used to de-register the PCI IO device.
|
||||
|
||||
This function is used to de-register the PCI device from the EFI,
|
||||
That includes un-installing PciIo protocol from the specified PCI
|
||||
device handle.
|
||||
|
||||
@param Controller - controller handle
|
||||
@param Handle - device handle
|
||||
@param Controller An EFI handle for the PCI bus controller.
|
||||
@param Handle PCI device handle.
|
||||
|
||||
@retval EFI_SUCCESS The PCI device is successfully de-registered.
|
||||
@retval Others An error occurred when de-registering the PCI device.
|
||||
|
||||
@return Status of de-register pci device
|
||||
**/
|
||||
EFI_STATUS
|
||||
DeRegisterPciDevice (
|
||||
|
@ -595,13 +587,13 @@ DeRegisterPciDevice (
|
|||
/**
|
||||
Start to manage the PCI device on specified the root bridge or PCI-PCI Bridge
|
||||
|
||||
@param Controller An efi handle.
|
||||
@param Controller The root bridge handle.
|
||||
@param RootBridge A pointer to the PCI_IO_DEVICE.
|
||||
@param RemainingDevicePath A pointer to the EFI_DEVICE_PATH_PROTOCOL.
|
||||
@param NumberOfChildren Children number.
|
||||
@param ChildHandleBuffer A pointer to the child handle buffer.
|
||||
|
||||
@retval EFI_NOT_READY Device is not allocated
|
||||
@retval EFI_NOT_READY Device is not allocated.
|
||||
@retval EFI_UNSUPPORTED Device only support PCI-PCI bridge.
|
||||
@retval EFI_NOT_FOUND Can not find the specific device
|
||||
@retval EFI_SUCCESS Success to start Pci device on bridge
|
||||
|
@ -713,7 +705,6 @@ StartPciDevicesOnBridge (
|
|||
// If remaining device path is NULL,
|
||||
// try to enable all the pci devices under this bridge
|
||||
//
|
||||
|
||||
if (!PciIoDevice->Registered && PciIoDevice->Allocated) {
|
||||
Status = RegisterPciDevice (
|
||||
Controller,
|
||||
|
@ -764,7 +755,7 @@ StartPciDevicesOnBridge (
|
|||
Start to manage all the PCI devices it found previously under
|
||||
the entire host bridge.
|
||||
|
||||
@param Controller - root bridge handle.
|
||||
@param Controller The root bridge handle.
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
|
@ -781,9 +772,9 @@ StartPciDevices (
|
|||
ASSERT (RootBridge != NULL);
|
||||
ThisHostBridge = RootBridge->PciRootBridgeIo->ParentHandle;
|
||||
|
||||
CurrentLink = gPciDevicePool.ForwardLink;
|
||||
CurrentLink = mPciDevicePool.ForwardLink;
|
||||
|
||||
while (CurrentLink != NULL && CurrentLink != &gPciDevicePool) {
|
||||
while (CurrentLink != NULL && CurrentLink != &mPciDevicePool) {
|
||||
|
||||
RootBridge = PCI_IO_DEVICE_FROM_LINK (CurrentLink);
|
||||
//
|
||||
|
@ -806,35 +797,29 @@ StartPciDevices (
|
|||
}
|
||||
|
||||
/**
|
||||
Create root bridge device
|
||||
Create root bridge device.
|
||||
|
||||
@param RootBridgeHandle - Parent bridge handle.
|
||||
@param RootBridgeHandle Specified root bridge hanle.
|
||||
|
||||
@return The crated root bridge device instance, NULL means no
|
||||
root bridge device instance created.
|
||||
|
||||
@return pointer to new root bridge
|
||||
**/
|
||||
PCI_IO_DEVICE *
|
||||
CreateRootBridge (
|
||||
IN EFI_HANDLE RootBridgeHandle
|
||||
IN EFI_HANDLE RootBridgeHandle
|
||||
)
|
||||
{
|
||||
|
||||
EFI_STATUS Status;
|
||||
PCI_IO_DEVICE *Dev;
|
||||
EFI_DEVICE_PATH_PROTOCOL *ParentDevicePath;
|
||||
EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *PciRootBridgeIo;
|
||||
|
||||
Dev = NULL;
|
||||
Status = gBS->AllocatePool (
|
||||
EfiBootServicesData,
|
||||
sizeof (PCI_IO_DEVICE),
|
||||
(VOID **) &Dev
|
||||
);
|
||||
|
||||
if (EFI_ERROR (Status)) {
|
||||
Dev = AllocateZeroPool (sizeof (PCI_IO_DEVICE));
|
||||
if (Dev == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
ZeroMem (Dev, sizeof (PCI_IO_DEVICE));
|
||||
Dev->Signature = PCI_IO_DEVICE_SIGNATURE;
|
||||
Dev->Handle = RootBridgeHandle;
|
||||
InitializeListHead (&Dev->ChildList);
|
||||
|
@ -849,7 +834,7 @@ CreateRootBridge (
|
|||
);
|
||||
|
||||
if (EFI_ERROR (Status)) {
|
||||
gBS->FreePool (Dev);
|
||||
FreePool (Dev);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -895,11 +880,13 @@ CreateRootBridge (
|
|||
}
|
||||
|
||||
/**
|
||||
Get root bridge device instance by specific handle.
|
||||
Get root bridge device instance by specific root bridge handle.
|
||||
|
||||
@param RootBridgeHandle Given root bridge handle.
|
||||
|
||||
@return root bridge device instance.
|
||||
@return The root bridge device instance, NULL means no root bridge
|
||||
device instance found.
|
||||
|
||||
**/
|
||||
PCI_IO_DEVICE *
|
||||
GetRootBridgeByHandle (
|
||||
|
@ -909,9 +896,9 @@ GetRootBridgeByHandle (
|
|||
PCI_IO_DEVICE *RootBridgeDev;
|
||||
LIST_ENTRY *CurrentLink;
|
||||
|
||||
CurrentLink = gPciDevicePool.ForwardLink;
|
||||
CurrentLink = mPciDevicePool.ForwardLink;
|
||||
|
||||
while (CurrentLink != NULL && CurrentLink != &gPciDevicePool) {
|
||||
while (CurrentLink != NULL && CurrentLink != &mPciDevicePool) {
|
||||
|
||||
RootBridgeDev = PCI_IO_DEVICE_FROM_LINK (CurrentLink);
|
||||
if (RootBridgeDev->Handle == RootBridgeHandle) {
|
||||
|
@ -930,7 +917,9 @@ GetRootBridgeByHandle (
|
|||
@param Bridge Parent bridege instance.
|
||||
@param PciIoDevice Device instance.
|
||||
|
||||
@return whether Pci device existed.
|
||||
@retval TRUE Pci device existed.
|
||||
@retval FALSE Pci device did not exist.
|
||||
|
||||
**/
|
||||
BOOLEAN
|
||||
PciDeviceExisted (
|
||||
|
@ -965,11 +954,12 @@ PciDeviceExisted (
|
|||
}
|
||||
|
||||
/**
|
||||
Active VGA device.
|
||||
Get the active VGA device on the same segment.
|
||||
|
||||
@param VgaDevice device instance for VGA.
|
||||
@param VgaDevice PCI IO instance for the VGA device.
|
||||
|
||||
@return device instance.
|
||||
@return The active VGA device on the same segment.
|
||||
|
||||
**/
|
||||
PCI_IO_DEVICE *
|
||||
ActiveVGADeviceOnTheSameSegment (
|
||||
|
@ -979,9 +969,9 @@ ActiveVGADeviceOnTheSameSegment (
|
|||
LIST_ENTRY *CurrentLink;
|
||||
PCI_IO_DEVICE *Temp;
|
||||
|
||||
CurrentLink = gPciDevicePool.ForwardLink;
|
||||
CurrentLink = mPciDevicePool.ForwardLink;
|
||||
|
||||
while (CurrentLink != NULL && CurrentLink != &gPciDevicePool) {
|
||||
while (CurrentLink != NULL && CurrentLink != &mPciDevicePool) {
|
||||
|
||||
Temp = PCI_IO_DEVICE_FROM_LINK (CurrentLink);
|
||||
|
||||
|
@ -1001,11 +991,12 @@ ActiveVGADeviceOnTheSameSegment (
|
|||
}
|
||||
|
||||
/**
|
||||
Active VGA device on root bridge.
|
||||
Get the active VGA device on the root bridge.
|
||||
|
||||
@param RootBridge Root bridge device instance.
|
||||
@param RootBridge PCI IO instance for the root bridge.
|
||||
|
||||
@return VGA device instance.
|
||||
@return The active VGA device.
|
||||
|
||||
**/
|
||||
PCI_IO_DEVICE *
|
||||
ActiveVGADeviceOnTheRootBridge (
|
||||
|
@ -1044,92 +1035,17 @@ ActiveVGADeviceOnTheRootBridge (
|
|||
return NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
Get HPC PCI address according to its device path.
|
||||
@param PciRootBridgeIo Root bridege Io instance.
|
||||
@param HpcDevicePath Given searching device path.
|
||||
@param PciAddress Buffer holding searched result.
|
||||
|
||||
@retval EFI_NOT_FOUND Can not find the specific device path.
|
||||
@retval EFI_SUCCESS Success to get the device path.
|
||||
**/
|
||||
EFI_STATUS
|
||||
GetHpcPciAddress (
|
||||
IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *PciRootBridgeIo,
|
||||
IN EFI_DEVICE_PATH_PROTOCOL *HpcDevicePath,
|
||||
OUT UINT64 *PciAddress
|
||||
)
|
||||
{
|
||||
EFI_DEVICE_PATH_PROTOCOL *CurrentDevicePath;
|
||||
EFI_DEV_PATH_PTR Node;
|
||||
LIST_ENTRY *CurrentLink;
|
||||
PCI_IO_DEVICE *RootBridge;
|
||||
EFI_STATUS Status;
|
||||
|
||||
CurrentDevicePath = HpcDevicePath;
|
||||
|
||||
//
|
||||
// Get the remaining device path for this PCI device, if it is a PCI device
|
||||
//
|
||||
while (!IsDevicePathEnd (CurrentDevicePath)) {
|
||||
|
||||
Node.DevPath = CurrentDevicePath;
|
||||
|
||||
//
|
||||
// Check if it is PCI device Path?
|
||||
//
|
||||
if ((Node.DevPath->Type != HARDWARE_DEVICE_PATH) ||
|
||||
((Node.DevPath->SubType != HW_PCI_DP) &&
|
||||
(DevicePathNodeLength (Node.DevPath) != sizeof (PCI_DEVICE_PATH)))) {
|
||||
CurrentDevicePath = NextDevicePathNode (CurrentDevicePath);
|
||||
continue;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
//
|
||||
// Check if it is not PCI device path
|
||||
//
|
||||
if (IsDevicePathEnd (CurrentDevicePath)) {
|
||||
return EFI_NOT_FOUND;
|
||||
}
|
||||
|
||||
CurrentLink = gPciDevicePool.ForwardLink;
|
||||
|
||||
while (CurrentLink != NULL && CurrentLink != &gPciDevicePool) {
|
||||
|
||||
RootBridge = PCI_IO_DEVICE_FROM_LINK (CurrentLink);
|
||||
//
|
||||
// Locate the right root bridge to start
|
||||
//
|
||||
if (RootBridge->PciRootBridgeIo == PciRootBridgeIo) {
|
||||
Status = GetHpcPciAddressFromRootBridge (
|
||||
RootBridge,
|
||||
CurrentDevicePath,
|
||||
PciAddress
|
||||
);
|
||||
if (EFI_ERROR (Status)) {
|
||||
return EFI_NOT_FOUND;
|
||||
}
|
||||
|
||||
return EFI_SUCCESS;
|
||||
|
||||
}
|
||||
|
||||
CurrentLink = CurrentLink->ForwardLink;
|
||||
}
|
||||
|
||||
return EFI_NOT_FOUND;
|
||||
}
|
||||
|
||||
/**
|
||||
Get HPC PCI address according to its device path.
|
||||
|
||||
@param RootBridge Root bridege Io instance.
|
||||
@param RemainingDevicePath Given searching device path.
|
||||
@param PciAddress Buffer holding searched result.
|
||||
|
||||
@retval EFI_NOT_FOUND Can not find the specific device path.
|
||||
@retval EFI_SUCCESS PCI address was stored in PciAddress
|
||||
@retval EFI_NOT_FOUND Can not find the specific device path.
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
GetHpcPciAddressFromRootBridge (
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
/** @file
|
||||
Supporting functions declaration for PCI devices management.
|
||||
|
||||
Copyright (c) 2006, Intel Corporation
|
||||
Copyright (c) 2006 - 2009, Intel Corporation
|
||||
All rights reserved. This program and the accompanying materials
|
||||
are licensed and made available under the terms and conditions of the BSD License
|
||||
which accompanies this distribution. The full text of the license may be found at
|
||||
|
@ -15,118 +16,128 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
|||
#define _EFI_PCI_DEVICE_SUPPORT_H_
|
||||
|
||||
/**
|
||||
Initialize the gPciDevicePool.
|
||||
Initialize the PCI devices pool.
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
VOID
|
||||
InitializePciDevicePool (
|
||||
VOID
|
||||
);
|
||||
|
||||
/**
|
||||
Insert a root bridge into PCI device pool
|
||||
Insert a root bridge into PCI device pool.
|
||||
|
||||
@param RootBridge - A pointer to the PCI_IO_DEVICE.
|
||||
@param RootBridge A pointer to the PCI_IO_DEVICE.
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
VOID
|
||||
InsertRootBridge (
|
||||
PCI_IO_DEVICE *RootBridge
|
||||
IN PCI_IO_DEVICE *RootBridge
|
||||
);
|
||||
|
||||
/**
|
||||
This function is used to insert a PCI device node under
|
||||
a bridge
|
||||
a bridge.
|
||||
|
||||
@param Bridge A pointer to the PCI_IO_DEVICE.
|
||||
@param PciDeviceNode A pointer to the PCI_IO_DEVICE.
|
||||
@param Bridge The PCI bridge.
|
||||
@param PciDeviceNode The PCI device needs inserting.
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
VOID
|
||||
InsertPciDevice (
|
||||
PCI_IO_DEVICE *Bridge,
|
||||
PCI_IO_DEVICE *PciDeviceNode
|
||||
IN PCI_IO_DEVICE *Bridge,
|
||||
IN PCI_IO_DEVICE *PciDeviceNode
|
||||
);
|
||||
|
||||
/**
|
||||
Destroy root bridge and remove it from deivce tree.
|
||||
|
||||
@param RootBridge The bridge want to be removed
|
||||
@param RootBridge The bridge want to be removed.
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
VOID
|
||||
DestroyRootBridge (
|
||||
IN PCI_IO_DEVICE *RootBridge
|
||||
IN PCI_IO_DEVICE *RootBridge
|
||||
);
|
||||
|
||||
/**
|
||||
Destroy all the pci device node under the bridge.
|
||||
Bridge itself is not included.
|
||||
|
||||
@param Bridge A pointer to the PCI_IO_DEVICE.
|
||||
@param Bridge A pointer to the PCI_IO_DEVICE.
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
VOID
|
||||
DestroyPciDeviceTree (
|
||||
IN PCI_IO_DEVICE *Bridge
|
||||
IN PCI_IO_DEVICE *Bridge
|
||||
);
|
||||
|
||||
/**
|
||||
Destroy all device nodes under the root bridge
|
||||
specified by Controller.
|
||||
|
||||
The root bridge itself is also included.
|
||||
|
||||
@param Controller An efi handle.
|
||||
@param Controller Root bridge handle.
|
||||
|
||||
@retval EFI_SUCCESS Destory all devcie nodes successfully.
|
||||
@retval EFI_NOT_FOUND Cannot find any PCI device under specified
|
||||
root bridge.
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
DestroyRootBridgeByHandle (
|
||||
EFI_HANDLE Controller
|
||||
IN EFI_HANDLE Controller
|
||||
);
|
||||
|
||||
/**
|
||||
This function registers the PCI IO device. It creates a handle for this PCI IO device
|
||||
(if the handle does not exist), attaches appropriate protocols onto the handle, does
|
||||
necessary initialization, and sets up parent/child relationship with its bus controller.
|
||||
This function registers the PCI IO device.
|
||||
|
||||
@param Controller - An EFI handle for the PCI bus controller.
|
||||
@param PciIoDevice - A PCI_IO_DEVICE pointer to the PCI IO device to be registered.
|
||||
@param Handle - A pointer to hold the EFI handle for the PCI IO device.
|
||||
It creates a handle for this PCI IO device (if the handle does not exist), attaches
|
||||
appropriate protocols onto the handle, does necessary initialization, and sets up
|
||||
parent/child relationship with its bus controller.
|
||||
|
||||
@retval EFI_SUCCESS - The PCI device is successfully registered.
|
||||
@retval Others - An error occurred when registering the PCI device.
|
||||
@param Controller An EFI handle for the PCI bus controller.
|
||||
@param PciIoDevice A PCI_IO_DEVICE pointer to the PCI IO device to be registered.
|
||||
@param Handle A pointer to hold the returned EFI handle for the PCI IO device.
|
||||
|
||||
@retval EFI_SUCCESS The PCI device is successfully registered.
|
||||
@retval Others An error occurred when registering the PCI device.
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
RegisterPciDevice (
|
||||
IN EFI_HANDLE Controller,
|
||||
IN PCI_IO_DEVICE *PciIoDevice,
|
||||
OUT EFI_HANDLE *Handle OPTIONAL
|
||||
IN EFI_HANDLE Controller,
|
||||
IN PCI_IO_DEVICE *PciIoDevice,
|
||||
OUT EFI_HANDLE *Handle OPTIONAL
|
||||
);
|
||||
|
||||
/**
|
||||
This function is used to remove the whole PCI devices from the bridge.
|
||||
This function is used to remove the whole PCI devices on the specified bridge from
|
||||
the root bridge.
|
||||
|
||||
@param RootBridgeHandle An efi handle.
|
||||
@param Bridge A pointer to the PCI_IO_DEVICE.
|
||||
@param RootBridgeHandle The root bridge device handle.
|
||||
@param Bridge The bridge device to be removed.
|
||||
|
||||
@retval EFI_SUCCESS
|
||||
**/
|
||||
EFI_STATUS
|
||||
VOID
|
||||
RemoveAllPciDeviceOnBridge (
|
||||
EFI_HANDLE RootBridgeHandle,
|
||||
PCI_IO_DEVICE *Bridge
|
||||
);
|
||||
|
||||
/**
|
||||
This function is used to de-register the PCI IO device.
|
||||
|
||||
This function is used to de-register the PCI device from the EFI,
|
||||
That includes un-installing PciIo protocol from the specified PCI
|
||||
device handle.
|
||||
|
||||
@param Controller - controller handle
|
||||
@param Handle - device handle
|
||||
@param Controller An EFI handle for the PCI bus controller.
|
||||
@param Handle PCI device handle.
|
||||
|
||||
@retval EFI_SUCCESS The PCI device is successfully de-registered.
|
||||
@retval Others An error occurred when de-registering the PCI device.
|
||||
|
||||
@return Status of de-register pci device
|
||||
**/
|
||||
EFI_STATUS
|
||||
DeRegisterPciDevice (
|
||||
|
@ -143,7 +154,7 @@ DeRegisterPciDevice (
|
|||
@param NumberOfChildren Children number.
|
||||
@param ChildHandleBuffer A pointer to the child handle buffer.
|
||||
|
||||
@retval EFI_NOT_READY Device is not allocated
|
||||
@retval EFI_NOT_READY Device is not allocated.
|
||||
@retval EFI_UNSUPPORTED Device only support PCI-PCI bridge.
|
||||
@retval EFI_NOT_FOUND Can not find the specific device
|
||||
@retval EFI_SUCCESS Success to start Pci device on bridge
|
||||
|
@ -171,48 +182,43 @@ StartPciDevices (
|
|||
);
|
||||
|
||||
/**
|
||||
Create root bridge device
|
||||
Create root bridge device.
|
||||
|
||||
@param RootBridgeHandle - Parent bridge handle.
|
||||
@param RootBridgeHandle Specified root bridge hanle.
|
||||
|
||||
@return The crated root bridge device instance, NULL means no
|
||||
root bridge device instance created.
|
||||
|
||||
@return pointer to new root bridge
|
||||
**/
|
||||
PCI_IO_DEVICE *
|
||||
CreateRootBridge (
|
||||
IN EFI_HANDLE RootBridgeHandle
|
||||
IN EFI_HANDLE RootBridgeHandle
|
||||
);
|
||||
|
||||
/**
|
||||
Get root bridge device instance by specific handle.
|
||||
Get root bridge device instance by specific root bridge handle.
|
||||
|
||||
@param RootBridgeHandle Given root bridge handle.
|
||||
|
||||
@return root bridge device instance.
|
||||
@return The root bridge device instance, NULL means no root bridge
|
||||
device instance found.
|
||||
|
||||
**/
|
||||
PCI_IO_DEVICE *
|
||||
GetRootBridgeByHandle (
|
||||
EFI_HANDLE RootBridgeHandle
|
||||
);
|
||||
|
||||
/**
|
||||
Check root bridge device is existed or not.
|
||||
|
||||
@param RootBridgeHandle Given root bridge handle.
|
||||
|
||||
@return root bridge device is existed or not.
|
||||
**/
|
||||
BOOLEAN
|
||||
RootBridgeExisted (
|
||||
IN EFI_HANDLE RootBridgeHandle
|
||||
);
|
||||
|
||||
/**
|
||||
Judege whether Pci device existed.
|
||||
|
||||
@param Bridge Parent bridege instance.
|
||||
@param Bridge Parent bridege instance.
|
||||
@param PciIoDevice Device instance.
|
||||
|
||||
@return whether Pci device existed.
|
||||
@retval TRUE Pci device existed.
|
||||
@retval FALSE Pci device did not exist.
|
||||
|
||||
**/
|
||||
BOOLEAN
|
||||
PciDeviceExisted (
|
||||
|
@ -221,11 +227,12 @@ PciDeviceExisted (
|
|||
);
|
||||
|
||||
/**
|
||||
Active VGA device.
|
||||
Get the active VGA device on the same segment.
|
||||
|
||||
@param VgaDevice device instance for VGA.
|
||||
@param VgaDevice PCI IO instance for the VGA device.
|
||||
|
||||
@return device instance.
|
||||
@return The active VGA device on the same segment.
|
||||
|
||||
**/
|
||||
PCI_IO_DEVICE *
|
||||
ActiveVGADeviceOnTheSameSegment (
|
||||
|
@ -233,11 +240,12 @@ ActiveVGADeviceOnTheSameSegment (
|
|||
);
|
||||
|
||||
/**
|
||||
Active VGA device on root bridge.
|
||||
Get the active VGA device on the root bridge.
|
||||
|
||||
@param RootBridge Root bridge device instance.
|
||||
@param RootBridge PCI IO instance for the root bridge.
|
||||
|
||||
@return VGA device instance.
|
||||
@return The active VGA device.
|
||||
|
||||
**/
|
||||
PCI_IO_DEVICE *
|
||||
ActiveVGADeviceOnTheRootBridge (
|
||||
|
@ -246,27 +254,14 @@ ActiveVGADeviceOnTheRootBridge (
|
|||
|
||||
/**
|
||||
Get HPC PCI address according to its device path.
|
||||
@param PciRootBridgeIo Root bridege Io instance.
|
||||
@param HpcDevicePath Given searching device path.
|
||||
@param PciAddress Buffer holding searched result.
|
||||
|
||||
@retval EFI_NOT_FOUND Can not find the specific device path.
|
||||
@retval EFI_SUCCESS Success to get the device path.
|
||||
**/
|
||||
EFI_STATUS
|
||||
GetHpcPciAddress (
|
||||
IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *PciRootBridgeIo,
|
||||
IN EFI_DEVICE_PATH_PROTOCOL *HpcDevicePath,
|
||||
OUT UINT64 *PciAddress
|
||||
);
|
||||
|
||||
/**
|
||||
Get HPC PCI address according to its device path.
|
||||
@param RootBridge Root bridege Io instance.
|
||||
@param RemainingDevicePath Given searching device path.
|
||||
@param PciAddress Buffer holding searched result.
|
||||
|
||||
@retval EFI_NOT_FOUND Can not find the specific device path.
|
||||
@retval EFI_SUCCESS PCI address was stored in PciAddress.
|
||||
@retval EFI_NOT_FOUND Can not find the specific device path.
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
GetHpcPciAddressFromRootBridge (
|
||||
|
@ -277,14 +272,15 @@ GetHpcPciAddressFromRootBridge (
|
|||
|
||||
/**
|
||||
Destroy a pci device node.
|
||||
Also all direct or indirect allocated resource for this node will be freed.
|
||||
|
||||
@param PciIoDevice A pointer to the PCI_IO_DEVICE.
|
||||
All direct or indirect allocated resource for this node will be freed.
|
||||
|
||||
@param PciIoDevice A pointer to the PCI_IO_DEVICE to be destoried.
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
VOID
|
||||
FreePciDevice (
|
||||
IN PCI_IO_DEVICE *PciIoDevice
|
||||
IN PCI_IO_DEVICE *PciIoDevice
|
||||
);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -223,7 +223,7 @@ PciRootBridgeEnumerator (
|
|||
Configuration
|
||||
);
|
||||
|
||||
gBS->FreePool (Configuration);
|
||||
FreePool (Configuration);
|
||||
|
||||
if (EFI_ERROR (Status)) {
|
||||
return Status;
|
||||
|
@ -683,9 +683,9 @@ RejectPciDevice (
|
|||
//
|
||||
// Remove the padding resource from a bridge
|
||||
//
|
||||
if ( IS_PCI_BRIDGE(&PciDevice->Pci) && \
|
||||
if ( IS_PCI_BRIDGE(&PciDevice->Pci) &&
|
||||
PciDevice->ResourcePaddingDescriptors != NULL ) {
|
||||
gBS->FreePool (PciDevice->ResourcePaddingDescriptors);
|
||||
FreePool (PciDevice->ResourcePaddingDescriptors);
|
||||
PciDevice->ResourcePaddingDescriptors = NULL;
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
@ -1950,7 +1950,7 @@ PciHotPlugRequestNotify (
|
|||
ChildHandleBuffer
|
||||
);
|
||||
|
||||
return EFI_SUCCESS;
|
||||
return Status;
|
||||
}
|
||||
|
||||
if (Operation == EfiPciHotplugRequestRemove) {
|
||||
|
@ -1959,8 +1959,8 @@ PciHotPlugRequestNotify (
|
|||
//
|
||||
// Remove all devices on the bridge
|
||||
//
|
||||
Status = RemoveAllPciDeviceOnBridge (RootBridgeHandle, Bridge);
|
||||
return Status;
|
||||
RemoveAllPciDeviceOnBridge (RootBridgeHandle, Bridge);
|
||||
return EFI_SUCCESS;
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -1224,7 +1224,9 @@ UpdatePciInfo (
|
|||
Ptr++;
|
||||
}
|
||||
|
||||
gBS->FreePool (Configuration);
|
||||
if (Configuration != NULL) {
|
||||
FreePool (Configuration);
|
||||
}
|
||||
return Status;
|
||||
|
||||
}
|
||||
|
@ -1618,24 +1620,13 @@ CreatePciIoDevice (
|
|||
UINT8 Func
|
||||
)
|
||||
{
|
||||
|
||||
EFI_STATUS Status;
|
||||
PCI_IO_DEVICE *PciIoDevice;
|
||||
|
||||
PciIoDevice = NULL;
|
||||
|
||||
Status = gBS->AllocatePool (
|
||||
EfiBootServicesData,
|
||||
sizeof (PCI_IO_DEVICE),
|
||||
(VOID **) &PciIoDevice
|
||||
);
|
||||
|
||||
if (EFI_ERROR (Status)) {
|
||||
PciIoDevice = AllocateZeroPool (sizeof (PCI_IO_DEVICE));
|
||||
if (PciIoDevice == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
ZeroMem (PciIoDevice, sizeof (PCI_IO_DEVICE));
|
||||
|
||||
PciIoDevice->Signature = PCI_IO_DEVICE_SIGNATURE;
|
||||
PciIoDevice->Handle = NULL;
|
||||
PciIoDevice->PciRootBridgeIo = PciRootBridgeIo;
|
||||
|
@ -1644,6 +1635,7 @@ CreatePciIoDevice (
|
|||
PciIoDevice->DeviceNumber = Device;
|
||||
PciIoDevice->FunctionNumber = Func;
|
||||
PciIoDevice->Decodes = 0;
|
||||
|
||||
if (gFullEnumeration) {
|
||||
PciIoDevice->Allocated = FALSE;
|
||||
} else {
|
||||
|
@ -1663,7 +1655,6 @@ CreatePciIoDevice (
|
|||
//
|
||||
// Initialize the PCI I/O instance structure
|
||||
//
|
||||
|
||||
InitializePciIoInstance (PciIoDevice);
|
||||
InitializePciDriverOverrideInstance (PciIoDevice);
|
||||
InitializePciLoadFile2 (PciIoDevice);
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/** @file
|
||||
Implement all interfaces for EFI_PCI_IO_PROTOCOL.
|
||||
Implements all interfaces for EFI_PCI_IO_PROTOCOL.
|
||||
|
||||
Copyright (c) 2006 - 2008, Intel Corporation
|
||||
All rights reserved. This program and the accompanying materials
|
||||
|
@ -15,14 +15,10 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
|||
|
||||
#include "PciBus.h"
|
||||
|
||||
//
|
||||
// Internal use only
|
||||
//
|
||||
|
||||
//
|
||||
// Pci Io Protocol Interface
|
||||
//
|
||||
EFI_PCI_IO_PROTOCOL PciIoInterface = {
|
||||
EFI_PCI_IO_PROTOCOL mPciIoInterface = {
|
||||
PciIoPollMem,
|
||||
PciIoPollIo,
|
||||
{
|
||||
|
@ -56,6 +52,7 @@ EFI_PCI_IO_PROTOCOL PciIoInterface = {
|
|||
|
||||
@param PciIoDevice Pci device instance.
|
||||
@param Code status code.
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
ReportErrorStatusCode (
|
||||
|
@ -98,7 +95,7 @@ InitializePciIoInstance (
|
|||
PCI_IO_DEVICE *PciIoDevice
|
||||
)
|
||||
{
|
||||
CopyMem (&PciIoDevice->PciIo, &PciIoInterface, sizeof (EFI_PCI_IO_PROTOCOL));
|
||||
CopyMem (&PciIoDevice->PciIo, &mPciIoInterface, sizeof (EFI_PCI_IO_PROTOCOL));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
/** @file
|
||||
Header file of EFI PCI IO protocol.
|
||||
|
||||
Copyright (c) 2006, Intel Corporation
|
||||
Copyright (c) 2006 - 2009, Intel Corporation
|
||||
All rights reserved. This program and the accompanying materials
|
||||
are licensed and made available under the terms and conditions of the BSD License
|
||||
which accompanies this distribution. The full text of the license may be found at
|
||||
|
|
|
@ -17,33 +17,6 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
|||
|
||||
#include "PciBus.h"
|
||||
|
||||
GLOBAL_REMOVE_IF_UNREFERENCED EFI_PCI_HOTPLUG_REQUEST_PROTOCOL gPciHotPlugRequest = {
|
||||
PciHotPlugRequestNotify
|
||||
};
|
||||
|
||||
/**
|
||||
Install protocol gEfiPciHotPlugRequestProtocolGuid
|
||||
@param Status return status of protocol installation.
|
||||
**/
|
||||
VOID
|
||||
InstallHotPlugRequestProtocol (
|
||||
IN EFI_STATUS *Status
|
||||
)
|
||||
{
|
||||
EFI_HANDLE Handle;
|
||||
|
||||
if (!FeaturePcdGet (PcdPciBusHotplugDeviceSupport)) {
|
||||
return;
|
||||
}
|
||||
|
||||
Handle = NULL;
|
||||
*Status = gBS->InstallProtocolInterface (
|
||||
&Handle,
|
||||
&gEfiPciHotPlugRequestProtocolGuid,
|
||||
EFI_NATIVE_INTERFACE,
|
||||
&gPciHotPlugRequest
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
Retrieve the BAR information via PciIo interface.
|
||||
|
@ -68,12 +41,12 @@ GetBackPcCardBar (
|
|||
|
||||
Address = 0;
|
||||
PciIoRead (
|
||||
&(PciIoDevice->PciIo),
|
||||
EfiPciIoWidthUint32,
|
||||
0x1c,
|
||||
1,
|
||||
&Address
|
||||
);
|
||||
&(PciIoDevice->PciIo),
|
||||
EfiPciIoWidthUint32,
|
||||
0x1c,
|
||||
1,
|
||||
&Address
|
||||
);
|
||||
|
||||
(PciIoDevice->PciBar)[P2C_MEM_1].BaseAddress = (UINT64) (Address);
|
||||
(PciIoDevice->PciBar)[P2C_MEM_1].Length = 0x2000000;
|
||||
|
@ -81,36 +54,36 @@ GetBackPcCardBar (
|
|||
|
||||
Address = 0;
|
||||
PciIoRead (
|
||||
&(PciIoDevice->PciIo),
|
||||
EfiPciIoWidthUint32,
|
||||
0x20,
|
||||
1,
|
||||
&Address
|
||||
);
|
||||
&(PciIoDevice->PciIo),
|
||||
EfiPciIoWidthUint32,
|
||||
0x20,
|
||||
1,
|
||||
&Address
|
||||
);
|
||||
(PciIoDevice->PciBar)[P2C_MEM_2].BaseAddress = (UINT64) (Address);
|
||||
(PciIoDevice->PciBar)[P2C_MEM_2].Length = 0x2000000;
|
||||
(PciIoDevice->PciBar)[P2C_MEM_2].BarType = PciBarTypePMem32;
|
||||
|
||||
Address = 0;
|
||||
PciIoRead (
|
||||
&(PciIoDevice->PciIo),
|
||||
EfiPciIoWidthUint32,
|
||||
0x2c,
|
||||
1,
|
||||
&Address
|
||||
);
|
||||
&(PciIoDevice->PciIo),
|
||||
EfiPciIoWidthUint32,
|
||||
0x2c,
|
||||
1,
|
||||
&Address
|
||||
);
|
||||
(PciIoDevice->PciBar)[P2C_IO_1].BaseAddress = (UINT64) (Address);
|
||||
(PciIoDevice->PciBar)[P2C_IO_1].Length = 0x100;
|
||||
(PciIoDevice->PciBar)[P2C_IO_1].BarType = PciBarTypeIo16;
|
||||
|
||||
Address = 0;
|
||||
PciIoRead (
|
||||
&(PciIoDevice->PciIo),
|
||||
EfiPciIoWidthUint32,
|
||||
0x34,
|
||||
1,
|
||||
&Address
|
||||
);
|
||||
&(PciIoDevice->PciIo),
|
||||
EfiPciIoWidthUint32,
|
||||
0x34,
|
||||
1,
|
||||
&Address
|
||||
);
|
||||
(PciIoDevice->PciBar)[P2C_IO_2].BaseAddress = (UINT64) (Address);
|
||||
(PciIoDevice->PciBar)[P2C_IO_2].Length = 0x100;
|
||||
(PciIoDevice->PciBar)[P2C_IO_2].BarType = PciBarTypeIo16;
|
||||
|
@ -165,7 +138,6 @@ RemoveRejectedPciDevices (
|
|||
//
|
||||
// For P2C, remove all devices on it
|
||||
//
|
||||
|
||||
if (!IsListEmpty (&Temp->ChildList)) {
|
||||
RemoveAllPciDeviceOnBridge (RootBridgeHandle, Temp);
|
||||
}
|
||||
|
@ -173,7 +145,6 @@ RemoveRejectedPciDevices (
|
|||
//
|
||||
// Finally remove itself
|
||||
//
|
||||
|
||||
LastLink = CurrentLink->BackLink;
|
||||
RemoveEntryList (CurrentLink);
|
||||
FreePciDevice (Temp);
|
||||
|
@ -278,13 +249,13 @@ PciHostBridgeResourceAllocator_WithoutHotPlugDeviceSupport (
|
|||
//
|
||||
|
||||
IoBridge = CreateResourceNode (
|
||||
RootBridgeDev,
|
||||
0,
|
||||
0xFFF,
|
||||
0,
|
||||
PciBarTypeIo16,
|
||||
PciResUsageTypical
|
||||
);
|
||||
RootBridgeDev,
|
||||
0,
|
||||
0xFFF,
|
||||
0,
|
||||
PciBarTypeIo16,
|
||||
PciResUsageTypical
|
||||
);
|
||||
|
||||
Mem32Bridge = CreateResourceNode (
|
||||
RootBridgeDev,
|
||||
|
@ -296,13 +267,13 @@ PciHostBridgeResourceAllocator_WithoutHotPlugDeviceSupport (
|
|||
);
|
||||
|
||||
PMem32Bridge = CreateResourceNode (
|
||||
RootBridgeDev,
|
||||
0,
|
||||
0xFFFFF,
|
||||
0,
|
||||
PciBarTypePMem32,
|
||||
PciResUsageTypical
|
||||
);
|
||||
RootBridgeDev,
|
||||
0,
|
||||
0xFFFFF,
|
||||
0,
|
||||
PciBarTypePMem32,
|
||||
PciResUsageTypical
|
||||
);
|
||||
|
||||
Mem64Bridge = CreateResourceNode (
|
||||
RootBridgeDev,
|
||||
|
@ -314,25 +285,25 @@ PciHostBridgeResourceAllocator_WithoutHotPlugDeviceSupport (
|
|||
);
|
||||
|
||||
PMem64Bridge = CreateResourceNode (
|
||||
RootBridgeDev,
|
||||
0,
|
||||
0xFFFFF,
|
||||
0,
|
||||
PciBarTypePMem64,
|
||||
PciResUsageTypical
|
||||
);
|
||||
RootBridgeDev,
|
||||
0,
|
||||
0xFFFFF,
|
||||
0,
|
||||
PciBarTypePMem64,
|
||||
PciResUsageTypical
|
||||
);
|
||||
|
||||
//
|
||||
// Create resourcemap by going through all the devices subject to this root bridge
|
||||
//
|
||||
Status = CreateResourceMap (
|
||||
RootBridgeDev,
|
||||
IoBridge,
|
||||
Mem32Bridge,
|
||||
PMem32Bridge,
|
||||
Mem64Bridge,
|
||||
PMem64Bridge
|
||||
);
|
||||
RootBridgeDev,
|
||||
IoBridge,
|
||||
Mem32Bridge,
|
||||
PMem32Bridge,
|
||||
Mem64Bridge,
|
||||
PMem64Bridge
|
||||
);
|
||||
|
||||
//
|
||||
// Get the max ROM size that the root bridge can process
|
||||
|
@ -366,14 +337,14 @@ PciHostBridgeResourceAllocator_WithoutHotPlugDeviceSupport (
|
|||
// submit the resource aperture to pci host bridge protocol
|
||||
//
|
||||
Status = ConstructAcpiResourceRequestor (
|
||||
RootBridgeDev,
|
||||
IoBridge,
|
||||
Mem32Bridge,
|
||||
PMem32Bridge,
|
||||
Mem64Bridge,
|
||||
PMem64Bridge,
|
||||
&AcpiConfig
|
||||
);
|
||||
RootBridgeDev,
|
||||
IoBridge,
|
||||
Mem32Bridge,
|
||||
PMem32Bridge,
|
||||
Mem64Bridge,
|
||||
PMem64Bridge,
|
||||
&AcpiConfig
|
||||
);
|
||||
|
||||
//
|
||||
// Insert these resource nodes into the database
|
||||
|
@ -493,18 +464,18 @@ PciHostBridgeResourceAllocator_WithoutHotPlugDeviceSupport (
|
|||
// enumerator. Several resource tree was created
|
||||
//
|
||||
Status = GetResourceMap (
|
||||
RootBridgeDev,
|
||||
&IoBridge,
|
||||
&Mem32Bridge,
|
||||
&PMem32Bridge,
|
||||
&Mem64Bridge,
|
||||
&PMem64Bridge,
|
||||
&IoPool,
|
||||
&Mem32Pool,
|
||||
&PMem32Pool,
|
||||
&Mem64Pool,
|
||||
&PMem64Pool
|
||||
);
|
||||
RootBridgeDev,
|
||||
&IoBridge,
|
||||
&Mem32Bridge,
|
||||
&PMem32Bridge,
|
||||
&Mem64Bridge,
|
||||
&PMem64Bridge,
|
||||
&IoPool,
|
||||
&Mem32Pool,
|
||||
&PMem32Pool,
|
||||
&Mem64Pool,
|
||||
&PMem64Pool
|
||||
);
|
||||
|
||||
if (EFI_ERROR (Status)) {
|
||||
return Status;
|
||||
|
@ -650,13 +621,13 @@ PciHostBridgeResourceAllocator_WithHotPlugDeviceSupport (
|
|||
//
|
||||
|
||||
IoBridge = CreateResourceNode (
|
||||
RootBridgeDev,
|
||||
0,
|
||||
0xFFF,
|
||||
0,
|
||||
PciBarTypeIo16,
|
||||
PciResUsageTypical
|
||||
);
|
||||
RootBridgeDev,
|
||||
0,
|
||||
0xFFF,
|
||||
0,
|
||||
PciBarTypeIo16,
|
||||
PciResUsageTypical
|
||||
);
|
||||
|
||||
Mem32Bridge = CreateResourceNode (
|
||||
RootBridgeDev,
|
||||
|
@ -668,13 +639,13 @@ PciHostBridgeResourceAllocator_WithHotPlugDeviceSupport (
|
|||
);
|
||||
|
||||
PMem32Bridge = CreateResourceNode (
|
||||
RootBridgeDev,
|
||||
0,
|
||||
0xFFFFF,
|
||||
0,
|
||||
PciBarTypePMem32,
|
||||
PciResUsageTypical
|
||||
);
|
||||
RootBridgeDev,
|
||||
0,
|
||||
0xFFFFF,
|
||||
0,
|
||||
PciBarTypePMem32,
|
||||
PciResUsageTypical
|
||||
);
|
||||
|
||||
Mem64Bridge = CreateResourceNode (
|
||||
RootBridgeDev,
|
||||
|
@ -686,25 +657,25 @@ PciHostBridgeResourceAllocator_WithHotPlugDeviceSupport (
|
|||
);
|
||||
|
||||
PMem64Bridge = CreateResourceNode (
|
||||
RootBridgeDev,
|
||||
0,
|
||||
0xFFFFF,
|
||||
0,
|
||||
PciBarTypePMem64,
|
||||
PciResUsageTypical
|
||||
);
|
||||
RootBridgeDev,
|
||||
0,
|
||||
0xFFFFF,
|
||||
0,
|
||||
PciBarTypePMem64,
|
||||
PciResUsageTypical
|
||||
);
|
||||
|
||||
//
|
||||
// Create resourcemap by going through all the devices subject to this root bridge
|
||||
//
|
||||
Status = CreateResourceMap (
|
||||
RootBridgeDev,
|
||||
IoBridge,
|
||||
Mem32Bridge,
|
||||
PMem32Bridge,
|
||||
Mem64Bridge,
|
||||
PMem64Bridge
|
||||
);
|
||||
RootBridgeDev,
|
||||
IoBridge,
|
||||
Mem32Bridge,
|
||||
PMem32Bridge,
|
||||
Mem64Bridge,
|
||||
PMem64Bridge
|
||||
);
|
||||
|
||||
//
|
||||
// Get the max ROM size that the root bridge can process
|
||||
|
@ -743,14 +714,14 @@ PciHostBridgeResourceAllocator_WithHotPlugDeviceSupport (
|
|||
// submit the resource aperture to pci host bridge protocol
|
||||
//
|
||||
Status = ConstructAcpiResourceRequestor (
|
||||
RootBridgeDev,
|
||||
IoBridge,
|
||||
Mem32Bridge,
|
||||
PMem32Bridge,
|
||||
Mem64Bridge,
|
||||
PMem64Bridge,
|
||||
&AcpiConfig
|
||||
);
|
||||
RootBridgeDev,
|
||||
IoBridge,
|
||||
Mem32Bridge,
|
||||
PMem32Bridge,
|
||||
Mem64Bridge,
|
||||
PMem64Bridge,
|
||||
&AcpiConfig
|
||||
);
|
||||
|
||||
//
|
||||
// Insert these resource nodes into the database
|
||||
|
@ -883,17 +854,17 @@ PciHostBridgeResourceAllocator_WithHotPlugDeviceSupport (
|
|||
);
|
||||
|
||||
Status = PciHostBridgeAdjustAllocation (
|
||||
&IoPool,
|
||||
&Mem32Pool,
|
||||
&PMem32Pool,
|
||||
&Mem64Pool,
|
||||
&PMem64Pool,
|
||||
IoResStatus,
|
||||
Mem32ResStatus,
|
||||
PMem32ResStatus,
|
||||
Mem64ResStatus,
|
||||
PMem64ResStatus
|
||||
);
|
||||
&IoPool,
|
||||
&Mem32Pool,
|
||||
&PMem32Pool,
|
||||
&Mem64Pool,
|
||||
&PMem64Pool,
|
||||
IoResStatus,
|
||||
Mem32ResStatus,
|
||||
PMem32ResStatus,
|
||||
Mem64ResStatus,
|
||||
PMem64ResStatus
|
||||
);
|
||||
|
||||
//
|
||||
// Destroy all the resource tree
|
||||
|
@ -984,18 +955,18 @@ PciHostBridgeResourceAllocator_WithHotPlugDeviceSupport (
|
|||
// enumerator. Several resource tree was created
|
||||
//
|
||||
Status = GetResourceMap (
|
||||
RootBridgeDev,
|
||||
&IoBridge,
|
||||
&Mem32Bridge,
|
||||
&PMem32Bridge,
|
||||
&Mem64Bridge,
|
||||
&PMem64Bridge,
|
||||
&IoPool,
|
||||
&Mem32Pool,
|
||||
&PMem32Pool,
|
||||
&Mem64Pool,
|
||||
&PMem64Pool
|
||||
);
|
||||
RootBridgeDev,
|
||||
&IoBridge,
|
||||
&Mem32Bridge,
|
||||
&PMem32Bridge,
|
||||
&Mem64Bridge,
|
||||
&PMem64Bridge,
|
||||
&IoPool,
|
||||
&Mem32Pool,
|
||||
&PMem32Pool,
|
||||
&Mem64Pool,
|
||||
&PMem64Pool
|
||||
);
|
||||
|
||||
if (EFI_ERROR (Status)) {
|
||||
return Status;
|
||||
|
@ -1447,7 +1418,7 @@ PciScanBus_WithHotPlugDeviceSupport (
|
|||
&BusRange
|
||||
);
|
||||
|
||||
gBS->FreePool (Descriptors);
|
||||
FreePool (Descriptors);
|
||||
|
||||
if (EFI_ERROR (Status)) {
|
||||
return Status;
|
||||
|
@ -1787,7 +1758,7 @@ PciHostBridgeEnumerator (
|
|||
StartBusNumber
|
||||
);
|
||||
|
||||
gBS->FreePool (Configuration);
|
||||
FreePool (Configuration);
|
||||
Link = GetNextNode (&RootBridgeList, Link);
|
||||
DestroyRootBridge (RootBridgeDev);
|
||||
}
|
||||
|
|
|
@ -49,14 +49,6 @@ typedef struct {
|
|||
UINT8 *AllocRes;
|
||||
} EFI_RESOURCE_ALLOC_FAILURE_ERROR_DATA_PAYLOAD;
|
||||
|
||||
/**
|
||||
Install protocol gEfiPciHotPlugRequestProtocolGuid
|
||||
@param Status return status of protocol installation.
|
||||
**/
|
||||
VOID
|
||||
InstallHotPlugRequestProtocol (
|
||||
IN EFI_STATUS *Status
|
||||
);
|
||||
|
||||
/**
|
||||
Retrieve the BAR information via PciIo interface.
|
||||
|
|
|
@ -140,7 +140,7 @@ LocalLoadFile2 (
|
|||
Scratch,
|
||||
ScratchSize
|
||||
);
|
||||
gBS->FreePool (Scratch);
|
||||
FreePool (Scratch);
|
||||
|
||||
if (EFI_ERROR (Status)) {
|
||||
return EFI_DEVICE_ERROR;
|
||||
|
@ -432,7 +432,7 @@ LoadOpRomImage (
|
|||
|
||||
RomPcir = AllocatePool (sizeof (PCI_DATA_STRUCTURE));
|
||||
if (RomPcir == NULL) {
|
||||
gBS->FreePool (RomHeader);
|
||||
FreePool (RomHeader);
|
||||
return EFI_OUT_OF_RESOURCES;
|
||||
}
|
||||
|
||||
|
@ -496,8 +496,8 @@ LoadOpRomImage (
|
|||
Image = AllocatePool ((UINT32) RomImageSize);
|
||||
if (Image == NULL) {
|
||||
RomDecode (PciDevice, RomBarIndex, RomBar, FALSE);
|
||||
gBS->FreePool (RomHeader);
|
||||
gBS->FreePool (RomPcir);
|
||||
FreePool (RomHeader);
|
||||
FreePool (RomPcir);
|
||||
return EFI_OUT_OF_RESOURCES;
|
||||
}
|
||||
|
||||
|
@ -536,8 +536,8 @@ LoadOpRomImage (
|
|||
//
|
||||
// Free allocated memory
|
||||
//
|
||||
gBS->FreePool (RomHeader);
|
||||
gBS->FreePool (RomPcir);
|
||||
FreePool (RomHeader);
|
||||
FreePool (RomPcir);
|
||||
|
||||
return RetStatus;
|
||||
}
|
||||
|
@ -725,7 +725,7 @@ ProcessOpRomImage (
|
|||
);
|
||||
}
|
||||
|
||||
gBS->FreePool (PciOptionRomImageDevicePath);
|
||||
FreePool (PciOptionRomImageDevicePath);
|
||||
|
||||
if (!EFI_ERROR (Status)) {
|
||||
Status = gBS->StartImage (ImageHandle, NULL, NULL);
|
||||
|
|
|
@ -66,7 +66,7 @@ PciRomAddImageMapping (
|
|||
CopyMem (TempMapping, mRomImageTable, mNumberOfPciRomImages * sizeof (EFI_PCI_ROM_IMAGE_MAPPING));
|
||||
|
||||
if (mRomImageTable != NULL) {
|
||||
gBS->FreePool (mRomImageTable);
|
||||
FreePool (mRomImageTable);
|
||||
}
|
||||
|
||||
mRomImageTable = TempMapping;
|
||||
|
|
Loading…
Reference in New Issue