From patchwork Mon Apr 8 14:51:52 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Colin Ian King X-Patchwork-Id: 1081111 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.ubuntu.com (client-ip=91.189.94.19; helo=huckleberry.canonical.com; envelope-from=fwts-devel-bounces@lists.ubuntu.com; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=canonical.com Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 44dD0Q4CMRz9sNd; Tue, 9 Apr 2019 00:52:06 +1000 (AEST) Received: from localhost ([127.0.0.1] helo=huckleberry.canonical.com) by huckleberry.canonical.com with esmtp (Exim 4.86_2) (envelope-from ) id 1hDVcx-0003VP-S5; Mon, 08 Apr 2019 14:52:03 +0000 Received: from youngberry.canonical.com ([91.189.89.112]) by huckleberry.canonical.com with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:128) (Exim 4.86_2) (envelope-from ) id 1hDVcp-0003TX-3Y for fwts-devel@lists.ubuntu.com; Mon, 08 Apr 2019 14:51:55 +0000 Received: from 1.general.cking.uk.vpn ([10.172.193.212] helo=localhost) by youngberry.canonical.com with esmtpsa (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.76) (envelope-from ) id 1hDVco-0001Xn-NT; Mon, 08 Apr 2019 14:51:54 +0000 From: Colin King To: fwts-devel@lists.ubuntu.com Subject: [PATCH 2/3] acpica: re-work fwts / iasl interface to work with latest ACPICA Date: Mon, 8 Apr 2019 15:51:52 +0100 Message-Id: <20190408145153.5485-2-colin.king@canonical.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190408145153.5485-1-colin.king@canonical.com> References: <20190408145153.5485-1-colin.king@canonical.com> MIME-Version: 1.0 X-BeenThere: fwts-devel@lists.ubuntu.com X-Mailman-Version: 2.1.20 Precedence: list List-Id: Firmware Test Suite Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: fwts-devel-bounces@lists.ubuntu.com Sender: "fwts-devel" From: Colin Ian King The latest ACPICA IASL tool has had some minor changes that need folding back into the fwts iasl interface to make it work. The reading of the stderr/stdout output from iasl has also been modified to read pipe sized output and not to break out if one of the streams hits EOF. Signed-off-by: Colin Ian King Acked-by: Ivan Hu Acked-by: Alex Hung --- .../source/compiler/fwts_iasl_interface.c | 42 ++++++++++++------- 1 file changed, 27 insertions(+), 15 deletions(-) diff --git a/src/acpica/source/compiler/fwts_iasl_interface.c b/src/acpica/source/compiler/fwts_iasl_interface.c index 1699eb6c..3861926c 100644 --- a/src/acpica/source/compiler/fwts_iasl_interface.c +++ b/src/acpica/source/compiler/fwts_iasl_interface.c @@ -29,6 +29,19 @@ #include "acdisasm.h" #include "acapps.h" +static void AslInitialize(void) +{ + AcpiGbl_DmOpt_Verbose = FALSE; + + /* Default integer width is 32 bits */ + + AcpiGbl_IntegerBitWidth = 32; + AcpiGbl_IntegerNybbleWidth = 8; + AcpiGbl_IntegerByteWidth = 4; + + AdInitialize(); +} + /* * init_asl_core() * initialize iasl @@ -40,12 +53,7 @@ static void init_asl_core(void) AcpiGbl_ExternalFileList = NULL; AcpiDbgLevel = 0; PrInitializePreprocessor(); - - /* From AslInitialize */ - AcpiGbl_DmOpt_Verbose = FALSE; - AcpiGbl_IntegerBitWidth = 32; - AcpiGbl_IntegerNybbleWidth = 8; - AcpiGbl_IntegerByteWidth = 4; + AslInitialize(); AslGbl_LineBufferSize = 1024; AslGbl_CurrentLineBuffer = NULL; @@ -153,7 +161,7 @@ int fwts_iasl_disassemble_aml( */ static int fwts_iasl_read_output(const int fd, char **data, size_t *len, bool *eof) { - char buffer[8192]; + char buffer[4096]; ssize_t n; if (*eof) @@ -191,6 +199,9 @@ int fwts_iasl_assemble_aml(const char *source, char **stdout_output, char **stde pid_t pid; bool stdout_eof = false, stderr_eof = false; + *stdout_output = NULL; + *stderr_output = NULL; + fflush(stdout); fflush(stderr); @@ -233,13 +244,16 @@ int fwts_iasl_assemble_aml(const char *source, char **stdout_output, char **stde AslGbl_DoCompile = TRUE; AslGbl_PreprocessFlag = TRUE; AslGbl_UseDefaultAmlFilename = FALSE; - AslGbl_OutputFilenamePrefix = (char*)source; - UtConvertBackslashes(AslGbl_OutputFilenamePrefix); AdInitialize(); - status = AslDoOneFile((char *)source); - AslCheckExpectedExceptions(); + AslGbl_OutputFilenamePrefix = (char*)source; + UtConvertBackslashes(AslGbl_OutputFilenamePrefix); + status = AslDoOneFile((char *)source); + if (!ACPI_FAILURE(status)) { + CmDoAslMiddleAndBackEnd(); + AslCheckExpectedExceptions(); + } UtFreeLineBuffers(); AslParserCleanup(); AcpiDmClearExternalFileList(); @@ -261,10 +275,8 @@ int fwts_iasl_assemble_aml(const char *source, char **stdout_output, char **stde (void)close(stderr_fds[1]); while (!stdout_eof && !stderr_eof) { - if (fwts_iasl_read_output(stdout_fds[0], stdout_output, &stdout_len, &stdout_eof) < 0) - break; - if (fwts_iasl_read_output(stderr_fds[0], stderr_output, &stderr_len, &stderr_eof) < 0) - break; + fwts_iasl_read_output(stdout_fds[0], stdout_output, &stdout_len, &stdout_eof); + fwts_iasl_read_output(stderr_fds[0], stderr_output, &stderr_len, &stderr_eof); } (void)waitpid(pid, &status, WUNTRACED | WCONTINUED);