From nobody Fri Dec 27 02:54:57 2024 Delivered-To: importer@patchew.org Received-SPF: none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) client-ip=198.145.21.10; envelope-from=edk2-devel-bounces@lists.01.org; helo=ml01.01.org; Authentication-Results: mx.zohomail.com; spf=none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) smtp.mailfrom=edk2-devel-bounces@lists.01.org Return-Path: Received: from ml01.01.org (ml01.01.org [198.145.21.10]) by mx.zohomail.com with SMTPS id 1503646878545531.5685331962761; Fri, 25 Aug 2017 00:41:18 -0700 (PDT) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id D1D0221D1E2C7; Fri, 25 Aug 2017 00:38:34 -0700 (PDT) Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id AEF4421D1E2C1 for ; Fri, 25 Aug 2017 00:38:33 -0700 (PDT) Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmsmga105.fm.intel.com with ESMTP; 25 Aug 2017 00:41:09 -0700 Received: from jyao1-mobl.ccr.corp.intel.com ([10.239.196.35]) by fmsmga004.fm.intel.com with ESMTP; 25 Aug 2017 00:41:08 -0700 X-Original-To: edk2-devel@lists.01.org X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.41,424,1498546800"; d="scan'208";a="304276374" From: Jiewen Yao To: edk2-devel@lists.01.org Date: Fri, 25 Aug 2017 15:40:46 +0800 Message-Id: <1503646846-1036-4-git-send-email-jiewen.yao@intel.com> X-Mailer: git-send-email 2.7.4.windows.1 In-Reply-To: <1503646846-1036-1-git-send-email-jiewen.yao@intel.com> References: <1503646846-1036-1-git-send-email-jiewen.yao@intel.com> Subject: [edk2] [PATCH 3/3] IntelSiliconPkg/PlatformVTdSample: update ExceptionDevice X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Star Zeng MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" X-ZohoMail: RSF_4 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Add sample for device scope based exception list and PCI vendor id based exception list. Cc: Star Zeng Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Jiewen Yao --- 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 #include =20 +#include + typedef struct { ACPI_EXTENDED_HID_DEVICE_PATH I2cController; UINT8 HidStr[8]; @@ -137,10 +139,57 @@ PLATFORM_PCI_BRIDGE_DEVICE_PATH mPlatformPciBridgeDev= icePath =3D { PLATFORM_END_ENTIRE }; =20 -EDKII_PLATFORM_VTD_DEVICE_INFO mExceptionDeviceList[] =3D { +#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[] =3D { { - 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, // SegmentNumb= er + { + 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, // Enumeration= Id + 0, // StartBusNum= ber + }, + }, // DeviceScope + { 0x1C, 1 }, // PciBridge + { 0x0, 0 }, // PciDevice + }, +}; + +PLATFORM_EXCEPTION_PCI_DEVICE_ID_STRUCT mExceptionPciDeviceIdList[] =3D { + { + { + EDKII_PLATFORM_VTD_EXCEPTION_DEVICE_INFO_TYPE_PCI_DEVICE_ID, + sizeof(PLATFORM_EXCEPTION_DEVICE_SCOPE_STRUCT) + }, // ExceptionDeviceInfo + { + 0x8086, // VendorId + 0x9D2F, // DeviceId + 0x21, // RevisionId + 0x8086, // SubsystemVe= ndorId + 0x7270, // SubsystemDe= viceId + }, }, }; =20 @@ -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 li= st of DeviceInfo. + Each DeviceInfo pointer points to EDKI= I_PLATFORM_VTD_EXCEPTION_DEVICE_INFO. =20 @retval EFI_SUCCESS The DeviceInfoCount and DeviceInfo are ret= urned. @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; } =20 - *DeviceInfo =3D AllocateZeroPool (sizeof(mExceptionDeviceList)); - if (*DeviceInfo =3D=3D NULL) { - return EFI_OUT_OF_RESOURCES; - } - CopyMem (*DeviceInfo, mExceptionDeviceList, sizeof(mExceptionDeviceList)= ); + if (0) { + *DeviceInfo =3D AllocateZeroPool (sizeof(mExceptionDeviceScopeList)); + if (*DeviceInfo =3D=3D NULL) { + return EFI_OUT_OF_RESOURCES; + } + CopyMem (*DeviceInfo, mExceptionDeviceScopeList, sizeof(mExceptionDevi= ceScopeList)); + + *DeviceInfoCount =3D ARRAY_SIZE(mExceptionDeviceScopeList); + } else { + *DeviceInfo =3D AllocateZeroPool (sizeof(mExceptionPciDeviceIdList)); + if (*DeviceInfo =3D=3D NULL) { + return EFI_OUT_OF_RESOURCES; + } + CopyMem (*DeviceInfo, mExceptionPciDeviceIdList, sizeof(mExceptionPciD= eviceIdList)); =20 - *DeviceInfoCount =3D ARRAY_SIZE(mExceptionDeviceList); + *DeviceInfoCount =3D ARRAY_SIZE(mExceptionPciDeviceIdList); + } =20 return EFI_SUCCESS; } --=20 2.7.4.windows.1 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel