From nobody Thu Dec 26 13:22:24 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 1505525999932817.121922943881; Fri, 15 Sep 2017 18:39:59 -0700 (PDT) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id D09252007D1EB; Fri, 15 Sep 2017 18:36:56 -0700 (PDT) Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) (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 AEE5920945B95 for ; Fri, 15 Sep 2017 18:36:54 -0700 (PDT) Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga101.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 15 Sep 2017 18:39:54 -0700 Received: from jyao1-mobl.ccr.corp.intel.com ([10.254.208.42]) by orsmga001.jf.intel.com with ESMTP; 15 Sep 2017 18:39:53 -0700 X-Original-To: edk2-devel@lists.01.org X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.42,400,1500966000"; d="scan'208";a="1172722612" From: Jiewen Yao To: edk2-devel@lists.01.org Date: Sat, 16 Sep 2017 09:39:41 +0800 Message-Id: <1505525983-27188-3-git-send-email-jiewen.yao@intel.com> X-Mailer: git-send-email 2.7.4.windows.1 In-Reply-To: <1505525983-27188-1-git-send-email-jiewen.yao@intel.com> References: <1505525983-27188-1-git-send-email-jiewen.yao@intel.com> Subject: [edk2] [PATCH 2/4] IntelSiliconPkg/PlatformVTdSampleDxe: Move to feature dir. 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" Move PlatformVTdSampleDxe to Feature/VTd/PlatformVTdSampleDxe. Suggested-by: Star Zeng Cc: Star Zeng Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Jiewen Yao --- IntelSiliconPkg/Feature/VTd/PlatformVTdSampleDxe/PlatformVTdSampleDxe.c = | 409 ++++++++++++++++++++ IntelSiliconPkg/Feature/VTd/PlatformVTdSampleDxe/PlatformVTdSampleDxe.inf = | 59 +++ IntelSiliconPkg/Feature/VTd/PlatformVTdSampleDxe/PlatformVTdSampleDxe.uni = | 20 + IntelSiliconPkg/Feature/VTd/PlatformVTdSampleDxe/PlatformVTdSampleDxeExtra= .uni | 20 + IntelSiliconPkg/IntelSiliconPkg.dsc = | 2 +- IntelSiliconPkg/PlatformVTdSampleDxe/PlatformVTdSampleDxe.c = | 409 -------------------- IntelSiliconPkg/PlatformVTdSampleDxe/PlatformVTdSampleDxe.inf = | 59 --- IntelSiliconPkg/PlatformVTdSampleDxe/PlatformVTdSampleDxe.uni = | 20 - IntelSiliconPkg/PlatformVTdSampleDxe/PlatformVTdSampleDxeExtra.uni = | 20 - 9 files changed, 509 insertions(+), 509 deletions(-) diff --git a/IntelSiliconPkg/Feature/VTd/PlatformVTdSampleDxe/PlatformVTdSa= mpleDxe.c b/IntelSiliconPkg/Feature/VTd/PlatformVTdSampleDxe/PlatformVTdSam= pleDxe.c new file mode 100644 index 0000000..3587fa3 --- /dev/null +++ b/IntelSiliconPkg/Feature/VTd/PlatformVTdSampleDxe/PlatformVTdSampleDxe= .c @@ -0,0 +1,409 @@ +/** @file + Platform VTd Sample driver. + + Copyright (c) 2017, Intel Corporation. All rights reserved.
+ This program and the accompanying materials + are licensed and made available under the terms and conditions of the BS= D License + which accompanies this distribution. The full text of the license may b= e found at + http://opensource.org/licenses/bsd-license.php + + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMP= LIED. + +**/ + +#include + +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include + +#include + +typedef struct { + ACPI_EXTENDED_HID_DEVICE_PATH I2cController; + UINT8 HidStr[8]; + UINT8 UidStr[1]; + UINT8 CidStr[8]; +} PLATFORM_I2C_CONTROLLER_DEVICE_PATH; + +typedef struct { + ACPI_EXTENDED_HID_DEVICE_PATH I2cDevice; + UINT8 HidStr[13]; + UINT8 UidStr[1]; + UINT8 CidStr[13]; +} PLATFORM_I2C_DEVICE_DEVICE_PATH; + +typedef struct { + PLATFORM_I2C_CONTROLLER_DEVICE_PATH I2cController; + PLATFORM_I2C_DEVICE_DEVICE_PATH I2cDevice; + EFI_DEVICE_PATH_PROTOCOL End; +} PLATFORM_I2C_DEVICE_PATH; + +typedef struct { + ACPI_HID_DEVICE_PATH PciRootBridge; + PCI_DEVICE_PATH PciDevice; + EFI_DEVICE_PATH_PROTOCOL EndDevicePath; +} PLATFORM_PCI_DEVICE_PATH; + +typedef struct { + ACPI_HID_DEVICE_PATH PciRootBridge; + PCI_DEVICE_PATH PciBridge; + PCI_DEVICE_PATH PciDevice; + EFI_DEVICE_PATH_PROTOCOL EndDevicePath; +} PLATFORM_PCI_BRIDGE_DEVICE_PATH; + +typedef struct { + EFI_DEVICE_PATH_PROTOCOL *DevicePath; + UINT16 Segment; + VTD_SOURCE_ID SourceId; +} PLATFORM_ACPI_DEVICE_MAPPING; + +#define PLATFORM_PCI_ROOT_BRIDGE \ + { \ + { \ + ACPI_DEVICE_PATH, \ + ACPI_DP, \ + { \ + (UINT8) (sizeof (ACPI_HID_DEVICE_PATH)), \ + (UINT8) ((sizeof (ACPI_HID_DEVICE_PATH)) >> 8) \ + }, \ + }, \ + EISA_PNP_ID (0x0A03), \ + 0 \ + } + +#define PLATFORM_END_ENTIRE \ + { \ + END_DEVICE_PATH_TYPE, END_ENTIRE_DEVICE_PATH_SUBTYPE, { END_DEVICE_PAT= H_LENGTH, 0 } \ + } + +#define PLATFORM_PCI(Device, Function) \ + { \ + { \ + HARDWARE_DEVICE_PATH, \ + HW_PCI_DP, \ + { \ + (UINT8) (sizeof (PCI_DEVICE_PATH)), \ + (UINT8) ((sizeof (PCI_DEVICE_PATH)) >> 8) \ + } \ + }, \ + (Function), \ + (Device) \ + } + +#define PLATFORM_I2C(Hid, Uid, Cid, HidStr, UidStr, CidStr) \ + { \ + { \ + { \ + ACPI_DEVICE_PATH, \ + ACPI_EXTENDED_DP, \ + {sizeof(ACPI_EXTENDED_HID_DEVICE_PATH) + sizeof(HidStr) + sizeof(U= idStr) + sizeof(CidStr), 0} \ + }, \ + Hid, \ + Uid, \ + Cid \ + }, \ + HidStr, \ + UidStr, \ + CidStr \ + } + +PLATFORM_I2C_DEVICE_PATH mPlatformI2CDevicePath =3D { + PLATFORM_I2C(0, 2, 0, "INT33C3", "", "INT33C3"), + PLATFORM_I2C(0, 1, 0, "I2C01\\TPANEL", "", "I2C01\\TPANEL"), + PLATFORM_END_ENTIRE +}; + +PLATFORM_ACPI_DEVICE_MAPPING mAcpiDeviceMapping[] =3D { + { + (EFI_DEVICE_PATH_PROTOCOL *)&mPlatformI2CDevicePath, + 0x0, // Segment + {{0x01, 0x15, 0x00}} // Function, Device, Bus + } +}; + +PLATFORM_PCI_BRIDGE_DEVICE_PATH mPlatformPciBridgeDevicePath =3D { + PLATFORM_PCI_ROOT_BRIDGE, + PLATFORM_PCI(0x1C, 1), + PLATFORM_PCI(0, 0), + PLATFORM_END_ENTIRE +}; + +#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 { + { + { + 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_PCI_DEVICE_ID_STRUCT) + }, // ExceptionDeviceInfo + { + 0x8086, // VendorId + 0x9D2F, // DeviceId + 0x21, // RevisionId + 0x8086, // SubsystemVe= ndorId + 0x7270, // SubsystemDe= viceId + }, + }, +}; + +/** + Compares 2 device path. + + @param[in] DevicePath1 A device path with EndDevicePath node. + @param[in] DevicePath2 A device path with EndDevicePath node. + + @retval TRUE 2 device path are identical. + @retval FALSE 2 device path are not identical. +**/ +BOOLEAN +CompareDevicePath ( + IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath1, + IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath2 + ) +{ + UINTN Size1; + UINTN Size2; + + Size1 =3D GetDevicePathSize (DevicePath1); + Size2 =3D GetDevicePathSize (DevicePath2); + if (Size1 !=3D Size2) { + return FALSE; + } + if (CompareMem (DevicePath1, DevicePath2, Size1) !=3D 0) { + return FALSE; + } + return TRUE; +} + +/** + Get the VTD SourceId from the device handler. + This function is required for non PCI device handler. + + Pseudo-algo in Intel VTd driver: + Status =3D PlatformGetVTdDeviceId (); + if (EFI_ERROR(Status)) { + if (DeviceHandle is PCI) { + Get SourceId from Bus/Device/Function + } else { + return EFI_UNSUPPORTED + } + } + Get VTd engine by Segment/Bus/Device/Function. + + @param[in] This The protocol instance pointer. + @param[in] DeviceHandle Device Identifier in UEFI. + @param[out] DeviceInfo DeviceInfo for indentify the VTd engin= e in ACPI Table + and the VTd page entry. + + @retval EFI_SUCCESS The VtdIndex and SourceId are returned. + @retval EFI_INVALID_PARAMETER DeviceHandle is not a valid handler. + @retval EFI_INVALID_PARAMETER DeviceInfo is NULL. + @retval EFI_NOT_FOUND The Segment or SourceId information is NOT= found. + @retval EFI_UNSUPPORTED This function is not supported. + +**/ +EFI_STATUS +EFIAPI +PlatformVTdGetDeviceId ( + IN EDKII_PLATFORM_VTD_POLICY_PROTOCOL *This, + IN EFI_HANDLE DeviceHandle, + OUT EDKII_PLATFORM_VTD_DEVICE_INFO *DeviceInfo + ) +{ + EFI_PCI_IO_PROTOCOL *PciIo; + UINTN Seg; + UINTN Bus; + UINTN Dev; + UINTN Func; + EFI_STATUS Status; + EFI_DEVICE_PATH_PROTOCOL *DevicePath; + UINTN Index; + + DEBUG ((DEBUG_VERBOSE, "PlatformVTdGetDeviceId\n")); + + if (DeviceInfo =3D=3D NULL) { + return EFI_INVALID_PARAMETER; + } + + if (DeviceHandle =3D=3D NULL) { + return EFI_INVALID_PARAMETER; + } + + // + // Handle PCI device + // + Status =3D gBS->HandleProtocol (DeviceHandle, &gEfiPciIoProtocolGuid, (V= OID **)&PciIo); + if (!EFI_ERROR(Status)) { + Status =3D PciIo->GetLocation (PciIo, &Seg, &Bus, &Dev, &Func); + if (EFI_ERROR(Status)) { + return EFI_UNSUPPORTED; + } + DeviceInfo->Segment =3D (UINT16)Seg; + DeviceInfo->SourceId.Bits.Bus =3D (UINT8)Bus; + DeviceInfo->SourceId.Bits.Device =3D (UINT8)Dev; + DeviceInfo->SourceId.Bits.Function =3D (UINT8)Func; + + return EFI_SUCCESS; + } + + // + // Handle ACPI device + // + Status =3D gBS->HandleProtocol (DeviceHandle, &gEfiDevicePathProtocolGui= d, (VOID **)&DevicePath); + if (!EFI_ERROR(Status)) { + for (Index =3D 0; Index < ARRAY_SIZE(mAcpiDeviceMapping); Index++) { + if (CompareDevicePath (mAcpiDeviceMapping[Index].DevicePath, DeviceP= ath)) { + DeviceInfo->Segment =3D mAcpiDeviceMapping[Index].Segment; + DeviceInfo->SourceId =3D mAcpiDeviceMapping[Index].SourceId; + return EFI_SUCCESS; + } + } + } + + return EFI_NOT_FOUND; +} + +/** + Get a list of the exception devices. + + The VTd driver should always set ALLOW for the device in this list. + + @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. + + @retval EFI_SUCCESS The DeviceInfoCount and DeviceInfo are ret= urned. + @retval EFI_INVALID_PARAMETER DeviceInfoCount is NULL, or DeviceInfo is = NULL. + @retval EFI_UNSUPPORTED This function is not supported. + +**/ +EFI_STATUS +EFIAPI +PlatformVTdGetExceptionDeviceList ( + IN EDKII_PLATFORM_VTD_POLICY_PROTOCOL *This, + OUT UINTN *DeviceInfoCount, + OUT VOID **DeviceInfo + ) +{ + DEBUG ((DEBUG_VERBOSE, "PlatformVTdGetExceptionDeviceList\n")); + + if (DeviceInfoCount =3D=3D NULL || DeviceInfo =3D=3D NULL) { + return EFI_INVALID_PARAMETER; + } + + // + // Sample codes for device scope based exception list. + // Uncomment to take affect and comment the sample codes for PCI vendor = id + // based exception list. + // + /* + *DeviceInfo =3D AllocateZeroPool (sizeof(mExceptionDeviceScopeList)); + if (*DeviceInfo =3D=3D NULL) { + return EFI_OUT_OF_RESOURCES; + } + CopyMem (*DeviceInfo, mExceptionDeviceScopeList, sizeof(mExceptionDevice= ScopeList)); + + *DeviceInfoCount =3D ARRAY_SIZE(mExceptionDeviceScopeList); + */ + + // + // Sample codes for PCI vendor id based exception list. + // Uncomment to take affect and comment the sample codes for device scope + // based exception list. + // + *DeviceInfo =3D AllocateZeroPool (sizeof(mExceptionPciDeviceIdList)); + if (*DeviceInfo =3D=3D NULL) { + return EFI_OUT_OF_RESOURCES; + } + CopyMem (*DeviceInfo, mExceptionPciDeviceIdList, sizeof(mExceptionPciDev= iceIdList)); + + *DeviceInfoCount =3D ARRAY_SIZE(mExceptionPciDeviceIdList); + + return EFI_SUCCESS; +} + +EDKII_PLATFORM_VTD_POLICY_PROTOCOL mPlatformVTdSample =3D { + EDKII_PLATFORM_VTD_POLICY_PROTOCOL_REVISION, + PlatformVTdGetDeviceId, + PlatformVTdGetExceptionDeviceList, +}; + +/** + Platform VTd sample driver. + + @param[in] ImageHandle ImageHandle of the loaded driver + @param[in] SystemTable Pointer to the System Table + + @retval EFI_SUCCESS The Protocol is installed. + @retval EFI_OUT_OF_RESOURCES Not enough resources available to initial= ize driver. + @retval EFI_DEVICE_ERROR A device error occurred attempting to ini= tialize the driver. + +**/ +EFI_STATUS +EFIAPI +PlatformVTdSampleInitialize ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + EFI_HANDLE Handle; + + Handle =3D NULL; + Status =3D gBS->InstallMultipleProtocolInterfaces ( + &Handle, + &gEdkiiPlatformVTdPolicyProtocolGuid, &mPlatformVTdSampl= e, + NULL + ); + ASSERT_EFI_ERROR (Status); + + return Status; +} diff --git a/IntelSiliconPkg/Feature/VTd/PlatformVTdSampleDxe/PlatformVTdSa= mpleDxe.inf b/IntelSiliconPkg/Feature/VTd/PlatformVTdSampleDxe/PlatformVTdS= ampleDxe.inf new file mode 100644 index 0000000..9895bc2 --- /dev/null +++ b/IntelSiliconPkg/Feature/VTd/PlatformVTdSampleDxe/PlatformVTdSampleDxe= .inf @@ -0,0 +1,59 @@ +## @file +# Platform VTd Sample driver. +# +# Copyright (c) 2017, Intel Corporation. All rights reserved.
+# This program and the accompanying materials +# are licensed and made available under the terms and conditions of the BS= D License +# which accompanies this distribution. The full text of the license may b= e found at +# http://opensource.org/licenses/bsd-license.php +# +# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMP= LIED. +# +## + +[Defines] + INF_VERSION =3D 0x00010005 + BASE_NAME =3D PlatformVTdSampleDxe + MODULE_UNI_FILE =3D PlatformVTdSampleDxe.uni + FILE_GUID =3D 5DFAE03E-9C19-4996-85BF-65297BD4137F + MODULE_TYPE =3D DXE_DRIVER + VERSION_STRING =3D 1.0 + ENTRY_POINT =3D PlatformVTdSampleInitialize + +# +# The following information is for reference only and not required by the = build tools. +# +# VALID_ARCHITECTURES =3D IA32 X64 IPF EBC +# +# + +[Sources] + PlatformVTdSampleDxe.c + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + IntelSiliconPkg/IntelSiliconPkg.dec + +[LibraryClasses] + DebugLib + UefiDriverEntryPoint + UefiBootServicesTableLib + BaseLib + IoLib + PciSegmentLib + BaseMemoryLib + MemoryAllocationLib + DevicePathLib + +[Protocols] + gEdkiiPlatformVTdPolicyProtocolGuid ## PRODUCES + gEfiPciIoProtocolGuid ## CONSUMES + +[Depex] + gEfiPciRootBridgeIoProtocolGuid + +[UserExtensions.TianoCore."ExtraFiles"] + PlatformVTdSampleDxeExtra.uni + diff --git a/IntelSiliconPkg/Feature/VTd/PlatformVTdSampleDxe/PlatformVTdSa= mpleDxe.uni b/IntelSiliconPkg/Feature/VTd/PlatformVTdSampleDxe/PlatformVTdS= ampleDxe.uni new file mode 100644 index 0000000..231b98d --- /dev/null +++ b/IntelSiliconPkg/Feature/VTd/PlatformVTdSampleDxe/PlatformVTdSampleDxe= .uni @@ -0,0 +1,20 @@ +// /** @file +// PlatformVTdSampleDxe Module Localized Abstract and Description Content +// +// Copyright (c) 2017, Intel Corporation. All rights reserved.
+// +// This program and the accompanying materials are +// licensed and made available under the terms and conditions of the BSD L= icense +// which accompanies this distribution. The full text of the license may = be found at +// http://opensource.org/licenses/bsd-license.php +// +// THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +// WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IM= PLIED. +// +// **/ + + +#string STR_MODULE_ABSTRACT #language en-US "Platform VTd Samp= le DXE Driver." + +#string STR_MODULE_DESCRIPTION #language en-US "This driver provi= des sample on how to produce Platform VTd policy protocol." + diff --git a/IntelSiliconPkg/Feature/VTd/PlatformVTdSampleDxe/PlatformVTdSa= mpleDxeExtra.uni b/IntelSiliconPkg/Feature/VTd/PlatformVTdSampleDxe/Platfor= mVTdSampleDxeExtra.uni new file mode 100644 index 0000000..fd29c26 --- /dev/null +++ b/IntelSiliconPkg/Feature/VTd/PlatformVTdSampleDxe/PlatformVTdSampleDxe= Extra.uni @@ -0,0 +1,20 @@ +// /** @file +// PlatformVTdSampleDxe Localized Strings and Content +// +// Copyright (c) 2017, Intel Corporation. All rights reserved.
+// +// This program and the accompanying materials are +// licensed and made available under the terms and conditions of the BSD L= icense +// which accompanies this distribution. The full text of the license may = be found at +// http://opensource.org/licenses/bsd-license.php +// +// THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +// WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IM= PLIED. +// +// **/ + +#string STR_PROPERTIES_MODULE_NAME +#language en-US +"Platform VTd Sample DXE Driver" + + diff --git a/IntelSiliconPkg/IntelSiliconPkg.dsc b/IntelSiliconPkg/IntelSil= iconPkg.dsc index 3b23800..091aea7 100644 --- a/IntelSiliconPkg/IntelSiliconPkg.dsc +++ b/IntelSiliconPkg/IntelSiliconPkg.dsc @@ -81,7 +81,7 @@ IntelSiliconPkg/Library/DxeSmbiosDataHobLib/DxeSmbiosDataHobLib.inf IntelSiliconPkg/Feature/VTd/IntelVTdDxe/IntelVTdDxe.inf IntelSiliconPkg/IntelVTdPmrPei/IntelVTdPmrPei.inf - IntelSiliconPkg/PlatformVTdSampleDxe/PlatformVTdSampleDxe.inf + IntelSiliconPkg/Feature/VTd/PlatformVTdSampleDxe/PlatformVTdSampleDxe.inf IntelSiliconPkg/PlatformVTdInfoSamplePei/PlatformVTdInfoSamplePei.inf =20 [BuildOptions] diff --git a/IntelSiliconPkg/PlatformVTdSampleDxe/PlatformVTdSampleDxe.c b/= IntelSiliconPkg/PlatformVTdSampleDxe/PlatformVTdSampleDxe.c deleted file mode 100644 index 3587fa3..0000000 --- a/IntelSiliconPkg/PlatformVTdSampleDxe/PlatformVTdSampleDxe.c +++ /dev/null @@ -1,409 +0,0 @@ -/** @file - Platform VTd Sample driver. - - Copyright (c) 2017, Intel Corporation. All rights reserved.
- This program and the accompanying materials - are licensed and made available under the terms and conditions of the BS= D License - which accompanies this distribution. The full text of the license may b= e found at - http://opensource.org/licenses/bsd-license.php - - THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, - WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMP= LIED. - -**/ - -#include - -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include - -#include - -typedef struct { - ACPI_EXTENDED_HID_DEVICE_PATH I2cController; - UINT8 HidStr[8]; - UINT8 UidStr[1]; - UINT8 CidStr[8]; -} PLATFORM_I2C_CONTROLLER_DEVICE_PATH; - -typedef struct { - ACPI_EXTENDED_HID_DEVICE_PATH I2cDevice; - UINT8 HidStr[13]; - UINT8 UidStr[1]; - UINT8 CidStr[13]; -} PLATFORM_I2C_DEVICE_DEVICE_PATH; - -typedef struct { - PLATFORM_I2C_CONTROLLER_DEVICE_PATH I2cController; - PLATFORM_I2C_DEVICE_DEVICE_PATH I2cDevice; - EFI_DEVICE_PATH_PROTOCOL End; -} PLATFORM_I2C_DEVICE_PATH; - -typedef struct { - ACPI_HID_DEVICE_PATH PciRootBridge; - PCI_DEVICE_PATH PciDevice; - EFI_DEVICE_PATH_PROTOCOL EndDevicePath; -} PLATFORM_PCI_DEVICE_PATH; - -typedef struct { - ACPI_HID_DEVICE_PATH PciRootBridge; - PCI_DEVICE_PATH PciBridge; - PCI_DEVICE_PATH PciDevice; - EFI_DEVICE_PATH_PROTOCOL EndDevicePath; -} PLATFORM_PCI_BRIDGE_DEVICE_PATH; - -typedef struct { - EFI_DEVICE_PATH_PROTOCOL *DevicePath; - UINT16 Segment; - VTD_SOURCE_ID SourceId; -} PLATFORM_ACPI_DEVICE_MAPPING; - -#define PLATFORM_PCI_ROOT_BRIDGE \ - { \ - { \ - ACPI_DEVICE_PATH, \ - ACPI_DP, \ - { \ - (UINT8) (sizeof (ACPI_HID_DEVICE_PATH)), \ - (UINT8) ((sizeof (ACPI_HID_DEVICE_PATH)) >> 8) \ - }, \ - }, \ - EISA_PNP_ID (0x0A03), \ - 0 \ - } - -#define PLATFORM_END_ENTIRE \ - { \ - END_DEVICE_PATH_TYPE, END_ENTIRE_DEVICE_PATH_SUBTYPE, { END_DEVICE_PAT= H_LENGTH, 0 } \ - } - -#define PLATFORM_PCI(Device, Function) \ - { \ - { \ - HARDWARE_DEVICE_PATH, \ - HW_PCI_DP, \ - { \ - (UINT8) (sizeof (PCI_DEVICE_PATH)), \ - (UINT8) ((sizeof (PCI_DEVICE_PATH)) >> 8) \ - } \ - }, \ - (Function), \ - (Device) \ - } - -#define PLATFORM_I2C(Hid, Uid, Cid, HidStr, UidStr, CidStr) \ - { \ - { \ - { \ - ACPI_DEVICE_PATH, \ - ACPI_EXTENDED_DP, \ - {sizeof(ACPI_EXTENDED_HID_DEVICE_PATH) + sizeof(HidStr) + sizeof(U= idStr) + sizeof(CidStr), 0} \ - }, \ - Hid, \ - Uid, \ - Cid \ - }, \ - HidStr, \ - UidStr, \ - CidStr \ - } - -PLATFORM_I2C_DEVICE_PATH mPlatformI2CDevicePath =3D { - PLATFORM_I2C(0, 2, 0, "INT33C3", "", "INT33C3"), - PLATFORM_I2C(0, 1, 0, "I2C01\\TPANEL", "", "I2C01\\TPANEL"), - PLATFORM_END_ENTIRE -}; - -PLATFORM_ACPI_DEVICE_MAPPING mAcpiDeviceMapping[] =3D { - { - (EFI_DEVICE_PATH_PROTOCOL *)&mPlatformI2CDevicePath, - 0x0, // Segment - {{0x01, 0x15, 0x00}} // Function, Device, Bus - } -}; - -PLATFORM_PCI_BRIDGE_DEVICE_PATH mPlatformPciBridgeDevicePath =3D { - PLATFORM_PCI_ROOT_BRIDGE, - PLATFORM_PCI(0x1C, 1), - PLATFORM_PCI(0, 0), - PLATFORM_END_ENTIRE -}; - -#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 { - { - { - 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_PCI_DEVICE_ID_STRUCT) - }, // ExceptionDeviceInfo - { - 0x8086, // VendorId - 0x9D2F, // DeviceId - 0x21, // RevisionId - 0x8086, // SubsystemVe= ndorId - 0x7270, // SubsystemDe= viceId - }, - }, -}; - -/** - Compares 2 device path. - - @param[in] DevicePath1 A device path with EndDevicePath node. - @param[in] DevicePath2 A device path with EndDevicePath node. - - @retval TRUE 2 device path are identical. - @retval FALSE 2 device path are not identical. -**/ -BOOLEAN -CompareDevicePath ( - IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath1, - IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath2 - ) -{ - UINTN Size1; - UINTN Size2; - - Size1 =3D GetDevicePathSize (DevicePath1); - Size2 =3D GetDevicePathSize (DevicePath2); - if (Size1 !=3D Size2) { - return FALSE; - } - if (CompareMem (DevicePath1, DevicePath2, Size1) !=3D 0) { - return FALSE; - } - return TRUE; -} - -/** - Get the VTD SourceId from the device handler. - This function is required for non PCI device handler. - - Pseudo-algo in Intel VTd driver: - Status =3D PlatformGetVTdDeviceId (); - if (EFI_ERROR(Status)) { - if (DeviceHandle is PCI) { - Get SourceId from Bus/Device/Function - } else { - return EFI_UNSUPPORTED - } - } - Get VTd engine by Segment/Bus/Device/Function. - - @param[in] This The protocol instance pointer. - @param[in] DeviceHandle Device Identifier in UEFI. - @param[out] DeviceInfo DeviceInfo for indentify the VTd engin= e in ACPI Table - and the VTd page entry. - - @retval EFI_SUCCESS The VtdIndex and SourceId are returned. - @retval EFI_INVALID_PARAMETER DeviceHandle is not a valid handler. - @retval EFI_INVALID_PARAMETER DeviceInfo is NULL. - @retval EFI_NOT_FOUND The Segment or SourceId information is NOT= found. - @retval EFI_UNSUPPORTED This function is not supported. - -**/ -EFI_STATUS -EFIAPI -PlatformVTdGetDeviceId ( - IN EDKII_PLATFORM_VTD_POLICY_PROTOCOL *This, - IN EFI_HANDLE DeviceHandle, - OUT EDKII_PLATFORM_VTD_DEVICE_INFO *DeviceInfo - ) -{ - EFI_PCI_IO_PROTOCOL *PciIo; - UINTN Seg; - UINTN Bus; - UINTN Dev; - UINTN Func; - EFI_STATUS Status; - EFI_DEVICE_PATH_PROTOCOL *DevicePath; - UINTN Index; - - DEBUG ((DEBUG_VERBOSE, "PlatformVTdGetDeviceId\n")); - - if (DeviceInfo =3D=3D NULL) { - return EFI_INVALID_PARAMETER; - } - - if (DeviceHandle =3D=3D NULL) { - return EFI_INVALID_PARAMETER; - } - - // - // Handle PCI device - // - Status =3D gBS->HandleProtocol (DeviceHandle, &gEfiPciIoProtocolGuid, (V= OID **)&PciIo); - if (!EFI_ERROR(Status)) { - Status =3D PciIo->GetLocation (PciIo, &Seg, &Bus, &Dev, &Func); - if (EFI_ERROR(Status)) { - return EFI_UNSUPPORTED; - } - DeviceInfo->Segment =3D (UINT16)Seg; - DeviceInfo->SourceId.Bits.Bus =3D (UINT8)Bus; - DeviceInfo->SourceId.Bits.Device =3D (UINT8)Dev; - DeviceInfo->SourceId.Bits.Function =3D (UINT8)Func; - - return EFI_SUCCESS; - } - - // - // Handle ACPI device - // - Status =3D gBS->HandleProtocol (DeviceHandle, &gEfiDevicePathProtocolGui= d, (VOID **)&DevicePath); - if (!EFI_ERROR(Status)) { - for (Index =3D 0; Index < ARRAY_SIZE(mAcpiDeviceMapping); Index++) { - if (CompareDevicePath (mAcpiDeviceMapping[Index].DevicePath, DeviceP= ath)) { - DeviceInfo->Segment =3D mAcpiDeviceMapping[Index].Segment; - DeviceInfo->SourceId =3D mAcpiDeviceMapping[Index].SourceId; - return EFI_SUCCESS; - } - } - } - - return EFI_NOT_FOUND; -} - -/** - Get a list of the exception devices. - - The VTd driver should always set ALLOW for the device in this list. - - @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. - - @retval EFI_SUCCESS The DeviceInfoCount and DeviceInfo are ret= urned. - @retval EFI_INVALID_PARAMETER DeviceInfoCount is NULL, or DeviceInfo is = NULL. - @retval EFI_UNSUPPORTED This function is not supported. - -**/ -EFI_STATUS -EFIAPI -PlatformVTdGetExceptionDeviceList ( - IN EDKII_PLATFORM_VTD_POLICY_PROTOCOL *This, - OUT UINTN *DeviceInfoCount, - OUT VOID **DeviceInfo - ) -{ - DEBUG ((DEBUG_VERBOSE, "PlatformVTdGetExceptionDeviceList\n")); - - if (DeviceInfoCount =3D=3D NULL || DeviceInfo =3D=3D NULL) { - return EFI_INVALID_PARAMETER; - } - - // - // Sample codes for device scope based exception list. - // Uncomment to take affect and comment the sample codes for PCI vendor = id - // based exception list. - // - /* - *DeviceInfo =3D AllocateZeroPool (sizeof(mExceptionDeviceScopeList)); - if (*DeviceInfo =3D=3D NULL) { - return EFI_OUT_OF_RESOURCES; - } - CopyMem (*DeviceInfo, mExceptionDeviceScopeList, sizeof(mExceptionDevice= ScopeList)); - - *DeviceInfoCount =3D ARRAY_SIZE(mExceptionDeviceScopeList); - */ - - // - // Sample codes for PCI vendor id based exception list. - // Uncomment to take affect and comment the sample codes for device scope - // based exception list. - // - *DeviceInfo =3D AllocateZeroPool (sizeof(mExceptionPciDeviceIdList)); - if (*DeviceInfo =3D=3D NULL) { - return EFI_OUT_OF_RESOURCES; - } - CopyMem (*DeviceInfo, mExceptionPciDeviceIdList, sizeof(mExceptionPciDev= iceIdList)); - - *DeviceInfoCount =3D ARRAY_SIZE(mExceptionPciDeviceIdList); - - return EFI_SUCCESS; -} - -EDKII_PLATFORM_VTD_POLICY_PROTOCOL mPlatformVTdSample =3D { - EDKII_PLATFORM_VTD_POLICY_PROTOCOL_REVISION, - PlatformVTdGetDeviceId, - PlatformVTdGetExceptionDeviceList, -}; - -/** - Platform VTd sample driver. - - @param[in] ImageHandle ImageHandle of the loaded driver - @param[in] SystemTable Pointer to the System Table - - @retval EFI_SUCCESS The Protocol is installed. - @retval EFI_OUT_OF_RESOURCES Not enough resources available to initial= ize driver. - @retval EFI_DEVICE_ERROR A device error occurred attempting to ini= tialize the driver. - -**/ -EFI_STATUS -EFIAPI -PlatformVTdSampleInitialize ( - IN EFI_HANDLE ImageHandle, - IN EFI_SYSTEM_TABLE *SystemTable - ) -{ - EFI_STATUS Status; - EFI_HANDLE Handle; - - Handle =3D NULL; - Status =3D gBS->InstallMultipleProtocolInterfaces ( - &Handle, - &gEdkiiPlatformVTdPolicyProtocolGuid, &mPlatformVTdSampl= e, - NULL - ); - ASSERT_EFI_ERROR (Status); - - return Status; -} diff --git a/IntelSiliconPkg/PlatformVTdSampleDxe/PlatformVTdSampleDxe.inf = b/IntelSiliconPkg/PlatformVTdSampleDxe/PlatformVTdSampleDxe.inf deleted file mode 100644 index 9895bc2..0000000 --- a/IntelSiliconPkg/PlatformVTdSampleDxe/PlatformVTdSampleDxe.inf +++ /dev/null @@ -1,59 +0,0 @@ -## @file -# Platform VTd Sample driver. -# -# Copyright (c) 2017, Intel Corporation. All rights reserved.
-# This program and the accompanying materials -# are licensed and made available under the terms and conditions of the BS= D License -# which accompanies this distribution. The full text of the license may b= e found at -# http://opensource.org/licenses/bsd-license.php -# -# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMP= LIED. -# -## - -[Defines] - INF_VERSION =3D 0x00010005 - BASE_NAME =3D PlatformVTdSampleDxe - MODULE_UNI_FILE =3D PlatformVTdSampleDxe.uni - FILE_GUID =3D 5DFAE03E-9C19-4996-85BF-65297BD4137F - MODULE_TYPE =3D DXE_DRIVER - VERSION_STRING =3D 1.0 - ENTRY_POINT =3D PlatformVTdSampleInitialize - -# -# The following information is for reference only and not required by the = build tools. -# -# VALID_ARCHITECTURES =3D IA32 X64 IPF EBC -# -# - -[Sources] - PlatformVTdSampleDxe.c - -[Packages] - MdePkg/MdePkg.dec - MdeModulePkg/MdeModulePkg.dec - IntelSiliconPkg/IntelSiliconPkg.dec - -[LibraryClasses] - DebugLib - UefiDriverEntryPoint - UefiBootServicesTableLib - BaseLib - IoLib - PciSegmentLib - BaseMemoryLib - MemoryAllocationLib - DevicePathLib - -[Protocols] - gEdkiiPlatformVTdPolicyProtocolGuid ## PRODUCES - gEfiPciIoProtocolGuid ## CONSUMES - -[Depex] - gEfiPciRootBridgeIoProtocolGuid - -[UserExtensions.TianoCore."ExtraFiles"] - PlatformVTdSampleDxeExtra.uni - diff --git a/IntelSiliconPkg/PlatformVTdSampleDxe/PlatformVTdSampleDxe.uni = b/IntelSiliconPkg/PlatformVTdSampleDxe/PlatformVTdSampleDxe.uni deleted file mode 100644 index 231b98d..0000000 --- a/IntelSiliconPkg/PlatformVTdSampleDxe/PlatformVTdSampleDxe.uni +++ /dev/null @@ -1,20 +0,0 @@ -// /** @file -// PlatformVTdSampleDxe Module Localized Abstract and Description Content -// -// Copyright (c) 2017, Intel Corporation. All rights reserved.
-// -// This program and the accompanying materials are -// licensed and made available under the terms and conditions of the BSD L= icense -// which accompanies this distribution. The full text of the license may = be found at -// http://opensource.org/licenses/bsd-license.php -// -// THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -// WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IM= PLIED. -// -// **/ - - -#string STR_MODULE_ABSTRACT #language en-US "Platform VTd Samp= le DXE Driver." - -#string STR_MODULE_DESCRIPTION #language en-US "This driver provi= des sample on how to produce Platform VTd policy protocol." - diff --git a/IntelSiliconPkg/PlatformVTdSampleDxe/PlatformVTdSampleDxeExtra= .uni b/IntelSiliconPkg/PlatformVTdSampleDxe/PlatformVTdSampleDxeExtra.uni deleted file mode 100644 index fd29c26..0000000 --- a/IntelSiliconPkg/PlatformVTdSampleDxe/PlatformVTdSampleDxeExtra.uni +++ /dev/null @@ -1,20 +0,0 @@ -// /** @file -// PlatformVTdSampleDxe Localized Strings and Content -// -// Copyright (c) 2017, Intel Corporation. All rights reserved.
-// -// This program and the accompanying materials are -// licensed and made available under the terms and conditions of the BSD L= icense -// which accompanies this distribution. The full text of the license may = be found at -// http://opensource.org/licenses/bsd-license.php -// -// THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -// WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IM= PLIED. -// -// **/ - -#string STR_PROPERTIES_MODULE_NAME -#language en-US -"Platform VTd Sample DXE Driver" - - --=20 2.7.4.windows.1 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel