diff mbox

[07/11] acpica + lib: fix assemble/dissassemble to work with new ACPICA core

Message ID 1334188256-26566-8-git-send-email-colin.king@canonical.com
State Accepted
Headers show

Commit Message

Colin Ian King April 11, 2012, 11:50 p.m. UTC
From: Colin Ian King <colin.king@canonical.com>

Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
 src/acpica/source/compiler/fwts_iasl_interface.c |   15 +++++++++++----
 src/lib/src/fwts_iasl.c                          |   10 +++++-----
 2 files changed, 16 insertions(+), 9 deletions(-)

Comments

Keng-Yu Lin April 12, 2012, 6:23 a.m. UTC | #1
On Thu, Apr 12, 2012 at 7:50 AM, Colin King <colin.king@canonical.com> wrote:
> From: Colin Ian King <colin.king@canonical.com>
>
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
>  src/acpica/source/compiler/fwts_iasl_interface.c |   15 +++++++++++----
>  src/lib/src/fwts_iasl.c                          |   10 +++++-----
>  2 files changed, 16 insertions(+), 9 deletions(-)
>
> diff --git a/src/acpica/source/compiler/fwts_iasl_interface.c b/src/acpica/source/compiler/fwts_iasl_interface.c
> index b4be8ef..ada4326 100644
> --- a/src/acpica/source/compiler/fwts_iasl_interface.c
> +++ b/src/acpica/source/compiler/fwts_iasl_interface.c
> @@ -37,9 +37,11 @@ static void init_asl_core(void)
>                Gbl_Files[i].Handle = NULL;
>                Gbl_Files[i].Filename = NULL;
>        }
> -
> +
>        Gbl_Files[ASL_FILE_STDOUT].Handle   = stdout;
>        Gbl_Files[ASL_FILE_STDOUT].Filename = "STDOUT";
> +       Gbl_Files[ASL_FILE_STDERR].Handle   = stdout;
> +       Gbl_Files[ASL_FILE_STDERR].Filename = "STDOUT";
>  }
>
>  int fwts_iasl_disassemble_aml(const char *aml, const char *outputfile)
> @@ -55,10 +57,11 @@ int fwts_iasl_disassemble_aml(const char *aml, const char *outputfile)
>                /* Child */
>                init_asl_core();
>
> +               /* Setup ACPICA disassembler globals */
>                Gbl_DisasmFlag = TRUE;
>                Gbl_DoCompile = FALSE;
>                Gbl_OutputFilenamePrefix = (char*)outputfile;
> -               Gbl_UseDefaultAmlFilename = FALSE;
> +               Gbl_UseDefaultAmlFilename = FALSE;
>
>                /* Throw away noisy errors */
>                freopen("/dev/null", "w", stderr);
> @@ -82,7 +85,7 @@ int fwts_iasl_assemble_aml(const char *source, char **output)
>        char    buffer[8192];
>        int     n;
>        int     len = 0;
> -       int     status;
> +       int     status;
>        FILE    *fp;
>
>        if (pipe(pipefds) < 0)
> @@ -104,8 +107,12 @@ int fwts_iasl_assemble_aml(const char *source, char **output)
>                }
>                close(pipefds[0]);
>
> +               /* Setup ACPICA compiler globals */
>                Gbl_DisasmFlag = FALSE;
>                Gbl_DoCompile = TRUE;
> +               Gbl_PreprocessFlag = FALSE;
> +               Gbl_UseDefaultAmlFilename = FALSE;
> +               Gbl_OutputFilenamePrefix = source;
>
>                status = AslDoOnePathname(source, AslDoOneFile);
>
> @@ -116,7 +123,7 @@ int fwts_iasl_assemble_aml(const char *source, char **output)
>        default:
>                /* Parent */
>                close(pipefds[1]);
> -
> +
>                while ((n = read(pipefds[0], buffer, sizeof(buffer))) > 0) {
>                        data = realloc(data, len + n + 1);
>                        memcpy(data + len, buffer, n);
> diff --git a/src/lib/src/fwts_iasl.c b/src/lib/src/fwts_iasl.c
> index d6c8676..d75d997 100644
> --- a/src/lib/src/fwts_iasl.c
> +++ b/src/lib/src/fwts_iasl.c
> @@ -169,18 +169,18 @@ int fwts_iasl_reassemble(fwts_framework *fw,
>        /* Now we have a disassembled source in tmpfile, so let's assemble it */
>
>        if (fwts_iasl_assemble_aml(tmpfile, &output_text) < 0) {
> -               (void)unlink(tmpfile);
> +               (void)unlink(amlfile);
>                (void)unlink(tmpfile);
>                free(output_text);
>                return FWTS_ERROR;
>        }
>
> +       /* Remove these now we don't need them */
>        (void)unlink(tmpfile);
> +       (void)unlink(amlfile);
>
> -       /* For some reason that I've not yet fathomed the ACPICA assembler
> -          leaves a .src file lying around so let's remove it to be tidy */
> -
> -       snprintf(tmpfile, sizeof(tmpfile), "/tmp/fwts_iasl_%d.src", pid);
> +       /* And remove aml file generated from ACPICA compiler */
> +       snprintf(tmpfile, sizeof(tmpfile), "/tmp/fwts_iasl_%d.aml", pid);
>        (void)unlink(tmpfile);
>
>        *iasl_errors = fwts_list_from_text(output_text);
> --
> 1.7.9.5
>
Acked-by: Keng-Yu Lin <kengyu@canonical.com>
Alex Hung April 12, 2012, 7:49 a.m. UTC | #2
On 04/12/2012 07:50 AM, Colin King wrote:
> From: Colin Ian King<colin.king@canonical.com>
>
> Signed-off-by: Colin Ian King<colin.king@canonical.com>
> ---

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

Patch

diff --git a/src/acpica/source/compiler/fwts_iasl_interface.c b/src/acpica/source/compiler/fwts_iasl_interface.c
index b4be8ef..ada4326 100644
--- a/src/acpica/source/compiler/fwts_iasl_interface.c
+++ b/src/acpica/source/compiler/fwts_iasl_interface.c
@@ -37,9 +37,11 @@  static void init_asl_core(void)
 		Gbl_Files[i].Handle = NULL;
 		Gbl_Files[i].Filename = NULL;
 	}
-	
+
 	Gbl_Files[ASL_FILE_STDOUT].Handle   = stdout;
 	Gbl_Files[ASL_FILE_STDOUT].Filename = "STDOUT";
+	Gbl_Files[ASL_FILE_STDERR].Handle   = stdout;
+	Gbl_Files[ASL_FILE_STDERR].Filename = "STDOUT";
 }
 
 int fwts_iasl_disassemble_aml(const char *aml, const char *outputfile)
@@ -55,10 +57,11 @@  int fwts_iasl_disassemble_aml(const char *aml, const char *outputfile)
 		/* Child */
 		init_asl_core();
 
+		/* Setup ACPICA disassembler globals */
 		Gbl_DisasmFlag = TRUE;
         	Gbl_DoCompile = FALSE;
         	Gbl_OutputFilenamePrefix = (char*)outputfile;
-        	Gbl_UseDefaultAmlFilename = FALSE;
+		Gbl_UseDefaultAmlFilename = FALSE;
 
 		/* Throw away noisy errors */
 		freopen("/dev/null", "w", stderr);
@@ -82,7 +85,7 @@  int fwts_iasl_assemble_aml(const char *source, char **output)
 	char	buffer[8192];
 	int	n;
 	int 	len = 0;
-	int	status;	
+	int	status;
 	FILE 	*fp;
 
 	if (pipe(pipefds) < 0)
@@ -104,8 +107,12 @@  int fwts_iasl_assemble_aml(const char *source, char **output)
 		}
 		close(pipefds[0]);
 
+		/* Setup ACPICA compiler globals */
 		Gbl_DisasmFlag = FALSE;
         	Gbl_DoCompile = TRUE;
+		Gbl_PreprocessFlag = FALSE;
+        	Gbl_UseDefaultAmlFilename = FALSE;
+        	Gbl_OutputFilenamePrefix = source;
 
 		status = AslDoOnePathname(source, AslDoOneFile);
 
@@ -116,7 +123,7 @@  int fwts_iasl_assemble_aml(const char *source, char **output)
 	default:
 		/* Parent */
 		close(pipefds[1]);
-		
+
 		while ((n = read(pipefds[0], buffer, sizeof(buffer))) > 0) {
 			data = realloc(data, len + n + 1);
 			memcpy(data + len, buffer, n);
diff --git a/src/lib/src/fwts_iasl.c b/src/lib/src/fwts_iasl.c
index d6c8676..d75d997 100644
--- a/src/lib/src/fwts_iasl.c
+++ b/src/lib/src/fwts_iasl.c
@@ -169,18 +169,18 @@  int fwts_iasl_reassemble(fwts_framework *fw,
 	/* Now we have a disassembled source in tmpfile, so let's assemble it */
 
 	if (fwts_iasl_assemble_aml(tmpfile, &output_text) < 0) {
-		(void)unlink(tmpfile);
+		(void)unlink(amlfile);
 		(void)unlink(tmpfile);
 		free(output_text);
 		return FWTS_ERROR;
 	}
 
+	/* Remove these now we don't need them */
 	(void)unlink(tmpfile);
+	(void)unlink(amlfile);
 
-	/* For some reason that I've not yet fathomed the ACPICA assembler 
-	   leaves a .src file lying around so let's remove it to be tidy */
-
-	snprintf(tmpfile, sizeof(tmpfile), "/tmp/fwts_iasl_%d.src", pid);
+	/* And remove aml file generated from ACPICA compiler */
+	snprintf(tmpfile, sizeof(tmpfile), "/tmp/fwts_iasl_%d.aml", pid);
 	(void)unlink(tmpfile);
 
 	*iasl_errors = fwts_list_from_text(output_text);