summaryrefslogtreecommitdiff
path: root/source
diff options
context:
space:
mode:
authorJung-uk Kim <jkim@FreeBSD.org>2017-02-28 20:06:31 +0000
committerJung-uk Kim <jkim@FreeBSD.org>2017-02-28 20:06:31 +0000
commit691d1929c1c1f25857086b168ef9973b2472de41 (patch)
tree04e90e804d87765833c7230981b2cca94e2ebf94 /source
parenta0b3a9cf1fc8fe1d9f95e69cdf8914bb6ebcee03 (diff)
downloadsrc-test2-691d1929c1c1f25857086b168ef9973b2472de41.tar.gz
src-test2-691d1929c1c1f25857086b168ef9973b2472de41.zip
Notes
Diffstat (limited to 'source')
-rw-r--r--source/common/adisasm.c25
-rw-r--r--source/common/adwalk.c2
-rw-r--r--source/common/dmextern.c25
-rw-r--r--source/common/dmtables.c22
-rw-r--r--source/common/dmtbinfo.c10
-rw-r--r--source/compiler/aslcodegen.c101
-rw-r--r--source/compiler/aslcompile.c31
-rw-r--r--source/compiler/aslcompiler.h16
-rw-r--r--source/compiler/aslcompiler.l5
-rw-r--r--source/compiler/asldebug.c34
-rw-r--r--source/compiler/asldefine.h8
-rw-r--r--source/compiler/aslfiles.c32
-rw-r--r--source/compiler/aslglobal.h22
-rw-r--r--source/compiler/aslhelp.c8
-rw-r--r--source/compiler/asllength.c5
-rw-r--r--source/compiler/aslmap.c36
-rw-r--r--source/compiler/asloffset.c2
-rw-r--r--source/compiler/asloperands.c7
-rw-r--r--source/compiler/asloptions.c63
-rw-r--r--source/compiler/aslprimaries.y23
-rw-r--r--source/compiler/aslprintf.c2
-rw-r--r--source/compiler/aslresources.y9
-rw-r--r--source/compiler/aslrules.y10
-rw-r--r--source/compiler/aslstartup.c32
-rw-r--r--source/compiler/aslsupport.l114
-rw-r--r--source/compiler/asltree.c175
-rw-r--r--source/compiler/asltypes.h23
-rw-r--r--source/compiler/aslwalks.c2
-rw-r--r--source/compiler/cvcompiler.c890
-rw-r--r--source/compiler/cvdisasm.c423
-rw-r--r--source/compiler/cvparser.c887
-rw-r--r--source/compiler/dttable1.c4
-rw-r--r--source/compiler/dttemplate.h72
-rw-r--r--source/components/debugger/dbmethod.c1
-rw-r--r--source/components/debugger/dbxface.c5
-rw-r--r--source/components/disassembler/dmcstyle.c51
-rw-r--r--source/components/disassembler/dmdeferred.c6
-rw-r--r--source/components/disassembler/dmnames.c2
-rw-r--r--source/components/disassembler/dmopcode.c82
-rw-r--r--source/components/disassembler/dmutils.c8
-rw-r--r--source/components/disassembler/dmwalk.c105
-rw-r--r--source/components/dispatcher/dscontrol.c2
-rw-r--r--source/components/dispatcher/dsmthdat.c3
-rw-r--r--source/components/dispatcher/dsobject.c14
-rw-r--r--source/components/dispatcher/dsopcode.c4
-rw-r--r--source/components/dispatcher/dsutils.c6
-rw-r--r--source/components/dispatcher/dswexec.c2
-rw-r--r--source/components/dispatcher/dswload2.c2
-rw-r--r--source/components/executer/exmisc.c16
-rw-r--r--source/components/executer/exnames.c4
-rw-r--r--source/components/executer/exoparg1.c15
-rw-r--r--source/components/executer/exoparg2.c4
-rw-r--r--source/components/executer/exoparg6.c10
-rw-r--r--source/components/executer/exresolv.c2
-rw-r--r--source/components/executer/exstore.c4
-rw-r--r--source/components/executer/exstoren.c2
-rw-r--r--source/components/hardware/hwvalid.c18
-rw-r--r--source/components/namespace/nsaccess.c2
-rw-r--r--source/components/namespace/nsrepair.c16
-rw-r--r--source/components/namespace/nsrepair2.c6
-rw-r--r--source/components/namespace/nsutils.c31
-rw-r--r--source/components/parser/psargs.c30
-rw-r--r--source/components/parser/psloop.c39
-rw-r--r--source/components/parser/psobject.c36
-rw-r--r--source/components/parser/psopcode.c13
-rw-r--r--source/components/parser/psopinfo.c2
-rw-r--r--source/components/parser/psparse.c6
-rw-r--r--source/components/parser/pstree.c9
-rw-r--r--source/components/parser/psutils.c13
-rw-r--r--source/components/utilities/utalloc.c44
-rw-r--r--source/components/utilities/utcache.c2
-rw-r--r--source/components/utilities/utdebug.c1
-rw-r--r--source/components/utilities/utresrc.c10
-rw-r--r--source/components/utilities/utxferror.c16
-rw-r--r--source/include/acconfig.h1
-rw-r--r--source/include/acconvert.h204
-rw-r--r--source/include/acdisasm.h14
-rw-r--r--source/include/acglobal.h44
-rw-r--r--source/include/aclocal.h118
-rw-r--r--source/include/acmacros.h35
-rw-r--r--source/include/acopcode.h2
-rw-r--r--source/include/acpixf.h2
-rw-r--r--source/include/actbl2.h11
-rw-r--r--source/include/amlcode.h104
-rw-r--r--source/tools/acpisrc/astable.c2
85 files changed, 3893 insertions, 408 deletions
diff --git a/source/common/adisasm.c b/source/common/adisasm.c
index d1ac077aa1e1..25926564a440 100644
--- a/source/common/adisasm.c
+++ b/source/common/adisasm.c
@@ -326,6 +326,21 @@ AdDisassembleOneTable (
ACPI_OWNER_ID OwnerId;
+#ifdef ACPI_ASL_COMPILER
+
+ /*
+ * For ASL-/ASL+ converter: replace the temporary "XXXX"
+ * table signature with the original. This "XXXX" makes
+ * it harder for the AML interpreter to run the badaml
+ * (.xxx) file produced from the converter in case if
+ * it fails to get deleted.
+ */
+ if (Gbl_CaptureComments)
+ {
+ strncpy (Table->Signature, AcpiGbl_TableSig, 4);
+ }
+#endif
+
/* ForceAmlDisassembly means to assume the table contains valid AML */
if (!AcpiGbl_ForceAmlDisassembly && !AcpiUtIsAmlTable (Table))
@@ -475,6 +490,7 @@ AdReparseOneTable (
ACPI_OWNER_ID OwnerId)
{
ACPI_STATUS Status;
+ ACPI_COMMENT_ADDR_NODE *AddrListHead;
fprintf (stderr,
@@ -508,6 +524,15 @@ AdReparseOneTable (
AcpiDmAddExternalsToNamespace ();
+ /* For -ca option: clear the list of comment addresses. */
+
+ while (AcpiGbl_CommentAddrListHead)
+ {
+ AddrListHead= AcpiGbl_CommentAddrListHead;
+ AcpiGbl_CommentAddrListHead = AcpiGbl_CommentAddrListHead->Next;
+ AcpiOsFree(AddrListHead);
+ }
+
/* Parse the table again. No need to reload it, however */
Status = AdParseTable (Table, NULL, FALSE, FALSE);
diff --git a/source/common/adwalk.c b/source/common/adwalk.c
index 130f66d6ac3b..c1da64c1e4ce 100644
--- a/source/common/adwalk.c
+++ b/source/common/adwalk.c
@@ -878,7 +878,7 @@ AcpiDmXrefDescendingOp (
* method.
*/
if (!(Op->Asl.Parent &&
- (Op->Asl.Parent->Asl.AmlOpcode == AML_COND_REF_OF_OP)))
+ (Op->Asl.Parent->Asl.AmlOpcode == AML_CONDITIONAL_REF_OF_OP)))
{
if (Node)
{
diff --git a/source/common/dmextern.c b/source/common/dmextern.c
index fab660623c88..66e3d212e8d3 100644
--- a/source/common/dmextern.c
+++ b/source/common/dmextern.c
@@ -1165,6 +1165,31 @@ AcpiDmEmitExternals (
/*******************************************************************************
*
+ * FUNCTION: AcpiDmEmitExternal
+ *
+ * PARAMETERS: Op External Parse Object
+ *
+ * RETURN: None
+ *
+ * DESCRIPTION: Emit an External() ASL statement for the current External
+ * parse object
+ *
+ ******************************************************************************/
+
+void
+AcpiDmEmitExternal (
+ ACPI_PARSE_OBJECT *NameOp,
+ ACPI_PARSE_OBJECT *TypeOp)
+{
+ AcpiOsPrintf ("External (");
+ AcpiDmNamestring (NameOp->Common.Value.Name);
+ AcpiOsPrintf ("%s)\n",
+ AcpiDmGetObjectTypeName ((ACPI_OBJECT_TYPE) TypeOp->Common.Value.Integer));
+}
+
+
+/*******************************************************************************
+ *
* FUNCTION: AcpiDmUnresolvedWarning
*
* PARAMETERS: Type - Where to output the warning.
diff --git a/source/common/dmtables.c b/source/common/dmtables.c
index 5c93cab771cd..46e4bad9bfd9 100644
--- a/source/common/dmtables.c
+++ b/source/common/dmtables.c
@@ -47,6 +47,8 @@
#include "actables.h"
#include "acparser.h"
#include "acapps.h"
+#include "acmacros.h"
+#include "acconvert.h"
#define _COMPONENT ACPI_TOOLS
@@ -202,6 +204,14 @@ AdCreateTableHeader (
AcpiOsPrintf (" */\n");
/*
+ * Print comments that come before this definition block.
+ */
+ if (Gbl_CaptureComments)
+ {
+ ASL_CV_PRINT_ONE_COMMENT(AcpiGbl_ParseOpRoot,AML_COMMENT_STANDARD, NULL, 0);
+ }
+
+ /*
* Open the ASL definition block.
*
* Note: the AMLFilename string is left zero-length in order to just let
@@ -388,6 +398,7 @@ AdParseTable (
AmlLength = Table->Length - sizeof (ACPI_TABLE_HEADER);
AmlStart = ((UINT8 *) Table + sizeof (ACPI_TABLE_HEADER));
+ ASL_CV_INIT_FILETREE(Table, AmlStart, AmlLength);
/* Create the root object */
@@ -397,6 +408,17 @@ AdParseTable (
return (AE_NO_MEMORY);
}
+#ifdef ACPI_ASL_COMPILER
+ if (Gbl_CaptureComments)
+ {
+ AcpiGbl_ParseOpRoot->Common.CvFilename = AcpiGbl_FileTreeRoot->Filename;
+ }
+ else
+ {
+ AcpiGbl_ParseOpRoot->Common.CvFilename = NULL;
+ }
+#endif
+
/* Create and initialize a new walk state */
WalkState = AcpiDsCreateWalkState (0, AcpiGbl_ParseOpRoot, NULL, NULL);
diff --git a/source/common/dmtbinfo.c b/source/common/dmtbinfo.c
index 2ac5c48e1ead..0cdbe501e676 100644
--- a/source/common/dmtbinfo.c
+++ b/source/common/dmtbinfo.c
@@ -171,6 +171,7 @@
#define ACPI_IORT1_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_IORT_NAMED_COMPONENT,f)
#define ACPI_IORT2_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_IORT_ROOT_COMPLEX,f)
#define ACPI_IORT3_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_IORT_SMMU,f)
+#define ACPI_IORT3A_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_IORT_SMMU_GSI,f)
#define ACPI_IORT4_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_IORT_SMMU_V3,f)
#define ACPI_IORTA_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_IORT_MEMORY_ACCESS,f)
#define ACPI_IORTH_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_IORT_NODE,f)
@@ -259,6 +260,7 @@
#define ACPI_GTDT0a_FLAG_OFFSET(f,o) ACPI_FLAG_OFFSET (ACPI_GTDT_TIMER_ENTRY,f,o)
#define ACPI_GTDT1_FLAG_OFFSET(f,o) ACPI_FLAG_OFFSET (ACPI_GTDT_WATCHDOG,f,o)
#define ACPI_IORT3_FLAG_OFFSET(f,o) ACPI_FLAG_OFFSET (ACPI_IORT_SMMU,f,o)
+#define ACPI_IORT3a_FLAG_OFFSET(f,o) ACPI_FLAG_OFFSET (ACPI_IORT_SMMU_GSI,f,o)
#define ACPI_IORT4_FLAG_OFFSET(f,o) ACPI_FLAG_OFFSET (ACPI_IORT_SMMU_V3,f,o)
#define ACPI_IORTA_FLAG_OFFSET(f,o) ACPI_FLAG_OFFSET (ACPI_IORT_MEMORY_ACCESS,f,o)
#define ACPI_IORTM_FLAG_OFFSET(f,o) ACPI_FLAG_OFFSET (ACPI_IORT_ID_MAPPING,f,o)
@@ -1549,8 +1551,12 @@ ACPI_DMTABLE_INFO AcpiDmTableInfoIort3[] =
ACPI_DMTABLE_INFO AcpiDmTableInfoIort3a[] =
{
- {ACPI_DMT_UINT64, 0, "SMMU_NSgIrpt Interrupt", 0},
- {ACPI_DMT_UINT64, 0, "SMMU_NSgCfgIrpt Interrupt", 0},
+ {ACPI_DMT_UINT32, ACPI_IORT3A_OFFSET (NSgIrpt), "NSgIrpt", 0},
+ {ACPI_DMT_UINT32, ACPI_IORT3A_OFFSET (NSgIrptFlags), "NSgIrpt Flags (decoded below)", 0},
+ {ACPI_DMT_FLAG0, ACPI_IORT3a_FLAG_OFFSET (NSgIrptFlags, 0), "Edge Triggered", 0},
+ {ACPI_DMT_UINT32, ACPI_IORT3A_OFFSET (NSgCfgIrpt), "NSgCfgIrpt", 0},
+ {ACPI_DMT_UINT32, ACPI_IORT3A_OFFSET (NSgCfgIrptFlags), "NSgCfgIrpt Flags (decoded below)", 0},
+ {ACPI_DMT_FLAG0, ACPI_IORT3a_FLAG_OFFSET (NSgCfgIrptFlags, 0), "Edge Triggered", 0},
ACPI_DMT_TERMINATOR
};
diff --git a/source/compiler/aslcodegen.c b/source/compiler/aslcodegen.c
index 941525392e80..f970238bb1b5 100644
--- a/source/compiler/aslcodegen.c
+++ b/source/compiler/aslcodegen.c
@@ -44,6 +44,7 @@
#include "aslcompiler.h"
#include "aslcompiler.y.h"
#include "amlcode.h"
+#include "acconvert.h"
#define _COMPONENT ACPI_COMPILER
ACPI_MODULE_NAME ("aslcodegen")
@@ -57,12 +58,6 @@ CgAmlWriteWalk (
void *Context);
static void
-CgLocalWriteAmlData (
- ACPI_PARSE_OBJECT *Op,
- void *Buffer,
- UINT32 Length);
-
-static void
CgWriteAmlOpcode (
ACPI_PARSE_OBJECT *Op);
@@ -206,7 +201,7 @@ CgAmlWriteWalk (
*
******************************************************************************/
-static void
+void
CgLocalWriteAmlData (
ACPI_PARSE_OBJECT *Op,
void *Buffer,
@@ -261,6 +256,15 @@ CgWriteAmlOpcode (
return;
}
+ /*
+ * Before printing the bytecode, generate comment byte codes
+ * associated with this node.
+ */
+ if (Gbl_CaptureComments)
+ {
+ CgWriteAmlComment(Op);
+ }
+
switch (Op->Asl.AmlOpcode)
{
case AML_UNASSIGNED_OPCODE:
@@ -416,6 +420,8 @@ CgWriteTableHeader (
ACPI_PARSE_OBJECT *Op)
{
ACPI_PARSE_OBJECT *Child;
+ UINT32 CommentLength;
+ ACPI_COMMENT_NODE *Current;
/* AML filename */
@@ -425,6 +431,21 @@ CgWriteTableHeader (
/* Signature */
Child = Child->Asl.Next;
+
+ /*
+ * For ASL-/ASL+ converter: replace the table signature with
+ * "XXXX" and save the original table signature. This results in an AML
+ * file with the signature "XXXX". The converter should remove this AML
+ * file. In the event where this AML file does not get deleted, the
+ * "XXXX" table signature prevents this AML file from running on the AML
+ * interpreter.
+ */
+ if (Gbl_CaptureComments)
+ {
+ strncpy(AcpiGbl_TableSig, Child->Asl.Value.String, 4);
+ Child->Asl.Value.String = ACPI_SIG_XXXX;
+ }
+
strncpy (TableHeader.Signature, Child->Asl.Value.String, 4);
/* Revision */
@@ -466,6 +487,50 @@ CgWriteTableHeader (
TableHeader.Length = sizeof (ACPI_TABLE_HEADER) +
Op->Asl.AmlSubtreeLength;
+
+ /* Calculate the comment lengths for this definition block parseOp */
+
+ if (Gbl_CaptureComments)
+ {
+ CvDbgPrint ("Calculating comment lengths for %s in write header\n",
+ Op->Asl.ParseOpName);
+
+ /*
+ * Take the filename without extensions, add 3 for the new extension
+ * and another 3 for the a908 bytecode and null terminator.
+ */
+ TableHeader.Length += strrchr (Gbl_ParseTreeRoot->Asl.Filename, '.')
+ - Gbl_ParseTreeRoot->Asl.Filename + 1 + 3 + 3;
+ Op->Asl.AmlSubtreeLength +=
+ strlen (Gbl_ParseTreeRoot->Asl.Filename) + 3;
+ CvDbgPrint (" Length: %lu\n",
+ strlen (Gbl_ParseTreeRoot->Asl.Filename) + 3);
+
+ if (Op->Asl.CommentList)
+ {
+ Current = Op->Asl.CommentList;
+ while (Current)
+ {
+ CommentLength = strlen (Current->Comment)+3;
+ CvDbgPrint ("Length of standard comment): %d\n", CommentLength);
+ CvDbgPrint (" Comment string: %s\n\n", Current->Comment);
+ TableHeader.Length += CommentLength;
+ Op->Asl.AmlSubtreeLength += CommentLength;
+ Current = Current->Next;
+ CvDbgPrint (" Length: %u\n", CommentLength);
+ }
+ }
+ if (Op->Asl.CloseBraceComment)
+ {
+ CommentLength = strlen (Op->Asl.CloseBraceComment)+3;
+ CvDbgPrint ("Length of inline comment +3: %d\n", CommentLength);
+ CvDbgPrint (" Comment string: %s\n\n", Op->Asl.CloseBraceComment);
+ TableHeader.Length += CommentLength;
+ Op->Asl.AmlSubtreeLength += CommentLength;
+ CvDbgPrint (" Length: %u\n", CommentLength);
+ }
+ }
+
TableHeader.Checksum = 0;
Op->Asl.FinalAmlOffset = ftell (Gbl_Files[ASL_FILE_AML_OUTPUT].Handle);
@@ -492,13 +557,13 @@ CgWriteTableHeader (
static void
CgUpdateHeader (
- ACPI_PARSE_OBJECT *Op)
+ ACPI_PARSE_OBJECT *Op)
{
- signed char Sum;
- UINT32 i;
- UINT32 Length;
- UINT8 FileByte;
- UINT8 Checksum;
+ signed char Sum;
+ UINT32 i;
+ UINT32 Length;
+ UINT8 FileByte;
+ UINT8 Checksum;
/* Calculate the checksum over the entire definition block */
@@ -580,6 +645,12 @@ CgWriteNode (
ASL_RESOURCE_NODE *Rnode;
+ /* Write all comments here. */
+ if (Gbl_CaptureComments)
+ {
+ CgWriteAmlComment(Op);
+ }
+
/* Always check for DEFAULT_ARG and other "Noop" nodes */
/* TBD: this may not be the best place for this check */
@@ -641,6 +712,10 @@ CgWriteNode (
case PARSEOP_DEFINITION_BLOCK:
CgWriteTableHeader (Op);
+ if (Gbl_CaptureComments)
+ {
+ CgWriteAmlDefBlockComment (Op);
+ }
break;
case PARSEOP_NAMESEG:
diff --git a/source/compiler/aslcompile.c b/source/compiler/aslcompile.c
index 281be341426b..5da664f57c23 100644
--- a/source/compiler/aslcompile.c
+++ b/source/compiler/aslcompile.c
@@ -285,8 +285,17 @@ CmDoCompile (
{
Event = UtBeginEvent ("Resolve all Externals");
DbgPrint (ASL_DEBUG_OUTPUT, "\nResolve Externals\n\n");
- TrWalkParseTree (Gbl_ParseTreeRoot, ASL_WALK_VISIT_TWICE,
- ExAmlExternalWalkBegin, ExAmlExternalWalkEnd, NULL);
+
+ if (Gbl_DoExternalsInPlace)
+ {
+ TrWalkParseTree (Gbl_ParseTreeRoot, ASL_WALK_VISIT_DOWNWARD,
+ ExAmlExternalWalkBegin, NULL, NULL);
+ }
+ else
+ {
+ TrWalkParseTree (Gbl_ParseTreeRoot, ASL_WALK_VISIT_TWICE,
+ ExAmlExternalWalkBegin, ExAmlExternalWalkEnd, NULL);
+ }
UtEndEvent (Event);
}
@@ -347,6 +356,18 @@ CmDoCompile (
NULL, &AnalysisWalkInfo);
UtEndEvent (Event);
+ /*
+ * ASL-/ASL+ converter: Gbl_ParseTreeRoot->CommentList contains the
+ * very last comment of a given ASL file because it's the last constructed
+ * node during compilation. We take the very last comment and save it in a
+ * global for it to be used by the disassembler.
+ */
+ if (Gbl_CaptureComments)
+ {
+ AcpiGbl_LastListHead = Gbl_ParseTreeRoot->Asl.CommentList;
+ Gbl_ParseTreeRoot->Asl.CommentList = NULL;
+ }
+
/* Calculate all AML package lengths */
Event = UtBeginEvent ("Finish AML package length generation");
@@ -800,7 +821,11 @@ CmCleanupAndExit (
/* Final cleanup after compiling one file */
- CmDeleteCaches ();
+ if (!Gbl_DoAslConversion)
+ {
+ CmDeleteCaches ();
+ }
+
}
diff --git a/source/compiler/aslcompiler.h b/source/compiler/aslcompiler.h
index f9fe2a31436f..0b7403f7a808 100644
--- a/source/compiler/aslcompiler.h
+++ b/source/compiler/aslcompiler.h
@@ -576,6 +576,12 @@ void
CgGenerateAmlOutput (
void);
+void
+CgLocalWriteAmlData (
+ ACPI_PARSE_OBJECT *Op,
+ void *Buffer,
+ UINT32 Length);
+
/*
* aslfile
@@ -1359,4 +1365,14 @@ ACPI_STATUS
DtCreateTemplates (
char **argv);
+
+/*
+ * ASL/ASL+ converter debug
+ */
+void
+CvDbgPrint (
+ char *Fmt,
+ ...);
+
+
#endif /* __ASLCOMPILER_H */
diff --git a/source/compiler/aslcompiler.l b/source/compiler/aslcompiler.l
index 5e0d4c12ca14..b609291e19e7 100644
--- a/source/compiler/aslcompiler.l
+++ b/source/compiler/aslcompiler.l
@@ -44,6 +44,7 @@
#include "aslcompiler.h"
#include "aslcompiler.y.h"
+#include "acconvert.h"
#include <stdlib.h>
#include <string.h>
@@ -66,10 +67,10 @@ YYSTYPE AslCompilerlval;
static void
AslDoLineDirective (void);
-static char
+static BOOLEAN
AslDoComment (void);
-static char
+static BOOLEAN
AslDoCommentType2 (void);
static char
diff --git a/source/compiler/asldebug.c b/source/compiler/asldebug.c
index 0178e05ce432..12f3c3475699 100644
--- a/source/compiler/asldebug.c
+++ b/source/compiler/asldebug.c
@@ -60,6 +60,40 @@ UtDumpParseOpName (
/*******************************************************************************
*
+ * FUNCTION: CvDbgPrint
+ *
+ * PARAMETERS: Type - Type of output
+ * Fmt - Printf format string
+ * ... - variable printf list
+ *
+ * RETURN: None
+ *
+ * DESCRIPTION: Print statement for debug messages within the converter.
+ *
+ ******************************************************************************/
+
+void
+CvDbgPrint (
+ char *Fmt,
+ ...)
+{
+ va_list Args;
+
+
+ if (!Gbl_CaptureComments || !AcpiGbl_DebugAslConversion)
+ {
+ return;
+ }
+
+ va_start (Args, Fmt);
+ (void) vfprintf (AcpiGbl_ConvDebugFile, Fmt, Args);
+ va_end (Args);
+ return;
+}
+
+
+/*******************************************************************************
+ *
* FUNCTION: UtDumpIntegerOp
*
* PARAMETERS: Op - Current parse op
diff --git a/source/compiler/asldefine.h b/source/compiler/asldefine.h
index 94ee7c88f819..85ecfc95e08a 100644
--- a/source/compiler/asldefine.h
+++ b/source/compiler/asldefine.h
@@ -159,7 +159,6 @@
/*
* Macros for debug output
*/
-
#define DEBUG_MAX_LINE_LENGTH 61
#define DEBUG_SPACES_PER_INDENT 3
#define DEBUG_FULL_LINE_LENGTH 71
@@ -185,4 +184,11 @@
" %08X %04X %04X %01X %04X %04X %05X %05X "\
"%08X %08X %08X %08X %08X %08X %04X %02d %5d %5d %5d %5d\n"
+/*
+ * Macros for ASL/ASL+ converter
+ */
+#define COMMENT_CAPTURE_ON Gbl_CommentState.CaptureComments = TRUE;
+#define COMMENT_CAPTURE_OFF Gbl_CommentState.CaptureComments = FALSE;
+
+
#endif /* ASLDEFINE.H */
diff --git a/source/compiler/aslfiles.c b/source/compiler/aslfiles.c
index ed067f0f0985..809090cf61a2 100644
--- a/source/compiler/aslfiles.c
+++ b/source/compiler/aslfiles.c
@@ -511,8 +511,14 @@ FlOpenAmlOutputFile (
if (!Filename)
{
/* Create the output AML filename */
-
- Filename = FlGenerateFilename (FilenamePrefix, FILE_SUFFIX_AML_CODE);
+ if (!Gbl_CaptureComments)
+ {
+ Filename = FlGenerateFilename (FilenamePrefix, FILE_SUFFIX_AML_CODE);
+ }
+ else
+ {
+ Filename = FlGenerateFilename (FilenamePrefix, FILE_SUFFIX_CONVERT_AML);
+ }
if (!Filename)
{
AslCommonError (ASL_ERROR, ASL_MSG_OUTPUT_FILENAME,
@@ -854,6 +860,28 @@ FlOpenMiscOutputFiles (
AslCompilerFileHeader (ASL_FILE_NAMESPACE_OUTPUT);
}
+ /* Create a debug file for the converter */
+
+ if (AcpiGbl_DebugAslConversion)
+ {
+ Filename = FlGenerateFilename (FilenamePrefix, FILE_SUFFIX_CONVERT_DEBUG);
+ if (!Filename)
+ {
+ AslCommonError (ASL_ERROR, ASL_MSG_LISTING_FILENAME,
+ 0, 0, 0, 0, NULL, NULL);
+ return (AE_ERROR);
+ }
+
+ /* Open the converter debug file, text mode */
+
+ FlOpenFile (ASL_FILE_CONV_DEBUG_OUTPUT, Filename, "w+t");
+
+ AslCompilerSignon (ASL_FILE_CONV_DEBUG_OUTPUT);
+ AslCompilerFileHeader (ASL_FILE_CONV_DEBUG_OUTPUT);
+
+ AcpiGbl_ConvDebugFile = Gbl_Files[ASL_FILE_CONV_DEBUG_OUTPUT].Handle;
+ }
+
return (AE_OK);
}
diff --git a/source/compiler/aslglobal.h b/source/compiler/aslglobal.h
index c2f4d61bc798..23d1a140b0b3 100644
--- a/source/compiler/aslglobal.h
+++ b/source/compiler/aslglobal.h
@@ -84,7 +84,8 @@ ASL_FILE_INFO Gbl_Files [ASL_NUM_FILES] =
{NULL, NULL, "C Include: ", "C Header Output"},
{NULL, NULL, "Offset Table: ", "C Offset Table Output"},
{NULL, NULL, "Device Map: ", "Device Map Output"},
- {NULL, NULL, "Cross Ref: ", "Cross-reference Output"}
+ {NULL, NULL, "Cross Ref: ", "Cross-reference Output"},
+ {NULL, NULL, "Converter db :", "Converter debug Output"}
};
#else
@@ -113,7 +114,7 @@ extern int AslCompilerdebug;
#define ASL_DEFAULT_LINE_BUFFER_SIZE (1024 * 32) /* 32K */
-#define ASL_MSG_BUFFER_SIZE 4096
+#define ASL_MSG_BUFFER_SIZE (1024 * 32) /* 32k */
#define ASL_MAX_DISABLED_MESSAGES 32
#define HEX_TABLE_LINE_SIZE 8
#define HEX_LISTING_LINE_SIZE 8
@@ -182,6 +183,9 @@ ASL_EXTERN BOOLEAN ASL_INIT_GLOBAL (Gbl_PruneParseTree, FALSE);
ASL_EXTERN BOOLEAN ASL_INIT_GLOBAL (Gbl_DoTypechecking, TRUE);
ASL_EXTERN BOOLEAN ASL_INIT_GLOBAL (Gbl_EnableReferenceTypechecking, FALSE);
ASL_EXTERN BOOLEAN ASL_INIT_GLOBAL (Gbl_DoExternals, TRUE);
+ASL_EXTERN BOOLEAN ASL_INIT_GLOBAL (Gbl_DoExternalsInPlace, FALSE);
+ASL_EXTERN BOOLEAN ASL_INIT_GLOBAL (Gbl_DoAslConversion, FALSE);
+ASL_EXTERN BOOLEAN ASL_INIT_GLOBAL (Gbl_OptimizeTrivialParseNodes, TRUE);
#define HEX_OUTPUT_NONE 0
@@ -265,6 +269,20 @@ ASL_EXTERN char ASL_INIT_GLOBAL (*Gbl_TableId, "NO_ID");
ASL_EXTERN UINT8 ASL_INIT_GLOBAL (Gbl_PruneDepth, 0);
ASL_EXTERN UINT16 ASL_INIT_GLOBAL (Gbl_PruneType, 0);
+ASL_EXTERN ASL_FILE_NODE ASL_INIT_GLOBAL (*Gbl_IncludeFileStack, NULL);
+
+/* Specific to the -q option */
+
+ASL_EXTERN ASL_COMMENT_STATE Gbl_CommentState;
+
+
+/*
+ * Determines if an inline comment should be saved in the InlineComment or NodeEndComment
+ * field of ACPI_PARSE_OBJECT.
+ */
+ASL_EXTERN ACPI_COMMENT_NODE ASL_INIT_GLOBAL (*Gbl_Comment_List_Head, NULL);
+ASL_EXTERN ACPI_COMMENT_NODE ASL_INIT_GLOBAL (*Gbl_Comment_List_Tail, NULL);
+ASL_EXTERN char ASL_INIT_GLOBAL (*Gbl_Inline_Comment_Buffer, NULL);
/* Static structures */
diff --git a/source/compiler/aslhelp.c b/source/compiler/aslhelp.c
index 0a76162d1685..982aa561964b 100644
--- a/source/compiler/aslhelp.c
+++ b/source/compiler/aslhelp.c
@@ -69,9 +69,10 @@ Usage (
ACPI_USAGE_HEADER ("iasl [Options] [Files]");
printf ("\nGeneral:\n");
- ACPI_OPTION ("-@ <file>", "Specify command file");
- ACPI_OPTION ("-I <dir>", "Specify additional include directory");
- ACPI_OPTION ("-p <prefix>", "Specify path/filename prefix for all output files");
+ ACPI_OPTION ("-@ <file>", "Specify command file");
+ ACPI_OPTION ("-I <dir>", "Specify additional include directory");
+ ACPI_OPTION ("-p <prefix>", "Specify path/filename prefix for all output files");
+ ACPI_OPTION ("-ca <file>", "convert a given ASL file to ASL+ (retains comments)");
ACPI_OPTION ("-v", "Display compiler version");
ACPI_OPTION ("-vd", "Display compiler build date and time");
ACPI_OPTION ("-vo", "Enable optimization comments");
@@ -153,6 +154,7 @@ Usage (
ACPI_OPTION ("-vt", "Dump binary table data in hex format within output file");
printf ("\nDebug Options:\n");
+ ACPI_OPTION ("-bc", "Create converter debug file (*.cdb)");
ACPI_OPTION ("-bf", "Create debug file (full output) (*.txt)");
ACPI_OPTION ("-bs", "Create debug file (parse tree only) (*.txt)");
ACPI_OPTION ("-bp <depth>", "Prune ASL parse tree");
diff --git a/source/compiler/asllength.c b/source/compiler/asllength.c
index 73c53910de6c..3f28ea1d7686 100644
--- a/source/compiler/asllength.c
+++ b/source/compiler/asllength.c
@@ -44,6 +44,7 @@
#include "aslcompiler.h"
#include "aslcompiler.y.h"
#include "amlcode.h"
+#include "acconvert.h"
#define _COMPONENT ACPI_COMPILER
@@ -136,7 +137,9 @@ LnPackageLengthWalk (
Op->Asl.AmlLength +
Op->Asl.AmlOpcodeLength +
Op->Asl.AmlPkgLenBytes +
- Op->Asl.AmlSubtreeLength);
+ Op->Asl.AmlSubtreeLength +
+ CvCalculateCommentLengths (Op)
+ );
}
return (AE_OK);
}
diff --git a/source/compiler/aslmap.c b/source/compiler/aslmap.c
index eaa0a7ea3be3..72a0ba9e8e6d 100644
--- a/source/compiler/aslmap.c
+++ b/source/compiler/aslmap.c
@@ -166,7 +166,7 @@ const ASL_MAPPING_ENTRY AslKeywordMapping [] =
/* BITSPERBYTE_SEVEN */ OP_TABLE_ENTRY (AML_BYTE_OP, 2, 0, 0),
/* BITSPERBYTE_SIX */ OP_TABLE_ENTRY (AML_BYTE_OP, 1, 0, 0),
/* BREAK */ OP_TABLE_ENTRY (AML_BREAK_OP, 0, 0, 0),
-/* BREAKPOINT */ OP_TABLE_ENTRY (AML_BREAK_POINT_OP, 0, 0, 0),
+/* BREAKPOINT */ OP_TABLE_ENTRY (AML_BREAKPOINT_OP, 0, 0, 0),
/* BUFFER */ OP_TABLE_ENTRY (AML_BUFFER_OP, 0, NODE_AML_PACKAGE, ACPI_BTYPE_BUFFER),
/* BUSMASTERTYPE_MASTER */ OP_TABLE_ENTRY (AML_BYTE_OP, 1, 0, 0),
/* BUSMASTERTYPE_NOTMASTER */ OP_TABLE_ENTRY (AML_BYTE_OP, 0, 0, 0),
@@ -176,12 +176,12 @@ const ASL_MAPPING_ENTRY AslKeywordMapping [] =
/* CLOCKPHASE_SECOND */ OP_TABLE_ENTRY (AML_BYTE_OP, 1, 0, 0),
/* CLOCKPOLARITY_HIGH */ OP_TABLE_ENTRY (AML_BYTE_OP, 1, 0, 0),
/* CLOCKPOLARITY_LOW */ OP_TABLE_ENTRY (AML_BYTE_OP, 0, 0, 0),
-/* CONCATENATE */ OP_TABLE_ENTRY (AML_CONCAT_OP, 0, 0, ACPI_BTYPE_COMPUTE_DATA),
-/* CONCATENATERESTEMPLATE */ OP_TABLE_ENTRY (AML_CONCAT_RES_OP, 0, 0, ACPI_BTYPE_BUFFER),
-/* CONDREFOF */ OP_TABLE_ENTRY (AML_COND_REF_OF_OP, 0, 0, ACPI_BTYPE_INTEGER),
+/* CONCATENATE */ OP_TABLE_ENTRY (AML_CONCATENATE_OP, 0, 0, ACPI_BTYPE_COMPUTE_DATA),
+/* CONCATENATERESTEMPLATE */ OP_TABLE_ENTRY (AML_CONCATENATE_TEMPLATE_OP,0, 0, ACPI_BTYPE_BUFFER),
+/* CONDREFOF */ OP_TABLE_ENTRY (AML_CONDITIONAL_REF_OF_OP, 0, 0, ACPI_BTYPE_INTEGER),
/* CONNECTION */ OP_TABLE_ENTRY (AML_INT_CONNECTION_OP, 0, 0, 0),
/* CONTINUE */ OP_TABLE_ENTRY (AML_CONTINUE_OP, 0, 0, 0),
-/* COPY */ OP_TABLE_ENTRY (AML_COPY_OP, 0, 0, ACPI_BTYPE_DATA_REFERENCE),
+/* COPYOBJECT */ OP_TABLE_ENTRY (AML_COPY_OBJECT_OP, 0, 0, ACPI_BTYPE_DATA_REFERENCE),
/* CREATEBITFIELD */ OP_TABLE_ENTRY (AML_CREATE_BIT_FIELD_OP, 0, 0, 0),
/* CREATEBYTEFIELD */ OP_TABLE_ENTRY (AML_CREATE_BYTE_FIELD_OP, 0, 0, 0),
/* CREATEDWORDFIELD */ OP_TABLE_ENTRY (AML_CREATE_DWORD_FIELD_OP, 0, 0, 0),
@@ -261,14 +261,14 @@ const ASL_MAPPING_ENTRY AslKeywordMapping [] =
/* IORESTRICT_PRESERVE */ OP_TABLE_ENTRY (AML_BYTE_OP, 3, 0, 0),
/* IRQ */ OP_TABLE_ENTRY (AML_DEFAULT_ARG_OP, 0, 0, 0),
/* IRQNOFLAGS */ OP_TABLE_ENTRY (AML_DEFAULT_ARG_OP, 0, 0, 0),
-/* LAND */ OP_TABLE_ENTRY (AML_LAND_OP, 0, 0, ACPI_BTYPE_INTEGER),
-/* LEQUAL */ OP_TABLE_ENTRY (AML_LEQUAL_OP, 0, 0, ACPI_BTYPE_INTEGER),
-/* LGREATER */ OP_TABLE_ENTRY (AML_LGREATER_OP, 0, 0, ACPI_BTYPE_INTEGER),
-/* LGREATEREQUAL */ OP_TABLE_ENTRY (AML_LGREATEREQUAL_OP, 0, 0, ACPI_BTYPE_INTEGER),
-/* LLESS */ OP_TABLE_ENTRY (AML_LLESS_OP, 0, 0, ACPI_BTYPE_INTEGER),
-/* LLESSEQUAL */ OP_TABLE_ENTRY (AML_LLESSEQUAL_OP, 0, 0, ACPI_BTYPE_INTEGER),
-/* LNOT */ OP_TABLE_ENTRY (AML_LNOT_OP, 0, 0, ACPI_BTYPE_INTEGER),
-/* LNOTEQUAL */ OP_TABLE_ENTRY (AML_LNOTEQUAL_OP, 0, 0, ACPI_BTYPE_INTEGER),
+/* LAND */ OP_TABLE_ENTRY (AML_LOGICAL_AND_OP, 0, 0, ACPI_BTYPE_INTEGER),
+/* LEQUAL */ OP_TABLE_ENTRY (AML_LOGICAL_EQUAL_OP, 0, 0, ACPI_BTYPE_INTEGER),
+/* LGREATER */ OP_TABLE_ENTRY (AML_LOGICAL_GREATER_OP, 0, 0, ACPI_BTYPE_INTEGER),
+/* LGREATEREQUAL */ OP_TABLE_ENTRY (AML_LOGICAL_GREATER_EQUAL_OP,0, 0, ACPI_BTYPE_INTEGER),
+/* LLESS */ OP_TABLE_ENTRY (AML_LOGICAL_LESS_OP, 0, 0, ACPI_BTYPE_INTEGER),
+/* LLESSEQUAL */ OP_TABLE_ENTRY (AML_LOGICAL_LESS_EQUAL_OP, 0, 0, ACPI_BTYPE_INTEGER),
+/* LNOT */ OP_TABLE_ENTRY (AML_LOGICAL_NOT_OP, 0, 0, ACPI_BTYPE_INTEGER),
+/* LNOTEQUAL */ OP_TABLE_ENTRY (AML_LOGICAL_NOT_EQUAL_OP, 0, 0, ACPI_BTYPE_INTEGER),
/* LOAD */ OP_TABLE_ENTRY (AML_LOAD_OP, 0, 0, 0),
/* LOADTABLE */ OP_TABLE_ENTRY (AML_LOAD_TABLE_OP, 0, 0, ACPI_BTYPE_DDB_HANDLE),
/* LOCAL0 */ OP_TABLE_ENTRY (AML_LOCAL0, 0, 0, ACPI_BTYPE_OBJECTS_AND_REFS),
@@ -281,7 +281,7 @@ const ASL_MAPPING_ENTRY AslKeywordMapping [] =
/* LOCAL7 */ OP_TABLE_ENTRY (AML_LOCAL7, 0, 0, ACPI_BTYPE_OBJECTS_AND_REFS),
/* LOCKRULE_LOCK */ OP_TABLE_ENTRY (AML_BYTE_OP, AML_FIELD_LOCK_ALWAYS, 0, 0),
/* LOCKRULE_NOLOCK */ OP_TABLE_ENTRY (AML_BYTE_OP, AML_FIELD_LOCK_NEVER, 0, 0),
-/* LOR */ OP_TABLE_ENTRY (AML_LOR_OP, 0, 0, ACPI_BTYPE_INTEGER),
+/* LOR */ OP_TABLE_ENTRY (AML_LOGICAL_OR_OP, 0, 0, ACPI_BTYPE_INTEGER),
/* MATCH */ OP_TABLE_ENTRY (AML_MATCH_OP, 0, 0, ACPI_BTYPE_INTEGER),
/* MATCHTYPE_MEQ */ OP_TABLE_ENTRY (AML_RAW_DATA_BYTE, MATCH_MEQ, 0, ACPI_BTYPE_INTEGER),
/* MATCHTYPE_MGE */ OP_TABLE_ENTRY (AML_RAW_DATA_BYTE, MATCH_MGE, 0, ACPI_BTYPE_INTEGER),
@@ -347,7 +347,7 @@ const ASL_MAPPING_ENTRY AslKeywordMapping [] =
/* PIN_PULLDEFAULT */ OP_TABLE_ENTRY (AML_BYTE_OP, 0, 0, 0),
/* PIN_PULLDOWN */ OP_TABLE_ENTRY (AML_BYTE_OP, 2, 0, 0),
/* PIN_PULLUP */ OP_TABLE_ENTRY (AML_BYTE_OP, 1, 0, 0),
-/* POWERRESOURCE */ OP_TABLE_ENTRY (AML_POWER_RES_OP, 0, NODE_AML_PACKAGE, 0),
+/* POWERRESOURCE */ OP_TABLE_ENTRY (AML_POWER_RESOURCE_OP, 0, NODE_AML_PACKAGE, 0),
/* PROCESSOR */ OP_TABLE_ENTRY (AML_PROCESSOR_OP, 0, NODE_AML_PACKAGE, 0),
/* QWORDCONST */ OP_TABLE_ENTRY (AML_RAW_DATA_QWORD, 0, 0, ACPI_BTYPE_INTEGER),
/* QWORDIO */ OP_TABLE_ENTRY (AML_BYTE_OP, 0, 0, 0),
@@ -412,8 +412,8 @@ const ASL_MAPPING_ENTRY AslKeywordMapping [] =
/* TIMER */ OP_TABLE_ENTRY (AML_TIMER_OP, 0, 0, ACPI_BTYPE_INTEGER),
/* TOBCD */ OP_TABLE_ENTRY (AML_TO_BCD_OP, 0, 0, ACPI_BTYPE_INTEGER),
/* TOBUFFER */ OP_TABLE_ENTRY (AML_TO_BUFFER_OP, 0, 0, ACPI_BTYPE_BUFFER),
-/* TODECIMALSTRING */ OP_TABLE_ENTRY (AML_TO_DECSTRING_OP, 0, 0, ACPI_BTYPE_STRING),
-/* TOHEXSTRING */ OP_TABLE_ENTRY (AML_TO_HEXSTRING_OP, 0, 0, ACPI_BTYPE_STRING),
+/* TODECIMALSTRING */ OP_TABLE_ENTRY (AML_TO_DECIMAL_STRING_OP, 0, 0, ACPI_BTYPE_STRING),
+/* TOHEXSTRING */ OP_TABLE_ENTRY (AML_TO_HEX_STRING_OP, 0, 0, ACPI_BTYPE_STRING),
/* TOINTEGER */ OP_TABLE_ENTRY (AML_TO_INTEGER_OP, 0, 0, ACPI_BTYPE_INTEGER),
/* TOSTRING */ OP_TABLE_ENTRY (AML_TO_STRING_OP, 0, 0, ACPI_BTYPE_STRING),
/* TOUUID */ OP_TABLE_ENTRY (AML_DWORD_OP, 0, NODE_AML_PACKAGE, ACPI_BTYPE_INTEGER),
@@ -428,7 +428,7 @@ const ASL_MAPPING_ENTRY AslKeywordMapping [] =
/* UPDATERULE_ONES */ OP_TABLE_ENTRY (AML_BYTE_OP, AML_FIELD_UPDATE_WRITE_AS_ONES, 0, 0),
/* UPDATERULE_PRESERVE */ OP_TABLE_ENTRY (AML_BYTE_OP, AML_FIELD_UPDATE_PRESERVE, 0, 0),
/* UPDATERULE_ZEROS */ OP_TABLE_ENTRY (AML_BYTE_OP, AML_FIELD_UPDATE_WRITE_AS_ZEROS,0, 0),
-/* VAR_PACKAGE */ OP_TABLE_ENTRY (AML_VAR_PACKAGE_OP, 0, NODE_AML_PACKAGE, ACPI_BTYPE_PACKAGE),
+/* VARIABLE_PACKAGE */ OP_TABLE_ENTRY (AML_VARIABLE_PACKAGE_OP, 0, NODE_AML_PACKAGE, ACPI_BTYPE_PACKAGE),
/* VENDORLONG */ OP_TABLE_ENTRY (AML_BYTE_OP, 0, 0, 0),
/* VENDORSHORT */ OP_TABLE_ENTRY (AML_BYTE_OP, 0, 0, 0),
/* WAIT */ OP_TABLE_ENTRY (AML_WAIT_OP, 0, 0, ACPI_BTYPE_INTEGER),
diff --git a/source/compiler/asloffset.c b/source/compiler/asloffset.c
index c508f08778d2..3aaab339d33f 100644
--- a/source/compiler/asloffset.c
+++ b/source/compiler/asloffset.c
@@ -185,7 +185,7 @@ LsAmlOffsetWalk (
break;
case AML_PACKAGE_OP:
- case AML_VAR_PACKAGE_OP:
+ case AML_VARIABLE_PACKAGE_OP:
/* Get the package element count */
diff --git a/source/compiler/asloperands.c b/source/compiler/asloperands.c
index ce4b2a239fe5..59900a787b4f 100644
--- a/source/compiler/asloperands.c
+++ b/source/compiler/asloperands.c
@@ -321,7 +321,7 @@ OpnDoFieldCommon (
Next->Asl.ParseOpcode = PARSEOP_DEFAULT_ARG;
PkgLengthNode->Asl.ParseOpcode = PARSEOP_DEFAULT_ARG;
}
- else if (NewBitOffset == CurrentBitOffset)
+ else if ((NewBitOffset == CurrentBitOffset) && Gbl_OptimizeTrivialParseNodes)
{
/*
* Offset is redundant; we don't need to output an
@@ -352,7 +352,8 @@ OpnDoFieldCommon (
CurrentBitOffset += NewBitOffset;
if ((NewBitOffset == 0) &&
- (Next->Asl.ParseOpcode == PARSEOP_RESERVED_BYTES))
+ (Next->Asl.ParseOpcode == PARSEOP_RESERVED_BYTES) &&
+ Gbl_OptimizeTrivialParseNodes)
{
/*
* Unnamed field with a bit length of zero. We can
@@ -1072,7 +1073,7 @@ OpnAttachNameToNode (
case AML_METHOD_OP:
case AML_MUTEX_OP:
case AML_REGION_OP:
- case AML_POWER_RES_OP:
+ case AML_POWER_RESOURCE_OP:
case AML_PROCESSOR_OP:
case AML_THERMAL_ZONE_OP:
case AML_NAME_OP:
diff --git a/source/compiler/asloptions.c b/source/compiler/asloptions.c
index bc167df8eb99..a982143f9f42 100644
--- a/source/compiler/asloptions.c
+++ b/source/compiler/asloptions.c
@@ -68,7 +68,7 @@ AslDoResponseFile (
#define ASL_TOKEN_SEPARATORS " \t\n"
-#define ASL_SUPPORTED_OPTIONS "@:a:b|c|d^D:e:f^gh^i|I:l^m:no|p:P^r:s|t|T+G^v^w|x:z"
+#define ASL_SUPPORTED_OPTIONS "@:a:b|c|d^D:e:f^gh^i|I:l^m:no|p:P^q^r:s|t|T+G^v^w|x:z"
static char ASL_BUILD_DATE[] = __DATE__;
static char ASL_BUILD_TIME[] = __TIME__;
@@ -209,6 +209,24 @@ AslDoOptions (
switch (AcpiGbl_Optarg[0])
{
+
+ case 'c':
+
+ printf ("Debug ASL to ASL+ conversion\n");
+
+ Gbl_DoAslConversion = TRUE;
+ Gbl_FoldConstants = FALSE;
+ Gbl_IntegerOptimizationFlag = FALSE;
+ Gbl_ReferenceOptimizationFlag = FALSE;
+ Gbl_OptimizeTrivialParseNodes = FALSE;
+ Gbl_CaptureComments = TRUE;
+ AcpiGbl_DoDisassemblerOptimizations = FALSE;
+ AcpiGbl_DebugAslConversion = TRUE;
+ AcpiGbl_DmEmitExternalOpcodes = TRUE;
+ Gbl_DoExternalsInPlace = TRUE;
+
+ return (0);
+
case 'f':
AslCompilerdebug = 1; /* same as yydebug */
@@ -260,6 +278,22 @@ AslDoOptions (
switch (AcpiGbl_Optarg[0])
{
+
+ case 'a':
+
+ printf ("Convert ASL to ASL+ with comments\n");
+ Gbl_DoAslConversion = TRUE;
+ Gbl_FoldConstants = FALSE;
+ Gbl_IntegerOptimizationFlag = FALSE;
+ Gbl_ReferenceOptimizationFlag = FALSE;
+ Gbl_OptimizeTrivialParseNodes = FALSE;
+ Gbl_CaptureComments = TRUE;
+ AcpiGbl_DoDisassemblerOptimizations = FALSE;
+ AcpiGbl_DmEmitExternalOpcodes = TRUE;
+ Gbl_DoExternalsInPlace = TRUE;
+
+ return (0);
+
case 'r':
Gbl_NoResourceChecking = TRUE;
@@ -552,6 +586,8 @@ AslDoOptions (
Gbl_FoldConstants = FALSE;
Gbl_IntegerOptimizationFlag = FALSE;
Gbl_ReferenceOptimizationFlag = FALSE;
+ Gbl_OptimizeTrivialParseNodes = FALSE;
+
break;
case 'c':
@@ -570,15 +606,21 @@ AslDoOptions (
case 'e':
- /* iASL: Disable External opcode generation */
-
- Gbl_DoExternals = FALSE;
-
/* Disassembler: Emit embedded external operators */
AcpiGbl_DmEmitExternalOpcodes = TRUE;
break;
+ case 'E':
+
+ /*
+ * iASL: keep External opcodes in place.
+ * No affect if Gbl_DoExternals is false.
+ */
+
+ Gbl_DoExternalsInPlace = TRUE;
+ break;
+
case 'f':
/* Disable folding on "normal" expressions */
@@ -643,6 +685,17 @@ AslDoOptions (
Gbl_UseDefaultAmlFilename = FALSE;
break;
+ case 'q': /* ASL/ASl+ converter: compile only and leave badaml. */
+
+ printf ("Convert ASL to ASL+ with comments\n");
+ Gbl_FoldConstants = FALSE;
+ Gbl_IntegerOptimizationFlag = FALSE;
+ Gbl_ReferenceOptimizationFlag = FALSE;
+ Gbl_OptimizeTrivialParseNodes = FALSE;
+ Gbl_CaptureComments = TRUE;
+ Gbl_DoExternalsInPlace = TRUE;
+ return (0);
+
case 'r': /* Override revision found in table header */
Gbl_RevisionOverride = (UINT8) strtoul (AcpiGbl_Optarg, NULL, 0);
diff --git a/source/compiler/aslprimaries.y b/source/compiler/aslprimaries.y
index eca3dfd71be0..b2c6ca4354bf 100644
--- a/source/compiler/aslprimaries.y
+++ b/source/compiler/aslprimaries.y
@@ -2,6 +2,8 @@ NoEcho('
/******************************************************************************
*
* Module Name: aslprimaries.y - Rules for primary ASL operators
+ * - Keep this file synched with the
+ * CvParseOpBlockType function in cvcompiler.c
*
*****************************************************************************/
@@ -146,9 +148,9 @@ BreakPointTerm
;
BufferTerm
- : PARSEOP_BUFFER {$<n>$ = TrCreateLeafNode (PARSEOP_BUFFER);}
+ : PARSEOP_BUFFER {$<n>$ = TrCreateLeafNode (PARSEOP_BUFFER); COMMENT_CAPTURE_OFF; }
OptionalDataCount
- '{' BufferTermData '}' {$$ = TrLinkChildren ($<n>2,2,$3,$5);}
+ '{' BufferTermData '}' {$$ = TrLinkChildren ($<n>2,2,$3,$5); COMMENT_CAPTURE_ON;}
;
BufferTermData
@@ -403,8 +405,9 @@ ElseIfTerm
ElseTerm
: {$$ = NULL;}
- | PARSEOP_ELSE '{' {$<n>$ = TrCreateLeafNode (PARSEOP_ELSE);}
- TermList '}' {$$ = TrLinkChildren ($<n>3,1,$4);}
+ | PARSEOP_ELSE '{'
+ TermList {$<n>$ = TrCreateLeafNode (PARSEOP_ELSE);}
+ '}' {$$ = TrLinkChildren ($<n>4,1,$3);}
| PARSEOP_ELSE '{'
error '}' {$$ = AslDoError(); yyclearin;}
@@ -545,16 +548,16 @@ FromBCDTerm
FunctionTerm
: PARSEOP_FUNCTION
- PARSEOP_OPEN_PAREN {$<n>$ = TrCreateLeafNode (PARSEOP_METHOD);}
+ PARSEOP_OPEN_PAREN {COMMENT_CAPTURE_OFF; $<n>$ = TrCreateLeafNode (PARSEOP_METHOD); }
NameString
OptionalParameterTypePackage
OptionalParameterTypesPackage
- PARSEOP_CLOSE_PAREN '{'
+ PARSEOP_CLOSE_PAREN '{' {COMMENT_CAPTURE_ON; }
TermList '}' {$$ = TrLinkChildren ($<n>3,7,
TrSetNodeFlags ($4, NODE_IS_NAME_DECLARATION),
TrCreateValuedLeafNode (PARSEOP_BYTECONST, 0),
TrCreateLeafNode (PARSEOP_SERIALIZERULE_NOTSERIAL),
- TrCreateValuedLeafNode (PARSEOP_BYTECONST, 0),$5,$6,$9);}
+ TrCreateValuedLeafNode (PARSEOP_BYTECONST, 0),$5,$6,$10);}
| PARSEOP_FUNCTION
PARSEOP_OPEN_PAREN
error PARSEOP_CLOSE_PAREN {$$ = AslDoError(); yyclearin;}
@@ -778,17 +781,17 @@ MatchTerm
MethodTerm
: PARSEOP_METHOD
- PARSEOP_OPEN_PAREN {$<n>$ = TrCreateLeafNode (PARSEOP_METHOD);}
+ PARSEOP_OPEN_PAREN {$<n>$ = TrCreateLeafNode (PARSEOP_METHOD); COMMENT_CAPTURE_OFF;}
NameString
OptionalByteConstExpr {UtCheckIntegerRange ($5, 0, 7);}
OptionalSerializeRuleKeyword
OptionalByteConstExpr
OptionalParameterTypePackage
OptionalParameterTypesPackage
- PARSEOP_CLOSE_PAREN '{'
+ PARSEOP_CLOSE_PAREN '{' {COMMENT_CAPTURE_ON;}
TermList '}' {$$ = TrLinkChildren ($<n>3,7,
TrSetNodeFlags ($4, NODE_IS_NAME_DECLARATION),
- $5,$7,$8,$9,$10,$13);}
+ $5,$7,$8,$9,$10,$14);}
| PARSEOP_METHOD
PARSEOP_OPEN_PAREN
error PARSEOP_CLOSE_PAREN {$$ = AslDoError(); yyclearin;}
diff --git a/source/compiler/aslprintf.c b/source/compiler/aslprintf.c
index 854e958f2df2..55b40ff55331 100644
--- a/source/compiler/aslprintf.c
+++ b/source/compiler/aslprintf.c
@@ -354,7 +354,7 @@ OpcCreateConcatenateNode (
}
NewConcatOp = TrAllocateNode (PARSEOP_CONCATENATE);
- NewConcatOp->Asl.AmlOpcode = AML_CONCAT_OP;
+ NewConcatOp->Asl.AmlOpcode = AML_CONCATENATE_OP;
NewConcatOp->Asl.AcpiBtype = 0x7;
NewConcatOp->Asl.LogicalLineNumber = Op->Asl.LogicalLineNumber;
diff --git a/source/compiler/aslresources.y b/source/compiler/aslresources.y
index 3425bc0cb617..928319223db5 100644
--- a/source/compiler/aslresources.y
+++ b/source/compiler/aslresources.y
@@ -2,6 +2,8 @@ NoEcho('
/******************************************************************************
*
* Module Name: aslresources.y - Bison/Yacc production rules for resources
+ * - Keep this file synched with the
+ * CvParseOpBlockType function in cvcompiler.c
*
*****************************************************************************/
@@ -56,14 +58,15 @@ NoEcho('
* Also, insert the EndTag at the end of the template.
*/
ResourceTemplateTerm
- : PARSEOP_RESOURCETEMPLATE
+ : PARSEOP_RESOURCETEMPLATE {COMMENT_CAPTURE_OFF;}
OptionalParentheses
'{'
ResourceMacroList '}' {$$ = TrCreateNode (PARSEOP_RESOURCETEMPLATE,4,
TrCreateLeafNode (PARSEOP_DEFAULT_ARG),
TrCreateLeafNode (PARSEOP_DEFAULT_ARG),
- $4,
- TrCreateLeafNode (PARSEOP_ENDTAG));}
+ $5,
+ TrCreateLeafNode (PARSEOP_ENDTAG));
+ COMMENT_CAPTURE_ON;}
;
OptionalParentheses
diff --git a/source/compiler/aslrules.y b/source/compiler/aslrules.y
index 6ef61e2673ee..fa6dbf830609 100644
--- a/source/compiler/aslrules.y
+++ b/source/compiler/aslrules.y
@@ -2,6 +2,8 @@ NoEcho('
/******************************************************************************
*
* Module Name: aslrules.y - Main Bison/Yacc production rules
+ * - Keep this file synched with the
+ * CvParseOpBlockType function in cvcompiler.c
*
*****************************************************************************/
@@ -82,14 +84,14 @@ AslCode
*/
DefinitionBlockTerm
: PARSEOP_DEFINITION_BLOCK
- PARSEOP_OPEN_PAREN {$<n>$ = TrCreateLeafNode (PARSEOP_DEFINITION_BLOCK);}
+ PARSEOP_OPEN_PAREN {$<n>$ = TrCreateLeafNode (PARSEOP_DEFINITION_BLOCK); COMMENT_CAPTURE_OFF;}
String ','
String ','
ByteConst ','
String ','
String ','
DWordConst
- PARSEOP_CLOSE_PAREN {TrSetEndLineNumber ($<n>3);}
+ PARSEOP_CLOSE_PAREN {TrSetEndLineNumber ($<n>3); COMMENT_CAPTURE_ON;}
'{' TermList '}' {$$ = TrLinkChildren ($<n>3,7,
$4,$6,$8,$10,$12,$14,$18);}
;
@@ -177,9 +179,9 @@ TermArg
MethodInvocationTerm
: NameString
- PARSEOP_OPEN_PAREN {TrUpdateNode (PARSEOP_METHODCALL, $1);}
+ PARSEOP_OPEN_PAREN {TrUpdateNode (PARSEOP_METHODCALL, $1); COMMENT_CAPTURE_OFF;}
ArgList
- PARSEOP_CLOSE_PAREN {$$ = TrLinkChildNode ($1,$4);}
+ PARSEOP_CLOSE_PAREN {$$ = TrLinkChildNode ($1,$4); COMMENT_CAPTURE_ON;}
;
/* OptionalCount must appear before ByteList or an incorrect reduction will result */
diff --git a/source/compiler/aslstartup.c b/source/compiler/aslstartup.c
index 99c57c513b66..ff0f2e5eea9f 100644
--- a/source/compiler/aslstartup.c
+++ b/source/compiler/aslstartup.c
@@ -45,6 +45,7 @@
#include "actables.h"
#include "acdisasm.h"
#include "acapps.h"
+#include "acconvert.h"
#define _COMPONENT ACPI_COMPILER
ACPI_MODULE_NAME ("aslstartup")
@@ -123,6 +124,15 @@ AslInitializeGlobals (
Gbl_Files[i].Handle = NULL;
Gbl_Files[i].Filename = NULL;
}
+
+ if (Gbl_CaptureComments)
+ {
+ Gbl_CommentState.SpacesBefore = 0;
+ Gbl_CommentState.CommentType = 1;
+ Gbl_CommentState.Latest_Parse_Node = NULL;
+ Gbl_CommentState.ParsingParenBraceNode = NULL;
+ Gbl_CommentState.CaptureComments = TRUE;
+ }
}
@@ -450,6 +460,28 @@ AslDoOneFile (
AeClearErrorLog ();
PrTerminatePreprocessor ();
+
+ /* ASL-to-ASL+ conversion - Perform immediate disassembly */
+
+ if (Gbl_DoAslConversion)
+ {
+ /*
+ * New input file is the output AML file from above.
+ * New output is from the input ASL file from above.
+ */
+ Gbl_OutputFilenamePrefix = Gbl_Files[ASL_FILE_INPUT].Filename;
+ CvDbgPrint ("OUTPUTFILENAME: %s\n", Gbl_OutputFilenamePrefix);
+ Gbl_Files[ASL_FILE_INPUT].Filename =
+ Gbl_Files[ASL_FILE_AML_OUTPUT].Filename;
+
+ fprintf (stderr, "\n");
+ AslDoDisassembly ();
+
+ /* delete the AML file. This AML file should never be utilized by AML interpreters. */
+
+ FlDeleteFile (ASL_FILE_AML_OUTPUT);
+ }
+
return (AE_OK);
/*
diff --git a/source/compiler/aslsupport.l b/source/compiler/aslsupport.l
index 01b3e0c0b87d..81d739deae3f 100644
--- a/source/compiler/aslsupport.l
+++ b/source/compiler/aslsupport.l
@@ -52,21 +52,12 @@
#define ASL_HEX_CONSTANT 3
-/* File node - used for "Include" operator file stack */
-
-typedef struct asl_file_node
+void
+yyerror (char const *s)
{
- FILE *File;
- UINT32 CurrentLineNumber;
- YY_BUFFER_STATE State;
- char *Filename;
- struct asl_file_node *Next;
-} ASL_FILE_NODE;
-
-/* File stack for the "Include" operator (NOT #include operator) */
-
-ASL_FILE_NODE *Gbl_IncludeFileStack = NULL;
+ AcpiOsPrintf ("YYERROR: %s\n", s);
+}
/*******************************************************************************
@@ -289,6 +280,10 @@ AslPushInputFileStack (
Gbl_CurrentLineNumber = 1;
yyin = InputFile;
+
+ /* converter: reset the comment state to STANDARD_COMMENT */
+
+ Gbl_CommentState.CommentType = STANDARD_COMMENT;
}
@@ -392,6 +387,11 @@ AslInsertLineBuffer (
AslResetCurrentLineBuffer ();
}
+
+ if (Gbl_CaptureComments)
+ {
+ CvProcessCommentState (SourceChar);
+ }
}
}
@@ -459,16 +459,26 @@ count (
*
******************************************************************************/
-static char
+static BOOLEAN
AslDoComment (
void)
{
- int c;
- int c1 = 0;
+ int c;
+ int c1 = 0;
+ char *StringBuffer = MsgBuffer;
+ char *EndBuffer = MsgBuffer + ASL_MSG_BUFFER_SIZE;
+ ASL_COMMENT_STATE CurrentState = Gbl_CommentState; /* to reference later on */
AslInsertLineBuffer ('/');
AslInsertLineBuffer ('*');
+ if (Gbl_CaptureComments && CurrentState.CaptureComments)
+ {
+ *StringBuffer = '/';
+ ++StringBuffer;
+ *StringBuffer = '*';
+ ++StringBuffer;
+ }
loop:
@@ -477,6 +487,11 @@ loop:
while (((c = input ()) != '*') && (c != EOF))
{
AslInsertLineBuffer (c);
+ if (Gbl_CaptureComments && CurrentState.CaptureComments)
+ {
+ *StringBuffer = c;
+ ++StringBuffer;
+ }
c1 = c;
}
@@ -500,10 +515,15 @@ loop:
/* Comment is closed only if the NEXT character is a slash */
AslInsertLineBuffer (c);
+ if (Gbl_CaptureComments && CurrentState.CaptureComments)
+ {
+ *StringBuffer = c;
+ ++StringBuffer;
+ }
if (((c1 = input ()) != '/') && (c1 != EOF))
{
- unput(c1);
+ unput (c1);
goto loop;
}
@@ -511,8 +531,13 @@ loop:
{
goto EarlyEOF;
}
+ if (StringBuffer > EndBuffer)
+ {
+ goto BufferOverflow;
+ }
AslInsertLineBuffer (c1);
+ CvProcessComment (CurrentState, StringBuffer, c1);
return (TRUE);
@@ -525,6 +550,18 @@ EarlyEOF:
Gbl_CurrentLineOffset, Gbl_CurrentColumn,
Gbl_Files[ASL_FILE_INPUT].Filename, NULL);
return (FALSE);
+
+
+BufferOverflow:
+
+ /* Comment was too long */
+
+ AslCommonError (ASL_ERROR, ASL_MSG_STRING_LENGTH,
+ Gbl_CurrentLineNumber, Gbl_LogicalLineNumber,
+ Gbl_CurrentLineOffset, Gbl_CurrentColumn,
+ Gbl_Files[ASL_FILE_INPUT].Filename, "Max length 4096");
+ return (FALSE);
+
}
@@ -536,23 +573,40 @@ EarlyEOF:
*
* RETURN: none
*
- * DESCRIPTION: Process a new "//" comment.
+ * DESCRIPTION: Process a new "//" comment. Inline comments will be converted
+ * to "/ *" standard comments.
*
******************************************************************************/
-static char
+static BOOLEAN
AslDoCommentType2 (
void)
{
- int c;
+ int c;
+ char *StringBuffer = MsgBuffer;
+ char *EndBuffer = MsgBuffer + ASL_MSG_BUFFER_SIZE;
+ ASL_COMMENT_STATE CurrentState = Gbl_CommentState;
AslInsertLineBuffer ('/');
- AslInsertLineBuffer ('/');
+ AslInsertLineBuffer ('*');
+
+ if (Gbl_CaptureComments && CurrentState.CaptureComments)
+ {
+ *StringBuffer = '/';
+ ++StringBuffer;
+ *StringBuffer = '*';
+ ++StringBuffer;
+ }
while (((c = input ()) != '\n') && (c != EOF))
{
AslInsertLineBuffer (c);
+ if (Gbl_CaptureComments && CurrentState.CaptureComments)
+ {
+ *StringBuffer = c;
+ ++StringBuffer;
+ }
}
if (c == EOF)
@@ -562,8 +616,26 @@ AslDoCommentType2 (
c = '\n';
}
+ if (StringBuffer > EndBuffer)
+ {
+ goto BufferOverflow;
+ }
AslInsertLineBuffer (c);
+
+ CvProcessCommentType2 (CurrentState, StringBuffer);
return (TRUE);
+
+
+BufferOverflow:
+
+ /* Comment was too long */
+
+ AslCommonError (ASL_ERROR, ASL_MSG_STRING_LENGTH,
+ Gbl_CurrentLineNumber, Gbl_LogicalLineNumber,
+ Gbl_CurrentLineOffset, Gbl_CurrentColumn,
+ Gbl_Files[ASL_FILE_INPUT].Filename, "Max length 4096");
+ return (FALSE);
+
}
diff --git a/source/compiler/asltree.c b/source/compiler/asltree.c
index 0d59071cf157..c29c404092e4 100644
--- a/source/compiler/asltree.c
+++ b/source/compiler/asltree.c
@@ -44,6 +44,7 @@
#include "aslcompiler.h"
#include "aslcompiler.y.h"
#include "acapps.h"
+#include "acconvert.h"
#include <time.h>
#define _COMPONENT ACPI_COMPILER
@@ -140,6 +141,7 @@ TrAllocateNode (
UINT32 ParseOpcode)
{
ACPI_PARSE_OBJECT *Op;
+ ACPI_PARSE_OBJECT *LatestNode;
Op = TrGetNextNode ();
@@ -152,6 +154,82 @@ TrAllocateNode (
Op->Asl.Column = Gbl_CurrentColumn;
UtSetParseOpName (Op);
+
+ /* The following is for capturing comments */
+
+ if(Gbl_CaptureComments)
+ {
+ LatestNode = Gbl_CommentState.Latest_Parse_Node;
+ Op->Asl.InlineComment = NULL;
+ Op->Asl.EndNodeComment = NULL;
+ Op->Asl.CommentList = NULL;
+ Op->Asl.FileChanged = FALSE;
+
+ /*
+ * Check to see if the file name has changed before resetting the
+ * latest parse node.
+ */
+ if (LatestNode &&
+ (ParseOpcode != PARSEOP_INCLUDE) &&
+ (ParseOpcode != PARSEOP_INCLUDE_END) &&
+ strcmp (LatestNode->Asl.Filename, Op->Asl.Filename))
+ {
+ CvDbgPrint ("latest node: %s\n", LatestNode->Asl.ParseOpName);
+ Op->Asl.FileChanged = TRUE;
+ if (Gbl_IncludeFileStack)
+ {
+ Op->Asl.ParentFilename = Gbl_IncludeFileStack->Filename;
+ }
+ else
+ {
+ Op->Asl.ParentFilename = NULL;
+ }
+ }
+
+ Gbl_CommentState.Latest_Parse_Node = Op;
+ if (Gbl_CommentState.Latest_Parse_Node->Asl.ParseOpName)
+ {
+ CvDbgPrint ("trallocatenode=Set latest parse node to this node.\n");
+ CvDbgPrint (" Op->Asl.ParseOpName = %s\n",
+ Gbl_CommentState.Latest_Parse_Node->Asl.ParseOpName);
+ CvDbgPrint (" Op->Asl.ParseOpcode = 0x%x\n", ParseOpcode);
+
+ if (Op->Asl.FileChanged)
+ {
+ CvDbgPrint(" file has been changed!\n");
+ }
+ }
+
+ /*
+ * if this parse op's syntax uses () and {} (i.e. Package(1){0x00}) then
+ * set a flag in the comment state. This facilitates paring comments for
+ * these types of opcodes.
+ */
+ if ((CvParseOpBlockType(Op) == (BLOCK_PAREN | BLOCK_BRACE)) &&
+ (ParseOpcode != PARSEOP_DEFINITION_BLOCK))
+ {
+ CvDbgPrint ("Parsing paren/Brace node now!\n");
+ Gbl_CommentState.ParsingParenBraceNode = Op;
+ }
+
+ if (Gbl_Comment_List_Head)
+ {
+ CvDbgPrint ("Transferring...\n");
+ Op->Asl.CommentList = Gbl_Comment_List_Head;
+ Gbl_Comment_List_Head = NULL;
+ Gbl_Comment_List_Tail = NULL;
+ CvDbgPrint (" Transferred current comment list to this node.\n");
+ CvDbgPrint (" %s\n", Op->Asl.CommentList->Comment);
+ }
+ if (Gbl_Inline_Comment_Buffer)
+ {
+ Op->Asl.InlineComment = Gbl_Inline_Comment_Buffer;
+ Gbl_Inline_Comment_Buffer = NULL;
+ CvDbgPrint ("Transferred current inline comment list to this node.\n");
+ }
+
+ }
+
return (Op);
}
@@ -294,6 +372,13 @@ TrUpdateNode (
break;
}
+ /* Converter: if this is a method invocation, turn off capture comments. */
+ if (Gbl_CaptureComments &&
+ (ParseOpcode == PARSEOP_METHODCALL))
+ {
+ Gbl_CommentState.CaptureComments = FALSE;
+ }
+
return (Op);
}
@@ -1060,6 +1145,39 @@ TrCreateNode (
{
FirstChild = FALSE;
Op->Asl.Child = Child;
+
+ /*
+ * For the ASL-/ASL+ converter: if the ParseOp is a connection,
+ * external, offset or accessAs, it means that the comments in the
+ * FirstChild belongs to their parent due to the parsing order in
+ * the .y files. To correct this, take the comments in the
+ * FirstChild place it in the parent. This also means that
+ * legitimate comments for the child gets put to the parent.
+ */
+ if (Gbl_CaptureComments &&
+ ((ParseOpcode == PARSEOP_CONNECTION) ||
+ (ParseOpcode == PARSEOP_EXTERNAL) ||
+ (ParseOpcode == PARSEOP_OFFSET) ||
+ (ParseOpcode == PARSEOP_ACCESSAS)))
+ {
+ Op->Asl.CommentList = Child->Asl.CommentList;
+ Op->Asl.EndBlkComment = Child->Asl.EndBlkComment;
+ Op->Asl.InlineComment = Child->Asl.InlineComment;
+ Op->Asl.FileChanged = Child->Asl.FileChanged;
+
+ Child->Asl.CommentList = NULL;
+ Child->Asl.EndBlkComment = NULL;
+ Child->Asl.InlineComment = NULL;
+ Child->Asl.FileChanged = FALSE;
+
+ /*
+ * These do not need to be "passed off". They can be copied
+ * because the code for these opcodes should be printed in the
+ * same file.
+ */
+ Op->Asl.Filename = Child->Asl.Filename;
+ Op->Asl.ParentFilename = Child->Asl.ParentFilename;
+ }
}
/* Point all children to parent */
@@ -1073,6 +1191,18 @@ TrCreateNode (
PrevChild->Asl.Next = Child;
};
+ /* Get the comment from last child in the resource template call */
+
+ if (Gbl_CaptureComments &&
+ (Op->Asl.ParseOpcode == PARSEOP_RESOURCETEMPLATE))
+ {
+ CvDbgPrint ("Transferred current comment list to this node.\n");
+ Op->Asl.CommentList = Child->Asl.CommentList;
+ Child->Asl.CommentList = NULL;
+ Op->Asl.InlineComment = Child->Asl.InlineComment;
+ Child->Asl.InlineComment = NULL;
+ }
+
/*
* This child might be a list, point all nodes in the list
* to the same parent
@@ -1097,9 +1227,9 @@ TrCreateNode (
* FUNCTION: TrLinkChildren
*
* PARAMETERS: Op - An existing parse node
- * NumChildren - Number of children to follow
- * ... - A list of child nodes to link to the new
- * node. NumChildren long.
+ * NumChildren - Number of children to follow
+ * ... - A list of child nodes to link to the new
+ * node. NumChildren long.
*
* RETURN: The updated (linked) node
*
@@ -1161,6 +1291,25 @@ TrLinkChildren (
break;
}
+ /* The following is for capturing comments */
+
+ if(Gbl_CaptureComments)
+ {
+ /*
+ * If there are "regular comments" detected at this point,
+ * then is an endBlk comment. Categorize it as so and distribute
+ * all regular comments to this parse node.
+ */
+ if (Gbl_Comment_List_Head)
+ {
+ Op->Asl.EndBlkComment = Gbl_Comment_List_Head;
+ CvDbgPrint ("EndBlk Comment for %s: %s",
+ Op->Asl.ParseOpName, Gbl_Comment_List_Head->Comment);
+ Gbl_Comment_List_Head = NULL;
+ Gbl_Comment_List_Tail = NULL;
+ }
+ }
+
/* Link the new node to it's children */
PrevChild = NULL;
@@ -1224,6 +1373,13 @@ TrLinkChildren (
va_end(ap);
DbgPrint (ASL_PARSE_OUTPUT, "\n\n");
+
+
+ if(Gbl_CaptureComments)
+ {
+ Gbl_CommentState.Latest_Parse_Node = Op;
+ CvDbgPrint ("trlinkchildren=====Set latest parse node to this node.\n");
+ }
return (Op);
}
@@ -1391,6 +1547,19 @@ TrLinkChildNode (
Op1, Op1 ? UtGetOpName(Op1->Asl.ParseOpcode): NULL,
Op2, Op2 ? UtGetOpName(Op2->Asl.ParseOpcode): NULL);
+ /*
+ * Converter: if TrLinkChildNode is called to link a method call,
+ * turn on capture comments as it signifies that we are done parsing
+ * a method call.
+ */
+ if (Gbl_CaptureComments)
+ {
+ if (Op1->Asl.ParseOpcode == PARSEOP_METHODCALL)
+ {
+ Gbl_CommentState.CaptureComments = TRUE;
+ }
+ Gbl_CommentState.Latest_Parse_Node = Op1;
+ }
if (!Op1 || !Op2)
{
return (Op1);
diff --git a/source/compiler/asltypes.h b/source/compiler/asltypes.h
index bd8376760ca0..e39355ac156a 100644
--- a/source/compiler/asltypes.h
+++ b/source/compiler/asltypes.h
@@ -153,6 +153,10 @@ typedef struct asl_file_status
* Corresponding filename suffixes are in comments
*
* NOTE: Don't move the first 4 file types
+ *
+ * .xxx file extension: this is used as a temporary .aml file for
+ * the ASL/ASL+ converter and is deleted after conversion. This file
+ * should never be used in the interpreter.
*/
typedef enum
{
@@ -173,12 +177,14 @@ typedef enum
ASL_FILE_C_INCLUDE_OUTPUT, /* .h */
ASL_FILE_C_OFFSET_OUTPUT, /* .offset.h */
ASL_FILE_MAP_OUTPUT, /* .map */
- ASL_FILE_XREF_OUTPUT /* .xrf */
+ ASL_FILE_XREF_OUTPUT, /* .xrf */
+ ASL_FILE_CONV_DEBUG_OUTPUT, /* .cdb */
+ ASL_FILE_CONV_OUTPUT /* .xxx */
} ASL_FILE_TYPES;
-#define ASL_MAX_FILE_TYPE 17
+#define ASL_MAX_FILE_TYPE 18
#define ASL_NUM_FILES (ASL_MAX_FILE_TYPE + 1)
/* Name suffixes used to create filenames for output files */
@@ -199,6 +205,8 @@ typedef enum
#define FILE_SUFFIX_C_OFFSET "offset.h"
#define FILE_SUFFIX_MAP "map"
#define FILE_SUFFIX_XREF "xrf"
+#define FILE_SUFFIX_CONVERT_AML "xxx"
+#define FILE_SUFFIX_CONVERT_DEBUG "cdb"
/* Cache block structure for ParseOps and Strings */
@@ -336,4 +344,15 @@ typedef struct asl_xref_info
} ASL_XREF_INFO;
+typedef struct yy_buffer_state *YY_BUFFER_STATE;
+typedef struct asl_file_node
+{
+ FILE *File;
+ UINT32 CurrentLineNumber;
+ YY_BUFFER_STATE State;
+ char *Filename;
+ struct asl_file_node *Next;
+
+} ASL_FILE_NODE;
+
#endif /* __ASLTYPES_H */
diff --git a/source/compiler/aslwalks.c b/source/compiler/aslwalks.c
index c32041ceaa4c..bb83d167828d 100644
--- a/source/compiler/aslwalks.c
+++ b/source/compiler/aslwalks.c
@@ -317,7 +317,7 @@ AnOperandTypecheckWalkEnd (
case AML_BUFFER_OP:
case AML_PACKAGE_OP:
- case AML_VAR_PACKAGE_OP:
+ case AML_VARIABLE_PACKAGE_OP:
/* If length is a constant, we are done */
diff --git a/source/compiler/cvcompiler.c b/source/compiler/cvcompiler.c
new file mode 100644
index 000000000000..07fecc37872c
--- /dev/null
+++ b/source/compiler/cvcompiler.c
@@ -0,0 +1,890 @@
+/******************************************************************************
+ *
+ * Module Name: cvcompiler - ASL-/ASL+ converter functions
+ *
+ *****************************************************************************/
+
+/*
+ * Copyright (C) 2000 - 2017, Intel Corp.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions, and the following disclaimer,
+ * without modification.
+ * 2. Redistributions in binary form must reproduce at minimum a disclaimer
+ * substantially similar to the "NO WARRANTY" disclaimer below
+ * ("Disclaimer") and any redistribution must be conditioned upon
+ * including a substantially similar Disclaimer requirement for further
+ * binary redistribution.
+ * 3. Neither the names of the above-listed copyright holders nor the names
+ * of any contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * Alternatively, this software may be distributed under the terms of the
+ * GNU General Public License ("GPL") version 2 as published by the Free
+ * Software Foundation.
+ *
+ * NO WARRANTY
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
+ * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGES.
+ */
+
+#include "aslcompiler.h"
+#include "aslcompiler.y.h"
+#include "amlcode.h"
+#include "acapps.h"
+#include "acconvert.h"
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: CvProcessComment
+ *
+ * PARAMETERS: CurrentState Current comment parse state
+ * StringBuffer Buffer containing the comment being processed
+ * c1 Current input
+ *
+ * RETURN: none
+ *
+ * DESCRIPTION: Process a single line comment of a c Style comment. This
+ * function captures a line of a c style comment in a char* and
+ * places the comment in the approperiate global buffer.
+ *
+ ******************************************************************************/
+
+void
+CvProcessComment (
+ ASL_COMMENT_STATE CurrentState,
+ char *StringBuffer,
+ int c1)
+{
+ UINT64 i;
+ char *LineToken;
+ char *FinalLineToken;
+ BOOLEAN CharStart;
+ char *CommentString;
+ char *FinalCommentString;
+
+
+ if (Gbl_CaptureComments && CurrentState.CaptureComments)
+ {
+ *StringBuffer = (char) c1;
+ ++StringBuffer;
+ *StringBuffer = 0;
+ CvDbgPrint ("Multi-line comment\n");
+ CommentString = UtStringCacheCalloc (strlen (MsgBuffer) + 1);
+ strcpy (CommentString, MsgBuffer);
+
+ CvDbgPrint ("CommentString: %s\n", CommentString);
+
+ /*
+ * Determine whether if this comment spans multiple lines.
+ * If so, break apart the comment by line so that it can be
+ * properly indented.
+ */
+ if (strchr (CommentString, '\n') != NULL)
+ {
+ /*
+ * Get the first token. The for loop pads subsequent lines
+ * for comments similar to the style of this comment.
+ */
+ LineToken = strtok (CommentString, "\n");
+ FinalLineToken = UtStringCacheCalloc (strlen (LineToken) + 1);
+ strcpy (FinalLineToken, LineToken);
+
+ /* Get rid of any carriage returns */
+
+ if (FinalLineToken[strlen (FinalLineToken) - 1] == 0x0D)
+ {
+ FinalLineToken[strlen(FinalLineToken)-1] = 0;
+ }
+ CvAddToCommentList (FinalLineToken);
+ LineToken = strtok (NULL, "\n");
+ while (LineToken != NULL)
+ {
+ /*
+ * It is assumed that each line has some sort of indentation.
+ * This means that we need to find the first character that is not
+ * a white space within each line.
+ */
+ CharStart = FALSE;
+ for (i = 0; (i < (strlen (LineToken) + 1)) && !CharStart; i++)
+ {
+ if (LineToken[i] != ' ' && LineToken[i] != '\t')
+ {
+ CharStart = TRUE;
+ LineToken += i-1;
+ LineToken [0] = ' '; /* Pad for Formatting */
+ }
+ }
+ FinalLineToken = UtStringCacheCalloc (strlen (LineToken) + 1);
+ strcat (FinalLineToken, LineToken);
+
+ /* Get rid of any carriage returns */
+
+ if (FinalLineToken[strlen (FinalLineToken) - 1] == 0x0D)
+ {
+ FinalLineToken[strlen(FinalLineToken) - 1] = 0;
+ }
+ CvAddToCommentList (FinalLineToken);
+ LineToken = strtok (NULL,"\n");
+ }
+ }
+
+ /*
+ * If this only spans a single line, check to see whether if this comment
+ * appears on the same line as a line of code. If does, retain it's
+ * position for stylistic reasons. If it doesn't, add it to the comment
+ * List so that it can be associated with the next node that's created.
+ */
+ else
+ {
+ /*
+ * if this is not a regular comment, pad with extra spaces that appeared
+ * in the original source input to retain the original spacing.
+ */
+ FinalCommentString = UtStringCacheCalloc (strlen (CommentString) + CurrentState.SpacesBefore + 1);
+ for (i=0; (CurrentState.CommentType != ASL_COMMENT_STANDARD) &&
+ (i < CurrentState.SpacesBefore); ++i)
+ {
+ FinalCommentString[i] = ' ';
+ }
+ strcat (FinalCommentString, CommentString);
+ CvPlaceComment (CurrentState.CommentType, FinalCommentString);
+ }
+ }
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: CvProcessCommentType2
+ *
+ * PARAMETERS: CurrentState Current comment parse state
+ * StringBuffer Buffer containing the comment being processed
+ *
+ * RETURN: none
+ *
+ * DESCRIPTION: Process a single line comment. This function captures a comment
+ * in a char* and places the comment in the approperiate global
+ * buffer through CvPlaceComment
+ *
+ ******************************************************************************/
+
+void
+CvProcessCommentType2 (
+ ASL_COMMENT_STATE CurrentState,
+ char *StringBuffer)
+{
+ UINT32 i;
+ char *CommentString;
+ char *FinalCommentString;
+
+
+ if (Gbl_CaptureComments && CurrentState.CaptureComments)
+ {
+ *StringBuffer = 0; /* null terminate */
+ CvDbgPrint ("Single-line comment\n");
+ CommentString = UtStringCacheCalloc (strlen (MsgBuffer) + 1);
+ strcpy (CommentString, MsgBuffer);
+
+ /* If this comment lies on the same line as the latest parse node,
+ * assign it to that node's CommentAfter field. Saving in this field
+ * will allow us to support comments that come after code on the same
+ * line as the code itself. For example,
+ * Name(A,"") //comment
+ *
+ * will be retained rather than transformed into
+ *
+ * Name(A,"")
+ * //comment
+ *
+ * For this case, we only need to add one comment since
+ *
+ * Name(A,"") //comment1 //comment2 ... more comments here.
+ *
+ * would be lexically analyzed as a single comment.
+ *
+ * Create a new string with the approperiate spaces. Since we need
+ * to account for the proper spacing, the actual comment,
+ * extra 2 spaces so that this comment can be converted to the "/ *"
+ * style and the null terminator, the string would look something like
+ *
+ * [ (spaces) (comment) ( * /) ('\0') ]
+ *
+ */
+ FinalCommentString = UtStringCacheCalloc (CurrentState.SpacesBefore + strlen (CommentString) + 3 + 1);
+ for (i=0; (CurrentState.CommentType!=1) && (i<CurrentState.SpacesBefore); ++i)
+ {
+ FinalCommentString[i] = ' ';
+ }
+ strcat (FinalCommentString, CommentString);
+
+ /* convert to a "/ *" style comment */
+
+ strcat (FinalCommentString, " */");
+ FinalCommentString [CurrentState.SpacesBefore + strlen (CommentString) + 3] = 0;
+
+ /* get rid of the carriage return */
+
+ if (FinalCommentString[strlen (FinalCommentString) - 1] == 0x0D)
+ {
+ FinalCommentString[strlen(FinalCommentString)-1] = 0;
+ }
+ CvPlaceComment (CurrentState.CommentType, FinalCommentString);
+ }
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: CgCalculateCommentLengths
+ *
+ * PARAMETERS: Op - Calculate all comments of this Op
+ *
+ * RETURN: TotalCommentLength - Length of all comments within this node.
+ *
+ * DESCRIPTION: calculate the length that the each comment takes up within Op.
+ * Comments look like the follwoing: [0xA9 OptionBtye comment 0x00]
+ * therefore, we add 1 + 1 + strlen (comment) + 1 to get the actual
+ * length of this comment.
+ *
+ ******************************************************************************/
+
+UINT32
+CvCalculateCommentLengths(
+ ACPI_PARSE_OBJECT *Op)
+{
+ UINT32 CommentLength = 0;
+ UINT32 TotalCommentLength = 0;
+ ACPI_COMMENT_NODE *Current = NULL;
+
+
+ if (!Gbl_CaptureComments)
+ {
+ return (0);
+ }
+
+ CvDbgPrint ("==Calculating comment lengths for %s\n", Op->Asl.ParseOpName);
+ if (Op->Asl.FileChanged)
+ {
+ TotalCommentLength += strlen (Op->Asl.Filename) + 3;
+
+ if (Op->Asl.ParentFilename &&
+ AcpiUtStricmp (Op->Asl.Filename, Op->Asl.ParentFilename))
+ {
+ TotalCommentLength += strlen (Op->Asl.ParentFilename) + 3;
+ }
+ }
+ if (Op->Asl.CommentList)
+ {
+ Current = Op->Asl.CommentList;
+ while (Current)
+ {
+ CommentLength = strlen (Current->Comment)+3;
+ CvDbgPrint ("Length of standard comment: %d\n", CommentLength);
+ CvDbgPrint (" Comment string: %s\n\n", Current->Comment);
+ TotalCommentLength += CommentLength;
+ Current = Current->Next;
+ }
+ }
+ if (Op->Asl.EndBlkComment)
+ {
+ Current = Op->Asl.EndBlkComment;
+ while (Current)
+ {
+ CommentLength = strlen (Current->Comment)+3;
+ CvDbgPrint ("Length of endblkcomment: %d\n", CommentLength);
+ CvDbgPrint (" Comment string: %s\n\n", Current->Comment);
+ TotalCommentLength += CommentLength;
+ Current = Current->Next;
+ }
+ }
+ if (Op->Asl.InlineComment)
+ {
+ CommentLength = strlen (Op->Asl.InlineComment)+3;
+ CvDbgPrint ("Length of inline comment: %d\n", CommentLength);
+ CvDbgPrint (" Comment string: %s\n\n", Op->Asl.InlineComment);
+ TotalCommentLength += CommentLength;
+ }
+ if (Op->Asl.EndNodeComment)
+ {
+ CommentLength = strlen(Op->Asl.EndNodeComment)+3;
+ CvDbgPrint ("Length of end node comment +3: %d\n", CommentLength);
+ CvDbgPrint (" Comment string: %s\n\n", Op->Asl.EndNodeComment);
+ TotalCommentLength += CommentLength;
+ }
+
+ if (Op->Asl.CloseBraceComment)
+ {
+ CommentLength = strlen (Op->Asl.CloseBraceComment)+3;
+ CvDbgPrint ("Length of close brace comment: %d\n", CommentLength);
+ CvDbgPrint (" Comment string: %s\n\n", Op->Asl.CloseBraceComment);
+ TotalCommentLength += CommentLength;
+ }
+
+ CvDbgPrint("\n\n");
+
+ return TotalCommentLength;
+
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: CgWriteAmlDefBlockComment
+ *
+ * PARAMETERS: Op - Current parse op
+ *
+ * RETURN: None
+ *
+ * DESCRIPTION: Write all comments for a particular definition block.
+ * For definition blocks, the comments need to come after the
+ * definition block header. The regular comments above the
+ * definition block would be categorized as
+ * STD_DEFBLK_COMMENT and comments after the closing brace
+ * is categorized as END_DEFBLK_COMMENT.
+ *
+ ******************************************************************************/
+
+void
+CgWriteAmlDefBlockComment(
+ ACPI_PARSE_OBJECT *Op)
+{
+ UINT8 CommentOption;
+ ACPI_COMMENT_NODE *Current;
+ char *NewFilename;
+ char *Position;
+ char *DirectoryPosition;
+
+
+ if (!Gbl_CaptureComments ||
+ (Op->Asl.ParseOpcode != PARSEOP_DEFINITION_BLOCK))
+ {
+ return;
+ }
+
+ CvDbgPrint ("Printing comments for a definition block..\n");
+
+ /* first, print the file name comment after changing .asl to .dsl */
+
+ NewFilename = UtStringCacheCalloc (strlen (Op->Asl.Filename));
+ strcpy (NewFilename, Op->Asl.Filename);
+ DirectoryPosition = strrchr (NewFilename, '/');
+ Position = strrchr (NewFilename, '.');
+
+ if (Position && (Position > DirectoryPosition))
+ {
+ /* Tack on the new suffix */
+
+ Position++;
+ *Position = 0;
+ strcat (Position, FILE_SUFFIX_DISASSEMBLY);
+ }
+ else
+ {
+ /* No dot, add one and then the suffix */
+
+ strcat (NewFilename, ".");
+ strcat (NewFilename, FILE_SUFFIX_DISASSEMBLY);
+ }
+
+ CommentOption = FILENAME_COMMENT;
+ CgWriteOneAmlComment(Op, NewFilename, CommentOption);
+
+ Current = Op->Asl.CommentList;
+ CommentOption = STD_DEFBLK_COMMENT;
+ while (Current)
+ {
+ CgWriteOneAmlComment(Op, Current->Comment, CommentOption);
+ CvDbgPrint ("Printing comment: %s\n", Current->Comment);
+ Current = Current->Next;
+ }
+ Op->Asl.CommentList = NULL;
+
+ /* print any Inline comments associated with this node */
+
+ if (Op->Asl.CloseBraceComment)
+ {
+ CommentOption = END_DEFBLK_COMMENT;
+ CgWriteOneAmlComment(Op, Op->Asl.CloseBraceComment, CommentOption);
+ Op->Asl.CloseBraceComment = NULL;
+ }
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: CgWriteOneAmlComment
+ *
+ * PARAMETERS: Op - Current parse op
+ * CommentToPrint - Comment that's printed
+ * InputOption - Denotes the comment option.
+ *
+ * RETURN: None
+ *
+ * DESCRIPTION: write a single comment.
+ *
+ ******************************************************************************/
+
+void
+CgWriteOneAmlComment(
+ ACPI_PARSE_OBJECT *Op,
+ char* CommentToPrint,
+ UINT8 InputOption)
+{
+ UINT8 CommentOption = InputOption;
+ UINT8 CommentOpcode = (UINT8)AML_COMMENT_OP;
+
+ CgLocalWriteAmlData (Op, &CommentOpcode, 1);
+ CgLocalWriteAmlData (Op, &CommentOption, 1);
+
+ /* The strlen (..) + 1 is to include the null terminator */
+
+ CgLocalWriteAmlData (Op, CommentToPrint, strlen (CommentToPrint) + 1);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: CgWriteAmlComment
+ *
+ * PARAMETERS: Op - Current parse op
+ *
+ * RETURN: None
+ *
+ * DESCRIPTION: write all comments pertaining to the
+ * current parse op
+ *
+ ******************************************************************************/
+
+void
+CgWriteAmlComment(
+ ACPI_PARSE_OBJECT *Op)
+{
+ ACPI_COMMENT_NODE *Current;
+ UINT8 CommentOption;
+ char *NewFilename;
+ char *ParentFilename;
+
+
+ if ((Op->Asl.ParseOpcode == PARSEOP_DEFINITION_BLOCK) ||
+ !Gbl_CaptureComments)
+ {
+ return;
+ }
+
+ /* Print out the filename comment if needed */
+
+ if (Op->Asl.FileChanged)
+ {
+
+ /* first, print the file name comment after changing .asl to .dsl */
+
+ NewFilename =
+ FlGenerateFilename (Op->Asl.Filename, FILE_SUFFIX_DISASSEMBLY);
+ CvDbgPrint ("Writing file comment, \"%s\" for %s\n",
+ NewFilename, Op->Asl.ParseOpName);
+ CgWriteOneAmlComment(Op, NewFilename, FILENAME_COMMENT);
+
+ if (Op->Asl.ParentFilename &&
+ AcpiUtStricmp (Op->Asl.ParentFilename, Op->Asl.Filename))
+ {
+ ParentFilename = FlGenerateFilename (Op->Asl.ParentFilename,
+ FILE_SUFFIX_DISASSEMBLY);
+ CgWriteOneAmlComment(Op, ParentFilename, PARENTFILENAME_COMMENT);
+ }
+
+ /* prevent multiple writes of the same comment */
+
+ Op->Asl.FileChanged = FALSE;
+ }
+
+ /*
+ * Regular comments are stored in a list of comments within an Op.
+ * If there is a such list in this node, print out the comment
+ * as byte code.
+ */
+ Current = Op->Asl.CommentList;
+ if (Op->Asl.ParseOpcode == PARSEOP_INCLUDE)
+ {
+ CommentOption = INCLUDE_COMMENT;
+ }
+ else
+ {
+ CommentOption = STANDARD_COMMENT;
+ }
+
+ while (Current)
+ {
+ CgWriteOneAmlComment(Op, Current->Comment, CommentOption);
+ Current = Current->Next;
+ }
+ Op->Asl.CommentList = NULL;
+
+ Current = Op->Asl.EndBlkComment;
+ CommentOption = ENDBLK_COMMENT;
+ while (Current)
+ {
+ CgWriteOneAmlComment(Op, Current->Comment, CommentOption);
+ Current = Current->Next;
+ }
+ Op->Asl.EndBlkComment = NULL;
+
+ /* print any Inline comments associated with this node */
+
+ if (Op->Asl.InlineComment)
+ {
+ CommentOption = INLINE_COMMENT;
+ CgWriteOneAmlComment(Op, Op->Asl.InlineComment, CommentOption);
+ Op->Asl.InlineComment = NULL;
+ }
+
+ if (Op->Asl.EndNodeComment)
+ {
+ CommentOption = ENDNODE_COMMENT;
+ CgWriteOneAmlComment(Op, Op->Asl.EndNodeComment, CommentOption);
+ Op->Asl.EndNodeComment = NULL;
+ }
+
+ if (Op->Asl.CloseBraceComment)
+ {
+ CommentOption = CLOSE_BRACE_COMMENT;
+ CgWriteOneAmlComment(Op, Op->Asl.CloseBraceComment, CommentOption);
+ Op->Asl.CloseBraceComment = NULL;
+ }
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: CvCommentNodeCalloc
+ *
+ * PARAMETERS: none
+ *
+ * RETURN: Pointer to the comment node. Aborts on allocation failure
+ *
+ * DESCRIPTION: Allocate a string node buffer.
+ *
+ ******************************************************************************/
+
+ACPI_COMMENT_NODE*
+CvCommentNodeCalloc (
+ void)
+{
+ ACPI_COMMENT_NODE *NewCommentNode;
+
+
+ NewCommentNode =
+ (ACPI_COMMENT_NODE*) UtLocalCalloc (sizeof(ACPI_COMMENT_NODE));
+ NewCommentNode->Next = NULL;
+ return NewCommentNode;
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: CvParseOpBlockType
+ *
+ * PARAMETERS: Op - Object to be examined
+ *
+ * RETURN: BlockType - not a block, parens, braces, or even both.
+ *
+ * DESCRIPTION: Type of block for this ASL parseop (parens or braces)
+ * keep this in sync with aslprimaries.y, aslresources.y and
+ * aslrules.y
+ *
+ ******************************************************************************/
+
+UINT32
+CvParseOpBlockType (
+ ACPI_PARSE_OBJECT *Op)
+{
+ if (!Op)
+ {
+ return (BLOCK_NONE);
+ }
+
+ switch (Op->Asl.ParseOpcode)
+ {
+
+ /* from aslprimaries.y */
+
+ case PARSEOP_VAR_PACKAGE:
+ case PARSEOP_BANKFIELD:
+ case PARSEOP_BUFFER:
+ case PARSEOP_CASE:
+ case PARSEOP_DEVICE:
+ case PARSEOP_FIELD:
+ case PARSEOP_FOR:
+ case PARSEOP_FUNCTION:
+ case PARSEOP_IF:
+ case PARSEOP_ELSEIF:
+ case PARSEOP_INDEXFIELD:
+ case PARSEOP_METHOD:
+ case PARSEOP_POWERRESOURCE:
+ case PARSEOP_PROCESSOR:
+ case PARSEOP_DATABUFFER:
+ case PARSEOP_SCOPE:
+ case PARSEOP_SWITCH:
+ case PARSEOP_THERMALZONE:
+ case PARSEOP_WHILE:
+
+ /* from aslresources.y */
+
+ case PARSEOP_RESOURCETEMPLATE: /* optional parens */
+ case PARSEOP_VENDORLONG:
+ case PARSEOP_VENDORSHORT:
+ case PARSEOP_INTERRUPT:
+ case PARSEOP_IRQNOFLAGS:
+ case PARSEOP_IRQ:
+ case PARSEOP_GPIO_INT:
+ case PARSEOP_GPIO_IO:
+ case PARSEOP_DMA:
+
+ /*from aslrules.y */
+
+ case PARSEOP_DEFINITION_BLOCK:
+ return (BLOCK_PAREN | BLOCK_BRACE);
+
+ default:
+
+ return (BLOCK_NONE);
+ }
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: CvProcessCommentState
+ *
+ * PARAMETERS: char
+ *
+ * RETURN: None
+ *
+ * DESCRIPTION: Take the given input. If this character is
+ * defined as a comment table entry, then update the state
+ * accordingly.
+ *
+ ******************************************************************************/
+
+void
+CvProcessCommentState (
+ char input)
+{
+
+ if (input != ' ')
+ {
+ Gbl_CommentState.SpacesBefore = 0;
+ }
+
+ switch (input)
+ {
+ case '\n':
+
+ Gbl_CommentState.CommentType = ASL_COMMENT_STANDARD;
+ break;
+
+ case ' ':
+
+ /* Keep the CommentType the same */
+
+ Gbl_CommentState.SpacesBefore++;
+ break;
+
+ case '(':
+
+ Gbl_CommentState.CommentType = ASL_COMMENT_OPEN_PAREN;
+ break;
+
+ case ')':
+
+ Gbl_CommentState.CommentType = ASL_COMMENT_CLOSE_PAREN;
+ break;
+
+ case '{':
+
+ Gbl_CommentState.CommentType = ASL_COMMENT_STANDARD;
+ Gbl_CommentState.ParsingParenBraceNode = NULL;
+ CvDbgPrint ("End Parsing paren/Brace node!\n");
+ break;
+
+ case '}':
+
+ Gbl_CommentState.CommentType = ASL_COMMENT_CLOSE_BRACE;
+ break;
+
+ case ',':
+
+ Gbl_CommentState.CommentType = ASLCOMMENT_INLINE;
+ break;
+
+ default:
+
+ Gbl_CommentState.CommentType = ASLCOMMENT_INLINE;
+ break;
+
+ }
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: CvAddToCommentList
+ *
+ * PARAMETERS: toAdd - Contains the comment to be inserted
+ *
+ * RETURN: None
+ *
+ * DESCRIPTION: Add the given char* to a list of comments in the global list
+ * of comments.
+ *
+ ******************************************************************************/
+
+void
+CvAddToCommentList (
+ char* ToAdd)
+{
+ if (Gbl_Comment_List_Head)
+ {
+ Gbl_Comment_List_Tail->Next = CvCommentNodeCalloc ();
+ Gbl_Comment_List_Tail = Gbl_Comment_List_Tail->Next;
+ }
+ else
+ {
+ Gbl_Comment_List_Head = CvCommentNodeCalloc ();
+ Gbl_Comment_List_Tail = Gbl_Comment_List_Head;
+ }
+
+ Gbl_Comment_List_Tail->Comment = ToAdd;
+
+ return;
+}
+
+/*******************************************************************************
+ *
+ * FUNCTION: CvAppendInlineComment
+ *
+ * PARAMETERS: InlineComment - Append to the end of this string.
+ * toAdd - Contains the comment to be inserted
+ *
+ * RETURN: Str - toAdd appended to InlineComment
+ *
+ * DESCRIPTION: Concatenate ToAdd to InlineComment
+ *
+ ******************************************************************************/
+
+char*
+CvAppendInlineComment (
+ char *InlineComment,
+ char *ToAdd)
+{
+ char* Str;
+ UINT32 Size = 0;
+
+
+ if (!InlineComment)
+ {
+ return ToAdd;
+ }
+ if (ToAdd)
+ {
+ Size = strlen (ToAdd);
+ }
+ Size += strlen (InlineComment);
+ Str = UtStringCacheCalloc (Size+1);
+ strcpy (Str, InlineComment);
+ strcat (Str, ToAdd);
+ Str[Size+1] = 0;
+
+ return Str;
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: CvPlaceComment
+ *
+ * PARAMETERS: Int - Type
+ * char* - CommentString
+ *
+ * RETURN: None
+ *
+ * DESCRIPTION: Given type and CommentString, this function places the
+ * CommentString in the approperiate global comment list or char*
+ *
+ ******************************************************************************/
+
+void
+CvPlaceComment(
+ UINT8 Type,
+ char *CommentString)
+{
+ ACPI_PARSE_OBJECT *LatestParseNode;
+ ACPI_PARSE_OBJECT *ParenBraceNode;
+
+
+ LatestParseNode = Gbl_CommentState.Latest_Parse_Node;
+ ParenBraceNode = Gbl_CommentState.ParsingParenBraceNode;
+ CvDbgPrint ("Placing comment %s for type %d\n", CommentString, Type);
+
+ switch (Type)
+ {
+ case ASL_COMMENT_STANDARD:
+
+ CvAddToCommentList (CommentString);
+ break;
+
+ case ASLCOMMENT_INLINE:
+
+ LatestParseNode->Asl.InlineComment =
+ CvAppendInlineComment (LatestParseNode->Asl.InlineComment,
+ CommentString);
+ break;
+
+ case ASL_COMMENT_OPEN_PAREN:
+
+ Gbl_Inline_Comment_Buffer =
+ CvAppendInlineComment(Gbl_Inline_Comment_Buffer,
+ CommentString);
+ break;
+
+ case ASL_COMMENT_CLOSE_PAREN:
+
+ if (ParenBraceNode)
+ {
+ ParenBraceNode->Asl.EndNodeComment =
+ CvAppendInlineComment (ParenBraceNode->Asl.EndNodeComment,
+ CommentString);
+ }
+ else
+ {
+ LatestParseNode->Asl.EndNodeComment =
+ CvAppendInlineComment (LatestParseNode->Asl.EndNodeComment,
+ CommentString);
+ }
+ break;
+
+ case ASL_COMMENT_CLOSE_BRACE:
+
+ LatestParseNode->Asl.CloseBraceComment = CommentString;
+ break;
+
+ default:
+
+ break;
+
+ }
+}
diff --git a/source/compiler/cvdisasm.c b/source/compiler/cvdisasm.c
new file mode 100644
index 000000000000..e688e85ffedc
--- /dev/null
+++ b/source/compiler/cvdisasm.c
@@ -0,0 +1,423 @@
+/******************************************************************************
+ *
+ * Module Name: cvcompiler - ASL-/ASL+ converter functions
+ *
+ *****************************************************************************/
+
+/*
+ * Copyright (C) 2000 - 2017, Intel Corp.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions, and the following disclaimer,
+ * without modification.
+ * 2. Redistributions in binary form must reproduce at minimum a disclaimer
+ * substantially similar to the "NO WARRANTY" disclaimer below
+ * ("Disclaimer") and any redistribution must be conditioned upon
+ * including a substantially similar Disclaimer requirement for further
+ * binary redistribution.
+ * 3. Neither the names of the above-listed copyright holders nor the names
+ * of any contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * Alternatively, this software may be distributed under the terms of the
+ * GNU General Public License ("GPL") version 2 as published by the Free
+ * Software Foundation.
+ *
+ * NO WARRANTY
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
+ * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGES.
+ */
+
+#include "aslcompiler.h"
+#include "acparser.h"
+#include "amlcode.h"
+#include "acdebug.h"
+#include "acconvert.h"
+
+
+static void
+CvPrintInclude(
+ ACPI_FILE_NODE *FNode,
+ UINT32 Level);
+
+static BOOLEAN
+CvListIsSingleton (
+ ACPI_COMMENT_NODE *CommentList);
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: CvPrintOneCommentList
+ *
+ * PARAMETERS: CommentList
+ * Level
+ *
+ * RETURN: None
+ *
+ * DESCRIPTION: Prints all comments within the given list.
+ * This is referred as ASL_CV_PRINT_ONE_COMMENT_LIST.
+ *
+ ******************************************************************************/
+
+void
+CvPrintOneCommentList (
+ ACPI_COMMENT_NODE *CommentList,
+ UINT32 Level)
+{
+ ACPI_COMMENT_NODE *Current = CommentList;
+ ACPI_COMMENT_NODE *Previous;
+
+
+ while (Current)
+ {
+ Previous = Current;
+ if (Current->Comment)
+ {
+ AcpiDmIndent(Level);
+ AcpiOsPrintf("%s\n", Current->Comment);
+ Current->Comment = NULL;
+ }
+ Current = Current->Next;
+ AcpiOsReleaseObject(AcpiGbl_RegCommentCache, Previous);
+ }
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: CvListIsSingleton
+ *
+ * PARAMETERS: CommentList -- check to see if this is a single item list.
+ *
+ * RETURN: BOOLEAN
+ *
+ * DESCRIPTION: Returns TRUE if CommentList only contains 1 node.
+ *
+ ******************************************************************************/
+
+static BOOLEAN
+CvListIsSingleton (
+ ACPI_COMMENT_NODE *CommentList)
+
+{
+ if (!CommentList)
+ {
+ return FALSE;
+ }
+ else if (CommentList->Next)
+ {
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: CvPrintOneCommentType
+ *
+ * PARAMETERS: Op
+ * CommentType
+ * EndStr - String to print after printing the comment
+ * Level - indentation level for comment lists.
+ *
+ * RETURN: None
+ *
+ * DESCRIPTION: Prints all comments of CommentType within the given Op and
+ * clears the printed comment from the Op.
+ * This is referred as ASL_CV_PRINT_ONE_COMMENT.
+ *
+ ******************************************************************************/
+
+void
+CvPrintOneCommentType (
+ ACPI_PARSE_OBJECT *Op,
+ UINT8 CommentType,
+ char* EndStr,
+ UINT32 Level)
+{
+ BOOLEAN CommentExists = FALSE;
+ char **CommentToPrint = NULL;
+
+
+ switch (CommentType)
+ {
+ case AML_COMMENT_STANDARD:
+
+ if (CvListIsSingleton (Op->Common.CommentList))
+ {
+ CvPrintOneCommentList (Op->Common.CommentList, Level);
+ AcpiOsPrintf ("\n");
+ }
+ else
+ {
+ CvPrintOneCommentList (Op->Common.CommentList, Level);
+ }
+ Op->Common.CommentList = NULL;
+ return;
+
+ case AML_COMMENT_ENDBLK:
+
+ if (Op->Common.EndBlkComment)
+ {
+ CvPrintOneCommentList (Op->Common.EndBlkComment, Level);
+ Op->Common.EndBlkComment = NULL;
+ AcpiDmIndent(Level);
+ }
+ return;
+
+ case AMLCOMMENT_INLINE:
+
+ CommentToPrint = &Op->Common.InlineComment;
+ break;
+
+ case AML_COMMENT_END_NODE:
+
+ CommentToPrint = &Op->Common.EndNodeComment;
+ break;
+
+ case AML_NAMECOMMENT:
+
+ CommentToPrint = &Op->Common.NameComment;
+ break;
+
+ case AML_COMMENT_CLOSE_BRACE:
+
+ CommentToPrint = &Op->Common.CloseBraceComment;
+ break;
+
+ default:
+ return;
+ }
+
+ if (*CommentToPrint)
+ {
+ AcpiOsPrintf ("%s", *CommentToPrint);
+ *CommentToPrint = NULL;
+ }
+
+ if (CommentExists && EndStr)
+ {
+ AcpiOsPrintf ("%s", EndStr);
+ }
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: CvCloseBraceWriteComment
+ *
+ * PARAMETERS: Op
+ * Level
+ *
+ * RETURN: none
+ *
+ * DESCRIPTION: Print a close brace } and any open brace comments associated
+ * with this parse object.
+ * This is referred as ASL_CV_CLOSE_BRACE.
+ *
+ ******************************************************************************/
+
+void
+CvCloseBraceWriteComment(
+ ACPI_PARSE_OBJECT *Op,
+ UINT32 Level)
+{
+ if (!Gbl_CaptureComments)
+ {
+ AcpiOsPrintf ("}");
+ return;
+ }
+
+ CvPrintOneCommentType (Op, AML_COMMENT_ENDBLK, NULL, Level);
+ AcpiOsPrintf ("}");
+ CvPrintOneCommentType (Op, AML_COMMENT_CLOSE_BRACE, NULL, Level);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: CvCloseParenWriteComment
+ *
+ * PARAMETERS: Op
+ * Level
+ *
+ * RETURN: none
+ *
+ * DESCRIPTION: Print a closing paren ) and any end node comments associated
+ * with this parse object.
+ * This is referred as ASL_CV_CLOSE_PAREN.
+ *
+ ******************************************************************************/
+
+void
+CvCloseParenWriteComment(
+ ACPI_PARSE_OBJECT *Op,
+ UINT32 Level)
+{
+ if (!Gbl_CaptureComments)
+ {
+ AcpiOsPrintf (")");
+ return;
+ }
+
+ /*
+ * If this op has a BLOCK_BRACE, then output the comment when the
+ * disassembler calls CvCloseBraceWriteComment
+ */
+ if (AcpiDmBlockType (Op) == BLOCK_PAREN)
+ {
+ CvPrintOneCommentType (Op, AML_COMMENT_ENDBLK, NULL, Level);
+ }
+
+ AcpiOsPrintf (")");
+
+ if (Op->Common.EndNodeComment)
+ {
+ CvPrintOneCommentType (Op, AML_COMMENT_END_NODE, NULL, Level);
+ }
+ else if ((Op->Common.Parent->Common.AmlOpcode == AML_IF_OP) &&
+ Op->Common.Parent->Common.EndNodeComment)
+ {
+ CvPrintOneCommentType (Op->Common.Parent,
+ AML_COMMENT_END_NODE, NULL, Level);
+ }
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: CvFileHasSwitched
+ *
+ * PARAMETERS: Op
+ *
+ * RETURN: BOOLEAN
+ *
+ * DESCRIPTION: Determine whether if a file has switched.
+ * TRUE - file has switched.
+ * FALSE - file has not switched.
+ * This is referred as ASL_CV_FILE_HAS_SWITCHED.
+ *
+ ******************************************************************************/
+
+BOOLEAN
+CvFileHasSwitched(
+ ACPI_PARSE_OBJECT *Op)
+{
+ if (Op->Common.CvFilename &&
+ AcpiGbl_CurrentFilename &&
+ AcpiUtStricmp(Op->Common.CvFilename, AcpiGbl_CurrentFilename))
+ {
+ return TRUE;
+ }
+ return FALSE;
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: CvPrintInclude
+ *
+ * PARAMETERS: FNode - Write an Include statement for the file that is pointed
+ * by FNode->File.
+ * Level - indentation level
+ *
+ * RETURN: None
+ *
+ * DESCRIPTION: Write the ASL Include statement for FNode->File in the file
+ * indicated by FNode->Parent->File. Note this function emits
+ * actual ASL code rather than comments. This switches the output
+ * file to FNode->Parent->File.
+ *
+ ******************************************************************************/
+
+static void
+CvPrintInclude(
+ ACPI_FILE_NODE *FNode,
+ UINT32 Level)
+{
+ if (!FNode || FNode->IncludeWritten)
+ {
+ return;
+ }
+
+ CvDbgPrint ("Writing include for %s within %s\n", FNode->Filename, FNode->Parent->Filename);
+ AcpiOsRedirectOutput (FNode->Parent->File);
+ CvPrintOneCommentList (FNode->IncludeComment, Level);
+ AcpiDmIndent (Level);
+ AcpiOsPrintf ("Include (\"%s\")\n", FNode->Filename);
+ CvDbgPrint ("emitted the following: Include (\"%s\")\n", FNode->Filename);
+ FNode->IncludeWritten = TRUE;
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: CvSwitchFiles
+ *
+ * PARAMETERS: Level - indentation level
+ * Op
+ *
+ * RETURN: None
+ *
+ * DESCRIPTION: Switch the outputfile and write ASL Include statement. Note,
+ * this function emits actual ASL code rather than comments.
+ * This is referred as ASL_CV_SWITCH_FILES.
+ *
+ ******************************************************************************/
+
+void
+CvSwitchFiles(
+ UINT32 Level,
+ ACPI_PARSE_OBJECT *Op)
+{
+ char *Filename = Op->Common.CvFilename;
+ ACPI_FILE_NODE *FNode;
+
+ CvDbgPrint ("Switching from %s to %s\n", AcpiGbl_CurrentFilename, Filename);
+ FNode = CvFilenameExists (Filename, AcpiGbl_FileTreeRoot);
+ if (!FNode)
+ {
+ /*
+ * At this point, each Filename should exist in AcpiGbl_FileTreeRoot
+ * if it does not exist, then abort.
+ */
+ FlDeleteFile (ASL_FILE_AML_OUTPUT);
+ sprintf (MsgBuffer, "\"Cannot find %s\" - %s", Filename, strerror (errno));
+ AslCommonError (ASL_ERROR, ASL_MSG_OPEN, 0, 0, 0, 0, NULL, MsgBuffer);
+ AslAbort ();
+ }
+
+ /*
+ * If the previous file is a descendent of the current file,
+ * make sure that Include statements from the current file
+ * to the previous have been emitted.
+ */
+ while (FNode &&
+ FNode->Parent &&
+ AcpiUtStricmp (FNode->Filename, AcpiGbl_CurrentFilename))
+ {
+ CvPrintInclude (FNode, Level);
+ FNode = FNode->Parent;
+ }
+
+ /* Redirect output to the Op->Common.CvFilename */
+
+ FNode = CvFilenameExists (Filename, AcpiGbl_FileTreeRoot);
+ AcpiOsRedirectOutput (FNode->File);
+ AcpiGbl_CurrentFilename = FNode->Filename;
+}
diff --git a/source/compiler/cvparser.c b/source/compiler/cvparser.c
new file mode 100644
index 000000000000..5eeccabb665b
--- /dev/null
+++ b/source/compiler/cvparser.c
@@ -0,0 +1,887 @@
+/******************************************************************************
+ *
+ * Module Name: cvparser - Converter functions that are called from the AML
+ * parser.
+ *
+ *****************************************************************************/
+
+/*
+ * Copyright (C) 2000 - 2017, Intel Corp.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions, and the following disclaimer,
+ * without modification.
+ * 2. Redistributions in binary form must reproduce at minimum a disclaimer
+ * substantially similar to the "NO WARRANTY" disclaimer below
+ * ("Disclaimer") and any redistribution must be conditioned upon
+ * including a substantially similar Disclaimer requirement for further
+ * binary redistribution.
+ * 3. Neither the names of the above-listed copyright holders nor the names
+ * of any contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * Alternatively, this software may be distributed under the terms of the
+ * GNU General Public License ("GPL") version 2 as published by the Free
+ * Software Foundation.
+ *
+ * NO WARRANTY
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
+ * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGES.
+ */
+
+#include "aslcompiler.h"
+#include "acparser.h"
+#include "acdispat.h"
+#include "amlcode.h"
+#include "acinterp.h"
+#include "acdisasm.h"
+#include "acconvert.h"
+
+
+/* local prototypes */
+
+static BOOLEAN
+CvCommentExists (
+ UINT8 *Address);
+
+static BOOLEAN
+CvIsFilename (
+ char *Filename);
+
+static ACPI_FILE_NODE*
+CvFileAddressLookup(
+ char *Address,
+ ACPI_FILE_NODE *Head);
+
+static void
+CvAddToFileTree (
+ char *Filename,
+ char *PreviousFilename);
+
+static void
+CvSetFileParent (
+ char *ChildFile,
+ char *ParentFile);
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: CvIsFilename
+ *
+ * PARAMETERS: filename - input filename
+ *
+ * RETURN: BOOLEAN - TRUE if all characters are between 0x20 and 0x7f
+ *
+ * DESCRIPTION: Take a given char * and see if it contains all printable
+ * characters. If all characters have hexvalues 20-7f and ends with
+ * .dsl, we will assume that it is a proper filename.
+ *
+ ******************************************************************************/
+
+static BOOLEAN
+CvIsFilename (
+ char *Filename)
+{
+ UINT64 Length = strlen(Filename);
+ UINT64 i;
+ char *FileExt = Filename + Length - 4;
+
+
+ if ((Length > 4) && AcpiUtStricmp (FileExt, ".dsl"))
+ {
+ return FALSE;
+ }
+
+ for(i = 0; i<Length; ++i)
+ {
+ if (!isprint (Filename[i]))
+ {
+ return FALSE;
+ }
+ }
+ return TRUE;
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: CvInitFileTree
+ *
+ * PARAMETERS: Table - input table
+ * AmlStart - Address of the starting point of the AML.
+ * AmlLength - Length of the AML file.
+ *
+ * RETURN: none
+ *
+ * DESCRIPTION: Initialize the file dependency tree by scanning the AML.
+ * This is referred as ASL_CV_INIT_FILETREE.
+ *
+ ******************************************************************************/
+
+void
+CvInitFileTree (
+ ACPI_TABLE_HEADER *Table,
+ UINT8 *AmlStart,
+ UINT32 AmlLength)
+{
+ UINT8 *TreeAml;
+ UINT8 *FileEnd;
+ char *Filename = NULL;
+ char *PreviousFilename = NULL;
+ char *ParentFilename = NULL;
+ char *ChildFilename = NULL;
+
+
+ if (!Gbl_CaptureComments)
+ {
+ return;
+ }
+
+ CvDbgPrint ("AmlLength: %x\n", AmlLength);
+ CvDbgPrint ("AmlStart: %p\n", AmlStart);
+ CvDbgPrint ("AmlEnd?: %p\n", AmlStart+AmlLength);
+
+ AcpiGbl_FileTreeRoot = AcpiOsAcquireObject (AcpiGbl_FileCache);
+ AcpiGbl_FileTreeRoot->FileStart = (char *)(AmlStart);
+ AcpiGbl_FileTreeRoot->FileEnd = (char *)(AmlStart + Table->Length);
+ AcpiGbl_FileTreeRoot->Next = NULL;
+ AcpiGbl_FileTreeRoot->Parent = NULL;
+ AcpiGbl_FileTreeRoot->Filename = (char *)(AmlStart+2);
+
+ /* Set the root file to the current open file */
+
+ AcpiGbl_FileTreeRoot->File = AcpiGbl_OutputFile;
+
+ /*
+ * Set this to true because we dont need to output
+ * an include statement for the topmost file
+ */
+ AcpiGbl_FileTreeRoot->IncludeWritten = TRUE;
+ Filename = NULL;
+ AcpiGbl_CurrentFilename = (char *)(AmlStart+2);
+ AcpiGbl_RootFilename = (char *)(AmlStart+2);
+
+ TreeAml = AmlStart;
+ FileEnd = AmlStart + AmlLength;
+
+ while (TreeAml <= FileEnd)
+ {
+ /*
+ * Make sure that this filename contains all printable characters
+ * and a .dsl extension at the end. If not, then it must be some
+ * raw data that doesn't outline a filename.
+ */
+ if ((*TreeAml == AML_COMMENT_OP) &&
+ (*(TreeAml+1) == FILENAME_COMMENT) &&
+ (CvIsFilename ((char *)(TreeAml+2))))
+ {
+ CvDbgPrint ("A9 and a 08 file\n");
+ PreviousFilename = Filename;
+ Filename = (char *) (TreeAml+2);
+ CvAddToFileTree (Filename, PreviousFilename);
+ ChildFilename = Filename;
+ CvDbgPrint ("%s\n", Filename);
+ }
+ else if ((*TreeAml == AML_COMMENT_OP) &&
+ (*(TreeAml+1) == PARENTFILENAME_COMMENT) &&
+ (CvIsFilename ((char *)(TreeAml+2))))
+ {
+ CvDbgPrint ("A9 and a 09 file\n");
+ ParentFilename = (char *)(TreeAml+2);
+ CvSetFileParent (ChildFilename, ParentFilename);
+ CvDbgPrint ("%s\n", ParentFilename);
+ }
+ ++TreeAml;
+ }
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: CvClearOpComments
+ *
+ * PARAMETERS: Op -- clear all comments within this Op
+ *
+ * RETURN: none
+ *
+ * DESCRIPTION: Clear all converter-related fields of the given Op.
+ * This is referred as ASL_CV_CLEAR_OP_COMMENTS.
+ *
+ ******************************************************************************/
+
+void
+CvClearOpComments (
+ ACPI_PARSE_OBJECT *Op)
+{
+ Op->Common.InlineComment = NULL;
+ Op->Common.EndNodeComment = NULL;
+ Op->Common.NameComment = NULL;
+ Op->Common.CommentList = NULL;
+ Op->Common.EndBlkComment = NULL;
+ Op->Common.CloseBraceComment = NULL;
+ Op->Common.CvFilename = NULL;
+ Op->Common.CvParentFilename = NULL;
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: CvCommentExists
+ *
+ * PARAMETERS: address - check if this address appears in the list
+ *
+ * RETURN: BOOLEAN - TRUE if the address exists.
+ *
+ * DESCRIPTION: look at the pointer address and check if this appears in the
+ * list of all addresses. If it exitsts in the list, return TRUE
+ * if it exists. Otherwise add to the list and return FALSE.
+ *
+ ******************************************************************************/
+
+static BOOLEAN
+CvCommentExists (
+ UINT8 *Address)
+{
+ ACPI_COMMENT_ADDR_NODE *Current = AcpiGbl_CommentAddrListHead;
+ UINT8 Option;
+
+
+ if (!Address)
+ {
+ return (FALSE);
+ }
+ Option = *(Address + 1);
+
+ /*
+ * FILENAME_COMMENT and PARENTFILENAME_COMMENT are not treated as comments.
+ * They serve as markers for where the file starts and ends.
+ */
+ if ((Option == FILENAME_COMMENT) || (Option == PARENTFILENAME_COMMENT))
+ {
+ return (FALSE);
+ }
+
+ if (!Current)
+ {
+ AcpiGbl_CommentAddrListHead =
+ AcpiOsAcquireObject (AcpiGbl_RegCommentCache);
+ AcpiGbl_CommentAddrListHead->Addr = Address;
+ AcpiGbl_CommentAddrListHead->Next = NULL;
+ return (FALSE);
+ }
+ else
+ {
+ while (Current)
+ {
+ if (Current->Addr != Address)
+ {
+ Current = Current->Next;
+ }
+ else
+ {
+ return (TRUE);
+ }
+ }
+
+ /*
+ * If the execution gets to this point, it means that this address
+ * does not exists in the list. Add this address to the
+ * beginning of the list.
+ */
+ Current = AcpiGbl_CommentAddrListHead;
+ AcpiGbl_CommentAddrListHead =
+ AcpiOsAcquireObject (AcpiGbl_RegCommentCache);
+ AcpiGbl_CommentAddrListHead->Addr = Address;
+ AcpiGbl_CommentAddrListHead->Next = Current;
+ return (FALSE);
+ }
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: CvFilenameExists
+ *
+ * PARAMETERS: Filename - filename to search
+ *
+ * RETURN: ACPI_FILE_NODE - a pointer to a file node
+ *
+ * DESCRIPTION: Look for the given filename in the file dependency tree.
+ * Returns the file node if it exists, returns NULL if it does not.
+ *
+ ******************************************************************************/
+
+ACPI_FILE_NODE*
+CvFilenameExists(
+ char *Filename,
+ ACPI_FILE_NODE *Head)
+{
+ ACPI_FILE_NODE *Current = Head;
+
+
+ while (Current)
+ {
+ if (!AcpiUtStricmp (Current->Filename, Filename))
+ {
+ return (Current);
+ }
+ Current = Current->Next;
+ }
+ return (NULL);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: CvFileAddressLookup
+ *
+ * PARAMETERS: Address - address to look up
+ * Head - file dependency tree
+ *
+ * RETURN: ACPI_FLE_NODE - pointer to a file node containing the address
+ *
+ * DESCRIPTION: Look for the given address in the file dependency tree.
+ * Returns the first file node where the given address is within
+ * the file node's starting and ending address.
+ *
+ ******************************************************************************/
+
+static ACPI_FILE_NODE*
+CvFileAddressLookup(
+ char *Address,
+ ACPI_FILE_NODE *Head)
+{
+ ACPI_FILE_NODE *Current = Head;
+
+
+ while (Current)
+ {
+ if ((Address >= Current->FileStart) &&
+ (Address < Current->FileEnd ||
+ !Current->FileEnd))
+ {
+ return (Current);
+ }
+ Current = Current->Next;
+ }
+
+ return (NULL);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: CvLabelFileNode
+ *
+ * PARAMETERS: Op
+ *
+ * RETURN: None
+ *
+ * DESCRIPTION: Takes a given parse op, looks up its Op->Common.Aml field
+ * within the file tree and fills in approperiate file information
+ * from a matching node within the tree.
+ * This is referred as ASL_CV_LABEL_FILENODE.
+ *
+ ******************************************************************************/
+
+void
+CvLabelFileNode(
+ ACPI_PARSE_OBJECT *Op)
+{
+ ACPI_FILE_NODE *Node;
+
+
+ if (!Op)
+ {
+ return;
+ }
+
+ Node = CvFileAddressLookup ((char *)Op->Common.Aml, AcpiGbl_FileTreeRoot);
+ if (!Node)
+ {
+ return;
+ }
+
+ Op->Common.CvFilename = Node->Filename;
+ if (Node->Parent)
+ {
+ Op->Common.CvParentFilename = Node->Parent->Filename;
+ }
+ else
+ {
+ Op->Common.CvParentFilename = Node->Filename;
+ }
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: CvAddToFileTree
+ *
+ * PARAMETERS: Filename - Address containing the name of the current
+ * filename
+ * PreviousFilename - Address containing the name of the previous
+ * filename
+ *
+ * RETURN: void
+ *
+ * DESCRIPTION: Add this filename to the AcpiGbl_FileTree if it does not exist.
+ *
+ ******************************************************************************/
+
+static void
+CvAddToFileTree (
+ char *Filename,
+ char *PreviousFilename)
+{
+ ACPI_FILE_NODE *Node;
+
+
+ if (!AcpiUtStricmp(Filename, AcpiGbl_RootFilename) &&
+ PreviousFilename)
+ {
+ Node = CvFilenameExists (PreviousFilename, AcpiGbl_FileTreeRoot);
+ if (Node)
+ {
+ /*
+ * Set the end point of the PreviousFilename to the address
+ * of Filename.
+ */
+ Node->FileEnd = Filename;
+ }
+ }
+ else if (!AcpiUtStricmp(Filename, AcpiGbl_RootFilename) &&
+ !PreviousFilename)
+ {
+ return;
+ }
+
+ Node = CvFilenameExists (Filename, AcpiGbl_FileTreeRoot);
+ if (Node && PreviousFilename)
+ {
+ /*
+ * Update the end of the previous file and all of their parents' ending
+ * Addresses. This is done to ensure that parent file ranges extend to
+ * the end of their childrens' files.
+ */
+ Node = CvFilenameExists (PreviousFilename, AcpiGbl_FileTreeRoot);
+ if (Node && (Node->FileEnd < Filename))
+ {
+ Node->FileEnd = Filename;
+ Node = Node->Parent;
+ while (Node)
+ {
+ if (Node->FileEnd < Filename)
+ {
+ Node->FileEnd = Filename;
+ }
+ Node = Node->Parent;
+ }
+ }
+ }
+ else
+ {
+ Node = AcpiGbl_FileTreeRoot;
+ AcpiGbl_FileTreeRoot = AcpiOsAcquireObject (AcpiGbl_FileCache);
+ AcpiGbl_FileTreeRoot->Next = Node;
+ AcpiGbl_FileTreeRoot->Parent = NULL;
+ AcpiGbl_FileTreeRoot->Filename = Filename;
+ AcpiGbl_FileTreeRoot->FileStart = Filename;
+ AcpiGbl_FileTreeRoot->IncludeWritten = FALSE;
+ AcpiGbl_FileTreeRoot->File = fopen(Filename, "w+");
+
+ /*
+ * If we can't open the file, we need to abort here before we
+ * accidentally write to a NULL file.
+ */
+ if (!AcpiGbl_FileTreeRoot->File)
+ {
+ /* delete the .xxx file */
+
+ FlDeleteFile (ASL_FILE_AML_OUTPUT);
+ sprintf (MsgBuffer, "\"%s\" - %s", Filename, strerror (errno));
+ AslCommonError (ASL_ERROR, ASL_MSG_OPEN, 0, 0, 0, 0, NULL, MsgBuffer);
+ AslAbort ();
+ }
+ }
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: CvSetFileParent
+ *
+ * PARAMETERS: ChildFile - contains the filename of the child file
+ * ParentFile - contains the filename of the parent file.
+ *
+ * RETURN: none
+ *
+ * DESCRIPTION: point the parent pointer of the Child to the node that
+ * corresponds with the parent file node.
+ *
+ ******************************************************************************/
+
+static void
+CvSetFileParent (
+ char *ChildFile,
+ char *ParentFile)
+{
+ ACPI_FILE_NODE *Child;
+ ACPI_FILE_NODE *Parent;
+
+
+ Child = CvFilenameExists (ChildFile, AcpiGbl_FileTreeRoot);
+ Parent = CvFilenameExists (ParentFile, AcpiGbl_FileTreeRoot);
+ if (Child && Parent)
+ {
+ Child->Parent = Parent;
+
+ while (Child->Parent)
+ {
+ if (Child->Parent->FileEnd < Child->FileStart)
+ {
+ Child->Parent->FileEnd = Child->FileStart;
+ }
+ Child = Child->Parent;
+ }
+ }
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: CvCaptureCommentsOnly
+ *
+ * PARAMETERS: ParserState - A parser state object
+ *
+ * RETURN: none
+ *
+ * DESCRIPTION: look at the aml that the parser state is pointing to,
+ * capture any AML_COMMENT_OP and it's arguments and increment the
+ * aml pointer past the comment. Comments are transferred to parse
+ * nodes through CvTransferComments() as well as
+ * AcpiPsBuildNamedOp().
+ * This is referred as ASL_CV_CAPTURE_COMMENTS_ONLY.
+ *
+ ******************************************************************************/
+
+void
+CvCaptureCommentsOnly (
+ ACPI_PARSE_STATE *ParserState)
+{
+ UINT8 *Aml = ParserState->Aml;
+ UINT16 Opcode = (UINT16) ACPI_GET8 (Aml);
+ UINT32 Length = 0;
+ UINT8 CommentOption = (UINT16) ACPI_GET8 (Aml+1);
+ BOOLEAN StdDefBlockFlag = FALSE;
+ ACPI_COMMENT_NODE *CommentNode;
+ ACPI_FILE_NODE *FileNode;
+
+
+ if (!Gbl_CaptureComments ||
+ Opcode != AML_COMMENT_OP)
+ {
+ return;
+ }
+
+ while (Opcode == AML_COMMENT_OP)
+ {
+ CvDbgPrint ("comment aml address: %p\n", Aml);
+
+ if (CvCommentExists(ParserState->Aml))
+ {
+ CvDbgPrint ("Avoiding capturing an existing comment.\n");
+ }
+ else
+ {
+ CommentOption = *(Aml+1);
+
+ /* Increment past the comment option and point the approperiate char pointers.*/
+
+ Aml += 2;
+
+ /* found a comment. Now, set pointers to these comments. */
+
+ switch (CommentOption)
+ {
+ case STD_DEFBLK_COMMENT:
+
+ StdDefBlockFlag = TRUE;
+
+ /* add to a linked list of nodes. This list will be taken by the parse node created next. */
+
+ CommentNode = AcpiOsAcquireObject (AcpiGbl_RegCommentCache);
+ CommentNode->Comment = ACPI_CAST_PTR (char, Aml);
+ CommentNode->Next = NULL;
+
+ if (!AcpiGbl_DefBlkCommentListHead)
+ {
+ AcpiGbl_DefBlkCommentListHead = CommentNode;
+ AcpiGbl_DefBlkCommentListTail = CommentNode;
+ }
+ else
+ {
+ AcpiGbl_DefBlkCommentListTail->Next = CommentNode;
+ AcpiGbl_DefBlkCommentListTail = AcpiGbl_DefBlkCommentListTail->Next;
+ }
+ break;
+
+ case STANDARD_COMMENT:
+
+ CvDbgPrint ("found regular comment.\n");
+
+ /* add to a linked list of nodes. This list will be taken by the parse node created next. */
+
+ CommentNode = AcpiOsAcquireObject (AcpiGbl_RegCommentCache);
+ CommentNode->Comment = ACPI_CAST_PTR (char, Aml);
+ CommentNode->Next = NULL;
+
+ if (!AcpiGbl_RegCommentListHead)
+ {
+ AcpiGbl_RegCommentListHead = CommentNode;
+ AcpiGbl_RegCommentListTail = CommentNode;
+ }
+ else
+ {
+ AcpiGbl_RegCommentListTail->Next = CommentNode;
+ AcpiGbl_RegCommentListTail = AcpiGbl_RegCommentListTail->Next;
+ }
+ break;
+
+ case ENDBLK_COMMENT:
+
+ CvDbgPrint ("found endblk comment.\n");
+
+ /* add to a linked list of nodes. This will be taken by the next created parse node. */
+
+ CommentNode = AcpiOsAcquireObject (AcpiGbl_RegCommentCache);
+ CommentNode->Comment = ACPI_CAST_PTR (char, Aml);
+ CommentNode->Next = NULL;
+
+ if (!AcpiGbl_EndBlkCommentListHead)
+ {
+ AcpiGbl_EndBlkCommentListHead = CommentNode;
+ AcpiGbl_EndBlkCommentListTail = CommentNode;
+ }
+ else
+ {
+ AcpiGbl_EndBlkCommentListTail->Next = CommentNode;
+ AcpiGbl_EndBlkCommentListTail = AcpiGbl_EndBlkCommentListTail->Next;
+ }
+ break;
+
+ case INLINE_COMMENT:
+
+ CvDbgPrint ("found inline comment.\n");
+ AcpiGbl_CurrentInlineComment = ACPI_CAST_PTR (char, Aml);
+ break;
+
+ case ENDNODE_COMMENT:
+
+ CvDbgPrint ("found EndNode comment.\n");
+ AcpiGbl_CurrentEndNodeComment = ACPI_CAST_PTR (char, Aml);
+ break;
+
+ case CLOSE_BRACE_COMMENT:
+
+ CvDbgPrint ("found close brace comment.\n");
+ AcpiGbl_CurrentCloseBraceComment = ACPI_CAST_PTR (char, Aml);
+ break;
+
+ case END_DEFBLK_COMMENT:
+
+ CvDbgPrint ("Found comment that belongs after the } for a definition block.\n");
+ AcpiGbl_CurrentScope->Common.CloseBraceComment = ACPI_CAST_PTR (char, Aml);
+ break;
+
+ case FILENAME_COMMENT:
+
+ CvDbgPrint ("Found a filename: %s\n", ACPI_CAST_PTR (char, Aml));
+ FileNode = CvFilenameExists (ACPI_CAST_PTR (char, Aml), AcpiGbl_FileTreeRoot);
+
+ /*
+ * If there is an INCLUDE_COMMENT followed by a
+ * FILENAME_COMMENT, then the INCLUDE_COMMENT is a comment
+ * that is emitted before the #include for the file.
+ * We will save the IncludeComment within the FileNode
+ * associated with this FILENAME_COMMENT.
+ */
+ if (FileNode && AcpiGbl_IncCommentListHead)
+ {
+ FileNode->IncludeComment = AcpiGbl_IncCommentListHead;
+ AcpiGbl_IncCommentListHead = NULL;
+ AcpiGbl_IncCommentListTail = NULL;
+ }
+ break;
+
+ case PARENTFILENAME_COMMENT:
+ CvDbgPrint (" Found a parent filename.\n");
+ break;
+
+ case INCLUDE_COMMENT:
+
+ /*
+ * Add to a linked list. This list will be taken by the
+ * parse node created next. See the FILENAME_COMMENT case
+ * for more details
+ */
+ CommentNode = AcpiOsAcquireObject (AcpiGbl_RegCommentCache);
+ CommentNode->Comment = ACPI_CAST_PTR (char, Aml);
+ CommentNode->Next = NULL;
+
+ if (!AcpiGbl_IncCommentListHead)
+ {
+ AcpiGbl_IncCommentListHead = CommentNode;
+ AcpiGbl_IncCommentListTail = CommentNode;
+ }
+ else
+ {
+ AcpiGbl_IncCommentListTail->Next = CommentNode;
+ AcpiGbl_IncCommentListTail = AcpiGbl_IncCommentListTail->Next;
+ }
+
+ CvDbgPrint ("Found a include comment: %s\n", CommentNode->Comment);
+ break;
+
+ default:
+
+ /* Not a valid comment option. Revert the AML */
+
+ Aml -= 2;
+ goto DefBlock;
+ break;
+
+ } /* end switch statement */
+
+ } /* end else */
+
+ /* determine the length and move forward that amount */
+
+ Length = 0;
+ while (ParserState->Aml[Length])
+ {
+ Length++;
+ }
+
+ ParserState->Aml += Length + 1;
+
+
+ /* Peek at the next Opcode. */
+
+ Aml = ParserState->Aml;
+ Opcode = (UINT16) ACPI_GET8 (Aml);
+
+ }
+
+DefBlock:
+ if (StdDefBlockFlag)
+ {
+ /*
+ * Give all of its comments to the current scope, which is known as
+ * the definition block, since STD_DEFBLK_COMMENT only appears after
+ * definition block headers.
+ */
+ AcpiGbl_CurrentScope->Common.CommentList
+ = AcpiGbl_DefBlkCommentListHead;
+ AcpiGbl_DefBlkCommentListHead = NULL;
+ AcpiGbl_DefBlkCommentListTail = NULL;
+ }
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: CvCaptureComments
+ *
+ * PARAMETERS: ParserState - A parser state object
+ *
+ * RETURN: none
+ *
+ * DESCRIPTION: Wrapper function for CvCaptureCommentsOnly
+ * This is referred as ASL_CV_CAPTURE_COMMENTS.
+ *
+ ******************************************************************************/
+
+void
+CvCaptureComments (
+ ACPI_WALK_STATE *WalkState)
+{
+ UINT8 *Aml;
+ UINT16 Opcode;
+ const ACPI_OPCODE_INFO *OpInfo;
+
+
+ if (!Gbl_CaptureComments)
+ {
+ return;
+ }
+
+ /*
+ * Before parsing, check to see that comments that come directly after
+ * deferred opcodes aren't being processed.
+ */
+ Aml = WalkState->ParserState.Aml;
+ Opcode = (UINT16) ACPI_GET8 (Aml);
+ OpInfo = AcpiPsGetOpcodeInfo (Opcode);
+
+ if (!(OpInfo->Flags & AML_DEFER) ||
+ ((OpInfo->Flags & AML_DEFER) &&
+ (WalkState->PassNumber != ACPI_IMODE_LOAD_PASS1)))
+ {
+ CvCaptureCommentsOnly (&WalkState->ParserState);
+ WalkState->Aml = WalkState->ParserState.Aml;
+ }
+
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: CvTransferComments
+ *
+ * PARAMETERS: Op - Transfer comments to this Op
+ *
+ * RETURN: none
+ *
+ * DESCRIPTION: Transfer all of the commments stored in global containers to the
+ * given Op. This will be invoked shortly after the parser creates
+ * a ParseOp.
+ * This is referred as ASL_CV_TRANSFER_COMMENTS.
+ *
+ ******************************************************************************/
+
+void
+CvTransferComments (
+ ACPI_PARSE_OBJECT *Op)
+{
+ Op->Common.InlineComment = AcpiGbl_CurrentInlineComment;
+ AcpiGbl_CurrentInlineComment = NULL;
+
+ Op->Common.EndNodeComment = AcpiGbl_CurrentEndNodeComment;
+ AcpiGbl_CurrentEndNodeComment = NULL;
+
+ Op->Common.CloseBraceComment = AcpiGbl_CurrentCloseBraceComment;
+ AcpiGbl_CurrentCloseBraceComment = NULL;
+
+ Op->Common.CommentList = AcpiGbl_RegCommentListHead;
+ AcpiGbl_RegCommentListHead = NULL;
+ AcpiGbl_RegCommentListTail = NULL;
+
+ Op->Common.EndBlkComment = AcpiGbl_EndBlkCommentListHead;
+ AcpiGbl_EndBlkCommentListHead = NULL;
+ AcpiGbl_EndBlkCommentListTail = NULL;
+
+}
diff --git a/source/compiler/dttable1.c b/source/compiler/dttable1.c
index 4de4a584f560..c8fb71b2b03f 100644
--- a/source/compiler/dttable1.c
+++ b/source/compiler/dttable1.c
@@ -1518,6 +1518,10 @@ DtCompileIort (
}
IortNode->MappingCount = IdMappingNumber;
+ if (!IdMappingNumber)
+ {
+ IortNode->MappingOffset = 0;
+ }
/*
* Node length can be determined by DT_LENGTH option
diff --git a/source/compiler/dttemplate.h b/source/compiler/dttemplate.h
index 8b05713f5060..e1c705600c31 100644
--- a/source/compiler/dttemplate.h
+++ b/source/compiler/dttemplate.h
@@ -543,47 +543,53 @@ const unsigned char TemplateHpet[] =
const unsigned char TemplateIort[] =
{
- 0x49,0x4F,0x52,0x54,0x48,0x01,0x00,0x00, /* 00000000 "IORTH..." */
- 0x00,0x02,0x49,0x4E,0x54,0x45,0x4C,0x20, /* 00000008 "..INTEL " */
+ 0x49,0x4F,0x52,0x54,0x74,0x01,0x00,0x00, /* 00000000 "IORTt..." */
+ 0x00,0xD2,0x49,0x4E,0x54,0x45,0x4C,0x20, /* 00000008 "..INTEL " */
0x54,0x45,0x4D,0x50,0x4C,0x41,0x54,0x45, /* 00000010 "TEMPLATE" */
0x00,0x00,0x00,0x00,0x49,0x4E,0x54,0x4C, /* 00000018 "....INTL" */
- 0x12,0x02,0x16,0x20,0x05,0x00,0x00,0x00, /* 00000020 "... ...." */
+ 0x19,0x01,0x17,0x20,0x05,0x00,0x00,0x00, /* 00000020 "... ...." */
0x34,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000028 "4......." */
- 0x00,0x00,0x00,0x00,0x00,0x2C,0x00,0x00, /* 00000030 ".....,.." */
- 0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00, /* 00000038 "........" */
- 0x18,0x00,0x00,0x00,0x01,0x00,0x00,0x00, /* 00000040 "........" */
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000048 "........" */
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000050 "........" */
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000058 "........" */
- 0x01,0x30,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000060 ".0......" */
- 0x00,0x00,0x00,0x00,0x30,0x00,0x00,0x00, /* 00000068 "....0..." */
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000070 "........" */
- 0x00,0x00,0x00,0x00,0x00,0x5C,0x5F,0x53, /* 00000078 ".....\_S" */
- 0x42,0x2E,0x50,0x43,0x49,0x30,0x2E,0x44, /* 00000080 "B.PCI0.D" */
- 0x45,0x56,0x30,0x00,0x00,0x00,0x00,0x00, /* 00000088 "EV0....." */
- 0x02,0x20,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000090 ". ......" */
- 0x00,0x00,0x00,0x00,0x20,0x00,0x00,0x00, /* 00000098 ".... ..." */
+ 0x00,0x00,0x00,0x00,0x00,0x18,0x00,0x00, /* 00000030 "........" */
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000038 "........" */
+ 0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00, /* 00000040 "........" */
+ 0x00,0x00,0x00,0x00,0x01,0x44,0x00,0x00, /* 00000048 ".....D.." */
+ 0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00, /* 00000050 "........" */
+ 0x30,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000058 "0......." */
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000060 "........" */
+ 0x00,0x5C,0x5F,0x53,0x42,0x2E,0x50,0x43, /* 00000068 ".\_SB.PC" */
+ 0x49,0x30,0x2E,0x44,0x45,0x56,0x30,0x00, /* 00000070 "I0.DEV0." */
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000078 "........" */
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000080 "........" */
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000088 "........" */
+ 0x02,0x34,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000090 ".4......" */
+ 0x01,0x00,0x00,0x00,0x20,0x00,0x00,0x00, /* 00000098 ".... ..." */
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 000000A0 "........" */
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 000000A8 "........" */
- 0x03,0x5C,0x00,0x00,0x00,0x00,0x00,0x00, /* 000000B0 ".\......" */
- 0x00,0x00,0x00,0x00,0x5C,0x00,0x00,0x00, /* 000000B8 "....\..." */
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 000000C0 "........" */
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 000000C8 "........" */
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 000000D0 "........" */
- 0x3C,0x00,0x00,0x00,0x01,0x00,0x00,0x00, /* 000000D8 "<......." */
- 0x4C,0x00,0x00,0x00,0x01,0x00,0x00,0x00, /* 000000E0 "L......." */
- 0x54,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 000000E8 "T......." */
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 000000F0 "........" */
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 000000F8 "........" */
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 000000B0 "........" */
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 000000B8 "........" */
+ 0x00,0x00,0x00,0x00,0x03,0x60,0x00,0x00, /* 000000C0 ".....`.." */
+ 0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00, /* 000000C8 "........" */
+ 0x4C,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 000000D0 "L......." */
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 000000D8 "........" */
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 000000E0 "........" */
+ 0x00,0x00,0x00,0x00,0x3C,0x00,0x00,0x00, /* 000000E8 "....<..." */
+ 0x00,0x00,0x00,0x00,0x4C,0x00,0x00,0x00, /* 000000F0 "....L..." */
+ 0x00,0x00,0x00,0x00,0x4C,0x00,0x00,0x00, /* 000000F8 "....L..." */
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000100 "........" */
- 0x00,0x00,0x00,0x00,0x04,0x3C,0x00,0x00, /* 00000108 ".....<.." */
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000108 "........" */
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000110 "........" */
- 0x3C,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000118 "<......." */
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000120 "........" */
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000128 "........" */
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000130 "........" */
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000118 "........" */
+ 0x00,0x00,0x00,0x00,0x04,0x50,0x00,0x00, /* 00000120 ".....P.." */
+ 0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00, /* 00000128 "........" */
+ 0x3C,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000130 "<......." */
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000138 "........" */
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 /* 00000140 "........" */
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000140 "........" */
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000148 "........" */
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000150 "........" */
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000158 "........" */
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000160 "........" */
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000168 "........" */
+ 0x00,0x00,0x00,0x00 /* 00000170 "...." */
};
const unsigned char TemplateIvrs[] =
diff --git a/source/components/debugger/dbmethod.c b/source/components/debugger/dbmethod.c
index c47ca39bbefb..3c7a6d3f1e33 100644
--- a/source/components/debugger/dbmethod.c
+++ b/source/components/debugger/dbmethod.c
@@ -479,6 +479,7 @@ AcpiDbWalkForExecute (
Status = AcpiGetObjectInfo (ObjHandle, &ObjInfo);
if (ACPI_FAILURE (Status))
{
+ ACPI_FREE (Pathname);
return (Status);
}
diff --git a/source/components/debugger/dbxface.c b/source/components/debugger/dbxface.c
index d548f64f71a5..def269d84f0b 100644
--- a/source/components/debugger/dbxface.c
+++ b/source/components/debugger/dbxface.c
@@ -45,6 +45,7 @@
#include "accommon.h"
#include "amlcode.h"
#include "acdebug.h"
+#include "acinterp.h"
#define _COMPONENT ACPI_CA_DEBUGGER
@@ -137,7 +138,7 @@ ErrorExit:
*
* RETURN: Status
*
- * DESCRIPTION: Called for AML_BREAK_POINT_OP
+ * DESCRIPTION: Called for AML_BREAKPOINT_OP
*
******************************************************************************/
@@ -404,7 +405,9 @@ AcpiDbSingleStep (
}
+ AcpiExExitInterpreter ();
Status = AcpiDbStartCommand (WalkState, Op);
+ AcpiExEnterInterpreter ();
/* User commands complete, continue execution of the interrupted method */
diff --git a/source/components/disassembler/dmcstyle.c b/source/components/disassembler/dmcstyle.c
index 2293283caa60..5430893195c2 100644
--- a/source/components/disassembler/dmcstyle.c
+++ b/source/components/disassembler/dmcstyle.c
@@ -46,6 +46,7 @@
#include "acparser.h"
#include "amlcode.h"
#include "acdebug.h"
+#include "acconvert.h"
#define _COMPONENT ACPI_CA_DEBUGGER
@@ -171,27 +172,27 @@ AcpiDmCheckForSymbolicOpcode (
/* Logical operators, no target */
- case AML_LAND_OP:
+ case AML_LOGICAL_AND_OP:
OperatorSymbol = " && ";
break;
- case AML_LEQUAL_OP:
+ case AML_LOGICAL_EQUAL_OP:
OperatorSymbol = " == ";
break;
- case AML_LGREATER_OP:
+ case AML_LOGICAL_GREATER_OP:
OperatorSymbol = " > ";
break;
- case AML_LLESS_OP:
+ case AML_LOGICAL_LESS_OP:
OperatorSymbol = " < ";
break;
- case AML_LOR_OP:
+ case AML_LOGICAL_OR_OP:
OperatorSymbol = " || ";
break;
- case AML_LNOT_OP:
+ case AML_LOGICAL_NOT_OP:
/*
* Check for the LNOT sub-opcodes. These correspond to
* LNotEqual, LLessEqual, and LGreaterEqual. There are
@@ -199,15 +200,15 @@ AcpiDmCheckForSymbolicOpcode (
*/
switch (Argument1->Common.AmlOpcode)
{
- case AML_LEQUAL_OP:
+ case AML_LOGICAL_EQUAL_OP:
OperatorSymbol = " != ";
break;
- case AML_LGREATER_OP:
+ case AML_LOGICAL_GREATER_OP:
OperatorSymbol = " <= ";
break;
- case AML_LLESS_OP:
+ case AML_LOGICAL_LESS_OP:
OperatorSymbol = " >= ";
break;
@@ -243,7 +244,7 @@ AcpiDmCheckForSymbolicOpcode (
if ((Argument1->Common.AmlOpcode == AML_STRING_OP) ||
(Argument1->Common.AmlOpcode == AML_BUFFER_OP) ||
(Argument1->Common.AmlOpcode == AML_PACKAGE_OP) ||
- (Argument1->Common.AmlOpcode == AML_VAR_PACKAGE_OP))
+ (Argument1->Common.AmlOpcode == AML_VARIABLE_PACKAGE_OP))
{
Op->Common.DisasmFlags |= ACPI_PARSEOP_CLOSING_PAREN;
return (FALSE);
@@ -474,11 +475,11 @@ AcpiDmCheckForSymbolicOpcode (
case AML_BIT_AND_OP:
case AML_BIT_OR_OP:
case AML_BIT_XOR_OP:
- case AML_LAND_OP:
- case AML_LEQUAL_OP:
- case AML_LGREATER_OP:
- case AML_LLESS_OP:
- case AML_LOR_OP:
+ case AML_LOGICAL_AND_OP:
+ case AML_LOGICAL_EQUAL_OP:
+ case AML_LOGICAL_GREATER_OP:
+ case AML_LOGICAL_LESS_OP:
+ case AML_LOGICAL_OR_OP:
Op->Common.DisasmFlags |= ACPI_PARSEOP_ASSIGNMENT;
AcpiOsPrintf ("(");
@@ -725,12 +726,14 @@ AcpiDmCloseOperator (
if (!AcpiGbl_CstyleDisassembly)
{
AcpiOsPrintf (")");
+ ASL_CV_PRINT_ONE_COMMENT (Op, AML_COMMENT_END_NODE, NULL, 0);
return;
}
if (Op->Common.DisasmFlags & ACPI_PARSEOP_LEGACY_ASL_ONLY)
{
AcpiOsPrintf (")");
+ ASL_CV_PRINT_ONE_COMMENT (Op, AML_COMMENT_END_NODE, NULL, 0);
return;
}
@@ -748,16 +751,17 @@ AcpiDmCloseOperator (
case AML_BIT_AND_OP:
case AML_BIT_OR_OP:
case AML_BIT_XOR_OP:
- case AML_LAND_OP:
- case AML_LEQUAL_OP:
- case AML_LGREATER_OP:
- case AML_LLESS_OP:
- case AML_LOR_OP:
+ case AML_LOGICAL_AND_OP:
+ case AML_LOGICAL_EQUAL_OP:
+ case AML_LOGICAL_GREATER_OP:
+ case AML_LOGICAL_LESS_OP:
+ case AML_LOGICAL_OR_OP:
/* Emit paren only if this is not a compound assignment */
if (Op->Common.DisasmFlags & ACPI_PARSEOP_COMPOUND_ASSIGNMENT)
{
+ ASL_CV_PRINT_ONE_COMMENT (Op, AML_COMMENT_END_NODE, NULL, 0);
return;
}
@@ -777,15 +781,17 @@ AcpiDmCloseOperator (
{
AcpiOsPrintf (")");
}
+ ASL_CV_PRINT_ONE_COMMENT (Op, AML_COMMENT_END_NODE, NULL, 0);
return;
/* No need for parens for these */
case AML_DECREMENT_OP:
case AML_INCREMENT_OP:
- case AML_LNOT_OP:
+ case AML_LOGICAL_NOT_OP:
case AML_BIT_NOT_OP:
case AML_STORE_OP:
+ ASL_CV_PRINT_ONE_COMMENT (Op, AML_COMMENT_END_NODE, NULL, 0);
return;
default:
@@ -795,6 +801,9 @@ AcpiDmCloseOperator (
}
AcpiOsPrintf (")");
+ ASL_CV_PRINT_ONE_COMMENT (Op, AML_COMMENT_END_NODE, NULL, 0);
+
+ return;
}
diff --git a/source/components/disassembler/dmdeferred.c b/source/components/disassembler/dmdeferred.c
index 1f8693ff3c95..53fe2b2ce43a 100644
--- a/source/components/disassembler/dmdeferred.c
+++ b/source/components/disassembler/dmdeferred.c
@@ -103,7 +103,7 @@ AcpiDmParseDeferredOps (
case AML_METHOD_OP:
case AML_BUFFER_OP:
case AML_PACKAGE_OP:
- case AML_VAR_PACKAGE_OP:
+ case AML_VARIABLE_PACKAGE_OP:
Status = AcpiDmDeferredParse (
Op, Op->Named.Data, Op->Named.Length);
@@ -217,7 +217,7 @@ AcpiDmDeferredParse (
{
case AML_BUFFER_OP:
case AML_PACKAGE_OP:
- case AML_VAR_PACKAGE_OP:
+ case AML_VARIABLE_PACKAGE_OP:
switch (Op->Common.AmlOpcode)
{
@@ -228,7 +228,7 @@ AcpiDmDeferredParse (
ACPI_FREE (ExtraOp);
break;
- case AML_VAR_PACKAGE_OP:
+ case AML_VARIABLE_PACKAGE_OP:
case AML_BUFFER_OP:
default:
diff --git a/source/components/disassembler/dmnames.c b/source/components/disassembler/dmnames.c
index 0c1a23e1c77c..8fb65d6c92df 100644
--- a/source/components/disassembler/dmnames.c
+++ b/source/components/disassembler/dmnames.c
@@ -244,7 +244,7 @@ AcpiDmNamestring (
Name++;
break;
- case AML_MULTI_NAME_PREFIX_OP:
+ case AML_MULTI_NAME_PREFIX:
SegCount = (UINT32) ACPI_GET8 (Name + 1);
Name += 2;
diff --git a/source/components/disassembler/dmopcode.c b/source/components/disassembler/dmopcode.c
index 821128f922bb..4bd0ca5db3df 100644
--- a/source/components/disassembler/dmopcode.c
+++ b/source/components/disassembler/dmopcode.c
@@ -48,6 +48,7 @@
#include "acinterp.h"
#include "acnamesp.h"
#include "acdebug.h"
+#include "acconvert.h"
#define _COMPONENT ACPI_CA_DEBUGGER
@@ -70,7 +71,8 @@ AcpiDmPromoteSubtree (
static BOOLEAN
AcpiDmIsSwitchBlock (
- ACPI_PARSE_OBJECT *Op);
+ ACPI_PARSE_OBJECT *Op,
+ char *Temp);
static BOOLEAN
AcpiDmIsCaseBlock (
@@ -441,6 +443,7 @@ AcpiDmFieldPredefinedDescription (
ACPI_CAST_PTR (char, Info->Description));
}
+ ACPI_FREE (Tag); /* Tag was allocated in AcpiGetTagPathname */
#endif
return;
}
@@ -716,15 +719,15 @@ AcpiDmDisassembleOneOp (
{
switch (Op->Common.AmlOpcode)
{
- case AML_LEQUAL_OP:
+ case AML_LOGICAL_EQUAL_OP:
AcpiOsPrintf ("LNotEqual");
break;
- case AML_LGREATER_OP:
+ case AML_LOGICAL_GREATER_OP:
AcpiOsPrintf ("LLessEqual");
break;
- case AML_LLESS_OP:
+ case AML_LOGICAL_LESS_OP:
AcpiOsPrintf ("LGreaterEqual");
break;
@@ -747,12 +750,12 @@ AcpiDmDisassembleOneOp (
switch (Op->Common.AmlOpcode)
{
- case AML_LNOT_OP:
+ case AML_LOGICAL_NOT_OP:
Child = Op->Common.Value.Arg;
- if ((Child->Common.AmlOpcode == AML_LEQUAL_OP) ||
- (Child->Common.AmlOpcode == AML_LGREATER_OP) ||
- (Child->Common.AmlOpcode == AML_LLESS_OP))
+ if ((Child->Common.AmlOpcode == AML_LOGICAL_EQUAL_OP) ||
+ (Child->Common.AmlOpcode == AML_LOGICAL_GREATER_OP) ||
+ (Child->Common.AmlOpcode == AML_LOGICAL_LESS_OP))
{
Child->Common.DisasmOpcode = ACPI_DASM_LNOT_SUFFIX;
Op->Common.DisasmOpcode = ACPI_DASM_LNOT_PREFIX;
@@ -881,8 +884,12 @@ AcpiDmDisassembleOneOp (
case AML_INT_NAMEDFIELD_OP:
Length = AcpiDmDumpName (Op->Named.Name);
- AcpiOsPrintf (",%*.s %u", (unsigned) (5 - Length), " ",
+
+ AcpiOsPrintf (",");
+ ASL_CV_PRINT_ONE_COMMENT (Op, AML_NAMECOMMENT, NULL, 0);
+ AcpiOsPrintf ("%*.s %u", (unsigned) (5 - Length), " ",
(UINT32) Op->Common.Value.Integer);
+
AcpiDmCommaIfFieldMember (Op);
Info->BitOffset += (UINT32) Op->Common.Value.Integer;
@@ -923,6 +930,7 @@ AcpiDmDisassembleOneOp (
AcpiOsPrintf (")");
AcpiDmCommaIfFieldMember (Op);
+ ASL_CV_PRINT_ONE_COMMENT (Op, AML_COMMENT_END_NODE, NULL, 0);
break;
case AML_INT_CONNECTION_OP:
@@ -956,6 +964,8 @@ AcpiDmDisassembleOneOp (
AcpiOsPrintf (")");
AcpiDmCommaIfFieldMember (Op);
+ ASL_CV_PRINT_ONE_COMMENT (Op, AML_COMMENT_END_NODE, NULL, 0);
+ ASL_CV_PRINT_ONE_COMMENT (Op, AMLCOMMENT_INLINE, NULL, 0);
AcpiOsPrintf ("\n");
Op->Common.DisasmFlags |= ACPI_PARSEOP_IGNORE; /* for now, ignore in AcpiDmAscendingOp */
@@ -977,7 +987,7 @@ AcpiDmDisassembleOneOp (
case AML_WHILE_OP:
- if (AcpiDmIsSwitchBlock(Op))
+ if (Op->Common.DisasmOpcode == ACPI_DASM_SWITCH)
{
AcpiOsPrintf ("%s", "Switch");
break;
@@ -1006,15 +1016,13 @@ AcpiDmDisassembleOneOp (
if (AcpiGbl_DmEmitExternalOpcodes)
{
- AcpiOsPrintf ("/* Opcode 0x15 */ ");
-
- /* Fallthrough */
- }
- else
- {
+ AcpiDmEmitExternal (AcpiPsGetArg(Op, 0),
+ AcpiPsGetArg(Op, 1));
break;
}
+ break;
+
default:
/* Just get the opcode name and print it */
@@ -1255,11 +1263,13 @@ AcpiDmPromoteSubtree (
*
* PARAMETERS: Op - Object to be examined
*
- * RETURN: TRUE if object is a temporary (_T_x) name
+ * RETURN: TRUE if object is a temporary (_T_x) name for a matching While
+ * loop that can be converted to a Switch.
*
- * DESCRIPTION: Determine if an object is a temporary name and ignore it.
- * Temporary names are only used for Switch statements. This
- * function depends on this restriced usage.
+ * DESCRIPTION: _T_X objects are only used for Switch statements. If a temporary
+ * name exists, search the siblings for a matching While (One) loop
+ * that can be converted to a Switch. Return TRUE if a match was
+ * found, FALSE otherwise.
*
******************************************************************************/
@@ -1267,6 +1277,7 @@ BOOLEAN
AcpiDmIsTempName (
ACPI_PARSE_OBJECT *Op)
{
+ ACPI_PARSE_OBJECT *CurrentOp;
char *Temp;
if (Op->Common.AmlOpcode != AML_NAME_OP)
@@ -1282,11 +1293,21 @@ AcpiDmIsTempName (
return (FALSE);
}
- /* Ignore Op */
+ CurrentOp = Op->Common.Next;
+ while (CurrentOp)
+ {
+ if (CurrentOp->Common.AmlOpcode == AML_WHILE_OP &&
+ AcpiDmIsSwitchBlock(CurrentOp, Temp))
+ {
+ Op->Common.DisasmFlags |= ACPI_PARSEOP_IGNORE;
+ CurrentOp->Common.DisasmOpcode = ACPI_DASM_SWITCH;
- Op->Common.DisasmFlags |= ACPI_PARSEOP_IGNORE;
+ return (TRUE);
+ }
+ CurrentOp = CurrentOp->Common.Next;
+ }
- return (TRUE);
+ return (FALSE);
}
/*******************************************************************************
@@ -1322,7 +1343,8 @@ AcpiDmIsTempName (
static BOOLEAN
AcpiDmIsSwitchBlock (
- ACPI_PARSE_OBJECT *Op)
+ ACPI_PARSE_OBJECT *Op,
+ char *Temp)
{
ACPI_PARSE_OBJECT *OneOp;
ACPI_PARSE_OBJECT *StoreOp;
@@ -1355,7 +1377,7 @@ AcpiDmIsSwitchBlock (
return (FALSE);
}
- if (strncmp((char *)(NamePathOp->Common.Aml), "_T_", 3))
+ if (strncmp((char *)(NamePathOp->Common.Aml), Temp, 4))
{
return (FALSE);
}
@@ -1411,7 +1433,7 @@ AcpiDmIsSwitchBlock (
TempOp = AcpiPsGetArg (CurrentOp, 0);
switch (TempOp->Common.AmlOpcode)
{
- case (AML_LEQUAL_OP):
+ case (AML_LOGICAL_EQUAL_OP):
/* Ignore just the LEqual Op */
@@ -1433,7 +1455,7 @@ AcpiDmIsSwitchBlock (
break;
- case (AML_LNOT_OP):
+ case (AML_LOGICAL_NOT_OP):
/*
* The Package will be the predicate of the Case statement.
@@ -1588,7 +1610,7 @@ AcpiDmIsCaseBlock (
switch (CurrentOp->Common.AmlOpcode)
{
- case (AML_LEQUAL_OP):
+ case (AML_LOGICAL_EQUAL_OP):
/* Next child must be NamePath with string _T_ */
@@ -1601,12 +1623,12 @@ AcpiDmIsCaseBlock (
break;
- case (AML_LNOT_OP):
+ case (AML_LOGICAL_NOT_OP):
/* Child of LNot must be LEqual op */
CurrentOp = AcpiPsGetArg (CurrentOp, 0);
- if (!CurrentOp || (CurrentOp->Common.AmlOpcode != AML_LEQUAL_OP))
+ if (!CurrentOp || (CurrentOp->Common.AmlOpcode != AML_LOGICAL_EQUAL_OP))
{
return (FALSE);
}
diff --git a/source/components/disassembler/dmutils.c b/source/components/disassembler/dmutils.c
index db6e3ca6c01e..e62e9abf0d7a 100644
--- a/source/components/disassembler/dmutils.c
+++ b/source/components/disassembler/dmutils.c
@@ -45,6 +45,7 @@
#include "accommon.h"
#include "amlcode.h"
#include "acdisasm.h"
+#include "acconvert.h"
#ifdef ACPI_ASL_COMPILER
#include <acnamesp.h>
@@ -250,6 +251,7 @@ AcpiDmCommaIfListMember (
if (!Op->Common.Next)
{
+ ASL_CV_PRINT_ONE_COMMENT (Op, AMLCOMMENT_INLINE, NULL, 0);
return (FALSE);
}
@@ -259,6 +261,7 @@ AcpiDmCommaIfListMember (
if (Op->Common.Next->Common.DisasmFlags & ACPI_PARSEOP_IGNORE)
{
+ ASL_CV_PRINT_ONE_COMMENT (Op, AMLCOMMENT_INLINE, NULL, 0);
return (FALSE);
}
@@ -275,6 +278,7 @@ AcpiDmCommaIfListMember (
*/
if (!Op->Common.Next->Common.Next)
{
+ ASL_CV_PRINT_ONE_COMMENT (Op, AMLCOMMENT_INLINE, NULL, 0);
return (FALSE);
}
}
@@ -282,6 +286,7 @@ AcpiDmCommaIfListMember (
if ((Op->Common.DisasmFlags & ACPI_PARSEOP_PARAMETER_LIST) &&
(!(Op->Common.Next->Common.DisasmFlags & ACPI_PARSEOP_PARAMETER_LIST)))
{
+ ASL_CV_PRINT_ONE_COMMENT (Op, AMLCOMMENT_INLINE, NULL, 0);
return (FALSE);
}
@@ -290,6 +295,7 @@ AcpiDmCommaIfListMember (
if (!Op->Common.OperatorSymbol)
{
AcpiOsPrintf (", ");
+ ASL_CV_PRINT_ONE_COMMENT (Op, AMLCOMMENT_INLINE, NULL, 0);
}
return (TRUE);
@@ -299,6 +305,8 @@ AcpiDmCommaIfListMember (
(Op->Common.Next->Common.DisasmFlags & ACPI_PARSEOP_PARAMETER_LIST))
{
AcpiOsPrintf (", ");
+ ASL_CV_PRINT_ONE_COMMENT (Op, AMLCOMMENT_INLINE, NULL, 0);
+
return (TRUE);
}
diff --git a/source/components/disassembler/dmwalk.c b/source/components/disassembler/dmwalk.c
index 7e2439bf3be2..548b7dce4d16 100644
--- a/source/components/disassembler/dmwalk.c
+++ b/source/components/disassembler/dmwalk.c
@@ -46,6 +46,7 @@
#include "acparser.h"
#include "amlcode.h"
#include "acdebug.h"
+#include "acconvert.h"
#define _COMPONENT ACPI_CA_DEBUGGER
@@ -63,6 +64,14 @@ AcpiDmEmitExternals (
{
return;
}
+
+void
+AcpiDmEmitExternal (
+ ACPI_PARSE_OBJECT *NameOp,
+ ACPI_PARSE_OBJECT *TypeOp)
+{
+ return;
+}
#endif
/* Local prototypes */
@@ -79,10 +88,6 @@ AcpiDmAscendingOp (
UINT32 Level,
void *Context);
-static UINT32
-AcpiDmBlockType (
- ACPI_PARSE_OBJECT *Op);
-
/*******************************************************************************
*
@@ -248,7 +253,7 @@ AcpiDmWalkParseTree (
*
******************************************************************************/
-static UINT32
+UINT32
AcpiDmBlockType (
ACPI_PARSE_OBJECT *Op)
{
@@ -270,7 +275,7 @@ AcpiDmBlockType (
case AML_DEVICE_OP:
case AML_SCOPE_OP:
case AML_PROCESSOR_OP:
- case AML_POWER_RES_OP:
+ case AML_POWER_RESOURCE_OP:
case AML_THERMAL_ZONE_OP:
case AML_IF_OP:
case AML_WHILE_OP:
@@ -292,7 +297,7 @@ AcpiDmBlockType (
/*lint -fallthrough */
case AML_PACKAGE_OP:
- case AML_VAR_PACKAGE_OP:
+ case AML_VARIABLE_PACKAGE_OP:
return (BLOCK_PAREN | BLOCK_BRACE);
@@ -304,7 +309,7 @@ AcpiDmBlockType (
if (Op->Common.Parent &&
((Op->Common.Parent->Common.AmlOpcode == AML_PACKAGE_OP) ||
- (Op->Common.Parent->Common.AmlOpcode == AML_VAR_PACKAGE_OP)))
+ (Op->Common.Parent->Common.AmlOpcode == AML_VARIABLE_PACKAGE_OP)))
{
/* This is a reference to a method, not an invocation */
@@ -357,7 +362,7 @@ AcpiDmListType (
case AML_METHOD_OP:
case AML_DEVICE_OP:
case AML_SCOPE_OP:
- case AML_POWER_RES_OP:
+ case AML_POWER_RESOURCE_OP:
case AML_PROCESSOR_OP:
case AML_THERMAL_ZONE_OP:
case AML_IF_OP:
@@ -370,7 +375,7 @@ AcpiDmListType (
case AML_BUFFER_OP:
case AML_PACKAGE_OP:
- case AML_VAR_PACKAGE_OP:
+ case AML_VARIABLE_PACKAGE_OP:
return (BLOCK_COMMA_LIST);
@@ -414,6 +419,22 @@ AcpiDmDescendingOp (
UINT32 AmlOffset;
+ /* Determine which file this parse node is contained in. */
+
+ if (Gbl_CaptureComments)
+ {
+ ASL_CV_LABEL_FILENODE (Op);
+
+ if (Level != 0 && ASL_CV_FILE_HAS_SWITCHED (Op))
+ {
+ ASL_CV_SWITCH_FILES (Level, Op);
+ }
+
+ /* If this parse node has regular comments, print them here. */
+
+ ASL_CV_PRINT_ONE_COMMENT (Op, AML_COMMENT_STANDARD, NULL, Level);
+ }
+
OpInfo = AcpiPsGetOpcodeInfo (Op->Common.AmlOpcode);
/* Listing support to dump the AML code after the ASL statement */
@@ -528,7 +549,11 @@ AcpiDmDescendingOp (
/* Emit all External() declarations here */
- AcpiDmEmitExternals ();
+ if (!AcpiGbl_DmEmitExternalOpcodes)
+ {
+ AcpiDmEmitExternals ();
+ }
+
return (AE_OK);
}
}
@@ -607,6 +632,12 @@ AcpiDmDescendingOp (
Info->Level--;
}
+ if (Op->Common.AmlOpcode == AML_EXTERNAL_OP)
+ {
+ Op->Common.DisasmFlags |= ACPI_PARSEOP_IGNORE;
+ return (AE_CTRL_DEPTH);
+ }
+
/* Start the opcode argument list if necessary */
if ((OpInfo->Flags & AML_HAS_ARGS) ||
@@ -617,6 +648,10 @@ AcpiDmDescendingOp (
if (AcpiDmBlockType (Op) & BLOCK_PAREN)
{
AcpiOsPrintf (" (");
+ if (!(AcpiDmBlockType (Op) & BLOCK_BRACE))
+ {
+ ASL_CV_PRINT_ONE_COMMENT (Op, AMLCOMMENT_INLINE, " ", 0);
+ }
}
/* If this is a named opcode, print the associated name value */
@@ -661,7 +696,7 @@ AcpiDmDescendingOp (
case AML_METHOD_OP:
AcpiDmMethodFlags (Op);
- AcpiOsPrintf (")");
+ ASL_CV_CLOSE_PAREN (Op, Level);
/* Emit description comment for Method() with a predefined ACPI name */
@@ -674,6 +709,7 @@ AcpiDmDescendingOp (
AcpiDmCheckForHardwareId (Op);
AcpiOsPrintf (", ");
+ ASL_CV_PRINT_ONE_COMMENT (Op, AML_NAMECOMMENT, NULL, 0);
break;
case AML_REGION_OP:
@@ -681,7 +717,7 @@ AcpiDmDescendingOp (
AcpiDmRegionFlags (Op);
break;
- case AML_POWER_RES_OP:
+ case AML_POWER_RESOURCE_OP:
/* Mark the next two Ops as part of the parameter list */
@@ -723,7 +759,7 @@ AcpiDmDescendingOp (
case AML_DEVICE_OP:
case AML_THERMAL_ZONE_OP:
- AcpiOsPrintf (")");
+ ASL_CV_CLOSE_PAREN (Op, Level);
break;
default:
@@ -817,7 +853,7 @@ AcpiDmDescendingOp (
*/
NextOp->Common.DisasmFlags |= ACPI_PARSEOP_IGNORE;
NextOp = NextOp->Common.Next;
- AcpiOsPrintf (")");
+ ASL_CV_CLOSE_PAREN (Op, Level);
/* Emit description comment for Name() with a predefined ACPI name */
@@ -835,7 +871,7 @@ AcpiDmDescendingOp (
return (AE_OK);
case AML_IF_OP:
- case AML_VAR_PACKAGE_OP:
+ case AML_VARIABLE_PACKAGE_OP:
case AML_WHILE_OP:
/* The next op is the size or predicate parameter */
@@ -903,6 +939,20 @@ AcpiDmAscendingOp (
ACPI_PARSE_OBJECT *ParentOp;
+ /* Point the Op's filename pointer to the proper file */
+
+ if (Gbl_CaptureComments)
+ {
+ ASL_CV_LABEL_FILENODE (Op);
+
+ /* Switch the output of these files if necessary */
+
+ if (ASL_CV_FILE_HAS_SWITCHED (Op))
+ {
+ ASL_CV_SWITCH_FILES (Level, Op);
+ }
+ }
+
if (Op->Common.DisasmFlags & ACPI_PARSEOP_IGNORE ||
Op->Common.DisasmOpcode == ACPI_DASM_IGNORE_SINGLE)
{
@@ -915,7 +965,17 @@ AcpiDmAscendingOp (
{
/* Indicates the end of the current descriptor block (table) */
- AcpiOsPrintf ("}\n\n");
+ ASL_CV_CLOSE_BRACE (Op, Level);
+
+ /* Print any comments that are at the end of the file here */
+
+ if (Gbl_CaptureComments && AcpiGbl_LastListHead)
+ {
+ AcpiOsPrintf ("\n");
+ ASL_CV_PRINT_ONE_COMMENT_LIST (AcpiGbl_LastListHead, 0);
+ }
+ AcpiOsPrintf ("\n\n");
+
return (AE_OK);
}
@@ -976,12 +1036,12 @@ AcpiDmAscendingOp (
if (Op->Common.DisasmFlags & ACPI_PARSEOP_EMPTY_TERMLIST)
{
- AcpiOsPrintf ("}");
+ ASL_CV_CLOSE_BRACE (Op, Level);
}
else
{
AcpiDmIndent (Level);
- AcpiOsPrintf ("}");
+ ASL_CV_CLOSE_BRACE (Op, Level);
}
AcpiDmCommaIfListMember (Op);
@@ -1031,7 +1091,7 @@ AcpiDmAscendingOp (
switch (Op->Common.Parent->Common.AmlOpcode)
{
case AML_PACKAGE_OP:
- case AML_VAR_PACKAGE_OP:
+ case AML_VARIABLE_PACKAGE_OP:
if (!(Op->Common.DisasmFlags & ACPI_PARSEOP_PARAMETER_LIST))
{
@@ -1071,7 +1131,7 @@ AcpiDmAscendingOp (
*/
if (Op->Common.Next || Op->Common.DisasmOpcode == ACPI_DASM_SWITCH_PREDICATE)
{
- AcpiOsPrintf (")");
+ ASL_CV_CLOSE_PAREN (Op, Level);
/*
* Emit a description comment for a Name() operator that is a
@@ -1098,7 +1158,8 @@ AcpiDmAscendingOp (
else
{
ParentOp->Common.DisasmFlags |= ACPI_PARSEOP_EMPTY_TERMLIST;
- AcpiOsPrintf (") {");
+ ASL_CV_CLOSE_PAREN (Op, Level);
+ AcpiOsPrintf ("{");
}
}
diff --git a/source/components/dispatcher/dscontrol.c b/source/components/dispatcher/dscontrol.c
index db014cfe0e7d..df22ddfb4437 100644
--- a/source/components/dispatcher/dscontrol.c
+++ b/source/components/dispatcher/dscontrol.c
@@ -358,7 +358,7 @@ AcpiDsExecEndControlOp (
break;
- case AML_BREAK_POINT_OP:
+ case AML_BREAKPOINT_OP:
AcpiDbSignalBreakPoint (WalkState);
diff --git a/source/components/dispatcher/dsmthdat.c b/source/components/dispatcher/dsmthdat.c
index 98fca89d86c0..18d7cd71b39c 100644
--- a/source/components/dispatcher/dsmthdat.c
+++ b/source/components/dispatcher/dsmthdat.c
@@ -728,7 +728,8 @@ AcpiDsStoreObjectToLocal (
*
* FUNCTION: AcpiDsMethodDataGetType
*
- * PARAMETERS: Opcode - Either AML_LOCAL_OP or AML_ARG_OP
+ * PARAMETERS: Opcode - Either AML_FIRST LOCAL_OP or
+ * AML_FIRST_ARG_OP
* Index - Which Local or Arg whose type to get
* WalkState - Current walk state object
*
diff --git a/source/components/dispatcher/dsobject.c b/source/components/dispatcher/dsobject.c
index 645c816e0c50..cb432e332a83 100644
--- a/source/components/dispatcher/dsobject.c
+++ b/source/components/dispatcher/dsobject.c
@@ -113,7 +113,7 @@ AcpiDsBuildInternalObject (
if ((Status == AE_NOT_FOUND) && (AcpiGbl_EnableInterpreterSlack) &&
((Op->Common.Parent->Common.AmlOpcode == AML_PACKAGE_OP) ||
- (Op->Common.Parent->Common.AmlOpcode == AML_VAR_PACKAGE_OP)))
+ (Op->Common.Parent->Common.AmlOpcode == AML_VARIABLE_PACKAGE_OP)))
{
/*
* We didn't find the target and we are populating elements
@@ -142,7 +142,7 @@ AcpiDsBuildInternalObject (
/* Special object resolution for elements of a package */
if ((Op->Common.Parent->Common.AmlOpcode == AML_PACKAGE_OP) ||
- (Op->Common.Parent->Common.AmlOpcode == AML_VAR_PACKAGE_OP))
+ (Op->Common.Parent->Common.AmlOpcode == AML_VARIABLE_PACKAGE_OP))
{
/*
* Attempt to resolve the node to a value before we insert it into
@@ -411,7 +411,7 @@ AcpiDsBuildInternalPackageObj (
Parent = Op->Common.Parent;
while ((Parent->Common.AmlOpcode == AML_PACKAGE_OP) ||
- (Parent->Common.AmlOpcode == AML_VAR_PACKAGE_OP))
+ (Parent->Common.AmlOpcode == AML_VARIABLE_PACKAGE_OP))
{
Parent = Parent->Common.Parent;
}
@@ -795,9 +795,9 @@ AcpiDsInitObjectFromOp (
{
case AML_TYPE_LOCAL_VARIABLE:
- /* Local ID (0-7) is (AML opcode - base AML_LOCAL_OP) */
+ /* Local ID (0-7) is (AML opcode - base AML_FIRST_LOCAL_OP) */
- ObjDesc->Reference.Value = ((UINT32) Opcode) - AML_LOCAL_OP;
+ ObjDesc->Reference.Value = ((UINT32) Opcode) - AML_FIRST_LOCAL_OP;
ObjDesc->Reference.Class = ACPI_REFCLASS_LOCAL;
#ifndef ACPI_NO_METHOD_EXECUTION
@@ -810,9 +810,9 @@ AcpiDsInitObjectFromOp (
case AML_TYPE_METHOD_ARGUMENT:
- /* Arg ID (0-6) is (AML opcode - base AML_ARG_OP) */
+ /* Arg ID (0-6) is (AML opcode - base AML_FIRST_ARG_OP) */
- ObjDesc->Reference.Value = ((UINT32) Opcode) - AML_ARG_OP;
+ ObjDesc->Reference.Value = ((UINT32) Opcode) - AML_FIRST_ARG_OP;
ObjDesc->Reference.Class = ACPI_REFCLASS_ARG;
#ifndef ACPI_NO_METHOD_EXECUTION
diff --git a/source/components/dispatcher/dsopcode.c b/source/components/dispatcher/dsopcode.c
index e7e037cf4afd..ceb0dab760a9 100644
--- a/source/components/dispatcher/dsopcode.c
+++ b/source/components/dispatcher/dsopcode.c
@@ -681,7 +681,7 @@ AcpiDsEvalDataObjectOperands (
break;
case AML_PACKAGE_OP:
- case AML_VAR_PACKAGE_OP:
+ case AML_VARIABLE_PACKAGE_OP:
Status = AcpiDsBuildInternalPackageObj (
WalkState, Op, Length, &ObjDesc);
@@ -701,7 +701,7 @@ AcpiDsEvalDataObjectOperands (
*/
if ((!Op->Common.Parent) ||
((Op->Common.Parent->Common.AmlOpcode != AML_PACKAGE_OP) &&
- (Op->Common.Parent->Common.AmlOpcode != AML_VAR_PACKAGE_OP) &&
+ (Op->Common.Parent->Common.AmlOpcode != AML_VARIABLE_PACKAGE_OP) &&
(Op->Common.Parent->Common.AmlOpcode != AML_NAME_OP)))
{
WalkState->ResultObj = ObjDesc;
diff --git a/source/components/dispatcher/dsutils.c b/source/components/dispatcher/dsutils.c
index d94001422d13..f44fb9f87c4f 100644
--- a/source/components/dispatcher/dsutils.c
+++ b/source/components/dispatcher/dsutils.c
@@ -297,8 +297,8 @@ AcpiDsIsResultUsed (
if ((Op->Common.Parent->Common.AmlOpcode == AML_REGION_OP) ||
(Op->Common.Parent->Common.AmlOpcode == AML_DATA_REGION_OP) ||
(Op->Common.Parent->Common.AmlOpcode == AML_PACKAGE_OP) ||
- (Op->Common.Parent->Common.AmlOpcode == AML_VAR_PACKAGE_OP) ||
(Op->Common.Parent->Common.AmlOpcode == AML_BUFFER_OP) ||
+ (Op->Common.Parent->Common.AmlOpcode == AML_VARIABLE_PACKAGE_OP) ||
(Op->Common.Parent->Common.AmlOpcode == AML_INT_EVAL_SUBTREE_OP) ||
(Op->Common.Parent->Common.AmlOpcode == AML_BANK_FIELD_OP))
{
@@ -589,7 +589,7 @@ AcpiDsCreateOperand (
*/
if (Status == AE_NOT_FOUND)
{
- if (ParentOp->Common.AmlOpcode == AML_COND_REF_OF_OP)
+ if (ParentOp->Common.AmlOpcode == AML_CONDITIONAL_REF_OF_OP)
{
/*
* For the Conditional Reference op, it's OK if
@@ -870,7 +870,7 @@ AcpiDsEvaluateNamePath (
}
if ((Op->Common.Parent->Common.AmlOpcode == AML_PACKAGE_OP) ||
- (Op->Common.Parent->Common.AmlOpcode == AML_VAR_PACKAGE_OP) ||
+ (Op->Common.Parent->Common.AmlOpcode == AML_VARIABLE_PACKAGE_OP) ||
(Op->Common.Parent->Common.AmlOpcode == AML_REF_OF_OP))
{
/* TBD: Should we specify this feature as a bit of OpInfo->Flags of these opcodes? */
diff --git a/source/components/dispatcher/dswexec.c b/source/components/dispatcher/dswexec.c
index 35f348f5f56b..7d7022e1721e 100644
--- a/source/components/dispatcher/dswexec.c
+++ b/source/components/dispatcher/dswexec.c
@@ -536,7 +536,7 @@ AcpiDsExecEndOp (
*/
if ((Op->Asl.Parent) &&
((Op->Asl.Parent->Asl.AmlOpcode == AML_PACKAGE_OP) ||
- (Op->Asl.Parent->Asl.AmlOpcode == AML_VAR_PACKAGE_OP)))
+ (Op->Asl.Parent->Asl.AmlOpcode == AML_VARIABLE_PACKAGE_OP)))
{
ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH,
"Method Reference in a Package, Op=%p\n", Op));
diff --git a/source/components/dispatcher/dswload2.c b/source/components/dispatcher/dswload2.c
index a81e978b4364..4985f2078cfe 100644
--- a/source/components/dispatcher/dswload2.c
+++ b/source/components/dispatcher/dswload2.c
@@ -543,7 +543,7 @@ AcpiDsLoad2EndOp (
Status = AcpiExCreateProcessor (WalkState);
break;
- case AML_POWER_RES_OP:
+ case AML_POWER_RESOURCE_OP:
Status = AcpiExCreatePowerResource (WalkState);
break;
diff --git a/source/components/executer/exmisc.c b/source/components/executer/exmisc.c
index 6d171167e634..80d420cb87df 100644
--- a/source/components/executer/exmisc.c
+++ b/source/components/executer/exmisc.c
@@ -274,7 +274,7 @@ AcpiExDoLogicalNumericOp (
switch (Opcode)
{
- case AML_LAND_OP: /* LAnd (Integer0, Integer1) */
+ case AML_LOGICAL_AND_OP: /* LAnd (Integer0, Integer1) */
if (Integer0 && Integer1)
{
@@ -282,7 +282,7 @@ AcpiExDoLogicalNumericOp (
}
break;
- case AML_LOR_OP: /* LOr (Integer0, Integer1) */
+ case AML_LOGICAL_OR_OP: /* LOr (Integer0, Integer1) */
if (Integer0 || Integer1)
{
@@ -400,7 +400,7 @@ AcpiExDoLogicalOp (
switch (Opcode)
{
- case AML_LEQUAL_OP: /* LEqual (Operand0, Operand1) */
+ case AML_LOGICAL_EQUAL_OP: /* LEqual (Operand0, Operand1) */
if (Integer0 == Integer1)
{
@@ -408,7 +408,7 @@ AcpiExDoLogicalOp (
}
break;
- case AML_LGREATER_OP: /* LGreater (Operand0, Operand1) */
+ case AML_LOGICAL_GREATER_OP: /* LGreater (Operand0, Operand1) */
if (Integer0 > Integer1)
{
@@ -416,7 +416,7 @@ AcpiExDoLogicalOp (
}
break;
- case AML_LLESS_OP: /* LLess (Operand0, Operand1) */
+ case AML_LOGICAL_LESS_OP: /* LLess (Operand0, Operand1) */
if (Integer0 < Integer1)
{
@@ -449,7 +449,7 @@ AcpiExDoLogicalOp (
switch (Opcode)
{
- case AML_LEQUAL_OP: /* LEqual (Operand0, Operand1) */
+ case AML_LOGICAL_EQUAL_OP: /* LEqual (Operand0, Operand1) */
/* Length and all bytes must be equal */
@@ -462,7 +462,7 @@ AcpiExDoLogicalOp (
}
break;
- case AML_LGREATER_OP: /* LGreater (Operand0, Operand1) */
+ case AML_LOGICAL_GREATER_OP: /* LGreater (Operand0, Operand1) */
if (Compare > 0)
{
@@ -482,7 +482,7 @@ AcpiExDoLogicalOp (
}
break;
- case AML_LLESS_OP: /* LLess (Operand0, Operand1) */
+ case AML_LOGICAL_LESS_OP: /* LLess (Operand0, Operand1) */
if (Compare > 0)
{
diff --git a/source/components/executer/exnames.c b/source/components/executer/exnames.c
index e921745432b6..7cd68ba1314d 100644
--- a/source/components/executer/exnames.c
+++ b/source/components/executer/exnames.c
@@ -141,7 +141,7 @@ AcpiExAllocateNameString (
{
/* Set up multi prefixes */
- *TempPtr++ = AML_MULTI_NAME_PREFIX_OP;
+ *TempPtr++ = AML_MULTI_NAME_PREFIX;
*TempPtr++ = (char) NumNameSegs;
}
else if (2 == NumNameSegs)
@@ -385,7 +385,7 @@ AcpiExGetNameString (
}
break;
- case AML_MULTI_NAME_PREFIX_OP:
+ case AML_MULTI_NAME_PREFIX:
ACPI_DEBUG_PRINT ((ACPI_DB_LOAD, "MultiNamePrefix at %p\n",
AmlAddress));
diff --git a/source/components/executer/exoparg1.c b/source/components/executer/exoparg1.c
index 656c60afd293..b3323db774d9 100644
--- a/source/components/executer/exoparg1.c
+++ b/source/components/executer/exoparg1.c
@@ -304,7 +304,7 @@ AcpiExOpcode_1A_1T_1R (
case AML_FIND_SET_RIGHT_BIT_OP:
case AML_FROM_BCD_OP:
case AML_TO_BCD_OP:
- case AML_COND_REF_OF_OP:
+ case AML_CONDITIONAL_REF_OF_OP:
/* Create a return object of type Integer for these opcodes */
@@ -435,7 +435,7 @@ AcpiExOpcode_1A_1T_1R (
}
break;
- case AML_COND_REF_OF_OP: /* CondRefOf (SourceObject, Result) */
+ case AML_CONDITIONAL_REF_OF_OP: /* CondRefOf (SourceObject, Result) */
/*
* This op is a little strange because the internal return value is
* different than the return value stored in the result descriptor
@@ -507,13 +507,13 @@ AcpiExOpcode_1A_1T_1R (
/*
* ACPI 2.0 Opcodes
*/
- case AML_COPY_OP: /* Copy (Source, Target) */
+ case AML_COPY_OBJECT_OP: /* CopyObject (Source, Target) */
Status = AcpiUtCopyIobjectToIobject (
Operand[0], &ReturnDesc, WalkState);
break;
- case AML_TO_DECSTRING_OP: /* ToDecimalString (Data, Result) */
+ case AML_TO_DECIMAL_STRING_OP: /* ToDecimalString (Data, Result) */
Status = AcpiExConvertToString (
Operand[0], &ReturnDesc, ACPI_EXPLICIT_CONVERT_DECIMAL);
@@ -525,7 +525,7 @@ AcpiExOpcode_1A_1T_1R (
}
break;
- case AML_TO_HEXSTRING_OP: /* ToHexString (Data, Result) */
+ case AML_TO_HEX_STRING_OP: /* ToHexString (Data, Result) */
Status = AcpiExConvertToString (
Operand[0], &ReturnDesc, ACPI_EXPLICIT_CONVERT_HEX);
@@ -640,7 +640,7 @@ AcpiExOpcode_1A_0T_1R (
switch (WalkState->Opcode)
{
- case AML_LNOT_OP: /* LNot (Operand) */
+ case AML_LOGICAL_NOT_OP: /* LNot (Operand) */
ReturnDesc = AcpiUtCreateIntegerObject ((UINT64) 0);
if (!ReturnDesc)
@@ -691,7 +691,8 @@ AcpiExOpcode_1A_0T_1R (
* NOTE: We use LNOT_OP here in order to force resolution of the
* reference operand to an actual integer.
*/
- Status = AcpiExResolveOperands (AML_LNOT_OP, &TempDesc, WalkState);
+ Status = AcpiExResolveOperands (AML_LOGICAL_NOT_OP,
+ &TempDesc, WalkState);
if (ACPI_FAILURE (Status))
{
ACPI_EXCEPTION ((AE_INFO, Status,
diff --git a/source/components/executer/exoparg2.c b/source/components/executer/exoparg2.c
index 01003d4a2cc8..cbbb4b5f86b9 100644
--- a/source/components/executer/exoparg2.c
+++ b/source/components/executer/exoparg2.c
@@ -330,7 +330,7 @@ AcpiExOpcode_2A_1T_1R (
&ReturnDesc->Integer.Value);
break;
- case AML_CONCAT_OP: /* Concatenate (Data1, Data2, Result) */
+ case AML_CONCATENATE_OP: /* Concatenate (Data1, Data2, Result) */
Status = AcpiExDoConcatenate (
Operand[0], Operand[1], &ReturnDesc, WalkState);
@@ -376,7 +376,7 @@ AcpiExOpcode_2A_1T_1R (
Operand[0]->Buffer.Pointer, Length);
break;
- case AML_CONCAT_RES_OP:
+ case AML_CONCATENATE_TEMPLATE_OP:
/* ConcatenateResTemplate (Buffer, Buffer, Result) (ACPI 2.0) */
diff --git a/source/components/executer/exoparg6.c b/source/components/executer/exoparg6.c
index d3e6d9d299c0..89c089bbb2d3 100644
--- a/source/components/executer/exoparg6.c
+++ b/source/components/executer/exoparg6.c
@@ -133,7 +133,7 @@ AcpiExDoMatch (
* Change to: (M == P[i])
*/
Status = AcpiExDoLogicalOp (
- AML_LEQUAL_OP, MatchObj, PackageObj, &LogicalResult);
+ AML_LOGICAL_EQUAL_OP, MatchObj, PackageObj, &LogicalResult);
if (ACPI_FAILURE (Status))
{
return (FALSE);
@@ -146,7 +146,7 @@ AcpiExDoMatch (
* Change to: (M >= P[i]) (M NotLess than P[i])
*/
Status = AcpiExDoLogicalOp (
- AML_LLESS_OP, MatchObj, PackageObj, &LogicalResult);
+ AML_LOGICAL_LESS_OP, MatchObj, PackageObj, &LogicalResult);
if (ACPI_FAILURE (Status))
{
return (FALSE);
@@ -160,7 +160,7 @@ AcpiExDoMatch (
* Change to: (M > P[i])
*/
Status = AcpiExDoLogicalOp (
- AML_LGREATER_OP, MatchObj, PackageObj, &LogicalResult);
+ AML_LOGICAL_GREATER_OP, MatchObj, PackageObj, &LogicalResult);
if (ACPI_FAILURE (Status))
{
return (FALSE);
@@ -173,7 +173,7 @@ AcpiExDoMatch (
* Change to: (M <= P[i]) (M NotGreater than P[i])
*/
Status = AcpiExDoLogicalOp (
- AML_LGREATER_OP, MatchObj, PackageObj, &LogicalResult);
+ AML_LOGICAL_GREATER_OP, MatchObj, PackageObj, &LogicalResult);
if (ACPI_FAILURE (Status))
{
return (FALSE);
@@ -187,7 +187,7 @@ AcpiExDoMatch (
* Change to: (M < P[i])
*/
Status = AcpiExDoLogicalOp (
- AML_LLESS_OP, MatchObj, PackageObj, &LogicalResult);
+ AML_LOGICAL_LESS_OP, MatchObj, PackageObj, &LogicalResult);
if (ACPI_FAILURE (Status))
{
return (FALSE);
diff --git a/source/components/executer/exresolv.c b/source/components/executer/exresolv.c
index b15e08c97c0b..bbef5c12f76c 100644
--- a/source/components/executer/exresolv.c
+++ b/source/components/executer/exresolv.c
@@ -210,7 +210,7 @@ AcpiExResolveObjectToValue (
/* If method call or CopyObject - do not dereference */
if ((WalkState->Opcode == AML_INT_METHODCALL_OP) ||
- (WalkState->Opcode == AML_COPY_OP))
+ (WalkState->Opcode == AML_COPY_OBJECT_OP))
{
break;
}
diff --git a/source/components/executer/exstore.c b/source/components/executer/exstore.c
index b9a8906ce9b1..cc3074b0e498 100644
--- a/source/components/executer/exstore.c
+++ b/source/components/executer/exstore.c
@@ -435,7 +435,7 @@ AcpiExStoreObjectToNode (
/* Only limited target types possible for everything except CopyObject */
- if (WalkState->Opcode != AML_COPY_OP)
+ if (WalkState->Opcode != AML_COPY_OBJECT_OP)
{
/*
* Only CopyObject allows all object types to be overwritten. For
@@ -521,7 +521,7 @@ AcpiExStoreObjectToNode (
case ACPI_TYPE_STRING:
case ACPI_TYPE_BUFFER:
- if ((WalkState->Opcode == AML_COPY_OP) ||
+ if ((WalkState->Opcode == AML_COPY_OBJECT_OP) ||
!ImplicitConversion)
{
/*
diff --git a/source/components/executer/exstoren.c b/source/components/executer/exstoren.c
index 88c2eac452d5..d930ed425215 100644
--- a/source/components/executer/exstoren.c
+++ b/source/components/executer/exstoren.c
@@ -113,7 +113,7 @@ AcpiExResolveObject (
/* For CopyObject, no further validation necessary */
- if (WalkState->Opcode == AML_COPY_OP)
+ if (WalkState->Opcode == AML_COPY_OBJECT_OP)
{
break;
}
diff --git a/source/components/hardware/hwvalid.c b/source/components/hardware/hwvalid.c
index e96125878b70..8fce29b137df 100644
--- a/source/components/hardware/hwvalid.c
+++ b/source/components/hardware/hwvalid.c
@@ -107,7 +107,7 @@ static const ACPI_PORT_INFO AcpiProtectedPorts[] =
{"PCI", 0x0CF8, 0x0CFF, ACPI_OSI_WIN_XP}
};
-#define ACPI_PORT_INFO_ENTRIES ACPI_ARRAY_LENGTH (AcpiProtectedPorts)
+#define ACPI_PORT_INFO_ENTRIES ACPI_ARRAY_LENGTH (AcpiProtectedPorts)
/******************************************************************************
@@ -137,7 +137,7 @@ AcpiHwValidateIoRequest (
const ACPI_PORT_INFO *PortInfo;
- ACPI_FUNCTION_TRACE (HwValidateIoRequest);
+ ACPI_FUNCTION_NAME (HwValidateIoRequest);
/* Supported widths are 8/16/32 */
@@ -166,14 +166,14 @@ AcpiHwValidateIoRequest (
ACPI_ERROR ((AE_INFO,
"Illegal I/O port address/length above 64K: %8.8X%8.8X/0x%X",
ACPI_FORMAT_UINT64 (Address), ByteWidth));
- return_ACPI_STATUS (AE_LIMIT);
+ return (AE_LIMIT);
}
/* Exit if requested address is not within the protected port table */
if (Address > AcpiProtectedPorts[ACPI_PORT_INFO_ENTRIES - 1].End)
{
- return_ACPI_STATUS (AE_OK);
+ return (AE_OK);
}
/* Check request against the list of protected I/O ports */
@@ -182,7 +182,7 @@ AcpiHwValidateIoRequest (
{
/*
* Check if the requested address range will write to a reserved
- * port. Four cases to consider:
+ * port. There are four cases to consider:
*
* 1) Address range is contained completely in the port address range
* 2) Address range overlaps port range at the port range start
@@ -212,7 +212,7 @@ AcpiHwValidateIoRequest (
}
}
- return_ACPI_STATUS (AE_OK);
+ return (AE_OK);
}
@@ -221,7 +221,7 @@ AcpiHwValidateIoRequest (
* FUNCTION: AcpiHwReadPort
*
* PARAMETERS: Address Address of I/O port/register to read
- * Value Where value is placed
+ * Value Where value (data) is returned
* Width Number of bits
*
* RETURN: Status and value read from port
@@ -267,7 +267,7 @@ AcpiHwReadPort (
/*
* There has been a protection violation within the request. Fall
* back to byte granularity port I/O and ignore the failing bytes.
- * This provides Windows compatibility.
+ * This provides compatibility with other ACPI implementations.
*/
for (i = 0, *Value = 0; i < Width; i += 8)
{
@@ -341,7 +341,7 @@ AcpiHwWritePort (
/*
* There has been a protection violation within the request. Fall
* back to byte granularity port I/O and ignore the failing bytes.
- * This provides Windows compatibility.
+ * This provides compatibility with other ACPI implementations.
*/
for (i = 0; i < Width; i += 8)
{
diff --git a/source/components/namespace/nsaccess.c b/source/components/namespace/nsaccess.c
index 2dd55c44f69a..7b5715be30e3 100644
--- a/source/components/namespace/nsaccess.c
+++ b/source/components/namespace/nsaccess.c
@@ -505,7 +505,7 @@ AcpiNsLookup (
"Dual Pathname (2 segments, Flags=%X)\n", Flags));
break;
- case AML_MULTI_NAME_PREFIX_OP:
+ case AML_MULTI_NAME_PREFIX:
/* More than one NameSeg, search rules do not apply */
diff --git a/source/components/namespace/nsrepair.c b/source/components/namespace/nsrepair.c
index 96dd88562e04..59957e4e7a09 100644
--- a/source/components/namespace/nsrepair.c
+++ b/source/components/namespace/nsrepair.c
@@ -302,24 +302,12 @@ ObjectRepaired:
if (PackageIndex != ACPI_NOT_PACKAGE_ELEMENT)
{
- /*
- * The original object is a package element. We need to
- * decrement the reference count of the original object,
- * for removing it from the package.
- *
- * However, if the original object was just wrapped with a
- * package object as part of the repair, we don't need to
- * change the reference count.
- */
+ /* Update reference count of new object */
+
if (!(Info->ReturnFlags & ACPI_OBJECT_WRAPPED))
{
NewObject->Common.ReferenceCount =
ReturnObject->Common.ReferenceCount;
-
- if (ReturnObject->Common.ReferenceCount > 1)
- {
- ReturnObject->Common.ReferenceCount--;
- }
}
ACPI_DEBUG_PRINT ((ACPI_DB_REPAIR,
diff --git a/source/components/namespace/nsrepair2.c b/source/components/namespace/nsrepair2.c
index fe8b763903a7..22ac8702c903 100644
--- a/source/components/namespace/nsrepair2.c
+++ b/source/components/namespace/nsrepair2.c
@@ -448,16 +448,12 @@ AcpiNsRepair_CID (
return (Status);
}
- /* Take care with reference counts */
-
if (OriginalElement != *ElementPtr)
{
- /* Element was replaced */
+ /* Update reference count of new object */
(*ElementPtr)->Common.ReferenceCount =
OriginalRefCount;
-
- AcpiUtRemoveReference (OriginalElement);
}
ElementPtr++;
diff --git a/source/components/namespace/nsutils.c b/source/components/namespace/nsutils.c
index 3664cbe4657e..652b19c12e2c 100644
--- a/source/components/namespace/nsutils.c
+++ b/source/components/namespace/nsutils.c
@@ -294,7 +294,7 @@ AcpiNsBuildInternalName (
}
else
{
- InternalName[1] = AML_MULTI_NAME_PREFIX_OP;
+ InternalName[1] = AML_MULTI_NAME_PREFIX;
InternalName[2] = (char) NumSegments;
Result = &InternalName[3];
}
@@ -325,7 +325,7 @@ AcpiNsBuildInternalName (
}
else
{
- InternalName[i] = AML_MULTI_NAME_PREFIX_OP;
+ InternalName[i] = AML_MULTI_NAME_PREFIX;
InternalName[(ACPI_SIZE) i+1] = (char) NumSegments;
Result = &InternalName[(ACPI_SIZE) i+2];
}
@@ -534,7 +534,7 @@ AcpiNsExternalizeName (
{
switch (InternalName[PrefixLength])
{
- case AML_MULTI_NAME_PREFIX_OP:
+ case AML_MULTI_NAME_PREFIX:
/* <count> 4-byte names */
@@ -694,28 +694,23 @@ AcpiNsTerminate (
void)
{
ACPI_STATUS Status;
+ ACPI_OPERAND_OBJECT *Prev;
+ ACPI_OPERAND_OBJECT *Next;
ACPI_FUNCTION_TRACE (NsTerminate);
-#ifdef ACPI_EXEC_APP
- {
- ACPI_OPERAND_OBJECT *Prev;
- ACPI_OPERAND_OBJECT *Next;
-
- /* Delete any module-level code blocks */
+ /* Delete any module-level code blocks */
- Next = AcpiGbl_ModuleCodeList;
- while (Next)
- {
- Prev = Next;
- Next = Next->Method.Mutex;
- Prev->Method.Mutex = NULL; /* Clear the Mutex (cheated) field */
- AcpiUtRemoveReference (Prev);
- }
+ Next = AcpiGbl_ModuleCodeList;
+ while (Next)
+ {
+ Prev = Next;
+ Next = Next->Method.Mutex;
+ Prev->Method.Mutex = NULL; /* Clear the Mutex (cheated) field */
+ AcpiUtRemoveReference (Prev);
}
-#endif
/*
* Free the entire namespace -- all nodes and all objects
diff --git a/source/components/parser/psargs.c b/source/components/parser/psargs.c
index 22f7a2907f15..4fc55b2e1866 100644
--- a/source/components/parser/psargs.c
+++ b/source/components/parser/psargs.c
@@ -47,6 +47,7 @@
#include "amlcode.h"
#include "acnamesp.h"
#include "acdispat.h"
+#include "acconvert.h"
#define _COMPONENT ACPI_PARSER
ACPI_MODULE_NAME ("psargs")
@@ -208,7 +209,7 @@ AcpiPsGetNextNamestring (
End += 1 + (2 * ACPI_NAME_SIZE);
break;
- case AML_MULTI_NAME_PREFIX_OP:
+ case AML_MULTI_NAME_PREFIX:
/* Multiple name segments, 4 chars each, count in next byte */
@@ -369,7 +370,7 @@ AcpiPsGetNextNamepath (
/* 2) NotFound during a CondRefOf(x) is ok by definition */
- else if (WalkState->Op->Common.AmlOpcode == AML_COND_REF_OF_OP)
+ else if (WalkState->Op->Common.AmlOpcode == AML_CONDITIONAL_REF_OF_OP)
{
Status = AE_OK;
}
@@ -381,7 +382,7 @@ AcpiPsGetNextNamepath (
*/
else if ((Arg->Common.Parent) &&
((Arg->Common.Parent->Common.AmlOpcode == AML_PACKAGE_OP) ||
- (Arg->Common.Parent->Common.AmlOpcode == AML_VAR_PACKAGE_OP)))
+ (Arg->Common.Parent->Common.AmlOpcode == AML_VARIABLE_PACKAGE_OP)))
{
Status = AE_OK;
}
@@ -543,6 +544,7 @@ AcpiPsGetNextField (
ACPI_FUNCTION_TRACE (PsGetNextField);
+ ASL_CV_CAPTURE_COMMENTS_ONLY (ParserState);
Aml = ParserState->Aml;
/* Determine field type */
@@ -589,6 +591,7 @@ AcpiPsGetNextField (
/* Decode the field type */
+ ASL_CV_CAPTURE_COMMENTS_ONLY (ParserState);
switch (Opcode)
{
case AML_INT_NAMEDFIELD_OP:
@@ -599,6 +602,23 @@ AcpiPsGetNextField (
AcpiPsSetName (Field, Name);
ParserState->Aml += ACPI_NAME_SIZE;
+
+ ASL_CV_CAPTURE_COMMENTS_ONLY (ParserState);
+
+#ifdef ACPI_ASL_COMPILER
+ /*
+ * Because the package length isn't represented as a parse tree object,
+ * take comments surrounding this and add to the previously created
+ * parse node.
+ */
+ if (Field->Common.InlineComment)
+ {
+ Field->Common.NameComment = Field->Common.InlineComment;
+ }
+ Field->Common.InlineComment = AcpiGbl_CurrentInlineComment;
+ AcpiGbl_CurrentInlineComment = NULL;
+#endif
+
/* Get the length which is encoded as a package length */
Field->Common.Value.Size = AcpiPsGetNextPackageLength (ParserState);
@@ -655,10 +675,12 @@ AcpiPsGetNextField (
{
ParserState->Aml++;
+ ASL_CV_CAPTURE_COMMENTS_ONLY (ParserState);
PkgEnd = ParserState->Aml;
PkgLength = AcpiPsGetNextPackageLength (ParserState);
PkgEnd += PkgLength;
+ ASL_CV_CAPTURE_COMMENTS_ONLY (ParserState);
if (ParserState->Aml < PkgEnd)
{
/* Non-empty list */
@@ -675,6 +697,7 @@ AcpiPsGetNextField (
Opcode = ACPI_GET8 (ParserState->Aml);
ParserState->Aml++;
+ ASL_CV_CAPTURE_COMMENTS_ONLY (ParserState);
switch (Opcode)
{
case AML_BYTE_OP: /* AML_BYTEDATA_ARG */
@@ -703,6 +726,7 @@ AcpiPsGetNextField (
/* Fill in bytelist data */
+ ASL_CV_CAPTURE_COMMENTS_ONLY (ParserState);
Arg->Named.Value.Size = BufferLength;
Arg->Named.Data = ParserState->Aml;
}
diff --git a/source/components/parser/psloop.c b/source/components/parser/psloop.c
index be5b2607c7e7..9ff8bcfb77e6 100644
--- a/source/components/parser/psloop.c
+++ b/source/components/parser/psloop.c
@@ -55,6 +55,7 @@
#include "acparser.h"
#include "acdispat.h"
#include "amlcode.h"
+#include "acconvert.h"
#define _COMPONENT ACPI_PARSER
ACPI_MODULE_NAME ("psloop")
@@ -142,6 +143,22 @@ AcpiPsGetArguments (
{
WalkState->Aml = WalkState->ParserState.Aml;
+ switch (Op->Common.AmlOpcode)
+ {
+ case AML_METHOD_OP:
+ case AML_BUFFER_OP:
+ case AML_PACKAGE_OP:
+ case AML_VARIABLE_PACKAGE_OP:
+ case AML_WHILE_OP:
+
+ break;
+
+ default:
+
+ ASL_CV_CAPTURE_COMMENTS (WalkState);
+ break;
+ }
+
Status = AcpiPsGetNextArg (WalkState, &(WalkState->ParserState),
GET_CURRENT_ARG_TYPE (WalkState->ArgTypes), &Arg);
if (ACPI_FAILURE (Status))
@@ -249,7 +266,7 @@ AcpiPsGetArguments (
case AML_BUFFER_OP:
case AML_PACKAGE_OP:
- case AML_VAR_PACKAGE_OP:
+ case AML_VARIABLE_PACKAGE_OP:
if ((Op->Common.Parent) &&
(Op->Common.Parent->Common.AmlOpcode == AML_NAME_OP) &&
@@ -487,6 +504,8 @@ AcpiPsParseLoop (
while ((ParserState->Aml < ParserState->AmlEnd) || (Op))
{
+ ASL_CV_CAPTURE_COMMENTS (WalkState);
+
AmlOpStart = ParserState->Aml;
if (!Op)
{
@@ -520,12 +539,26 @@ AcpiPsParseLoop (
AcpiExStartTraceOpcode (Op, WalkState);
}
-
/*
* Start ArgCount at zero because we don't know if there are
* any args yet
*/
- WalkState->ArgCount = 0;
+ WalkState->ArgCount = 0;
+
+ switch (Op->Common.AmlOpcode)
+ {
+ case AML_BYTE_OP:
+ case AML_WORD_OP:
+ case AML_DWORD_OP:
+ case AML_QWORD_OP:
+
+ break;
+
+ default:
+
+ ASL_CV_CAPTURE_COMMENTS (WalkState);
+ break;
+ }
/* Are there any arguments that must be processed? */
diff --git a/source/components/parser/psobject.c b/source/components/parser/psobject.c
index 7f1a0860f14e..bcc2aa2686dd 100644
--- a/source/components/parser/psobject.c
+++ b/source/components/parser/psobject.c
@@ -45,6 +45,7 @@
#include "accommon.h"
#include "acparser.h"
#include "amlcode.h"
+#include "acconvert.h"
#define _COMPONENT ACPI_PARSER
ACPI_MODULE_NAME ("psobject")
@@ -201,6 +202,7 @@ AcpiPsBuildNamedOp (
while (GET_CURRENT_ARG_TYPE (WalkState->ArgTypes) &&
(GET_CURRENT_ARG_TYPE (WalkState->ArgTypes) != ARGP_NAME))
{
+ ASL_CV_CAPTURE_COMMENTS (WalkState);
Status = AcpiPsGetNextArg (WalkState, &(WalkState->ParserState),
GET_CURRENT_ARG_TYPE (WalkState->ArgTypes), &Arg);
if (ACPI_FAILURE (Status))
@@ -212,6 +214,18 @@ AcpiPsBuildNamedOp (
INCREMENT_ARG_LIST (WalkState->ArgTypes);
}
+ /* are there any inline comments associated with the NameSeg?? If so, save this. */
+
+ ASL_CV_CAPTURE_COMMENTS (WalkState);
+
+#ifdef ACPI_ASL_COMPILER
+ if (AcpiGbl_CurrentInlineComment != NULL)
+ {
+ UnnamedOp->Common.NameComment = AcpiGbl_CurrentInlineComment;
+ AcpiGbl_CurrentInlineComment = NULL;
+ }
+#endif
+
/*
* Make sure that we found a NAME and didn't run out of arguments
*/
@@ -257,6 +271,28 @@ AcpiPsBuildNamedOp (
AcpiPsAppendArg (*Op, UnnamedOp->Common.Value.Arg);
+#ifdef ACPI_ASL_COMPILER
+
+ /* save any comments that might be associated with UnnamedOp. */
+
+ (*Op)->Common.InlineComment = UnnamedOp->Common.InlineComment;
+ (*Op)->Common.EndNodeComment = UnnamedOp->Common.EndNodeComment;
+ (*Op)->Common.CloseBraceComment = UnnamedOp->Common.CloseBraceComment;
+ (*Op)->Common.NameComment = UnnamedOp->Common.NameComment;
+ (*Op)->Common.CommentList = UnnamedOp->Common.CommentList;
+ (*Op)->Common.EndBlkComment = UnnamedOp->Common.EndBlkComment;
+ (*Op)->Common.CvFilename = UnnamedOp->Common.CvFilename;
+ (*Op)->Common.CvParentFilename = UnnamedOp->Common.CvParentFilename;
+ (*Op)->Named.Aml = UnnamedOp->Common.Aml;
+
+ UnnamedOp->Common.InlineComment = NULL;
+ UnnamedOp->Common.EndNodeComment = NULL;
+ UnnamedOp->Common.CloseBraceComment = NULL;
+ UnnamedOp->Common.NameComment = NULL;
+ UnnamedOp->Common.CommentList = NULL;
+ UnnamedOp->Common.EndBlkComment = NULL;
+#endif
+
if ((*Op)->Common.AmlOpcode == AML_REGION_OP ||
(*Op)->Common.AmlOpcode == AML_DATA_REGION_OP)
{
diff --git a/source/components/parser/psopcode.c b/source/components/parser/psopcode.c
index 968d7db9df9f..c355c3da791d 100644
--- a/source/components/parser/psopcode.c
+++ b/source/components/parser/psopcode.c
@@ -72,7 +72,7 @@
AML_DEVICE_OP
AML_THERMAL_ZONE_OP
AML_METHOD_OP
- AML_POWER_RES_OP
+ AML_POWER_RESOURCE_OP
AML_PROCESSOR_OP
AML_FIELD_OP
AML_INDEX_FIELD_OP
@@ -98,7 +98,7 @@
AML_DEVICE_OP
AML_THERMAL_ZONE_OP
AML_METHOD_OP
- AML_POWER_RES_OP
+ AML_POWER_RESOURCE_OP
AML_PROCESSOR_OP
AML_FIELD_OP
AML_INDEX_FIELD_OP
@@ -116,7 +116,7 @@
AML_DEVICE_OP
AML_THERMAL_ZONE_OP
AML_METHOD_OP
- AML_POWER_RES_OP
+ AML_POWER_RESOURCE_OP
AML_PROCESSOR_OP
AML_NAME_OP
AML_ALIAS_OP
@@ -139,7 +139,7 @@
AML_DEVICE_OP
AML_THERMAL_ZONE_OP
AML_METHOD_OP
- AML_POWER_RES_OP
+ AML_POWER_RESOURCE_OP
AML_PROCESSOR_OP
AML_NAME_OP
AML_ALIAS_OP
@@ -152,7 +152,7 @@
must be deferred until needed
AML_METHOD_OP
- AML_VAR_PACKAGE_OP
+ AML_VARIABLE_PACKAGE_OP
AML_CREATE_FIELD_OP
AML_CREATE_BIT_FIELD_OP
AML_CREATE_BYTE_FIELD_OP
@@ -337,7 +337,8 @@ const ACPI_OPCODE_INFO AcpiGbl_AmlOpInfo[AML_NUM_OPCODES] =
/* ACPI 6.0 opcodes */
-/* 81 */ ACPI_OP ("External", ARGP_EXTERNAL_OP, ARGI_EXTERNAL_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE,/* ? */ AML_TYPE_EXEC_3A_0T_0R, AML_FLAGS_EXEC_3A_0T_0R)
+/* 81 */ ACPI_OP ("External", ARGP_EXTERNAL_OP, ARGI_EXTERNAL_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE,/* ? */ AML_TYPE_EXEC_3A_0T_0R, AML_FLAGS_EXEC_3A_0T_0R),
+/* 82 */ ACPI_OP ("Comment", ARGP_COMMENT_OP, ARGI_COMMENT_OP, ACPI_TYPE_STRING, AML_CLASS_ARGUMENT, AML_TYPE_LITERAL, AML_CONSTANT)
/*! [End] no source code translation !*/
};
diff --git a/source/components/parser/psopinfo.c b/source/components/parser/psopinfo.c
index fa4bb1152edf..d8f812945e25 100644
--- a/source/components/parser/psopinfo.c
+++ b/source/components/parser/psopinfo.c
@@ -242,7 +242,7 @@ const UINT8 AcpiGbl_ShortOpIndex[256] =
/* 0x90 */ 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x73, 0x74,
/* 0x98 */ 0x75, 0x76, _UNK, _UNK, 0x77, 0x78, 0x79, 0x7A,
/* 0xA0 */ 0x3e, 0x3f, 0x40, 0x41, 0x42, 0x43, 0x60, 0x61,
-/* 0xA8 */ 0x62, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK,
+/* 0xA8 */ 0x62, 0x82, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK,
/* 0xB0 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK,
/* 0xB8 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK,
/* 0xC0 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK,
diff --git a/source/components/parser/psparse.c b/source/components/parser/psparse.c
index d8ec494a2d75..112a4fcb91f5 100644
--- a/source/components/parser/psparse.c
+++ b/source/components/parser/psparse.c
@@ -114,7 +114,7 @@ AcpiPsPeekOpcode (
Aml = ParserState->Aml;
Opcode = (UINT16) ACPI_GET8 (Aml);
- if (Opcode == AML_EXTENDED_OP_PREFIX)
+ if (Opcode == AML_EXTENDED_PREFIX)
{
/* Extended opcode, get the second opcode byte */
@@ -218,7 +218,7 @@ AcpiPsCompleteThisOp (
(Op->Common.Parent->Common.AmlOpcode == AML_BUFFER_OP) ||
(Op->Common.Parent->Common.AmlOpcode == AML_PACKAGE_OP) ||
(Op->Common.Parent->Common.AmlOpcode == AML_BANK_FIELD_OP) ||
- (Op->Common.Parent->Common.AmlOpcode == AML_VAR_PACKAGE_OP))
+ (Op->Common.Parent->Common.AmlOpcode == AML_VARIABLE_PACKAGE_OP))
{
ReplacementOp = AcpiPsAllocOp (
AML_INT_RETURN_VALUE_OP, Op->Common.Aml);
@@ -232,7 +232,7 @@ AcpiPsCompleteThisOp (
{
if ((Op->Common.AmlOpcode == AML_BUFFER_OP) ||
(Op->Common.AmlOpcode == AML_PACKAGE_OP) ||
- (Op->Common.AmlOpcode == AML_VAR_PACKAGE_OP))
+ (Op->Common.AmlOpcode == AML_VARIABLE_PACKAGE_OP))
{
ReplacementOp = AcpiPsAllocOp (Op->Common.AmlOpcode,
Op->Common.Aml);
diff --git a/source/components/parser/pstree.c b/source/components/parser/pstree.c
index 0e150bc563c4..94658cc4cdcd 100644
--- a/source/components/parser/pstree.c
+++ b/source/components/parser/pstree.c
@@ -45,6 +45,7 @@
#include "accommon.h"
#include "acparser.h"
#include "amlcode.h"
+#include "acconvert.h"
#define _COMPONENT ACPI_PARSER
ACPI_MODULE_NAME ("pstree")
@@ -242,6 +243,7 @@ AcpiPsGetDepthNext (
Next = AcpiPsGetArg (Op, 0);
if (Next)
{
+ ASL_CV_LABEL_FILENODE (Next);
return (Next);
}
@@ -250,6 +252,7 @@ AcpiPsGetDepthNext (
Next = Op->Common.Next;
if (Next)
{
+ ASL_CV_LABEL_FILENODE (Next);
return (Next);
}
@@ -262,6 +265,8 @@ AcpiPsGetDepthNext (
Arg = AcpiPsGetArg (Parent, 0);
while (Arg && (Arg != Origin) && (Arg != Op))
{
+
+ ASL_CV_LABEL_FILENODE (Arg);
Arg = Arg->Common.Next;
}
@@ -276,6 +281,7 @@ AcpiPsGetDepthNext (
{
/* Found sibling of parent */
+ ASL_CV_LABEL_FILENODE (Parent->Common.Next);
return (Parent->Common.Next);
}
@@ -283,6 +289,7 @@ AcpiPsGetDepthNext (
Parent = Parent->Common.Parent;
}
+ ASL_CV_LABEL_FILENODE (Next);
return (Next);
}
@@ -331,7 +338,7 @@ AcpiPsGetChild (
Child = AcpiPsGetArg (Op, 1);
break;
- case AML_POWER_RES_OP:
+ case AML_POWER_RESOURCE_OP:
case AML_INDEX_FIELD_OP:
Child = AcpiPsGetArg (Op, 2);
diff --git a/source/components/parser/psutils.c b/source/components/parser/psutils.c
index 766fd1b8a51a..05699489adc8 100644
--- a/source/components/parser/psutils.c
+++ b/source/components/parser/psutils.c
@@ -45,6 +45,7 @@
#include "accommon.h"
#include "acparser.h"
#include "amlcode.h"
+#include "acconvert.h"
#define _COMPONENT ACPI_PARSER
ACPI_MODULE_NAME ("psutils")
@@ -177,6 +178,17 @@ AcpiPsAllocOp (
AcpiPsInitOp (Op, Opcode);
Op->Common.Aml = Aml;
Op->Common.Flags = Flags;
+ ASL_CV_CLEAR_OP_COMMENTS(Op);
+
+ if (Opcode == AML_SCOPE_OP)
+ {
+ AcpiGbl_CurrentScope = Op;
+ }
+ }
+
+ if (Gbl_CaptureComments)
+ {
+ ASL_CV_TRANSFER_COMMENTS (Op);
}
return (Op);
@@ -203,6 +215,7 @@ AcpiPsFreeOp (
ACPI_FUNCTION_NAME (PsFreeOp);
+ ASL_CV_CLEAR_OP_COMMENTS(Op);
if (Op->Common.AmlOpcode == AML_INT_RETURN_VALUE_OP)
{
ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS,
diff --git a/source/components/utilities/utalloc.c b/source/components/utilities/utalloc.c
index 3cd82ae898db..e9507ffaff96 100644
--- a/source/components/utilities/utalloc.c
+++ b/source/components/utilities/utalloc.c
@@ -144,6 +144,40 @@ AcpiUtCreateCaches (
return (Status);
}
+#ifdef ACPI_ASL_COMPILER
+ /*
+ * For use with the ASL-/ASL+ option. This cache keeps track of regular
+ * 0xA9 0x01 comments.
+ */
+ Status = AcpiOsCreateCache ("Acpi-Comment", sizeof (ACPI_COMMENT_NODE),
+ ACPI_MAX_COMMENT_CACHE_DEPTH, &AcpiGbl_RegCommentCache);
+ if (ACPI_FAILURE (Status))
+ {
+ return (Status);
+ }
+
+ /*
+ * This cache keeps track of the starting addresses of where the comments
+ * lie. This helps prevent duplication of comments.
+ */
+ Status = AcpiOsCreateCache ("Acpi-Comment-Addr", sizeof (ACPI_COMMENT_ADDR_NODE),
+ ACPI_MAX_COMMENT_CACHE_DEPTH, &AcpiGbl_CommentAddrCache);
+ if (ACPI_FAILURE (Status))
+ {
+ return (Status);
+ }
+
+ /*
+ * This cache will be used for nodes that represent files.
+ */
+ Status = AcpiOsCreateCache ("Acpi-File", sizeof (ACPI_FILE_NODE),
+ ACPI_MAX_COMMENT_CACHE_DEPTH, &AcpiGbl_FileCache);
+ if (ACPI_FAILURE (Status))
+ {
+ return (Status);
+ }
+#endif
+
#ifdef ACPI_DBG_TRACK_ALLOCATIONS
@@ -210,6 +244,16 @@ AcpiUtDeleteCaches (
(void) AcpiOsDeleteCache (AcpiGbl_PsNodeExtCache);
AcpiGbl_PsNodeExtCache = NULL;
+#ifdef ACPI_ASL_COMPILER
+ (void) AcpiOsDeleteCache (AcpiGbl_RegCommentCache);
+ AcpiGbl_RegCommentCache = NULL;
+
+ (void) AcpiOsDeleteCache (AcpiGbl_CommentAddrCache);
+ AcpiGbl_CommentAddrCache = NULL;
+
+ (void) AcpiOsDeleteCache (AcpiGbl_FileCache);
+ AcpiGbl_FileCache = NULL;
+#endif
#ifdef ACPI_DBG_TRACK_ALLOCATIONS
diff --git a/source/components/utilities/utcache.c b/source/components/utilities/utcache.c
index 36bdb31667f6..888d5c9c9fe7 100644
--- a/source/components/utilities/utcache.c
+++ b/source/components/utilities/utcache.c
@@ -77,7 +77,7 @@ AcpiOsCreateCache (
ACPI_FUNCTION_ENTRY ();
- if (!CacheName || !ReturnCache || (ObjectSize < 16))
+ if (!CacheName || !ReturnCache || !ObjectSize)
{
return (AE_BAD_PARAMETER);
}
diff --git a/source/components/utilities/utdebug.c b/source/components/utilities/utdebug.c
index 5bb0924efcea..cbe4487dc174 100644
--- a/source/components/utilities/utdebug.c
+++ b/source/components/utilities/utdebug.c
@@ -707,4 +707,5 @@ AcpiTracePoint (
ACPI_EXPORT_SYMBOL (AcpiTracePoint)
+
#endif
diff --git a/source/components/utilities/utresrc.c b/source/components/utilities/utresrc.c
index ed78a8489292..f3cd77cea578 100644
--- a/source/components/utilities/utresrc.c
+++ b/source/components/utilities/utresrc.c
@@ -526,6 +526,16 @@ AcpiUtWalkAmlResources (
return_ACPI_STATUS (AE_AML_NO_RESOURCE_END_TAG);
}
+ /*
+ * The EndTag opcode must be followed by a zero byte.
+ * Although this byte is technically defined to be a checksum,
+ * in practice, all ASL compilers set this byte to zero.
+ */
+ if (*(Aml + 1) != 0)
+ {
+ return_ACPI_STATUS (AE_AML_NO_RESOURCE_END_TAG);
+ }
+
/* Return the pointer to the EndTag if requested */
if (!UserFunction)
diff --git a/source/components/utilities/utxferror.c b/source/components/utilities/utxferror.c
index 0c65302cd965..e88108682e43 100644
--- a/source/components/utilities/utxferror.c
+++ b/source/components/utilities/utxferror.c
@@ -101,7 +101,7 @@ ACPI_EXPORT_SYMBOL (AcpiError)
*
* PARAMETERS: ModuleName - Caller's module name (for error output)
* LineNumber - Caller's line number (for error output)
- * Status - Status to be formatted
+ * Status - Status value to be decoded/formatted
* Format - Printf format string + additional args
*
* RETURN: None
@@ -152,8 +152,8 @@ ACPI_EXPORT_SYMBOL (AcpiException)
*
* FUNCTION: AcpiWarning
*
- * PARAMETERS: ModuleName - Caller's module name (for error output)
- * LineNumber - Caller's line number (for error output)
+ * PARAMETERS: ModuleName - Caller's module name (for warning output)
+ * LineNumber - Caller's line number (for warning output)
* Format - Printf format string + additional args
*
* RETURN: None
@@ -190,17 +190,13 @@ ACPI_EXPORT_SYMBOL (AcpiWarning)
*
* FUNCTION: AcpiInfo
*
- * PARAMETERS: ModuleName - Caller's module name (for error output)
- * LineNumber - Caller's line number (for error output)
- * Format - Printf format string + additional args
+ * PARAMETERS: Format - Printf format string + additional args
*
* RETURN: None
*
* DESCRIPTION: Print generic "ACPI:" information message. There is no
* module/line/version info in order to keep the message simple.
*
- * TBD: ModuleName and LineNumber args are not needed, should be removed.
- *
******************************************************************************/
void ACPI_INTERNAL_VAR_XFACE
@@ -268,8 +264,8 @@ ACPI_EXPORT_SYMBOL (AcpiBiosError)
*
* FUNCTION: AcpiBiosWarning
*
- * PARAMETERS: ModuleName - Caller's module name (for error output)
- * LineNumber - Caller's line number (for error output)
+ * PARAMETERS: ModuleName - Caller's module name (for warning output)
+ * LineNumber - Caller's line number (for warning output)
* Format - Printf format string + additional args
*
* RETURN: None
diff --git a/source/include/acconfig.h b/source/include/acconfig.h
index 5e1912ea5fb9..a0e22703a329 100644
--- a/source/include/acconfig.h
+++ b/source/include/acconfig.h
@@ -79,6 +79,7 @@
#define ACPI_MAX_EXTPARSE_CACHE_DEPTH 96 /* Parse tree objects */
#define ACPI_MAX_OBJECT_CACHE_DEPTH 96 /* Interpreter operand objects */
#define ACPI_MAX_NAMESPACE_CACHE_DEPTH 96 /* Namespace objects */
+#define ACPI_MAX_COMMENT_CACHE_DEPTH 96 /* Comments for the -ca option */
/*
* Should the subsystem abort the loading of an ACPI table if the
diff --git a/source/include/acconvert.h b/source/include/acconvert.h
new file mode 100644
index 000000000000..90a141a97b11
--- /dev/null
+++ b/source/include/acconvert.h
@@ -0,0 +1,204 @@
+/******************************************************************************
+ *
+ * Module Name: acapps - common include for ACPI applications/tools
+ *
+ *****************************************************************************/
+
+/*
+ * Copyright (C) 2000 - 2017, Intel Corp.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions, and the following disclaimer,
+ * without modification.
+ * 2. Redistributions in binary form must reproduce at minimum a disclaimer
+ * substantially similar to the "NO WARRANTY" disclaimer below
+ * ("Disclaimer") and any redistribution must be conditioned upon
+ * including a substantially similar Disclaimer requirement for further
+ * binary redistribution.
+ * 3. Neither the names of the above-listed copyright holders nor the names
+ * of any contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * Alternatively, this software may be distributed under the terms of the
+ * GNU General Public License ("GPL") version 2 as published by the Free
+ * Software Foundation.
+ *
+ * NO WARRANTY
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
+ * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGES.
+ */
+
+#ifndef _ACCONVERT
+#define _ACCONVERT
+
+/* Definitions for comment state */
+
+#define ASL_COMMENT_STANDARD 1
+#define ASLCOMMENT_INLINE 2
+#define ASL_COMMENT_OPEN_PAREN 3
+#define ASL_COMMENT_CLOSE_PAREN 4
+#define ASL_COMMENT_CLOSE_BRACE 5
+
+/* Definitions for comment print function*/
+
+#define AML_COMMENT_STANDARD 1
+#define AMLCOMMENT_INLINE 2
+#define AML_COMMENT_END_NODE 3
+#define AML_NAMECOMMENT 4
+#define AML_COMMENT_CLOSE_BRACE 5
+#define AML_COMMENT_ENDBLK 6
+#define AML_COMMENT_INCLUDE 7
+
+
+#ifdef ACPI_ASL_COMPILER
+/*
+ * cvcompiler
+ */
+void
+CvProcessComment (
+ ASL_COMMENT_STATE CurrentState,
+ char *StringBuffer,
+ int c1);
+
+void
+CvProcessCommentType2 (
+ ASL_COMMENT_STATE CurrentState,
+ char *StringBuffer);
+
+UINT32
+CvCalculateCommentLengths(
+ ACPI_PARSE_OBJECT *Op);
+
+void
+CvProcessCommentState (
+ char input);
+
+char*
+CvAppendInlineComment (
+ char *InlineComment,
+ char *ToAdd);
+
+void
+CvAddToCommentList (
+ char* ToAdd);
+
+void
+CvPlaceComment (
+ UINT8 Type,
+ char *CommentString);
+
+UINT32
+CvParseOpBlockType (
+ ACPI_PARSE_OBJECT *Op);
+
+ACPI_COMMENT_NODE*
+CvCommentNodeCalloc (
+ void);
+
+void
+CgWriteAmlDefBlockComment (
+ ACPI_PARSE_OBJECT *Op);
+
+void
+CgWriteOneAmlComment (
+ ACPI_PARSE_OBJECT *Op,
+ char* CommentToPrint,
+ UINT8 InputOption);
+
+void
+CgWriteAmlComment (
+ ACPI_PARSE_OBJECT *Op);
+
+
+/*
+ * cvparser
+ */
+void
+CvInitFileTree (
+ ACPI_TABLE_HEADER *Table,
+ UINT8 *AmlStart,
+ UINT32 AmlLength);
+
+void
+CvClearOpComments (
+ ACPI_PARSE_OBJECT *Op);
+
+ACPI_FILE_NODE*
+CvFilenameExists (
+ char *Filename,
+ ACPI_FILE_NODE *Head);
+
+void
+CvLabelFileNode (
+ ACPI_PARSE_OBJECT *Op);
+
+void
+CvCaptureListComments (
+ ACPI_PARSE_STATE *ParserState,
+ ACPI_COMMENT_NODE *ListHead,
+ ACPI_COMMENT_NODE *ListTail);
+
+void
+CvCaptureCommentsOnly (
+ ACPI_PARSE_STATE *ParserState);
+
+void
+CvCaptureComments (
+ ACPI_WALK_STATE *WalkState);
+
+void
+CvTransferComments (
+ ACPI_PARSE_OBJECT *Op);
+
+/*
+ * cvdisasm
+ */
+void
+CvSwitchFiles (
+ UINT32 level,
+ ACPI_PARSE_OBJECT *op);
+
+BOOLEAN
+CvFileHasSwitched (
+ ACPI_PARSE_OBJECT *Op);
+
+
+void
+CvCloseParenWriteComment (
+ ACPI_PARSE_OBJECT *Op,
+ UINT32 Level);
+
+void
+CvCloseBraceWriteComment (
+ ACPI_PARSE_OBJECT *Op,
+ UINT32 Level);
+
+void
+CvPrintOneCommentList (
+ ACPI_COMMENT_NODE *CommentList,
+ UINT32 Level);
+
+void
+CvPrintOneCommentType (
+ ACPI_PARSE_OBJECT *Op,
+ UINT8 CommentType,
+ char* EndStr,
+ UINT32 Level);
+
+
+#endif
+
+#endif /* _ACCONVERT */
diff --git a/source/include/acdisasm.h b/source/include/acdisasm.h
index 3c5851fcb9c2..b9b03d31ef6a 100644
--- a/source/include/acdisasm.h
+++ b/source/include/acdisasm.h
@@ -803,6 +803,11 @@ AcpiDmEmitExternals (
void);
void
+AcpiDmEmitExternal (
+ ACPI_PARSE_OBJECT *NameOp,
+ ACPI_PARSE_OBJECT *TypeOp);
+
+void
AcpiDmUnresolvedWarning (
UINT8 Type);
@@ -1097,4 +1102,13 @@ ACPI_STATUS
AdDisplayStatistics (
void);
+
+/*
+ * dmwalk
+ */
+UINT32
+AcpiDmBlockType (
+ ACPI_PARSE_OBJECT *Op);
+
+
#endif /* __ACDISASM_H__ */
diff --git a/source/include/acglobal.h b/source/include/acglobal.h
index d83825f0fabb..3dfbe423e5b7 100644
--- a/source/include/acglobal.h
+++ b/source/include/acglobal.h
@@ -374,6 +374,50 @@ ACPI_GLOBAL (const char, *AcpiGbl_PldShapeList[]);
#endif
+/*
+ * Meant for the -ca option.
+ */
+ACPI_INIT_GLOBAL (char*, AcpiGbl_CurrentInlineComment, NULL);
+ACPI_INIT_GLOBAL (char*, AcpiGbl_CurrentEndNodeComment, NULL);
+ACPI_INIT_GLOBAL (char*, AcpiGbl_CurrentOpenBraceComment, NULL);
+ACPI_INIT_GLOBAL (char*, AcpiGbl_CurrentCloseBraceComment, NULL);
+
+ACPI_INIT_GLOBAL (char*, AcpiGbl_RootFilename, NULL);
+ACPI_INIT_GLOBAL (char*, AcpiGbl_CurrentFilename, NULL);
+ACPI_INIT_GLOBAL (char*, AcpiGbl_CurrentParentFilename, NULL);
+ACPI_INIT_GLOBAL (char*, AcpiGbl_CurrentIncludeFilename, NULL);
+
+ACPI_INIT_GLOBAL (ACPI_COMMENT_NODE, *AcpiGbl_LastListHead, NULL);
+
+ACPI_INIT_GLOBAL (ACPI_COMMENT_NODE, *AcpiGbl_DefBlkCommentListHead, NULL);
+ACPI_INIT_GLOBAL (ACPI_COMMENT_NODE, *AcpiGbl_DefBlkCommentListTail, NULL);
+
+ACPI_INIT_GLOBAL (ACPI_COMMENT_NODE, *AcpiGbl_RegCommentListHead, NULL);
+ACPI_INIT_GLOBAL (ACPI_COMMENT_NODE, *AcpiGbl_RegCommentListTail, NULL);
+
+ACPI_INIT_GLOBAL (ACPI_COMMENT_NODE, *AcpiGbl_IncCommentListHead, NULL);
+ACPI_INIT_GLOBAL (ACPI_COMMENT_NODE, *AcpiGbl_IncCommentListTail, NULL);
+
+ACPI_INIT_GLOBAL (ACPI_COMMENT_NODE, *AcpiGbl_EndBlkCommentListHead, NULL);
+ACPI_INIT_GLOBAL (ACPI_COMMENT_NODE, *AcpiGbl_EndBlkCommentListTail, NULL);
+
+ACPI_INIT_GLOBAL (ACPI_COMMENT_ADDR_NODE, *AcpiGbl_CommentAddrListHead, NULL);
+
+ACPI_INIT_GLOBAL (ACPI_PARSE_OBJECT, *AcpiGbl_CurrentScope, NULL);
+
+ACPI_INIT_GLOBAL (ACPI_FILE_NODE, *AcpiGbl_FileTreeRoot, NULL);
+
+ACPI_GLOBAL (ACPI_CACHE_T *, AcpiGbl_RegCommentCache);
+ACPI_GLOBAL (ACPI_CACHE_T *, AcpiGbl_CommentAddrCache);
+ACPI_GLOBAL (ACPI_CACHE_T *, AcpiGbl_FileCache);
+
+ACPI_INIT_GLOBAL (BOOLEAN, Gbl_CaptureComments, FALSE);
+
+ACPI_INIT_GLOBAL (BOOLEAN, AcpiGbl_DebugAslConversion, FALSE);
+ACPI_INIT_GLOBAL (ACPI_FILE, AcpiGbl_ConvDebugFile, NULL);
+
+ACPI_GLOBAL (char, AcpiGbl_TableSig[4]);
+
/*****************************************************************************
*
* Application globals
diff --git a/source/include/aclocal.h b/source/include/aclocal.h
index 3b5f779edc2f..77cf580a39be 100644
--- a/source/include/aclocal.h
+++ b/source/include/aclocal.h
@@ -54,7 +54,7 @@ typedef UINT32 ACPI_MUTEX_HANDLE;
/* Total number of aml opcodes defined */
-#define AML_NUM_OPCODES 0x82
+#define AML_NUM_OPCODES 0x83
/* Forward declarations */
@@ -906,21 +906,55 @@ typedef union acpi_parse_value
#define ACPI_DISASM_ONLY_MEMBERS(a)
#endif
+#if defined(ACPI_ASL_COMPILER)
+#define ACPI_CONVERTER_ONLY_MEMBERS(a) a;
+#else
+#define ACPI_CONVERTER_ONLY_MEMBERS(a)
+#endif
+
#define ACPI_PARSE_COMMON \
- union acpi_parse_object *Parent; /* Parent op */\
- UINT8 DescriptorType; /* To differentiate various internal objs */\
- UINT8 Flags; /* Type of Op */\
- UINT16 AmlOpcode; /* AML opcode */\
- UINT8 *Aml; /* Address of declaration in AML */\
- union acpi_parse_object *Next; /* Next op */\
- ACPI_NAMESPACE_NODE *Node; /* For use by interpreter */\
- ACPI_PARSE_VALUE Value; /* Value or args associated with the opcode */\
- UINT8 ArgListLength; /* Number of elements in the arg list */\
- ACPI_DISASM_ONLY_MEMBERS (\
- UINT16 DisasmFlags; /* Used during AML disassembly */\
- UINT8 DisasmOpcode; /* Subtype used for disassembly */\
- char *OperatorSymbol;/* Used for C-style operator name strings */\
- char AmlOpName[16]) /* Op name (debug only) */
+ union acpi_parse_object *Parent; /* Parent op */\
+ UINT8 DescriptorType; /* To differentiate various internal objs */\
+ UINT8 Flags; /* Type of Op */\
+ UINT16 AmlOpcode; /* AML opcode */\
+ UINT8 *Aml; /* Address of declaration in AML */\
+ union acpi_parse_object *Next; /* Next op */\
+ ACPI_NAMESPACE_NODE *Node; /* For use by interpreter */\
+ ACPI_PARSE_VALUE Value; /* Value or args associated with the opcode */\
+ UINT8 ArgListLength; /* Number of elements in the arg list */\
+ ACPI_DISASM_ONLY_MEMBERS (\
+ UINT16 DisasmFlags; /* Used during AML disassembly */\
+ UINT8 DisasmOpcode; /* Subtype used for disassembly */\
+ char *OperatorSymbol; /* Used for C-style operator name strings */\
+ char AmlOpName[16]) /* Op name (debug only) */\
+ ACPI_CONVERTER_ONLY_MEMBERS (\
+ char *InlineComment; /* Inline comment */\
+ char *EndNodeComment; /* End of node comment */\
+ char *NameComment; /* Comment associated with the first parameter of the name node */\
+ char *CloseBraceComment; /* Comments that come after } on the same as } */\
+ ACPI_COMMENT_NODE *CommentList; /* comments that appears before this node */\
+ ACPI_COMMENT_NODE *EndBlkComment; /* comments that at the end of a block but before ) or } */\
+ char *CvFilename; /* Filename associated with this node. Used for ASL/ASL+ converter */\
+ char *CvParentFilename) /* Parent filename associated with this node. Used for ASL/ASL+ converter */
+
+
+/* categories of comments */
+
+typedef enum
+{
+ STANDARD_COMMENT = 1,
+ INLINE_COMMENT,
+ ENDNODE_COMMENT,
+ OPENBRACE_COMMENT,
+ CLOSE_BRACE_COMMENT,
+ STD_DEFBLK_COMMENT,
+ END_DEFBLK_COMMENT,
+ FILENAME_COMMENT,
+ PARENTFILENAME_COMMENT,
+ ENDBLK_COMMENT,
+ INCLUDE_COMMENT
+
+} ASL_COMMENT_TYPES;
/* Internal opcodes for DisasmOpcode field above */
@@ -937,9 +971,46 @@ typedef union acpi_parse_value
#define ACPI_DASM_LNOT_SUFFIX 0x09 /* End of a LNotEqual (etc.) pair of opcodes */
#define ACPI_DASM_HID_STRING 0x0A /* String is a _HID or _CID */
#define ACPI_DASM_IGNORE_SINGLE 0x0B /* Ignore the opcode but not it's children */
-#define ACPI_DASM_SWITCH_PREDICATE 0x0C /* Object is a predicate for a Switch or Case block */
-#define ACPI_DASM_CASE 0x0D /* If/Else is a Case in a Switch/Case block */
-#define ACPI_DASM_DEFAULT 0x0E /* Else is a Default in a Switch/Case block */
+#define ACPI_DASM_SWITCH 0x0C /* While is a Switch */
+#define ACPI_DASM_SWITCH_PREDICATE 0x0D /* Object is a predicate for a Switch or Case block */
+#define ACPI_DASM_CASE 0x0E /* If/Else is a Case in a Switch/Case block */
+#define ACPI_DASM_DEFAULT 0x0F /* Else is a Default in a Switch/Case block */
+
+
+/*
+ * List struct used in the -ca option
+ */
+typedef struct acpi_comment_node
+{
+ char *Comment;
+ struct acpi_comment_node *Next;
+
+} ACPI_COMMENT_NODE;
+
+
+typedef struct acpi_comment_addr_node
+{
+ UINT8 *Addr;
+ struct acpi_comment_addr_node *Next;
+} ACPI_COMMENT_ADDR_NODE;
+
+/*
+ * File node - used for "Include" operator file stack and
+ * depdendency tree for the -ca option
+ */
+typedef struct acpi_file_node
+{
+ FILE *File;
+ char *Filename;
+ char *FileStart; /* Points to AML and indicates when the AML for this particular file starts. */
+ char *FileEnd; /* Points to AML and indicates when the AML for this particular file ends. */
+ struct acpi_file_node *Next;
+ struct acpi_file_node *Parent;
+ BOOLEAN IncludeWritten;
+ ACPI_COMMENT_NODE *IncludeComment;
+
+} ACPI_FILE_NODE;
+
/*
* Generic operation (for example: If, While, Store)
@@ -975,6 +1046,8 @@ typedef struct acpi_parse_obj_asl
union acpi_parse_object *Child;
union acpi_parse_object *ParentMethod;
char *Filename;
+ BOOLEAN FileChanged;
+ char *ParentFilename;
char *ExternalName;
char *Namepath;
char NameSeg[4];
@@ -1007,6 +1080,15 @@ typedef union acpi_parse_object
} ACPI_PARSE_OBJECT;
+typedef struct asl_comment_state
+{
+ UINT8 CommentType;
+ UINT32 SpacesBefore;
+ ACPI_PARSE_OBJECT *Latest_Parse_Node;
+ ACPI_PARSE_OBJECT *ParsingParenBraceNode;
+ BOOLEAN CaptureComments;
+} ASL_COMMENT_STATE;
+
/*
* Parse state - one state per parser invocation and each control
diff --git a/source/include/acmacros.h b/source/include/acmacros.h
index 0e6dee66ff71..f9d9dacf0234 100644
--- a/source/include/acmacros.h
+++ b/source/include/acmacros.h
@@ -499,4 +499,39 @@
#define ACPI_IS_OCTAL_DIGIT(d) (((char)(d) >= '0') && ((char)(d) <= '7'))
+/*
+ * Macors used for the ASL-/ASL+ converter utility
+ */
+#ifdef ACPI_ASL_COMPILER
+
+#define ASL_CV_LABEL_FILENODE(a) CvLabelFileNode(a);
+#define ASL_CV_CAPTURE_COMMENTS_ONLY(a) CvCaptureCommentsOnly (a);
+#define ASL_CV_CAPTURE_COMMENTS(a) CvCaptureComments (a);
+#define ASL_CV_TRANSFER_COMMENTS(a) CvTransferComments (a);
+#define ASL_CV_CLOSE_PAREN(a,b) CvCloseParenWriteComment(a,b);
+#define ASL_CV_CLOSE_BRACE(a,b) CvCloseBraceWriteComment(a,b);
+#define ASL_CV_SWITCH_FILES(a,b) CvSwitchFiles(a,b);
+#define ASL_CV_CLEAR_OP_COMMENTS(a) CvClearOpComments(a);
+#define ASL_CV_PRINT_ONE_COMMENT(a,b,c,d) CvPrintOneCommentType (a,b,c,d);
+#define ASL_CV_PRINT_ONE_COMMENT_LIST(a,b) CvPrintOneCommentList (a,b);
+#define ASL_CV_FILE_HAS_SWITCHED(a) CvFileHasSwitched(a)
+#define ASL_CV_INIT_FILETREE(a,b,c) CvInitFileTree(a,b,c);
+
+#else
+
+#define ASL_CV_LABEL_FILENODE(a)
+#define ASL_CV_CAPTURE_COMMENTS_ONLY(a)
+#define ASL_CV_CAPTURE_COMMENTS(a)
+#define ASL_CV_TRANSFER_COMMENTS(a)
+#define ASL_CV_CLOSE_PAREN(a,b) AcpiOsPrintf (")");
+#define ASL_CV_CLOSE_BRACE(a,b) AcpiOsPrintf ("}");
+#define ASL_CV_SWITCH_FILES(a,b)
+#define ASL_CV_CLEAR_OP_COMMENTS(a)
+#define ASL_CV_PRINT_ONE_COMMENT(a,b,c,d)
+#define ASL_CV_PRINT_ONE_COMMENT_LIST(a,b)
+#define ASL_CV_FILE_HAS_SWITCHED(a) 0
+#define ASL_CV_INIT_FILETREE(a,b,c)
+
+#endif
+
#endif /* ACMACROS_H */
diff --git a/source/include/acopcode.h b/source/include/acopcode.h
index ce4e420bfa6a..336d146235d1 100644
--- a/source/include/acopcode.h
+++ b/source/include/acopcode.h
@@ -91,6 +91,7 @@
#define ARGP_BUFFER_OP ARGP_LIST3 (ARGP_PKGLENGTH, ARGP_TERMARG, ARGP_BYTELIST)
#define ARGP_BYTE_OP ARGP_LIST1 (ARGP_BYTEDATA)
#define ARGP_BYTELIST_OP ARGP_LIST1 (ARGP_NAMESTRING)
+#define ARGP_COMMENT_OP ARGP_LIST2 (ARGP_BYTEDATA, ARGP_COMMENT)
#define ARGP_CONCAT_OP ARGP_LIST3 (ARGP_TERMARG, ARGP_TERMARG, ARGP_TARGET)
#define ARGP_CONCAT_RES_OP ARGP_LIST3 (ARGP_TERMARG, ARGP_TERMARG, ARGP_TARGET)
#define ARGP_COND_REF_OF_OP ARGP_LIST2 (ARGP_SIMPLENAME, ARGP_TARGET)
@@ -225,6 +226,7 @@
#define ARGI_BUFFER_OP ARGI_LIST1 (ARGI_INTEGER)
#define ARGI_BYTE_OP ARGI_INVALID_OPCODE
#define ARGI_BYTELIST_OP ARGI_INVALID_OPCODE
+#define ARGI_COMMENT_OP ARGI_INVALID_OPCODE
#define ARGI_CONCAT_OP ARGI_LIST3 (ARGI_ANYTYPE, ARGI_ANYTYPE, ARGI_TARGETREF)
#define ARGI_CONCAT_RES_OP ARGI_LIST3 (ARGI_BUFFER, ARGI_BUFFER, ARGI_TARGETREF)
#define ARGI_COND_REF_OF_OP ARGI_LIST2 (ARGI_OBJECT_REF, ARGI_TARGETREF)
diff --git a/source/include/acpixf.h b/source/include/acpixf.h
index 8b1ea4f0241c..bf71b1f01dcd 100644
--- a/source/include/acpixf.h
+++ b/source/include/acpixf.h
@@ -46,7 +46,7 @@
/* Current ACPICA subsystem version in YYYYMMDD format */
-#define ACPI_CA_VERSION 0x20170119
+#define ACPI_CA_VERSION 0x20170224
#include "acconfig.h"
#include "actypes.h"
diff --git a/source/include/actbl2.h b/source/include/actbl2.h
index 86d3a43f96ba..51aafc082692 100644
--- a/source/include/actbl2.h
+++ b/source/include/actbl2.h
@@ -89,6 +89,7 @@
#define ACPI_SIG_WDAT "WDAT" /* Watchdog Action Table */
#define ACPI_SIG_WDDT "WDDT" /* Watchdog Timer Description Table */
#define ACPI_SIG_WDRT "WDRT" /* Watchdog Resource Table */
+#define ACPI_SIG_XXXX "XXXX" /* Intermediate AML header for ASL/ASL+ converter */
#ifdef ACPI_UNDEFINED_TABLES
/*
@@ -909,6 +910,16 @@ typedef struct acpi_iort_smmu
#define ACPI_IORT_SMMU_DVM_SUPPORTED (1)
#define ACPI_IORT_SMMU_COHERENT_WALK (1<<1)
+/* Global interrupt format */
+
+typedef struct acpi_iort_smmu_gsi
+{
+ UINT32 NSgIrpt;
+ UINT32 NSgIrptFlags;
+ UINT32 NSgCfgIrpt;
+ UINT32 NSgCfgIrptFlags;
+} ACPI_IORT_SMMU_GSI;
+
typedef struct acpi_iort_smmu_v3
{
diff --git a/source/include/amlcode.h b/source/include/amlcode.h
index 401dfc3fb4de..ed70466b55c7 100644
--- a/source/include/amlcode.h
+++ b/source/include/amlcode.h
@@ -48,11 +48,8 @@
/* primary opcodes */
-#define AML_NULL_CHAR (UINT16) 0x00
-
#define AML_ZERO_OP (UINT16) 0x00
#define AML_ONE_OP (UINT16) 0x01
-#define AML_UNASSIGNED (UINT16) 0x02
#define AML_ALIAS_OP (UINT16) 0x06
#define AML_NAME_OP (UINT16) 0x08
#define AML_BYTE_OP (UINT16) 0x0a
@@ -63,17 +60,15 @@
#define AML_SCOPE_OP (UINT16) 0x10
#define AML_BUFFER_OP (UINT16) 0x11
#define AML_PACKAGE_OP (UINT16) 0x12
-#define AML_VAR_PACKAGE_OP (UINT16) 0x13 /* ACPI 2.0 */
+#define AML_VARIABLE_PACKAGE_OP (UINT16) 0x13 /* ACPI 2.0 */
#define AML_METHOD_OP (UINT16) 0x14
#define AML_EXTERNAL_OP (UINT16) 0x15 /* ACPI 6.0 */
#define AML_DUAL_NAME_PREFIX (UINT16) 0x2e
-#define AML_MULTI_NAME_PREFIX_OP (UINT16) 0x2f
-#define AML_NAME_CHAR_SUBSEQ (UINT16) 0x30
-#define AML_NAME_CHAR_FIRST (UINT16) 0x41
-#define AML_EXTENDED_OP_PREFIX (UINT16) 0x5b
+#define AML_MULTI_NAME_PREFIX (UINT16) 0x2f
+#define AML_EXTENDED_PREFIX (UINT16) 0x5b
#define AML_ROOT_PREFIX (UINT16) 0x5c
#define AML_PARENT_PREFIX (UINT16) 0x5e
-#define AML_LOCAL_OP (UINT16) 0x60
+#define AML_FIRST_LOCAL_OP (UINT16) 0x60 /* Used for Local op # calculations */
#define AML_LOCAL0 (UINT16) 0x60
#define AML_LOCAL1 (UINT16) 0x61
#define AML_LOCAL2 (UINT16) 0x62
@@ -82,7 +77,7 @@
#define AML_LOCAL5 (UINT16) 0x65
#define AML_LOCAL6 (UINT16) 0x66
#define AML_LOCAL7 (UINT16) 0x67
-#define AML_ARG_OP (UINT16) 0x68
+#define AML_FIRST_ARG_OP (UINT16) 0x68 /* Used for Arg op # calculations */
#define AML_ARG0 (UINT16) 0x68
#define AML_ARG1 (UINT16) 0x69
#define AML_ARG2 (UINT16) 0x6a
@@ -93,7 +88,7 @@
#define AML_STORE_OP (UINT16) 0x70
#define AML_REF_OF_OP (UINT16) 0x71
#define AML_ADD_OP (UINT16) 0x72
-#define AML_CONCAT_OP (UINT16) 0x73
+#define AML_CONCATENATE_OP (UINT16) 0x73
#define AML_SUBTRACT_OP (UINT16) 0x74
#define AML_INCREMENT_OP (UINT16) 0x75
#define AML_DECREMENT_OP (UINT16) 0x76
@@ -110,7 +105,7 @@
#define AML_FIND_SET_LEFT_BIT_OP (UINT16) 0x81
#define AML_FIND_SET_RIGHT_BIT_OP (UINT16) 0x82
#define AML_DEREF_OF_OP (UINT16) 0x83
-#define AML_CONCAT_RES_OP (UINT16) 0x84 /* ACPI 2.0 */
+#define AML_CONCATENATE_TEMPLATE_OP (UINT16) 0x84 /* ACPI 2.0 */
#define AML_MOD_OP (UINT16) 0x85 /* ACPI 2.0 */
#define AML_NOTIFY_OP (UINT16) 0x86
#define AML_SIZE_OF_OP (UINT16) 0x87
@@ -122,18 +117,18 @@
#define AML_CREATE_BIT_FIELD_OP (UINT16) 0x8d
#define AML_OBJECT_TYPE_OP (UINT16) 0x8e
#define AML_CREATE_QWORD_FIELD_OP (UINT16) 0x8f /* ACPI 2.0 */
-#define AML_LAND_OP (UINT16) 0x90
-#define AML_LOR_OP (UINT16) 0x91
-#define AML_LNOT_OP (UINT16) 0x92
-#define AML_LEQUAL_OP (UINT16) 0x93
-#define AML_LGREATER_OP (UINT16) 0x94
-#define AML_LLESS_OP (UINT16) 0x95
+#define AML_LOGICAL_AND_OP (UINT16) 0x90
+#define AML_LOGICAL_OR_OP (UINT16) 0x91
+#define AML_LOGICAL_NOT_OP (UINT16) 0x92
+#define AML_LOGICAL_EQUAL_OP (UINT16) 0x93
+#define AML_LOGICAL_GREATER_OP (UINT16) 0x94
+#define AML_LOGICAL_LESS_OP (UINT16) 0x95
#define AML_TO_BUFFER_OP (UINT16) 0x96 /* ACPI 2.0 */
-#define AML_TO_DECSTRING_OP (UINT16) 0x97 /* ACPI 2.0 */
-#define AML_TO_HEXSTRING_OP (UINT16) 0x98 /* ACPI 2.0 */
+#define AML_TO_DECIMAL_STRING_OP (UINT16) 0x97 /* ACPI 2.0 */
+#define AML_TO_HEX_STRING_OP (UINT16) 0x98 /* ACPI 2.0 */
#define AML_TO_INTEGER_OP (UINT16) 0x99 /* ACPI 2.0 */
#define AML_TO_STRING_OP (UINT16) 0x9c /* ACPI 2.0 */
-#define AML_COPY_OP (UINT16) 0x9d /* ACPI 2.0 */
+#define AML_COPY_OBJECT_OP (UINT16) 0x9d /* ACPI 2.0 */
#define AML_MID_OP (UINT16) 0x9e /* ACPI 2.0 */
#define AML_CONTINUE_OP (UINT16) 0x9f /* ACPI 2.0 */
#define AML_IF_OP (UINT16) 0xa0
@@ -142,18 +137,29 @@
#define AML_NOOP_OP (UINT16) 0xa3
#define AML_RETURN_OP (UINT16) 0xa4
#define AML_BREAK_OP (UINT16) 0xa5
-#define AML_BREAK_POINT_OP (UINT16) 0xcc
+#define AML_COMMENT_OP (UINT16) 0xa9
+#define AML_BREAKPOINT_OP (UINT16) 0xcc
#define AML_ONES_OP (UINT16) 0xff
-/* prefixed opcodes */
-#define AML_EXTENDED_OPCODE (UINT16) 0x5b00 /* prefix for 2-byte opcodes */
+/*
+ * Combination opcodes (actually two one-byte opcodes)
+ * Used by the disassembler and iASL compiler
+ */
+#define AML_LOGICAL_GREATER_EQUAL_OP (UINT16) 0x9295 /* LNot (LLess) */
+#define AML_LOGICAL_LESS_EQUAL_OP (UINT16) 0x9294 /* LNot (LGreater) */
+#define AML_LOGICAL_NOT_EQUAL_OP (UINT16) 0x9293 /* LNot (LEqual) */
+
+
+/* Prefixed (2-byte) opcodes (with AML_EXTENDED_PREFIX) */
+
+#define AML_EXTENDED_OPCODE (UINT16) 0x5b00 /* Prefix for 2-byte opcodes */
#define AML_MUTEX_OP (UINT16) 0x5b01
#define AML_EVENT_OP (UINT16) 0x5b02
-#define AML_SHIFT_RIGHT_BIT_OP (UINT16) 0x5b10
-#define AML_SHIFT_LEFT_BIT_OP (UINT16) 0x5b11
-#define AML_COND_REF_OF_OP (UINT16) 0x5b12
+#define AML_SHIFT_RIGHT_BIT_OP (UINT16) 0x5b10 /* Obsolete, not in ACPI spec */
+#define AML_SHIFT_LEFT_BIT_OP (UINT16) 0x5b11 /* Obsolete, not in ACPI spec */
+#define AML_CONDITIONAL_REF_OF_OP (UINT16) 0x5b12
#define AML_CREATE_FIELD_OP (UINT16) 0x5b13
#define AML_LOAD_TABLE_OP (UINT16) 0x5b1f /* ACPI 2.0 */
#define AML_LOAD_OP (UINT16) 0x5b20
@@ -175,7 +181,7 @@
#define AML_FIELD_OP (UINT16) 0x5b81
#define AML_DEVICE_OP (UINT16) 0x5b82
#define AML_PROCESSOR_OP (UINT16) 0x5b83
-#define AML_POWER_RES_OP (UINT16) 0x5b84
+#define AML_POWER_RESOURCE_OP (UINT16) 0x5b84
#define AML_THERMAL_ZONE_OP (UINT16) 0x5b85
#define AML_INDEX_FIELD_OP (UINT16) 0x5b86
#define AML_BANK_FIELD_OP (UINT16) 0x5b87
@@ -183,15 +189,6 @@
/*
- * Combination opcodes (actually two one-byte opcodes)
- * Used by the disassembler and iASL compiler
- */
-#define AML_LGREATEREQUAL_OP (UINT16) 0x9295
-#define AML_LLESSEQUAL_OP (UINT16) 0x9294
-#define AML_LNOTEQUAL_OP (UINT16) 0x9293
-
-
-/*
* Opcodes for "Field" operators
*/
#define AML_FIELD_OFFSET_OP (UINT8) 0x00
@@ -244,6 +241,7 @@
#define ARGP_SIMPLENAME 0x12 /* NameString | LocalTerm | ArgTerm */
#define ARGP_NAME_OR_REF 0x13 /* For ObjectType only */
#define ARGP_MAX 0x13
+#define ARGP_COMMENT 0x14
/*
* Resolved argument types for the AML Interpreter
@@ -313,26 +311,19 @@
/*
- * hash offsets
- */
-#define AML_EXTOP_HASH_OFFSET 22
-#define AML_LNOT_HASH_OFFSET 19
-
-
-/*
- * opcode groups and types
+ * Some of the flags and types below are of the form:
+ *
+ * AML_FLAGS_EXEC_#A_#T,#R, or
+ * AML_TYPE_EXEC_#A_#T,#R where:
+ *
+ * #A is the number of required arguments
+ * #T is the number of target operands
+ * #R indicates whether there is a return value
*/
-#define OPGRP_NAMED 0x01
-#define OPGRP_FIELD 0x02
-#define OPGRP_BYTELIST 0x04
-
/*
- * Opcode information
+ * Opcode information flags
*/
-
-/* Opcode flags */
-
#define AML_LOGICAL 0x0001
#define AML_LOGICAL_NUMERIC 0x0002
#define AML_MATH 0x0004
@@ -349,7 +340,7 @@
#define AML_CONSTANT 0x2000
#define AML_NO_OPERAND_RESOLVE 0x4000
-/* Convenient flag groupings */
+/* Convenient flag groupings of the flags above */
#define AML_FLAGS_EXEC_0A_0T_1R AML_HAS_RETVAL
#define AML_FLAGS_EXEC_1A_0T_0R AML_HAS_ARGS /* Monadic1 */
@@ -367,7 +358,7 @@
/*
* The opcode Type is used in a dispatch table, do not change
- * without updating the table.
+ * or add anything new without updating the table.
*/
#define AML_TYPE_EXEC_0A_0T_1R 0x00
#define AML_TYPE_EXEC_1A_0T_0R 0x01 /* Monadic1 */
@@ -393,7 +384,7 @@
#define AML_TYPE_METHOD_CALL 0x10
-/* Misc */
+/* Miscellaneous types */
#define AML_TYPE_CREATE_FIELD 0x11
#define AML_TYPE_CREATE_OBJECT 0x12
@@ -403,7 +394,6 @@
#define AML_TYPE_NAMED_SIMPLE 0x16
#define AML_TYPE_NAMED_COMPLEX 0x17
#define AML_TYPE_RETURN 0x18
-
#define AML_TYPE_UNDEFINED 0x19
#define AML_TYPE_BOGUS 0x1A
diff --git a/source/tools/acpisrc/astable.c b/source/tools/acpisrc/astable.c
index d41d314b4a86..ff45e509dbc2 100644
--- a/source/tools/acpisrc/astable.c
+++ b/source/tools/acpisrc/astable.c
@@ -623,6 +623,7 @@ ACPI_TYPED_IDENTIFIER_TABLE AcpiIdentifiers[] = {
{"ACPI_IORT_NODE", SRC_TYPE_STRUCT},
{"ACPI_IORT_ROOT_COMPLEX", SRC_TYPE_STRUCT},
{"ACPI_IORT_SMMU", SRC_TYPE_STRUCT},
+ {"ACPI_IORT_SMMU_GSI", SRC_TYPE_STRUCT},
{"ACPI_IORT_SMMU_V3", SRC_TYPE_STRUCT},
{"ACPI_IVRS_HEADER", SRC_TYPE_STRUCT},
{"ACPI_IVRS_HARDWARE", SRC_TYPE_STRUCT},
@@ -776,6 +777,7 @@ ACPI_STRING_TABLE LinuxSpecialStrings[] = {
{"\"platform/acenv.h\"", "<acpi/platform/acenv.h>", REPLACE_WHOLE_WORD},
{"\"platform/acenvex.h\"", "<acpi/platform/acenvex.h>", REPLACE_WHOLE_WORD},
{"\"acgcc.h\"", "<acpi/platform/acgcc.h>", REPLACE_WHOLE_WORD},
+ {"\"acintel.h\"", "<acpi/platform/acintel.h>", REPLACE_WHOLE_WORD},
{"\"aclinux.h\"", "<acpi/platform/aclinux.h>", REPLACE_WHOLE_WORD},
{"\"aclinuxex.h\"", "<acpi/platform/aclinuxex.h>", REPLACE_WHOLE_WORD},