Message ID | 20170227145652.8098-2-colin.king@canonical.com |
---|---|
State | Accepted |
Headers | show |
On 2017-02-27 10:56 PM, Colin King wrote: > From: Colin Ian King <colin.king@canonical.com> > > Changes in this release of ACPICA are detailed at the following > link on the ACPICA developer mailing list: > > https://lists.acpica.org/pipermail/devel/2017-February/001088.html > > This also contains a revert of ACPICA commit > 20741c9c6e4f86eb90948cfceb55169593b79f0b ("Disassembler: Fix small > memory leak for resource tags") as this causes iASL to segfault > as reported on the ACPICA BugZilla #1365, ("incorrect free of non" > heap object causing iasl to break when disassembling a DSDT"), see > https://bugs.acpica.org/show_bug.cgi?id=1365 > > Signed-off-by: Colin Ian King <colin.king@canonical.com> Acked-by: Alex Hung <alex.hung@canonical.com>
On 02/27/2017 10:56 PM, Colin King wrote: > From: Colin Ian King <colin.king@canonical.com> > > Changes in this release of ACPICA are detailed at the following > link on the ACPICA developer mailing list: > > https://lists.acpica.org/pipermail/devel/2017-February/001088.html > > This also contains a revert of ACPICA commit > 20741c9c6e4f86eb90948cfceb55169593b79f0b ("Disassembler: Fix small > memory leak for resource tags") as this causes iASL to segfault > as reported on the ACPICA BugZilla #1365, ("incorrect free of non" > heap object causing iasl to break when disassembling a DSDT"), see > https://bugs.acpica.org/show_bug.cgi?id=1365 > > Signed-off-by: Colin Ian King <colin.king@canonical.com> > --- > src/acpica/source/common/adisasm.c | 25 + > src/acpica/source/common/adwalk.c | 2 +- > src/acpica/source/common/dmextern.c | 25 + > src/acpica/source/common/dmtables.c | 22 + > src/acpica/source/common/dmtbinfo.c | 10 +- > src/acpica/source/compiler/Makefile.am | 3 + > src/acpica/source/compiler/aslcodegen.c | 101 ++- > src/acpica/source/compiler/aslcompile.c | 31 +- > src/acpica/source/compiler/aslcompiler.h | 16 + > src/acpica/source/compiler/aslcompiler.l | 5 +- > src/acpica/source/compiler/asldebug.c | 34 + > src/acpica/source/compiler/asldefine.h | 8 +- > src/acpica/source/compiler/aslfiles.c | 32 +- > src/acpica/source/compiler/aslglobal.h | 22 +- > src/acpica/source/compiler/asllength.c | 5 +- > src/acpica/source/compiler/aslmap.c | 36 +- > src/acpica/source/compiler/asloffset.c | 2 +- > src/acpica/source/compiler/asloperands.c | 7 +- > src/acpica/source/compiler/aslprimaries.y | 23 +- > src/acpica/source/compiler/aslprintf.c | 2 +- > src/acpica/source/compiler/aslresources.y | 9 +- > src/acpica/source/compiler/aslrules.y | 10 +- > src/acpica/source/compiler/aslstartup.c | 32 + > src/acpica/source/compiler/aslsupport.l | 114 ++- > src/acpica/source/compiler/asltree.c | 175 +++- > src/acpica/source/compiler/asltypes.h | 23 +- > src/acpica/source/compiler/aslwalks.c | 2 +- > src/acpica/source/compiler/cvcompiler.c | 962 +++++++++++++++++++++ > src/acpica/source/compiler/cvdisasm.c | 495 +++++++++++ > src/acpica/source/compiler/cvparser.c | 959 ++++++++++++++++++++ > src/acpica/source/compiler/dttable1.c | 4 + > src/acpica/source/compiler/dttemplate.h | 72 +- > src/acpica/source/components/debugger/dbmethod.c | 1 + > src/acpica/source/components/debugger/dbxface.c | 5 +- > .../source/components/disassembler/dmcstyle.c | 51 +- > .../source/components/disassembler/dmdeferred.c | 6 +- > .../source/components/disassembler/dmnames.c | 2 +- > .../source/components/disassembler/dmopcode.c | 81 +- > .../source/components/disassembler/dmutils.c | 8 + > src/acpica/source/components/disassembler/dmwalk.c | 105 ++- > .../source/components/dispatcher/dscontrol.c | 2 +- > src/acpica/source/components/dispatcher/dsmthdat.c | 3 +- > src/acpica/source/components/dispatcher/dsobject.c | 14 +- > src/acpica/source/components/dispatcher/dsopcode.c | 4 +- > src/acpica/source/components/dispatcher/dsutils.c | 6 +- > src/acpica/source/components/dispatcher/dswexec.c | 2 +- > src/acpica/source/components/dispatcher/dswload2.c | 2 +- > src/acpica/source/components/executer/exmisc.c | 16 +- > src/acpica/source/components/executer/exnames.c | 4 +- > src/acpica/source/components/executer/exoparg1.c | 15 +- > src/acpica/source/components/executer/exoparg2.c | 4 +- > src/acpica/source/components/executer/exoparg6.c | 10 +- > src/acpica/source/components/executer/exresolv.c | 2 +- > src/acpica/source/components/executer/exstore.c | 4 +- > src/acpica/source/components/executer/exstoren.c | 2 +- > src/acpica/source/components/hardware/hwvalid.c | 18 +- > src/acpica/source/components/namespace/nsaccess.c | 2 +- > src/acpica/source/components/namespace/nsrepair.c | 16 +- > src/acpica/source/components/namespace/nsrepair2.c | 6 +- > src/acpica/source/components/namespace/nsutils.c | 31 +- > src/acpica/source/components/parser/psargs.c | 30 +- > src/acpica/source/components/parser/psloop.c | 39 +- > src/acpica/source/components/parser/psobject.c | 36 + > src/acpica/source/components/parser/psopcode.c | 13 +- > src/acpica/source/components/parser/psopinfo.c | 2 +- > src/acpica/source/components/parser/psparse.c | 6 +- > src/acpica/source/components/parser/pstree.c | 9 +- > src/acpica/source/components/parser/psutils.c | 13 + > src/acpica/source/components/utilities/utalloc.c | 44 + > src/acpica/source/components/utilities/utcache.c | 2 +- > src/acpica/source/components/utilities/utdebug.c | 1 + > src/acpica/source/components/utilities/utresrc.c | 10 + > src/acpica/source/components/utilities/utxferror.c | 16 +- > src/acpica/source/include/acconfig.h | 1 + > src/acpica/source/include/acconvert.h | 276 ++++++ > src/acpica/source/include/acdisasm.h | 14 + > src/acpica/source/include/acglobal.h | 44 + > src/acpica/source/include/aclocal.h | 118 ++- > src/acpica/source/include/acmacros.h | 35 + > src/acpica/source/include/acopcode.h | 2 + > src/acpica/source/include/acpixf.h | 2 +- > src/acpica/source/include/actbl2.h | 11 + > src/acpica/source/include/amlcode.h | 104 +-- > 83 files changed, 4118 insertions(+), 400 deletions(-) > create mode 100644 src/acpica/source/compiler/cvcompiler.c > create mode 100644 src/acpica/source/compiler/cvdisasm.c > create mode 100644 src/acpica/source/compiler/cvparser.c > create mode 100644 src/acpica/source/include/acconvert.h > > diff --git a/src/acpica/source/common/adisasm.c b/src/acpica/source/common/adisasm.c > index 8ff7657..a9518d0 100644 > --- a/src/acpica/source/common/adisasm.c > +++ b/src/acpica/source/common/adisasm.c > @@ -398,6 +398,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)) > @@ -547,6 +562,7 @@ AdReparseOneTable ( > ACPI_OWNER_ID OwnerId) > { > ACPI_STATUS Status; > + ACPI_COMMENT_ADDR_NODE *AddrListHead; > > > fprintf (stderr, > @@ -580,6 +596,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/src/acpica/source/common/adwalk.c b/src/acpica/source/common/adwalk.c > index a9dd65e..34f77a9 100644 > --- a/src/acpica/source/common/adwalk.c > +++ b/src/acpica/source/common/adwalk.c > @@ -950,7 +950,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/src/acpica/source/common/dmextern.c b/src/acpica/source/common/dmextern.c > index 206916e..5f28ad0 100644 > --- a/src/acpica/source/common/dmextern.c > +++ b/src/acpica/source/common/dmextern.c > @@ -1237,6 +1237,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/src/acpica/source/common/dmtables.c b/src/acpica/source/common/dmtables.c > index 554e6df..3082f28 100644 > --- a/src/acpica/source/common/dmtables.c > +++ b/src/acpica/source/common/dmtables.c > @@ -119,6 +119,8 @@ > #include "actables.h" > #include "acparser.h" > #include "acapps.h" > +#include "acmacros.h" > +#include "acconvert.h" > > > #define _COMPONENT ACPI_TOOLS > @@ -274,6 +276,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 > @@ -460,6 +470,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 */ > > @@ -469,6 +480,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/src/acpica/source/common/dmtbinfo.c b/src/acpica/source/common/dmtbinfo.c > index 041327f..7d11370 100644 > --- a/src/acpica/source/common/dmtbinfo.c > +++ b/src/acpica/source/common/dmtbinfo.c > @@ -243,6 +243,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) > @@ -331,6 +332,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) > @@ -1621,8 +1623,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/src/acpica/source/compiler/Makefile.am b/src/acpica/source/compiler/Makefile.am > index a9bcf5c..ba5fe77 100644 > --- a/src/acpica/source/compiler/Makefile.am > +++ b/src/acpica/source/compiler/Makefile.am > @@ -128,6 +128,9 @@ libfwtsiasl_la_SOURCES = \ > aslprepkg.c \ > aslprintf.c \ > aslprune.c \ > + cvcompiler.c \ > + cvdisasm.c \ > + cvparser.c \ > dtfield.c \ > dtio.c \ > dtsubtable.c \ > diff --git a/src/acpica/source/compiler/aslcodegen.c b/src/acpica/source/compiler/aslcodegen.c > index 0764e78..95ed656 100644 > --- a/src/acpica/source/compiler/aslcodegen.c > +++ b/src/acpica/source/compiler/aslcodegen.c > @@ -116,6 +116,7 @@ > #include "aslcompiler.h" > #include "aslcompiler.y.h" > #include "amlcode.h" > +#include "acconvert.h" > > #define _COMPONENT ACPI_COMPILER > ACPI_MODULE_NAME ("aslcodegen") > @@ -129,12 +130,6 @@ CgAmlWriteWalk ( > void *Context); > > static void > -CgLocalWriteAmlData ( > - ACPI_PARSE_OBJECT *Op, > - void *Buffer, > - UINT32 Length); > - > -static void > CgWriteAmlOpcode ( > ACPI_PARSE_OBJECT *Op); > > @@ -278,7 +273,7 @@ CgAmlWriteWalk ( > * > ******************************************************************************/ > > -static void > +void > CgLocalWriteAmlData ( > ACPI_PARSE_OBJECT *Op, > void *Buffer, > @@ -333,6 +328,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: > @@ -488,6 +492,8 @@ CgWriteTableHeader ( > ACPI_PARSE_OBJECT *Op) > { > ACPI_PARSE_OBJECT *Child; > + UINT32 CommentLength; > + ACPI_COMMENT_NODE *Current; > > > /* AML filename */ > @@ -497,6 +503,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 */ > @@ -538,6 +559,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); > @@ -564,13 +629,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 */ > @@ -652,6 +717,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 */ > > @@ -713,6 +784,10 @@ CgWriteNode ( > case PARSEOP_DEFINITION_BLOCK: > > CgWriteTableHeader (Op); > + if (Gbl_CaptureComments) > + { > + CgWriteAmlDefBlockComment (Op); > + } > break; > > case PARSEOP_NAMESEG: > diff --git a/src/acpica/source/compiler/aslcompile.c b/src/acpica/source/compiler/aslcompile.c > index e601ede..9a83d59 100644 > --- a/src/acpica/source/compiler/aslcompile.c > +++ b/src/acpica/source/compiler/aslcompile.c > @@ -357,8 +357,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); > } > > @@ -419,6 +428,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"); > @@ -872,7 +893,11 @@ CmCleanupAndExit ( > > /* Final cleanup after compiling one file */ > > - CmDeleteCaches (); > + if (!Gbl_DoAslConversion) > + { > + CmDeleteCaches (); > + } > + > } > > > diff --git a/src/acpica/source/compiler/aslcompiler.h b/src/acpica/source/compiler/aslcompiler.h > index dc6f649..841d4f0 100644 > --- a/src/acpica/source/compiler/aslcompiler.h > +++ b/src/acpica/source/compiler/aslcompiler.h > @@ -648,6 +648,12 @@ void > CgGenerateAmlOutput ( > void); > > +void > +CgLocalWriteAmlData ( > + ACPI_PARSE_OBJECT *Op, > + void *Buffer, > + UINT32 Length); > + > > /* > * aslfile > @@ -1431,4 +1437,14 @@ ACPI_STATUS > DtCreateTemplates ( > char **argv); > > + > +/* > + * ASL/ASL+ converter debug > + */ > +void > +CvDbgPrint ( > + char *Fmt, > + ...); > + > + > #endif /* __ASLCOMPILER_H */ > diff --git a/src/acpica/source/compiler/aslcompiler.l b/src/acpica/source/compiler/aslcompiler.l > index e4592aa..9d84dba 100644 > --- a/src/acpica/source/compiler/aslcompiler.l > +++ b/src/acpica/source/compiler/aslcompiler.l > @@ -116,6 +116,7 @@ > > #include "aslcompiler.h" > #include "aslcompiler.y.h" > +#include "acconvert.h" > > #include <stdlib.h> > #include <string.h> > @@ -138,10 +139,10 @@ YYSTYPE AslCompilerlval; > static void > AslDoLineDirective (void); > > -static char > +static BOOLEAN > AslDoComment (void); > > -static char > +static BOOLEAN > AslDoCommentType2 (void); > > static char > diff --git a/src/acpica/source/compiler/asldebug.c b/src/acpica/source/compiler/asldebug.c > index 84eefbf..b50ad6b 100644 > --- a/src/acpica/source/compiler/asldebug.c > +++ b/src/acpica/source/compiler/asldebug.c > @@ -132,6 +132,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/src/acpica/source/compiler/asldefine.h b/src/acpica/source/compiler/asldefine.h > index 8c47087..b527eba 100644 > --- a/src/acpica/source/compiler/asldefine.h > +++ b/src/acpica/source/compiler/asldefine.h > @@ -231,7 +231,6 @@ > /* > * Macros for debug output > */ > - > #define DEBUG_MAX_LINE_LENGTH 61 > #define DEBUG_SPACES_PER_INDENT 3 > #define DEBUG_FULL_LINE_LENGTH 71 > @@ -257,4 +256,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/src/acpica/source/compiler/aslfiles.c b/src/acpica/source/compiler/aslfiles.c > index ea9ba54..e53a212 100644 > --- a/src/acpica/source/compiler/aslfiles.c > +++ b/src/acpica/source/compiler/aslfiles.c > @@ -583,8 +583,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, > @@ -926,6 +932,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/src/acpica/source/compiler/aslglobal.h b/src/acpica/source/compiler/aslglobal.h > index da706bd..9e8fa7f 100644 > --- a/src/acpica/source/compiler/aslglobal.h > +++ b/src/acpica/source/compiler/aslglobal.h > @@ -156,7 +156,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 > @@ -185,7 +186,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 > @@ -254,6 +255,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 > @@ -337,6 +341,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/src/acpica/source/compiler/asllength.c b/src/acpica/source/compiler/asllength.c > index fc7ed50..4c15cfa 100644 > --- a/src/acpica/source/compiler/asllength.c > +++ b/src/acpica/source/compiler/asllength.c > @@ -116,6 +116,7 @@ > #include "aslcompiler.h" > #include "aslcompiler.y.h" > #include "amlcode.h" > +#include "acconvert.h" > > > #define _COMPONENT ACPI_COMPILER > @@ -208,7 +209,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/src/acpica/source/compiler/aslmap.c b/src/acpica/source/compiler/aslmap.c > index 7d45fd3..96e54a6 100644 > --- a/src/acpica/source/compiler/aslmap.c > +++ b/src/acpica/source/compiler/aslmap.c > @@ -238,7 +238,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), > @@ -248,12 +248,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), > @@ -333,14 +333,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), > @@ -353,7 +353,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), > @@ -419,7 +419,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), > @@ -484,8 +484,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), > @@ -500,7 +500,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/src/acpica/source/compiler/asloffset.c b/src/acpica/source/compiler/asloffset.c > index 3dac50d..6105f8c 100644 > --- a/src/acpica/source/compiler/asloffset.c > +++ b/src/acpica/source/compiler/asloffset.c > @@ -257,7 +257,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/src/acpica/source/compiler/asloperands.c b/src/acpica/source/compiler/asloperands.c > index 9d6a9cd..7806dcc 100644 > --- a/src/acpica/source/compiler/asloperands.c > +++ b/src/acpica/source/compiler/asloperands.c > @@ -393,7 +393,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 > @@ -424,7 +424,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 > @@ -1144,7 +1145,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/src/acpica/source/compiler/aslprimaries.y b/src/acpica/source/compiler/aslprimaries.y > index 9e8d711..bc39c51 100644 > --- a/src/acpica/source/compiler/aslprimaries.y > +++ b/src/acpica/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 > * > *****************************************************************************/ > > @@ -218,9 +220,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 > @@ -475,8 +477,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;} > @@ -617,16 +620,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;} > @@ -850,17 +853,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/src/acpica/source/compiler/aslprintf.c b/src/acpica/source/compiler/aslprintf.c > index 7c53e0a..87611a0 100644 > --- a/src/acpica/source/compiler/aslprintf.c > +++ b/src/acpica/source/compiler/aslprintf.c > @@ -426,7 +426,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/src/acpica/source/compiler/aslresources.y b/src/acpica/source/compiler/aslresources.y > index c88e9c9..2926b07 100644 > --- a/src/acpica/source/compiler/aslresources.y > +++ b/src/acpica/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 > * > *****************************************************************************/ > > @@ -128,14 +130,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/src/acpica/source/compiler/aslrules.y b/src/acpica/source/compiler/aslrules.y > index c6a6413..d55b729 100644 > --- a/src/acpica/source/compiler/aslrules.y > +++ b/src/acpica/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 > * > *****************************************************************************/ > > @@ -154,14 +156,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);} > ; > @@ -249,9 +251,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/src/acpica/source/compiler/aslstartup.c b/src/acpica/source/compiler/aslstartup.c > index 37f7641..e7bf33f 100644 > --- a/src/acpica/source/compiler/aslstartup.c > +++ b/src/acpica/source/compiler/aslstartup.c > @@ -117,6 +117,7 @@ > #include "actables.h" > #include "acdisasm.h" > #include "acapps.h" > +#include "acconvert.h" > > #define _COMPONENT ACPI_COMPILER > ACPI_MODULE_NAME ("aslstartup") > @@ -195,6 +196,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; > + } > } > > > @@ -522,6 +532,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/src/acpica/source/compiler/aslsupport.l b/src/acpica/source/compiler/aslsupport.l > index cc5cf52..e877edf 100644 > --- a/src/acpica/source/compiler/aslsupport.l > +++ b/src/acpica/source/compiler/aslsupport.l > @@ -124,21 +124,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); > +} > > > /******************************************************************************* > @@ -361,6 +352,10 @@ AslPushInputFileStack ( > > Gbl_CurrentLineNumber = 1; > yyin = InputFile; > + > + /* converter: reset the comment state to STANDARD_COMMENT */ > + > + Gbl_CommentState.CommentType = STANDARD_COMMENT; > } > > > @@ -464,6 +459,11 @@ AslInsertLineBuffer ( > > AslResetCurrentLineBuffer (); > } > + > + if (Gbl_CaptureComments) > + { > + CvProcessCommentState (SourceChar); > + } > } > } > > @@ -531,16 +531,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: > > @@ -549,6 +559,11 @@ loop: > while (((c = input ()) != '*') && (c != EOF)) > { > AslInsertLineBuffer (c); > + if (Gbl_CaptureComments && CurrentState.CaptureComments) > + { > + *StringBuffer = c; > + ++StringBuffer; > + } > c1 = c; > } > > @@ -572,10 +587,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; > } > > @@ -583,8 +603,13 @@ loop: > { > goto EarlyEOF; > } > + if (StringBuffer > EndBuffer) > + { > + goto BufferOverflow; > + } > > AslInsertLineBuffer (c1); > + CvProcessComment (CurrentState, StringBuffer, c1); > return (TRUE); > > > @@ -597,6 +622,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); > + > } > > > @@ -608,23 +645,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) > @@ -634,8 +688,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/src/acpica/source/compiler/asltree.c b/src/acpica/source/compiler/asltree.c > index c2230c3..d707ef4 100644 > --- a/src/acpica/source/compiler/asltree.c > +++ b/src/acpica/source/compiler/asltree.c > @@ -116,6 +116,7 @@ > #include "aslcompiler.h" > #include "aslcompiler.y.h" > #include "acapps.h" > +#include "acconvert.h" > #include <time.h> > > #define _COMPONENT ACPI_COMPILER > @@ -212,6 +213,7 @@ TrAllocateNode ( > UINT32 ParseOpcode) > { > ACPI_PARSE_OBJECT *Op; > + ACPI_PARSE_OBJECT *LatestNode; > > > Op = TrGetNextNode (); > @@ -224,6 +226,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); > } > > @@ -366,6 +444,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); > } > > @@ -1132,6 +1217,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 */ > @@ -1145,6 +1263,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 > @@ -1169,9 +1299,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 > * > @@ -1233,6 +1363,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; > @@ -1296,6 +1445,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); > } > > @@ -1463,6 +1619,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/src/acpica/source/compiler/asltypes.h b/src/acpica/source/compiler/asltypes.h > index d04c692..2b4773e 100644 > --- a/src/acpica/source/compiler/asltypes.h > +++ b/src/acpica/source/compiler/asltypes.h > @@ -225,6 +225,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 > { > @@ -245,12 +249,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 */ > @@ -271,6 +277,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 */ > @@ -408,4 +416,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/src/acpica/source/compiler/aslwalks.c b/src/acpica/source/compiler/aslwalks.c > index 574b8e2..6eaca9f 100644 > --- a/src/acpica/source/compiler/aslwalks.c > +++ b/src/acpica/source/compiler/aslwalks.c > @@ -389,7 +389,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/src/acpica/source/compiler/cvcompiler.c b/src/acpica/source/compiler/cvcompiler.c > new file mode 100644 > index 0000000..28af25a > --- /dev/null > +++ b/src/acpica/source/compiler/cvcompiler.c > @@ -0,0 +1,962 @@ > +/****************************************************************************** > + * > + * Module Name: cvcompiler - ASL-/ASL+ converter functions > + * > + *****************************************************************************/ > + > +/****************************************************************************** > + * > + * 1. Copyright Notice > + * > + * Some or all of this work - Copyright (c) 1999 - 2017, Intel Corp. > + * All rights reserved. > + * > + * 2. License > + * > + * 2.1. This is your license from Intel Corp. under its intellectual property > + * rights. You may have additional license terms from the party that provided > + * you this software, covering your right to use that party's intellectual > + * property rights. > + * > + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a > + * copy of the source code appearing in this file ("Covered Code") an > + * irrevocable, perpetual, worldwide license under Intel's copyrights in the > + * base code distributed originally by Intel ("Original Intel Code") to copy, > + * make derivatives, distribute, use and display any portion of the Covered > + * Code in any form, with the right to sublicense such rights; and > + * > + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent > + * license (with the right to sublicense), under only those claims of Intel > + * patents that are infringed by the Original Intel Code, to make, use, sell, > + * offer to sell, and import the Covered Code and derivative works thereof > + * solely to the minimum extent necessary to exercise the above copyright > + * license, and in no event shall the patent license extend to any additions > + * to or modifications of the Original Intel Code. No other license or right > + * is granted directly or by implication, estoppel or otherwise; > + * > + * The above copyright and patent license is granted only if the following > + * conditions are met: > + * > + * 3. Conditions > + * > + * 3.1. Redistribution of Source with Rights to Further Distribute Source. > + * Redistribution of source code of any substantial portion of the Covered > + * Code or modification with rights to further distribute source must include > + * the above Copyright Notice, the above License, this list of Conditions, > + * and the following Disclaimer and Export Compliance provision. In addition, > + * Licensee must cause all Covered Code to which Licensee contributes to > + * contain a file documenting the changes Licensee made to create that Covered > + * Code and the date of any change. Licensee must include in that file the > + * documentation of any changes made by any predecessor Licensee. Licensee > + * must include a prominent statement that the modification is derived, > + * directly or indirectly, from Original Intel Code. > + * > + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. > + * Redistribution of source code of any substantial portion of the Covered > + * Code or modification without rights to further distribute source must > + * include the following Disclaimer and Export Compliance provision in the > + * documentation and/or other materials provided with distribution. In > + * addition, Licensee may not authorize further sublicense of source of any > + * portion of the Covered Code, and must include terms to the effect that the > + * license from Licensee to its licensee is limited to the intellectual > + * property embodied in the software Licensee provides to its licensee, and > + * not to intellectual property embodied in modifications its licensee may > + * make. > + * > + * 3.3. Redistribution of Executable. Redistribution in executable form of any > + * substantial portion of the Covered Code or modification must reproduce the > + * above Copyright Notice, and the following Disclaimer and Export Compliance > + * provision in the documentation and/or other materials provided with the > + * distribution. > + * > + * 3.4. Intel retains all right, title, and interest in and to the Original > + * Intel Code. > + * > + * 3.5. Neither the name Intel nor any other trademark owned or controlled by > + * Intel shall be used in advertising or otherwise to promote the sale, use or > + * other dealings in products derived from or relating to the Covered Code > + * without prior written authorization from Intel. > + * > + * 4. Disclaimer and Export Compliance > + * > + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED > + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE > + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, > + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY > + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY > + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A > + * PARTICULAR PURPOSE. > + * > + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES > + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR > + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, > + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY > + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL > + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS > + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY > + * LIMITED REMEDY. > + * > + * 4.3. Licensee shall not export, either directly or indirectly, any of this > + * software or system incorporating such software without first obtaining any > + * required license or other approval from the U. S. Department of Commerce or > + * any other agency or department of the United States Government. In the > + * event Licensee exports any such software from the United States or > + * re-exports any such software from a foreign destination, Licensee shall > + * ensure that the distribution and export/re-export of the software is in > + * compliance with all laws, regulations, orders, or other restrictions of the > + * U.S. Export Administration Regulations. Licensee agrees that neither it nor > + * any of its subsidiaries will export/re-export any technical data, process, > + * software, or service, directly or indirectly, to any country for which the > + * United States government or any agency thereof requires an export license, > + * other governmental approval, or letter of assurance, without first obtaining > + * such license, approval or letter. > + * > + *****************************************************************************/ > + > +#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/src/acpica/source/compiler/cvdisasm.c b/src/acpica/source/compiler/cvdisasm.c > new file mode 100644 > index 0000000..e588e1f > --- /dev/null > +++ b/src/acpica/source/compiler/cvdisasm.c > @@ -0,0 +1,495 @@ > +/****************************************************************************** > + * > + * Module Name: cvcompiler - ASL-/ASL+ converter functions > + * > + *****************************************************************************/ > + > +/****************************************************************************** > + * > + * 1. Copyright Notice > + * > + * Some or all of this work - Copyright (c) 1999 - 2017, Intel Corp. > + * All rights reserved. > + * > + * 2. License > + * > + * 2.1. This is your license from Intel Corp. under its intellectual property > + * rights. You may have additional license terms from the party that provided > + * you this software, covering your right to use that party's intellectual > + * property rights. > + * > + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a > + * copy of the source code appearing in this file ("Covered Code") an > + * irrevocable, perpetual, worldwide license under Intel's copyrights in the > + * base code distributed originally by Intel ("Original Intel Code") to copy, > + * make derivatives, distribute, use and display any portion of the Covered > + * Code in any form, with the right to sublicense such rights; and > + * > + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent > + * license (with the right to sublicense), under only those claims of Intel > + * patents that are infringed by the Original Intel Code, to make, use, sell, > + * offer to sell, and import the Covered Code and derivative works thereof > + * solely to the minimum extent necessary to exercise the above copyright > + * license, and in no event shall the patent license extend to any additions > + * to or modifications of the Original Intel Code. No other license or right > + * is granted directly or by implication, estoppel or otherwise; > + * > + * The above copyright and patent license is granted only if the following > + * conditions are met: > + * > + * 3. Conditions > + * > + * 3.1. Redistribution of Source with Rights to Further Distribute Source. > + * Redistribution of source code of any substantial portion of the Covered > + * Code or modification with rights to further distribute source must include > + * the above Copyright Notice, the above License, this list of Conditions, > + * and the following Disclaimer and Export Compliance provision. In addition, > + * Licensee must cause all Covered Code to which Licensee contributes to > + * contain a file documenting the changes Licensee made to create that Covered > + * Code and the date of any change. Licensee must include in that file the > + * documentation of any changes made by any predecessor Licensee. Licensee > + * must include a prominent statement that the modification is derived, > + * directly or indirectly, from Original Intel Code. > + * > + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. > + * Redistribution of source code of any substantial portion of the Covered > + * Code or modification without rights to further distribute source must > + * include the following Disclaimer and Export Compliance provision in the > + * documentation and/or other materials provided with distribution. In > + * addition, Licensee may not authorize further sublicense of source of any > + * portion of the Covered Code, and must include terms to the effect that the > + * license from Licensee to its licensee is limited to the intellectual > + * property embodied in the software Licensee provides to its licensee, and > + * not to intellectual property embodied in modifications its licensee may > + * make. > + * > + * 3.3. Redistribution of Executable. Redistribution in executable form of any > + * substantial portion of the Covered Code or modification must reproduce the > + * above Copyright Notice, and the following Disclaimer and Export Compliance > + * provision in the documentation and/or other materials provided with the > + * distribution. > + * > + * 3.4. Intel retains all right, title, and interest in and to the Original > + * Intel Code. > + * > + * 3.5. Neither the name Intel nor any other trademark owned or controlled by > + * Intel shall be used in advertising or otherwise to promote the sale, use or > + * other dealings in products derived from or relating to the Covered Code > + * without prior written authorization from Intel. > + * > + * 4. Disclaimer and Export Compliance > + * > + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED > + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE > + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, > + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY > + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY > + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A > + * PARTICULAR PURPOSE. > + * > + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES > + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR > + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, > + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY > + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL > + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS > + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY > + * LIMITED REMEDY. > + * > + * 4.3. Licensee shall not export, either directly or indirectly, any of this > + * software or system incorporating such software without first obtaining any > + * required license or other approval from the U. S. Department of Commerce or > + * any other agency or department of the United States Government. In the > + * event Licensee exports any such software from the United States or > + * re-exports any such software from a foreign destination, Licensee shall > + * ensure that the distribution and export/re-export of the software is in > + * compliance with all laws, regulations, orders, or other restrictions of the > + * U.S. Export Administration Regulations. Licensee agrees that neither it nor > + * any of its subsidiaries will export/re-export any technical data, process, > + * software, or service, directly or indirectly, to any country for which the > + * United States government or any agency thereof requires an export license, > + * other governmental approval, or letter of assurance, without first obtaining > + * such license, approval or letter. > + * > + *****************************************************************************/ > + > +#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/src/acpica/source/compiler/cvparser.c b/src/acpica/source/compiler/cvparser.c > new file mode 100644 > index 0000000..57486f4 > --- /dev/null > +++ b/src/acpica/source/compiler/cvparser.c > @@ -0,0 +1,959 @@ > +/****************************************************************************** > + * > + * Module Name: cvparser - Converter functions that are called from the AML > + * parser. > + * > + *****************************************************************************/ > + > +/****************************************************************************** > + * > + * 1. Copyright Notice > + * > + * Some or all of this work - Copyright (c) 1999 - 2017, Intel Corp. > + * All rights reserved. > + * > + * 2. License > + * > + * 2.1. This is your license from Intel Corp. under its intellectual property > + * rights. You may have additional license terms from the party that provided > + * you this software, covering your right to use that party's intellectual > + * property rights. > + * > + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a > + * copy of the source code appearing in this file ("Covered Code") an > + * irrevocable, perpetual, worldwide license under Intel's copyrights in the > + * base code distributed originally by Intel ("Original Intel Code") to copy, > + * make derivatives, distribute, use and display any portion of the Covered > + * Code in any form, with the right to sublicense such rights; and > + * > + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent > + * license (with the right to sublicense), under only those claims of Intel > + * patents that are infringed by the Original Intel Code, to make, use, sell, > + * offer to sell, and import the Covered Code and derivative works thereof > + * solely to the minimum extent necessary to exercise the above copyright > + * license, and in no event shall the patent license extend to any additions > + * to or modifications of the Original Intel Code. No other license or right > + * is granted directly or by implication, estoppel or otherwise; > + * > + * The above copyright and patent license is granted only if the following > + * conditions are met: > + * > + * 3. Conditions > + * > + * 3.1. Redistribution of Source with Rights to Further Distribute Source. > + * Redistribution of source code of any substantial portion of the Covered > + * Code or modification with rights to further distribute source must include > + * the above Copyright Notice, the above License, this list of Conditions, > + * and the following Disclaimer and Export Compliance provision. In addition, > + * Licensee must cause all Covered Code to which Licensee contributes to > + * contain a file documenting the changes Licensee made to create that Covered > + * Code and the date of any change. Licensee must include in that file the > + * documentation of any changes made by any predecessor Licensee. Licensee > + * must include a prominent statement that the modification is derived, > + * directly or indirectly, from Original Intel Code. > + * > + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. > + * Redistribution of source code of any substantial portion of the Covered > + * Code or modification without rights to further distribute source must > + * include the following Disclaimer and Export Compliance provision in the > + * documentation and/or other materials provided with distribution. In > + * addition, Licensee may not authorize further sublicense of source of any > + * portion of the Covered Code, and must include terms to the effect that the > + * license from Licensee to its licensee is limited to the intellectual > + * property embodied in the software Licensee provides to its licensee, and > + * not to intellectual property embodied in modifications its licensee may > + * make. > + * > + * 3.3. Redistribution of Executable. Redistribution in executable form of any > + * substantial portion of the Covered Code or modification must reproduce the > + * above Copyright Notice, and the following Disclaimer and Export Compliance > + * provision in the documentation and/or other materials provided with the > + * distribution. > + * > + * 3.4. Intel retains all right, title, and interest in and to the Original > + * Intel Code. > + * > + * 3.5. Neither the name Intel nor any other trademark owned or controlled by > + * Intel shall be used in advertising or otherwise to promote the sale, use or > + * other dealings in products derived from or relating to the Covered Code > + * without prior written authorization from Intel. > + * > + * 4. Disclaimer and Export Compliance > + * > + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED > + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE > + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, > + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY > + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY > + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A > + * PARTICULAR PURPOSE. > + * > + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES > + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR > + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, > + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY > + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL > + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS > + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY > + * LIMITED REMEDY. > + * > + * 4.3. Licensee shall not export, either directly or indirectly, any of this > + * software or system incorporating such software without first obtaining any > + * required license or other approval from the U. S. Department of Commerce or > + * any other agency or department of the United States Government. In the > + * event Licensee exports any such software from the United States or > + * re-exports any such software from a foreign destination, Licensee shall > + * ensure that the distribution and export/re-export of the software is in > + * compliance with all laws, regulations, orders, or other restrictions of the > + * U.S. Export Administration Regulations. Licensee agrees that neither it nor > + * any of its subsidiaries will export/re-export any technical data, process, > + * software, or service, directly or indirectly, to any country for which the > + * United States government or any agency thereof requires an export license, > + * other governmental approval, or letter of assurance, without first obtaining > + * such license, approval or letter. > + * > + *****************************************************************************/ > + > +#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/src/acpica/source/compiler/dttable1.c b/src/acpica/source/compiler/dttable1.c > index 7552d5b..7c5860c 100644 > --- a/src/acpica/source/compiler/dttable1.c > +++ b/src/acpica/source/compiler/dttable1.c > @@ -1590,6 +1590,10 @@ DtCompileIort ( > } > > IortNode->MappingCount = IdMappingNumber; > + if (!IdMappingNumber) > + { > + IortNode->MappingOffset = 0; > + } > > /* > * Node length can be determined by DT_LENGTH option > diff --git a/src/acpica/source/compiler/dttemplate.h b/src/acpica/source/compiler/dttemplate.h > index 9c85d94..59175d7 100644 > --- a/src/acpica/source/compiler/dttemplate.h > +++ b/src/acpica/source/compiler/dttemplate.h > @@ -615,47 +615,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/src/acpica/source/components/debugger/dbmethod.c b/src/acpica/source/components/debugger/dbmethod.c > index 60df51a..aba9134 100644 > --- a/src/acpica/source/components/debugger/dbmethod.c > +++ b/src/acpica/source/components/debugger/dbmethod.c > @@ -551,6 +551,7 @@ AcpiDbWalkForExecute ( > Status = AcpiGetObjectInfo (ObjHandle, &ObjInfo); > if (ACPI_FAILURE (Status)) > { > + ACPI_FREE (Pathname); > return (Status); > } > > diff --git a/src/acpica/source/components/debugger/dbxface.c b/src/acpica/source/components/debugger/dbxface.c > index 46eb6da..97261a1 100644 > --- a/src/acpica/source/components/debugger/dbxface.c > +++ b/src/acpica/source/components/debugger/dbxface.c > @@ -117,6 +117,7 @@ > #include "accommon.h" > #include "amlcode.h" > #include "acdebug.h" > +#include "acinterp.h" > > > #define _COMPONENT ACPI_CA_DEBUGGER > @@ -209,7 +210,7 @@ ErrorExit: > * > * RETURN: Status > * > - * DESCRIPTION: Called for AML_BREAK_POINT_OP > + * DESCRIPTION: Called for AML_BREAKPOINT_OP > * > ******************************************************************************/ > > @@ -476,7 +477,9 @@ AcpiDbSingleStep ( > } > > > + AcpiExExitInterpreter (); > Status = AcpiDbStartCommand (WalkState, Op); > + AcpiExEnterInterpreter (); > > /* User commands complete, continue execution of the interrupted method */ > > diff --git a/src/acpica/source/components/disassembler/dmcstyle.c b/src/acpica/source/components/disassembler/dmcstyle.c > index 5b2f827..76e0a3a 100644 > --- a/src/acpica/source/components/disassembler/dmcstyle.c > +++ b/src/acpica/source/components/disassembler/dmcstyle.c > @@ -118,6 +118,7 @@ > #include "acparser.h" > #include "amlcode.h" > #include "acdebug.h" > +#include "acconvert.h" > > > #define _COMPONENT ACPI_CA_DEBUGGER > @@ -243,27 +244,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 > @@ -271,15 +272,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; > > @@ -315,7 +316,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); > @@ -546,11 +547,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 ("("); > @@ -797,12 +798,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; > } > > @@ -820,16 +823,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; > } > > @@ -849,15 +853,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: > @@ -867,6 +873,9 @@ AcpiDmCloseOperator ( > } > > AcpiOsPrintf (")"); > + ASL_CV_PRINT_ONE_COMMENT (Op, AML_COMMENT_END_NODE, NULL, 0); > + > + return; > } > > > diff --git a/src/acpica/source/components/disassembler/dmdeferred.c b/src/acpica/source/components/disassembler/dmdeferred.c > index b83a415..1d1d0e8 100644 > --- a/src/acpica/source/components/disassembler/dmdeferred.c > +++ b/src/acpica/source/components/disassembler/dmdeferred.c > @@ -175,7 +175,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); > @@ -289,7 +289,7 @@ AcpiDmDeferredParse ( > { > case AML_BUFFER_OP: > case AML_PACKAGE_OP: > - case AML_VAR_PACKAGE_OP: > + case AML_VARIABLE_PACKAGE_OP: > > switch (Op->Common.AmlOpcode) > { > @@ -300,7 +300,7 @@ AcpiDmDeferredParse ( > ACPI_FREE (ExtraOp); > break; > > - case AML_VAR_PACKAGE_OP: > + case AML_VARIABLE_PACKAGE_OP: > case AML_BUFFER_OP: > default: > > diff --git a/src/acpica/source/components/disassembler/dmnames.c b/src/acpica/source/components/disassembler/dmnames.c > index cd4445b..916d592 100644 > --- a/src/acpica/source/components/disassembler/dmnames.c > +++ b/src/acpica/source/components/disassembler/dmnames.c > @@ -316,7 +316,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/src/acpica/source/components/disassembler/dmopcode.c b/src/acpica/source/components/disassembler/dmopcode.c > index fb924f2..17e726d 100644 > --- a/src/acpica/source/components/disassembler/dmopcode.c > +++ b/src/acpica/source/components/disassembler/dmopcode.c > @@ -120,6 +120,7 @@ > #include "acinterp.h" > #include "acnamesp.h" > #include "acdebug.h" > +#include "acconvert.h" > > > #define _COMPONENT ACPI_CA_DEBUGGER > @@ -142,7 +143,8 @@ AcpiDmPromoteSubtree ( > > static BOOLEAN > AcpiDmIsSwitchBlock ( > - ACPI_PARSE_OBJECT *Op); > + ACPI_PARSE_OBJECT *Op, > + char *Temp); > > static BOOLEAN > AcpiDmIsCaseBlock ( > @@ -788,15 +790,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; > > @@ -819,12 +821,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; > @@ -953,8 +955,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; > @@ -995,6 +1001,7 @@ AcpiDmDisassembleOneOp ( > > AcpiOsPrintf (")"); > AcpiDmCommaIfFieldMember (Op); > + ASL_CV_PRINT_ONE_COMMENT (Op, AML_COMMENT_END_NODE, NULL, 0); > break; > > case AML_INT_CONNECTION_OP: > @@ -1028,6 +1035,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 */ > @@ -1049,7 +1058,7 @@ AcpiDmDisassembleOneOp ( > > case AML_WHILE_OP: > > - if (AcpiDmIsSwitchBlock(Op)) > + if (Op->Common.DisasmOpcode == ACPI_DASM_SWITCH) > { > AcpiOsPrintf ("%s", "Switch"); > break; > @@ -1078,15 +1087,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 */ > @@ -1327,11 +1334,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. > * > ******************************************************************************/ > > @@ -1339,6 +1348,7 @@ BOOLEAN > AcpiDmIsTempName ( > ACPI_PARSE_OBJECT *Op) > { > + ACPI_PARSE_OBJECT *CurrentOp; > char *Temp; > > if (Op->Common.AmlOpcode != AML_NAME_OP) > @@ -1354,11 +1364,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); > } > > /******************************************************************************* > @@ -1394,7 +1414,8 @@ AcpiDmIsTempName ( > > static BOOLEAN > AcpiDmIsSwitchBlock ( > - ACPI_PARSE_OBJECT *Op) > + ACPI_PARSE_OBJECT *Op, > + char *Temp) > { > ACPI_PARSE_OBJECT *OneOp; > ACPI_PARSE_OBJECT *StoreOp; > @@ -1427,7 +1448,7 @@ AcpiDmIsSwitchBlock ( > return (FALSE); > } > > - if (strncmp((char *)(NamePathOp->Common.Aml), "_T_", 3)) > + if (strncmp((char *)(NamePathOp->Common.Aml), Temp, 4)) > { > return (FALSE); > } > @@ -1483,7 +1504,7 @@ AcpiDmIsSwitchBlock ( > TempOp = AcpiPsGetArg (CurrentOp, 0); > switch (TempOp->Common.AmlOpcode) > { > - case (AML_LEQUAL_OP): > + case (AML_LOGICAL_EQUAL_OP): > > /* Ignore just the LEqual Op */ > > @@ -1505,7 +1526,7 @@ AcpiDmIsSwitchBlock ( > > break; > > - case (AML_LNOT_OP): > + case (AML_LOGICAL_NOT_OP): > > /* > * The Package will be the predicate of the Case statement. > @@ -1660,7 +1681,7 @@ AcpiDmIsCaseBlock ( > > switch (CurrentOp->Common.AmlOpcode) > { > - case (AML_LEQUAL_OP): > + case (AML_LOGICAL_EQUAL_OP): > > /* Next child must be NamePath with string _T_ */ > > @@ -1673,12 +1694,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/src/acpica/source/components/disassembler/dmutils.c b/src/acpica/source/components/disassembler/dmutils.c > index 2f4a343..33c8b5c 100644 > --- a/src/acpica/source/components/disassembler/dmutils.c > +++ b/src/acpica/source/components/disassembler/dmutils.c > @@ -117,6 +117,7 @@ > #include "accommon.h" > #include "amlcode.h" > #include "acdisasm.h" > +#include "acconvert.h" > > #ifdef ACPI_ASL_COMPILER > #include <acnamesp.h> > @@ -322,6 +323,7 @@ AcpiDmCommaIfListMember ( > > if (!Op->Common.Next) > { > + ASL_CV_PRINT_ONE_COMMENT (Op, AMLCOMMENT_INLINE, NULL, 0); > return (FALSE); > } > > @@ -331,6 +333,7 @@ AcpiDmCommaIfListMember ( > > if (Op->Common.Next->Common.DisasmFlags & ACPI_PARSEOP_IGNORE) > { > + ASL_CV_PRINT_ONE_COMMENT (Op, AMLCOMMENT_INLINE, NULL, 0); > return (FALSE); > } > > @@ -347,6 +350,7 @@ AcpiDmCommaIfListMember ( > */ > if (!Op->Common.Next->Common.Next) > { > + ASL_CV_PRINT_ONE_COMMENT (Op, AMLCOMMENT_INLINE, NULL, 0); > return (FALSE); > } > } > @@ -354,6 +358,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); > } > > @@ -362,6 +367,7 @@ AcpiDmCommaIfListMember ( > if (!Op->Common.OperatorSymbol) > { > AcpiOsPrintf (", "); > + ASL_CV_PRINT_ONE_COMMENT (Op, AMLCOMMENT_INLINE, NULL, 0); > } > > return (TRUE); > @@ -371,6 +377,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/src/acpica/source/components/disassembler/dmwalk.c b/src/acpica/source/components/disassembler/dmwalk.c > index fa681d7..3c17b8c 100644 > --- a/src/acpica/source/components/disassembler/dmwalk.c > +++ b/src/acpica/source/components/disassembler/dmwalk.c > @@ -118,6 +118,7 @@ > #include "acparser.h" > #include "amlcode.h" > #include "acdebug.h" > +#include "acconvert.h" > > > #define _COMPONENT ACPI_CA_DEBUGGER > @@ -135,6 +136,14 @@ AcpiDmEmitExternals ( > { > return; > } > + > +void > +AcpiDmEmitExternal ( > + ACPI_PARSE_OBJECT *NameOp, > + ACPI_PARSE_OBJECT *TypeOp) > +{ > + return; > +} > #endif > > /* Local prototypes */ > @@ -151,10 +160,6 @@ AcpiDmAscendingOp ( > UINT32 Level, > void *Context); > > -static UINT32 > -AcpiDmBlockType ( > - ACPI_PARSE_OBJECT *Op); > - > > /******************************************************************************* > * > @@ -320,7 +325,7 @@ AcpiDmWalkParseTree ( > * > ******************************************************************************/ > > -static UINT32 > +UINT32 > AcpiDmBlockType ( > ACPI_PARSE_OBJECT *Op) > { > @@ -342,7 +347,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: > @@ -364,7 +369,7 @@ AcpiDmBlockType ( > /*lint -fallthrough */ > > case AML_PACKAGE_OP: > - case AML_VAR_PACKAGE_OP: > + case AML_VARIABLE_PACKAGE_OP: > > return (BLOCK_PAREN | BLOCK_BRACE); > > @@ -376,7 +381,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 */ > > @@ -429,7 +434,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: > @@ -442,7 +447,7 @@ AcpiDmListType ( > > case AML_BUFFER_OP: > case AML_PACKAGE_OP: > - case AML_VAR_PACKAGE_OP: > + case AML_VARIABLE_PACKAGE_OP: > > return (BLOCK_COMMA_LIST); > > @@ -486,6 +491,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 */ > @@ -600,7 +621,11 @@ AcpiDmDescendingOp ( > > /* Emit all External() declarations here */ > > - AcpiDmEmitExternals (); > + if (!AcpiGbl_DmEmitExternalOpcodes) > + { > + AcpiDmEmitExternals (); > + } > + > return (AE_OK); > } > } > @@ -679,6 +704,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) || > @@ -689,6 +720,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 */ > @@ -733,7 +768,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 */ > > @@ -746,6 +781,7 @@ AcpiDmDescendingOp ( > > AcpiDmCheckForHardwareId (Op); > AcpiOsPrintf (", "); > + ASL_CV_PRINT_ONE_COMMENT (Op, AML_NAMECOMMENT, NULL, 0); > break; > > case AML_REGION_OP: > @@ -753,7 +789,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 */ > > @@ -795,7 +831,7 @@ AcpiDmDescendingOp ( > case AML_DEVICE_OP: > case AML_THERMAL_ZONE_OP: > > - AcpiOsPrintf (")"); > + ASL_CV_CLOSE_PAREN (Op, Level); > break; > > default: > @@ -889,7 +925,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 */ > > @@ -907,7 +943,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 */ > @@ -975,6 +1011,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) > { > @@ -987,7 +1037,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); > } > > @@ -1048,12 +1108,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); > @@ -1103,7 +1163,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)) > { > @@ -1143,7 +1203,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 > @@ -1170,7 +1230,8 @@ AcpiDmAscendingOp ( > else > { > ParentOp->Common.DisasmFlags |= ACPI_PARSEOP_EMPTY_TERMLIST; > - AcpiOsPrintf (") {"); > + ASL_CV_CLOSE_PAREN (Op, Level); > + AcpiOsPrintf ("{"); > } > } > > diff --git a/src/acpica/source/components/dispatcher/dscontrol.c b/src/acpica/source/components/dispatcher/dscontrol.c > index bfbd4b1..777a270 100644 > --- a/src/acpica/source/components/dispatcher/dscontrol.c > +++ b/src/acpica/source/components/dispatcher/dscontrol.c > @@ -430,7 +430,7 @@ AcpiDsExecEndControlOp ( > > break; > > - case AML_BREAK_POINT_OP: > + case AML_BREAKPOINT_OP: > > AcpiDbSignalBreakPoint (WalkState); > > diff --git a/src/acpica/source/components/dispatcher/dsmthdat.c b/src/acpica/source/components/dispatcher/dsmthdat.c > index 18763e5..539438f 100644 > --- a/src/acpica/source/components/dispatcher/dsmthdat.c > +++ b/src/acpica/source/components/dispatcher/dsmthdat.c > @@ -800,7 +800,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/src/acpica/source/components/dispatcher/dsobject.c b/src/acpica/source/components/dispatcher/dsobject.c > index 6cdb335..d0dee77 100644 > --- a/src/acpica/source/components/dispatcher/dsobject.c > +++ b/src/acpica/source/components/dispatcher/dsobject.c > @@ -185,7 +185,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 > @@ -214,7 +214,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 > @@ -483,7 +483,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; > } > @@ -867,9 +867,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 > @@ -882,9 +882,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/src/acpica/source/components/dispatcher/dsopcode.c b/src/acpica/source/components/dispatcher/dsopcode.c > index d2d5d8b..254d43e 100644 > --- a/src/acpica/source/components/dispatcher/dsopcode.c > +++ b/src/acpica/source/components/dispatcher/dsopcode.c > @@ -753,7 +753,7 @@ AcpiDsEvalDataObjectOperands ( > break; > > case AML_PACKAGE_OP: > - case AML_VAR_PACKAGE_OP: > + case AML_VARIABLE_PACKAGE_OP: > > Status = AcpiDsBuildInternalPackageObj ( > WalkState, Op, Length, &ObjDesc); > @@ -773,7 +773,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/src/acpica/source/components/dispatcher/dsutils.c b/src/acpica/source/components/dispatcher/dsutils.c > index 0dd2c57..5de1d89 100644 > --- a/src/acpica/source/components/dispatcher/dsutils.c > +++ b/src/acpica/source/components/dispatcher/dsutils.c > @@ -369,8 +369,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)) > { > @@ -661,7 +661,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 > @@ -942,7 +942,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/src/acpica/source/components/dispatcher/dswexec.c b/src/acpica/source/components/dispatcher/dswexec.c > index 6d8421f..716e1e6 100644 > --- a/src/acpica/source/components/dispatcher/dswexec.c > +++ b/src/acpica/source/components/dispatcher/dswexec.c > @@ -608,7 +608,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/src/acpica/source/components/dispatcher/dswload2.c b/src/acpica/source/components/dispatcher/dswload2.c > index 6cc32ee..0a4f9fc 100644 > --- a/src/acpica/source/components/dispatcher/dswload2.c > +++ b/src/acpica/source/components/dispatcher/dswload2.c > @@ -615,7 +615,7 @@ AcpiDsLoad2EndOp ( > Status = AcpiExCreateProcessor (WalkState); > break; > > - case AML_POWER_RES_OP: > + case AML_POWER_RESOURCE_OP: > > Status = AcpiExCreatePowerResource (WalkState); > break; > diff --git a/src/acpica/source/components/executer/exmisc.c b/src/acpica/source/components/executer/exmisc.c > index e12a9b1..d888e76 100644 > --- a/src/acpica/source/components/executer/exmisc.c > +++ b/src/acpica/source/components/executer/exmisc.c > @@ -347,7 +347,7 @@ AcpiExDoLogicalNumericOp ( > > switch (Opcode) > { > - case AML_LAND_OP: /* LAnd (Integer0, Integer1) */ > + case AML_LOGICAL_AND_OP: /* LAnd (Integer0, Integer1) */ > > if (Integer0 && Integer1) > { > @@ -355,7 +355,7 @@ AcpiExDoLogicalNumericOp ( > } > break; > > - case AML_LOR_OP: /* LOr (Integer0, Integer1) */ > + case AML_LOGICAL_OR_OP: /* LOr (Integer0, Integer1) */ > > if (Integer0 || Integer1) > { > @@ -473,7 +473,7 @@ AcpiExDoLogicalOp ( > > switch (Opcode) > { > - case AML_LEQUAL_OP: /* LEqual (Operand0, Operand1) */ > + case AML_LOGICAL_EQUAL_OP: /* LEqual (Operand0, Operand1) */ > > if (Integer0 == Integer1) > { > @@ -481,7 +481,7 @@ AcpiExDoLogicalOp ( > } > break; > > - case AML_LGREATER_OP: /* LGreater (Operand0, Operand1) */ > + case AML_LOGICAL_GREATER_OP: /* LGreater (Operand0, Operand1) */ > > if (Integer0 > Integer1) > { > @@ -489,7 +489,7 @@ AcpiExDoLogicalOp ( > } > break; > > - case AML_LLESS_OP: /* LLess (Operand0, Operand1) */ > + case AML_LOGICAL_LESS_OP: /* LLess (Operand0, Operand1) */ > > if (Integer0 < Integer1) > { > @@ -522,7 +522,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 */ > > @@ -535,7 +535,7 @@ AcpiExDoLogicalOp ( > } > break; > > - case AML_LGREATER_OP: /* LGreater (Operand0, Operand1) */ > + case AML_LOGICAL_GREATER_OP: /* LGreater (Operand0, Operand1) */ > > if (Compare > 0) > { > @@ -555,7 +555,7 @@ AcpiExDoLogicalOp ( > } > break; > > - case AML_LLESS_OP: /* LLess (Operand0, Operand1) */ > + case AML_LOGICAL_LESS_OP: /* LLess (Operand0, Operand1) */ > > if (Compare > 0) > { > diff --git a/src/acpica/source/components/executer/exnames.c b/src/acpica/source/components/executer/exnames.c > index 705862b..9d33b0b 100644 > --- a/src/acpica/source/components/executer/exnames.c > +++ b/src/acpica/source/components/executer/exnames.c > @@ -213,7 +213,7 @@ AcpiExAllocateNameString ( > { > /* Set up multi prefixes */ > > - *TempPtr++ = AML_MULTI_NAME_PREFIX_OP; > + *TempPtr++ = AML_MULTI_NAME_PREFIX; > *TempPtr++ = (char) NumNameSegs; > } > else if (2 == NumNameSegs) > @@ -457,7 +457,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/src/acpica/source/components/executer/exoparg1.c b/src/acpica/source/components/executer/exoparg1.c > index 800be70..cbe2eb4 100644 > --- a/src/acpica/source/components/executer/exoparg1.c > +++ b/src/acpica/source/components/executer/exoparg1.c > @@ -376,7 +376,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 */ > > @@ -507,7 +507,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 > @@ -579,13 +579,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); > @@ -597,7 +597,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); > @@ -712,7 +712,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) > @@ -763,7 +763,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/src/acpica/source/components/executer/exoparg2.c b/src/acpica/source/components/executer/exoparg2.c > index 2daf8c1..b3806cc 100644 > --- a/src/acpica/source/components/executer/exoparg2.c > +++ b/src/acpica/source/components/executer/exoparg2.c > @@ -402,7 +402,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); > @@ -448,7 +448,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/src/acpica/source/components/executer/exoparg6.c b/src/acpica/source/components/executer/exoparg6.c > index 4f9f99b..816b197 100644 > --- a/src/acpica/source/components/executer/exoparg6.c > +++ b/src/acpica/source/components/executer/exoparg6.c > @@ -206,7 +206,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); > @@ -219,7 +219,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); > @@ -233,7 +233,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); > @@ -246,7 +246,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); > @@ -260,7 +260,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/src/acpica/source/components/executer/exresolv.c b/src/acpica/source/components/executer/exresolv.c > index 758c286..f51fc8c 100644 > --- a/src/acpica/source/components/executer/exresolv.c > +++ b/src/acpica/source/components/executer/exresolv.c > @@ -282,7 +282,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/src/acpica/source/components/executer/exstore.c b/src/acpica/source/components/executer/exstore.c > index 76f6629..884342d 100644 > --- a/src/acpica/source/components/executer/exstore.c > +++ b/src/acpica/source/components/executer/exstore.c > @@ -507,7 +507,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 > @@ -593,7 +593,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/src/acpica/source/components/executer/exstoren.c b/src/acpica/source/components/executer/exstoren.c > index 200ef8c..6b4fd33 100644 > --- a/src/acpica/source/components/executer/exstoren.c > +++ b/src/acpica/source/components/executer/exstoren.c > @@ -185,7 +185,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/src/acpica/source/components/hardware/hwvalid.c b/src/acpica/source/components/hardware/hwvalid.c > index 8405468..c1a1063 100644 > --- a/src/acpica/source/components/hardware/hwvalid.c > +++ b/src/acpica/source/components/hardware/hwvalid.c > @@ -179,7 +179,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) > > > /****************************************************************************** > @@ -209,7 +209,7 @@ AcpiHwValidateIoRequest ( > const ACPI_PORT_INFO *PortInfo; > > > - ACPI_FUNCTION_TRACE (HwValidateIoRequest); > + ACPI_FUNCTION_NAME (HwValidateIoRequest); > > > /* Supported widths are 8/16/32 */ > @@ -238,14 +238,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 */ > @@ -254,7 +254,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 > @@ -284,7 +284,7 @@ AcpiHwValidateIoRequest ( > } > } > > - return_ACPI_STATUS (AE_OK); > + return (AE_OK); > } > > > @@ -293,7 +293,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 > @@ -339,7 +339,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) > { > @@ -413,7 +413,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/src/acpica/source/components/namespace/nsaccess.c b/src/acpica/source/components/namespace/nsaccess.c > index 949e7bd..8463cc3 100644 > --- a/src/acpica/source/components/namespace/nsaccess.c > +++ b/src/acpica/source/components/namespace/nsaccess.c > @@ -577,7 +577,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/src/acpica/source/components/namespace/nsrepair.c b/src/acpica/source/components/namespace/nsrepair.c > index 14f4095..4b0c59b 100644 > --- a/src/acpica/source/components/namespace/nsrepair.c > +++ b/src/acpica/source/components/namespace/nsrepair.c > @@ -374,24 +374,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/src/acpica/source/components/namespace/nsrepair2.c b/src/acpica/source/components/namespace/nsrepair2.c > index 2e36b89..241a4b0 100644 > --- a/src/acpica/source/components/namespace/nsrepair2.c > +++ b/src/acpica/source/components/namespace/nsrepair2.c > @@ -520,16 +520,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/src/acpica/source/components/namespace/nsutils.c b/src/acpica/source/components/namespace/nsutils.c > index 601bc2e..5bdcc63 100644 > --- a/src/acpica/source/components/namespace/nsutils.c > +++ b/src/acpica/source/components/namespace/nsutils.c > @@ -366,7 +366,7 @@ AcpiNsBuildInternalName ( > } > else > { > - InternalName[1] = AML_MULTI_NAME_PREFIX_OP; > + InternalName[1] = AML_MULTI_NAME_PREFIX; > InternalName[2] = (char) NumSegments; > Result = &InternalName[3]; > } > @@ -397,7 +397,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]; > } > @@ -606,7 +606,7 @@ AcpiNsExternalizeName ( > { > switch (InternalName[PrefixLength]) > { > - case AML_MULTI_NAME_PREFIX_OP: > + case AML_MULTI_NAME_PREFIX: > > /* <count> 4-byte names */ > > @@ -766,28 +766,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/src/acpica/source/components/parser/psargs.c b/src/acpica/source/components/parser/psargs.c > index df7f6d2..7e893f7 100644 > --- a/src/acpica/source/components/parser/psargs.c > +++ b/src/acpica/source/components/parser/psargs.c > @@ -119,6 +119,7 @@ > #include "amlcode.h" > #include "acnamesp.h" > #include "acdispat.h" > +#include "acconvert.h" > > #define _COMPONENT ACPI_PARSER > ACPI_MODULE_NAME ("psargs") > @@ -280,7 +281,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 */ > > @@ -441,7 +442,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; > } > @@ -453,7 +454,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; > } > @@ -615,6 +616,7 @@ AcpiPsGetNextField ( > ACPI_FUNCTION_TRACE (PsGetNextField); > > > + ASL_CV_CAPTURE_COMMENTS_ONLY (ParserState); > Aml = ParserState->Aml; > > /* Determine field type */ > @@ -661,6 +663,7 @@ AcpiPsGetNextField ( > > /* Decode the field type */ > > + ASL_CV_CAPTURE_COMMENTS_ONLY (ParserState); > switch (Opcode) > { > case AML_INT_NAMEDFIELD_OP: > @@ -671,6 +674,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); > @@ -727,10 +747,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 */ > @@ -747,6 +769,7 @@ AcpiPsGetNextField ( > Opcode = ACPI_GET8 (ParserState->Aml); > ParserState->Aml++; > > + ASL_CV_CAPTURE_COMMENTS_ONLY (ParserState); > switch (Opcode) > { > case AML_BYTE_OP: /* AML_BYTEDATA_ARG */ > @@ -775,6 +798,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/src/acpica/source/components/parser/psloop.c b/src/acpica/source/components/parser/psloop.c > index 4f51573..de55004 100644 > --- a/src/acpica/source/components/parser/psloop.c > +++ b/src/acpica/source/components/parser/psloop.c > @@ -127,6 +127,7 @@ > #include "acparser.h" > #include "acdispat.h" > #include "amlcode.h" > +#include "acconvert.h" > > #define _COMPONENT ACPI_PARSER > ACPI_MODULE_NAME ("psloop") > @@ -214,6 +215,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)) > @@ -321,7 +338,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) && > @@ -559,6 +576,8 @@ AcpiPsParseLoop ( > > while ((ParserState->Aml < ParserState->AmlEnd) || (Op)) > { > + ASL_CV_CAPTURE_COMMENTS (WalkState); > + > AmlOpStart = ParserState->Aml; > if (!Op) > { > @@ -592,12 +611,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/src/acpica/source/components/parser/psobject.c b/src/acpica/source/components/parser/psobject.c > index 49f11f3..7d54dca 100644 > --- a/src/acpica/source/components/parser/psobject.c > +++ b/src/acpica/source/components/parser/psobject.c > @@ -117,6 +117,7 @@ > #include "accommon.h" > #include "acparser.h" > #include "amlcode.h" > +#include "acconvert.h" > > #define _COMPONENT ACPI_PARSER > ACPI_MODULE_NAME ("psobject") > @@ -273,6 +274,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)) > @@ -284,6 +286,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 > */ > @@ -329,6 +343,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/src/acpica/source/components/parser/psopcode.c b/src/acpica/source/components/parser/psopcode.c > index f7176a7..95988fb 100644 > --- a/src/acpica/source/components/parser/psopcode.c > +++ b/src/acpica/source/components/parser/psopcode.c > @@ -144,7 +144,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 > @@ -170,7 +170,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 > @@ -188,7 +188,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 > @@ -211,7 +211,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 > @@ -224,7 +224,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 > @@ -409,7 +409,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/src/acpica/source/components/parser/psopinfo.c b/src/acpica/source/components/parser/psopinfo.c > index 5245351..e04649b 100644 > --- a/src/acpica/source/components/parser/psopinfo.c > +++ b/src/acpica/source/components/parser/psopinfo.c > @@ -314,7 +314,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/src/acpica/source/components/parser/psparse.c b/src/acpica/source/components/parser/psparse.c > index ba92d3e..f0385e0 100644 > --- a/src/acpica/source/components/parser/psparse.c > +++ b/src/acpica/source/components/parser/psparse.c > @@ -186,7 +186,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 */ > > @@ -290,7 +290,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); > @@ -304,7 +304,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/src/acpica/source/components/parser/pstree.c b/src/acpica/source/components/parser/pstree.c > index d987d65..2334a7d 100644 > --- a/src/acpica/source/components/parser/pstree.c > +++ b/src/acpica/source/components/parser/pstree.c > @@ -117,6 +117,7 @@ > #include "accommon.h" > #include "acparser.h" > #include "amlcode.h" > +#include "acconvert.h" > > #define _COMPONENT ACPI_PARSER > ACPI_MODULE_NAME ("pstree") > @@ -314,6 +315,7 @@ AcpiPsGetDepthNext ( > Next = AcpiPsGetArg (Op, 0); > if (Next) > { > + ASL_CV_LABEL_FILENODE (Next); > return (Next); > } > > @@ -322,6 +324,7 @@ AcpiPsGetDepthNext ( > Next = Op->Common.Next; > if (Next) > { > + ASL_CV_LABEL_FILENODE (Next); > return (Next); > } > > @@ -334,6 +337,8 @@ AcpiPsGetDepthNext ( > Arg = AcpiPsGetArg (Parent, 0); > while (Arg && (Arg != Origin) && (Arg != Op)) > { > + > + ASL_CV_LABEL_FILENODE (Arg); > Arg = Arg->Common.Next; > } > > @@ -348,6 +353,7 @@ AcpiPsGetDepthNext ( > { > /* Found sibling of parent */ > > + ASL_CV_LABEL_FILENODE (Parent->Common.Next); > return (Parent->Common.Next); > } > > @@ -355,6 +361,7 @@ AcpiPsGetDepthNext ( > Parent = Parent->Common.Parent; > } > > + ASL_CV_LABEL_FILENODE (Next); > return (Next); > } > > @@ -403,7 +410,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/src/acpica/source/components/parser/psutils.c b/src/acpica/source/components/parser/psutils.c > index 5eec90b..fc9005a 100644 > --- a/src/acpica/source/components/parser/psutils.c > +++ b/src/acpica/source/components/parser/psutils.c > @@ -117,6 +117,7 @@ > #include "accommon.h" > #include "acparser.h" > #include "amlcode.h" > +#include "acconvert.h" > > #define _COMPONENT ACPI_PARSER > ACPI_MODULE_NAME ("psutils") > @@ -249,6 +250,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); > @@ -275,6 +287,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/src/acpica/source/components/utilities/utalloc.c b/src/acpica/source/components/utilities/utalloc.c > index ce194d4..4d035eb 100644 > --- a/src/acpica/source/components/utilities/utalloc.c > +++ b/src/acpica/source/components/utilities/utalloc.c > @@ -216,6 +216,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 > > @@ -282,6 +316,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/src/acpica/source/components/utilities/utcache.c b/src/acpica/source/components/utilities/utcache.c > index 93a6c70..e9df612 100644 > --- a/src/acpica/source/components/utilities/utcache.c > +++ b/src/acpica/source/components/utilities/utcache.c > @@ -149,7 +149,7 @@ AcpiOsCreateCache ( > ACPI_FUNCTION_ENTRY (); > > > - if (!CacheName || !ReturnCache || (ObjectSize < 16)) > + if (!CacheName || !ReturnCache || !ObjectSize) > { > return (AE_BAD_PARAMETER); > } > diff --git a/src/acpica/source/components/utilities/utdebug.c b/src/acpica/source/components/utilities/utdebug.c > index 3faa6b2..c78ae96 100644 > --- a/src/acpica/source/components/utilities/utdebug.c > +++ b/src/acpica/source/components/utilities/utdebug.c > @@ -779,4 +779,5 @@ AcpiTracePoint ( > > ACPI_EXPORT_SYMBOL (AcpiTracePoint) > > + > #endif > diff --git a/src/acpica/source/components/utilities/utresrc.c b/src/acpica/source/components/utilities/utresrc.c > index d26b15c..c08e9c7 100644 > --- a/src/acpica/source/components/utilities/utresrc.c > +++ b/src/acpica/source/components/utilities/utresrc.c > @@ -598,6 +598,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/src/acpica/source/components/utilities/utxferror.c b/src/acpica/source/components/utilities/utxferror.c > index b660bb0..0ce7195 100644 > --- a/src/acpica/source/components/utilities/utxferror.c > +++ b/src/acpica/source/components/utilities/utxferror.c > @@ -173,7 +173,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 > @@ -224,8 +224,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 > @@ -262,17 +262,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 > @@ -340,8 +336,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/src/acpica/source/include/acconfig.h b/src/acpica/source/include/acconfig.h > index cd5533c..7f069f9 100644 > --- a/src/acpica/source/include/acconfig.h > +++ b/src/acpica/source/include/acconfig.h > @@ -151,6 +151,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/src/acpica/source/include/acconvert.h b/src/acpica/source/include/acconvert.h > new file mode 100644 > index 0000000..f7fd873 > --- /dev/null > +++ b/src/acpica/source/include/acconvert.h > @@ -0,0 +1,276 @@ > +/****************************************************************************** > + * > + * Module Name: acapps - common include for ACPI applications/tools > + * > + *****************************************************************************/ > + > +/****************************************************************************** > + * > + * 1. Copyright Notice > + * > + * Some or all of this work - Copyright (c) 1999 - 2017, Intel Corp. > + * All rights reserved. > + * > + * 2. License > + * > + * 2.1. This is your license from Intel Corp. under its intellectual property > + * rights. You may have additional license terms from the party that provided > + * you this software, covering your right to use that party's intellectual > + * property rights. > + * > + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a > + * copy of the source code appearing in this file ("Covered Code") an > + * irrevocable, perpetual, worldwide license under Intel's copyrights in the > + * base code distributed originally by Intel ("Original Intel Code") to copy, > + * make derivatives, distribute, use and display any portion of the Covered > + * Code in any form, with the right to sublicense such rights; and > + * > + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent > + * license (with the right to sublicense), under only those claims of Intel > + * patents that are infringed by the Original Intel Code, to make, use, sell, > + * offer to sell, and import the Covered Code and derivative works thereof > + * solely to the minimum extent necessary to exercise the above copyright > + * license, and in no event shall the patent license extend to any additions > + * to or modifications of the Original Intel Code. No other license or right > + * is granted directly or by implication, estoppel or otherwise; > + * > + * The above copyright and patent license is granted only if the following > + * conditions are met: > + * > + * 3. Conditions > + * > + * 3.1. Redistribution of Source with Rights to Further Distribute Source. > + * Redistribution of source code of any substantial portion of the Covered > + * Code or modification with rights to further distribute source must include > + * the above Copyright Notice, the above License, this list of Conditions, > + * and the following Disclaimer and Export Compliance provision. In addition, > + * Licensee must cause all Covered Code to which Licensee contributes to > + * contain a file documenting the changes Licensee made to create that Covered > + * Code and the date of any change. Licensee must include in that file the > + * documentation of any changes made by any predecessor Licensee. Licensee > + * must include a prominent statement that the modification is derived, > + * directly or indirectly, from Original Intel Code. > + * > + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. > + * Redistribution of source code of any substantial portion of the Covered > + * Code or modification without rights to further distribute source must > + * include the following Disclaimer and Export Compliance provision in the > + * documentation and/or other materials provided with distribution. In > + * addition, Licensee may not authorize further sublicense of source of any > + * portion of the Covered Code, and must include terms to the effect that the > + * license from Licensee to its licensee is limited to the intellectual > + * property embodied in the software Licensee provides to its licensee, and > + * not to intellectual property embodied in modifications its licensee may > + * make. > + * > + * 3.3. Redistribution of Executable. Redistribution in executable form of any > + * substantial portion of the Covered Code or modification must reproduce the > + * above Copyright Notice, and the following Disclaimer and Export Compliance > + * provision in the documentation and/or other materials provided with the > + * distribution. > + * > + * 3.4. Intel retains all right, title, and interest in and to the Original > + * Intel Code. > + * > + * 3.5. Neither the name Intel nor any other trademark owned or controlled by > + * Intel shall be used in advertising or otherwise to promote the sale, use or > + * other dealings in products derived from or relating to the Covered Code > + * without prior written authorization from Intel. > + * > + * 4. Disclaimer and Export Compliance > + * > + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED > + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE > + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, > + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY > + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY > + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A > + * PARTICULAR PURPOSE. > + * > + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES > + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR > + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, > + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY > + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL > + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS > + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY > + * LIMITED REMEDY. > + * > + * 4.3. Licensee shall not export, either directly or indirectly, any of this > + * software or system incorporating such software without first obtaining any > + * required license or other approval from the U. S. Department of Commerce or > + * any other agency or department of the United States Government. In the > + * event Licensee exports any such software from the United States or > + * re-exports any such software from a foreign destination, Licensee shall > + * ensure that the distribution and export/re-export of the software is in > + * compliance with all laws, regulations, orders, or other restrictions of the > + * U.S. Export Administration Regulations. Licensee agrees that neither it nor > + * any of its subsidiaries will export/re-export any technical data, process, > + * software, or service, directly or indirectly, to any country for which the > + * United States government or any agency thereof requires an export license, > + * other governmental approval, or letter of assurance, without first obtaining > + * such license, approval or letter. > + * > + *****************************************************************************/ > + > +#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/src/acpica/source/include/acdisasm.h b/src/acpica/source/include/acdisasm.h > index 05cc91d..27354e7 100644 > --- a/src/acpica/source/include/acdisasm.h > +++ b/src/acpica/source/include/acdisasm.h > @@ -875,6 +875,11 @@ AcpiDmEmitExternals ( > void); > > void > +AcpiDmEmitExternal ( > + ACPI_PARSE_OBJECT *NameOp, > + ACPI_PARSE_OBJECT *TypeOp); > + > +void > AcpiDmUnresolvedWarning ( > UINT8 Type); > > @@ -1169,4 +1174,13 @@ ACPI_STATUS > AdDisplayStatistics ( > void); > > + > +/* > + * dmwalk > + */ > +UINT32 > +AcpiDmBlockType ( > + ACPI_PARSE_OBJECT *Op); > + > + > #endif /* __ACDISASM_H__ */ > diff --git a/src/acpica/source/include/acglobal.h b/src/acpica/source/include/acglobal.h > index b586cff..47b34f5 100644 > --- a/src/acpica/source/include/acglobal.h > +++ b/src/acpica/source/include/acglobal.h > @@ -446,6 +446,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/src/acpica/source/include/aclocal.h b/src/acpica/source/include/aclocal.h > index ce7322c..ab3277f 100644 > --- a/src/acpica/source/include/aclocal.h > +++ b/src/acpica/source/include/aclocal.h > @@ -126,7 +126,7 @@ typedef UINT32 ACPI_MUTEX_HANDLE; > > /* Total number of aml opcodes defined */ > > -#define AML_NUM_OPCODES 0x82 > +#define AML_NUM_OPCODES 0x83 > > > /* Forward declarations */ > @@ -978,21 +978,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 */ > @@ -1009,9 +1043,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) > @@ -1047,6 +1118,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]; > @@ -1079,6 +1152,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/src/acpica/source/include/acmacros.h b/src/acpica/source/include/acmacros.h > index e8ff04c..d866d14 100644 > --- a/src/acpica/source/include/acmacros.h > +++ b/src/acpica/source/include/acmacros.h > @@ -571,4 +571,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/src/acpica/source/include/acopcode.h b/src/acpica/source/include/acopcode.h > index 6e55301..61d581e 100644 > --- a/src/acpica/source/include/acopcode.h > +++ b/src/acpica/source/include/acopcode.h > @@ -163,6 +163,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) > @@ -297,6 +298,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/src/acpica/source/include/acpixf.h b/src/acpica/source/include/acpixf.h > index 020e572..0ab6fe4 100644 > --- a/src/acpica/source/include/acpixf.h > +++ b/src/acpica/source/include/acpixf.h > @@ -118,7 +118,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/src/acpica/source/include/actbl2.h b/src/acpica/source/include/actbl2.h > index 736efd8..d98c0ee 100644 > --- a/src/acpica/source/include/actbl2.h > +++ b/src/acpica/source/include/actbl2.h > @@ -161,6 +161,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 > /* > @@ -981,6 +982,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/src/acpica/source/include/amlcode.h b/src/acpica/source/include/amlcode.h > index b9aa3af..d03ac0d 100644 > --- a/src/acpica/source/include/amlcode.h > +++ b/src/acpica/source/include/amlcode.h > @@ -120,11 +120,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 > @@ -135,17 +132,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 > @@ -154,7 +149,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 > @@ -165,7 +160,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 > @@ -182,7 +177,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 > @@ -194,18 +189,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 > @@ -214,18 +209,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 > @@ -247,7 +253,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 > @@ -255,15 +261,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 > @@ -316,6 +313,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 > @@ -385,26 +383,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 > @@ -421,7 +412,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 */ > @@ -439,7 +430,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 */ > @@ -465,7 +456,7 @@ > > #define AML_TYPE_METHOD_CALL 0x10 > > -/* Misc */ > +/* Miscellaneous types */ > > #define AML_TYPE_CREATE_FIELD 0x11 > #define AML_TYPE_CREATE_OBJECT 0x12 > @@ -475,7 +466,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 > > Acked-by: Ivan Hu <ivan.hu@canonical.com>
diff --git a/src/acpica/source/common/adisasm.c b/src/acpica/source/common/adisasm.c index 8ff7657..a9518d0 100644 --- a/src/acpica/source/common/adisasm.c +++ b/src/acpica/source/common/adisasm.c @@ -398,6 +398,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)) @@ -547,6 +562,7 @@ AdReparseOneTable ( ACPI_OWNER_ID OwnerId) { ACPI_STATUS Status; + ACPI_COMMENT_ADDR_NODE *AddrListHead; fprintf (stderr, @@ -580,6 +596,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/src/acpica/source/common/adwalk.c b/src/acpica/source/common/adwalk.c index a9dd65e..34f77a9 100644 --- a/src/acpica/source/common/adwalk.c +++ b/src/acpica/source/common/adwalk.c @@ -950,7 +950,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/src/acpica/source/common/dmextern.c b/src/acpica/source/common/dmextern.c index 206916e..5f28ad0 100644 --- a/src/acpica/source/common/dmextern.c +++ b/src/acpica/source/common/dmextern.c @@ -1237,6 +1237,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/src/acpica/source/common/dmtables.c b/src/acpica/source/common/dmtables.c index 554e6df..3082f28 100644 --- a/src/acpica/source/common/dmtables.c +++ b/src/acpica/source/common/dmtables.c @@ -119,6 +119,8 @@ #include "actables.h" #include "acparser.h" #include "acapps.h" +#include "acmacros.h" +#include "acconvert.h" #define _COMPONENT ACPI_TOOLS @@ -274,6 +276,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 @@ -460,6 +470,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 */ @@ -469,6 +480,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/src/acpica/source/common/dmtbinfo.c b/src/acpica/source/common/dmtbinfo.c index 041327f..7d11370 100644 --- a/src/acpica/source/common/dmtbinfo.c +++ b/src/acpica/source/common/dmtbinfo.c @@ -243,6 +243,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) @@ -331,6 +332,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) @@ -1621,8 +1623,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/src/acpica/source/compiler/Makefile.am b/src/acpica/source/compiler/Makefile.am index a9bcf5c..ba5fe77 100644 --- a/src/acpica/source/compiler/Makefile.am +++ b/src/acpica/source/compiler/Makefile.am @@ -128,6 +128,9 @@ libfwtsiasl_la_SOURCES = \ aslprepkg.c \ aslprintf.c \ aslprune.c \ + cvcompiler.c \ + cvdisasm.c \ + cvparser.c \ dtfield.c \ dtio.c \ dtsubtable.c \ diff --git a/src/acpica/source/compiler/aslcodegen.c b/src/acpica/source/compiler/aslcodegen.c index 0764e78..95ed656 100644 --- a/src/acpica/source/compiler/aslcodegen.c +++ b/src/acpica/source/compiler/aslcodegen.c @@ -116,6 +116,7 @@ #include "aslcompiler.h" #include "aslcompiler.y.h" #include "amlcode.h" +#include "acconvert.h" #define _COMPONENT ACPI_COMPILER ACPI_MODULE_NAME ("aslcodegen") @@ -129,12 +130,6 @@ CgAmlWriteWalk ( void *Context); static void -CgLocalWriteAmlData ( - ACPI_PARSE_OBJECT *Op, - void *Buffer, - UINT32 Length); - -static void CgWriteAmlOpcode ( ACPI_PARSE_OBJECT *Op); @@ -278,7 +273,7 @@ CgAmlWriteWalk ( * ******************************************************************************/ -static void +void CgLocalWriteAmlData ( ACPI_PARSE_OBJECT *Op, void *Buffer, @@ -333,6 +328,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: @@ -488,6 +492,8 @@ CgWriteTableHeader ( ACPI_PARSE_OBJECT *Op) { ACPI_PARSE_OBJECT *Child; + UINT32 CommentLength; + ACPI_COMMENT_NODE *Current; /* AML filename */ @@ -497,6 +503,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 */ @@ -538,6 +559,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); @@ -564,13 +629,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 */ @@ -652,6 +717,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 */ @@ -713,6 +784,10 @@ CgWriteNode ( case PARSEOP_DEFINITION_BLOCK: CgWriteTableHeader (Op); + if (Gbl_CaptureComments) + { + CgWriteAmlDefBlockComment (Op); + } break; case PARSEOP_NAMESEG: diff --git a/src/acpica/source/compiler/aslcompile.c b/src/acpica/source/compiler/aslcompile.c index e601ede..9a83d59 100644 --- a/src/acpica/source/compiler/aslcompile.c +++ b/src/acpica/source/compiler/aslcompile.c @@ -357,8 +357,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); } @@ -419,6 +428,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"); @@ -872,7 +893,11 @@ CmCleanupAndExit ( /* Final cleanup after compiling one file */ - CmDeleteCaches (); + if (!Gbl_DoAslConversion) + { + CmDeleteCaches (); + } + } diff --git a/src/acpica/source/compiler/aslcompiler.h b/src/acpica/source/compiler/aslcompiler.h index dc6f649..841d4f0 100644 --- a/src/acpica/source/compiler/aslcompiler.h +++ b/src/acpica/source/compiler/aslcompiler.h @@ -648,6 +648,12 @@ void CgGenerateAmlOutput ( void); +void +CgLocalWriteAmlData ( + ACPI_PARSE_OBJECT *Op, + void *Buffer, + UINT32 Length); + /* * aslfile @@ -1431,4 +1437,14 @@ ACPI_STATUS DtCreateTemplates ( char **argv); + +/* + * ASL/ASL+ converter debug + */ +void +CvDbgPrint ( + char *Fmt, + ...); + + #endif /* __ASLCOMPILER_H */ diff --git a/src/acpica/source/compiler/aslcompiler.l b/src/acpica/source/compiler/aslcompiler.l index e4592aa..9d84dba 100644 --- a/src/acpica/source/compiler/aslcompiler.l +++ b/src/acpica/source/compiler/aslcompiler.l @@ -116,6 +116,7 @@ #include "aslcompiler.h" #include "aslcompiler.y.h" +#include "acconvert.h" #include <stdlib.h> #include <string.h> @@ -138,10 +139,10 @@ YYSTYPE AslCompilerlval; static void AslDoLineDirective (void); -static char +static BOOLEAN AslDoComment (void); -static char +static BOOLEAN AslDoCommentType2 (void); static char diff --git a/src/acpica/source/compiler/asldebug.c b/src/acpica/source/compiler/asldebug.c index 84eefbf..b50ad6b 100644 --- a/src/acpica/source/compiler/asldebug.c +++ b/src/acpica/source/compiler/asldebug.c @@ -132,6 +132,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/src/acpica/source/compiler/asldefine.h b/src/acpica/source/compiler/asldefine.h index 8c47087..b527eba 100644 --- a/src/acpica/source/compiler/asldefine.h +++ b/src/acpica/source/compiler/asldefine.h @@ -231,7 +231,6 @@ /* * Macros for debug output */ - #define DEBUG_MAX_LINE_LENGTH 61 #define DEBUG_SPACES_PER_INDENT 3 #define DEBUG_FULL_LINE_LENGTH 71 @@ -257,4 +256,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/src/acpica/source/compiler/aslfiles.c b/src/acpica/source/compiler/aslfiles.c index ea9ba54..e53a212 100644 --- a/src/acpica/source/compiler/aslfiles.c +++ b/src/acpica/source/compiler/aslfiles.c @@ -583,8 +583,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, @@ -926,6 +932,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/src/acpica/source/compiler/aslglobal.h b/src/acpica/source/compiler/aslglobal.h index da706bd..9e8fa7f 100644 --- a/src/acpica/source/compiler/aslglobal.h +++ b/src/acpica/source/compiler/aslglobal.h @@ -156,7 +156,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 @@ -185,7 +186,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 @@ -254,6 +255,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 @@ -337,6 +341,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/src/acpica/source/compiler/asllength.c b/src/acpica/source/compiler/asllength.c index fc7ed50..4c15cfa 100644 --- a/src/acpica/source/compiler/asllength.c +++ b/src/acpica/source/compiler/asllength.c @@ -116,6 +116,7 @@ #include "aslcompiler.h" #include "aslcompiler.y.h" #include "amlcode.h" +#include "acconvert.h" #define _COMPONENT ACPI_COMPILER @@ -208,7 +209,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/src/acpica/source/compiler/aslmap.c b/src/acpica/source/compiler/aslmap.c index 7d45fd3..96e54a6 100644 --- a/src/acpica/source/compiler/aslmap.c +++ b/src/acpica/source/compiler/aslmap.c @@ -238,7 +238,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), @@ -248,12 +248,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), @@ -333,14 +333,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), @@ -353,7 +353,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), @@ -419,7 +419,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), @@ -484,8 +484,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), @@ -500,7 +500,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/src/acpica/source/compiler/asloffset.c b/src/acpica/source/compiler/asloffset.c index 3dac50d..6105f8c 100644 --- a/src/acpica/source/compiler/asloffset.c +++ b/src/acpica/source/compiler/asloffset.c @@ -257,7 +257,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/src/acpica/source/compiler/asloperands.c b/src/acpica/source/compiler/asloperands.c index 9d6a9cd..7806dcc 100644 --- a/src/acpica/source/compiler/asloperands.c +++ b/src/acpica/source/compiler/asloperands.c @@ -393,7 +393,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 @@ -424,7 +424,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 @@ -1144,7 +1145,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/src/acpica/source/compiler/aslprimaries.y b/src/acpica/source/compiler/aslprimaries.y index 9e8d711..bc39c51 100644 --- a/src/acpica/source/compiler/aslprimaries.y +++ b/src/acpica/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 * *****************************************************************************/ @@ -218,9 +220,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 @@ -475,8 +477,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;} @@ -617,16 +620,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;} @@ -850,17 +853,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/src/acpica/source/compiler/aslprintf.c b/src/acpica/source/compiler/aslprintf.c index 7c53e0a..87611a0 100644 --- a/src/acpica/source/compiler/aslprintf.c +++ b/src/acpica/source/compiler/aslprintf.c @@ -426,7 +426,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/src/acpica/source/compiler/aslresources.y b/src/acpica/source/compiler/aslresources.y index c88e9c9..2926b07 100644 --- a/src/acpica/source/compiler/aslresources.y +++ b/src/acpica/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 * *****************************************************************************/ @@ -128,14 +130,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/src/acpica/source/compiler/aslrules.y b/src/acpica/source/compiler/aslrules.y index c6a6413..d55b729 100644 --- a/src/acpica/source/compiler/aslrules.y +++ b/src/acpica/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 * *****************************************************************************/ @@ -154,14 +156,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);} ; @@ -249,9 +251,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/src/acpica/source/compiler/aslstartup.c b/src/acpica/source/compiler/aslstartup.c index 37f7641..e7bf33f 100644 --- a/src/acpica/source/compiler/aslstartup.c +++ b/src/acpica/source/compiler/aslstartup.c @@ -117,6 +117,7 @@ #include "actables.h" #include "acdisasm.h" #include "acapps.h" +#include "acconvert.h" #define _COMPONENT ACPI_COMPILER ACPI_MODULE_NAME ("aslstartup") @@ -195,6 +196,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; + } } @@ -522,6 +532,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/src/acpica/source/compiler/aslsupport.l b/src/acpica/source/compiler/aslsupport.l index cc5cf52..e877edf 100644 --- a/src/acpica/source/compiler/aslsupport.l +++ b/src/acpica/source/compiler/aslsupport.l @@ -124,21 +124,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); +} /******************************************************************************* @@ -361,6 +352,10 @@ AslPushInputFileStack ( Gbl_CurrentLineNumber = 1; yyin = InputFile; + + /* converter: reset the comment state to STANDARD_COMMENT */ + + Gbl_CommentState.CommentType = STANDARD_COMMENT; } @@ -464,6 +459,11 @@ AslInsertLineBuffer ( AslResetCurrentLineBuffer (); } + + if (Gbl_CaptureComments) + { + CvProcessCommentState (SourceChar); + } } } @@ -531,16 +531,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: @@ -549,6 +559,11 @@ loop: while (((c = input ()) != '*') && (c != EOF)) { AslInsertLineBuffer (c); + if (Gbl_CaptureComments && CurrentState.CaptureComments) + { + *StringBuffer = c; + ++StringBuffer; + } c1 = c; } @@ -572,10 +587,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; } @@ -583,8 +603,13 @@ loop: { goto EarlyEOF; } + if (StringBuffer > EndBuffer) + { + goto BufferOverflow; + } AslInsertLineBuffer (c1); + CvProcessComment (CurrentState, StringBuffer, c1); return (TRUE); @@ -597,6 +622,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); + } @@ -608,23 +645,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) @@ -634,8 +688,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/src/acpica/source/compiler/asltree.c b/src/acpica/source/compiler/asltree.c index c2230c3..d707ef4 100644 --- a/src/acpica/source/compiler/asltree.c +++ b/src/acpica/source/compiler/asltree.c @@ -116,6 +116,7 @@ #include "aslcompiler.h" #include "aslcompiler.y.h" #include "acapps.h" +#include "acconvert.h" #include <time.h> #define _COMPONENT ACPI_COMPILER @@ -212,6 +213,7 @@ TrAllocateNode ( UINT32 ParseOpcode) { ACPI_PARSE_OBJECT *Op; + ACPI_PARSE_OBJECT *LatestNode; Op = TrGetNextNode (); @@ -224,6 +226,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); } @@ -366,6 +444,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); } @@ -1132,6 +1217,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 */ @@ -1145,6 +1263,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 @@ -1169,9 +1299,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 * @@ -1233,6 +1363,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; @@ -1296,6 +1445,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); } @@ -1463,6 +1619,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/src/acpica/source/compiler/asltypes.h b/src/acpica/source/compiler/asltypes.h index d04c692..2b4773e 100644 --- a/src/acpica/source/compiler/asltypes.h +++ b/src/acpica/source/compiler/asltypes.h @@ -225,6 +225,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 { @@ -245,12 +249,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 */ @@ -271,6 +277,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 */ @@ -408,4 +416,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/src/acpica/source/compiler/aslwalks.c b/src/acpica/source/compiler/aslwalks.c index 574b8e2..6eaca9f 100644 --- a/src/acpica/source/compiler/aslwalks.c +++ b/src/acpica/source/compiler/aslwalks.c @@ -389,7 +389,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/src/acpica/source/compiler/cvcompiler.c b/src/acpica/source/compiler/cvcompiler.c new file mode 100644 index 0000000..28af25a --- /dev/null +++ b/src/acpica/source/compiler/cvcompiler.c @@ -0,0 +1,962 @@ +/****************************************************************************** + * + * Module Name: cvcompiler - ASL-/ASL+ converter functions + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2017, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#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/src/acpica/source/compiler/cvdisasm.c b/src/acpica/source/compiler/cvdisasm.c new file mode 100644 index 0000000..e588e1f --- /dev/null +++ b/src/acpica/source/compiler/cvdisasm.c @@ -0,0 +1,495 @@ +/****************************************************************************** + * + * Module Name: cvcompiler - ASL-/ASL+ converter functions + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2017, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#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/src/acpica/source/compiler/cvparser.c b/src/acpica/source/compiler/cvparser.c new file mode 100644 index 0000000..57486f4 --- /dev/null +++ b/src/acpica/source/compiler/cvparser.c @@ -0,0 +1,959 @@ +/****************************************************************************** + * + * Module Name: cvparser - Converter functions that are called from the AML + * parser. + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2017, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#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/src/acpica/source/compiler/dttable1.c b/src/acpica/source/compiler/dttable1.c index 7552d5b..7c5860c 100644 --- a/src/acpica/source/compiler/dttable1.c +++ b/src/acpica/source/compiler/dttable1.c @@ -1590,6 +1590,10 @@ DtCompileIort ( } IortNode->MappingCount = IdMappingNumber; + if (!IdMappingNumber) + { + IortNode->MappingOffset = 0; + } /* * Node length can be determined by DT_LENGTH option diff --git a/src/acpica/source/compiler/dttemplate.h b/src/acpica/source/compiler/dttemplate.h index 9c85d94..59175d7 100644 --- a/src/acpica/source/compiler/dttemplate.h +++ b/src/acpica/source/compiler/dttemplate.h @@ -615,47 +615,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/src/acpica/source/components/debugger/dbmethod.c b/src/acpica/source/components/debugger/dbmethod.c index 60df51a..aba9134 100644 --- a/src/acpica/source/components/debugger/dbmethod.c +++ b/src/acpica/source/components/debugger/dbmethod.c @@ -551,6 +551,7 @@ AcpiDbWalkForExecute ( Status = AcpiGetObjectInfo (ObjHandle, &ObjInfo); if (ACPI_FAILURE (Status)) { + ACPI_FREE (Pathname); return (Status); } diff --git a/src/acpica/source/components/debugger/dbxface.c b/src/acpica/source/components/debugger/dbxface.c index 46eb6da..97261a1 100644 --- a/src/acpica/source/components/debugger/dbxface.c +++ b/src/acpica/source/components/debugger/dbxface.c @@ -117,6 +117,7 @@ #include "accommon.h" #include "amlcode.h" #include "acdebug.h" +#include "acinterp.h" #define _COMPONENT ACPI_CA_DEBUGGER @@ -209,7 +210,7 @@ ErrorExit: * * RETURN: Status * - * DESCRIPTION: Called for AML_BREAK_POINT_OP + * DESCRIPTION: Called for AML_BREAKPOINT_OP * ******************************************************************************/ @@ -476,7 +477,9 @@ AcpiDbSingleStep ( } + AcpiExExitInterpreter (); Status = AcpiDbStartCommand (WalkState, Op); + AcpiExEnterInterpreter (); /* User commands complete, continue execution of the interrupted method */ diff --git a/src/acpica/source/components/disassembler/dmcstyle.c b/src/acpica/source/components/disassembler/dmcstyle.c index 5b2f827..76e0a3a 100644 --- a/src/acpica/source/components/disassembler/dmcstyle.c +++ b/src/acpica/source/components/disassembler/dmcstyle.c @@ -118,6 +118,7 @@ #include "acparser.h" #include "amlcode.h" #include "acdebug.h" +#include "acconvert.h" #define _COMPONENT ACPI_CA_DEBUGGER @@ -243,27 +244,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 @@ -271,15 +272,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; @@ -315,7 +316,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); @@ -546,11 +547,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 ("("); @@ -797,12 +798,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; } @@ -820,16 +823,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; } @@ -849,15 +853,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: @@ -867,6 +873,9 @@ AcpiDmCloseOperator ( } AcpiOsPrintf (")"); + ASL_CV_PRINT_ONE_COMMENT (Op, AML_COMMENT_END_NODE, NULL, 0); + + return; } diff --git a/src/acpica/source/components/disassembler/dmdeferred.c b/src/acpica/source/components/disassembler/dmdeferred.c index b83a415..1d1d0e8 100644 --- a/src/acpica/source/components/disassembler/dmdeferred.c +++ b/src/acpica/source/components/disassembler/dmdeferred.c @@ -175,7 +175,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); @@ -289,7 +289,7 @@ AcpiDmDeferredParse ( { case AML_BUFFER_OP: case AML_PACKAGE_OP: - case AML_VAR_PACKAGE_OP: + case AML_VARIABLE_PACKAGE_OP: switch (Op->Common.AmlOpcode) { @@ -300,7 +300,7 @@ AcpiDmDeferredParse ( ACPI_FREE (ExtraOp); break; - case AML_VAR_PACKAGE_OP: + case AML_VARIABLE_PACKAGE_OP: case AML_BUFFER_OP: default: diff --git a/src/acpica/source/components/disassembler/dmnames.c b/src/acpica/source/components/disassembler/dmnames.c index cd4445b..916d592 100644 --- a/src/acpica/source/components/disassembler/dmnames.c +++ b/src/acpica/source/components/disassembler/dmnames.c @@ -316,7 +316,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/src/acpica/source/components/disassembler/dmopcode.c b/src/acpica/source/components/disassembler/dmopcode.c index fb924f2..17e726d 100644 --- a/src/acpica/source/components/disassembler/dmopcode.c +++ b/src/acpica/source/components/disassembler/dmopcode.c @@ -120,6 +120,7 @@ #include "acinterp.h" #include "acnamesp.h" #include "acdebug.h" +#include "acconvert.h" #define _COMPONENT ACPI_CA_DEBUGGER @@ -142,7 +143,8 @@ AcpiDmPromoteSubtree ( static BOOLEAN AcpiDmIsSwitchBlock ( - ACPI_PARSE_OBJECT *Op); + ACPI_PARSE_OBJECT *Op, + char *Temp); static BOOLEAN AcpiDmIsCaseBlock ( @@ -788,15 +790,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; @@ -819,12 +821,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; @@ -953,8 +955,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; @@ -995,6 +1001,7 @@ AcpiDmDisassembleOneOp ( AcpiOsPrintf (")"); AcpiDmCommaIfFieldMember (Op); + ASL_CV_PRINT_ONE_COMMENT (Op, AML_COMMENT_END_NODE, NULL, 0); break; case AML_INT_CONNECTION_OP: @@ -1028,6 +1035,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 */ @@ -1049,7 +1058,7 @@ AcpiDmDisassembleOneOp ( case AML_WHILE_OP: - if (AcpiDmIsSwitchBlock(Op)) + if (Op->Common.DisasmOpcode == ACPI_DASM_SWITCH) { AcpiOsPrintf ("%s", "Switch"); break; @@ -1078,15 +1087,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 */ @@ -1327,11 +1334,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. * ******************************************************************************/ @@ -1339,6 +1348,7 @@ BOOLEAN AcpiDmIsTempName ( ACPI_PARSE_OBJECT *Op) { + ACPI_PARSE_OBJECT *CurrentOp; char *Temp; if (Op->Common.AmlOpcode != AML_NAME_OP) @@ -1354,11 +1364,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); } /******************************************************************************* @@ -1394,7 +1414,8 @@ AcpiDmIsTempName ( static BOOLEAN AcpiDmIsSwitchBlock ( - ACPI_PARSE_OBJECT *Op) + ACPI_PARSE_OBJECT *Op, + char *Temp) { ACPI_PARSE_OBJECT *OneOp; ACPI_PARSE_OBJECT *StoreOp; @@ -1427,7 +1448,7 @@ AcpiDmIsSwitchBlock ( return (FALSE); } - if (strncmp((char *)(NamePathOp->Common.Aml), "_T_", 3)) + if (strncmp((char *)(NamePathOp->Common.Aml), Temp, 4)) { return (FALSE); } @@ -1483,7 +1504,7 @@ AcpiDmIsSwitchBlock ( TempOp = AcpiPsGetArg (CurrentOp, 0); switch (TempOp->Common.AmlOpcode) { - case (AML_LEQUAL_OP): + case (AML_LOGICAL_EQUAL_OP): /* Ignore just the LEqual Op */ @@ -1505,7 +1526,7 @@ AcpiDmIsSwitchBlock ( break; - case (AML_LNOT_OP): + case (AML_LOGICAL_NOT_OP): /* * The Package will be the predicate of the Case statement. @@ -1660,7 +1681,7 @@ AcpiDmIsCaseBlock ( switch (CurrentOp->Common.AmlOpcode) { - case (AML_LEQUAL_OP): + case (AML_LOGICAL_EQUAL_OP): /* Next child must be NamePath with string _T_ */ @@ -1673,12 +1694,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/src/acpica/source/components/disassembler/dmutils.c b/src/acpica/source/components/disassembler/dmutils.c index 2f4a343..33c8b5c 100644 --- a/src/acpica/source/components/disassembler/dmutils.c +++ b/src/acpica/source/components/disassembler/dmutils.c @@ -117,6 +117,7 @@ #include "accommon.h" #include "amlcode.h" #include "acdisasm.h" +#include "acconvert.h" #ifdef ACPI_ASL_COMPILER #include <acnamesp.h> @@ -322,6 +323,7 @@ AcpiDmCommaIfListMember ( if (!Op->Common.Next) { + ASL_CV_PRINT_ONE_COMMENT (Op, AMLCOMMENT_INLINE, NULL, 0); return (FALSE); } @@ -331,6 +333,7 @@ AcpiDmCommaIfListMember ( if (Op->Common.Next->Common.DisasmFlags & ACPI_PARSEOP_IGNORE) { + ASL_CV_PRINT_ONE_COMMENT (Op, AMLCOMMENT_INLINE, NULL, 0); return (FALSE); } @@ -347,6 +350,7 @@ AcpiDmCommaIfListMember ( */ if (!Op->Common.Next->Common.Next) { + ASL_CV_PRINT_ONE_COMMENT (Op, AMLCOMMENT_INLINE, NULL, 0); return (FALSE); } } @@ -354,6 +358,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); } @@ -362,6 +367,7 @@ AcpiDmCommaIfListMember ( if (!Op->Common.OperatorSymbol) { AcpiOsPrintf (", "); + ASL_CV_PRINT_ONE_COMMENT (Op, AMLCOMMENT_INLINE, NULL, 0); } return (TRUE); @@ -371,6 +377,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/src/acpica/source/components/disassembler/dmwalk.c b/src/acpica/source/components/disassembler/dmwalk.c index fa681d7..3c17b8c 100644 --- a/src/acpica/source/components/disassembler/dmwalk.c +++ b/src/acpica/source/components/disassembler/dmwalk.c @@ -118,6 +118,7 @@ #include "acparser.h" #include "amlcode.h" #include "acdebug.h" +#include "acconvert.h" #define _COMPONENT ACPI_CA_DEBUGGER @@ -135,6 +136,14 @@ AcpiDmEmitExternals ( { return; } + +void +AcpiDmEmitExternal ( + ACPI_PARSE_OBJECT *NameOp, + ACPI_PARSE_OBJECT *TypeOp) +{ + return; +} #endif /* Local prototypes */ @@ -151,10 +160,6 @@ AcpiDmAscendingOp ( UINT32 Level, void *Context); -static UINT32 -AcpiDmBlockType ( - ACPI_PARSE_OBJECT *Op); - /******************************************************************************* * @@ -320,7 +325,7 @@ AcpiDmWalkParseTree ( * ******************************************************************************/ -static UINT32 +UINT32 AcpiDmBlockType ( ACPI_PARSE_OBJECT *Op) { @@ -342,7 +347,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: @@ -364,7 +369,7 @@ AcpiDmBlockType ( /*lint -fallthrough */ case AML_PACKAGE_OP: - case AML_VAR_PACKAGE_OP: + case AML_VARIABLE_PACKAGE_OP: return (BLOCK_PAREN | BLOCK_BRACE); @@ -376,7 +381,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 */ @@ -429,7 +434,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: @@ -442,7 +447,7 @@ AcpiDmListType ( case AML_BUFFER_OP: case AML_PACKAGE_OP: - case AML_VAR_PACKAGE_OP: + case AML_VARIABLE_PACKAGE_OP: return (BLOCK_COMMA_LIST); @@ -486,6 +491,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 */ @@ -600,7 +621,11 @@ AcpiDmDescendingOp ( /* Emit all External() declarations here */ - AcpiDmEmitExternals (); + if (!AcpiGbl_DmEmitExternalOpcodes) + { + AcpiDmEmitExternals (); + } + return (AE_OK); } } @@ -679,6 +704,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) || @@ -689,6 +720,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 */ @@ -733,7 +768,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 */ @@ -746,6 +781,7 @@ AcpiDmDescendingOp ( AcpiDmCheckForHardwareId (Op); AcpiOsPrintf (", "); + ASL_CV_PRINT_ONE_COMMENT (Op, AML_NAMECOMMENT, NULL, 0); break; case AML_REGION_OP: @@ -753,7 +789,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 */ @@ -795,7 +831,7 @@ AcpiDmDescendingOp ( case AML_DEVICE_OP: case AML_THERMAL_ZONE_OP: - AcpiOsPrintf (")"); + ASL_CV_CLOSE_PAREN (Op, Level); break; default: @@ -889,7 +925,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 */ @@ -907,7 +943,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 */ @@ -975,6 +1011,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) { @@ -987,7 +1037,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); } @@ -1048,12 +1108,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); @@ -1103,7 +1163,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)) { @@ -1143,7 +1203,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 @@ -1170,7 +1230,8 @@ AcpiDmAscendingOp ( else { ParentOp->Common.DisasmFlags |= ACPI_PARSEOP_EMPTY_TERMLIST; - AcpiOsPrintf (") {"); + ASL_CV_CLOSE_PAREN (Op, Level); + AcpiOsPrintf ("{"); } } diff --git a/src/acpica/source/components/dispatcher/dscontrol.c b/src/acpica/source/components/dispatcher/dscontrol.c index bfbd4b1..777a270 100644 --- a/src/acpica/source/components/dispatcher/dscontrol.c +++ b/src/acpica/source/components/dispatcher/dscontrol.c @@ -430,7 +430,7 @@ AcpiDsExecEndControlOp ( break; - case AML_BREAK_POINT_OP: + case AML_BREAKPOINT_OP: AcpiDbSignalBreakPoint (WalkState); diff --git a/src/acpica/source/components/dispatcher/dsmthdat.c b/src/acpica/source/components/dispatcher/dsmthdat.c index 18763e5..539438f 100644 --- a/src/acpica/source/components/dispatcher/dsmthdat.c +++ b/src/acpica/source/components/dispatcher/dsmthdat.c @@ -800,7 +800,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/src/acpica/source/components/dispatcher/dsobject.c b/src/acpica/source/components/dispatcher/dsobject.c index 6cdb335..d0dee77 100644 --- a/src/acpica/source/components/dispatcher/dsobject.c +++ b/src/acpica/source/components/dispatcher/dsobject.c @@ -185,7 +185,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 @@ -214,7 +214,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 @@ -483,7 +483,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; } @@ -867,9 +867,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 @@ -882,9 +882,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/src/acpica/source/components/dispatcher/dsopcode.c b/src/acpica/source/components/dispatcher/dsopcode.c index d2d5d8b..254d43e 100644 --- a/src/acpica/source/components/dispatcher/dsopcode.c +++ b/src/acpica/source/components/dispatcher/dsopcode.c @@ -753,7 +753,7 @@ AcpiDsEvalDataObjectOperands ( break; case AML_PACKAGE_OP: - case AML_VAR_PACKAGE_OP: + case AML_VARIABLE_PACKAGE_OP: Status = AcpiDsBuildInternalPackageObj ( WalkState, Op, Length, &ObjDesc); @@ -773,7 +773,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/src/acpica/source/components/dispatcher/dsutils.c b/src/acpica/source/components/dispatcher/dsutils.c index 0dd2c57..5de1d89 100644 --- a/src/acpica/source/components/dispatcher/dsutils.c +++ b/src/acpica/source/components/dispatcher/dsutils.c @@ -369,8 +369,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)) { @@ -661,7 +661,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 @@ -942,7 +942,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/src/acpica/source/components/dispatcher/dswexec.c b/src/acpica/source/components/dispatcher/dswexec.c index 6d8421f..716e1e6 100644 --- a/src/acpica/source/components/dispatcher/dswexec.c +++ b/src/acpica/source/components/dispatcher/dswexec.c @@ -608,7 +608,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/src/acpica/source/components/dispatcher/dswload2.c b/src/acpica/source/components/dispatcher/dswload2.c index 6cc32ee..0a4f9fc 100644 --- a/src/acpica/source/components/dispatcher/dswload2.c +++ b/src/acpica/source/components/dispatcher/dswload2.c @@ -615,7 +615,7 @@ AcpiDsLoad2EndOp ( Status = AcpiExCreateProcessor (WalkState); break; - case AML_POWER_RES_OP: + case AML_POWER_RESOURCE_OP: Status = AcpiExCreatePowerResource (WalkState); break; diff --git a/src/acpica/source/components/executer/exmisc.c b/src/acpica/source/components/executer/exmisc.c index e12a9b1..d888e76 100644 --- a/src/acpica/source/components/executer/exmisc.c +++ b/src/acpica/source/components/executer/exmisc.c @@ -347,7 +347,7 @@ AcpiExDoLogicalNumericOp ( switch (Opcode) { - case AML_LAND_OP: /* LAnd (Integer0, Integer1) */ + case AML_LOGICAL_AND_OP: /* LAnd (Integer0, Integer1) */ if (Integer0 && Integer1) { @@ -355,7 +355,7 @@ AcpiExDoLogicalNumericOp ( } break; - case AML_LOR_OP: /* LOr (Integer0, Integer1) */ + case AML_LOGICAL_OR_OP: /* LOr (Integer0, Integer1) */ if (Integer0 || Integer1) { @@ -473,7 +473,7 @@ AcpiExDoLogicalOp ( switch (Opcode) { - case AML_LEQUAL_OP: /* LEqual (Operand0, Operand1) */ + case AML_LOGICAL_EQUAL_OP: /* LEqual (Operand0, Operand1) */ if (Integer0 == Integer1) { @@ -481,7 +481,7 @@ AcpiExDoLogicalOp ( } break; - case AML_LGREATER_OP: /* LGreater (Operand0, Operand1) */ + case AML_LOGICAL_GREATER_OP: /* LGreater (Operand0, Operand1) */ if (Integer0 > Integer1) { @@ -489,7 +489,7 @@ AcpiExDoLogicalOp ( } break; - case AML_LLESS_OP: /* LLess (Operand0, Operand1) */ + case AML_LOGICAL_LESS_OP: /* LLess (Operand0, Operand1) */ if (Integer0 < Integer1) { @@ -522,7 +522,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 */ @@ -535,7 +535,7 @@ AcpiExDoLogicalOp ( } break; - case AML_LGREATER_OP: /* LGreater (Operand0, Operand1) */ + case AML_LOGICAL_GREATER_OP: /* LGreater (Operand0, Operand1) */ if (Compare > 0) { @@ -555,7 +555,7 @@ AcpiExDoLogicalOp ( } break; - case AML_LLESS_OP: /* LLess (Operand0, Operand1) */ + case AML_LOGICAL_LESS_OP: /* LLess (Operand0, Operand1) */ if (Compare > 0) { diff --git a/src/acpica/source/components/executer/exnames.c b/src/acpica/source/components/executer/exnames.c index 705862b..9d33b0b 100644 --- a/src/acpica/source/components/executer/exnames.c +++ b/src/acpica/source/components/executer/exnames.c @@ -213,7 +213,7 @@ AcpiExAllocateNameString ( { /* Set up multi prefixes */ - *TempPtr++ = AML_MULTI_NAME_PREFIX_OP; + *TempPtr++ = AML_MULTI_NAME_PREFIX; *TempPtr++ = (char) NumNameSegs; } else if (2 == NumNameSegs) @@ -457,7 +457,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/src/acpica/source/components/executer/exoparg1.c b/src/acpica/source/components/executer/exoparg1.c index 800be70..cbe2eb4 100644 --- a/src/acpica/source/components/executer/exoparg1.c +++ b/src/acpica/source/components/executer/exoparg1.c @@ -376,7 +376,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 */ @@ -507,7 +507,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 @@ -579,13 +579,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); @@ -597,7 +597,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); @@ -712,7 +712,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) @@ -763,7 +763,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/src/acpica/source/components/executer/exoparg2.c b/src/acpica/source/components/executer/exoparg2.c index 2daf8c1..b3806cc 100644 --- a/src/acpica/source/components/executer/exoparg2.c +++ b/src/acpica/source/components/executer/exoparg2.c @@ -402,7 +402,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); @@ -448,7 +448,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/src/acpica/source/components/executer/exoparg6.c b/src/acpica/source/components/executer/exoparg6.c index 4f9f99b..816b197 100644 --- a/src/acpica/source/components/executer/exoparg6.c +++ b/src/acpica/source/components/executer/exoparg6.c @@ -206,7 +206,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); @@ -219,7 +219,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); @@ -233,7 +233,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); @@ -246,7 +246,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); @@ -260,7 +260,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/src/acpica/source/components/executer/exresolv.c b/src/acpica/source/components/executer/exresolv.c index 758c286..f51fc8c 100644 --- a/src/acpica/source/components/executer/exresolv.c +++ b/src/acpica/source/components/executer/exresolv.c @@ -282,7 +282,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/src/acpica/source/components/executer/exstore.c b/src/acpica/source/components/executer/exstore.c index 76f6629..884342d 100644 --- a/src/acpica/source/components/executer/exstore.c +++ b/src/acpica/source/components/executer/exstore.c @@ -507,7 +507,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 @@ -593,7 +593,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/src/acpica/source/components/executer/exstoren.c b/src/acpica/source/components/executer/exstoren.c index 200ef8c..6b4fd33 100644 --- a/src/acpica/source/components/executer/exstoren.c +++ b/src/acpica/source/components/executer/exstoren.c @@ -185,7 +185,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/src/acpica/source/components/hardware/hwvalid.c b/src/acpica/source/components/hardware/hwvalid.c index 8405468..c1a1063 100644 --- a/src/acpica/source/components/hardware/hwvalid.c +++ b/src/acpica/source/components/hardware/hwvalid.c @@ -179,7 +179,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) /****************************************************************************** @@ -209,7 +209,7 @@ AcpiHwValidateIoRequest ( const ACPI_PORT_INFO *PortInfo; - ACPI_FUNCTION_TRACE (HwValidateIoRequest); + ACPI_FUNCTION_NAME (HwValidateIoRequest); /* Supported widths are 8/16/32 */ @@ -238,14 +238,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 */ @@ -254,7 +254,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 @@ -284,7 +284,7 @@ AcpiHwValidateIoRequest ( } } - return_ACPI_STATUS (AE_OK); + return (AE_OK); } @@ -293,7 +293,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 @@ -339,7 +339,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) { @@ -413,7 +413,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/src/acpica/source/components/namespace/nsaccess.c b/src/acpica/source/components/namespace/nsaccess.c index 949e7bd..8463cc3 100644 --- a/src/acpica/source/components/namespace/nsaccess.c +++ b/src/acpica/source/components/namespace/nsaccess.c @@ -577,7 +577,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/src/acpica/source/components/namespace/nsrepair.c b/src/acpica/source/components/namespace/nsrepair.c index 14f4095..4b0c59b 100644 --- a/src/acpica/source/components/namespace/nsrepair.c +++ b/src/acpica/source/components/namespace/nsrepair.c @@ -374,24 +374,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/src/acpica/source/components/namespace/nsrepair2.c b/src/acpica/source/components/namespace/nsrepair2.c index 2e36b89..241a4b0 100644 --- a/src/acpica/source/components/namespace/nsrepair2.c +++ b/src/acpica/source/components/namespace/nsrepair2.c @@ -520,16 +520,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/src/acpica/source/components/namespace/nsutils.c b/src/acpica/source/components/namespace/nsutils.c index 601bc2e..5bdcc63 100644 --- a/src/acpica/source/components/namespace/nsutils.c +++ b/src/acpica/source/components/namespace/nsutils.c @@ -366,7 +366,7 @@ AcpiNsBuildInternalName ( } else { - InternalName[1] = AML_MULTI_NAME_PREFIX_OP; + InternalName[1] = AML_MULTI_NAME_PREFIX; InternalName[2] = (char) NumSegments; Result = &InternalName[3]; } @@ -397,7 +397,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]; } @@ -606,7 +606,7 @@ AcpiNsExternalizeName ( { switch (InternalName[PrefixLength]) { - case AML_MULTI_NAME_PREFIX_OP: + case AML_MULTI_NAME_PREFIX: /* <count> 4-byte names */ @@ -766,28 +766,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/src/acpica/source/components/parser/psargs.c b/src/acpica/source/components/parser/psargs.c index df7f6d2..7e893f7 100644 --- a/src/acpica/source/components/parser/psargs.c +++ b/src/acpica/source/components/parser/psargs.c @@ -119,6 +119,7 @@ #include "amlcode.h" #include "acnamesp.h" #include "acdispat.h" +#include "acconvert.h" #define _COMPONENT ACPI_PARSER ACPI_MODULE_NAME ("psargs") @@ -280,7 +281,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 */ @@ -441,7 +442,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; } @@ -453,7 +454,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; } @@ -615,6 +616,7 @@ AcpiPsGetNextField ( ACPI_FUNCTION_TRACE (PsGetNextField); + ASL_CV_CAPTURE_COMMENTS_ONLY (ParserState); Aml = ParserState->Aml; /* Determine field type */ @@ -661,6 +663,7 @@ AcpiPsGetNextField ( /* Decode the field type */ + ASL_CV_CAPTURE_COMMENTS_ONLY (ParserState); switch (Opcode) { case AML_INT_NAMEDFIELD_OP: @@ -671,6 +674,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); @@ -727,10 +747,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 */ @@ -747,6 +769,7 @@ AcpiPsGetNextField ( Opcode = ACPI_GET8 (ParserState->Aml); ParserState->Aml++; + ASL_CV_CAPTURE_COMMENTS_ONLY (ParserState); switch (Opcode) { case AML_BYTE_OP: /* AML_BYTEDATA_ARG */ @@ -775,6 +798,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/src/acpica/source/components/parser/psloop.c b/src/acpica/source/components/parser/psloop.c index 4f51573..de55004 100644 --- a/src/acpica/source/components/parser/psloop.c +++ b/src/acpica/source/components/parser/psloop.c @@ -127,6 +127,7 @@ #include "acparser.h" #include "acdispat.h" #include "amlcode.h" +#include "acconvert.h" #define _COMPONENT ACPI_PARSER ACPI_MODULE_NAME ("psloop") @@ -214,6 +215,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)) @@ -321,7 +338,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) && @@ -559,6 +576,8 @@ AcpiPsParseLoop ( while ((ParserState->Aml < ParserState->AmlEnd) || (Op)) { + ASL_CV_CAPTURE_COMMENTS (WalkState); + AmlOpStart = ParserState->Aml; if (!Op) { @@ -592,12 +611,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/src/acpica/source/components/parser/psobject.c b/src/acpica/source/components/parser/psobject.c index 49f11f3..7d54dca 100644 --- a/src/acpica/source/components/parser/psobject.c +++ b/src/acpica/source/components/parser/psobject.c @@ -117,6 +117,7 @@ #include "accommon.h" #include "acparser.h" #include "amlcode.h" +#include "acconvert.h" #define _COMPONENT ACPI_PARSER ACPI_MODULE_NAME ("psobject") @@ -273,6 +274,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)) @@ -284,6 +286,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 */ @@ -329,6 +343,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/src/acpica/source/components/parser/psopcode.c b/src/acpica/source/components/parser/psopcode.c index f7176a7..95988fb 100644 --- a/src/acpica/source/components/parser/psopcode.c +++ b/src/acpica/source/components/parser/psopcode.c @@ -144,7 +144,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 @@ -170,7 +170,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 @@ -188,7 +188,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 @@ -211,7 +211,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 @@ -224,7 +224,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 @@ -409,7 +409,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/src/acpica/source/components/parser/psopinfo.c b/src/acpica/source/components/parser/psopinfo.c index 5245351..e04649b 100644 --- a/src/acpica/source/components/parser/psopinfo.c +++ b/src/acpica/source/components/parser/psopinfo.c @@ -314,7 +314,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/src/acpica/source/components/parser/psparse.c b/src/acpica/source/components/parser/psparse.c index ba92d3e..f0385e0 100644 --- a/src/acpica/source/components/parser/psparse.c +++ b/src/acpica/source/components/parser/psparse.c @@ -186,7 +186,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 */ @@ -290,7 +290,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); @@ -304,7 +304,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/src/acpica/source/components/parser/pstree.c b/src/acpica/source/components/parser/pstree.c index d987d65..2334a7d 100644 --- a/src/acpica/source/components/parser/pstree.c +++ b/src/acpica/source/components/parser/pstree.c @@ -117,6 +117,7 @@ #include "accommon.h" #include "acparser.h" #include "amlcode.h" +#include "acconvert.h" #define _COMPONENT ACPI_PARSER ACPI_MODULE_NAME ("pstree") @@ -314,6 +315,7 @@ AcpiPsGetDepthNext ( Next = AcpiPsGetArg (Op, 0); if (Next) { + ASL_CV_LABEL_FILENODE (Next); return (Next); } @@ -322,6 +324,7 @@ AcpiPsGetDepthNext ( Next = Op->Common.Next; if (Next) { + ASL_CV_LABEL_FILENODE (Next); return (Next); } @@ -334,6 +337,8 @@ AcpiPsGetDepthNext ( Arg = AcpiPsGetArg (Parent, 0); while (Arg && (Arg != Origin) && (Arg != Op)) { + + ASL_CV_LABEL_FILENODE (Arg); Arg = Arg->Common.Next; } @@ -348,6 +353,7 @@ AcpiPsGetDepthNext ( { /* Found sibling of parent */ + ASL_CV_LABEL_FILENODE (Parent->Common.Next); return (Parent->Common.Next); } @@ -355,6 +361,7 @@ AcpiPsGetDepthNext ( Parent = Parent->Common.Parent; } + ASL_CV_LABEL_FILENODE (Next); return (Next); } @@ -403,7 +410,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/src/acpica/source/components/parser/psutils.c b/src/acpica/source/components/parser/psutils.c index 5eec90b..fc9005a 100644 --- a/src/acpica/source/components/parser/psutils.c +++ b/src/acpica/source/components/parser/psutils.c @@ -117,6 +117,7 @@ #include "accommon.h" #include "acparser.h" #include "amlcode.h" +#include "acconvert.h" #define _COMPONENT ACPI_PARSER ACPI_MODULE_NAME ("psutils") @@ -249,6 +250,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); @@ -275,6 +287,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/src/acpica/source/components/utilities/utalloc.c b/src/acpica/source/components/utilities/utalloc.c index ce194d4..4d035eb 100644 --- a/src/acpica/source/components/utilities/utalloc.c +++ b/src/acpica/source/components/utilities/utalloc.c @@ -216,6 +216,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 @@ -282,6 +316,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/src/acpica/source/components/utilities/utcache.c b/src/acpica/source/components/utilities/utcache.c index 93a6c70..e9df612 100644 --- a/src/acpica/source/components/utilities/utcache.c +++ b/src/acpica/source/components/utilities/utcache.c @@ -149,7 +149,7 @@ AcpiOsCreateCache ( ACPI_FUNCTION_ENTRY (); - if (!CacheName || !ReturnCache || (ObjectSize < 16)) + if (!CacheName || !ReturnCache || !ObjectSize) { return (AE_BAD_PARAMETER); } diff --git a/src/acpica/source/components/utilities/utdebug.c b/src/acpica/source/components/utilities/utdebug.c index 3faa6b2..c78ae96 100644 --- a/src/acpica/source/components/utilities/utdebug.c +++ b/src/acpica/source/components/utilities/utdebug.c @@ -779,4 +779,5 @@ AcpiTracePoint ( ACPI_EXPORT_SYMBOL (AcpiTracePoint) + #endif diff --git a/src/acpica/source/components/utilities/utresrc.c b/src/acpica/source/components/utilities/utresrc.c index d26b15c..c08e9c7 100644 --- a/src/acpica/source/components/utilities/utresrc.c +++ b/src/acpica/source/components/utilities/utresrc.c @@ -598,6 +598,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/src/acpica/source/components/utilities/utxferror.c b/src/acpica/source/components/utilities/utxferror.c index b660bb0..0ce7195 100644 --- a/src/acpica/source/components/utilities/utxferror.c +++ b/src/acpica/source/components/utilities/utxferror.c @@ -173,7 +173,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 @@ -224,8 +224,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 @@ -262,17 +262,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 @@ -340,8 +336,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/src/acpica/source/include/acconfig.h b/src/acpica/source/include/acconfig.h index cd5533c..7f069f9 100644 --- a/src/acpica/source/include/acconfig.h +++ b/src/acpica/source/include/acconfig.h @@ -151,6 +151,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/src/acpica/source/include/acconvert.h b/src/acpica/source/include/acconvert.h new file mode 100644 index 0000000..f7fd873 --- /dev/null +++ b/src/acpica/source/include/acconvert.h @@ -0,0 +1,276 @@ +/****************************************************************************** + * + * Module Name: acapps - common include for ACPI applications/tools + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2017, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#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/src/acpica/source/include/acdisasm.h b/src/acpica/source/include/acdisasm.h index 05cc91d..27354e7 100644 --- a/src/acpica/source/include/acdisasm.h +++ b/src/acpica/source/include/acdisasm.h @@ -875,6 +875,11 @@ AcpiDmEmitExternals ( void); void +AcpiDmEmitExternal ( + ACPI_PARSE_OBJECT *NameOp, + ACPI_PARSE_OBJECT *TypeOp); + +void AcpiDmUnresolvedWarning ( UINT8 Type); @@ -1169,4 +1174,13 @@ ACPI_STATUS AdDisplayStatistics ( void); + +/* + * dmwalk + */ +UINT32 +AcpiDmBlockType ( + ACPI_PARSE_OBJECT *Op); + + #endif /* __ACDISASM_H__ */ diff --git a/src/acpica/source/include/acglobal.h b/src/acpica/source/include/acglobal.h index b586cff..47b34f5 100644 --- a/src/acpica/source/include/acglobal.h +++ b/src/acpica/source/include/acglobal.h @@ -446,6 +446,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/src/acpica/source/include/aclocal.h b/src/acpica/source/include/aclocal.h index ce7322c..ab3277f 100644 --- a/src/acpica/source/include/aclocal.h +++ b/src/acpica/source/include/aclocal.h @@ -126,7 +126,7 @@ typedef UINT32 ACPI_MUTEX_HANDLE; /* Total number of aml opcodes defined */ -#define AML_NUM_OPCODES 0x82 +#define AML_NUM_OPCODES 0x83 /* Forward declarations */ @@ -978,21 +978,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 */ @@ -1009,9 +1043,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) @@ -1047,6 +1118,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]; @@ -1079,6 +1152,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/src/acpica/source/include/acmacros.h b/src/acpica/source/include/acmacros.h index e8ff04c..d866d14 100644 --- a/src/acpica/source/include/acmacros.h +++ b/src/acpica/source/include/acmacros.h @@ -571,4 +571,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/src/acpica/source/include/acopcode.h b/src/acpica/source/include/acopcode.h index 6e55301..61d581e 100644 --- a/src/acpica/source/include/acopcode.h +++ b/src/acpica/source/include/acopcode.h @@ -163,6 +163,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) @@ -297,6 +298,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/src/acpica/source/include/acpixf.h b/src/acpica/source/include/acpixf.h index 020e572..0ab6fe4 100644 --- a/src/acpica/source/include/acpixf.h +++ b/src/acpica/source/include/acpixf.h @@ -118,7 +118,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/src/acpica/source/include/actbl2.h b/src/acpica/source/include/actbl2.h index 736efd8..d98c0ee 100644 --- a/src/acpica/source/include/actbl2.h +++ b/src/acpica/source/include/actbl2.h @@ -161,6 +161,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 /* @@ -981,6 +982,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/src/acpica/source/include/amlcode.h b/src/acpica/source/include/amlcode.h index b9aa3af..d03ac0d 100644 --- a/src/acpica/source/include/amlcode.h +++ b/src/acpica/source/include/amlcode.h @@ -120,11 +120,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 @@ -135,17 +132,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 @@ -154,7 +149,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 @@ -165,7 +160,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 @@ -182,7 +177,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 @@ -194,18 +189,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 @@ -214,18 +209,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 @@ -247,7 +253,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 @@ -255,15 +261,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 @@ -316,6 +313,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 @@ -385,26 +383,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 @@ -421,7 +412,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 */ @@ -439,7 +430,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 */ @@ -465,7 +456,7 @@ #define AML_TYPE_METHOD_CALL 0x10 -/* Misc */ +/* Miscellaneous types */ #define AML_TYPE_CREATE_FIELD 0x11 #define AML_TYPE_CREATE_OBJECT 0x12 @@ -475,7 +466,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