From nobody Fri Apr 26 14:17:13 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+60064+1787277+3901457@groups.io; arc=fail (BodyHash is different from the expected one) Received: from web01.groups.io (web01.groups.io [66.175.222.12]) by mx.zohomail.com with SMTPS id 1590086697707198.70747118098927; Thu, 21 May 2020 11:44:57 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id XiaPYY1788612x1UHKDm2M7G; Thu, 21 May 2020 11:44:57 -0700 X-Received: from EUR05-VI1-obe.outbound.protection.outlook.com (EUR05-VI1-obe.outbound.protection.outlook.com [40.107.21.76]) by mx.groups.io with SMTP id smtpd.web10.1868.1590086696223118874 for ; Thu, 21 May 2020 11:44:56 -0700 X-Received: from MR2P264CA0120.FRAP264.PROD.OUTLOOK.COM (2603:10a6:500:33::36) by VI1PR08MB3183.eurprd08.prod.outlook.com (2603:10a6:803:47::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3000.26; Thu, 21 May 2020 18:44:52 +0000 X-Received: from VE1EUR03FT019.eop-EUR03.prod.protection.outlook.com (2603:10a6:500:33:cafe::9d) by MR2P264CA0120.outlook.office365.com (2603:10a6:500:33::36) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3021.27 via Frontend Transport; Thu, 21 May 2020 18:44:52 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 63.35.35.123) smtp.mailfrom=arm.com; edk2.groups.io; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com;edk2.groups.io; dmarc=bestguesspass action=none header.from=arm.com; Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) client-ip=66.175.222.12; envelope-from=bounce+27952+60064+1787277+3901457@groups.io; helo=web01.groups.io; Received-SPF: Pass (protection.outlook.com: domain of arm.com designates 63.35.35.123 as permitted sender) receiver=protection.outlook.com; client-ip=63.35.35.123; helo=64aa7808-outbound-1.mta.getcheckrecipient.com; X-Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by VE1EUR03FT019.mail.protection.outlook.com (10.152.18.153) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3021.23 via Frontend Transport; Thu, 21 May 2020 18:44:52 +0000 X-Received: ("Tessian outbound 952576a3272a:v57"); Thu, 21 May 2020 18:44:52 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 4c49eb7882b58d66 X-CR-MTA-TID: 64aa7808 X-Received: from 0e67d6aac01d.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 04C119B7-50C1-4803-879A-C697A546D80F.1; Thu, 21 May 2020 18:44:46 +0000 X-Received: from EUR02-AM5-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 0e67d6aac01d.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Thu, 21 May 2020 18:44:46 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=QuFewtoi3Fo/C08sC+Zi85DEsse2EG8R2Lhfc9zHXDWfbTajYK+dRFrzX87ZDk8chjoPh99/FzORyH/u6nqOeGsULSlnWfrzTTZpqhfdEiCYmFWra3/Ky2z3a/6tSJpg6apErpITKK+0MRxzMTKTTNAgOXsu+khcHd7bCTHfBqeQljy7OpVtJmJrhHUmR+LRljgEpMvPzCE/WbnYlyZvRtd+3iNc3oDuiSqbNumaui5BigVn+leUngqscAdIub0tQiMuuDoM3kSF56fKBvZJr7OuZlv14tVBw1VR8JiM3KI+QsCKWCD9b2HTlRfIYKZOeo1Tkqoiqhwbzda2z0tH+g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=v/pAtIlC74SckcZc9mc6zSB+vQG7h0e+j0ViZMtymW0=; b=CGMNiFPno7lLK+SNoOWnOc/HBK0iRFanMK/Y5uhT3s3r8tsDM9fg9iUGQI6Yv5mUvVMgexCxojCBWE5UvyO9UfqlhZUIwSH/4JkIpIbR6x5lbMMgsJ5zjDs/nz9RvWp3N0Tqsn1pzC5wQwQme2SqiE1rgql9EonmHB0Hxmhoy7rClOAUx/+vH0BefMSA8FcchwbVvQkZIk+DnedphjJdRA2ljmmqubG6VfjglH2gZxfBWuG5dKXnPEwOk6uWpnU3QiUN/z9OfRa3WQ4gqg5Pl241ctAoRi8LqNinvwSEHpaYnFNB8eAi2CNLd38jj0vWajOMhFwYhWox7zKDrfeKNA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 40.67.248.234) smtp.rcpttodomain=edk2.groups.io smtp.mailfrom=arm.com; dmarc=bestguesspass action=none header.from=arm.com; dkim=none (message not signed); arc=none X-Received: from AM3PR05CA0154.eurprd05.prod.outlook.com (2603:10a6:207:3::32) by DB6PR08MB2791.eurprd08.prod.outlook.com (2603:10a6:6:17::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3021.23; Thu, 21 May 2020 18:44:41 +0000 X-Received: from AM5EUR03FT059.eop-EUR03.prod.protection.outlook.com (2603:10a6:207:3:cafe::3e) by AM3PR05CA0154.outlook.office365.com (2603:10a6:207:3::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3021.23 via Frontend Transport; Thu, 21 May 2020 18:44:41 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 40.67.248.234) smtp.mailfrom=arm.com; edk2.groups.io; dkim=none (message not signed) header.d=none;edk2.groups.io; dmarc=bestguesspass action=none header.from=arm.com; Received-SPF: Pass (protection.outlook.com: domain of arm.com designates 40.67.248.234 as permitted sender) receiver=protection.outlook.com; client-ip=40.67.248.234; helo=nebula.arm.com; X-Received: from nebula.arm.com (40.67.248.234) by AM5EUR03FT059.mail.protection.outlook.com (10.152.17.193) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.3021.23 via Frontend Transport; Thu, 21 May 2020 18:44:41 +0000 X-Received: from AZ-NEU-EX04.Arm.com (10.251.24.32) by AZ-NEU-EX03.Arm.com (10.251.24.31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1415.2; Thu, 21 May 2020 18:44:39 +0000 X-Received: from localhost.localdomain (10.57.25.130) by mail.arm.com (10.251.24.32) with Microsoft SMTP Server id 15.1.1415.2 via Frontend Transport; Thu, 21 May 2020 18:44:39 +0000 From: "Tomas Pilar (tpilar)" To: CC: , Ray Ni , Zhichao Gao Subject: [edk2-devel] [PATCH v2 5/6] ShellPkg/AcpiView: Refactor DumpAcpiTableToFile Date: Thu, 21 May 2020 19:44:20 +0100 Message-ID: <20200521184421.2222-6-Tomas.Pilar@arm.com> In-Reply-To: <20200521184421.2222-1-Tomas.Pilar@arm.com> References: <20200521184421.2222-1-Tomas.Pilar@arm.com> MIME-Version: 1.0 X-EOPAttributedMessage: 1 X-MS-Office365-Filtering-HT: Tenant X-Forefront-Antispam-Report-Untrusted: CIP:40.67.248.234;CTRY:IE;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:nebula.arm.com;PTR:InfoDomainNonexistent;CAT:NONE;SFTY:;SFS:(6029001)(4636009)(346002)(39860400002)(396003)(136003)(376002)(46966005)(8676002)(186003)(26005)(2906002)(1076003)(6916009)(336012)(36756003)(54906003)(6666004)(8936002)(316002)(478600001)(4326008)(82740400003)(47076004)(5660300002)(70586007)(86362001)(70206006)(426003)(2616005)(356005)(82310400002)(81166007);DIR:OUT;SFP:1101; X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: cb07b15e-1701-48e0-4549-08d7fdb70c42 X-MS-TrafficTypeDiagnostic: DB6PR08MB2791:|VI1PR08MB3183: X-Microsoft-Antispam-PRVS: x-checkrecipientrouted: true NoDisclaimer: true X-MS-Oob-TLC-OOBClassifiers: OLM:9508;OLM:9508; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: JSNtKf8HuaI5DC3GA7ImF8jXgdPNsb5IPa0RqBmIyGPfNYgaoKOsammV/T4YetqWsyvta4qW2haIoN3nUHipdxNutecYkW6rz9NPh7gCeNm1RI17JWbVE00PgewbzR1Kmova/hV9qKWkZZL6Nq6pH+fKAIOfQmxCHuq8RawtvRgV5VEoDDaScvO1xRQy63OfXh7PkRHRcf5N/7jbMAri7ne8OPc/pWXEGOAl46DVqfXN8mVLW/71wjj60LlWaO6jexTbQtN4BZsqrsEjZx3sHgJd3rHGt6x9IYXQHvMMNZhIThMbZx5QwjVsBrZ41cRhy9dhmnaPxJSFpp8a3nvMy3VBvz6cTNRJAqU5Gmlsk0/9CYjE4YQGsoWKHl8n8TmQnASy8JkLbVvZxLDSMiVBCg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB6PR08MB2791 X-MS-Exchange-Transport-CrossTenantHeadersStripped: VE1EUR03FT019.eop-EUR03.prod.protection.outlook.com X-MS-Office365-Filtering-Correlation-Id-Prvs: a2221bf6-03ff-4eaf-b5a1-08d7fdb70594 X-Microsoft-Antispam-Message-Info: uaL0qNgchjvfGI7LWzbqeVSzbZxtjeKuunwsFY3nf/0ug7yTUfNoeQmkuh/E/1G1XIwsTYZD6sIq9E1PRxG+KGjVpl+DI/zGYjH16klcHBG0tVweqnteu7humTTdj7VPuK9xDbD7FYs0Oqy9Q51q+AyEhJa/AqlKNSNieo1AaDKrcRArfiBv/xWMZBlL8qcH7OBLlkGnXvn+SiYEymb8+jwyKZxBrxlDg3r3bEmEpWc3ljFtyEh+nlZfQIHHmdqmQwWzQWwtyCqN93Rdz1AlEWbmFPRwJLB91flcaPLEI1a8QR0MCAp8bt5NbQucj6XxB30KJZ2Hk8YIgJ5UiPKL4p9s0HrE6gQ7wQZD5KbpEhL0P3aIY8mZkMt53U166pYSEgJqYEkzup/isl73nE3J/6XJmkSzNP3O0QEyqUcEvrLnVdSixKuoNDLBENKtB5Ahl3dp0ivuS4hxQl31Lv7KpDFqZGRN51kEwJxZnFYV7ePZi0r+rI8icQLvkngaqS0uvHYHuYq7ESxtKEpqV4WX2w== X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 May 2020 18:44:52.1688 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: cb07b15e-1701-48e0-4549-08d7fdb70c42 X-MS-Exchange-CrossTenant-Id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=f34e5979-57d9-4aaa-ad4d-b122a662184d;Ip=[63.35.35.123];Helo=[64aa7808-outbound-1.mta.getcheckrecipient.com] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR08MB3183 Precedence: Bulk List-Unsubscribe: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,Tomas.Pilar@arm.com X-Gm-Message-State: KDGM9vitSMqqefM5RBkntRtax1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1590086697; bh=sUvFjEB5P7YBnvEwtaIg5sCVuruGUG3h9XefAZ7l9NU=; h=CC:Content-Type:Date:From:Reply-To:Subject:To; b=Ty2W8+m137vzs3/hSE9sSgJvRWhb7h/lbnhCQRD9fBG39lw81ZG9rARoXU8PUvdvLmU hwb4xrUNmchIi2cabgOKdlsf5UnPqLTIfSCZOsseqz64CH4WFOTDptmPX1S/kMpQQsu8c MN7znf2lA87TGv0JmEhluy4OjlAVgyEVf8o= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Type: text/plain; charset="utf-8" Method is refactored into two parts. A new method is created that dumps arbitrary buffers into a newly created file. This method is called from core code after the core code determined the appropriate filename to be used. This improves the modular design. Cc: Ray Ni Cc: Zhichao Gao Signed-off-by: Tomas Pilar --- ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiView.c = | 35 +---------------------------------- ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiViewCommandLib.c= | 58 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiViewCommandLib.h= | 17 +++++++++++++++++ 3 files changed, 76 insertions(+), 34 deletions(-) diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiView.c b/Shel= lPkg/Library/UefiShellAcpiViewCommandLib/AcpiView.c index a3160ed6f0a2..e866b84c6844 100644 --- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiView.c +++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiView.c @@ -48,13 +48,10 @@ DumpAcpiTableToFile ( IN CONST UINTN Length ) { - EFI_STATUS Status; CHAR16 FileNameBuffer[MAX_FILE_NAME_LEN]; - SHELL_FILE_HANDLE DumpFileHandle; UINTN TransferBytes; SELECTED_ACPI_TABLE SelectedTable; =20 - DumpFileHandle =3D NULL; TransferBytes =3D Length; GetSelectedAcpiTable (&SelectedTable); =20 @@ -66,39 +63,9 @@ DumpAcpiTableToFile ( mBinTableCount++ ); =20 - Status =3D ShellOpenFileByName ( - FileNameBuffer, - &DumpFileHandle, - EFI_FILE_MODE_READ | EFI_FILE_MODE_WRITE | EFI_FILE_MODE_CREA= TE, - 0 - ); - if (EFI_ERROR (Status)) { - ShellPrintHiiEx ( - -1, - -1, - NULL, - STRING_TOKEN (STR_GEN_READONLY_MEDIA), - gShellAcpiViewHiiHandle, - L"acpiview" - ); - return FALSE; - } - Print (L"Dumping ACPI table to : %s ... ", FileNameBuffer); =20 - Status =3D ShellWriteFile ( - DumpFileHandle, - &TransferBytes, - (VOID*)Ptr - ); - if (EFI_ERROR (Status)) { - Print (L"ERROR: Failed to dump table to binary file.\n"); - TransferBytes =3D 0; - } else { - Print (L"DONE.\n"); - } - - ShellCloseFile (&DumpFileHandle); + TransferBytes =3D DumpFile (FileNameBuffer, Ptr, Length); return (Length =3D=3D TransferBytes); } =20 diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiView= CommandLib.c b/ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiVi= ewCommandLib.c index c3942ad24e5b..adf3cce6cfe2 100644 --- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiViewCommand= Lib.c +++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiViewCommand= Lib.c @@ -98,6 +98,64 @@ RegisterAllParsers ( return Status; } =20 +/** + Dump a buffer to a file + + @param[in] FileName The filename that shall be created to contain the = buffer + @param[in] Buffer Pointer to buffer that shall be dumped + @param[in] BufferSize The size of buffer to be dumped in bytes + + @return The number of bytes that were written +**/ +UINTN +EFIAPI +DumpFile ( + IN CONST CHAR16* FileNameBuffer, + IN CONST VOID* Buffer, + IN CONST UINTN BufferSize + ) +{ + EFI_STATUS Status; + SHELL_FILE_HANDLE DumpFileHandle; + UINTN TransferBytes; + + Status =3D ShellOpenFileByName ( + FileNameBuffer, + &DumpFileHandle, + EFI_FILE_MODE_READ | EFI_FILE_MODE_WRITE | EFI_FILE_MODE_CREA= TE, + 0 + ); + + if (EFI_ERROR (Status)) { + ShellPrintHiiEx ( + -1, + -1, + NULL, + STRING_TOKEN (STR_GEN_READONLY_MEDIA), + gShellAcpiViewHiiHandle, + L"acpiview" + ); + return 0; + } + + TransferBytes =3D BufferSize; + Status =3D ShellWriteFile ( + DumpFileHandle, + &TransferBytes, + (VOID *) Buffer + ); + + if (EFI_ERROR (Status)) { + Print (L"ERROR: Failed to write binary file.\n"); + TransferBytes =3D 0; + } else { + Print (L"DONE.\n"); + } + + ShellCloseFile (&DumpFileHandle); + return TransferBytes; +} + /** Return the file name of the help text file if not using HII. =20 diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiView= CommandLib.h b/ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiVi= ewCommandLib.h index a3a29164004d..9dd39cf4b3f0 100644 --- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiViewCommand= Lib.h +++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiViewCommand= Lib.h @@ -10,6 +10,23 @@ =20 extern EFI_HII_HANDLE gShellAcpiViewHiiHandle; =20 +/** + Dump a buffer to a file + + @param[in] FileName The filename that shall be created to contain the = buffer + @param[in] Buffer Pointer to buffer that shall be dumped + @param[in] BufferSize The size of buffer to be dumped in bytes + + @return The number of bytes that were written +**/ +UINTN +EFIAPI +DumpFile ( + IN CONST CHAR16* FileNameBuffer, + IN CONST VOID* Buffer, + IN CONST UINTN BufferSize + ); + /** Function for 'acpiview' command. =20 --=20 2.24.1.windows.2 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#60064): https://edk2.groups.io/g/devel/message/60064 Mute This Topic: https://groups.io/mt/74382417/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-