#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