diff mbox series

[2/3] acpica: re-work fwts / iasl interface to work with latest ACPICA

Message ID 20190408145153.5485-2-colin.king@canonical.com
State Accepted
Headers show
Series [1/3] ACPICA: Update to version 20190405 | expand

Commit Message

Colin Ian King April 8, 2019, 2:51 p.m. UTC
From: Colin Ian King <colin.king@canonical.com>

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 <colin.king@canonical.com>
---
 .../source/compiler/fwts_iasl_interface.c     | 42 ++++++++++++-------
 1 file changed, 27 insertions(+), 15 deletions(-)

Comments

Ivan Hu April 19, 2019, 2:59 a.m. UTC | #1
On 4/8/19 10:51 PM, Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
>
> 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 <colin.king@canonical.com>
> ---
>  .../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);

Acked-by: Ivan Hu <ivan.hu@canonical.com>
Alex Hung April 19, 2019, 6:31 a.m. UTC | #2
On 2019-04-08 7:51 a.m., Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
> 
> 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 <colin.king@canonical.com>
> ---
>  .../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);
> 


Acked-by: Alex Hung <alex.hung@canonical.com>
diff mbox series

Patch

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);