summaryrefslogtreecommitdiff
path: root/IntelFrameworkModulePkg
diff options
context:
space:
mode:
authorqhuang8 <qhuang8@6f19259b-4bc3-4df7-8a09-765794883524>2008-02-19 04:17:05 +0000
committerqhuang8 <qhuang8@6f19259b-4bc3-4df7-8a09-765794883524>2008-02-19 04:17:05 +0000
commiteb9a9a5e23d8dac741192d023d65f6d4adef4caa (patch)
tree6f0323bfb62acc21461abe7a0b3334ef589a18e1 /IntelFrameworkModulePkg
parent23f642e80ada6354e540109174c9079448e12352 (diff)
downloadedk2-platforms-eb9a9a5e23d8dac741192d023d65f6d4adef4caa.tar.xz
Produce all the PciIo & Dpath protocol for all the pci devices under the current host bridge.
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@4703 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'IntelFrameworkModulePkg')
-rw-r--r--IntelFrameworkModulePkg/Bus/Pci/PciBusDxe/PciDeviceSupport.c270
-rw-r--r--IntelFrameworkModulePkg/Bus/Pci/PciBusDxe/PciDeviceSupport.h4
-rw-r--r--IntelFrameworkModulePkg/Bus/Pci/PciBusDxe/PciEnumerator.c15
-rw-r--r--IntelFrameworkModulePkg/Bus/Pci/PciBusDxe/PciEnumeratorSupport.c11
-rw-r--r--IntelFrameworkModulePkg/Bus/Pci/PciBusDxe/pcibus.c8
5 files changed, 124 insertions, 184 deletions
diff --git a/IntelFrameworkModulePkg/Bus/Pci/PciBusDxe/PciDeviceSupport.c b/IntelFrameworkModulePkg/Bus/Pci/PciBusDxe/PciDeviceSupport.c
index 7a1d30e07c..d19ee04bf4 100644
--- a/IntelFrameworkModulePkg/Bus/Pci/PciBusDxe/PciDeviceSupport.c
+++ b/IntelFrameworkModulePkg/Bus/Pci/PciBusDxe/PciDeviceSupport.c
@@ -335,44 +335,48 @@ Returns:
PciIoWrite (PciIo, EfiPciIoWidthUint8, 0x3C, 1, &Data8);
//
- // Process Platform OpRom
+ // Process OpRom
//
- if (gPciPlatformProtocol != NULL && !PciIoDevice->AllOpRomProcessed) {
+ if (!PciIoDevice->AllOpRomProcessed) {
PciIoDevice->AllOpRomProcessed = TRUE;
- Status = gPciPlatformProtocol->GetPciRom (
- gPciPlatformProtocol,
- PciIoDevice->Handle,
- &PlatformOpRomBuffer,
- &PlatformOpRomSize
- );
-
- if (!EFI_ERROR (Status)) {
-
- //
- // Have Platform OpRom
- //
- PciIoDevice->RomSize = PlatformOpRomSize;
- PciIoDevice->PciIo.RomSize = PlatformOpRomSize;
- PciIoDevice->PciIo.RomImage = PlatformOpRomBuffer;
-
- //
- // For OpROM read from gPciPlatformProtocol:
- // Add the Rom Image to internal database for later PCI light enumeration
- //
- PciRomAddImageMapping (
- NULL,
- PciIoDevice->PciRootBridgeIo->SegmentNumber,
- PciIoDevice->BusNumber,
- PciIoDevice->DeviceNumber,
- PciIoDevice->FunctionNumber,
- (UINT64) (UINTN) PciIoDevice->PciIo.RomImage,
- PciIoDevice->PciIo.RomSize
- );
+ //
+ // Get the OpRom provided by platform
+ //
+ if (gPciPlatformProtocol != NULL) {
+ Status = gPciPlatformProtocol->GetPciRom (
+ gPciPlatformProtocol,
+ PciIoDevice->Handle,
+ &PlatformOpRomBuffer,
+ &PlatformOpRomSize
+ );
+ if (!EFI_ERROR (Status)) {
+ PciIoDevice->RomSize = PlatformOpRomSize;
+ PciIoDevice->PciIo.RomSize = PlatformOpRomSize;
+ PciIoDevice->PciIo.RomImage = PlatformOpRomBuffer;
+ //
+ // For OpROM read from gPciPlatformProtocol:
+ // Add the Rom Image to internal database for later PCI light enumeration
+ //
+ PciRomAddImageMapping (
+ NULL,
+ PciIoDevice->PciRootBridgeIo->SegmentNumber,
+ PciIoDevice->BusNumber,
+ PciIoDevice->DeviceNumber,
+ PciIoDevice->FunctionNumber,
+ (UINT64) (UINTN) PciIoDevice->PciIo.RomImage,
+ PciIoDevice->PciIo.RomSize
+ );
+
+ }
+ }
- //
- // Process Image
- //
+ //
+ // Dispatch the EFI OpRom for the PCI device.
+ // The OpRom is got from platform in the above code
+ // or loaded from device in previous bus enumeration
+ //
+ if (PciIoDevice->RomSize > 0) {
ProcessOpRomImage (PciIoDevice);
}
}
@@ -659,7 +663,6 @@ Returns:
// TODO: EFI_UNSUPPORTED - add return value to function comment
// TODO: EFI_NOT_FOUND - add return value to function comment
{
- PCI_IO_DEVICE *Temp;
PCI_IO_DEVICE *PciIoDevice;
EFI_DEV_PATH_PTR Node;
EFI_DEVICE_PATH_PROTOCOL *CurrentDevicePath;
@@ -671,13 +674,13 @@ Returns:
while (CurrentLink && CurrentLink != &RootBridge->ChildList) {
- Temp = PCI_IO_DEVICE_FROM_LINK (CurrentLink);
+ PciIoDevice = PCI_IO_DEVICE_FROM_LINK (CurrentLink);
if (RemainingDevicePath != NULL) {
Node.DevPath = RemainingDevicePath;
- if (Node.Pci->Device != Temp->DeviceNumber ||
- Node.Pci->Function != Temp->FunctionNumber) {
+ if (Node.Pci->Device != PciIoDevice->DeviceNumber ||
+ Node.Pci->Function != PciIoDevice->FunctionNumber) {
CurrentLink = CurrentLink->ForwardLink;
continue;
}
@@ -685,30 +688,28 @@ Returns:
//
// Check if the device has been assigned with required resource
//
- if (!Temp->Allocated) {
+ if (!PciIoDevice->Allocated) {
return EFI_NOT_READY;
}
-
+
//
// Check if the current node has been registered before
// If it is not, register it
//
- if (!Temp->Registered) {
- PciIoDevice = Temp;
-
+ if (!PciIoDevice->Registered) {
Status = RegisterPciDevice (
- Controller,
- PciIoDevice,
- NULL
- );
+ Controller,
+ PciIoDevice,
+ NULL
+ );
}
- if (NumberOfChildren != NULL && ChildHandleBuffer != NULL && Temp->Registered) {
- ChildHandleBuffer[*NumberOfChildren] = Temp->Handle;
+ if (NumberOfChildren != NULL && ChildHandleBuffer != NULL && PciIoDevice->Registered) {
+ ChildHandleBuffer[*NumberOfChildren] = PciIoDevice->Handle;
(*NumberOfChildren)++;
}
-
+
//
// Get the next device path
//
@@ -720,28 +721,28 @@ Returns:
//
// If it is a PPB
//
- if (!IsListEmpty (&Temp->ChildList)) {
+ if (!IsListEmpty (&PciIoDevice->ChildList)) {
Status = StartPciDevicesOnBridge (
- Controller,
- Temp,
- CurrentDevicePath,
- NumberOfChildren,
- ChildHandleBuffer
- );
-
- Temp->PciIo.Attributes (
- &(Temp->PciIo),
- EfiPciIoAttributeOperationSupported,
- 0,
- &Supports
- );
+ Controller,
+ PciIoDevice,
+ CurrentDevicePath,
+ NumberOfChildren,
+ ChildHandleBuffer
+ );
+
+ PciIoDevice->PciIo.Attributes (
+ &(PciIoDevice->PciIo),
+ EfiPciIoAttributeOperationSupported,
+ 0,
+ &Supports
+ );
Supports &= EFI_PCI_DEVICE_ENABLE;
- Temp->PciIo.Attributes (
- &(Temp->PciIo),
- EfiPciIoAttributeOperationEnable,
- Supports,
- NULL
- );
+ PciIoDevice->PciIo.Attributes (
+ &(PciIoDevice->PciIo),
+ EfiPciIoAttributeOperationEnable,
+ Supports,
+ NULL
+ );
return Status;
} else {
@@ -759,50 +760,46 @@ Returns:
// try to enable all the pci devices under this bridge
//
- if (!Temp->Registered && Temp->Allocated) {
-
- PciIoDevice = Temp;
-
+ if (!PciIoDevice->Registered && PciIoDevice->Allocated) {
Status = RegisterPciDevice (
- Controller,
- PciIoDevice,
- NULL
- );
+ Controller,
+ PciIoDevice,
+ NULL
+ );
}
- if (NumberOfChildren != NULL && ChildHandleBuffer != NULL && Temp->Registered) {
- ChildHandleBuffer[*NumberOfChildren] = Temp->Handle;
+ if (NumberOfChildren != NULL && ChildHandleBuffer != NULL && PciIoDevice->Registered) {
+ ChildHandleBuffer[*NumberOfChildren] = PciIoDevice->Handle;
(*NumberOfChildren)++;
}
- if (!IsListEmpty (&Temp->ChildList)) {
+ if (!IsListEmpty (&PciIoDevice->ChildList)) {
Status = StartPciDevicesOnBridge (
- Controller,
- Temp,
- RemainingDevicePath,
- NumberOfChildren,
- ChildHandleBuffer
- );
-
- Temp->PciIo.Attributes (
- &(Temp->PciIo),
- EfiPciIoAttributeOperationSupported,
- 0,
- &Supports
- );
+ Controller,
+ PciIoDevice,
+ RemainingDevicePath,
+ NumberOfChildren,
+ ChildHandleBuffer
+ );
+
+ PciIoDevice->PciIo.Attributes (
+ &(PciIoDevice->PciIo),
+ EfiPciIoAttributeOperationSupported,
+ 0,
+ &Supports
+ );
Supports &= EFI_PCI_DEVICE_ENABLE;
- Temp->PciIo.Attributes (
- &(Temp->PciIo),
- EfiPciIoAttributeOperationEnable,
- Supports,
- NULL
- );
+ PciIoDevice->PciIo.Attributes (
+ &(PciIoDevice->PciIo),
+ EfiPciIoAttributeOperationEnable,
+ Supports,
+ NULL
+ );
}
CurrentLink = CurrentLink->ForwardLink;
- continue;
}
}
@@ -811,46 +808,31 @@ Returns:
EFI_STATUS
StartPciDevices (
- IN EFI_HANDLE Controller,
- IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
+ IN EFI_HANDLE Controller
)
/*++
Routine Description:
- Start to manage the PCI device according to RemainingDevicePath
- If RemainingDevicePath == NULL, the PCI bus driver will start
- to manage all the PCI devices it found previously
+ Start to manage all the PCI devices it found previously under
+ the entire host bridge.
Arguments:
- Controller - An efi handle.
- RemainingDevicePath - A pointer to the EFI_DEVICE_PATH_PROTOCOL.
+ Controller - root bridge handle.
Returns:
None
--*/
-// TODO: EFI_UNSUPPORTED - add return value to function comment
-// TODO: EFI_SUCCESS - add return value to function comment
{
- EFI_DEV_PATH_PTR Node;
PCI_IO_DEVICE *RootBridge;
+ EFI_HANDLE ThisHostBridge;
LIST_ENTRY *CurrentLink;
- if (RemainingDevicePath != NULL) {
-
- //
- // Check if the RemainingDevicePath is valid
- //
- Node.DevPath = RemainingDevicePath;
- if ((Node.DevPath->Type != HARDWARE_DEVICE_PATH) ||
- ((Node.DevPath->SubType != HW_PCI_DP) &&
- (DevicePathNodeLength (Node.DevPath) != sizeof (PCI_DEVICE_PATH)))
- ) {
- return EFI_UNSUPPORTED;
- }
- }
+ RootBridge = GetRootBridgeByHandle (Controller);
+ ASSERT (RootBridge != NULL);
+ ThisHostBridge = RootBridge->PciRootBridgeIo->ParentHandle;
CurrentLink = gPciDevicePool.ForwardLink;
@@ -860,11 +842,11 @@ Returns:
//
// Locate the right root bridge to start
//
- if (RootBridge->Handle == Controller) {
+ if (RootBridge->PciRootBridgeIo->ParentHandle == ThisHostBridge) {
StartPciDevicesOnBridge (
- Controller,
+ RootBridge->Handle,
RootBridge,
- RemainingDevicePath,
+ NULL,
NULL,
NULL
);
@@ -1008,40 +990,6 @@ Returns:
}
BOOLEAN
-RootBridgeExisted (
- IN EFI_HANDLE RootBridgeHandle
- )
-/*++
-
-Routine Description:
-
- This function searches if RootBridgeHandle has already existed
- in current device pool.
-
- If so, it means the given root bridge has been already enumerated.
-
-Arguments:
-
- RootBridgeHandle - An efi handle.
-
-Returns:
-
- None
-
---*/
-{
- PCI_IO_DEVICE *Bridge;
-
- Bridge = GetRootBridgeByHandle (RootBridgeHandle);
-
- if (Bridge != NULL) {
- return TRUE;
- }
-
- return FALSE;
-}
-
-BOOLEAN
PciDeviceExisted (
IN PCI_IO_DEVICE *Bridge,
IN PCI_IO_DEVICE *PciIoDevice
diff --git a/IntelFrameworkModulePkg/Bus/Pci/PciBusDxe/PciDeviceSupport.h b/IntelFrameworkModulePkg/Bus/Pci/PciBusDxe/PciDeviceSupport.h
index 5009175062..b32dfe214a 100644
--- a/IntelFrameworkModulePkg/Bus/Pci/PciBusDxe/PciDeviceSupport.h
+++ b/IntelFrameworkModulePkg/Bus/Pci/PciBusDxe/PciDeviceSupport.h
@@ -244,8 +244,7 @@ Returns:
EFI_STATUS
StartPciDevices (
- IN EFI_HANDLE Controller,
- IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
+ IN EFI_HANDLE Controller
)
/*++
@@ -256,7 +255,6 @@ Routine Description:
Arguments:
Controller - TODO: add argument description
- RemainingDevicePath - TODO: add argument description
Returns:
diff --git a/IntelFrameworkModulePkg/Bus/Pci/PciBusDxe/PciEnumerator.c b/IntelFrameworkModulePkg/Bus/Pci/PciBusDxe/PciEnumerator.c
index e0b6694ba2..b5b35687a6 100644
--- a/IntelFrameworkModulePkg/Bus/Pci/PciBusDxe/PciEnumerator.c
+++ b/IntelFrameworkModulePkg/Bus/Pci/PciBusDxe/PciEnumerator.c
@@ -53,13 +53,6 @@ Returns:
}
//
- // If this host bridge has been already enumerated, then return successfully
- //
- if (RootBridgeExisted (Controller)) {
- return EFI_SUCCESS;
- }
-
- //
// Get the rootbridge Io protocol to find the host bridge handle
//
Status = gBS->OpenProtocol (
@@ -277,7 +270,6 @@ Returns:
{
LIST_ENTRY *CurrentLink;
PCI_IO_DEVICE *Temp;
- EFI_STATUS Status;
//
// Go through bridges to reach all devices
@@ -290,7 +282,7 @@ Returns:
//
// Go further to process the option rom under this bridge
//
- Status = ProcessOptionRom (Temp, RomBase, MaxLength);
+ ProcessOptionRom (Temp, RomBase, MaxLength);
}
if (Temp->RomSize != 0 && Temp->RomSize <= MaxLength) {
@@ -298,10 +290,7 @@ Returns:
//
// Load and process the option rom
//
- Status = LoadOpRomImage (Temp, RomBase);
- if (Status == EFI_SUCCESS) {
- Status = ProcessOpRomImage (Temp);
- }
+ LoadOpRomImage (Temp, RomBase);
}
CurrentLink = CurrentLink->ForwardLink;
diff --git a/IntelFrameworkModulePkg/Bus/Pci/PciBusDxe/PciEnumeratorSupport.c b/IntelFrameworkModulePkg/Bus/Pci/PciBusDxe/PciEnumeratorSupport.c
index be316effdc..048e30c8a3 100644
--- a/IntelFrameworkModulePkg/Bus/Pci/PciBusDxe/PciEnumeratorSupport.c
+++ b/IntelFrameworkModulePkg/Bus/Pci/PciBusDxe/PciEnumeratorSupport.c
@@ -1000,6 +1000,12 @@ Returns:
}
PciRomGetImageMapping (Temp);
+
+ //
+ // The OpRom has already been processed in the first round
+ //
+ Temp->AllOpRomProcessed = TRUE;
+
CurrentLink = CurrentLink->ForwardLink;
}
@@ -1856,6 +1862,7 @@ Routine Description:
This routine is used to enumerate entire pci bus system
in a given platform
+ It is only called on the second start on the same Root Bridge.
Arguments:
@@ -1881,9 +1888,9 @@ Returns:
Descriptors = NULL;
//
- // If this host bridge has been already enumerated, then return successfully
+ // If this root bridge has been already enumerated, then return successfully
//
- if (RootBridgeExisted (Controller)) {
+ if (GetRootBridgeByHandle (Controller) != NULL) {
return EFI_SUCCESS;
}
diff --git a/IntelFrameworkModulePkg/Bus/Pci/PciBusDxe/pcibus.c b/IntelFrameworkModulePkg/Bus/Pci/PciBusDxe/pcibus.c
index a8e50fcb28..94f29157e8 100644
--- a/IntelFrameworkModulePkg/Bus/Pci/PciBusDxe/pcibus.c
+++ b/IntelFrameworkModulePkg/Bus/Pci/PciBusDxe/pcibus.c
@@ -245,13 +245,11 @@ Returns:
if (EFI_ERROR (Status)) {
return Status;
}
-
+
//
- // Enable PCI device specified by remaining device path. BDS or other driver can call the
- // start more than once.
+ // Start all the devices under the entire host bridge.
//
-
- StartPciDevices (Controller, RemainingDevicePath);
+ StartPciDevices (Controller);
return EFI_SUCCESS;
}