public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Zeng, Star" <star.zeng@intel.com>
To: "Yao, Jiewen" <jiewen.yao@intel.com>,
	"edk2-devel@lists.01.org" <edk2-devel@lists.01.org>
Cc: "Zeng, Star" <star.zeng@intel.com>
Subject: Re: [PATCH 3/3] IntelSiliconPkg/PlatformVTdSample: update ExceptionDevice
Date: Fri, 25 Aug 2017 09:39:29 +0000	[thread overview]
Message-ID: <0C09AFA07DD0434D9E2A0C6AEB0483103B91DB90@shsmsx102.ccr.corp.intel.com> (raw)
In-Reply-To: <1503646846-1036-4-git-send-email-jiewen.yao@intel.com>

PLATFORM_EXCEPTION_DEVICE_SCOPE_STRUCT is used in mExceptionPciDeviceIdList, that is wrong and should be PLATFORM_EXCEPTION_PCI_DEVICE_ID_STRUCT.
Others are good to me. Reviewed-by: Star Zeng <star.zeng@intel.com>

+PLATFORM_EXCEPTION_PCI_DEVICE_ID_STRUCT  mExceptionPciDeviceIdList[] = 
+{
+  {
+    {
+      EDKII_PLATFORM_VTD_EXCEPTION_DEVICE_INFO_TYPE_PCI_DEVICE_ID,
+      sizeof(PLATFORM_EXCEPTION_DEVICE_SCOPE_STRUCT)


Thanks,
Star
-----Original Message-----
From: Yao, Jiewen 
Sent: Friday, August 25, 2017 3:41 PM
To: edk2-devel@lists.01.org
Cc: Zeng, Star <star.zeng@intel.com>
Subject: [PATCH 3/3] IntelSiliconPkg/PlatformVTdSample: update ExceptionDevice

Add sample for device scope based exception list and PCI vendor id based exception list.

Cc: Star Zeng <star.zeng@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Jiewen Yao <jiewen.yao@intel.com>
---
 IntelSiliconPkg/PlatformVTdSampleDxe/PlatformVTdSampleDxe.c | 80 +++++++++++++++++---
 1 file changed, 70 insertions(+), 10 deletions(-)

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



  reply	other threads:[~2017-08-25  9:36 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-08-25  7:40 [PATCH 0/3] Add flexible exception device reporting Jiewen Yao
2017-08-25  7:40 ` [PATCH 1/3] IntelSiliconPkg/header: update PlatformVtdPolicy Jiewen Yao
2017-08-25  7:40 ` [PATCH 2/3] IntelSiliconPkg/IntelVTd: " Jiewen Yao
2017-08-25  7:40 ` [PATCH 3/3] IntelSiliconPkg/PlatformVTdSample: update ExceptionDevice Jiewen Yao
2017-08-25  9:39   ` Zeng, Star [this message]
2017-08-25 13:34     ` Yao, Jiewen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=0C09AFA07DD0434D9E2A0C6AEB0483103B91DB90@shsmsx102.ccr.corp.intel.com \
    --to=devel@edk2.groups.io \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox