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
|
/** @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
|
All rights reserved. This program and the accompanying materials
|
||||||
are licensed and made available under the terms and conditions of the BSD License
|
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
|
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"
|
#include "PciBus.h"
|
||||||
|
|
||||||
//
|
//
|
||||||
// PCI Bus Driver Global Variables
|
// PCI Bus Driver Global Variables
|
||||||
//
|
//
|
||||||
|
|
||||||
EFI_DRIVER_BINDING_PROTOCOL gPciBusDriverBinding = {
|
EFI_DRIVER_BINDING_PROTOCOL gPciBusDriverBinding = {
|
||||||
PciBusDriverBindingSupported,
|
PciBusDriverBindingSupported,
|
||||||
PciBusDriverBindingStart,
|
PciBusDriverBindingStart,
|
||||||
|
@ -28,26 +26,32 @@ EFI_DRIVER_BINDING_PROTOCOL gPciBusDriverBinding = {
|
||||||
NULL
|
NULL
|
||||||
};
|
};
|
||||||
|
|
||||||
EFI_INCOMPATIBLE_PCI_DEVICE_SUPPORT_PROTOCOL *gEfiIncompatiblePciDeviceSupport = NULL;
|
|
||||||
EFI_HANDLE gPciHostBrigeHandles[PCI_MAX_HOST_BRIDGE_NUM];
|
EFI_HANDLE gPciHostBrigeHandles[PCI_MAX_HOST_BRIDGE_NUM];
|
||||||
UINTN gPciHostBridgeNumber;
|
EFI_INCOMPATIBLE_PCI_DEVICE_SUPPORT_PROTOCOL *gEfiIncompatiblePciDeviceSupport = NULL;
|
||||||
BOOLEAN gFullEnumeration;
|
UINTN gPciHostBridgeNumber = 0;
|
||||||
UINT64 gAllOne = 0xFFFFFFFFFFFFFFFFULL;
|
BOOLEAN gFullEnumeration = TRUE;
|
||||||
UINT64 gAllZero = 0;
|
UINT64 gAllOne = 0xFFFFFFFFFFFFFFFFULL;
|
||||||
|
UINT64 gAllZero = 0;
|
||||||
|
|
||||||
EFI_PCI_PLATFORM_PROTOCOL *gPciPlatformProtocol;
|
EFI_PCI_PLATFORM_PROTOCOL *gPciPlatformProtocol;
|
||||||
|
|
||||||
//
|
GLOBAL_REMOVE_IF_UNREFERENCED EFI_PCI_HOTPLUG_REQUEST_PROTOCOL mPciHotPlugRequest = {
|
||||||
// PCI Bus Driver Support Functions
|
PciHotPlugRequestNotify
|
||||||
//
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Initialize the global variables
|
The Entry Point for PCI Bus module. The user code starts with this function.
|
||||||
publish the driver binding protocol
|
|
||||||
|
|
||||||
@param[in] ImageHandle,
|
Installs driver module protocols and. Creates virtual device handles for ConIn,
|
||||||
@param[in] *SystemTable
|
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
|
EFI_STATUS
|
||||||
|
@ -58,13 +62,13 @@ PciBusEntryPoint (
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
EFI_STATUS Status;
|
EFI_STATUS Status;
|
||||||
|
EFI_HANDLE Handle;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Initializes PCI devices pool
|
||||||
|
//
|
||||||
InitializePciDevicePool ();
|
InitializePciDevicePool ();
|
||||||
|
|
||||||
gFullEnumeration = TRUE;
|
|
||||||
|
|
||||||
gPciHostBridgeNumber = 0;
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Install driver model protocol(s).
|
// Install driver model protocol(s).
|
||||||
//
|
//
|
||||||
|
@ -78,8 +82,19 @@ PciBusEntryPoint (
|
||||||
);
|
);
|
||||||
ASSERT_EFI_ERROR (Status);
|
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;
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -88,13 +103,13 @@ PciBusEntryPoint (
|
||||||
than contains a gEfiPciRootBridgeIoProtocolGuid protocol can be supported.
|
than contains a gEfiPciRootBridgeIoProtocolGuid protocol can be supported.
|
||||||
|
|
||||||
@param This Protocol instance pointer.
|
@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
|
@param RemainingDevicePath Optional parameter use to pick a specific child.
|
||||||
device to start.
|
device to start.
|
||||||
|
|
||||||
@retval EFI_SUCCESS This driver supports this device
|
@retval EFI_SUCCESS This driver supports this device.
|
||||||
@retval EFI_ALREADY_STARTED This driver is already running on this device
|
@retval EFI_ALREADY_STARTED This driver is already running on this device.
|
||||||
@retval other This driver does not support this device
|
@retval other This driver does not support this device.
|
||||||
|
|
||||||
**/
|
**/
|
||||||
EFI_STATUS
|
EFI_STATUS
|
||||||
|
@ -175,13 +190,13 @@ PciBusDriverBindingSupported (
|
||||||
all device under PCI bus.
|
all device under PCI bus.
|
||||||
|
|
||||||
@param This Protocol instance pointer.
|
@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
|
@param RemainingDevicePath Optional parameter use to pick a specific child.
|
||||||
device to start.
|
device to start.
|
||||||
|
|
||||||
@retval EFI_SUCCESS This driver is added to ControllerHandle
|
@retval EFI_SUCCESS This driver is added to ControllerHandle.
|
||||||
@retval EFI_ALREADY_STARTED This driver is already running on ControllerHandle
|
@retval EFI_ALREADY_STARTED This driver is already running on ControllerHandle.
|
||||||
@retval other This driver does not support this device
|
@retval other This driver does not support this device.
|
||||||
|
|
||||||
**/
|
**/
|
||||||
EFI_STATUS
|
EFI_STATUS
|
||||||
|
@ -237,13 +252,13 @@ PciBusDriverBindingStart (
|
||||||
created by this driver.
|
created by this driver.
|
||||||
|
|
||||||
@param This Protocol instance pointer.
|
@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
|
@param NumberOfChildren Number of Handles in ChildHandleBuffer. If number of
|
||||||
children is zero stop the entire bus driver.
|
children is zero stop the entire bus driver.
|
||||||
@param ChildHandleBuffer List of Child Handles to Stop.
|
@param ChildHandleBuffer List of Child Handles to Stop.
|
||||||
|
|
||||||
@retval EFI_SUCCESS This driver is removed ControllerHandle
|
@retval EFI_SUCCESS This driver is removed ControllerHandle.
|
||||||
@retval other This driver was not removed from this device
|
@retval other This driver was not removed from this device.
|
||||||
|
|
||||||
**/
|
**/
|
||||||
EFI_STATUS
|
EFI_STATUS
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
/** @file
|
/** @file
|
||||||
|
Header files and data structures needed by PCI Bus module.
|
||||||
|
|
||||||
Copyright (c) 2006 - 2009, Intel Corporation
|
Copyright (c) 2006 - 2009, Intel Corporation
|
||||||
All rights reserved. This program and the accompanying materials
|
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_
|
#ifndef _EFI_PCI_BUS_H_
|
||||||
#define _EFI_PCI_BUS_H_
|
#define _EFI_PCI_BUS_H_
|
||||||
|
|
||||||
|
|
||||||
#include <FrameworkDxe.h>
|
#include <FrameworkDxe.h>
|
||||||
|
|
||||||
|
|
||||||
#include <Protocol/LoadedImage.h>
|
#include <Protocol/LoadedImage.h>
|
||||||
#include <Protocol/PciHostBridgeResourceAllocation.h>
|
#include <Protocol/PciHostBridgeResourceAllocation.h>
|
||||||
#include <Protocol/PciIo.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/PciHotPlugInit.h>
|
||||||
#include <Protocol/Decompress.h>
|
#include <Protocol/Decompress.h>
|
||||||
#include <Protocol/BusSpecificDriverOverride.h>
|
#include <Protocol/BusSpecificDriverOverride.h>
|
||||||
#include <Protocol/UgaIo.h>
|
|
||||||
#include <Protocol/IncompatiblePciDeviceSupport.h>
|
#include <Protocol/IncompatiblePciDeviceSupport.h>
|
||||||
|
|
||||||
#include <Library/DebugLib.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/Pci.h>
|
||||||
#include <IndustryStandard/PeImage.h>
|
#include <IndustryStandard/PeImage.h>
|
||||||
#include <IndustryStandard/Acpi.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"
|
#include "ComponentName.h"
|
||||||
|
#include "PciIo.h"
|
||||||
|
#include "PciCommand.h"
|
||||||
//
|
#include "PciDeviceSupport.h"
|
||||||
// Global Variables
|
#include "PciEnumerator.h"
|
||||||
//
|
#include "PciEnumeratorSupport.h"
|
||||||
extern EFI_INCOMPATIBLE_PCI_DEVICE_SUPPORT_PROTOCOL *gEfiIncompatiblePciDeviceSupport;
|
#include "PciDriverOverride.h"
|
||||||
extern EFI_DRIVER_BINDING_PROTOCOL gPciBusDriverBinding;
|
#include "PciRomTable.h"
|
||||||
extern EFI_COMPONENT_NAME_PROTOCOL gPciBusComponentName;
|
#include "PciOptionRomSupport.h"
|
||||||
extern EFI_COMPONENT_NAME2_PROTOCOL gPciBusComponentName2;
|
#include "PciPowerManagement.h"
|
||||||
|
#include "PciHotPlugSupport.h"
|
||||||
//
|
#include "PciLib.h"
|
||||||
// Driver Produced Protocol Prototypes
|
|
||||||
//
|
|
||||||
|
|
||||||
#define VGABASE1 0x3B0
|
#define VGABASE1 0x3B0
|
||||||
#define VGALIMIT1 0x3BB
|
#define VGALIMIT1 0x3BB
|
||||||
|
@ -73,7 +74,7 @@ extern EFI_COMPONENT_NAME2_PROTOCOL gPciBusComponentName2;
|
||||||
#define ISABASE 0x100
|
#define ISABASE 0x100
|
||||||
#define ISALIMIT 0x3FF
|
#define ISALIMIT 0x3FF
|
||||||
|
|
||||||
typedef enum {
|
enum _PCI_BAR_TYPE {
|
||||||
PciBarTypeUnknown = 0,
|
PciBarTypeUnknown = 0,
|
||||||
PciBarTypeIo16,
|
PciBarTypeIo16,
|
||||||
PciBarTypeIo32,
|
PciBarTypeIo32,
|
||||||
|
@ -84,9 +85,12 @@ typedef enum {
|
||||||
PciBarTypeIo,
|
PciBarTypeIo,
|
||||||
PciBarTypeMem,
|
PciBarTypeMem,
|
||||||
PciBarTypeMaxType
|
PciBarTypeMaxType
|
||||||
} PCI_BAR_TYPE;
|
};
|
||||||
|
|
||||||
typedef struct {
|
//
|
||||||
|
// PCI BAR parameters
|
||||||
|
//
|
||||||
|
struct _PCI_BAR {
|
||||||
UINT64 BaseAddress;
|
UINT64 BaseAddress;
|
||||||
UINT64 Length;
|
UINT64 Length;
|
||||||
UINT64 Alignment;
|
UINT64 Alignment;
|
||||||
|
@ -94,7 +98,7 @@ typedef struct {
|
||||||
BOOLEAN Prefetchable;
|
BOOLEAN Prefetchable;
|
||||||
UINT8 MemType;
|
UINT8 MemType;
|
||||||
UINT8 Offset;
|
UINT8 Offset;
|
||||||
} PCI_BAR;
|
};
|
||||||
|
|
||||||
#define PPB_BAR_0 0
|
#define PPB_BAR_0 0
|
||||||
#define PPB_BAR_1 1
|
#define PPB_BAR_1 1
|
||||||
|
@ -110,8 +114,6 @@ typedef struct {
|
||||||
#define P2C_IO_1 3
|
#define P2C_IO_1 3
|
||||||
#define P2C_IO_2 4
|
#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_IO32_DECODE_SUPPORTED 0x0001
|
||||||
#define EFI_BRIDGE_PMEM32_DECODE_SUPPORTED 0x0002
|
#define EFI_BRIDGE_PMEM32_DECODE_SUPPORTED 0x0002
|
||||||
#define EFI_BRIDGE_PMEM64_DECODE_SUPPORTED 0x0004
|
#define EFI_BRIDGE_PMEM64_DECODE_SUPPORTED 0x0004
|
||||||
|
@ -128,7 +130,7 @@ typedef struct {
|
||||||
#define EFI_SET_SUPPORTS 0
|
#define EFI_SET_SUPPORTS 0
|
||||||
#define EFI_SET_ATTRIBUTES 1
|
#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 {
|
struct _PCI_IO_DEVICE {
|
||||||
UINT32 Signature;
|
UINT32 Signature;
|
||||||
|
@ -215,7 +217,7 @@ struct _PCI_IO_DEVICE {
|
||||||
BOOLEAN BusOverride;
|
BOOLEAN BusOverride;
|
||||||
|
|
||||||
//
|
//
|
||||||
// A list tracking reserved resource on a bridge device
|
// A list tracking reserved resource on a bridge device
|
||||||
//
|
//
|
||||||
LIST_ENTRY ReservedResourceList;
|
LIST_ENTRY ReservedResourceList;
|
||||||
|
|
||||||
|
@ -231,7 +233,6 @@ struct _PCI_IO_DEVICE {
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
#define PCI_IO_DEVICE_FROM_PCI_IO_THIS(a) \
|
#define PCI_IO_DEVICE_FROM_PCI_IO_THIS(a) \
|
||||||
CR (a, PCI_IO_DEVICE, PciIo, PCI_IO_DEVICE_SIGNATURE)
|
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) \
|
#define PCI_IO_DEVICE_FROM_LOAD_FILE2_THIS(a) \
|
||||||
CR (a, PCI_IO_DEVICE, LoadFile2, PCI_IO_DEVICE_SIGNATURE)
|
CR (a, PCI_IO_DEVICE, LoadFile2, PCI_IO_DEVICE_SIGNATURE)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Global Variables
|
// 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 BOOLEAN gFullEnumeration;
|
||||||
extern UINTN gPciHostBridgeNumber;
|
extern UINTN gPciHostBridgeNumber;
|
||||||
extern EFI_HANDLE gPciHostBrigeHandles[PCI_MAX_HOST_BRIDGE_NUM];
|
extern EFI_HANDLE gPciHostBrigeHandles[PCI_MAX_HOST_BRIDGE_NUM];
|
||||||
extern UINT64 gAllOne;
|
extern UINT64 gAllOne;
|
||||||
extern UINT64 gAllZero;
|
extern UINT64 gAllZero;
|
||||||
|
|
||||||
extern EFI_PCI_PLATFORM_PROTOCOL *gPciPlatformProtocol;
|
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
|
Test to see if this driver supports ControllerHandle. Any ControllerHandle
|
||||||
than contains a gEfiPciRootBridgeIoProtocolGuid protocol can be supported.
|
than contains a gEfiPciRootBridgeIoProtocolGuid protocol can be supported.
|
||||||
|
|
||||||
@param This Protocol instance pointer.
|
@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.
|
@param RemainingDevicePath Optional parameter use to pick a specific child.
|
||||||
device to start.
|
device to start.
|
||||||
|
|
||||||
|
@ -298,7 +300,7 @@ PciBusDriverBindingSupported (
|
||||||
all device under PCI bus.
|
all device under PCI bus.
|
||||||
|
|
||||||
@param This Protocol instance pointer.
|
@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.
|
@param RemainingDevicePath Optional parameter use to pick a specific child.
|
||||||
device to start.
|
device to start.
|
||||||
|
|
||||||
|
@ -320,7 +322,7 @@ PciBusDriverBindingStart (
|
||||||
created by this driver.
|
created by this driver.
|
||||||
|
|
||||||
@param This Protocol instance pointer.
|
@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
|
@param NumberOfChildren Number of Handles in ChildHandleBuffer. If number of
|
||||||
children is zero stop the entire bus driver.
|
children is zero stop the entire bus driver.
|
||||||
@param ChildHandleBuffer List of Child Handles to Stop.
|
@param ChildHandleBuffer List of Child Handles to Stop.
|
||||||
|
@ -338,6 +340,4 @@ PciBusDriverBindingStop (
|
||||||
IN EFI_HANDLE *ChildHandleBuffer
|
IN EFI_HANDLE *ChildHandleBuffer
|
||||||
);
|
);
|
||||||
|
|
||||||
#define IS_PCI_GFX(_p) IS_CLASS2 (_p, PCI_CLASS_DISPLAY, PCI_CLASS_DISPLAY_OTHER)
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -3,7 +3,8 @@
|
||||||
#
|
#
|
||||||
# PCI bus driver. This module will probe all PCI devices and allocate MMIO and IO
|
# 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
|
# space for these devices. Please use PCD feature flag PcdPciBusHotplugDeviceSupport to enable
|
||||||
# support hot plug.
|
# hot plug supporting.
|
||||||
|
#
|
||||||
# Copyright (c) 2006 - 2009, Intel Corporation
|
# Copyright (c) 2006 - 2009, Intel Corporation
|
||||||
#
|
#
|
||||||
# All rights reserved. This program and the accompanying materials
|
# All rights reserved. This program and the accompanying materials
|
||||||
|
@ -86,18 +87,18 @@
|
||||||
PeCoffLib
|
PeCoffLib
|
||||||
|
|
||||||
[Protocols]
|
[Protocols]
|
||||||
gEfiPciHotPlugRequestProtocolGuid # PROTOCOL ALWAYS_PRODUCED
|
gEfiPciHotPlugRequestProtocolGuid ## BY_START
|
||||||
gEfiBusSpecificDriverOverrideProtocolGuid # PROTOCOL BY_START
|
gEfiPciIoProtocolGuid ## BY_START
|
||||||
gEfiPciIoProtocolGuid # PROTOCOL BY_START
|
gEfiDevicePathProtocolGuid ## BY_START
|
||||||
gEfiLoadedImageProtocolGuid # PROTOCOL TO_START
|
gEfiBusSpecificDriverOverrideProtocolGuid ## CONSUMED
|
||||||
gEfiDecompressProtocolGuid # PROTOCOL TO_START
|
gEfiLoadedImageProtocolGuid ## CONSUMED
|
||||||
gEfiPciHotPlugInitProtocolGuid # PROTOCOL TO_START
|
gEfiDecompressProtocolGuid ## CONSUMED
|
||||||
gEfiPciHostBridgeResourceAllocationProtocolGuid # PROTOCOL TO_START
|
gEfiPciHotPlugInitProtocolGuid ## CONSUMED
|
||||||
gEfiPciPlatformProtocolGuid # PROTOCOL TO_START
|
gEfiPciHostBridgeResourceAllocationProtocolGuid ## CONSUMED
|
||||||
gEfiPciRootBridgeIoProtocolGuid # PROTOCOL TO_START
|
gEfiPciPlatformProtocolGuid ## CONSUMED
|
||||||
gEfiDevicePathProtocolGuid # PROTOCOL TO_START
|
gEfiPciRootBridgeIoProtocolGuid ## CONSUMED
|
||||||
gEfiIncompatiblePciDeviceSupportProtocolGuid # PROTOCOL TO_START
|
gEfiIncompatiblePciDeviceSupportProtocolGuid ## CONSUMED
|
||||||
gEfiLoadFile2ProtocolGuid # SOMETIMES_CONSUMED
|
gEfiLoadFile2ProtocolGuid ## CONSUMED
|
||||||
|
|
||||||
[FeaturePcd.common]
|
[FeaturePcd.common]
|
||||||
gEfiIntelFrameworkModulePkgTokenSpaceGuid.PcdPciBusHotplugDeviceSupport
|
gEfiIntelFrameworkModulePkgTokenSpaceGuid.PcdPciBusHotplugDeviceSupport
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
/** @file
|
/** @file
|
||||||
|
Supporting functions implementaion for PCI devices management.
|
||||||
|
|
||||||
Copyright (c) 2006 - 2009, Intel Corporation
|
Copyright (c) 2006 - 2009, Intel Corporation
|
||||||
All rights reserved. This program and the accompanying materials
|
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 "PciBus.h"
|
||||||
#include "PciDeviceSupport.h"
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// This device structure is serviced as a header.
|
// 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 (
|
InitializePciDevicePool (
|
||||||
VOID
|
VOID
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
InitializeListHead (&gPciDevicePool);
|
InitializeListHead (&mPciDevicePool);
|
||||||
|
|
||||||
return EFI_SUCCESS;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
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 (
|
InsertRootBridge (
|
||||||
PCI_IO_DEVICE *RootBridge
|
IN PCI_IO_DEVICE *RootBridge
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
|
InsertTailList (&mPciDevicePool, &(RootBridge->Link));
|
||||||
InsertTailList (&gPciDevicePool, &(RootBridge->Link));
|
|
||||||
|
|
||||||
return EFI_SUCCESS;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
This function is used to insert a PCI device node under
|
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 Bridge The PCI bridge.
|
||||||
@param PciDeviceNode A pointer to the PCI_IO_DEVICE.
|
@param PciDeviceNode The PCI device needs inserting.
|
||||||
|
|
||||||
**/
|
**/
|
||||||
EFI_STATUS
|
VOID
|
||||||
InsertPciDevice (
|
InsertPciDevice (
|
||||||
PCI_IO_DEVICE *Bridge,
|
IN PCI_IO_DEVICE *Bridge,
|
||||||
PCI_IO_DEVICE *PciDeviceNode
|
IN PCI_IO_DEVICE *PciDeviceNode
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
|
|
||||||
InsertTailList (&Bridge->ChildList, &(PciDeviceNode->Link));
|
InsertTailList (&Bridge->ChildList, &(PciDeviceNode->Link));
|
||||||
PciDeviceNode->Parent = Bridge;
|
PciDeviceNode->Parent = Bridge;
|
||||||
|
|
||||||
return EFI_SUCCESS;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Destroy root bridge and remove it from deivce tree.
|
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 (
|
DestroyRootBridge (
|
||||||
IN PCI_IO_DEVICE *RootBridge
|
IN PCI_IO_DEVICE *RootBridge
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
DestroyPciDeviceTree (RootBridge);
|
DestroyPciDeviceTree (RootBridge);
|
||||||
|
|
||||||
FreePciDevice (RootBridge);
|
FreePciDevice (RootBridge);
|
||||||
|
|
||||||
return EFI_SUCCESS;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Destroy a pci device node.
|
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 (
|
FreePciDevice (
|
||||||
IN PCI_IO_DEVICE *PciIoDevice
|
IN PCI_IO_DEVICE *PciIoDevice
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
|
ASSERT (PciIoDevice != NULL);
|
||||||
//
|
//
|
||||||
// Assume all children have been removed underneath this device
|
// Assume all children have been removed underneath this device
|
||||||
//
|
//
|
||||||
if (PciIoDevice->ResourcePaddingDescriptors != NULL) {
|
if (PciIoDevice->ResourcePaddingDescriptors != NULL) {
|
||||||
gBS->FreePool (PciIoDevice->ResourcePaddingDescriptors);
|
FreePool (PciIoDevice->ResourcePaddingDescriptors);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (PciIoDevice->DevicePath != NULL) {
|
if (PciIoDevice->DevicePath != NULL) {
|
||||||
gBS->FreePool (PciIoDevice->DevicePath);
|
FreePool (PciIoDevice->DevicePath);
|
||||||
}
|
}
|
||||||
|
|
||||||
gBS->FreePool (PciIoDevice);
|
FreePool (PciIoDevice);
|
||||||
|
|
||||||
return EFI_SUCCESS;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Destroy all the pci device node under the bridge.
|
Destroy all the pci device node under the bridge.
|
||||||
Bridge itself is not included.
|
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 (
|
DestroyPciDeviceTree (
|
||||||
IN PCI_IO_DEVICE *Bridge
|
IN PCI_IO_DEVICE *Bridge
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
LIST_ENTRY *CurrentLink;
|
LIST_ENTRY *CurrentLink;
|
||||||
|
@ -151,30 +140,33 @@ DestroyPciDeviceTree (
|
||||||
|
|
||||||
FreePciDevice (Temp);
|
FreePciDevice (Temp);
|
||||||
}
|
}
|
||||||
|
|
||||||
return EFI_SUCCESS;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Destroy all device nodes under the root bridge
|
Destroy all device nodes under the root bridge
|
||||||
specified by Controller.
|
specified by Controller.
|
||||||
|
|
||||||
The root bridge itself is also included.
|
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
|
EFI_STATUS
|
||||||
DestroyRootBridgeByHandle (
|
DestroyRootBridgeByHandle (
|
||||||
EFI_HANDLE Controller
|
IN EFI_HANDLE Controller
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
|
|
||||||
LIST_ENTRY *CurrentLink;
|
LIST_ENTRY *CurrentLink;
|
||||||
PCI_IO_DEVICE *Temp;
|
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);
|
Temp = PCI_IO_DEVICE_FROM_LINK (CurrentLink);
|
||||||
|
|
||||||
if (Temp->Handle == Controller) {
|
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
|
This function registers the 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.
|
|
||||||
|
|
||||||
@param Controller - An EFI handle for the PCI bus controller.
|
It creates a handle for this PCI IO device (if the handle does not exist), attaches
|
||||||
@param PciIoDevice - A PCI_IO_DEVICE pointer to the PCI IO device to be registered.
|
appropriate protocols onto the handle, does necessary initialization, and sets up
|
||||||
@param Handle - A pointer to hold the EFI handle for the PCI IO device.
|
parent/child relationship with its bus controller.
|
||||||
|
|
||||||
@retval EFI_SUCCESS - The PCI device is successfully registered.
|
@param Controller An EFI handle for the PCI bus controller.
|
||||||
@retval Others - An error occurred when registering the PCI device.
|
@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
|
EFI_STATUS
|
||||||
RegisterPciDevice (
|
RegisterPciDevice (
|
||||||
IN EFI_HANDLE Controller,
|
IN EFI_HANDLE Controller,
|
||||||
IN PCI_IO_DEVICE *PciIoDevice,
|
IN PCI_IO_DEVICE *PciIoDevice,
|
||||||
OUT EFI_HANDLE *Handle OPTIONAL
|
OUT EFI_HANDLE *Handle OPTIONAL
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
EFI_STATUS Status;
|
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 RootBridgeHandle The root bridge device handle.
|
||||||
@param Bridge A pointer to the PCI_IO_DEVICE.
|
@param Bridge The bridge device to be removed.
|
||||||
|
|
||||||
@retval EFI_SUCCESS
|
|
||||||
**/
|
**/
|
||||||
EFI_STATUS
|
VOID
|
||||||
RemoveAllPciDeviceOnBridge (
|
RemoveAllPciDeviceOnBridge (
|
||||||
EFI_HANDLE RootBridgeHandle,
|
EFI_HANDLE RootBridgeHandle,
|
||||||
PCI_IO_DEVICE *Bridge
|
PCI_IO_DEVICE *Bridge
|
||||||
)
|
)
|
||||||
|
|
||||||
{
|
{
|
||||||
|
|
||||||
LIST_ENTRY *CurrentLink;
|
LIST_ENTRY *CurrentLink;
|
||||||
PCI_IO_DEVICE *Temp;
|
PCI_IO_DEVICE *Temp;
|
||||||
|
|
||||||
|
@ -433,20 +425,20 @@ RemoveAllPciDeviceOnBridge (
|
||||||
|
|
||||||
FreePciDevice (Temp);
|
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
|
That includes un-installing PciIo protocol from the specified PCI
|
||||||
device handle.
|
device handle.
|
||||||
|
|
||||||
@param Controller - controller handle
|
@param Controller An EFI handle for the PCI bus controller.
|
||||||
@param Handle - device handle
|
@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
|
EFI_STATUS
|
||||||
DeRegisterPciDevice (
|
DeRegisterPciDevice (
|
||||||
|
@ -595,13 +587,13 @@ DeRegisterPciDevice (
|
||||||
/**
|
/**
|
||||||
Start to manage the PCI device on specified the root bridge or PCI-PCI Bridge
|
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 RootBridge A pointer to the PCI_IO_DEVICE.
|
||||||
@param RemainingDevicePath A pointer to the EFI_DEVICE_PATH_PROTOCOL.
|
@param RemainingDevicePath A pointer to the EFI_DEVICE_PATH_PROTOCOL.
|
||||||
@param NumberOfChildren Children number.
|
@param NumberOfChildren Children number.
|
||||||
@param ChildHandleBuffer A pointer to the child handle buffer.
|
@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_UNSUPPORTED Device only support PCI-PCI bridge.
|
||||||
@retval EFI_NOT_FOUND Can not find the specific device
|
@retval EFI_NOT_FOUND Can not find the specific device
|
||||||
@retval EFI_SUCCESS Success to start Pci device on bridge
|
@retval EFI_SUCCESS Success to start Pci device on bridge
|
||||||
|
@ -713,7 +705,6 @@ StartPciDevicesOnBridge (
|
||||||
// If remaining device path is NULL,
|
// If remaining device path is NULL,
|
||||||
// try to enable all the pci devices under this bridge
|
// try to enable all the pci devices under this bridge
|
||||||
//
|
//
|
||||||
|
|
||||||
if (!PciIoDevice->Registered && PciIoDevice->Allocated) {
|
if (!PciIoDevice->Registered && PciIoDevice->Allocated) {
|
||||||
Status = RegisterPciDevice (
|
Status = RegisterPciDevice (
|
||||||
Controller,
|
Controller,
|
||||||
|
@ -764,7 +755,7 @@ StartPciDevicesOnBridge (
|
||||||
Start to manage all the PCI devices it found previously under
|
Start to manage all the PCI devices it found previously under
|
||||||
the entire host bridge.
|
the entire host bridge.
|
||||||
|
|
||||||
@param Controller - root bridge handle.
|
@param Controller The root bridge handle.
|
||||||
|
|
||||||
**/
|
**/
|
||||||
EFI_STATUS
|
EFI_STATUS
|
||||||
|
@ -781,9 +772,9 @@ StartPciDevices (
|
||||||
ASSERT (RootBridge != NULL);
|
ASSERT (RootBridge != NULL);
|
||||||
ThisHostBridge = RootBridge->PciRootBridgeIo->ParentHandle;
|
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);
|
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 *
|
PCI_IO_DEVICE *
|
||||||
CreateRootBridge (
|
CreateRootBridge (
|
||||||
IN EFI_HANDLE RootBridgeHandle
|
IN EFI_HANDLE RootBridgeHandle
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
|
|
||||||
EFI_STATUS Status;
|
EFI_STATUS Status;
|
||||||
PCI_IO_DEVICE *Dev;
|
PCI_IO_DEVICE *Dev;
|
||||||
EFI_DEVICE_PATH_PROTOCOL *ParentDevicePath;
|
EFI_DEVICE_PATH_PROTOCOL *ParentDevicePath;
|
||||||
EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *PciRootBridgeIo;
|
EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *PciRootBridgeIo;
|
||||||
|
|
||||||
Dev = NULL;
|
Dev = AllocateZeroPool (sizeof (PCI_IO_DEVICE));
|
||||||
Status = gBS->AllocatePool (
|
if (Dev == NULL) {
|
||||||
EfiBootServicesData,
|
|
||||||
sizeof (PCI_IO_DEVICE),
|
|
||||||
(VOID **) &Dev
|
|
||||||
);
|
|
||||||
|
|
||||||
if (EFI_ERROR (Status)) {
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
ZeroMem (Dev, sizeof (PCI_IO_DEVICE));
|
|
||||||
Dev->Signature = PCI_IO_DEVICE_SIGNATURE;
|
Dev->Signature = PCI_IO_DEVICE_SIGNATURE;
|
||||||
Dev->Handle = RootBridgeHandle;
|
Dev->Handle = RootBridgeHandle;
|
||||||
InitializeListHead (&Dev->ChildList);
|
InitializeListHead (&Dev->ChildList);
|
||||||
|
@ -849,7 +834,7 @@ CreateRootBridge (
|
||||||
);
|
);
|
||||||
|
|
||||||
if (EFI_ERROR (Status)) {
|
if (EFI_ERROR (Status)) {
|
||||||
gBS->FreePool (Dev);
|
FreePool (Dev);
|
||||||
return NULL;
|
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.
|
@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 *
|
PCI_IO_DEVICE *
|
||||||
GetRootBridgeByHandle (
|
GetRootBridgeByHandle (
|
||||||
|
@ -909,9 +896,9 @@ GetRootBridgeByHandle (
|
||||||
PCI_IO_DEVICE *RootBridgeDev;
|
PCI_IO_DEVICE *RootBridgeDev;
|
||||||
LIST_ENTRY *CurrentLink;
|
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);
|
RootBridgeDev = PCI_IO_DEVICE_FROM_LINK (CurrentLink);
|
||||||
if (RootBridgeDev->Handle == RootBridgeHandle) {
|
if (RootBridgeDev->Handle == RootBridgeHandle) {
|
||||||
|
@ -930,7 +917,9 @@ GetRootBridgeByHandle (
|
||||||
@param Bridge Parent bridege instance.
|
@param Bridge Parent bridege instance.
|
||||||
@param PciIoDevice Device instance.
|
@param PciIoDevice Device instance.
|
||||||
|
|
||||||
@return whether Pci device existed.
|
@retval TRUE Pci device existed.
|
||||||
|
@retval FALSE Pci device did not exist.
|
||||||
|
|
||||||
**/
|
**/
|
||||||
BOOLEAN
|
BOOLEAN
|
||||||
PciDeviceExisted (
|
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 *
|
PCI_IO_DEVICE *
|
||||||
ActiveVGADeviceOnTheSameSegment (
|
ActiveVGADeviceOnTheSameSegment (
|
||||||
|
@ -979,9 +969,9 @@ ActiveVGADeviceOnTheSameSegment (
|
||||||
LIST_ENTRY *CurrentLink;
|
LIST_ENTRY *CurrentLink;
|
||||||
PCI_IO_DEVICE *Temp;
|
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);
|
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 *
|
PCI_IO_DEVICE *
|
||||||
ActiveVGADeviceOnTheRootBridge (
|
ActiveVGADeviceOnTheRootBridge (
|
||||||
|
@ -1044,92 +1035,17 @@ ActiveVGADeviceOnTheRootBridge (
|
||||||
return NULL;
|
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.
|
Get HPC PCI address according to its device path.
|
||||||
|
|
||||||
@param RootBridge Root bridege Io instance.
|
@param RootBridge Root bridege Io instance.
|
||||||
@param RemainingDevicePath Given searching device path.
|
@param RemainingDevicePath Given searching device path.
|
||||||
@param PciAddress Buffer holding searched result.
|
@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
|
EFI_STATUS
|
||||||
GetHpcPciAddressFromRootBridge (
|
GetHpcPciAddressFromRootBridge (
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
/** @file
|
/** @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
|
All rights reserved. This program and the accompanying materials
|
||||||
are licensed and made available under the terms and conditions of the BSD License
|
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
|
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_
|
#define _EFI_PCI_DEVICE_SUPPORT_H_
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Initialize the gPciDevicePool.
|
Initialize the PCI devices pool.
|
||||||
|
|
||||||
**/
|
**/
|
||||||
EFI_STATUS
|
VOID
|
||||||
InitializePciDevicePool (
|
InitializePciDevicePool (
|
||||||
VOID
|
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 (
|
InsertRootBridge (
|
||||||
PCI_IO_DEVICE *RootBridge
|
IN PCI_IO_DEVICE *RootBridge
|
||||||
);
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
This function is used to insert a PCI device node under
|
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 Bridge The PCI bridge.
|
||||||
@param PciDeviceNode A pointer to the PCI_IO_DEVICE.
|
@param PciDeviceNode The PCI device needs inserting.
|
||||||
|
|
||||||
**/
|
**/
|
||||||
EFI_STATUS
|
VOID
|
||||||
InsertPciDevice (
|
InsertPciDevice (
|
||||||
PCI_IO_DEVICE *Bridge,
|
IN PCI_IO_DEVICE *Bridge,
|
||||||
PCI_IO_DEVICE *PciDeviceNode
|
IN PCI_IO_DEVICE *PciDeviceNode
|
||||||
);
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Destroy root bridge and remove it from deivce tree.
|
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 (
|
DestroyRootBridge (
|
||||||
IN PCI_IO_DEVICE *RootBridge
|
IN PCI_IO_DEVICE *RootBridge
|
||||||
);
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Destroy all the pci device node under the bridge.
|
Destroy all the pci device node under the bridge.
|
||||||
Bridge itself is not included.
|
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 (
|
DestroyPciDeviceTree (
|
||||||
IN PCI_IO_DEVICE *Bridge
|
IN PCI_IO_DEVICE *Bridge
|
||||||
);
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Destroy all device nodes under the root bridge
|
Destroy all device nodes under the root bridge
|
||||||
specified by Controller.
|
specified by Controller.
|
||||||
|
|
||||||
The root bridge itself is also included.
|
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
|
EFI_STATUS
|
||||||
DestroyRootBridgeByHandle (
|
DestroyRootBridgeByHandle (
|
||||||
EFI_HANDLE Controller
|
IN EFI_HANDLE Controller
|
||||||
);
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
This function registers the PCI IO device. It creates a handle for this PCI IO device
|
This function registers the 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.
|
|
||||||
|
|
||||||
@param Controller - An EFI handle for the PCI bus controller.
|
It creates a handle for this PCI IO device (if the handle does not exist), attaches
|
||||||
@param PciIoDevice - A PCI_IO_DEVICE pointer to the PCI IO device to be registered.
|
appropriate protocols onto the handle, does necessary initialization, and sets up
|
||||||
@param Handle - A pointer to hold the EFI handle for the PCI IO device.
|
parent/child relationship with its bus controller.
|
||||||
|
|
||||||
@retval EFI_SUCCESS - The PCI device is successfully registered.
|
@param Controller An EFI handle for the PCI bus controller.
|
||||||
@retval Others - An error occurred when registering the PCI device.
|
@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
|
EFI_STATUS
|
||||||
RegisterPciDevice (
|
RegisterPciDevice (
|
||||||
IN EFI_HANDLE Controller,
|
IN EFI_HANDLE Controller,
|
||||||
IN PCI_IO_DEVICE *PciIoDevice,
|
IN PCI_IO_DEVICE *PciIoDevice,
|
||||||
OUT EFI_HANDLE *Handle OPTIONAL
|
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 RootBridgeHandle The root bridge device handle.
|
||||||
@param Bridge A pointer to the PCI_IO_DEVICE.
|
@param Bridge The bridge device to be removed.
|
||||||
|
|
||||||
@retval EFI_SUCCESS
|
|
||||||
**/
|
**/
|
||||||
EFI_STATUS
|
VOID
|
||||||
RemoveAllPciDeviceOnBridge (
|
RemoveAllPciDeviceOnBridge (
|
||||||
EFI_HANDLE RootBridgeHandle,
|
EFI_HANDLE RootBridgeHandle,
|
||||||
PCI_IO_DEVICE *Bridge
|
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
|
That includes un-installing PciIo protocol from the specified PCI
|
||||||
device handle.
|
device handle.
|
||||||
|
|
||||||
@param Controller - controller handle
|
@param Controller An EFI handle for the PCI bus controller.
|
||||||
@param Handle - device handle
|
@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
|
EFI_STATUS
|
||||||
DeRegisterPciDevice (
|
DeRegisterPciDevice (
|
||||||
|
@ -143,7 +154,7 @@ DeRegisterPciDevice (
|
||||||
@param NumberOfChildren Children number.
|
@param NumberOfChildren Children number.
|
||||||
@param ChildHandleBuffer A pointer to the child handle buffer.
|
@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_UNSUPPORTED Device only support PCI-PCI bridge.
|
||||||
@retval EFI_NOT_FOUND Can not find the specific device
|
@retval EFI_NOT_FOUND Can not find the specific device
|
||||||
@retval EFI_SUCCESS Success to start Pci device on bridge
|
@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 *
|
PCI_IO_DEVICE *
|
||||||
CreateRootBridge (
|
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.
|
@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 *
|
PCI_IO_DEVICE *
|
||||||
GetRootBridgeByHandle (
|
GetRootBridgeByHandle (
|
||||||
EFI_HANDLE RootBridgeHandle
|
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.
|
Judege whether Pci device existed.
|
||||||
|
|
||||||
@param Bridge Parent bridege instance.
|
@param Bridge Parent bridege instance.
|
||||||
@param PciIoDevice Device instance.
|
@param PciIoDevice Device instance.
|
||||||
|
|
||||||
@return whether Pci device existed.
|
@retval TRUE Pci device existed.
|
||||||
|
@retval FALSE Pci device did not exist.
|
||||||
|
|
||||||
**/
|
**/
|
||||||
BOOLEAN
|
BOOLEAN
|
||||||
PciDeviceExisted (
|
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 *
|
PCI_IO_DEVICE *
|
||||||
ActiveVGADeviceOnTheSameSegment (
|
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 *
|
PCI_IO_DEVICE *
|
||||||
ActiveVGADeviceOnTheRootBridge (
|
ActiveVGADeviceOnTheRootBridge (
|
||||||
|
@ -246,27 +254,14 @@ ActiveVGADeviceOnTheRootBridge (
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Get HPC PCI address according to its device path.
|
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 RootBridge Root bridege Io instance.
|
||||||
@param RemainingDevicePath Given searching device path.
|
@param RemainingDevicePath Given searching device path.
|
||||||
@param PciAddress Buffer holding searched result.
|
@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
|
EFI_STATUS
|
||||||
GetHpcPciAddressFromRootBridge (
|
GetHpcPciAddressFromRootBridge (
|
||||||
|
@ -277,14 +272,15 @@ GetHpcPciAddressFromRootBridge (
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Destroy a pci device node.
|
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 (
|
FreePciDevice (
|
||||||
IN PCI_IO_DEVICE *PciIoDevice
|
IN PCI_IO_DEVICE *PciIoDevice
|
||||||
);
|
);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -223,7 +223,7 @@ PciRootBridgeEnumerator (
|
||||||
Configuration
|
Configuration
|
||||||
);
|
);
|
||||||
|
|
||||||
gBS->FreePool (Configuration);
|
FreePool (Configuration);
|
||||||
|
|
||||||
if (EFI_ERROR (Status)) {
|
if (EFI_ERROR (Status)) {
|
||||||
return Status;
|
return Status;
|
||||||
|
@ -683,9 +683,9 @@ RejectPciDevice (
|
||||||
//
|
//
|
||||||
// Remove the padding resource from a bridge
|
// Remove the padding resource from a bridge
|
||||||
//
|
//
|
||||||
if ( IS_PCI_BRIDGE(&PciDevice->Pci) && \
|
if ( IS_PCI_BRIDGE(&PciDevice->Pci) &&
|
||||||
PciDevice->ResourcePaddingDescriptors != NULL ) {
|
PciDevice->ResourcePaddingDescriptors != NULL ) {
|
||||||
gBS->FreePool (PciDevice->ResourcePaddingDescriptors);
|
FreePool (PciDevice->ResourcePaddingDescriptors);
|
||||||
PciDevice->ResourcePaddingDescriptors = NULL;
|
PciDevice->ResourcePaddingDescriptors = NULL;
|
||||||
return EFI_SUCCESS;
|
return EFI_SUCCESS;
|
||||||
}
|
}
|
||||||
|
@ -1950,7 +1950,7 @@ PciHotPlugRequestNotify (
|
||||||
ChildHandleBuffer
|
ChildHandleBuffer
|
||||||
);
|
);
|
||||||
|
|
||||||
return EFI_SUCCESS;
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Operation == EfiPciHotplugRequestRemove) {
|
if (Operation == EfiPciHotplugRequestRemove) {
|
||||||
|
@ -1959,8 +1959,8 @@ PciHotPlugRequestNotify (
|
||||||
//
|
//
|
||||||
// Remove all devices on the bridge
|
// Remove all devices on the bridge
|
||||||
//
|
//
|
||||||
Status = RemoveAllPciDeviceOnBridge (RootBridgeHandle, Bridge);
|
RemoveAllPciDeviceOnBridge (RootBridgeHandle, Bridge);
|
||||||
return Status;
|
return EFI_SUCCESS;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1224,7 +1224,9 @@ UpdatePciInfo (
|
||||||
Ptr++;
|
Ptr++;
|
||||||
}
|
}
|
||||||
|
|
||||||
gBS->FreePool (Configuration);
|
if (Configuration != NULL) {
|
||||||
|
FreePool (Configuration);
|
||||||
|
}
|
||||||
return Status;
|
return Status;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1618,24 +1620,13 @@ CreatePciIoDevice (
|
||||||
UINT8 Func
|
UINT8 Func
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
|
|
||||||
EFI_STATUS Status;
|
|
||||||
PCI_IO_DEVICE *PciIoDevice;
|
PCI_IO_DEVICE *PciIoDevice;
|
||||||
|
|
||||||
PciIoDevice = NULL;
|
PciIoDevice = AllocateZeroPool (sizeof (PCI_IO_DEVICE));
|
||||||
|
if (PciIoDevice == NULL) {
|
||||||
Status = gBS->AllocatePool (
|
|
||||||
EfiBootServicesData,
|
|
||||||
sizeof (PCI_IO_DEVICE),
|
|
||||||
(VOID **) &PciIoDevice
|
|
||||||
);
|
|
||||||
|
|
||||||
if (EFI_ERROR (Status)) {
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
ZeroMem (PciIoDevice, sizeof (PCI_IO_DEVICE));
|
|
||||||
|
|
||||||
PciIoDevice->Signature = PCI_IO_DEVICE_SIGNATURE;
|
PciIoDevice->Signature = PCI_IO_DEVICE_SIGNATURE;
|
||||||
PciIoDevice->Handle = NULL;
|
PciIoDevice->Handle = NULL;
|
||||||
PciIoDevice->PciRootBridgeIo = PciRootBridgeIo;
|
PciIoDevice->PciRootBridgeIo = PciRootBridgeIo;
|
||||||
|
@ -1644,6 +1635,7 @@ CreatePciIoDevice (
|
||||||
PciIoDevice->DeviceNumber = Device;
|
PciIoDevice->DeviceNumber = Device;
|
||||||
PciIoDevice->FunctionNumber = Func;
|
PciIoDevice->FunctionNumber = Func;
|
||||||
PciIoDevice->Decodes = 0;
|
PciIoDevice->Decodes = 0;
|
||||||
|
|
||||||
if (gFullEnumeration) {
|
if (gFullEnumeration) {
|
||||||
PciIoDevice->Allocated = FALSE;
|
PciIoDevice->Allocated = FALSE;
|
||||||
} else {
|
} else {
|
||||||
|
@ -1663,7 +1655,6 @@ CreatePciIoDevice (
|
||||||
//
|
//
|
||||||
// Initialize the PCI I/O instance structure
|
// Initialize the PCI I/O instance structure
|
||||||
//
|
//
|
||||||
|
|
||||||
InitializePciIoInstance (PciIoDevice);
|
InitializePciIoInstance (PciIoDevice);
|
||||||
InitializePciDriverOverrideInstance (PciIoDevice);
|
InitializePciDriverOverrideInstance (PciIoDevice);
|
||||||
InitializePciLoadFile2 (PciIoDevice);
|
InitializePciLoadFile2 (PciIoDevice);
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/** @file
|
/** @file
|
||||||
Implement all interfaces for EFI_PCI_IO_PROTOCOL.
|
Implements all interfaces for EFI_PCI_IO_PROTOCOL.
|
||||||
|
|
||||||
Copyright (c) 2006 - 2008, Intel Corporation
|
Copyright (c) 2006 - 2008, Intel Corporation
|
||||||
All rights reserved. This program and the accompanying materials
|
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"
|
#include "PciBus.h"
|
||||||
|
|
||||||
//
|
|
||||||
// Internal use only
|
|
||||||
//
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Pci Io Protocol Interface
|
// Pci Io Protocol Interface
|
||||||
//
|
//
|
||||||
EFI_PCI_IO_PROTOCOL PciIoInterface = {
|
EFI_PCI_IO_PROTOCOL mPciIoInterface = {
|
||||||
PciIoPollMem,
|
PciIoPollMem,
|
||||||
PciIoPollIo,
|
PciIoPollIo,
|
||||||
{
|
{
|
||||||
|
@ -56,6 +52,7 @@ EFI_PCI_IO_PROTOCOL PciIoInterface = {
|
||||||
|
|
||||||
@param PciIoDevice Pci device instance.
|
@param PciIoDevice Pci device instance.
|
||||||
@param Code status code.
|
@param Code status code.
|
||||||
|
|
||||||
**/
|
**/
|
||||||
EFI_STATUS
|
EFI_STATUS
|
||||||
ReportErrorStatusCode (
|
ReportErrorStatusCode (
|
||||||
|
@ -98,7 +95,7 @@ InitializePciIoInstance (
|
||||||
PCI_IO_DEVICE *PciIoDevice
|
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
|
/** @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
|
All rights reserved. This program and the accompanying materials
|
||||||
are licensed and made available under the terms and conditions of the BSD License
|
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
|
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"
|
#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.
|
Retrieve the BAR information via PciIo interface.
|
||||||
|
@ -68,12 +41,12 @@ GetBackPcCardBar (
|
||||||
|
|
||||||
Address = 0;
|
Address = 0;
|
||||||
PciIoRead (
|
PciIoRead (
|
||||||
&(PciIoDevice->PciIo),
|
&(PciIoDevice->PciIo),
|
||||||
EfiPciIoWidthUint32,
|
EfiPciIoWidthUint32,
|
||||||
0x1c,
|
0x1c,
|
||||||
1,
|
1,
|
||||||
&Address
|
&Address
|
||||||
);
|
);
|
||||||
|
|
||||||
(PciIoDevice->PciBar)[P2C_MEM_1].BaseAddress = (UINT64) (Address);
|
(PciIoDevice->PciBar)[P2C_MEM_1].BaseAddress = (UINT64) (Address);
|
||||||
(PciIoDevice->PciBar)[P2C_MEM_1].Length = 0x2000000;
|
(PciIoDevice->PciBar)[P2C_MEM_1].Length = 0x2000000;
|
||||||
|
@ -81,36 +54,36 @@ GetBackPcCardBar (
|
||||||
|
|
||||||
Address = 0;
|
Address = 0;
|
||||||
PciIoRead (
|
PciIoRead (
|
||||||
&(PciIoDevice->PciIo),
|
&(PciIoDevice->PciIo),
|
||||||
EfiPciIoWidthUint32,
|
EfiPciIoWidthUint32,
|
||||||
0x20,
|
0x20,
|
||||||
1,
|
1,
|
||||||
&Address
|
&Address
|
||||||
);
|
);
|
||||||
(PciIoDevice->PciBar)[P2C_MEM_2].BaseAddress = (UINT64) (Address);
|
(PciIoDevice->PciBar)[P2C_MEM_2].BaseAddress = (UINT64) (Address);
|
||||||
(PciIoDevice->PciBar)[P2C_MEM_2].Length = 0x2000000;
|
(PciIoDevice->PciBar)[P2C_MEM_2].Length = 0x2000000;
|
||||||
(PciIoDevice->PciBar)[P2C_MEM_2].BarType = PciBarTypePMem32;
|
(PciIoDevice->PciBar)[P2C_MEM_2].BarType = PciBarTypePMem32;
|
||||||
|
|
||||||
Address = 0;
|
Address = 0;
|
||||||
PciIoRead (
|
PciIoRead (
|
||||||
&(PciIoDevice->PciIo),
|
&(PciIoDevice->PciIo),
|
||||||
EfiPciIoWidthUint32,
|
EfiPciIoWidthUint32,
|
||||||
0x2c,
|
0x2c,
|
||||||
1,
|
1,
|
||||||
&Address
|
&Address
|
||||||
);
|
);
|
||||||
(PciIoDevice->PciBar)[P2C_IO_1].BaseAddress = (UINT64) (Address);
|
(PciIoDevice->PciBar)[P2C_IO_1].BaseAddress = (UINT64) (Address);
|
||||||
(PciIoDevice->PciBar)[P2C_IO_1].Length = 0x100;
|
(PciIoDevice->PciBar)[P2C_IO_1].Length = 0x100;
|
||||||
(PciIoDevice->PciBar)[P2C_IO_1].BarType = PciBarTypeIo16;
|
(PciIoDevice->PciBar)[P2C_IO_1].BarType = PciBarTypeIo16;
|
||||||
|
|
||||||
Address = 0;
|
Address = 0;
|
||||||
PciIoRead (
|
PciIoRead (
|
||||||
&(PciIoDevice->PciIo),
|
&(PciIoDevice->PciIo),
|
||||||
EfiPciIoWidthUint32,
|
EfiPciIoWidthUint32,
|
||||||
0x34,
|
0x34,
|
||||||
1,
|
1,
|
||||||
&Address
|
&Address
|
||||||
);
|
);
|
||||||
(PciIoDevice->PciBar)[P2C_IO_2].BaseAddress = (UINT64) (Address);
|
(PciIoDevice->PciBar)[P2C_IO_2].BaseAddress = (UINT64) (Address);
|
||||||
(PciIoDevice->PciBar)[P2C_IO_2].Length = 0x100;
|
(PciIoDevice->PciBar)[P2C_IO_2].Length = 0x100;
|
||||||
(PciIoDevice->PciBar)[P2C_IO_2].BarType = PciBarTypeIo16;
|
(PciIoDevice->PciBar)[P2C_IO_2].BarType = PciBarTypeIo16;
|
||||||
|
@ -165,7 +138,6 @@ RemoveRejectedPciDevices (
|
||||||
//
|
//
|
||||||
// For P2C, remove all devices on it
|
// For P2C, remove all devices on it
|
||||||
//
|
//
|
||||||
|
|
||||||
if (!IsListEmpty (&Temp->ChildList)) {
|
if (!IsListEmpty (&Temp->ChildList)) {
|
||||||
RemoveAllPciDeviceOnBridge (RootBridgeHandle, Temp);
|
RemoveAllPciDeviceOnBridge (RootBridgeHandle, Temp);
|
||||||
}
|
}
|
||||||
|
@ -173,7 +145,6 @@ RemoveRejectedPciDevices (
|
||||||
//
|
//
|
||||||
// Finally remove itself
|
// Finally remove itself
|
||||||
//
|
//
|
||||||
|
|
||||||
LastLink = CurrentLink->BackLink;
|
LastLink = CurrentLink->BackLink;
|
||||||
RemoveEntryList (CurrentLink);
|
RemoveEntryList (CurrentLink);
|
||||||
FreePciDevice (Temp);
|
FreePciDevice (Temp);
|
||||||
|
@ -278,13 +249,13 @@ PciHostBridgeResourceAllocator_WithoutHotPlugDeviceSupport (
|
||||||
//
|
//
|
||||||
|
|
||||||
IoBridge = CreateResourceNode (
|
IoBridge = CreateResourceNode (
|
||||||
RootBridgeDev,
|
RootBridgeDev,
|
||||||
0,
|
0,
|
||||||
0xFFF,
|
0xFFF,
|
||||||
0,
|
0,
|
||||||
PciBarTypeIo16,
|
PciBarTypeIo16,
|
||||||
PciResUsageTypical
|
PciResUsageTypical
|
||||||
);
|
);
|
||||||
|
|
||||||
Mem32Bridge = CreateResourceNode (
|
Mem32Bridge = CreateResourceNode (
|
||||||
RootBridgeDev,
|
RootBridgeDev,
|
||||||
|
@ -296,13 +267,13 @@ PciHostBridgeResourceAllocator_WithoutHotPlugDeviceSupport (
|
||||||
);
|
);
|
||||||
|
|
||||||
PMem32Bridge = CreateResourceNode (
|
PMem32Bridge = CreateResourceNode (
|
||||||
RootBridgeDev,
|
RootBridgeDev,
|
||||||
0,
|
0,
|
||||||
0xFFFFF,
|
0xFFFFF,
|
||||||
0,
|
0,
|
||||||
PciBarTypePMem32,
|
PciBarTypePMem32,
|
||||||
PciResUsageTypical
|
PciResUsageTypical
|
||||||
);
|
);
|
||||||
|
|
||||||
Mem64Bridge = CreateResourceNode (
|
Mem64Bridge = CreateResourceNode (
|
||||||
RootBridgeDev,
|
RootBridgeDev,
|
||||||
|
@ -314,25 +285,25 @@ PciHostBridgeResourceAllocator_WithoutHotPlugDeviceSupport (
|
||||||
);
|
);
|
||||||
|
|
||||||
PMem64Bridge = CreateResourceNode (
|
PMem64Bridge = CreateResourceNode (
|
||||||
RootBridgeDev,
|
RootBridgeDev,
|
||||||
0,
|
0,
|
||||||
0xFFFFF,
|
0xFFFFF,
|
||||||
0,
|
0,
|
||||||
PciBarTypePMem64,
|
PciBarTypePMem64,
|
||||||
PciResUsageTypical
|
PciResUsageTypical
|
||||||
);
|
);
|
||||||
|
|
||||||
//
|
//
|
||||||
// Create resourcemap by going through all the devices subject to this root bridge
|
// Create resourcemap by going through all the devices subject to this root bridge
|
||||||
//
|
//
|
||||||
Status = CreateResourceMap (
|
Status = CreateResourceMap (
|
||||||
RootBridgeDev,
|
RootBridgeDev,
|
||||||
IoBridge,
|
IoBridge,
|
||||||
Mem32Bridge,
|
Mem32Bridge,
|
||||||
PMem32Bridge,
|
PMem32Bridge,
|
||||||
Mem64Bridge,
|
Mem64Bridge,
|
||||||
PMem64Bridge
|
PMem64Bridge
|
||||||
);
|
);
|
||||||
|
|
||||||
//
|
//
|
||||||
// Get the max ROM size that the root bridge can process
|
// 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
|
// submit the resource aperture to pci host bridge protocol
|
||||||
//
|
//
|
||||||
Status = ConstructAcpiResourceRequestor (
|
Status = ConstructAcpiResourceRequestor (
|
||||||
RootBridgeDev,
|
RootBridgeDev,
|
||||||
IoBridge,
|
IoBridge,
|
||||||
Mem32Bridge,
|
Mem32Bridge,
|
||||||
PMem32Bridge,
|
PMem32Bridge,
|
||||||
Mem64Bridge,
|
Mem64Bridge,
|
||||||
PMem64Bridge,
|
PMem64Bridge,
|
||||||
&AcpiConfig
|
&AcpiConfig
|
||||||
);
|
);
|
||||||
|
|
||||||
//
|
//
|
||||||
// Insert these resource nodes into the database
|
// Insert these resource nodes into the database
|
||||||
|
@ -493,18 +464,18 @@ PciHostBridgeResourceAllocator_WithoutHotPlugDeviceSupport (
|
||||||
// enumerator. Several resource tree was created
|
// enumerator. Several resource tree was created
|
||||||
//
|
//
|
||||||
Status = GetResourceMap (
|
Status = GetResourceMap (
|
||||||
RootBridgeDev,
|
RootBridgeDev,
|
||||||
&IoBridge,
|
&IoBridge,
|
||||||
&Mem32Bridge,
|
&Mem32Bridge,
|
||||||
&PMem32Bridge,
|
&PMem32Bridge,
|
||||||
&Mem64Bridge,
|
&Mem64Bridge,
|
||||||
&PMem64Bridge,
|
&PMem64Bridge,
|
||||||
&IoPool,
|
&IoPool,
|
||||||
&Mem32Pool,
|
&Mem32Pool,
|
||||||
&PMem32Pool,
|
&PMem32Pool,
|
||||||
&Mem64Pool,
|
&Mem64Pool,
|
||||||
&PMem64Pool
|
&PMem64Pool
|
||||||
);
|
);
|
||||||
|
|
||||||
if (EFI_ERROR (Status)) {
|
if (EFI_ERROR (Status)) {
|
||||||
return Status;
|
return Status;
|
||||||
|
@ -650,13 +621,13 @@ PciHostBridgeResourceAllocator_WithHotPlugDeviceSupport (
|
||||||
//
|
//
|
||||||
|
|
||||||
IoBridge = CreateResourceNode (
|
IoBridge = CreateResourceNode (
|
||||||
RootBridgeDev,
|
RootBridgeDev,
|
||||||
0,
|
0,
|
||||||
0xFFF,
|
0xFFF,
|
||||||
0,
|
0,
|
||||||
PciBarTypeIo16,
|
PciBarTypeIo16,
|
||||||
PciResUsageTypical
|
PciResUsageTypical
|
||||||
);
|
);
|
||||||
|
|
||||||
Mem32Bridge = CreateResourceNode (
|
Mem32Bridge = CreateResourceNode (
|
||||||
RootBridgeDev,
|
RootBridgeDev,
|
||||||
|
@ -668,13 +639,13 @@ PciHostBridgeResourceAllocator_WithHotPlugDeviceSupport (
|
||||||
);
|
);
|
||||||
|
|
||||||
PMem32Bridge = CreateResourceNode (
|
PMem32Bridge = CreateResourceNode (
|
||||||
RootBridgeDev,
|
RootBridgeDev,
|
||||||
0,
|
0,
|
||||||
0xFFFFF,
|
0xFFFFF,
|
||||||
0,
|
0,
|
||||||
PciBarTypePMem32,
|
PciBarTypePMem32,
|
||||||
PciResUsageTypical
|
PciResUsageTypical
|
||||||
);
|
);
|
||||||
|
|
||||||
Mem64Bridge = CreateResourceNode (
|
Mem64Bridge = CreateResourceNode (
|
||||||
RootBridgeDev,
|
RootBridgeDev,
|
||||||
|
@ -686,25 +657,25 @@ PciHostBridgeResourceAllocator_WithHotPlugDeviceSupport (
|
||||||
);
|
);
|
||||||
|
|
||||||
PMem64Bridge = CreateResourceNode (
|
PMem64Bridge = CreateResourceNode (
|
||||||
RootBridgeDev,
|
RootBridgeDev,
|
||||||
0,
|
0,
|
||||||
0xFFFFF,
|
0xFFFFF,
|
||||||
0,
|
0,
|
||||||
PciBarTypePMem64,
|
PciBarTypePMem64,
|
||||||
PciResUsageTypical
|
PciResUsageTypical
|
||||||
);
|
);
|
||||||
|
|
||||||
//
|
//
|
||||||
// Create resourcemap by going through all the devices subject to this root bridge
|
// Create resourcemap by going through all the devices subject to this root bridge
|
||||||
//
|
//
|
||||||
Status = CreateResourceMap (
|
Status = CreateResourceMap (
|
||||||
RootBridgeDev,
|
RootBridgeDev,
|
||||||
IoBridge,
|
IoBridge,
|
||||||
Mem32Bridge,
|
Mem32Bridge,
|
||||||
PMem32Bridge,
|
PMem32Bridge,
|
||||||
Mem64Bridge,
|
Mem64Bridge,
|
||||||
PMem64Bridge
|
PMem64Bridge
|
||||||
);
|
);
|
||||||
|
|
||||||
//
|
//
|
||||||
// Get the max ROM size that the root bridge can process
|
// 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
|
// submit the resource aperture to pci host bridge protocol
|
||||||
//
|
//
|
||||||
Status = ConstructAcpiResourceRequestor (
|
Status = ConstructAcpiResourceRequestor (
|
||||||
RootBridgeDev,
|
RootBridgeDev,
|
||||||
IoBridge,
|
IoBridge,
|
||||||
Mem32Bridge,
|
Mem32Bridge,
|
||||||
PMem32Bridge,
|
PMem32Bridge,
|
||||||
Mem64Bridge,
|
Mem64Bridge,
|
||||||
PMem64Bridge,
|
PMem64Bridge,
|
||||||
&AcpiConfig
|
&AcpiConfig
|
||||||
);
|
);
|
||||||
|
|
||||||
//
|
//
|
||||||
// Insert these resource nodes into the database
|
// Insert these resource nodes into the database
|
||||||
|
@ -883,17 +854,17 @@ PciHostBridgeResourceAllocator_WithHotPlugDeviceSupport (
|
||||||
);
|
);
|
||||||
|
|
||||||
Status = PciHostBridgeAdjustAllocation (
|
Status = PciHostBridgeAdjustAllocation (
|
||||||
&IoPool,
|
&IoPool,
|
||||||
&Mem32Pool,
|
&Mem32Pool,
|
||||||
&PMem32Pool,
|
&PMem32Pool,
|
||||||
&Mem64Pool,
|
&Mem64Pool,
|
||||||
&PMem64Pool,
|
&PMem64Pool,
|
||||||
IoResStatus,
|
IoResStatus,
|
||||||
Mem32ResStatus,
|
Mem32ResStatus,
|
||||||
PMem32ResStatus,
|
PMem32ResStatus,
|
||||||
Mem64ResStatus,
|
Mem64ResStatus,
|
||||||
PMem64ResStatus
|
PMem64ResStatus
|
||||||
);
|
);
|
||||||
|
|
||||||
//
|
//
|
||||||
// Destroy all the resource tree
|
// Destroy all the resource tree
|
||||||
|
@ -984,18 +955,18 @@ PciHostBridgeResourceAllocator_WithHotPlugDeviceSupport (
|
||||||
// enumerator. Several resource tree was created
|
// enumerator. Several resource tree was created
|
||||||
//
|
//
|
||||||
Status = GetResourceMap (
|
Status = GetResourceMap (
|
||||||
RootBridgeDev,
|
RootBridgeDev,
|
||||||
&IoBridge,
|
&IoBridge,
|
||||||
&Mem32Bridge,
|
&Mem32Bridge,
|
||||||
&PMem32Bridge,
|
&PMem32Bridge,
|
||||||
&Mem64Bridge,
|
&Mem64Bridge,
|
||||||
&PMem64Bridge,
|
&PMem64Bridge,
|
||||||
&IoPool,
|
&IoPool,
|
||||||
&Mem32Pool,
|
&Mem32Pool,
|
||||||
&PMem32Pool,
|
&PMem32Pool,
|
||||||
&Mem64Pool,
|
&Mem64Pool,
|
||||||
&PMem64Pool
|
&PMem64Pool
|
||||||
);
|
);
|
||||||
|
|
||||||
if (EFI_ERROR (Status)) {
|
if (EFI_ERROR (Status)) {
|
||||||
return Status;
|
return Status;
|
||||||
|
@ -1447,7 +1418,7 @@ PciScanBus_WithHotPlugDeviceSupport (
|
||||||
&BusRange
|
&BusRange
|
||||||
);
|
);
|
||||||
|
|
||||||
gBS->FreePool (Descriptors);
|
FreePool (Descriptors);
|
||||||
|
|
||||||
if (EFI_ERROR (Status)) {
|
if (EFI_ERROR (Status)) {
|
||||||
return Status;
|
return Status;
|
||||||
|
@ -1787,7 +1758,7 @@ PciHostBridgeEnumerator (
|
||||||
StartBusNumber
|
StartBusNumber
|
||||||
);
|
);
|
||||||
|
|
||||||
gBS->FreePool (Configuration);
|
FreePool (Configuration);
|
||||||
Link = GetNextNode (&RootBridgeList, Link);
|
Link = GetNextNode (&RootBridgeList, Link);
|
||||||
DestroyRootBridge (RootBridgeDev);
|
DestroyRootBridge (RootBridgeDev);
|
||||||
}
|
}
|
||||||
|
|
|
@ -49,14 +49,6 @@ typedef struct {
|
||||||
UINT8 *AllocRes;
|
UINT8 *AllocRes;
|
||||||
} EFI_RESOURCE_ALLOC_FAILURE_ERROR_DATA_PAYLOAD;
|
} 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.
|
Retrieve the BAR information via PciIo interface.
|
||||||
|
|
|
@ -140,7 +140,7 @@ LocalLoadFile2 (
|
||||||
Scratch,
|
Scratch,
|
||||||
ScratchSize
|
ScratchSize
|
||||||
);
|
);
|
||||||
gBS->FreePool (Scratch);
|
FreePool (Scratch);
|
||||||
|
|
||||||
if (EFI_ERROR (Status)) {
|
if (EFI_ERROR (Status)) {
|
||||||
return EFI_DEVICE_ERROR;
|
return EFI_DEVICE_ERROR;
|
||||||
|
@ -432,7 +432,7 @@ LoadOpRomImage (
|
||||||
|
|
||||||
RomPcir = AllocatePool (sizeof (PCI_DATA_STRUCTURE));
|
RomPcir = AllocatePool (sizeof (PCI_DATA_STRUCTURE));
|
||||||
if (RomPcir == NULL) {
|
if (RomPcir == NULL) {
|
||||||
gBS->FreePool (RomHeader);
|
FreePool (RomHeader);
|
||||||
return EFI_OUT_OF_RESOURCES;
|
return EFI_OUT_OF_RESOURCES;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -496,8 +496,8 @@ LoadOpRomImage (
|
||||||
Image = AllocatePool ((UINT32) RomImageSize);
|
Image = AllocatePool ((UINT32) RomImageSize);
|
||||||
if (Image == NULL) {
|
if (Image == NULL) {
|
||||||
RomDecode (PciDevice, RomBarIndex, RomBar, FALSE);
|
RomDecode (PciDevice, RomBarIndex, RomBar, FALSE);
|
||||||
gBS->FreePool (RomHeader);
|
FreePool (RomHeader);
|
||||||
gBS->FreePool (RomPcir);
|
FreePool (RomPcir);
|
||||||
return EFI_OUT_OF_RESOURCES;
|
return EFI_OUT_OF_RESOURCES;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -536,8 +536,8 @@ LoadOpRomImage (
|
||||||
//
|
//
|
||||||
// Free allocated memory
|
// Free allocated memory
|
||||||
//
|
//
|
||||||
gBS->FreePool (RomHeader);
|
FreePool (RomHeader);
|
||||||
gBS->FreePool (RomPcir);
|
FreePool (RomPcir);
|
||||||
|
|
||||||
return RetStatus;
|
return RetStatus;
|
||||||
}
|
}
|
||||||
|
@ -725,7 +725,7 @@ ProcessOpRomImage (
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
gBS->FreePool (PciOptionRomImageDevicePath);
|
FreePool (PciOptionRomImageDevicePath);
|
||||||
|
|
||||||
if (!EFI_ERROR (Status)) {
|
if (!EFI_ERROR (Status)) {
|
||||||
Status = gBS->StartImage (ImageHandle, NULL, NULL);
|
Status = gBS->StartImage (ImageHandle, NULL, NULL);
|
||||||
|
|
|
@ -66,7 +66,7 @@ PciRomAddImageMapping (
|
||||||
CopyMem (TempMapping, mRomImageTable, mNumberOfPciRomImages * sizeof (EFI_PCI_ROM_IMAGE_MAPPING));
|
CopyMem (TempMapping, mRomImageTable, mNumberOfPciRomImages * sizeof (EFI_PCI_ROM_IMAGE_MAPPING));
|
||||||
|
|
||||||
if (mRomImageTable != NULL) {
|
if (mRomImageTable != NULL) {
|
||||||
gBS->FreePool (mRomImageTable);
|
FreePool (mRomImageTable);
|
||||||
}
|
}
|
||||||
|
|
||||||
mRomImageTable = TempMapping;
|
mRomImageTable = TempMapping;
|
||||||
|
|
Loading…
Reference in New Issue