From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) (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 5CE1580342 for ; Tue, 21 Mar 2017 18:38:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=intel.com; i=@intel.com; q=dns/txt; s=intel; t=1490146694; x=1521682694; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-transfer-encoding:mime-version; bh=yl1ogZpo7g4qExfgYpsCDRYFayr2nGC7RzQaeB0Epz0=; b=DEgKwvqrBi/pApiP6lKzi9Ac2wi6YYWZpmTr3jB1Xm/W9AVvU2omU7se PduXyET48dLuI2TVzR0MKVN2BaZgWQ==; Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga103.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 21 Mar 2017 18:38:13 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.36,202,1486454400"; d="scan'208";a="63427831" Received: from fmsmsx107.amr.corp.intel.com ([10.18.124.205]) by orsmga002.jf.intel.com with ESMTP; 21 Mar 2017 18:38:13 -0700 Received: from fmsmsx114.amr.corp.intel.com (10.18.116.8) by fmsmsx107.amr.corp.intel.com (10.18.124.205) with Microsoft SMTP Server (TLS) id 14.3.319.2; Tue, 21 Mar 2017 18:38:13 -0700 Received: from shsmsx104.ccr.corp.intel.com (10.239.4.70) by FMSMSX114.amr.corp.intel.com (10.18.116.8) with Microsoft SMTP Server (TLS) id 14.3.319.2; Tue, 21 Mar 2017 18:38:12 -0700 Received: from shsmsx101.ccr.corp.intel.com ([169.254.1.177]) by SHSMSX104.ccr.corp.intel.com ([10.239.4.70]) with mapi id 14.03.0248.002; Wed, 22 Mar 2017 09:38:10 +0800 From: "Wei, David" To: "Lu, ShifeiX A" , "edk2-devel@lists.01.org" CC: "Wei, David" Thread-Topic: [Patch][edk2-platforms/devel-MinnowBoard3] Add SSDT table tool. Thread-Index: AQHSoiWFhl6q5GCV/ESiUsEMnhuDnKGgFUjg Date: Wed, 22 Mar 2017 01:38:09 +0000 Message-ID: <89954A0B46707A448411A627AD4EEE3468F0721C@SHSMSX101.ccr.corp.intel.com> References: In-Reply-To: Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.239.127.40] MIME-Version: 1.0 Subject: Re: [Patch][edk2-platforms/devel-MinnowBoard3] Add SSDT table tool. 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: , X-List-Received-Date: Wed, 22 Mar 2017 01:38:14 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Reviewed-by: zwei4 Thanks, David Wei =20 -----Original Message----- From: Lu, ShifeiX A=20 Sent: Tuesday, March 21, 2017 5:28 PM To: edk2-devel@lists.01.org Cc: Wei, David Subject: [Patch][edk2-platforms/devel-MinnowBoard3] Add SSDT table tool. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: lushifex --- .../Common/Application/SsdtUpdate/SsdtUpdate.asl | 29 +++ .../Common/Application/SsdtUpdate/SsdtUpdate.c | 199 +++++++++++++++++= ++++ .../Common/Application/SsdtUpdate/SsdtUpdate.h | 38 ++++ .../Common/Application/SsdtUpdate/SsdtUpdate.inf | 62 +++++++ 4 files changed, 328 insertions(+) create mode 100644 Platform/BroxtonPlatformPkg/Common/Application/SsdtUpda= te/SsdtUpdate.asl create mode 100644 Platform/BroxtonPlatformPkg/Common/Application/SsdtUpda= te/SsdtUpdate.c create mode 100644 Platform/BroxtonPlatformPkg/Common/Application/SsdtUpda= te/SsdtUpdate.h create mode 100644 Platform/BroxtonPlatformPkg/Common/Application/SsdtUpda= te/SsdtUpdate.inf diff --git a/Platform/BroxtonPlatformPkg/Common/Application/SsdtUpdate/Ssdt= Update.asl b/Platform/BroxtonPlatformPkg/Common/Application/SsdtUpdate/Ssdt= Update.asl new file mode 100644 index 0000000..e5bd7e6 --- /dev/null +++ b/Platform/BroxtonPlatformPkg/Common/Application/SsdtUpdate/SsdtUpdate.= asl @@ -0,0 +1,29 @@ +/** @file + The definition block in ACPI table for Genernal device. + + Copyright (c) 2015 - 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. + +**/ + +DefinitionBlock ( + "Gene.aml", + "SSDT", + 2, + "INTEL ", + "GeneTabl", + 0x1000 + ) +{ + Scope (\_SB) + { + } +} + diff --git a/Platform/BroxtonPlatformPkg/Common/Application/SsdtUpdate/Ssdt= Update.c b/Platform/BroxtonPlatformPkg/Common/Application/SsdtUpdate/SsdtUp= date.c new file mode 100644 index 0000000..f63df95 --- /dev/null +++ b/Platform/BroxtonPlatformPkg/Common/Application/SsdtUpdate/SsdtUpdate.= c @@ -0,0 +1,199 @@ +/** @file + Update SSDT table to ACPI table. + + Copyright (c) 2013 - 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 "SsdtUpdate.h" + +FV_INPUT_DATA mInputData =3D {0}; + +/** + Read file data from given file name. + + @param[in] FileName Pointer the readed given file name. + @param[out] Buffer The buffer which read the given file name's = data. + @param[out] BufferSize The buffer size which read the given file na= me's data. + + @retval EFI_SUCCESS The file data is successfully readed. + @retval EFI_ERROR The file data is unsuccessfully readed. + +**/ +STATIC +EFI_STATUS +ReadFileData ( + IN CHAR16 *FileName, + OUT UINT8 **Buffer, + OUT UINT32 *BufferSize + ) +{ + EFI_STATUS Status; + SHELL_FILE_HANDLE FileHandle; + UINT64 Size; + VOID *NewBuffer; + UINTN ReadSize; + + FileHandle =3D NULL; + NewBuffer =3D NULL; + Size =3D 0; + + Status =3D ShellOpenFileByName (FileName, &FileHandle, EFI_FILE_MODE_REA= D, 0); + if (EFI_ERROR (Status)) { + goto Done; + } + + Status =3D FileHandleIsDirectory (FileHandle); + if (!EFI_ERROR (Status)) { + Status =3D EFI_NOT_FOUND; + goto Done; + } + + Status =3D FileHandleGetSize (FileHandle, &Size); + if (EFI_ERROR (Status)) { + goto Done; + } + + NewBuffer =3D AllocatePool ((UINTN) Size); + + ReadSize =3D (UINTN) Size; + Status =3D FileHandleRead (FileHandle, &ReadSize, NewBuffer); + if (EFI_ERROR (Status)) { + goto Done; + } else if (ReadSize !=3D (UINTN) Size) { + Status =3D EFI_INVALID_PARAMETER; + goto Done; + } + +Done: + if (FileHandle !=3D NULL) { + ShellCloseFile (&FileHandle); + } + + if (EFI_ERROR (Status)) { + if (NewBuffer !=3D NULL) { + FreePool (NewBuffer); + } + } else { + *Buffer =3D NewBuffer; + *BufferSize =3D (UINT32) Size; + } + + return Status; +} + + +/** + Initialize and publish device in ACPI table. + + @param[in] Table The pointer to the ACPI table which will be p= ublished. + @param[in] TableSize The size of ACPI table which will be publishe= d. + + @retval EFI_SUCCESS The ACPI table is published successfully. + @retval Others The ACPI table is not published. + +**/ +EFI_STATUS +PublishAcpiTable ( + IN UINT8 *Table, + IN UINT32 TableSize + ) +{ + EFI_STATUS Status; + EFI_ACPI_TABLE_PROTOCOL *AcpiTable; + UINTN TableKey; + + // + // Publish the ACPI table + // + Status =3D gBS->LocateProtocol (&gEfiAcpiTableProtocolGuid, NULL, (VOID = **) &AcpiTable); + DEBUG ((DEBUG_INFO, " Publish ACPI Table-3\n")); + ASSERT_EFI_ERROR (Status); + + TableKey =3D 0; + Status =3D AcpiTable->InstallAcpiTable ( + AcpiTable, + (EFI_ACPI_DESCRIPTION_HEADER *) Table, + TableSize, + &TableKey + ); + DEBUG ((DEBUG_INFO, " Publish ACPI Table-4\n")); + ASSERT_EFI_ERROR (Status); + + return Status; +} + + +/** + Init device + + @retval EFI_SUCCESS Init Devices successfully + @retval Others Some error occurs + +**/ +EFI_STATUS +InitDevice ( + ) +{ + // + // Add device Init here if needed + // + return EFI_SUCCESS; +} + + +/** + UEFI application entry point which has an interface similar to a + standard C main function. + + The ShellCEntryLib library instance wrappers the actual UEFI application + entry point and calls this ShellAppMain function. + + @param[in] Argc The number of items in Argv. + @param[in] Argv Array of pointers to strings. + + @retval Status + +**/ +INTN +EFIAPI + ShellAppMain ( + IN UINTN Argc, + IN CHAR16 **Argv + ) +{ + EFI_STATUS Status; + UINT8 *FileBuffer; + UINT32 TableSize; + + TableSize =3D 0; + FileBuffer =3D NULL; + + // + // Necessary device Initialization + // + Status =3D InitDevice (); + if (EFI_ERROR (Status)) { + return EFI_DEVICE_ERROR; + } + + StrCpy (mInputData.FileName, Argv[1]); + Status =3D ReadFileData (mInputData.FileName, &FileBuffer, &TableSize); + + // + // Update and publish ACPI table + // + Status =3D PublishAcpiTable (FileBuffer, TableSize); + ASSERT_EFI_ERROR (Status); + + return Status; +} + diff --git a/Platform/BroxtonPlatformPkg/Common/Application/SsdtUpdate/Ssdt= Update.h b/Platform/BroxtonPlatformPkg/Common/Application/SsdtUpdate/SsdtUp= date.h new file mode 100644 index 0000000..a3ca6d3 --- /dev/null +++ b/Platform/BroxtonPlatformPkg/Common/Application/SsdtUpdate/SsdtUpdate.= h @@ -0,0 +1,38 @@ +/** @file + The header file for update SSDT table to ACPI table. + + Copyright (c) 2015 - 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 +#include + +#define INPUT_STRING_LEN 255 +#define INPUT_STRING_SIZE (INPUT_STRING_LEN + 1) + +typedef struct { + BOOLEAN UpdateFromFile; + CHAR16 FileName[INPUT_STRING_SIZE]; +} FV_INPUT_DATA; + diff --git a/Platform/BroxtonPlatformPkg/Common/Application/SsdtUpdate/Ssdt= Update.inf b/Platform/BroxtonPlatformPkg/Common/Application/SsdtUpdate/Ssdt= Update.inf new file mode 100644 index 0000000..911dff3 --- /dev/null +++ b/Platform/BroxtonPlatformPkg/Common/Application/SsdtUpdate/SsdtUpdate.= inf @@ -0,0 +1,62 @@ +## @file +# This application add SSDT table into ACPI table. +# +# Copyright (c) 2015 - 2017, Intel Corporation. All rights reserved.
+# +# This program and the accompanying materials +# are licensed and made available under the terms and conditions of the B= SD 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 IM= PLIED. +# +## + +[Defines] + INF_VERSION =3D 0x00010005 + BASE_NAME =3D SsdtUpdate + FILE_GUID =3D 6527d4b8-8f0f-4c02-9e78-8338cb6f0875 + MODULE_TYPE =3D UEFI_APPLICATION + PI_SPECIFICATION_VERSION =3D 0x0001000A + VERSION_STRING =3D 1.0 + ENTRY_POINT =3D ShellCEntryLib + +[Sources] + SsdtUpdate.h + SsdtUpdate.c + SsdtUpdate.asl + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + ShellPkg/ShellPkg.dec + +[LibraryClasses] + BaseLib + BaseMemoryLib + UefiBootServicesTableLib + DebugLib + DxeServicesLib + UefiApplicationEntryPoint + FileHandleLib + ShellCEntryLib + ShellLib + UefiBootServicesTableLib + MemoryAllocationLib + +[Guids] + +[Protocols] + gEfiAcpiTableProtocolGuid # PROTOCOL ALWAYS_CONSUMED + +[Pcd] + gEfiMdeModulePkgTokenSpaceGuid.PcdAcpiDefaultOemId + gEfiMdeModulePkgTokenSpaceGuid.PcdAcpiDefaultOemTableId + gEfiMdeModulePkgTokenSpaceGuid.PcdAcpiDefaultOemRevision + gEfiMdeModulePkgTokenSpaceGuid.PcdAcpiDefaultCreatorId + gEfiMdeModulePkgTokenSpaceGuid.PcdAcpiDefaultCreatorRevision + +[Depex] + gEfiAcpiTableProtocolGuid + --=20 2.7.0.windows.1