]> git.proxmox.com Git - mirror_edk2.git/blobdiff - IntelSiliconPkg/PlatformVTdSampleDxe/PlatformVTdSampleDxe.c
IntelSiliconPkg/PlatformVTdSample: update ExceptionDevice
[mirror_edk2.git] / IntelSiliconPkg / PlatformVTdSampleDxe / PlatformVTdSampleDxe.c
index f181b94dfa9f2bfb950de26263dd75f1901d72a8..07499c7da81eb1a54a7e0133e5a0e18898addbf6 100644 (file)
@@ -27,6 +27,8 @@
 #include <Library/UefiBootServicesTableLib.h>\r
 #include <Library/DevicePathLib.h>\r
 \r
+#include <IndustryStandard/DmaRemappingReportingTable.h>\r
+\r
 typedef struct {\r
   ACPI_EXTENDED_HID_DEVICE_PATH      I2cController;\r
   UINT8                              HidStr[8];\r
@@ -137,10 +139,57 @@ PLATFORM_PCI_BRIDGE_DEVICE_PATH mPlatformPciBridgeDevicePath = {
   PLATFORM_END_ENTIRE\r
 };\r
 \r
-EDKII_PLATFORM_VTD_DEVICE_INFO  mExceptionDeviceList[] = {\r
+#pragma pack(1)\r
+\r
+typedef struct {\r
+  EDKII_PLATFORM_VTD_EXCEPTION_DEVICE_INFO     ExceptionDeviceInfo;\r
+  EDKII_PLATFORM_VTD_DEVICE_SCOPE              DeviceScope;\r
+  EFI_ACPI_DMAR_PCI_PATH                       PciBridge;\r
+  EFI_ACPI_DMAR_PCI_PATH                       PciDevice;\r
+} PLATFORM_EXCEPTION_DEVICE_SCOPE_STRUCT;\r
+\r
+typedef struct {\r
+  EDKII_PLATFORM_VTD_EXCEPTION_DEVICE_INFO     ExceptionDeviceInfo;\r
+  EDKII_PLATFORM_VTD_PCI_DEVICE_ID             PciDeviceId;\r
+} PLATFORM_EXCEPTION_PCI_DEVICE_ID_STRUCT;\r
+\r
+#pragma pack()\r
+\r
+PLATFORM_EXCEPTION_DEVICE_SCOPE_STRUCT  mExceptionDeviceScopeList[] = {\r
   {\r
-    0x0,                 // Segment\r
-    {{0x00, 0x00, 0x02}} // Function, Device, Bus\r
+    {\r
+      EDKII_PLATFORM_VTD_EXCEPTION_DEVICE_INFO_TYPE_DEVICE_SCOPE,\r
+      sizeof(PLATFORM_EXCEPTION_DEVICE_SCOPE_STRUCT)\r
+    },  // ExceptionDeviceInfo\r
+    {\r
+      0,                                                    // SegmentNumber\r
+      {\r
+        EFI_ACPI_DEVICE_SCOPE_ENTRY_TYPE_PCI_ENDPOINT,      // Type\r
+        sizeof(EFI_ACPI_DMAR_DEVICE_SCOPE_STRUCTURE_HEADER) +\r
+          2 * sizeof(EFI_ACPI_DMAR_PCI_PATH),               // Length\r
+        0,                                                  // Reserved2\r
+        0,                                                  // EnumerationId\r
+        0,                                                  // StartBusNumber\r
+      },\r
+    },                                                      // DeviceScope\r
+    { 0x1C, 1 },                                            // PciBridge\r
+    { 0x0,  0 },                                            // PciDevice\r
+  },\r
+};\r
+\r
+PLATFORM_EXCEPTION_PCI_DEVICE_ID_STRUCT  mExceptionPciDeviceIdList[] = {\r
+  {\r
+    {\r
+      EDKII_PLATFORM_VTD_EXCEPTION_DEVICE_INFO_TYPE_PCI_DEVICE_ID,\r
+      sizeof(PLATFORM_EXCEPTION_PCI_DEVICE_ID_STRUCT)\r
+    },  // ExceptionDeviceInfo\r
+    {\r
+      0x8086,                                               // VendorId\r
+      0x9D2F,                                               // DeviceId\r
+      0x21,                                                 // RevisionId\r
+      0x8086,                                               // SubsystemVendorId\r
+      0x7270,                                               // SubsystemDeviceId\r
+    },\r
   },\r
 };\r
 \r
@@ -269,6 +318,7 @@ PlatformVTdGetDeviceId (
   @param[in]  This                  The protocol instance pointer.\r
   @param[out] DeviceInfoCount       The count of the list of DeviceInfo.\r
   @param[out] DeviceInfo            A callee allocated buffer to hold a list of DeviceInfo.\r
+                                    Each DeviceInfo pointer points to EDKII_PLATFORM_VTD_EXCEPTION_DEVICE_INFO.\r
 \r
   @retval EFI_SUCCESS           The DeviceInfoCount and DeviceInfo are returned.\r
   @retval EFI_INVALID_PARAMETER DeviceInfoCount is NULL, or DeviceInfo is NULL.\r
@@ -280,7 +330,7 @@ EFIAPI
 PlatformVTdGetExceptionDeviceList (\r
   IN  EDKII_PLATFORM_VTD_POLICY_PROTOCOL       *This,\r
   OUT UINTN                                    *DeviceInfoCount,\r
-  OUT EDKII_PLATFORM_VTD_DEVICE_INFO           **DeviceInfo\r
+  OUT VOID                                     **DeviceInfo\r
   )\r
 {\r
   DEBUG ((DEBUG_VERBOSE, "PlatformVTdGetExceptionDeviceList\n"));\r
@@ -289,13 +339,23 @@ PlatformVTdGetExceptionDeviceList (
     return EFI_INVALID_PARAMETER;\r
   }\r
 \r
-  *DeviceInfo = AllocateZeroPool (sizeof(mExceptionDeviceList));\r
-  if (*DeviceInfo == NULL) {\r
-    return EFI_OUT_OF_RESOURCES;\r
-  }\r
-  CopyMem (*DeviceInfo, mExceptionDeviceList, sizeof(mExceptionDeviceList));\r
+  if (0) {\r
+    *DeviceInfo = AllocateZeroPool (sizeof(mExceptionDeviceScopeList));\r
+    if (*DeviceInfo == NULL) {\r
+      return EFI_OUT_OF_RESOURCES;\r
+    }\r
+    CopyMem (*DeviceInfo, mExceptionDeviceScopeList, sizeof(mExceptionDeviceScopeList));\r
+\r
+    *DeviceInfoCount = ARRAY_SIZE(mExceptionDeviceScopeList);\r
+  } else {\r
+    *DeviceInfo = AllocateZeroPool (sizeof(mExceptionPciDeviceIdList));\r
+    if (*DeviceInfo == NULL) {\r
+      return EFI_OUT_OF_RESOURCES;\r
+    }\r
+    CopyMem (*DeviceInfo, mExceptionPciDeviceIdList, sizeof(mExceptionPciDeviceIdList));\r
 \r
-  *DeviceInfoCount = ARRAY_SIZE(mExceptionDeviceList);\r
+    *DeviceInfoCount = ARRAY_SIZE(mExceptionPciDeviceIdList);\r
+  }\r
 \r
   return EFI_SUCCESS;\r
 }\r