PciIoWrite (PciIo, EfiPciIoWidthUint8, 0x3C, 1, &Data8);\r
\r
//\r
- // Process Platform OpRom\r
+ // Process OpRom\r
//\r
- if (gPciPlatformProtocol != NULL && !PciIoDevice->AllOpRomProcessed) {\r
+ if (!PciIoDevice->AllOpRomProcessed) {\r
PciIoDevice->AllOpRomProcessed = TRUE;\r
\r
- Status = gPciPlatformProtocol->GetPciRom (\r
- gPciPlatformProtocol,\r
- PciIoDevice->Handle,\r
- &PlatformOpRomBuffer,\r
- &PlatformOpRomSize\r
- );\r
-\r
- if (!EFI_ERROR (Status)) {\r
-\r
- //\r
- // Have Platform OpRom\r
- //\r
- PciIoDevice->RomSize = PlatformOpRomSize;\r
- PciIoDevice->PciIo.RomSize = PlatformOpRomSize;\r
- PciIoDevice->PciIo.RomImage = PlatformOpRomBuffer;\r
-\r
- //\r
- // For OpROM read from gPciPlatformProtocol:\r
- // Add the Rom Image to internal database for later PCI light enumeration\r
- //\r
- PciRomAddImageMapping (\r
- NULL,\r
- PciIoDevice->PciRootBridgeIo->SegmentNumber,\r
- PciIoDevice->BusNumber,\r
- PciIoDevice->DeviceNumber,\r
- PciIoDevice->FunctionNumber,\r
- (UINT64) (UINTN) PciIoDevice->PciIo.RomImage,\r
- PciIoDevice->PciIo.RomSize\r
- );\r
+ //\r
+ // Get the OpRom provided by platform\r
+ //\r
+ if (gPciPlatformProtocol != NULL) {\r
+ Status = gPciPlatformProtocol->GetPciRom (\r
+ gPciPlatformProtocol,\r
+ PciIoDevice->Handle,\r
+ &PlatformOpRomBuffer,\r
+ &PlatformOpRomSize\r
+ );\r
+ if (!EFI_ERROR (Status)) {\r
+ PciIoDevice->RomSize = PlatformOpRomSize;\r
+ PciIoDevice->PciIo.RomSize = PlatformOpRomSize;\r
+ PciIoDevice->PciIo.RomImage = PlatformOpRomBuffer;\r
+ //\r
+ // For OpROM read from gPciPlatformProtocol:\r
+ // Add the Rom Image to internal database for later PCI light enumeration\r
+ //\r
+ PciRomAddImageMapping (\r
+ NULL,\r
+ PciIoDevice->PciRootBridgeIo->SegmentNumber,\r
+ PciIoDevice->BusNumber,\r
+ PciIoDevice->DeviceNumber,\r
+ PciIoDevice->FunctionNumber,\r
+ (UINT64) (UINTN) PciIoDevice->PciIo.RomImage,\r
+ PciIoDevice->PciIo.RomSize\r
+ );\r
+ \r
+ }\r
+ }\r
\r
- //\r
- // Process Image\r
- //\r
+ //\r
+ // Dispatch the EFI OpRom for the PCI device.\r
+ // The OpRom is got from platform in the above code\r
+ // or loaded from device in previous bus enumeration\r
+ //\r
+ if (PciIoDevice->RomSize > 0) {\r
ProcessOpRomImage (PciIoDevice);\r
}\r
}\r
// TODO: EFI_UNSUPPORTED - add return value to function comment\r
// TODO: EFI_NOT_FOUND - add return value to function comment\r
{\r
- PCI_IO_DEVICE *Temp;\r
PCI_IO_DEVICE *PciIoDevice;\r
EFI_DEV_PATH_PTR Node;\r
EFI_DEVICE_PATH_PROTOCOL *CurrentDevicePath;\r
\r
while (CurrentLink && CurrentLink != &RootBridge->ChildList) {\r
\r
- Temp = PCI_IO_DEVICE_FROM_LINK (CurrentLink);\r
+ PciIoDevice = PCI_IO_DEVICE_FROM_LINK (CurrentLink);\r
if (RemainingDevicePath != NULL) {\r
\r
Node.DevPath = RemainingDevicePath;\r
\r
- if (Node.Pci->Device != Temp->DeviceNumber ||\r
- Node.Pci->Function != Temp->FunctionNumber) {\r
+ if (Node.Pci->Device != PciIoDevice->DeviceNumber || \r
+ Node.Pci->Function != PciIoDevice->FunctionNumber) {\r
CurrentLink = CurrentLink->ForwardLink;\r
continue;\r
}\r
//\r
// Check if the device has been assigned with required resource\r
//\r
- if (!Temp->Allocated) {\r
+ if (!PciIoDevice->Allocated) {\r
return EFI_NOT_READY;\r
}\r
-\r
+ \r
//\r
// Check if the current node has been registered before\r
// If it is not, register it\r
//\r
- if (!Temp->Registered) {\r
- PciIoDevice = Temp;\r
-\r
+ if (!PciIoDevice->Registered) {\r
Status = RegisterPciDevice (\r
- Controller,\r
- PciIoDevice,\r
- NULL\r
- );\r
+ Controller,\r
+ PciIoDevice,\r
+ NULL\r
+ );\r
\r
}\r
\r
- if (NumberOfChildren != NULL && ChildHandleBuffer != NULL && Temp->Registered) {\r
- ChildHandleBuffer[*NumberOfChildren] = Temp->Handle;\r
+ if (NumberOfChildren != NULL && ChildHandleBuffer != NULL && PciIoDevice->Registered) {\r
+ ChildHandleBuffer[*NumberOfChildren] = PciIoDevice->Handle;\r
(*NumberOfChildren)++;\r
}\r
-\r
+ \r
//\r
// Get the next device path\r
//\r
//\r
// If it is a PPB\r
//\r
- if (!IsListEmpty (&Temp->ChildList)) {\r
+ if (!IsListEmpty (&PciIoDevice->ChildList)) {\r
Status = StartPciDevicesOnBridge (\r
- Controller,\r
- Temp,\r
- CurrentDevicePath,\r
- NumberOfChildren,\r
- ChildHandleBuffer\r
- );\r
-\r
- Temp->PciIo.Attributes (\r
- &(Temp->PciIo),\r
- EfiPciIoAttributeOperationSupported,\r
- 0,\r
- &Supports\r
- );\r
+ Controller,\r
+ PciIoDevice,\r
+ CurrentDevicePath,\r
+ NumberOfChildren,\r
+ ChildHandleBuffer\r
+ );\r
+\r
+ PciIoDevice->PciIo.Attributes (\r
+ &(PciIoDevice->PciIo),\r
+ EfiPciIoAttributeOperationSupported,\r
+ 0,\r
+ &Supports\r
+ );\r
Supports &= EFI_PCI_DEVICE_ENABLE;\r
- Temp->PciIo.Attributes (\r
- &(Temp->PciIo),\r
- EfiPciIoAttributeOperationEnable,\r
- Supports,\r
- NULL\r
- );\r
+ PciIoDevice->PciIo.Attributes (\r
+ &(PciIoDevice->PciIo),\r
+ EfiPciIoAttributeOperationEnable,\r
+ Supports,\r
+ NULL\r
+ );\r
\r
return Status;\r
} else {\r
// try to enable all the pci devices under this bridge\r
//\r
\r
- if (!Temp->Registered && Temp->Allocated) {\r
-\r
- PciIoDevice = Temp;\r
-\r
+ if (!PciIoDevice->Registered && PciIoDevice->Allocated) {\r
Status = RegisterPciDevice (\r
- Controller,\r
- PciIoDevice,\r
- NULL\r
- );\r
+ Controller,\r
+ PciIoDevice,\r
+ NULL\r
+ );\r
\r
}\r
\r
- if (NumberOfChildren != NULL && ChildHandleBuffer != NULL && Temp->Registered) {\r
- ChildHandleBuffer[*NumberOfChildren] = Temp->Handle;\r
+ if (NumberOfChildren != NULL && ChildHandleBuffer != NULL && PciIoDevice->Registered) {\r
+ ChildHandleBuffer[*NumberOfChildren] = PciIoDevice->Handle;\r
(*NumberOfChildren)++;\r
}\r
\r
- if (!IsListEmpty (&Temp->ChildList)) {\r
+ if (!IsListEmpty (&PciIoDevice->ChildList)) {\r
Status = StartPciDevicesOnBridge (\r
- Controller,\r
- Temp,\r
- RemainingDevicePath,\r
- NumberOfChildren,\r
- ChildHandleBuffer\r
- );\r
-\r
- Temp->PciIo.Attributes (\r
- &(Temp->PciIo),\r
- EfiPciIoAttributeOperationSupported,\r
- 0,\r
- &Supports\r
- );\r
+ Controller,\r
+ PciIoDevice,\r
+ RemainingDevicePath,\r
+ NumberOfChildren,\r
+ ChildHandleBuffer\r
+ );\r
+\r
+ PciIoDevice->PciIo.Attributes (\r
+ &(PciIoDevice->PciIo),\r
+ EfiPciIoAttributeOperationSupported,\r
+ 0,\r
+ &Supports\r
+ );\r
Supports &= EFI_PCI_DEVICE_ENABLE;\r
- Temp->PciIo.Attributes (\r
- &(Temp->PciIo),\r
- EfiPciIoAttributeOperationEnable,\r
- Supports,\r
- NULL\r
- );\r
+ PciIoDevice->PciIo.Attributes (\r
+ &(PciIoDevice->PciIo),\r
+ EfiPciIoAttributeOperationEnable,\r
+ Supports,\r
+ NULL\r
+ );\r
\r
}\r
\r
CurrentLink = CurrentLink->ForwardLink;\r
- continue;\r
}\r
}\r
\r
\r
EFI_STATUS\r
StartPciDevices (\r
- IN EFI_HANDLE Controller,\r
- IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath\r
+ IN EFI_HANDLE Controller\r
)\r
/*++\r
\r
Routine Description:\r
\r
- Start to manage the PCI device according to RemainingDevicePath\r
- If RemainingDevicePath == NULL, the PCI bus driver will start\r
- to manage all the PCI devices it found previously\r
+ Start to manage all the PCI devices it found previously under \r
+ the entire host bridge.\r
\r
Arguments:\r
- Controller - An efi handle.\r
- RemainingDevicePath - A pointer to the EFI_DEVICE_PATH_PROTOCOL.\r
+ Controller - root bridge handle.\r
\r
Returns:\r
\r
None\r
\r
--*/\r
-// TODO: EFI_UNSUPPORTED - add return value to function comment\r
-// TODO: EFI_SUCCESS - add return value to function comment\r
{\r
- EFI_DEV_PATH_PTR Node;\r
PCI_IO_DEVICE *RootBridge;\r
+ EFI_HANDLE ThisHostBridge;\r
LIST_ENTRY *CurrentLink;\r
\r
- if (RemainingDevicePath != NULL) {\r
-\r
- //\r
- // Check if the RemainingDevicePath is valid\r
- //\r
- Node.DevPath = RemainingDevicePath;\r
- if ((Node.DevPath->Type != HARDWARE_DEVICE_PATH) ||\r
- ((Node.DevPath->SubType != HW_PCI_DP) &&\r
- (DevicePathNodeLength (Node.DevPath) != sizeof (PCI_DEVICE_PATH)))\r
- ) {\r
- return EFI_UNSUPPORTED;\r
- }\r
- }\r
+ RootBridge = GetRootBridgeByHandle (Controller);\r
+ ASSERT (RootBridge != NULL);\r
+ ThisHostBridge = RootBridge->PciRootBridgeIo->ParentHandle;\r
\r
CurrentLink = gPciDevicePool.ForwardLink;\r
\r
//\r
// Locate the right root bridge to start\r
//\r
- if (RootBridge->Handle == Controller) {\r
+ if (RootBridge->PciRootBridgeIo->ParentHandle == ThisHostBridge) {\r
StartPciDevicesOnBridge (\r
- Controller,\r
+ RootBridge->Handle,\r
RootBridge,\r
- RemainingDevicePath,\r
+ NULL,\r
NULL,\r
NULL\r
);\r
return NULL;\r
}\r
\r
-BOOLEAN\r
-RootBridgeExisted (\r
- IN EFI_HANDLE RootBridgeHandle\r
- )\r
-/*++\r
-\r
-Routine Description:\r
-\r
- This function searches if RootBridgeHandle has already existed\r
- in current device pool.\r
-\r
- If so, it means the given root bridge has been already enumerated.\r
-\r
-Arguments:\r
-\r
- RootBridgeHandle - An efi handle.\r
-\r
-Returns:\r
-\r
- None\r
-\r
---*/\r
-{\r
- PCI_IO_DEVICE *Bridge;\r
-\r
- Bridge = GetRootBridgeByHandle (RootBridgeHandle);\r
-\r
- if (Bridge != NULL) {\r
- return TRUE;\r
- }\r
-\r
- return FALSE;\r
-}\r
-\r
BOOLEAN\r
PciDeviceExisted (\r
IN PCI_IO_DEVICE *Bridge,\r