1. Handle flexible exception list format.
1.1 Handle DeviceScope based device info.
1.2 Handle PciDeviceId based device info.
2. Reorg the PCI_DEVICE_INFORMATION
2.1 Merge data pointer reduce allocation times
2.2 Add PCI device id to PCI_DEVICE_INFORMATION
2.3 Rename PciDescriptor to avoid confusing.
3. Fix the debug message too long issue.
Cc: Star Zeng <star.zeng@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Jiewen Yao <jiewen.yao@intel.com>
Reviewed-by: Star Zeng <star.zeng@intel.com>
return ;\r
}\r
\r
+/**\r
+ The scan bus callback function to always enable page attribute.\r
+\r
+ @param[in] Context The context of the callback.\r
+ @param[in] Segment The segment of the source.\r
+ @param[in] Bus The bus of the source.\r
+ @param[in] Device The device of the source.\r
+ @param[in] Function The function of the source.\r
+\r
+ @retval EFI_SUCCESS The VTd entry is updated to always enable all DMA access for the specific device.\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+ScanBusCallbackAlwaysEnablePageAttribute (\r
+ IN VOID *Context,\r
+ IN UINT16 Segment,\r
+ IN UINT8 Bus,\r
+ IN UINT8 Device,\r
+ IN UINT8 Function\r
+ )\r
+{\r
+ VTD_SOURCE_ID SourceId;\r
+ EFI_STATUS Status;\r
+\r
+ SourceId.Bits.Bus = Bus;\r
+ SourceId.Bits.Device = Device;\r
+ SourceId.Bits.Function = Function;\r
+ Status = AlwaysEnablePageAttribute (Segment, SourceId);\r
+ return Status;\r
+}\r
+\r
+/**\r
+ Always enable the VTd page attribute for the device in the DeviceScope.\r
+\r
+ @param[in] DeviceScope the input device scope data structure\r
+\r
+ @retval EFI_SUCCESS The VTd entry is updated to always enable all DMA access for the specific device in the device scope.\r
+**/\r
+EFI_STATUS\r
+AlwaysEnablePageAttributeDeviceScope (\r
+ IN EDKII_PLATFORM_VTD_DEVICE_SCOPE *DeviceScope\r
+ )\r
+{\r
+ UINT8 Bus;\r
+ UINT8 Device;\r
+ UINT8 Function;\r
+ VTD_SOURCE_ID SourceId;\r
+ UINT8 SecondaryBusNumber;\r
+ EFI_STATUS Status;\r
+\r
+ Status = GetPciBusDeviceFunction (DeviceScope->SegmentNumber, &DeviceScope->DeviceScope, &Bus, &Device, &Function);\r
+\r
+ if (DeviceScope->DeviceScope.Type == EFI_ACPI_DEVICE_SCOPE_ENTRY_TYPE_PCI_BRIDGE) {\r
+ //\r
+ // Need scan the bridge and add all devices.\r
+ //\r
+ SecondaryBusNumber = PciSegmentRead8 (PCI_SEGMENT_LIB_ADDRESS(DeviceScope->SegmentNumber, Bus, Device, Function, PCI_BRIDGE_SECONDARY_BUS_REGISTER_OFFSET));\r
+ Status = ScanPciBus (NULL, DeviceScope->SegmentNumber, SecondaryBusNumber, ScanBusCallbackAlwaysEnablePageAttribute);\r
+ return Status;\r
+ } else {\r
+ SourceId.Bits.Bus = Bus;\r
+ SourceId.Bits.Device = Device;\r
+ SourceId.Bits.Function = Function;\r
+ Status = AlwaysEnablePageAttribute (DeviceScope->SegmentNumber, SourceId);\r
+ return Status;\r
+ }\r
+}\r
+\r
+/**\r
+ Always enable the VTd page attribute for the device matching DeviceId.\r
+\r
+ @param[in] PciDeviceId the input PCI device ID\r
+\r
+ @retval EFI_SUCCESS The VTd entry is updated to always enable all DMA access for the specific device matching DeviceId.\r
+**/\r
+EFI_STATUS\r
+AlwaysEnablePageAttributePciDeviceId (\r
+ IN EDKII_PLATFORM_VTD_PCI_DEVICE_ID *PciDeviceId\r
+ )\r
+{\r
+ UINTN VtdIndex;\r
+ UINTN PciIndex;\r
+ PCI_DEVICE_DATA *PciDeviceData;\r
+ EFI_STATUS Status;\r
+\r
+ for (VtdIndex = 0; VtdIndex < mVtdUnitNumber; VtdIndex++) {\r
+ for (PciIndex = 0; PciIndex < mVtdUnitInformation[VtdIndex].PciDeviceInfo.PciDeviceDataNumber; PciIndex++) {\r
+ PciDeviceData = &mVtdUnitInformation[VtdIndex].PciDeviceInfo.PciDeviceData[PciIndex];\r
+\r
+ if (((PciDeviceId->VendorId == 0xFFFF) || (PciDeviceId->VendorId == PciDeviceData->PciDeviceId.VendorId)) &&\r
+ ((PciDeviceId->DeviceId == 0xFFFF) || (PciDeviceId->DeviceId == PciDeviceData->PciDeviceId.DeviceId)) &&\r
+ ((PciDeviceId->RevisionId == 0xFF) || (PciDeviceId->RevisionId == PciDeviceData->PciDeviceId.RevisionId)) &&\r
+ ((PciDeviceId->SubsystemVendorId == 0xFFFF) || (PciDeviceId->SubsystemVendorId == PciDeviceData->PciDeviceId.SubsystemVendorId)) &&\r
+ ((PciDeviceId->SubsystemDeviceId == 0xFFFF) || (PciDeviceId->SubsystemDeviceId == PciDeviceData->PciDeviceId.SubsystemDeviceId)) ) {\r
+ Status = AlwaysEnablePageAttribute (mVtdUnitInformation[VtdIndex].Segment, PciDeviceData->PciSourceId);\r
+ if (EFI_ERROR(Status)) {\r
+ continue;\r
+ }\r
+ }\r
+ }\r
+ }\r
+ return EFI_SUCCESS;\r
+}\r
+\r
+/**\r
+ Always enable the VTd page attribute for the device.\r
+\r
+ @param[in] DeviceInfo the exception device information\r
+\r
+ @retval EFI_SUCCESS The VTd entry is updated to always enable all DMA access for the specific device in the device info.\r
+**/\r
+EFI_STATUS\r
+AlwaysEnablePageAttributeExceptionDeviceInfo (\r
+ IN EDKII_PLATFORM_VTD_EXCEPTION_DEVICE_INFO *DeviceInfo\r
+ )\r
+{\r
+ switch (DeviceInfo->Type) {\r
+ case EDKII_PLATFORM_VTD_EXCEPTION_DEVICE_INFO_TYPE_DEVICE_SCOPE:\r
+ return AlwaysEnablePageAttributeDeviceScope ((VOID *)(DeviceInfo + 1));\r
+ case EDKII_PLATFORM_VTD_EXCEPTION_DEVICE_INFO_TYPE_PCI_DEVICE_ID:\r
+ return AlwaysEnablePageAttributePciDeviceId ((VOID *)(DeviceInfo + 1));\r
+ default:\r
+ return EFI_UNSUPPORTED;\r
+ }\r
+}\r
+\r
/**\r
Initialize platform VTd policy.\r
**/\r
VOID\r
)\r
{\r
- EFI_STATUS Status;\r
- UINTN DeviceInfoCount;\r
- EDKII_PLATFORM_VTD_DEVICE_INFO *DeviceInfo;\r
- UINTN Index;\r
+ EFI_STATUS Status;\r
+ UINTN DeviceInfoCount;\r
+ VOID *DeviceInfo;\r
+ EDKII_PLATFORM_VTD_EXCEPTION_DEVICE_INFO *ThisDeviceInfo;\r
+ UINTN Index;\r
\r
//\r
// It is optional.\r
(VOID **)&mPlatformVTdPolicy\r
);\r
if (!EFI_ERROR(Status)) {\r
+ DEBUG ((DEBUG_INFO, "InitializePlatformVTdPolicy\n"));\r
Status = mPlatformVTdPolicy->GetExceptionDeviceList (mPlatformVTdPolicy, &DeviceInfoCount, &DeviceInfo);\r
if (!EFI_ERROR(Status)) {\r
+ ThisDeviceInfo = DeviceInfo;\r
for (Index = 0; Index < DeviceInfoCount; Index++) {\r
- AlwaysEnablePageAttribute (DeviceInfo[Index].Segment, DeviceInfo[Index].SourceId);\r
+ if (ThisDeviceInfo->Type == EDKII_PLATFORM_VTD_EXCEPTION_DEVICE_INFO_TYPE_END) {\r
+ break;\r
+ }\r
+ AlwaysEnablePageAttributeExceptionDeviceInfo (ThisDeviceInfo);\r
+ ThisDeviceInfo = (VOID *)((UINTN)ThisDeviceInfo + ThisDeviceInfo->Length);\r
}\r
FreePool (DeviceInfo);\r
}\r
#define ALIGN_VALUE_LOW(Value, Alignment) ((Value) & (~((Alignment) - 1)))\r
\r
//\r
-// This is the initial max PCI descriptor.\r
+// This is the initial max PCI DATA number.\r
// The number may be enlarged later.\r
//\r
-#define MAX_PCI_DESCRIPTORS 0x100\r
+#define MAX_VTD_PCI_DATA_NUMBER 0x100\r
\r
typedef struct {\r
- BOOLEAN IncludeAllFlag;\r
- UINTN PciDescriptorNumber;\r
- UINTN PciDescriptorMaxNumber;\r
- BOOLEAN *IsRealPciDevice;\r
- VTD_SOURCE_ID *PciDescriptors;\r
+ UINT8 DeviceType;\r
+ VTD_SOURCE_ID PciSourceId;\r
+ EDKII_PLATFORM_VTD_PCI_DEVICE_ID PciDeviceId;\r
// for statistic analysis\r
- UINTN *AccessCount;\r
+ UINTN AccessCount;\r
+} PCI_DEVICE_DATA;\r
+\r
+typedef struct {\r
+ BOOLEAN IncludeAllFlag;\r
+ UINTN PciDeviceDataNumber;\r
+ UINTN PciDeviceDataMaxNumber;\r
+ PCI_DEVICE_DATA *PciDeviceData;\r
} PCI_DEVICE_INFORMATION;\r
\r
typedef struct {\r
PCI_DEVICE_INFORMATION PciDeviceInfo;\r
} VTD_UNIT_INFORMATION;\r
\r
+/**\r
+ The scan bus callback function.\r
+\r
+ It is called in PCI bus scan for each PCI device under the bus.\r
+\r
+ @param[in] Context The context of the callback.\r
+ @param[in] Segment The segment of the source.\r
+ @param[in] Bus The bus of the source.\r
+ @param[in] Device The device of the source.\r
+ @param[in] Function The function of the source.\r
+\r
+ @retval EFI_SUCCESS The specific PCI device is processed in the callback.\r
+**/\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *SCAN_BUS_FUNC_CALLBACK_FUNC) (\r
+ IN VOID *Context,\r
+ IN UINT16 Segment,\r
+ IN UINT8 Bus,\r
+ IN UINT8 Device,\r
+ IN UINT8 Function\r
+ );\r
+\r
extern EFI_ACPI_DMAR_HEADER *mAcpiDmarTable;\r
\r
extern UINT64 mVtdHostAddressWidthMask;\r
);\r
\r
/**\r
- Register PCI device to VTd engine as PCI descriptor.\r
+ Register PCI device to VTd engine.\r
\r
@param[in] VtdIndex The index of VTd engine.\r
@param[in] Segment The segment of the source.\r
@param[in] SourceId The SourceId of the source.\r
- @param[in] IsRealPciDevice TRUE: It is a real PCI device.\r
- FALSE: It is not a real PCI device.\r
+ @param[in] DeviceType The DMAR device scope type.\r
@param[in] CheckExist TRUE: ERROR will be returned if the PCI device is already registered.\r
FALSE: SUCCESS will be returned if the PCI device is registered.\r
\r
IN UINTN VtdIndex,\r
IN UINT16 Segment,\r
IN VTD_SOURCE_ID SourceId,\r
- IN BOOLEAN IsRealPciDevice,\r
+ IN UINT8 DeviceType,\r
IN BOOLEAN CheckExist\r
);\r
\r
/**\r
- Scan PCI bus and register PCI devices under the bus.\r
+ The scan bus callback function to always enable page attribute.\r
\r
- @param[in] VtdIndex The index of VTd engine.\r
+ @param[in] Context The context of the callback.\r
@param[in] Segment The segment of the source.\r
@param[in] Bus The bus of the source.\r
+ @param[in] Device The device of the source.\r
+ @param[in] Function The function of the source.\r
\r
- @retval EFI_SUCCESS The PCI devices under the bus are registered.\r
- @retval EFI_OUT_OF_RESOURCES No enough resource to register a new PCI device.\r
+ @retval EFI_SUCCESS The VTd entry is updated to always enable all DMA access for the specific device.\r
**/\r
EFI_STATUS\r
-ScanPciBus (\r
- IN UINTN VtdIndex,\r
+EFIAPI\r
+ScanBusCallbackRegisterPciDevice (\r
+ IN VOID *Context,\r
IN UINT16 Segment,\r
- IN UINT8 Bus\r
+ IN UINT8 Bus,\r
+ IN UINT8 Device,\r
+ IN UINT8 Function\r
+ );\r
+\r
+/**\r
+ Scan PCI bus and invoke callback function for each PCI devices under the bus.\r
+\r
+ @param[in] Context The context of the callback function.\r
+ @param[in] Segment The segment of the source.\r
+ @param[in] Bus The bus of the source.\r
+ @param[in] Callback The callback function in PCI scan.\r
+\r
+ @retval EFI_SUCCESS The PCI devices under the bus are scaned.\r
+**/\r
+EFI_STATUS\r
+ScanPciBus (\r
+ IN VOID *Context,\r
+ IN UINT16 Segment,\r
+ IN UINT8 Bus,\r
+ IN SCAN_BUS_FUNC_CALLBACK_FUNC Callback\r
);\r
\r
/**\r
@param[out] ExtContextEntry The ExtContextEntry of the source.\r
@param[out] ContextEntry The ContextEntry of the source.\r
\r
- @return The index of the PCI descriptor.\r
- @retval (UINTN)-1 The PCI descriptor is not found.\r
+ @return The index of the VTd engine.\r
+ @retval (UINTN)-1 The VTd engine is not found.\r
**/\r
UINTN\r
FindVtdIndexByPciDevice (\r
);\r
\r
/**\r
- Return the index of PCI descriptor.\r
+ Return the index of PCI data.\r
\r
@param[in] VtdIndex The index used to identify a VTd engine.\r
@param[in] Segment The Segment used to identify a VTd engine.\r
@param[in] SourceId The SourceId used to identify a VTd engine and table entry.\r
\r
- @return The index of the PCI descriptor.\r
- @retval (UINTN)-1 The PCI descriptor is not found.\r
+ @return The index of the PCI data.\r
+ @retval (UINTN)-1 The PCI data is not found.\r
**/\r
UINTN\r
-GetPciDescriptor (\r
+GetPciDataIndex (\r
IN UINTN VtdIndex,\r
IN UINT16 Segment,\r
IN VTD_SOURCE_ID SourceId\r
IN UINTN Size\r
);\r
\r
+/**\r
+ Get PCI device information from DMAR DevScopeEntry.\r
+\r
+ @param[in] Segment The segment number.\r
+ @param[in] DmarDevScopeEntry DMAR DevScopeEntry\r
+ @param[out] Bus The bus number.\r
+ @param[out] Device The device number.\r
+ @param[out] Function The function number.\r
+\r
+ @retval EFI_SUCCESS The PCI device information is returned.\r
+**/\r
+EFI_STATUS\r
+GetPciBusDeviceFunction (\r
+ IN UINT16 Segment,\r
+ IN EFI_ACPI_DMAR_DEVICE_SCOPE_STRUCTURE_HEADER *DmarDevScopeEntry,\r
+ OUT UINT8 *Bus,\r
+ OUT UINT8 *Device,\r
+ OUT UINT8 *Function\r
+ );\r
+\r
#endif\r
\r
DEBUG ((DEBUG_INFO,\r
" *************************************************************************\n"\r
+ ));\r
+ DEBUG ((DEBUG_INFO,\r
" * DMA-Remapping Device Scope Entry Structure *\n"\r
+ ));\r
+ DEBUG ((DEBUG_INFO,\r
" *************************************************************************\n"\r
));\r
DEBUG ((DEBUG_INFO,\r
\r
DEBUG ((DEBUG_INFO,\r
" ***************************************************************************\n"\r
+ ));\r
+ DEBUG ((DEBUG_INFO,\r
" * ACPI Name-space Device Declaration Structure *\n"\r
+ ));\r
+ DEBUG ((DEBUG_INFO,\r
" ***************************************************************************\n"\r
));\r
DEBUG ((DEBUG_INFO,\r
\r
DEBUG ((DEBUG_INFO,\r
" ***************************************************************************\n"\r
+ ));\r
+ DEBUG ((DEBUG_INFO,\r
" * Remapping Hardware Status Affinity Structure *\n"\r
+ ));\r
+ DEBUG ((DEBUG_INFO,\r
" ***************************************************************************\n"\r
));\r
DEBUG ((DEBUG_INFO,\r
\r
DEBUG ((DEBUG_INFO,\r
" ***************************************************************************\n"\r
+ ));\r
+ DEBUG ((DEBUG_INFO,\r
" * Root Port ATS Capability Reporting Structure *\n"\r
+ ));\r
+ DEBUG ((DEBUG_INFO,\r
" ***************************************************************************\n"\r
));\r
DEBUG ((DEBUG_INFO,\r
\r
DEBUG ((DEBUG_INFO,\r
" ***************************************************************************\n"\r
+ ));\r
+ DEBUG ((DEBUG_INFO,\r
" * Reserved Memory Region Reporting Structure *\n"\r
+ ));\r
+ DEBUG ((DEBUG_INFO,\r
" ***************************************************************************\n"\r
));\r
DEBUG ((DEBUG_INFO,\r
\r
DEBUG ((DEBUG_INFO,\r
" ***************************************************************************\n"\r
+ ));\r
+ DEBUG ((DEBUG_INFO,\r
" * DMA-Remapping Hardware Definition Structure *\n"\r
+ ));\r
+ DEBUG ((DEBUG_INFO,\r
" ***************************************************************************\n"\r
));\r
DEBUG ((DEBUG_INFO,\r
//\r
DEBUG ((DEBUG_INFO,\r
"*****************************************************************************\n"\r
+ ));\r
+ DEBUG ((DEBUG_INFO,\r
"* DMAR Table *\n"\r
+ ));\r
+ DEBUG ((DEBUG_INFO,\r
"*****************************************************************************\n"\r
));\r
\r
switch (DmarDevScopeEntry->Type) {\r
case EFI_ACPI_DEVICE_SCOPE_ENTRY_TYPE_PCI_ENDPOINT:\r
case EFI_ACPI_DEVICE_SCOPE_ENTRY_TYPE_PCI_BRIDGE:\r
- while ((UINTN)DmarPciPath < (UINTN)DmarDevScopeEntry + DmarDevScopeEntry->Length) {\r
+ while ((UINTN)DmarPciPath + sizeof(EFI_ACPI_DMAR_PCI_PATH) < (UINTN)DmarDevScopeEntry + DmarDevScopeEntry->Length) {\r
MyBus = PciSegmentRead8 (PCI_SEGMENT_LIB_ADDRESS(Segment, MyBus, MyDevice, MyFunction, PCI_BRIDGE_SECONDARY_BUS_REGISTER_OFFSET));\r
+ DmarPciPath ++;\r
MyDevice = DmarPciPath->Device;\r
MyFunction = DmarPciPath->Function;\r
- DmarPciPath ++;\r
}\r
break;\r
case EFI_ACPI_DEVICE_SCOPE_ENTRY_TYPE_IOAPIC:\r
UINT8 SecondaryBusNumber;\r
EFI_STATUS Status;\r
VTD_SOURCE_ID SourceId;\r
- BOOLEAN IsRealPciDevice;\r
\r
mVtdUnitInformation[VtdIndex].VtdUnitBaseAddress = (UINTN)DmarDrhd->RegisterBaseAddress;\r
DEBUG ((DEBUG_INFO," VTD (%d) BaseAddress - 0x%016lx\n", VtdIndex, DmarDrhd->RegisterBaseAddress));\r
mVtdUnitInformation[VtdIndex].PciDeviceInfo.IncludeAllFlag = TRUE;\r
DEBUG ((DEBUG_INFO," ProcessDhrd: with INCLUDE ALL\n"));\r
\r
- Status = ScanPciBus(VtdIndex, DmarDrhd->SegmentNumber, 0);\r
+ Status = ScanPciBus((VOID *)VtdIndex, DmarDrhd->SegmentNumber, 0, ScanBusCallbackRegisterPciDevice);\r
if (EFI_ERROR (Status)) {\r
return Status;\r
}\r
if (EFI_ERROR (Status)) {\r
return Status;\r
}\r
- switch (DmarDevScopeEntry->Type) {\r
- case EFI_ACPI_DEVICE_SCOPE_ENTRY_TYPE_PCI_ENDPOINT:\r
- case EFI_ACPI_DEVICE_SCOPE_ENTRY_TYPE_PCI_BRIDGE:\r
- IsRealPciDevice = TRUE;\r
- break;\r
- default:\r
- IsRealPciDevice = FALSE;\r
- break;\r
- }\r
\r
DEBUG ((DEBUG_INFO," ProcessDhrd: "));\r
switch (DmarDevScopeEntry->Type) {\r
SourceId.Bits.Device = Device;\r
SourceId.Bits.Function = Function;\r
\r
- Status = RegisterPciDevice (VtdIndex, DmarDrhd->SegmentNumber, SourceId, IsRealPciDevice, TRUE);\r
+ Status = RegisterPciDevice (VtdIndex, DmarDrhd->SegmentNumber, SourceId, DmarDevScopeEntry->Type, TRUE);\r
if (EFI_ERROR (Status)) {\r
//\r
// There might be duplication for special device other than standard PCI device.\r
switch (DmarDevScopeEntry->Type) {\r
case EFI_ACPI_DEVICE_SCOPE_ENTRY_TYPE_PCI_BRIDGE:\r
SecondaryBusNumber = PciSegmentRead8 (PCI_SEGMENT_LIB_ADDRESS(DmarDrhd->SegmentNumber, Bus, Device, Function, PCI_BRIDGE_SECONDARY_BUS_REGISTER_OFFSET));\r
- Status = ScanPciBus (VtdIndex, DmarDrhd->SegmentNumber, SecondaryBusNumber);\r
+ Status = ScanPciBus ((VOID *)VtdIndex, DmarDrhd->SegmentNumber, SecondaryBusNumber, ScanBusCallbackRegisterPciDevice);\r
if (EFI_ERROR (Status)) {\r
return Status;\r
}\r
#include "DmaProtection.h"\r
\r
/**\r
- Return the index of PCI descriptor.\r
+ Return the index of PCI data.\r
\r
@param[in] VtdIndex The index used to identify a VTd engine.\r
@param[in] Segment The Segment used to identify a VTd engine.\r
@param[in] SourceId The SourceId used to identify a VTd engine and table entry.\r
\r
- @return The index of the PCI descriptor.\r
- @retval (UINTN)-1 The PCI descriptor is not found.\r
+ @return The index of the PCI data.\r
+ @retval (UINTN)-1 The PCI data is not found.\r
**/\r
UINTN\r
-GetPciDescriptor (\r
+GetPciDataIndex (\r
IN UINTN VtdIndex,\r
IN UINT16 Segment,\r
IN VTD_SOURCE_ID SourceId\r
)\r
{\r
- UINTN Index;\r
+ UINTN Index;\r
+ VTD_SOURCE_ID *PciSourceId;\r
\r
if (Segment != mVtdUnitInformation[VtdIndex].Segment) {\r
return (UINTN)-1;\r
}\r
\r
- for (Index = 0; Index < mVtdUnitInformation[VtdIndex].PciDeviceInfo.PciDescriptorNumber; Index++) {\r
- if ((mVtdUnitInformation[VtdIndex].PciDeviceInfo.PciDescriptors[Index].Bits.Bus == SourceId.Bits.Bus) &&\r
- (mVtdUnitInformation[VtdIndex].PciDeviceInfo.PciDescriptors[Index].Bits.Device == SourceId.Bits.Device) &&\r
- (mVtdUnitInformation[VtdIndex].PciDeviceInfo.PciDescriptors[Index].Bits.Function == SourceId.Bits.Function) ) {\r
+ for (Index = 0; Index < mVtdUnitInformation[VtdIndex].PciDeviceInfo.PciDeviceDataNumber; Index++) {\r
+ PciSourceId = &mVtdUnitInformation[VtdIndex].PciDeviceInfo.PciDeviceData[Index].PciSourceId;\r
+ if ((PciSourceId->Bits.Bus == SourceId.Bits.Bus) &&\r
+ (PciSourceId->Bits.Device == SourceId.Bits.Device) &&\r
+ (PciSourceId->Bits.Function == SourceId.Bits.Function) ) {\r
return Index;\r
}\r
}\r
}\r
\r
/**\r
- Register PCI device to VTd engine as PCI descriptor.\r
+ Register PCI device to VTd engine.\r
\r
@param[in] VtdIndex The index of VTd engine.\r
@param[in] Segment The segment of the source.\r
@param[in] SourceId The SourceId of the source.\r
- @param[in] IsRealPciDevice TRUE: It is a real PCI device.\r
- FALSE: It is not a real PCI device.\r
+ @param[in] DeviceType The DMAR device scope type.\r
@param[in] CheckExist TRUE: ERROR will be returned if the PCI device is already registered.\r
FALSE: SUCCESS will be returned if the PCI device is registered.\r
\r
IN UINTN VtdIndex,\r
IN UINT16 Segment,\r
IN VTD_SOURCE_ID SourceId,\r
- IN BOOLEAN IsRealPciDevice,\r
+ IN UINT8 DeviceType,\r
IN BOOLEAN CheckExist\r
)\r
{\r
- PCI_DEVICE_INFORMATION *PciDeviceInfo;\r
- VTD_SOURCE_ID *PciDescriptor;\r
- UINTN PciDescriptorIndex;\r
- UINTN Index;\r
- BOOLEAN *NewIsRealPciDevice;\r
- VTD_SOURCE_ID *NewPciDescriptors;\r
- UINTN *NewAccessCount;\r
+ PCI_DEVICE_INFORMATION *PciDeviceInfo;\r
+ VTD_SOURCE_ID *PciSourceId;\r
+ UINTN PciDataIndex;\r
+ UINTN Index;\r
+ PCI_DEVICE_DATA *NewPciDeviceData;\r
+ EDKII_PLATFORM_VTD_PCI_DEVICE_ID *PciDeviceId;\r
\r
PciDeviceInfo = &mVtdUnitInformation[VtdIndex].PciDeviceInfo;\r
\r
// Do not register device in other VTD Unit\r
//\r
for (Index = 0; Index < VtdIndex; Index++) {\r
- PciDescriptorIndex = GetPciDescriptor (Index, Segment, SourceId);\r
- if (PciDescriptorIndex != (UINTN)-1) {\r
+ PciDataIndex = GetPciDataIndex (Index, Segment, SourceId);\r
+ if (PciDataIndex != (UINTN)-1) {\r
DEBUG ((DEBUG_INFO, " RegisterPciDevice: PCI S%04x B%02x D%02x F%02x already registered by Other Vtd(%d)\n", Segment, SourceId.Bits.Bus, SourceId.Bits.Device, SourceId.Bits.Function, Index));\r
return EFI_SUCCESS;\r
}\r
}\r
}\r
\r
- PciDescriptorIndex = GetPciDescriptor (VtdIndex, Segment, SourceId);\r
- if (PciDescriptorIndex == (UINTN)-1) {\r
+ PciDataIndex = GetPciDataIndex (VtdIndex, Segment, SourceId);\r
+ if (PciDataIndex == (UINTN)-1) {\r
//\r
// Register new\r
//\r
\r
- if (PciDeviceInfo->PciDescriptorNumber >= PciDeviceInfo->PciDescriptorMaxNumber) {\r
+ if (PciDeviceInfo->PciDeviceDataNumber >= PciDeviceInfo->PciDeviceDataMaxNumber) {\r
//\r
// Reallocate\r
//\r
- NewIsRealPciDevice = AllocateZeroPool (sizeof(*NewIsRealPciDevice) * (PciDeviceInfo->PciDescriptorMaxNumber + MAX_PCI_DESCRIPTORS));\r
- if (NewIsRealPciDevice == NULL) {\r
- return EFI_OUT_OF_RESOURCES;\r
- }\r
- NewPciDescriptors = AllocateZeroPool (sizeof(*NewPciDescriptors) * (PciDeviceInfo->PciDescriptorMaxNumber + MAX_PCI_DESCRIPTORS));\r
- if (NewPciDescriptors == NULL) {\r
- FreePool (NewIsRealPciDevice);\r
+ NewPciDeviceData = AllocateZeroPool (sizeof(*NewPciDeviceData) * (PciDeviceInfo->PciDeviceDataMaxNumber + MAX_VTD_PCI_DATA_NUMBER));\r
+ if (NewPciDeviceData == NULL) {\r
return EFI_OUT_OF_RESOURCES;\r
}\r
- NewAccessCount = AllocateZeroPool (sizeof(*NewAccessCount) * (PciDeviceInfo->PciDescriptorMaxNumber + MAX_PCI_DESCRIPTORS));\r
- if (NewAccessCount == NULL) {\r
- FreePool (NewIsRealPciDevice);\r
- FreePool (NewPciDescriptors);\r
- return EFI_OUT_OF_RESOURCES;\r
- }\r
- PciDeviceInfo->PciDescriptorMaxNumber += MAX_PCI_DESCRIPTORS;\r
- if (PciDeviceInfo->IsRealPciDevice != NULL) {\r
- CopyMem (NewIsRealPciDevice, PciDeviceInfo->IsRealPciDevice, sizeof(*NewIsRealPciDevice) * PciDeviceInfo->PciDescriptorNumber);\r
- FreePool (PciDeviceInfo->IsRealPciDevice);\r
- }\r
- PciDeviceInfo->IsRealPciDevice = NewIsRealPciDevice;\r
- if (PciDeviceInfo->PciDescriptors != NULL) {\r
- CopyMem (NewPciDescriptors, PciDeviceInfo->PciDescriptors, sizeof(*NewPciDescriptors) * PciDeviceInfo->PciDescriptorNumber);\r
- FreePool (PciDeviceInfo->PciDescriptors);\r
+ PciDeviceInfo->PciDeviceDataMaxNumber += MAX_VTD_PCI_DATA_NUMBER;\r
+ if (PciDeviceInfo->PciDeviceData != NULL) {\r
+ CopyMem (NewPciDeviceData, PciDeviceInfo->PciDeviceData, sizeof(*NewPciDeviceData) * PciDeviceInfo->PciDeviceDataNumber);\r
+ FreePool (PciDeviceInfo->PciDeviceData);\r
}\r
- PciDeviceInfo->PciDescriptors = NewPciDescriptors;\r
- if (PciDeviceInfo->AccessCount != NULL) {\r
- CopyMem (NewAccessCount, PciDeviceInfo->AccessCount, sizeof(*NewAccessCount) * PciDeviceInfo->PciDescriptorNumber);\r
- FreePool (PciDeviceInfo->AccessCount);\r
- }\r
- PciDeviceInfo->AccessCount = NewAccessCount;\r
+ PciDeviceInfo->PciDeviceData = NewPciDeviceData;\r
}\r
\r
- ASSERT (PciDeviceInfo->PciDescriptorNumber < PciDeviceInfo->PciDescriptorMaxNumber);\r
-\r
- PciDescriptor = &PciDeviceInfo->PciDescriptors[PciDeviceInfo->PciDescriptorNumber];\r
- PciDescriptor->Bits.Bus = SourceId.Bits.Bus;\r
- PciDescriptor->Bits.Device = SourceId.Bits.Device;\r
- PciDescriptor->Bits.Function = SourceId.Bits.Function;\r
- PciDeviceInfo->IsRealPciDevice[PciDeviceInfo->PciDescriptorNumber] = IsRealPciDevice;\r
+ ASSERT (PciDeviceInfo->PciDeviceDataNumber < PciDeviceInfo->PciDeviceDataMaxNumber);\r
\r
- PciDeviceInfo->PciDescriptorNumber++;\r
+ PciSourceId = &PciDeviceInfo->PciDeviceData[PciDeviceInfo->PciDeviceDataNumber].PciSourceId;\r
+ PciSourceId->Bits.Bus = SourceId.Bits.Bus;\r
+ PciSourceId->Bits.Device = SourceId.Bits.Device;\r
+ PciSourceId->Bits.Function = SourceId.Bits.Function;\r
\r
DEBUG ((DEBUG_INFO, " RegisterPciDevice: PCI S%04x B%02x D%02x F%02x", Segment, SourceId.Bits.Bus, SourceId.Bits.Device, SourceId.Bits.Function));\r
- if (!IsRealPciDevice) {\r
+\r
+ PciDeviceId = &PciDeviceInfo->PciDeviceData[PciDeviceInfo->PciDeviceDataNumber].PciDeviceId;\r
+ if ((DeviceType == EFI_ACPI_DEVICE_SCOPE_ENTRY_TYPE_PCI_ENDPOINT) ||\r
+ (DeviceType == EFI_ACPI_DEVICE_SCOPE_ENTRY_TYPE_PCI_BRIDGE)) {\r
+ PciDeviceId->VendorId = PciSegmentRead16 (PCI_SEGMENT_LIB_ADDRESS(Segment, SourceId.Bits.Bus, SourceId.Bits.Device, SourceId.Bits.Function, PCI_VENDOR_ID_OFFSET));\r
+ PciDeviceId->DeviceId = PciSegmentRead16 (PCI_SEGMENT_LIB_ADDRESS(Segment, SourceId.Bits.Bus, SourceId.Bits.Device, SourceId.Bits.Function, PCI_DEVICE_ID_OFFSET));\r
+ PciDeviceId->RevisionId = PciSegmentRead8 (PCI_SEGMENT_LIB_ADDRESS(Segment, SourceId.Bits.Bus, SourceId.Bits.Device, SourceId.Bits.Function, PCI_REVISION_ID_OFFSET));\r
+\r
+ DEBUG ((DEBUG_INFO, " (%04x:%04x:%02x", PciDeviceId->VendorId, PciDeviceId->DeviceId, PciDeviceId->RevisionId));\r
+\r
+ if (DeviceType == EFI_ACPI_DEVICE_SCOPE_ENTRY_TYPE_PCI_ENDPOINT) {\r
+ PciDeviceId->SubsystemVendorId = PciSegmentRead16 (PCI_SEGMENT_LIB_ADDRESS(Segment, SourceId.Bits.Bus, SourceId.Bits.Device, SourceId.Bits.Function, PCI_SUBSYSTEM_VENDOR_ID_OFFSET));\r
+ PciDeviceId->SubsystemDeviceId = PciSegmentRead16 (PCI_SEGMENT_LIB_ADDRESS(Segment, SourceId.Bits.Bus, SourceId.Bits.Device, SourceId.Bits.Function, PCI_SUBSYSTEM_ID_OFFSET));\r
+ DEBUG ((DEBUG_INFO, ":%04x:%04x", PciDeviceId->SubsystemVendorId, PciDeviceId->SubsystemDeviceId));\r
+ }\r
+ DEBUG ((DEBUG_INFO, ")"));\r
+ }\r
+\r
+ PciDeviceInfo->PciDeviceData[PciDeviceInfo->PciDeviceDataNumber].DeviceType = DeviceType;\r
+\r
+ if ((DeviceType != EFI_ACPI_DEVICE_SCOPE_ENTRY_TYPE_PCI_ENDPOINT) &&\r
+ (DeviceType != EFI_ACPI_DEVICE_SCOPE_ENTRY_TYPE_PCI_BRIDGE)) {\r
DEBUG ((DEBUG_INFO, " (*)"));\r
}\r
DEBUG ((DEBUG_INFO, "\n"));\r
+\r
+ PciDeviceInfo->PciDeviceDataNumber++;\r
} else {\r
if (CheckExist) {\r
DEBUG ((DEBUG_INFO, " RegisterPciDevice: PCI S%04x B%02x D%02x F%02x already registered\n", Segment, SourceId.Bits.Bus, SourceId.Bits.Device, SourceId.Bits.Function));\r
}\r
\r
/**\r
- Scan PCI bus and register PCI devices under the bus.\r
+ The scan bus callback function to register PCI device.\r
\r
- @param[in] VtdIndex The index of VTd engine.\r
+ @param[in] Context The context of the callback.\r
@param[in] Segment The segment of the source.\r
@param[in] Bus The bus of the source.\r
+ @param[in] Device The device of the source.\r
+ @param[in] Function The function of the source.\r
\r
- @retval EFI_SUCCESS The PCI devices under the bus are registered.\r
- @retval EFI_OUT_OF_RESOURCES No enough resource to register a new PCI device.\r
+ @retval EFI_SUCCESS The PCI device is registered.\r
**/\r
EFI_STATUS\r
-ScanPciBus (\r
- IN UINTN VtdIndex,\r
+EFIAPI\r
+ScanBusCallbackRegisterPciDevice (\r
+ IN VOID *Context,\r
IN UINT16 Segment,\r
- IN UINT8 Bus\r
+ IN UINT8 Bus,\r
+ IN UINT8 Device,\r
+ IN UINT8 Function\r
+ )\r
+{\r
+ VTD_SOURCE_ID SourceId;\r
+ UINTN VtdIndex;\r
+ UINT8 BaseClass;\r
+ UINT8 SubClass;\r
+ UINT8 DeviceType;\r
+ EFI_STATUS Status;\r
+\r
+ VtdIndex = (UINTN)Context;\r
+ SourceId.Bits.Bus = Bus;\r
+ SourceId.Bits.Device = Device;\r
+ SourceId.Bits.Function = Function;\r
+\r
+ DeviceType = EFI_ACPI_DEVICE_SCOPE_ENTRY_TYPE_PCI_ENDPOINT;\r
+ BaseClass = PciSegmentRead8 (PCI_SEGMENT_LIB_ADDRESS(Segment, Bus, Device, Function, PCI_CLASSCODE_OFFSET + 2));\r
+ if (BaseClass == PCI_CLASS_BRIDGE) {\r
+ SubClass = PciSegmentRead8 (PCI_SEGMENT_LIB_ADDRESS(Segment, Bus, Device, Function, PCI_CLASSCODE_OFFSET + 1));\r
+ if (SubClass == PCI_CLASS_BRIDGE_P2P) {\r
+ DeviceType = EFI_ACPI_DEVICE_SCOPE_ENTRY_TYPE_PCI_BRIDGE;\r
+ }\r
+ }\r
+\r
+ Status = RegisterPciDevice (VtdIndex, Segment, SourceId, DeviceType, FALSE);\r
+ return Status;\r
+}\r
+\r
+/**\r
+ Scan PCI bus and invoke callback function for each PCI devices under the bus.\r
+\r
+ @param[in] Context The context of the callback function.\r
+ @param[in] Segment The segment of the source.\r
+ @param[in] Bus The bus of the source.\r
+ @param[in] Callback The callback function in PCI scan.\r
+\r
+ @retval EFI_SUCCESS The PCI devices under the bus are scaned.\r
+**/\r
+EFI_STATUS\r
+ScanPciBus (\r
+ IN VOID *Context,\r
+ IN UINT16 Segment,\r
+ IN UINT8 Bus,\r
+ IN SCAN_BUS_FUNC_CALLBACK_FUNC Callback\r
)\r
{\r
UINT8 Device;\r
UINT16 VendorID;\r
UINT16 DeviceID;\r
EFI_STATUS Status;\r
- VTD_SOURCE_ID SourceId;\r
\r
// Scan the PCI bus for devices\r
for (Device = 0; Device < PCI_MAX_DEVICE + 1; Device++) {\r
continue;\r
}\r
\r
- SourceId.Bits.Bus = Bus;\r
- SourceId.Bits.Device = Device;\r
- SourceId.Bits.Function = Function;\r
- Status = RegisterPciDevice (VtdIndex, Segment, SourceId, TRUE, FALSE);\r
+ Status = Callback (Context, Segment, Bus, Device, Function);\r
if (EFI_ERROR (Status)) {\r
return Status;\r
}\r
SecondaryBusNumber = PciSegmentRead8 (PCI_SEGMENT_LIB_ADDRESS(Segment, Bus, Device, Function, PCI_BRIDGE_SECONDARY_BUS_REGISTER_OFFSET));\r
DEBUG ((DEBUG_INFO," ScanPciBus: PCI bridge S%04x B%02x D%02x F%02x (SecondBus:%02x)\n", Segment, Bus, Device, Function, SecondaryBusNumber));\r
if (SecondaryBusNumber != 0) {\r
- Status = ScanPciBus (VtdIndex, Segment, SecondaryBusNumber);\r
+ Status = ScanPciBus (Context, Segment, SecondaryBusNumber, Callback);\r
if (EFI_ERROR (Status)) {\r
return Status;\r
}\r
UINTN Index;\r
\r
DEBUG ((DEBUG_INFO,"PCI Device Information (Number 0x%x, IncludeAll - %d):\n",\r
- mVtdUnitInformation[VtdIndex].PciDeviceInfo.PciDescriptorNumber,\r
+ mVtdUnitInformation[VtdIndex].PciDeviceInfo.PciDeviceDataNumber,\r
mVtdUnitInformation[VtdIndex].PciDeviceInfo.IncludeAllFlag\r
));\r
- for (Index = 0; Index < mVtdUnitInformation[VtdIndex].PciDeviceInfo.PciDescriptorNumber; Index++) {\r
+ for (Index = 0; Index < mVtdUnitInformation[VtdIndex].PciDeviceInfo.PciDeviceDataNumber; Index++) {\r
DEBUG ((DEBUG_INFO," S%04x B%02x D%02x F%02x\n",\r
mVtdUnitInformation[VtdIndex].Segment,\r
- mVtdUnitInformation[VtdIndex].PciDeviceInfo.PciDescriptors[Index].Bits.Bus,\r
- mVtdUnitInformation[VtdIndex].PciDeviceInfo.PciDescriptors[Index].Bits.Device,\r
- mVtdUnitInformation[VtdIndex].PciDeviceInfo.PciDescriptors[Index].Bits.Function\r
+ mVtdUnitInformation[VtdIndex].PciDeviceInfo.PciDeviceData[Index].PciSourceId.Bits.Bus,\r
+ mVtdUnitInformation[VtdIndex].PciDeviceInfo.PciDeviceData[Index].PciSourceId.Bits.Device,\r
+ mVtdUnitInformation[VtdIndex].PciDeviceInfo.PciDeviceData[Index].PciSourceId.Bits.Function\r
));\r
}\r
}\r
@param[out] ExtContextEntry The ExtContextEntry of the source.\r
@param[out] ContextEntry The ContextEntry of the source.\r
\r
- @return The index of the PCI descriptor.\r
- @retval (UINTN)-1 The PCI descriptor is not found.\r
+ @return The index of the VTd engine.\r
+ @retval (UINTN)-1 The VTd engine is not found.\r
**/\r
UINTN\r
FindVtdIndexByPciDevice (\r
VTD_EXT_ROOT_ENTRY *ExtRootEntry;\r
VTD_EXT_CONTEXT_ENTRY *ExtContextEntryTable;\r
VTD_EXT_CONTEXT_ENTRY *ThisExtContextEntry;\r
- UINTN PciDescriptorIndex;\r
+ UINTN PciDataIndex;\r
\r
for (VtdIndex = 0; VtdIndex < mVtdUnitNumber; VtdIndex++) {\r
if (Segment != mVtdUnitInformation[VtdIndex].Segment) {\r
continue;\r
}\r
\r
- PciDescriptorIndex = GetPciDescriptor (VtdIndex, Segment, SourceId);\r
- if (PciDescriptorIndex == (UINTN)-1) {\r
+ PciDataIndex = GetPciDataIndex (VtdIndex, Segment, SourceId);\r
+ if (PciDataIndex == (UINTN)-1) {\r
continue;\r
}\r
\r
VTD_ROOT_ENTRY *RootEntry;\r
VTD_CONTEXT_ENTRY *ContextEntryTable;\r
VTD_CONTEXT_ENTRY *ContextEntry;\r
- VTD_SOURCE_ID *PciDescriptor;\r
+ VTD_SOURCE_ID *PciSourceId;\r
VTD_SOURCE_ID SourceId;\r
UINTN MaxBusNumber;\r
UINTN EntryTablePages;\r
\r
MaxBusNumber = 0;\r
- for (Index = 0; Index < mVtdUnitInformation[VtdIndex].PciDeviceInfo.PciDescriptorNumber; Index++) {\r
- PciDescriptor = &mVtdUnitInformation[VtdIndex].PciDeviceInfo.PciDescriptors[Index];\r
- if (PciDescriptor->Bits.Bus > MaxBusNumber) {\r
- MaxBusNumber = PciDescriptor->Bits.Bus;\r
+ for (Index = 0; Index < mVtdUnitInformation[VtdIndex].PciDeviceInfo.PciDeviceDataNumber; Index++) {\r
+ PciSourceId = &mVtdUnitInformation[VtdIndex].PciDeviceInfo.PciDeviceData[Index].PciSourceId;\r
+ if (PciSourceId->Bits.Bus > MaxBusNumber) {\r
+ MaxBusNumber = PciSourceId->Bits.Bus;\r
}\r
}\r
DEBUG ((DEBUG_INFO," MaxBusNumber - 0x%x\n", MaxBusNumber));\r
mVtdUnitInformation[VtdIndex].RootEntryTable = (VTD_ROOT_ENTRY *)Buffer;\r
Buffer = (UINT8 *)Buffer + EFI_PAGES_TO_SIZE (RootPages);\r
\r
- for (Index = 0; Index < mVtdUnitInformation[VtdIndex].PciDeviceInfo.PciDescriptorNumber; Index++) {\r
- PciDescriptor = &mVtdUnitInformation[VtdIndex].PciDeviceInfo.PciDescriptors[Index];\r
+ for (Index = 0; Index < mVtdUnitInformation[VtdIndex].PciDeviceInfo.PciDeviceDataNumber; Index++) {\r
+ PciSourceId = &mVtdUnitInformation[VtdIndex].PciDeviceInfo.PciDeviceData[Index].PciSourceId;\r
\r
- SourceId.Bits.Bus = PciDescriptor->Bits.Bus;\r
- SourceId.Bits.Device = PciDescriptor->Bits.Device;\r
- SourceId.Bits.Function = PciDescriptor->Bits.Function;\r
+ SourceId.Bits.Bus = PciSourceId->Bits.Bus;\r
+ SourceId.Bits.Device = PciSourceId->Bits.Device;\r
+ SourceId.Bits.Function = PciSourceId->Bits.Function;\r
\r
RootEntry = &mVtdUnitInformation[VtdIndex].RootEntryTable[SourceId.Index.RootIndex];\r
if (RootEntry->Bits.Present == 0) {\r
VTD_CONTEXT_ENTRY *ContextEntry;\r
VTD_SECOND_LEVEL_PAGING_ENTRY *SecondLevelPagingEntry;\r
UINT64 Pt;\r
- UINTN PciDescriptorIndex;\r
+ UINTN PciDataIndex;\r
UINT16 DomainIdentifier;\r
\r
SecondLevelPagingEntry = NULL;\r
return EFI_DEVICE_ERROR;\r
}\r
\r
- PciDescriptorIndex = GetPciDescriptor (VtdIndex, Segment, SourceId);\r
- mVtdUnitInformation[VtdIndex].PciDeviceInfo.AccessCount[PciDescriptorIndex]++;\r
+ PciDataIndex = GetPciDataIndex (VtdIndex, Segment, SourceId);\r
+ mVtdUnitInformation[VtdIndex].PciDeviceInfo.PciDeviceData[PciDataIndex].AccessCount++;\r
//\r
// DomainId should not be 0.\r
//\r
- DomainIdentifier = (UINT16)(PciDescriptorIndex + 1);\r
+ DomainIdentifier = (UINT16)(PciDataIndex + 1);\r
\r
if (ExtContextEntry != NULL) {\r
if (ExtContextEntry->Bits.Present == 0) {\r
VTD_EXT_ROOT_ENTRY *ExtRootEntry;\r
VTD_EXT_CONTEXT_ENTRY *ExtContextEntryTable;\r
VTD_EXT_CONTEXT_ENTRY *ExtContextEntry;\r
- VTD_SOURCE_ID *PciDescriptor;\r
+ VTD_SOURCE_ID *PciSourceId;\r
VTD_SOURCE_ID SourceId;\r
UINTN MaxBusNumber;\r
UINTN EntryTablePages;\r
\r
MaxBusNumber = 0;\r
- for (Index = 0; Index < mVtdUnitInformation[VtdIndex].PciDeviceInfo.PciDescriptorNumber; Index++) {\r
- PciDescriptor = &mVtdUnitInformation[VtdIndex].PciDeviceInfo.PciDescriptors[Index];\r
- if (PciDescriptor->Bits.Bus > MaxBusNumber) {\r
- MaxBusNumber = PciDescriptor->Bits.Bus;\r
+ for (Index = 0; Index < mVtdUnitInformation[VtdIndex].PciDeviceInfo.PciDeviceDataNumber; Index++) {\r
+ PciSourceId = &mVtdUnitInformation[VtdIndex].PciDeviceInfo.PciDeviceData[Index].PciSourceId;\r
+ if (PciSourceId->Bits.Bus > MaxBusNumber) {\r
+ MaxBusNumber = PciSourceId->Bits.Bus;\r
}\r
}\r
DEBUG ((DEBUG_INFO," MaxBusNumber - 0x%x\n", MaxBusNumber));\r
mVtdUnitInformation[VtdIndex].ExtRootEntryTable = (VTD_EXT_ROOT_ENTRY *)Buffer;\r
Buffer = (UINT8 *)Buffer + EFI_PAGES_TO_SIZE (RootPages);\r
\r
- for (Index = 0; Index < mVtdUnitInformation[VtdIndex].PciDeviceInfo.PciDescriptorNumber; Index++) {\r
- PciDescriptor = &mVtdUnitInformation[VtdIndex].PciDeviceInfo.PciDescriptors[Index];\r
+ for (Index = 0; Index < mVtdUnitInformation[VtdIndex].PciDeviceInfo.PciDeviceDataNumber; Index++) {\r
+ PciSourceId = &mVtdUnitInformation[VtdIndex].PciDeviceInfo.PciDeviceData[Index].PciSourceId;\r
\r
- SourceId.Bits.Bus = PciDescriptor->Bits.Bus;\r
- SourceId.Bits.Device = PciDescriptor->Bits.Device;\r
- SourceId.Bits.Function = PciDescriptor->Bits.Function;\r
+ SourceId.Bits.Bus = PciSourceId->Bits.Bus;\r
+ SourceId.Bits.Device = PciSourceId->Bits.Device;\r
+ SourceId.Bits.Function = PciSourceId->Bits.Function;\r
\r
ExtRootEntry = &mVtdUnitInformation[VtdIndex].ExtRootEntryTable[SourceId.Index.RootIndex];\r
if (ExtRootEntry->Bits.LowerPresent == 0) {\r
}\r
\r
DomainNumber = (UINTN)1 << (UINT8)((UINTN)mVtdUnitInformation[Index].CapReg.Bits.ND * 2 + 4);\r
- if (mVtdUnitInformation[Index].PciDeviceInfo.PciDescriptorNumber >= DomainNumber) {\r
- DEBUG((DEBUG_ERROR, "!!!! Pci device Number(0x%x) >= DomainNumber(0x%x) !!!!\n", mVtdUnitInformation[Index].PciDeviceInfo.PciDescriptorNumber, DomainNumber));\r
+ if (mVtdUnitInformation[Index].PciDeviceInfo.PciDeviceDataNumber >= DomainNumber) {\r
+ DEBUG((DEBUG_ERROR, "!!!! Pci device Number(0x%x) >= DomainNumber(0x%x) !!!!\n", mVtdUnitInformation[Index].PciDeviceInfo.PciDeviceDataNumber, DomainNumber));\r
return ;\r
}\r
}\r
\r
for (Index = 0; Index < mVtdUnitNumber; Index++) {\r
DEBUG((DEBUG_INFO, "engine [%d] access\n", Index));\r
- for (SubIndex = 0; SubIndex < mVtdUnitInformation[Index].PciDeviceInfo.PciDescriptorNumber; SubIndex++) {\r
+ for (SubIndex = 0; SubIndex < mVtdUnitInformation[Index].PciDeviceInfo.PciDeviceDataNumber; SubIndex++) {\r
DEBUG ((DEBUG_INFO, " PCI S%04X B%02x D%02x F%02x - %d\n",\r
mVtdUnitInformation[Index].Segment,\r
- mVtdUnitInformation[Index].PciDeviceInfo.PciDescriptors[SubIndex].Bits.Bus,\r
- mVtdUnitInformation[Index].PciDeviceInfo.PciDescriptors[SubIndex].Bits.Device,\r
- mVtdUnitInformation[Index].PciDeviceInfo.PciDescriptors[SubIndex].Bits.Function,\r
- mVtdUnitInformation[Index].PciDeviceInfo.AccessCount[SubIndex]\r
+ mVtdUnitInformation[Index].PciDeviceInfo.PciDeviceData[Index].PciSourceId.Bits.Bus,\r
+ mVtdUnitInformation[Index].PciDeviceInfo.PciDeviceData[Index].PciSourceId.Bits.Device,\r
+ mVtdUnitInformation[Index].PciDeviceInfo.PciDeviceData[Index].PciSourceId.Bits.Function,\r
+ mVtdUnitInformation[Index].PciDeviceInfo.PciDeviceData[Index].AccessCount\r
));\r
}\r
}\r