From c49657baf0302b429680dc204071f879b62281a7 Mon Sep 17 00:00:00 2001 From: Al Stone Date: Mar 19 2016 21:43:17 +0000 Subject: Imported Upstream version 20160318 --- diff --git a/changes.txt b/changes.txt index c9eaa64..d797ded 100644 --- a/changes.txt +++ b/changes.txt @@ -1,7 +1,83 @@ ---------------------------------------- -12 February 2016. Summary of changes for version 20160212: +18 March 2016. Summary of changes for version 20160318: -This release is available at https://acpica.org/downloads +1) ACPICA kernel-resident subsystem: + +Added support for arbitrary bit lengths and bit offsets for registers +defined by the Generic Address Structure. Previously, only aligned bit +lengths of 8/16/32/64 were supported. This was sufficient for many years, +but recently some machines have been seen that require arbitrary bit- +level support. ACPICA BZ 1240. Lv Zheng. + +Fixed an issue where the \_SB._INI method sometimes must be evaluated +before any _REG methods are evaluated. Lv Zheng. + +Implemented several changes related to ACPI table support +(Headers/Disassembler/TableCompiler): +NFIT: For ACPI 6.1, updated to add some additional new fields and +constants. +FADT: Updated a warning message and set compliance to ACPI 6.1 (Version +6). +DMAR: Added new constants per the 10/2014 DMAR spec. +IORT: Added new subtable per the 10/2015 IORT spec. +HEST: For ACPI 6.1, added new constants and new subtable. +DBG2: Added new constants per the 12/2015 DBG2 spec. +FPDT: Fixed several incorrect fields, add the FPDT boot record structure. +ACPICA BZ 1249. +ERST/EINJ: Updated disassembler with new "Execute Timings" actions. + +Updated header support for the DMAR table to match the current version of +the related spec. + +Added extensions to the ASL Concatenate operator to allow any ACPI object +to be passed as an operand. Any object other than Integer/String/Buffer +simply returns a string containing the object type. This extends the +usefulness of the Printf macros. Previously, Concatenate would abort the +control method if a non-data object was encountered. + +ACPICA source code: Deployed the C "const" keyword across the source code +where appropriate. ACPICA BZ 732. Joerg Sonnenberger (NetBSD). + +Example Code and Data Size: These are the sizes for the OS-independent +acpica.lib produced by the Microsoft Visual C++ 9.0 32-bit compiler. The +debug version of the code includes the debug output trace mechanism and +has a much larger code and data size. + + Current Release: + Non-Debug Version: 137.1K Code, 51.5K Data, 188.6K Total + Debug Version: 201.0K Code, 82.0K Data, 283.0K Total + Previous Release: + Non-Debug Version: 136.2K Code, 51.5K Data, 187.7K Total + Debug Version: 200.4K Code, 82.0K Data, 282.4K Total + + +2) iASL Compiler/Disassembler and Tools: + +iASL/Disassembler: Improved the heuristic used to determine the number of +arguments for an externally defined control method (a method in another +table). Although this is an improvement, there is no deterministic way to +"guess" the number of method arguments. Only the ACPI 6.0 External opcode +will completely solve this problem as it is deployed (automatically) in +newer BIOS code. + +iASL/Disassembler: Fixed an ordering issue for emitted External() ASL +statements that could cause errors when the disassembled file is +compiled. ACPICA BZ 1243. David Box. + +iASL: Fixed a regression caused by the merger of the two versions of the +local strtoul64. Because of a dependency on a global variable, strtoul64 +could return an error for integers greater than a 32-bit value. ACPICA BZ +1260. + +iASL: Fixed a regression where a fault could occur for an ASL Return +statement if it invokes a control method that is not resolved. ACPICA BZ +1264. + +AcpiXtract: Improved input file validation: detection of binary files and +non-acpidump text files. + +---------------------------------------- +12 February 2016. Summary of changes for version 20160212: 1) ACPICA kernel-resident subsystem: diff --git a/generate/unix/Makefile.common b/generate/unix/Makefile.common index fe5e46b..cc6a101 100644 --- a/generate/unix/Makefile.common +++ b/generate/unix/Makefile.common @@ -9,8 +9,12 @@ ifeq ($(HOST), _FreeBSD) HARDWARE_NAME := $(shell uname -p) else +ifeq ($(HOST), _QNX) +HARDWARE_NAME := x86pc +else HARDWARE_NAME := $(shell uname -m) endif +endif # # Main rule will only generate versions that are appropriate for the running diff --git a/generate/unix/Makefile.config b/generate/unix/Makefile.config index 3137821..da0f61d 100644 --- a/generate/unix/Makefile.config +++ b/generate/unix/Makefile.config @@ -67,6 +67,10 @@ ifeq ($(UNAME_S), NetBSD) HOST = _NetBSD endif +ifeq ($(UNAME_S), QNX) +HOST = _QNX +endif + ifeq ($(HOST), _APPLE) INSTALL = cp INSTALLFLAGS ?= -f @@ -163,6 +167,14 @@ CFLAGS += \ -D$(HOST)\ -D_GNU_SOURCE\ -I$(ACPICA_INCLUDE) + +# +# QNX requires __EXT to enable most functions in its C library, analogous +# to _GNU_SOURCE. +# +ifeq ($(HOST), _QNX) + CFLAGS+=-D__EXT +endif # # Common compiler warning flags. The warning flags in addition diff --git a/generate/unix/acpidump/Makefile b/generate/unix/acpidump/Makefile index 313ad15..67e7e94 100644 --- a/generate/unix/acpidump/Makefile +++ b/generate/unix/acpidump/Makefile @@ -64,6 +64,10 @@ ifeq ($(HOST), _NetBSD) HOST_FAMILY = BSD endif +ifeq ($(HOST), _QNX) +HOST_FAMILY = BSD +endif + ifeq ($(HOST_FAMILY), BSD) OBJECTS += \ $(OBJDIR)/osbsdtbl.o diff --git a/generate/unix/acpiexamples/Makefile b/generate/unix/acpiexamples/Makefile index 7d9daf3..f40c11b 100644 --- a/generate/unix/acpiexamples/Makefile +++ b/generate/unix/acpiexamples/Makefile @@ -59,6 +59,7 @@ OBJECTS = \ $(OBJDIR)/evrgnini.o\ $(OBJDIR)/evxface.o\ $(OBJDIR)/evxfregn.o\ + $(OBJDIR)/exconcat.o\ $(OBJDIR)/exconfig.o\ $(OBJDIR)/exconvrt.o\ $(OBJDIR)/excreate.o\ diff --git a/generate/unix/acpiexec/Makefile b/generate/unix/acpiexec/Makefile index 384089c..e473664 100644 --- a/generate/unix/acpiexec/Makefile +++ b/generate/unix/acpiexec/Makefile @@ -106,6 +106,7 @@ OBJECTS = \ $(OBJDIR)/evxfgpe.o\ $(OBJDIR)/evxfregn.o\ $(OBJDIR)/exconfig.o\ + $(OBJDIR)/exconcat.o\ $(OBJDIR)/exconvrt.o\ $(OBJDIR)/excreate.o\ $(OBJDIR)/exdebug.o\ @@ -245,11 +246,15 @@ CFLAGS += \ -DACPI_CHECKSUM_ABORT=TRUE endif +ifneq ($(HOST),_QNX) LDFLAGS += -lpthread +endif ifneq ($(HOST),_APPLE) +ifneq ($(HOST),_QNX) LDFLAGS += -lrt endif +endif # # Common Rules diff --git a/generate/unix/iasl/Makefile b/generate/unix/iasl/Makefile index ed4ed2d..36c93d5 100644 --- a/generate/unix/iasl/Makefile +++ b/generate/unix/iasl/Makefile @@ -96,6 +96,7 @@ OBJECTS = \ $(OBJDIR)/aslrestype2w.o\ $(OBJDIR)/aslstartup.o\ $(OBJDIR)/aslstubs.o\ + $(OBJDIR)/aslpld.o\ $(OBJDIR)/asltransform.o\ $(OBJDIR)/asltree.o\ $(OBJDIR)/aslutils.o\ @@ -143,6 +144,7 @@ OBJECTS = \ $(OBJDIR)/dttable2.o\ $(OBJDIR)/dttemplate.o\ $(OBJDIR)/dtutils.o\ + $(OBJDIR)/exconcat.o\ $(OBJDIR)/exconvrt.o\ $(OBJDIR)/excreate.o\ $(OBJDIR)/exdump.o\ diff --git a/source/common/adwalk.c b/source/common/adwalk.c index 28255c6..714d837 100644 --- a/source/common/adwalk.c +++ b/source/common/adwalk.c @@ -327,6 +327,7 @@ AcpiDmConvertResourceIndexes ( WalkState); if (ACPI_FAILURE (Status)) { + ACPI_FREE (WalkState); return; } @@ -442,7 +443,7 @@ AcpiDmDumpDescending ( * * DESCRIPTION: Check namepath Ops for orphaned method invocations * - * Note: Experimental. + * Note: Parts of this are experimental, under possible further development. * ******************************************************************************/ @@ -508,6 +509,7 @@ AcpiDmFindOrphanDescending ( ChildOp->Common.Value.String, ACPI_TYPE_METHOD, ArgCount, 0); } break; + #endif case AML_STORE_OP: @@ -532,7 +534,7 @@ AcpiDmFindOrphanDescending ( /* One Arg means this is just a Store(Name,Target) */ AcpiDmAddOpToExternalList (ChildOp, - ChildOp->Common.Value.String, ACPI_TYPE_INTEGER, 0, 0); + ChildOp->Common.Value.String, ACPI_TYPE_INTEGER, ArgCount, 0); return (AE_OK); } @@ -554,7 +556,7 @@ AcpiDmFindOrphanDescending ( (ParentOp->Common.AmlOpcode != AML_INT_METHODCALL_OP) && !Op->Common.Node) { - ArgCount = AcpiDmInspectPossibleArgs (0, 0, Op->Common.Next); + ArgCount = AcpiDmInspectPossibleArgs (0, 0, Op); /* * Check if namepath is a predicate for if/while or lone parameter to @@ -788,6 +790,7 @@ AcpiDmXrefDescendingOp ( Op->Common.Next->Common.Next->Common.Value.Integer; } + Flags |= ACPI_EXT_RESOLVED_REFERENCE | ACPI_EXT_ORIGIN_FROM_OPCODE; AcpiDmAddOpToExternalList (Op, Path, (UINT8) ObjectType, ParamCount, Flags); @@ -855,12 +858,12 @@ AcpiDmXrefDescendingOp ( Status = AcpiNsLookup (WalkState->ScopeInfo, Path, ACPI_TYPE_ANY, ACPI_IMODE_EXECUTE, ACPI_NS_SEARCH_PARENT | ACPI_NS_DONT_OPEN_SCOPE, WalkState, &Node); + if (ACPI_SUCCESS (Status) && (Node->Flags & ANOBJ_IS_EXTERNAL)) { /* Node was created by an External() statement */ Status = AE_NOT_FOUND; - Flags = ACPI_EXT_RESOLVED_REFERENCE; } if (ACPI_FAILURE (Status)) @@ -880,12 +883,12 @@ AcpiDmXrefDescendingOp ( if (Node) { AcpiDmAddNodeToExternalList (Node, - (UINT8) ObjectType, 0, Flags); + (UINT8) ObjectType, 7, Flags); } else { AcpiDmAddOpToExternalList (Op, Path, - (UINT8) ObjectType, 0, Flags); + (UINT8) ObjectType, 7, Flags); } } } @@ -1067,40 +1070,69 @@ AcpiDmInspectPossibleArgs ( { const ACPI_OPCODE_INFO *OpInfo; UINT32 i; - UINT32 Last = 0; - UINT32 Lookahead; + UINT32 ArgumentCount = 0; + ACPI_PARSE_OBJECT *NextOp; + ACPI_PARSE_OBJECT *ExecuteOp; - Lookahead = (ACPI_METHOD_NUM_ARGS + TargetCount) - CurrentOpArgCount; + if (!Op) + { + return (0); + } /* Lookahead for the maximum number of possible arguments */ - for (i = 0; i < Lookahead; i++) + NextOp = Op->Common.Next; + + for (i = 0; (i < ACPI_METHOD_NUM_ARGS) && NextOp; i++) { - if (!Op) - { - break; - } + OpInfo = AcpiPsGetOpcodeInfo (NextOp->Common.AmlOpcode); - OpInfo = AcpiPsGetOpcodeInfo (Op->Common.AmlOpcode); + /* Any one of these operators is "very probably" not a method arg */ - /* - * Any one of these operators is "very probably" not a method arg - */ - if ((Op->Common.AmlOpcode == AML_STORE_OP) || - (Op->Common.AmlOpcode == AML_NOTIFY_OP)) + if ((NextOp->Common.AmlOpcode == AML_STORE_OP) || + (NextOp->Common.AmlOpcode == AML_NOTIFY_OP) || + (OpInfo->Class == AML_CLASS_CONTROL) || + (OpInfo->Class == AML_CLASS_CREATE) || + (OpInfo->Class == AML_CLASS_NAMED_OBJECT)) { break; } - if ((OpInfo->Class != AML_CLASS_EXECUTE) && - (OpInfo->Class != AML_CLASS_CONTROL)) + if (OpInfo->Class == AML_CLASS_EXECUTE) { - Last = i+1; + /* Probable that this is method arg if there is no target */ + + ExecuteOp = NextOp->Common.Value.Arg; + while (ExecuteOp) + { + if ((ExecuteOp->Common.AmlOpcode == AML_INT_NAMEPATH_OP) && + (ExecuteOp->Common.Value.Arg == NULL)) + { + /* No target, could be a method arg */ + + break; + } + + if (NextOp->Common.AmlOpcode == AML_REF_OF_OP) + { + break; + } + + ExecuteOp = ExecuteOp->Common.Next; + } + + if (!ExecuteOp) + { + /* Has a target, not method arg */ + + return (ArgumentCount); + } } - Op = Op->Common.Next; + ArgumentCount++; + NextOp = NextOp->Common.Next; } - return (Last); + return (ArgumentCount); } diff --git a/source/common/dmextern.c b/source/common/dmextern.c index bb44b88..924c42f 100644 --- a/source/common/dmextern.c +++ b/source/common/dmextern.c @@ -754,46 +754,6 @@ AcpiDmAddPathToExternalList ( /******************************************************************************* * - * FUNCTION: AcpiDmEternalIsMatch - * - * PARAMETERS: NamePath - Path to match to External Name - * ExternalPath - External NamePath to be matched - * - * RETURN: BOOLEAN - * - * DESCRIPTION: Returns TRUE if NamePath matches the last NamePath-length - * characters of ExternalPath. - * - * External (_SB_.DEV0.ABCD) will match: - * _SB_.DEV0.ABCD - * DEV0.ABCD - * ABCD - * - ******************************************************************************/ - -static BOOLEAN -AcpiDmExternalIsMatch ( - const char * NamePath, - const char * ListNamePath) -{ - BOOLEAN Match = FALSE; - - - if (strlen (ListNamePath) >= strlen (NamePath)) - { - if (!strcmp (ListNamePath + - (strlen (ListNamePath) - strlen (NamePath)), NamePath)) - { - return (TRUE); - } - } - - return (Match); -} - - -/******************************************************************************* - * * FUNCTION: AcpiDmCreateNewExternal * * PARAMETERS: ExternalPath - External path to the object @@ -850,26 +810,29 @@ AcpiDmCreateNewExternal ( { /* Check for duplicates */ - if (AcpiDmExternalIsMatch (ExternalPath, NextExternal->Path)) + if (!strcmp (ExternalPath, NextExternal->Path)) { - /* Duplicate method, check that the Value (ArgCount) is the same */ - - if ((NextExternal->Type == ACPI_TYPE_METHOD) && - (NextExternal->Flags & ANOBJ_IS_EXTERNAL) && - (NextExternal->Value != Value) && - (Value > 0)) + /* + * If this external came from an External() opcode, we are + * finished with this one. (No need to check any further). + */ + if (NextExternal->Flags & ACPI_EXT_ORIGIN_FROM_OPCODE) { - ACPI_ERROR ((AE_INFO, - "External method arg count mismatch %s: " - "Current %u, attempted %u", - NextExternal->Path, NextExternal->Value, Value)); + return_ACPI_STATUS (AE_ALREADY_EXISTS); } /* Allow upgrade of type from ANY */ - else if (NextExternal->Type == ACPI_TYPE_ANY) + else if ((NextExternal->Type == ACPI_TYPE_ANY) && + (Type != ACPI_TYPE_ANY)) { NextExternal->Type = Type; + } + + /* Update the argument count as necessary */ + + if (Value < NextExternal->Value) + { NextExternal->Value = Value; } @@ -1125,90 +1088,63 @@ AcpiDmEmitExternals ( AcpiDmUnresolvedWarning (1); - /* Emit any unresolved method externals in a single text block */ - - NextExternal = AcpiGbl_ExternalList; - while (NextExternal) - { - if ((NextExternal->Type == ACPI_TYPE_METHOD) && - (!(NextExternal->Flags & ACPI_EXT_RESOLVED_REFERENCE))) - { - AcpiOsPrintf (" External (%s%s", - NextExternal->Path, - AcpiDmGetObjectTypeName (NextExternal->Type)); - - AcpiOsPrintf (") // Warning: Unresolved method, " - "guessing %u arguments\n", - NextExternal->Value); - - NextExternal->Flags |= ACPI_EXT_EXTERNAL_EMITTED; - } - - NextExternal = NextExternal->Next; - } - - AcpiOsPrintf ("\n"); - - - /* Emit externals that were imported from a file */ - if (Gbl_ExternalRefFilename) { AcpiOsPrintf ( - " /*\n * External declarations that were imported from\n" - " * the reference file [%s]\n */\n", + " /*\n * External declarations were imported from\n" + " * a reference file -- %s\n */\n\n", Gbl_ExternalRefFilename); - - NextExternal = AcpiGbl_ExternalList; - while (NextExternal) - { - if (!(NextExternal->Flags & ACPI_EXT_EXTERNAL_EMITTED) && - (NextExternal->Flags & ACPI_EXT_ORIGIN_FROM_FILE)) - { - AcpiOsPrintf (" External (%s%s", - NextExternal->Path, - AcpiDmGetObjectTypeName (NextExternal->Type)); - - if (NextExternal->Type == ACPI_TYPE_METHOD) - { - AcpiOsPrintf (") // %u Arguments\n", - NextExternal->Value); - } - else - { - AcpiOsPrintf (")\n"); - } - NextExternal->Flags |= ACPI_EXT_EXTERNAL_EMITTED; - } - - NextExternal = NextExternal->Next; - } - - AcpiOsPrintf ("\n"); } /* - * Walk the list of externals found during the AML parsing + * Walk and emit the list of externals found during the AML parsing */ while (AcpiGbl_ExternalList) { + AcpiGbl_ExternalList = AcpiGbl_ExternalList; if (!(AcpiGbl_ExternalList->Flags & ACPI_EXT_EXTERNAL_EMITTED)) { - AcpiOsPrintf (" External (%s%s", + AcpiOsPrintf (" External (%s%s)", AcpiGbl_ExternalList->Path, AcpiDmGetObjectTypeName (AcpiGbl_ExternalList->Type)); - /* For methods, add a comment with the number of arguments */ + /* Check for "unresolved" method reference */ - if (AcpiGbl_ExternalList->Type == ACPI_TYPE_METHOD) + if ((AcpiGbl_ExternalList->Type == ACPI_TYPE_METHOD) && + (!(AcpiGbl_ExternalList->Flags & ACPI_EXT_RESOLVED_REFERENCE))) { - AcpiOsPrintf (") // %u Arguments\n", + AcpiOsPrintf (" // Warning: Unknown method, " + "guessing %u arguments", AcpiGbl_ExternalList->Value); } + + /* Check for external from a external references file */ + + else if (AcpiGbl_ExternalList->Flags & ACPI_EXT_ORIGIN_FROM_FILE) + { + if (AcpiGbl_ExternalList->Type == ACPI_TYPE_METHOD) + { + AcpiOsPrintf (" // %u Arguments", + AcpiGbl_ExternalList->Value); + } + + AcpiOsPrintf (" // From external reference file"); + } + + /* This is the normal external case */ + else { - AcpiOsPrintf (")\n"); + /* For methods, add a comment with the number of arguments */ + + if (AcpiGbl_ExternalList->Type == ACPI_TYPE_METHOD) + { + AcpiOsPrintf (" // %u Arguments", + AcpiGbl_ExternalList->Value); + } } + + AcpiOsPrintf ("\n"); } /* Free this external info block and move on to next external */ @@ -1341,15 +1277,17 @@ AcpiDmUnresolvedWarning ( Format = Type ? Pad : NoPad; sprintf (ExternalWarningPart1, - "%s iASL Warning: There were %u external control methods found during\n" + "%s iASL Warning: There %s %u external control method%s found during\n" "%s disassembly, but only %u %s resolved (%u unresolved). Additional\n" "%s ACPI tables may be required to properly disassemble the code. This\n" "%s resulting disassembler output file may not compile because the\n" "%s disassembler did not know how many arguments to assign to the\n" "%s unresolved methods. Note: SSDTs can be dynamically loaded at\n" "%s runtime and may or may not be available via the host OS.\n", - Format, AcpiGbl_NumExternalMethods, Format, AcpiGbl_ResolvedExternalMethods, - (AcpiGbl_ResolvedExternalMethods > 1 ? "were" : "was"), + Format, (AcpiGbl_NumExternalMethods != 1 ? "were" : "was"), + AcpiGbl_NumExternalMethods, (AcpiGbl_NumExternalMethods != 1 ? "s" : ""), + Format, AcpiGbl_ResolvedExternalMethods, + (AcpiGbl_ResolvedExternalMethods != 1 ? "were" : "was"), (AcpiGbl_NumExternalMethods - AcpiGbl_ResolvedExternalMethods), Format, Format, Format, Format, Format); @@ -1391,7 +1329,7 @@ AcpiDmUnresolvedWarning ( { /* The -e option was specified, but there are still some unresolved externals */ - AcpiOsPrintf (" /*\n%s *\n *\n */\n", + AcpiOsPrintf (" /*\n%s *\n%s *\n%s */\n", ExternalWarningPart1, ExternalWarningPart3, ExternalWarningPart4); } } diff --git a/source/common/dmtable.c b/source/common/dmtable.c index 89f6db0..14f0861 100644 --- a/source/common/dmtable.c +++ b/source/common/dmtable.c @@ -118,6 +118,7 @@ static const char *AcpiDmEinjActions[] = "Check Busy Status", "Get Command Status", "Set Error Type With Address", + "Get Execute Timings", "Unknown Action" }; @@ -150,6 +151,7 @@ static const char *AcpiDmErstActions[] = "Get Error Address Range", "Get Error Address Length", "Get Error Attributes", + "Execute Timings", "Unknown Action" }; @@ -209,6 +211,10 @@ static const char *AcpiDmHestNotifySubnames[] = "NMI", "CMCI", /* ACPI 5.0 */ "MCE", /* ACPI 5.0 */ + "GPIO", /* ACPI 6.0 */ + "SEA", /* ACPI 6.1 */ + "SEI", /* ACPI 6.1 */ + "GSIV", /* ACPI 6.1 */ "Unknown Notify Type" /* Reserved */ }; diff --git a/source/common/dmtables.c b/source/common/dmtables.c index 5758b9d..85abfe7 100644 --- a/source/common/dmtables.c +++ b/source/common/dmtables.c @@ -141,7 +141,6 @@ AdCreateTableHeader ( char *Filename, ACPI_TABLE_HEADER *Table) { - char *NewFilename; UINT8 Checksum; @@ -184,11 +183,10 @@ AdCreateTableHeader ( break; } - AcpiOsPrintf ("\n"); /* Print and validate the table checksum */ - AcpiOsPrintf (" * Checksum 0x%2.2X", Table->Checksum); + AcpiOsPrintf ("\n * Checksum 0x%2.2X", Table->Checksum); Checksum = AcpiTbChecksum (ACPI_CAST_PTR (UINT8, Table), Table->Length); if (Checksum) @@ -205,33 +203,16 @@ AdCreateTableHeader ( AcpiOsPrintf (" * Compiler Version 0x%8.8X (%u)\n", Table->AslCompilerRevision, Table->AslCompilerRevision); AcpiOsPrintf (" */\n"); - /* Create AML output filename based on input filename */ - - if (Filename) - { - NewFilename = FlGenerateFilename (Filename, "aml"); - } - else - { - NewFilename = UtStringCacheCalloc (9); - if (NewFilename) - { - strncat (NewFilename, Table->Signature, 4); - strcat (NewFilename, ".aml"); - } - } - - if (!NewFilename) - { - AcpiOsPrintf (" **** Could not generate AML output filename\n"); - return; - } - - /* Open the ASL definition block */ - + /* + * Open the ASL definition block. + * + * Note: the AMLFilename string is left zero-length in order to just let + * the compiler create it when the disassembled file is compiled. This + * makes it easier to rename the disassembled ASL file if needed. + */ AcpiOsPrintf ( - "DefinitionBlock (\"%s\", \"%4.4s\", %hu, \"%.6s\", \"%.8s\", 0x%8.8X)\n", - NewFilename, Table->Signature, Table->Revision, + "DefinitionBlock (\"\", \"%4.4s\", %hu, \"%.6s\", \"%.8s\", 0x%8.8X)\n", + Table->Signature, Table->Revision, Table->OemId, Table->OemTableId, Table->OemRevision); } diff --git a/source/common/dmtbdump.c b/source/common/dmtbdump.c index c6e0c4e..efc383d 100644 --- a/source/common/dmtbdump.c +++ b/source/common/dmtbdump.c @@ -1773,6 +1773,12 @@ AcpiDmDumpIort ( IortSmmu = ACPI_ADD_PTR (ACPI_IORT_SMMU, IortNode, NodeOffset); break; + case ACPI_IORT_NODE_SMMU_V3: + + InfoTable = AcpiDmTableInfoIort4; + Length = IortNode->Length - NodeOffset; + break; + default: AcpiOsPrintf ("\n**** Unknown IORT node type 0x%X\n", @@ -3139,7 +3145,7 @@ AcpiDmDumpS3pt ( { ACPI_STATUS Status; UINT32 Offset = sizeof (ACPI_TABLE_S3PT); - ACPI_S3PT_HEADER *SubTable; + ACPI_FPDT_HEADER *SubTable; ACPI_DMTABLE_INFO *InfoTable; ACPI_TABLE_S3PT *S3ptTable = ACPI_CAST_PTR (ACPI_TABLE_S3PT, Tables); @@ -3152,7 +3158,7 @@ AcpiDmDumpS3pt ( return 0; } - SubTable = ACPI_ADD_PTR (ACPI_S3PT_HEADER, S3ptTable, Offset); + SubTable = ACPI_ADD_PTR (ACPI_FPDT_HEADER, S3ptTable, Offset); while (Offset < S3ptTable->Length) { /* Common subtable header */ @@ -3204,7 +3210,7 @@ NextSubTable: /* Point to next subtable */ Offset += SubTable->Length; - SubTable = ACPI_ADD_PTR (ACPI_S3PT_HEADER, SubTable, SubTable->Length); + SubTable = ACPI_ADD_PTR (ACPI_FPDT_HEADER, SubTable, SubTable->Length); } return (S3ptTable->Length); diff --git a/source/common/dmtbinfo.c b/source/common/dmtbinfo.c index dde36d3..bc9cc3b 100644 --- a/source/common/dmtbinfo.c +++ b/source/common/dmtbinfo.c @@ -150,8 +150,8 @@ #define ACPI_EINJ0_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_WHEA_HEADER,f) #define ACPI_ERST0_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_WHEA_HEADER,f) #define ACPI_FPDTH_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_FPDT_HEADER,f) -#define ACPI_FPDT0_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_FPDT_BOOT,f) -#define ACPI_FPDT1_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_FPDT_S3PT_PTR,f) +#define ACPI_FPDT0_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_FPDT_BOOT_POINTER,f) +#define ACPI_FPDT1_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_FPDT_S3PT_POINTER,f) #define ACPI_GTDT0_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_GTDT_TIMER_BLOCK,f) #define ACPI_GTDT0a_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_GTDT_TIMER_ENTRY,f) #define ACPI_GTDT1_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_GTDT_WATCHDOG,f) @@ -170,6 +170,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_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) #define ACPI_IORTM_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_IORT_ID_MAPPING,f) @@ -222,7 +223,7 @@ #define ACPI_PMTT1A_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_PMTT_DOMAIN,f) #define ACPI_PMTT2_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_PMTT_PHYSICAL_COMPONENT,f) #define ACPI_PMTTH_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_PMTT_HEADER,f) -#define ACPI_S3PTH_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_S3PT_HEADER,f) +#define ACPI_S3PTH_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_FPDT_HEADER,f) #define ACPI_S3PT0_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_S3PT_RESUME,f) #define ACPI_S3PT1_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_S3PT_SUSPEND,f) #define ACPI_SLIC_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_TABLE_SLIC,f) @@ -256,6 +257,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_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) #define ACPI_LPITH_FLAG_OFFSET(f,o) ACPI_FLAG_OFFSET (ACPI_LPIT_HEADER,f,o) @@ -1095,11 +1097,7 @@ ACPI_DMTABLE_INFO AcpiDmTableInfoFpdtHdr[] = ACPI_DMTABLE_INFO AcpiDmTableInfoFpdt0[] = { {ACPI_DMT_UINT32, ACPI_FPDT0_OFFSET (Reserved), "Reserved", 0}, - {ACPI_DMT_UINT64, ACPI_FPDT0_OFFSET (ResetEnd), "Reset End", 0}, - {ACPI_DMT_UINT64, ACPI_FPDT0_OFFSET (LoadStart), "Load Image Start", 0}, - {ACPI_DMT_UINT64, ACPI_FPDT0_OFFSET (StartupStart), "Start Image Start", 0}, - {ACPI_DMT_UINT64, ACPI_FPDT0_OFFSET (ExitServicesEntry), "Exit Services Entry", 0}, - {ACPI_DMT_UINT64, ACPI_FPDT0_OFFSET (ExitServicesExit), "Exit Services Exit", 0}, + {ACPI_DMT_UINT64, ACPI_FPDT1_OFFSET (Address), "FPDT Boot Record Address", 0}, ACPI_DMT_TERMINATOR }; @@ -1108,10 +1106,18 @@ ACPI_DMTABLE_INFO AcpiDmTableInfoFpdt0[] = ACPI_DMTABLE_INFO AcpiDmTableInfoFpdt1[] = { {ACPI_DMT_UINT32, ACPI_FPDT1_OFFSET (Reserved), "Reserved", 0}, - {ACPI_DMT_UINT64, ACPI_FPDT1_OFFSET (Address), "S3PT Address", 0}, + {ACPI_DMT_UINT64, ACPI_FPDT1_OFFSET (Address), "S3PT Record Address", 0}, ACPI_DMT_TERMINATOR }; +#if 0 + /* Boot Performance Record, not supported at this time. */ + {ACPI_DMT_UINT64, ACPI_FPDT0_OFFSET (ResetEnd), "Reset End", 0}, + {ACPI_DMT_UINT64, ACPI_FPDT0_OFFSET (LoadStart), "Load Image Start", 0}, + {ACPI_DMT_UINT64, ACPI_FPDT0_OFFSET (StartupStart), "Start Image Start", 0}, + {ACPI_DMT_UINT64, ACPI_FPDT0_OFFSET (ExitServicesEntry), "Exit Services Entry", 0}, + {ACPI_DMT_UINT64, ACPI_FPDT0_OFFSET (ExitServicesExit), "Exit Services Exit", 0}, +#endif /******************************************************************************* * @@ -1557,6 +1563,23 @@ ACPI_DMTABLE_INFO AcpiDmTableInfoIort3c[] = ACPI_DMT_TERMINATOR }; +/* 0x04: SMMUv3 */ + +ACPI_DMTABLE_INFO AcpiDmTableInfoIort4[] = +{ + {ACPI_DMT_UINT64, ACPI_IORT4_OFFSET (BaseAddress), "Base Address", 0}, + {ACPI_DMT_UINT32, ACPI_IORT4_OFFSET (Flags), "Flags (decoded below)", 0}, + {ACPI_DMT_FLAG0, ACPI_IORT4_FLAG_OFFSET (Flags, 0), "COHACC Override", 0}, + {ACPI_DMT_FLAG1, ACPI_IORT4_FLAG_OFFSET (Flags, 0), "HTTU Override", 0}, + {ACPI_DMT_UINT32, ACPI_IORT4_OFFSET (Reserved), "Reserved", 0}, + {ACPI_DMT_UINT64, ACPI_IORT4_OFFSET (VatosAddress), "VATOS Address", 0}, + {ACPI_DMT_UINT32, ACPI_IORT4_OFFSET (Model), "Model", 0}, + {ACPI_DMT_UINT32, ACPI_IORT4_OFFSET (EventGsiv), "Event GSIV", 0}, + {ACPI_DMT_UINT32, ACPI_IORT4_OFFSET (PriGsiv), "PRI GSIV", 0}, + {ACPI_DMT_UINT32, ACPI_IORT4_OFFSET (GerrGsiv), "GERR GSIV", 0}, + {ACPI_DMT_UINT32, ACPI_IORT4_OFFSET (SyncGsiv), "Sync GSIV", 0}, + ACPI_DMT_TERMINATOR +}; /******************************************************************************* * @@ -2209,7 +2232,10 @@ ACPI_DMTABLE_INFO AcpiDmTableInfoNfit4[] = {ACPI_DMT_UINT16, ACPI_NFIT4_OFFSET (SubsystemVendorId), "Subsystem Vendor Id", 0}, {ACPI_DMT_UINT16, ACPI_NFIT4_OFFSET (SubsystemDeviceId), "Subsystem Device Id", 0}, {ACPI_DMT_UINT16, ACPI_NFIT4_OFFSET (SubsystemRevisionId), "Subsystem Revision Id", 0}, - {ACPI_DMT_UINT48, ACPI_NFIT4_OFFSET (Reserved[0]), "Reserved", 0}, + {ACPI_DMT_UINT8, ACPI_NFIT4_OFFSET (ValidFields), "Valid Fields", 0}, + {ACPI_DMT_UINT8, ACPI_NFIT4_OFFSET (ManufacturingLocation), "Manufacturing Location", 0}, + {ACPI_DMT_UINT16, ACPI_NFIT4_OFFSET (ManufacturingDate), "Manufacturing Date", 0}, + {ACPI_DMT_UINT16, ACPI_NFIT4_OFFSET (Reserved[0]), "Reserved", 0}, {ACPI_DMT_UINT32, ACPI_NFIT4_OFFSET (SerialNumber), "Serial Number", 0}, {ACPI_DMT_UINT16, ACPI_NFIT4_OFFSET (Code), "Code", 0}, {ACPI_DMT_UINT16, ACPI_NFIT4_OFFSET (Windows), "Window Count", 0}, diff --git a/source/compiler/aslcodegen.c b/source/compiler/aslcodegen.c index 5e25d0d..30e7984 100644 --- a/source/compiler/aslcodegen.c +++ b/source/compiler/aslcodegen.c @@ -590,6 +590,12 @@ CgWriteNode ( return; } + if ((Op->Asl.ParseOpcode == PARSEOP_EXTERNAL) && + Gbl_DoExternals == FALSE) + { + return; + } + Op->Asl.FinalAmlLength = 0; switch (Op->Asl.AmlOpcode) diff --git a/source/compiler/aslcompile.c b/source/compiler/aslcompile.c index 54c863e..a2a03e9 100644 --- a/source/compiler/aslcompile.c +++ b/source/compiler/aslcompile.c @@ -281,11 +281,14 @@ CmDoCompile ( /* Resolve External Declarations */ - Event = UtBeginEvent ("Resolve all Externals"); - DbgPrint (ASL_DEBUG_OUTPUT, "\nResolve Externals\n\n"); - TrWalkParseTree (Gbl_ParseTreeRoot, ASL_WALK_VISIT_TWICE, - ExAmlExternalWalkBegin, ExAmlExternalWalkEnd, NULL); - UtEndEvent (Event); + if (Gbl_DoExternals) + { + Event = UtBeginEvent ("Resolve all Externals"); + DbgPrint (ASL_DEBUG_OUTPUT, "\nResolve Externals\n\n"); + TrWalkParseTree (Gbl_ParseTreeRoot, ASL_WALK_VISIT_TWICE, + ExAmlExternalWalkBegin, ExAmlExternalWalkEnd, NULL); + UtEndEvent (Event); + } /* * Semantic analysis. This can happen only after the diff --git a/source/compiler/aslcompiler.h b/source/compiler/aslcompiler.h index d92b9b1..1446dc8 100644 --- a/source/compiler/aslcompiler.h +++ b/source/compiler/aslcompiler.h @@ -538,6 +538,14 @@ OptOptimizeNamePath ( /* + * aslpld - ToPLD macro support + */ +void +OpcDoPld ( + ACPI_PARSE_OBJECT *Op); + + +/* * aslprintf - Printf/Fprintf macros */ void diff --git a/source/compiler/aslexternal.c b/source/compiler/aslexternal.c index 5335048..a814efd 100644 --- a/source/compiler/aslexternal.c +++ b/source/compiler/aslexternal.c @@ -146,6 +146,7 @@ ExInsertArgCount ( char * ExternalName; char * CallName; UINT16 ArgCount = 0; + ACPI_STATUS Status; CallName = AcpiNsGetNormalizedPathname (Op->Asl.Node, TRUE); @@ -166,43 +167,49 @@ ExInsertArgCount ( NameOp = Next->Asl.Child->Asl.Child; ExternalName = AcpiNsGetNormalizedPathname (NameOp->Asl.Node, TRUE); - if (!strcmp (CallName, ExternalName)) + if (strcmp (CallName, ExternalName)) { - Next->Asl.Child->Asl.CompileFlags |= NODE_VISITED; - - /* - * Since we will reposition Externals to the Root, set Namepath - * to the fully qualified name and recalculate the aml length - */ - if (ACPI_FAILURE (UtInternalizeName ( - ExternalName, &NameOp->Asl.Value.String))) - { - AslError (ASL_ERROR, ASL_MSG_COMPILER_INTERNAL, - NULL, "- Could not Internalize External"); + ACPI_FREE (ExternalName); + Next = Next->Asl.Next; + continue; + } - break; - } + Next->Asl.Child->Asl.CompileFlags |= NODE_VISITED; - NameOp->Asl.AmlLength = strlen (NameOp->Asl.Value.String); + /* + * Since we will reposition Externals to the Root, set Namepath + * to the fully qualified name and recalculate the aml length + */ + Status = UtInternalizeName (ExternalName, + &NameOp->Asl.Value.String); - /* Get argument count */ + ACPI_FREE (ExternalName); + if (ACPI_FAILURE (Status)) + { + AslError (ASL_ERROR, ASL_MSG_COMPILER_INTERNAL, + NULL, "- Could not Internalize External"); + break; + } - Child = Op->Asl.Child; - while (Child) - { - ArgCount++; - Child = Child->Asl.Next; - } + NameOp->Asl.AmlLength = strlen (NameOp->Asl.Value.String); - /* Setup ArgCount operand */ + /* Get argument count */ - ArgCountOp = Next->Asl.Child->Asl.Child->Asl.Next->Asl.Next; - ArgCountOp->Asl.Value.Integer = ArgCount; - break; + Child = Op->Asl.Child; + while (Child) + { + ArgCount++; + Child = Child->Asl.Next; } - Next = Next->Asl.Next; + /* Setup ArgCount operand */ + + ArgCountOp = Next->Asl.Child->Asl.Child->Asl.Next->Asl.Next; + ArgCountOp->Asl.Value.Integer = ArgCount; + break; } + + ACPI_FREE (CallName); } diff --git a/source/compiler/aslglobal.h b/source/compiler/aslglobal.h index 0e534f3..6f35c24 100644 --- a/source/compiler/aslglobal.h +++ b/source/compiler/aslglobal.h @@ -181,6 +181,7 @@ ASL_EXTERN BOOLEAN ASL_INIT_GLOBAL (Gbl_AllExceptionsDisabled, 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); #define HEX_OUTPUT_NONE 0 diff --git a/source/compiler/asllength.c b/source/compiler/asllength.c index 44c85aa..626c2e7 100644 --- a/source/compiler/asllength.c +++ b/source/compiler/asllength.c @@ -406,6 +406,14 @@ CgGenerateAmlLengths ( break; + case PARSEOP_EXTERNAL: + + if (Gbl_DoExternals == TRUE) + { + CgGenerateAmlOpcodeLength (Op); + } + break; + default: CgGenerateAmlOpcodeLength (Op); diff --git a/source/compiler/aslload.c b/source/compiler/aslload.c index 955fd7f..99ec1bf 100644 --- a/source/compiler/aslload.c +++ b/source/compiler/aslload.c @@ -698,6 +698,25 @@ LdNamespace1Begin ( */ Status = AE_OK; } + else if ((Node->Flags & ANOBJ_IS_EXTERNAL) && + (Op->Asl.ParseOpcode == PARSEOP_EXTERNAL) && + (ObjectType == ACPI_TYPE_ANY)) + { + /* Allow update of externals of unknown type. */ + + if (AcpiNsOpensScope (ActualObjectType)) + { + Node->Type = (UINT8) ActualObjectType; + Status = AE_OK; + } + else + { + sprintf (MsgBuffer, "%s [%s]", Op->Asl.ExternalName, + AcpiUtGetTypeName (Node->Type)); + AslError (ASL_ERROR, ASL_MSG_SCOPE_TYPE, Op, MsgBuffer); + return_ACPI_STATUS (AE_OK); + } + } else { /* Valid error, object already exists */ diff --git a/source/compiler/aslmessages.c b/source/compiler/aslmessages.c index 8cf0e78..7a6506b 100644 --- a/source/compiler/aslmessages.c +++ b/source/compiler/aslmessages.c @@ -130,7 +130,7 @@ const char *AslCompilerMsgs [] = /* ASL_MSG_HID_SUFFIX */ "_HID suffix must be all hex digits", /* ASL_MSG_INCLUDE_FILE_OPEN */ "Could not open include file", /* ASL_MSG_INPUT_FILE_OPEN */ "Could not open input file", -/* ASL_MSG_INTEGER_LENGTH */ "64-bit integer in 32-bit table, truncating (DSDT version < 2)", +/* ASL_MSG_INTEGER_LENGTH */ "64-bit integer in 32-bit table, truncating (DSDT or SSDT version < 2)", /* ASL_MSG_INTEGER_OPTIMIZATION */ "Integer optimized to single-byte AML opcode", /* ASL_MSG_INTERRUPT_LIST */ "Too many interrupts (16 max)", /* ASL_MSG_INTERRUPT_NUMBER */ "Invalid interrupt number (must be 0-15)", @@ -224,7 +224,7 @@ const char *AslCompilerMsgs [] = /* ASL_MSG_TAG_SMALLER */ "ResourceTag smaller than Field", /* ASL_MSG_TIMEOUT */ "Result is not used, possible operator timeout will be missed", /* ASL_MSG_TOO_MANY_TEMPS */ "Method requires too many temporary variables (_T_x)", -/* ASL_MSG_TRUNCATION */ "64-bit return value will be truncated to 32 bits (DSDT version < 2)", +/* ASL_MSG_TRUNCATION */ "64-bit return value will be truncated to 32 bits (DSDT or SSDT version < 2)", /* ASL_MSG_UNKNOWN_RESERVED_NAME */ "Unknown reserved name", /* ASL_MSG_UNREACHABLE_CODE */ "Statement is unreachable", /* ASL_MSG_UNSUPPORTED */ "Unsupported feature", diff --git a/source/compiler/aslopcodes.c b/source/compiler/aslopcodes.c index d1e4277..de9ffe1 100644 --- a/source/compiler/aslopcodes.c +++ b/source/compiler/aslopcodes.c @@ -68,62 +68,9 @@ OpcDoEisaId ( ACPI_PARSE_OBJECT *Op); static void -OpcDoPld ( - ACPI_PARSE_OBJECT *Op); - -static void OpcDoUuId ( ACPI_PARSE_OBJECT *Op); -static UINT8 * -OpcEncodePldBuffer ( - ACPI_PLD_INFO *PldInfo); - - -/* ToPld strings */ - -static char *AslPldPanelList[] = -{ - "TOP", - "BOTTOM", - "LEFT", - "RIGHT", - "FRONT", - "BACK", - "UNKNOWN", - NULL -}; - -static char *AslPldVerticalPositionList[] = -{ - "UPPER", - "CENTER", - "LOWER", - NULL -}; - -static char *AslPldHorizontalPositionList[] = -{ - "LEFT", - "CENTER", - "RIGHT", - NULL -}; - -static char *AslPldShapeList[] = -{ - "ROUND", - "OVAL", - "SQUARE", - "VERTICALRECTANGLE", - "HORIZONTALRECTANGLE", - "VERTICALTRAPEZOID", - "HORIZONTALTRAPEZOID", - "UNKNOWN", - "CHAMFERED", - NULL -}; - /******************************************************************************* * @@ -709,651 +656,6 @@ OpcDoEisaId ( /******************************************************************************* * - * FUNCTION: OpcEncodePldBuffer - * - * PARAMETERS: PldInfo - _PLD buffer struct (Using local struct) - * - * RETURN: Encode _PLD buffer suitable for return value from _PLD - * - * DESCRIPTION: Bit-packs a _PLD buffer struct. - * - ******************************************************************************/ - -static UINT8 * -OpcEncodePldBuffer ( - ACPI_PLD_INFO *PldInfo) -{ - UINT32 *Buffer; - UINT32 Dword; - - - Buffer = ACPI_ALLOCATE_ZEROED (ACPI_PLD_BUFFER_SIZE); - if (!Buffer) - { - return (NULL); - } - - /* First 32 bits */ - - Dword = 0; - ACPI_PLD_SET_REVISION (&Dword, PldInfo->Revision); - ACPI_PLD_SET_IGNORE_COLOR (&Dword, PldInfo->IgnoreColor); - ACPI_PLD_SET_RED (&Dword, PldInfo->Red); - ACPI_PLD_SET_GREEN (&Dword, PldInfo->Green); - ACPI_PLD_SET_BLUE (&Dword, PldInfo->Blue); - ACPI_MOVE_32_TO_32 (&Buffer[0], &Dword); - - /* Second 32 bits */ - - Dword = 0; - ACPI_PLD_SET_WIDTH (&Dword, PldInfo->Width); - ACPI_PLD_SET_HEIGHT (&Dword, PldInfo->Height); - ACPI_MOVE_32_TO_32 (&Buffer[1], &Dword); - - /* Third 32 bits */ - - Dword = 0; - ACPI_PLD_SET_USER_VISIBLE (&Dword, PldInfo->UserVisible); - ACPI_PLD_SET_DOCK (&Dword, PldInfo->Dock); - ACPI_PLD_SET_LID (&Dword, PldInfo->Lid); - ACPI_PLD_SET_PANEL (&Dword, PldInfo->Panel); - ACPI_PLD_SET_VERTICAL (&Dword, PldInfo->VerticalPosition); - ACPI_PLD_SET_HORIZONTAL (&Dword, PldInfo->HorizontalPosition); - ACPI_PLD_SET_SHAPE (&Dword, PldInfo->Shape); - ACPI_PLD_SET_ORIENTATION (&Dword, PldInfo->GroupOrientation); - ACPI_PLD_SET_TOKEN (&Dword, PldInfo->GroupToken); - ACPI_PLD_SET_POSITION (&Dword, PldInfo->GroupPosition); - ACPI_PLD_SET_BAY (&Dword, PldInfo->Bay); - ACPI_MOVE_32_TO_32 (&Buffer[2], &Dword); - - /* Fourth 32 bits */ - - Dword = 0; - ACPI_PLD_SET_EJECTABLE (&Dword, PldInfo->Ejectable); - ACPI_PLD_SET_OSPM_EJECT (&Dword, PldInfo->OspmEjectRequired); - ACPI_PLD_SET_CABINET (&Dword, PldInfo->CabinetNumber); - ACPI_PLD_SET_CARD_CAGE (&Dword, PldInfo->CardCageNumber); - ACPI_PLD_SET_REFERENCE (&Dword, PldInfo->Reference); - ACPI_PLD_SET_ROTATION (&Dword, PldInfo->Rotation); - ACPI_PLD_SET_ORDER (&Dword, PldInfo->Order); - ACPI_MOVE_32_TO_32 (&Buffer[3], &Dword); - - if (PldInfo->Revision >= 2) - { - /* Fifth 32 bits */ - - Dword = 0; - ACPI_PLD_SET_VERT_OFFSET (&Dword, PldInfo->VerticalOffset); - ACPI_PLD_SET_HORIZ_OFFSET (&Dword, PldInfo->HorizontalOffset); - ACPI_MOVE_32_TO_32 (&Buffer[4], &Dword); - } - - return (ACPI_CAST_PTR (UINT8, Buffer)); -} - - -/******************************************************************************* - * - * FUNCTION: OpcFindName - * - * PARAMETERS: List - Array of char strings to be searched - * Name - Char string to string for - * Index - Index value to set if found - * - * RETURN: TRUE if any names matched, FALSE otherwise - * - * DESCRIPTION: Match PLD name to value in lookup table. Sets Value to - * equivalent parameter value. - * - ******************************************************************************/ - -static BOOLEAN -OpcFindName ( - char **List, - char *Name, - UINT64 *Index) -{ - char *Str; - UINT32 i; - - - AcpiUtStrupr (Name); - - for (i = 0, Str = List[0]; Str; i++, Str = List[i]) - { - if (!(strncmp (Str, Name, strlen (Name)))) - { - *Index = i; - return (TRUE); - } - } - - return (FALSE); -} - - -/******************************************************************************* - * - * FUNCTION: OpcDoPld - * - * PARAMETERS: Op - Parse node - * - * RETURN: None - * - * DESCRIPTION: Convert ToPLD macro to 20-byte buffer - * - ******************************************************************************/ - -static void -OpcDoPld ( - ACPI_PARSE_OBJECT *Op) -{ - UINT8 *Buffer; - ACPI_PARSE_OBJECT *Node; - ACPI_PLD_INFO PldInfo; - ACPI_PARSE_OBJECT *NewOp; - - - if (!Op) - { - AslError(ASL_ERROR, ASL_MSG_NOT_EXIST, Op, NULL); - return; - } - - if (Op->Asl.ParseOpcode != PARSEOP_TOPLD) - { - AslError(ASL_ERROR, ASL_MSG_INVALID_TYPE, Op, NULL); - return; - } - - memset (&PldInfo, 0, sizeof (ACPI_PLD_INFO)); - - Node = Op->Asl.Child; - while (Node) - { - switch (Node->Asl.ParseOpcode) - { - case PARSEOP_PLD_REVISION: - - if (Node->Asl.Child->Asl.ParseOpcode != PARSEOP_INTEGER) - { - AslError(ASL_ERROR, ASL_MSG_INVALID_TYPE, Node, NULL); - break; - } - - if (Node->Asl.Child->Asl.Value.Integer > 127) - { - AslError(ASL_ERROR, ASL_MSG_RANGE, Node, NULL); - break; - } - - PldInfo.Revision = (UINT8) Node->Asl.Child->Asl.Value.Integer; - break; - - case PARSEOP_PLD_IGNORECOLOR: - - if (Node->Asl.Child->Asl.ParseOpcode != PARSEOP_INTEGER) - { - AslError(ASL_ERROR, ASL_MSG_INVALID_TYPE, Node, NULL); - break; - } - - if (Node->Asl.Child->Asl.Value.Integer > 1) - { - AslError(ASL_ERROR, ASL_MSG_RANGE, Node, NULL); - break; - } - - PldInfo.IgnoreColor = (UINT8) Node->Asl.Child->Asl.Value.Integer; - break; - - case PARSEOP_PLD_RED: - case PARSEOP_PLD_GREEN: - case PARSEOP_PLD_BLUE: - - if (Node->Asl.Child->Asl.ParseOpcode != PARSEOP_INTEGER) - { - AslError(ASL_ERROR, ASL_MSG_RANGE, Node, NULL); - break; - } - - if (Node->Asl.Child->Asl.Value.Integer > 255) - { - AslError(ASL_ERROR, ASL_MSG_RANGE, Node, NULL); - break; - } - - if (Node->Asl.ParseOpcode == PARSEOP_PLD_RED) - { - PldInfo.Red = (UINT8) Node->Asl.Child->Asl.Value.Integer; - } - else if (Node->Asl.ParseOpcode == PARSEOP_PLD_GREEN) - { - PldInfo.Green = (UINT8) Node->Asl.Child->Asl.Value.Integer; - } - else /* PARSEOP_PLD_BLUE */ - { - PldInfo.Blue = (UINT8) Node->Asl.Child->Asl.Value.Integer; - } - break; - - case PARSEOP_PLD_WIDTH: - case PARSEOP_PLD_HEIGHT: - - if (Node->Asl.Child->Asl.ParseOpcode != PARSEOP_INTEGER) - { - AslError(ASL_ERROR, ASL_MSG_INVALID_TYPE, Node, NULL); - break; - } - - if (Node->Asl.Child->Asl.Value.Integer > 65535) - { - AslError(ASL_ERROR, ASL_MSG_RANGE, Node, NULL); - break; - } - - if (Node->Asl.ParseOpcode == PARSEOP_PLD_WIDTH) - { - PldInfo.Width = (UINT16) Node->Asl.Child->Asl.Value.Integer; - } - else /* PARSEOP_PLD_HEIGHT */ - { - PldInfo.Height = (UINT16) Node->Asl.Child->Asl.Value.Integer; - } - - break; - - case PARSEOP_PLD_USERVISIBLE: - case PARSEOP_PLD_DOCK: - case PARSEOP_PLD_LID: - - if (Node->Asl.Child->Asl.ParseOpcode != PARSEOP_INTEGER) - { - AslError(ASL_ERROR, ASL_MSG_INVALID_TYPE, Node, NULL); - break; - } - - if (Node->Asl.Child->Asl.Value.Integer > 1) - { - AslError(ASL_ERROR, ASL_MSG_RANGE, Node, NULL); - break; - } - - if (Node->Asl.ParseOpcode == PARSEOP_PLD_USERVISIBLE) - { - PldInfo.UserVisible = (UINT8) Node->Asl.Child->Asl.Value.Integer; - } - else if (Node->Asl.ParseOpcode == PARSEOP_PLD_DOCK) - { - PldInfo.Dock = (UINT8) Node->Asl.Child->Asl.Value.Integer; - } - else - { - PldInfo.Lid = (UINT8) Node->Asl.Child->Asl.Value.Integer; - } - - break; - - case PARSEOP_PLD_PANEL: - - if (Node->Asl.Child->Asl.ParseOpcode == PARSEOP_INTEGER) - { - if (Node->Asl.Child->Asl.Value.Integer > 6) - { - AslError(ASL_ERROR, ASL_MSG_RANGE, Node, NULL); - break; - } - } - else /* PARSEOP_STRING */ - { - if (!OpcFindName(AslPldPanelList, - Node->Asl.Child->Asl.Value.String, - &Node->Asl.Child->Asl.Value.Integer)) - { - AslError(ASL_ERROR, ASL_MSG_INVALID_OPERAND, Node, NULL); - break; - } - } - - PldInfo.Panel = (UINT8) Node->Asl.Child->Asl.Value.Integer; - break; - - case PARSEOP_PLD_VERTICALPOSITION: - - if (Node->Asl.Child->Asl.ParseOpcode == PARSEOP_INTEGER) - { - if (Node->Asl.Child->Asl.Value.Integer > 2) - { - AslError(ASL_ERROR, ASL_MSG_RANGE, Node, NULL); - break; - } - } - else /* PARSEOP_STRING */ - { - if (!OpcFindName(AslPldVerticalPositionList, - Node->Asl.Child->Asl.Value.String, - &Node->Asl.Child->Asl.Value.Integer)) - { - AslError(ASL_ERROR, ASL_MSG_INVALID_OPERAND, Node, NULL); - break; - } - } - - PldInfo.VerticalPosition = (UINT8) Node->Asl.Child->Asl.Value.Integer; - break; - - case PARSEOP_PLD_HORIZONTALPOSITION: - - if (Node->Asl.Child->Asl.ParseOpcode == PARSEOP_INTEGER) - { - if (Node->Asl.Child->Asl.Value.Integer > 2) - { - AslError(ASL_ERROR, ASL_MSG_RANGE, Node, NULL); - break; - } - } - else /* PARSEOP_STRING */ - { - if (!OpcFindName(AslPldHorizontalPositionList, - Node->Asl.Child->Asl.Value.String, - &Node->Asl.Child->Asl.Value.Integer)) - { - AslError(ASL_ERROR, ASL_MSG_INVALID_OPERAND, Node, NULL); - break; - } - } - - PldInfo.HorizontalPosition = (UINT8) Node->Asl.Child->Asl.Value.Integer; - break; - - case PARSEOP_PLD_SHAPE: - - if (Node->Asl.Child->Asl.ParseOpcode == PARSEOP_INTEGER) - { - if (Node->Asl.Child->Asl.Value.Integer > 8) - { - AslError(ASL_ERROR, ASL_MSG_RANGE, Node, NULL); - break; - } - } - else /* PARSEOP_STRING */ - { - if (!OpcFindName(AslPldShapeList, - Node->Asl.Child->Asl.Value.String, - &Node->Asl.Child->Asl.Value.Integer)) - { - AslError(ASL_ERROR, ASL_MSG_INVALID_OPERAND, Node, NULL); - break; - } - } - - PldInfo.Shape = (UINT8) Node->Asl.Child->Asl.Value.Integer; - break; - - case PARSEOP_PLD_GROUPORIENTATION: - - if (Node->Asl.Child->Asl.ParseOpcode != PARSEOP_INTEGER) - { - AslError(ASL_ERROR, ASL_MSG_INVALID_TYPE, Node, NULL); - break; - } - - if (Node->Asl.Child->Asl.Value.Integer > 1) - { - AslError(ASL_ERROR, ASL_MSG_RANGE, Node, NULL); - break; - } - - PldInfo.GroupOrientation = (UINT8) Node->Asl.Child->Asl.Value.Integer; - break; - - case PARSEOP_PLD_GROUPTOKEN: - case PARSEOP_PLD_GROUPPOSITION: - - if (Node->Asl.Child->Asl.ParseOpcode != PARSEOP_INTEGER) - { - AslError(ASL_ERROR, ASL_MSG_INVALID_TYPE, Node, NULL); - break; - } - - if (Node->Asl.Child->Asl.Value.Integer > 255) - { - AslError(ASL_ERROR, ASL_MSG_RANGE, Node, NULL); - break; - } - - - if (Node->Asl.ParseOpcode == PARSEOP_PLD_GROUPTOKEN) - { - PldInfo.GroupToken = (UINT8) Node->Asl.Child->Asl.Value.Integer; - } - else /* PARSEOP_PLD_GROUPPOSITION */ - { - PldInfo.GroupPosition = (UINT8) Node->Asl.Child->Asl.Value.Integer; - } - - break; - - case PARSEOP_PLD_BAY: - case PARSEOP_PLD_EJECTABLE: - case PARSEOP_PLD_EJECTREQUIRED: - - if (Node->Asl.Child->Asl.ParseOpcode != PARSEOP_INTEGER) - { - AslError(ASL_ERROR, ASL_MSG_INVALID_TYPE, Node, NULL); - break; - } - - if (Node->Asl.Child->Asl.Value.Integer > 1) - { - AslError(ASL_ERROR, ASL_MSG_RANGE, Node, NULL); - break; - } - - if (Node->Asl.ParseOpcode == PARSEOP_PLD_BAY) - { - PldInfo.Bay = (UINT8) Node->Asl.Child->Asl.Value.Integer; - } - else if (Node->Asl.ParseOpcode == PARSEOP_PLD_EJECTABLE) - { - PldInfo.Ejectable = (UINT8) Node->Asl.Child->Asl.Value.Integer; - } - else /* PARSEOP_PLD_EJECTREQUIRED */ - { - PldInfo.OspmEjectRequired = (UINT8) Node->Asl.Child->Asl.Value.Integer; - } - - break; - - case PARSEOP_PLD_CABINETNUMBER: - case PARSEOP_PLD_CARDCAGENUMBER: - - if (Node->Asl.Child->Asl.ParseOpcode != PARSEOP_INTEGER) - { - AslError(ASL_ERROR, ASL_MSG_INVALID_TYPE, Node, NULL); - break; - } - - if (Node->Asl.Child->Asl.Value.Integer > 255) - { - AslError(ASL_ERROR, ASL_MSG_RANGE, Node, NULL); - break; - } - - if (Node->Asl.ParseOpcode == PARSEOP_PLD_CABINETNUMBER) - { - PldInfo.CabinetNumber = (UINT8) Node->Asl.Child->Asl.Value.Integer; - } - else /* PARSEOP_PLD_CARDCAGENUMBER */ - { - PldInfo.CardCageNumber = (UINT8) Node->Asl.Child->Asl.Value.Integer; - } - - break; - - case PARSEOP_PLD_REFERENCE: - - if (Node->Asl.Child->Asl.ParseOpcode != PARSEOP_INTEGER) - { - AslError(ASL_ERROR, ASL_MSG_INVALID_TYPE, Node, NULL); - break; - } - - if (Node->Asl.Child->Asl.Value.Integer > 1) - { - AslError(ASL_ERROR, ASL_MSG_RANGE, Node, NULL); - break; - } - - PldInfo.Reference = (UINT8) Node->Asl.Child->Asl.Value.Integer; - break; - - case PARSEOP_PLD_ROTATION: - - if (Node->Asl.Child->Asl.ParseOpcode != PARSEOP_INTEGER) - { - AslError(ASL_ERROR, ASL_MSG_INVALID_TYPE, Node, NULL); - break; - } - - if (Node->Asl.Child->Asl.Value.Integer > 7) - { - switch (Node->Asl.Child->Asl.Value.Integer) - { - case 45: - - Node->Asl.Child->Asl.Value.Integer = 1; - break; - - case 90: - - Node->Asl.Child->Asl.Value.Integer = 2; - break; - - case 135: - - Node->Asl.Child->Asl.Value.Integer = 3; - break; - - case 180: - - Node->Asl.Child->Asl.Value.Integer = 4; - break; - - case 225: - - Node->Asl.Child->Asl.Value.Integer = 5; - break; - - case 270: - - Node->Asl.Child->Asl.Value.Integer = 6; - break; - - case 315: - - Node->Asl.Child->Asl.Value.Integer = 7; - break; - - default: - - AslError(ASL_ERROR, ASL_MSG_RANGE, Node, NULL); - break; - } - } - - PldInfo.Rotation = (UINT8) Node->Asl.Child->Asl.Value.Integer; - break; - - case PARSEOP_PLD_ORDER: - - if (Node->Asl.Child->Asl.ParseOpcode != PARSEOP_INTEGER) - { - AslError(ASL_ERROR, ASL_MSG_INVALID_TYPE, Node, NULL); - break; - } - - if (Node->Asl.Child->Asl.Value.Integer > 31) - { - AslError(ASL_ERROR, ASL_MSG_RANGE, Node, NULL); - break; - } - - PldInfo.Order = (UINT8) Node->Asl.Child->Asl.Value.Integer; - break; - - case PARSEOP_PLD_VERTICALOFFSET: - case PARSEOP_PLD_HORIZONTALOFFSET: - - if (Node->Asl.Child->Asl.ParseOpcode != PARSEOP_INTEGER) - { - AslError(ASL_ERROR, ASL_MSG_INVALID_TYPE, Node, NULL); - break; - } - - if (Node->Asl.Child->Asl.Value.Integer > 65535) - { - AslError(ASL_ERROR, ASL_MSG_RANGE, Node, NULL); - break; - } - - if (Node->Asl.ParseOpcode == PARSEOP_PLD_VERTICALOFFSET) - { - PldInfo.VerticalOffset = (UINT16) Node->Asl.Child->Asl.Value.Integer; - } - else /* PARSEOP_PLD_HORIZONTALOFFSET */ - { - PldInfo.HorizontalOffset = (UINT16) Node->Asl.Child->Asl.Value.Integer; - } - - break; - - default: - - AslError(ASL_ERROR, ASL_MSG_INVALID_TYPE, Node, NULL); - break; - } - - Node = Node->Asl.Next; - } - - Buffer = OpcEncodePldBuffer(&PldInfo); - - /* Change Op to a Buffer */ - - Op->Asl.ParseOpcode = PARSEOP_BUFFER; - Op->Common.AmlOpcode = AML_BUFFER_OP; - - /* Disable further optimization */ - - Op->Asl.CompileFlags &= ~NODE_COMPILE_TIME_CONST; - UtSetParseOpName (Op); - - /* Child node is the buffer length */ - - NewOp = TrAllocateNode (PARSEOP_INTEGER); - - NewOp->Asl.AmlOpcode = AML_BYTE_OP; - NewOp->Asl.Value.Integer = 20; - NewOp->Asl.Parent = Op; - - Op->Asl.Child = NewOp; - Op = NewOp; - - /* Peer to the child is the raw buffer data */ - - NewOp = TrAllocateNode (PARSEOP_RAW_DATA); - NewOp->Asl.AmlOpcode = AML_RAW_DATA_BUFFER; - NewOp->Asl.AmlLength = 20; - NewOp->Asl.Value.String = ACPI_CAST_PTR (char, Buffer); - NewOp->Asl.Parent = Op->Asl.Parent; - - Op->Asl.Next = NewOp; -} - - -/******************************************************************************* - * * FUNCTION: OpcDoUuId * * PARAMETERS: Op - Parse node @@ -1513,6 +815,15 @@ OpcGenerateAmlOpcode ( Gbl_HasIncludeFiles = TRUE; break; + case PARSEOP_EXTERNAL: + + if (Gbl_DoExternals == FALSE) + { + Op->Asl.Child->Asl.ParseOpcode = PARSEOP_DEFAULT_ARG; + Op->Asl.Child->Asl.Next->Asl.ParseOpcode = PARSEOP_DEFAULT_ARG; + } + break; + case PARSEOP_TIMER: if (AcpiGbl_IntegerBitWidth == 32) diff --git a/source/compiler/aslopt.c b/source/compiler/aslopt.c index d39e2cb..a07f10c 100644 --- a/source/compiler/aslopt.c +++ b/source/compiler/aslopt.c @@ -217,7 +217,7 @@ OptBuildShortestPath ( UINT32 Index; UINT32 NumCarats; UINT32 i; - char *NewPath; + char *NewPathInternal; char *NewPathExternal; ACPI_NAMESPACE_NODE *Node; ACPI_GENERIC_STATE ScopeInfo; @@ -253,11 +253,11 @@ OptBuildShortestPath ( { /* Compare two single NameSegs */ + Index = (NumCommonSegments * ACPI_PATH_SEGMENT_LENGTH) + 1; + if (!ACPI_COMPARE_NAME ( - &((char *) TargetPath->Pointer)[ - (NumCommonSegments * ACPI_PATH_SEGMENT_LENGTH) + 1], - &((char *) CurrentPath->Pointer)[ - (NumCommonSegments * ACPI_PATH_SEGMENT_LENGTH) + 1])) + &(ACPI_CAST_PTR (char, TargetPath->Pointer)) [Index], + &(ACPI_CAST_PTR (char, CurrentPath->Pointer)) [Index])) { /* Mismatch */ @@ -297,8 +297,8 @@ OptBuildShortestPath ( /* * Construct a new target string */ - NewPathExternal = ACPI_ALLOCATE_ZEROED ( - TargetPath->Length + NumCarats + 1); + NewPathExternal = + ACPI_ALLOCATE_ZEROED (TargetPath->Length + NumCarats + 1); /* Insert the Carats into the Target string */ @@ -315,7 +315,8 @@ OptBuildShortestPath ( /* Special handling for exact subpath in a name declaration */ - if (IsDeclaration && SubPath && (CurrentPath->Length > TargetPath->Length)) + if (IsDeclaration && SubPath && + (CurrentPath->Length > TargetPath->Length)) { /* * The current path is longer than the target, and the target is a @@ -341,7 +342,8 @@ OptBuildShortestPath ( Index = TargetPath->Length; } - strcpy (&NewPathExternal[i], &((char *) TargetPath->Pointer)[Index]); + strcpy (&NewPathExternal[i], + &(ACPI_CAST_PTR (char, TargetPath->Pointer))[Index]); ACPI_DEBUG_PRINT_RAW ((ACPI_DB_OPTIMIZATIONS, " %-24s", NewPathExternal)); /* @@ -349,22 +351,24 @@ OptBuildShortestPath ( * string to make sure that this is in fact an optimization. If the * original string is already optimal, there is no point in continuing. */ - Status = AcpiNsInternalizeName (NewPathExternal, &NewPath); + Status = AcpiNsInternalizeName (NewPathExternal, &NewPathInternal); if (ACPI_FAILURE (Status)) { AslCoreSubsystemError (Op, Status, "Internalizing new NamePath", ASL_NO_ABORT); - ACPI_FREE (NewPathExternal); - return (Status); + goto Cleanup; } - if (strlen (NewPath) >= AmlNameStringLength) + if (strlen (NewPathInternal) >= AmlNameStringLength) { ACPI_DEBUG_PRINT_RAW ((ACPI_DB_OPTIMIZATIONS, " NOT SHORTER (New %u old %u)", - (UINT32) strlen (NewPath), (UINT32) AmlNameStringLength)); - ACPI_FREE (NewPathExternal); - return (AE_NOT_FOUND); + (UINT32) strlen (NewPathInternal), + (UINT32) AmlNameStringLength)); + + ACPI_FREE (NewPathInternal); + Status = AE_NOT_FOUND; + goto Cleanup; } /* @@ -372,7 +376,7 @@ OptBuildShortestPath ( * looking for. This is simply a sanity check on the new * path that has been created. */ - Status = AcpiNsLookup (&ScopeInfo, NewPath, + Status = AcpiNsLookup (&ScopeInfo, NewPathInternal, ACPI_TYPE_ANY, ACPI_IMODE_EXECUTE, ACPI_NS_DONT_OPEN_SCOPE, WalkState, &(Node)); if (ACPI_SUCCESS (Status)) @@ -385,7 +389,7 @@ OptBuildShortestPath ( AslError (ASL_OPTIMIZATION, ASL_MSG_NAME_OPTIMIZATION, Op, NewPathExternal); - *ReturnNewPath = NewPath; + *ReturnNewPath = NewPathInternal; } else { @@ -401,11 +405,15 @@ OptBuildShortestPath ( { /* The lookup failed, we obviously cannot use this optimization */ + ACPI_FREE (NewPathInternal); + ACPI_DEBUG_PRINT_RAW ((ACPI_DB_OPTIMIZATIONS, " ***** NOT FOUND")); AslError (ASL_WARNING, ASL_MSG_COMPILER_INTERNAL, Op, "Not using optimized name - did not find node"); } +Cleanup: + ACPI_FREE (NewPathExternal); return (Status); } diff --git a/source/compiler/asloptions.c b/source/compiler/asloptions.c index 61d2cbf..792e0db 100644 --- a/source/compiler/asloptions.c +++ b/source/compiler/asloptions.c @@ -539,6 +539,13 @@ AslDoOptions ( Gbl_CompileTimesFlag = TRUE; break; + case 'e': + + /* Disable External opcode generation */ + + Gbl_DoExternals = FALSE; + break; + case 'f': /* Disable folding on "normal" expressions */ diff --git a/source/compiler/aslpld.c b/source/compiler/aslpld.c new file mode 100644 index 0000000..afc4683 --- /dev/null +++ b/source/compiler/aslpld.c @@ -0,0 +1,729 @@ +/****************************************************************************** + * + * Module Name: aslpld - Implementation of ASL ToPLD macro + * + *****************************************************************************/ + +/* + * Copyright (C) 2000 - 2016, Intel Corp. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions, and the following disclaimer, + * without modification. + * 2. Redistributions in binary form must reproduce at minimum a disclaimer + * substantially similar to the "NO WARRANTY" disclaimer below + * ("Disclaimer") and any redistribution must be conditioned upon + * including a substantially similar Disclaimer requirement for further + * binary redistribution. + * 3. Neither the names of the above-listed copyright holders nor the names + * of any contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * Alternatively, this software may be distributed under the terms of the + * GNU General Public License ("GPL") version 2 as published by the Free + * Software Foundation. + * + * NO WARRANTY + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING + * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGES. + */ + +#include "aslcompiler.h" +#include "aslcompiler.y.h" +#include "amlcode.h" + +#define _COMPONENT ACPI_COMPILER + ACPI_MODULE_NAME ("aslpld") + + +/* Local prototypes */ + +static UINT8 * +OpcEncodePldBuffer ( + ACPI_PLD_INFO *PldInfo); + +static BOOLEAN +OpcFindName ( + const char **List, + char *Name, + UINT32 *Index); + + +/******************************************************************************* + * + * FUNCTION: OpcDoPld + * + * PARAMETERS: Op - Current parse node + * + * RETURN: None + * + * DESCRIPTION: Convert ToPLD macro to 20-byte buffer + * + * The ToPLD parse tree looks like this: + * + * TOPLD + * PLD_REVISION + * INTEGER + * PLD_IGNORECOLOR + * INTEGER + * ... + * etc. + * + ******************************************************************************/ + +void +OpcDoPld ( + ACPI_PARSE_OBJECT *Op) +{ + ACPI_PLD_INFO PldInfo; + UINT8 *Buffer; + ACPI_PARSE_OBJECT *ThisOp; + ACPI_PARSE_OBJECT *NewOp; + UINT16 ParseOpcode; + UINT32 Value; + + + if (!Op) + { + AslError (ASL_ERROR, ASL_MSG_NOT_EXIST, Op, NULL); + return; + } + + if (Op->Asl.ParseOpcode != PARSEOP_TOPLD) + { + AslError (ASL_ERROR, ASL_MSG_INVALID_TYPE, Op, NULL); + return; + } + + memset (&PldInfo, 0, sizeof (ACPI_PLD_INFO)); + + /* Traverse the list of PLD Ops (one per PLD field) */ + + ThisOp = Op->Asl.Child; + while (ThisOp) + { + /* Get child values */ + + ParseOpcode = ThisOp->Asl.Child->Asl.ParseOpcode; + Value = (UINT32) ThisOp->Asl.Child->Asl.Value.Integer; + + switch (ThisOp->Asl.ParseOpcode) + { + case PARSEOP_PLD_REVISION: + + if (ParseOpcode != PARSEOP_INTEGER) + { + AslError (ASL_ERROR, ASL_MSG_INVALID_TYPE, ThisOp, NULL); + break; + } + + if (Value > 127) + { + AslError (ASL_ERROR, ASL_MSG_RANGE, ThisOp, NULL); + break; + } + + PldInfo.Revision = (UINT8) Value; + break; + + case PARSEOP_PLD_IGNORECOLOR: + + if (ParseOpcode != PARSEOP_INTEGER) + { + AslError (ASL_ERROR, ASL_MSG_INVALID_TYPE, ThisOp, NULL); + break; + } + + if (Value > 1) + { + AslError (ASL_ERROR, ASL_MSG_RANGE, ThisOp, NULL); + break; + } + + PldInfo.IgnoreColor = (UINT8) Value; + break; + + case PARSEOP_PLD_RED: + case PARSEOP_PLD_GREEN: + case PARSEOP_PLD_BLUE: + + if (ParseOpcode != PARSEOP_INTEGER) + { + AslError (ASL_ERROR, ASL_MSG_RANGE, ThisOp, NULL); + break; + } + + if (Value > 255) + { + AslError (ASL_ERROR, ASL_MSG_RANGE, ThisOp, NULL); + break; + } + + if (ThisOp->Asl.ParseOpcode == PARSEOP_PLD_RED) + { + PldInfo.Red = (UINT8) Value; + } + else if (ThisOp->Asl.ParseOpcode == PARSEOP_PLD_GREEN) + { + PldInfo.Green = (UINT8) Value; + } + else /* PARSEOP_PLD_BLUE */ + { + PldInfo.Blue = (UINT8) Value; + } + break; + + case PARSEOP_PLD_WIDTH: + case PARSEOP_PLD_HEIGHT: + + if (ParseOpcode != PARSEOP_INTEGER) + { + AslError (ASL_ERROR, ASL_MSG_INVALID_TYPE, ThisOp, NULL); + break; + } + + if (Value > 65535) + { + AslError (ASL_ERROR, ASL_MSG_RANGE, ThisOp, NULL); + break; + } + + if (ThisOp->Asl.ParseOpcode == PARSEOP_PLD_WIDTH) + { + PldInfo.Width = (UINT16) Value; + } + else /* PARSEOP_PLD_HEIGHT */ + { + PldInfo.Height = (UINT16) Value; + } + + break; + + case PARSEOP_PLD_USERVISIBLE: + case PARSEOP_PLD_DOCK: + case PARSEOP_PLD_LID: + + if (ParseOpcode != PARSEOP_INTEGER) + { + AslError (ASL_ERROR, ASL_MSG_INVALID_TYPE, ThisOp, NULL); + break; + } + + if (Value > 1) + { + AslError (ASL_ERROR, ASL_MSG_RANGE, ThisOp, NULL); + break; + } + + if (ThisOp->Asl.ParseOpcode == PARSEOP_PLD_USERVISIBLE) + { + PldInfo.UserVisible = (UINT8) Value; + } + else if (ThisOp->Asl.ParseOpcode == PARSEOP_PLD_DOCK) + { + PldInfo.Dock = (UINT8) Value; + } + else + { + PldInfo.Lid = (UINT8) Value; + } + + break; + + case PARSEOP_PLD_PANEL: + + if (ParseOpcode == PARSEOP_INTEGER) + { + if (Value > 6) + { + AslError (ASL_ERROR, ASL_MSG_RANGE, ThisOp, NULL); + break; + } + } + else /* PARSEOP_STRING */ + { + if (!OpcFindName (AcpiGbl_PldPanelList, + ThisOp->Asl.Child->Asl.Value.String, + &Value)) + { + AslError (ASL_ERROR, ASL_MSG_INVALID_OPERAND, ThisOp, NULL); + break; + } + } + + PldInfo.Panel = (UINT8) Value; + break; + + case PARSEOP_PLD_VERTICALPOSITION: + + if (ParseOpcode == PARSEOP_INTEGER) + { + if (Value > 2) + { + AslError (ASL_ERROR, ASL_MSG_RANGE, ThisOp, NULL); + break; + } + } + else /* PARSEOP_STRING */ + { + if (!OpcFindName (AcpiGbl_PldVerticalPositionList, + ThisOp->Asl.Child->Asl.Value.String, + &Value)) + { + AslError (ASL_ERROR, ASL_MSG_INVALID_OPERAND, ThisOp, NULL); + break; + } + } + + PldInfo.VerticalPosition = (UINT8) Value; + break; + + case PARSEOP_PLD_HORIZONTALPOSITION: + + if (ParseOpcode == PARSEOP_INTEGER) + { + if (Value > 2) + { + AslError (ASL_ERROR, ASL_MSG_RANGE, ThisOp, NULL); + break; + } + } + else /* PARSEOP_STRING */ + { + if (!OpcFindName (AcpiGbl_PldHorizontalPositionList, + ThisOp->Asl.Child->Asl.Value.String, + &Value)) + { + AslError (ASL_ERROR, ASL_MSG_INVALID_OPERAND, ThisOp, NULL); + break; + } + } + + PldInfo.HorizontalPosition = (UINT8) Value; + break; + + case PARSEOP_PLD_SHAPE: + + if (ParseOpcode == PARSEOP_INTEGER) + { + if (Value > 8) + { + AslError (ASL_ERROR, ASL_MSG_RANGE, ThisOp, NULL); + break; + } + } + else /* PARSEOP_STRING */ + { + if (!OpcFindName (AcpiGbl_PldShapeList, + ThisOp->Asl.Child->Asl.Value.String, + &Value)) + { + AslError (ASL_ERROR, ASL_MSG_INVALID_OPERAND, ThisOp, NULL); + break; + } + } + + PldInfo.Shape = (UINT8) Value; + break; + + case PARSEOP_PLD_GROUPORIENTATION: + + if (ParseOpcode != PARSEOP_INTEGER) + { + AslError (ASL_ERROR, ASL_MSG_INVALID_TYPE, ThisOp, NULL); + break; + } + + if (Value > 1) + { + AslError (ASL_ERROR, ASL_MSG_RANGE, ThisOp, NULL); + break; + } + + PldInfo.GroupOrientation = (UINT8) Value; + break; + + case PARSEOP_PLD_GROUPTOKEN: + case PARSEOP_PLD_GROUPPOSITION: + + if (ParseOpcode != PARSEOP_INTEGER) + { + AslError (ASL_ERROR, ASL_MSG_INVALID_TYPE, ThisOp, NULL); + break; + } + + if (Value > 255) + { + AslError (ASL_ERROR, ASL_MSG_RANGE, ThisOp, NULL); + break; + } + + if (ThisOp->Asl.ParseOpcode == PARSEOP_PLD_GROUPTOKEN) + { + PldInfo.GroupToken = (UINT8) Value; + } + else /* PARSEOP_PLD_GROUPPOSITION */ + { + PldInfo.GroupPosition = (UINT8) Value; + } + + break; + + case PARSEOP_PLD_BAY: + case PARSEOP_PLD_EJECTABLE: + case PARSEOP_PLD_EJECTREQUIRED: + + if (ParseOpcode != PARSEOP_INTEGER) + { + AslError (ASL_ERROR, ASL_MSG_INVALID_TYPE, ThisOp, NULL); + break; + } + + if (Value > 1) + { + AslError (ASL_ERROR, ASL_MSG_RANGE, ThisOp, NULL); + break; + } + + if (ThisOp->Asl.ParseOpcode == PARSEOP_PLD_BAY) + { + PldInfo.Bay = (UINT8) Value; + } + else if (ThisOp->Asl.ParseOpcode == PARSEOP_PLD_EJECTABLE) + { + PldInfo.Ejectable = (UINT8) Value; + } + else /* PARSEOP_PLD_EJECTREQUIRED */ + { + PldInfo.OspmEjectRequired = (UINT8) Value; + } + + break; + + case PARSEOP_PLD_CABINETNUMBER: + case PARSEOP_PLD_CARDCAGENUMBER: + + if (ParseOpcode != PARSEOP_INTEGER) + { + AslError (ASL_ERROR, ASL_MSG_INVALID_TYPE, ThisOp, NULL); + break; + } + + if (Value > 255) + { + AslError (ASL_ERROR, ASL_MSG_RANGE, ThisOp, NULL); + break; + } + + if (ThisOp->Asl.ParseOpcode == PARSEOP_PLD_CABINETNUMBER) + { + PldInfo.CabinetNumber = (UINT8) Value; + } + else /* PARSEOP_PLD_CARDCAGENUMBER */ + { + PldInfo.CardCageNumber = (UINT8) Value; + } + + break; + + case PARSEOP_PLD_REFERENCE: + + if (ParseOpcode != PARSEOP_INTEGER) + { + AslError (ASL_ERROR, ASL_MSG_INVALID_TYPE, ThisOp, NULL); + break; + } + + if (Value > 1) + { + AslError (ASL_ERROR, ASL_MSG_RANGE, ThisOp, NULL); + break; + } + + PldInfo.Reference = (UINT8) Value; + break; + + case PARSEOP_PLD_ROTATION: + + if (ParseOpcode != PARSEOP_INTEGER) + { + AslError (ASL_ERROR, ASL_MSG_INVALID_TYPE, ThisOp, NULL); + break; + } + + if (Value > 7) + { + switch (Value) + { + case 45: + + Value = 1; + break; + + case 90: + + Value = 2; + break; + + case 135: + + Value = 3; + break; + + case 180: + + Value = 4; + break; + + case 225: + + Value = 5; + break; + + case 270: + + Value = 6; + break; + + case 315: + + Value = 7; + break; + + default: + + AslError (ASL_ERROR, ASL_MSG_RANGE, ThisOp, NULL); + break; + } + } + + PldInfo.Rotation = (UINT8) Value; + break; + + case PARSEOP_PLD_ORDER: + + if (ParseOpcode != PARSEOP_INTEGER) + { + AslError (ASL_ERROR, ASL_MSG_INVALID_TYPE, ThisOp, NULL); + break; + } + + if (Value > 31) + { + AslError (ASL_ERROR, ASL_MSG_RANGE, ThisOp, NULL); + break; + } + + PldInfo.Order = (UINT8) Value; + break; + + case PARSEOP_PLD_VERTICALOFFSET: + case PARSEOP_PLD_HORIZONTALOFFSET: + + if (ParseOpcode != PARSEOP_INTEGER) + { + AslError (ASL_ERROR, ASL_MSG_INVALID_TYPE, ThisOp, NULL); + break; + } + + if (Value > 65535) + { + AslError (ASL_ERROR, ASL_MSG_RANGE, ThisOp, NULL); + break; + } + + if (ThisOp->Asl.ParseOpcode == PARSEOP_PLD_VERTICALOFFSET) + { + PldInfo.VerticalOffset = (UINT16) Value; + } + else /* PARSEOP_PLD_HORIZONTALOFFSET */ + { + PldInfo.HorizontalOffset = (UINT16) Value; + } + + break; + + default: + + AslError (ASL_ERROR, ASL_MSG_INVALID_TYPE, ThisOp, NULL); + break; + } + + ThisOp = ThisOp->Asl.Next; + } + + Buffer = OpcEncodePldBuffer (&PldInfo); + + /* Change Op to a Buffer */ + + Op->Asl.ParseOpcode = PARSEOP_BUFFER; + Op->Common.AmlOpcode = AML_BUFFER_OP; + + /* Disable further optimization */ + + Op->Asl.CompileFlags &= ~NODE_COMPILE_TIME_CONST; + UtSetParseOpName (Op); + + /* Child node is the buffer length */ + + NewOp = TrAllocateNode (PARSEOP_INTEGER); + + NewOp->Asl.AmlOpcode = AML_BYTE_OP; + NewOp->Asl.Value.Integer = 20; + NewOp->Asl.Parent = Op; + + Op->Asl.Child = NewOp; + Op = NewOp; + + /* Peer to the child is the raw buffer data */ + + NewOp = TrAllocateNode (PARSEOP_RAW_DATA); + NewOp->Asl.AmlOpcode = AML_RAW_DATA_BUFFER; + NewOp->Asl.AmlLength = 20; + NewOp->Asl.Value.String = ACPI_CAST_PTR (char, Buffer); + NewOp->Asl.Parent = Op->Asl.Parent; + + Op->Asl.Next = NewOp; +} + + +/******************************************************************************* + * + * FUNCTION: OpcEncodePldBuffer + * + * PARAMETERS: PldInfo - _PLD buffer struct (Using local struct) + * + * RETURN: Encode _PLD buffer suitable for return value from _PLD + * + * DESCRIPTION: Bit-packs a _PLD buffer struct. + * + ******************************************************************************/ + +static UINT8 * +OpcEncodePldBuffer ( + ACPI_PLD_INFO *PldInfo) +{ + UINT32 *Buffer; + UINT32 Dword; + + + Buffer = ACPI_ALLOCATE_ZEROED (ACPI_PLD_BUFFER_SIZE); + if (!Buffer) + { + return (NULL); + } + + /* First 32 bits */ + + Dword = 0; + ACPI_PLD_SET_REVISION (&Dword, PldInfo->Revision); + ACPI_PLD_SET_IGNORE_COLOR (&Dword, PldInfo->IgnoreColor); + ACPI_PLD_SET_RED (&Dword, PldInfo->Red); + ACPI_PLD_SET_GREEN (&Dword, PldInfo->Green); + ACPI_PLD_SET_BLUE (&Dword, PldInfo->Blue); + ACPI_MOVE_32_TO_32 (&Buffer[0], &Dword); + + /* Second 32 bits */ + + Dword = 0; + ACPI_PLD_SET_WIDTH (&Dword, PldInfo->Width); + ACPI_PLD_SET_HEIGHT (&Dword, PldInfo->Height); + ACPI_MOVE_32_TO_32 (&Buffer[1], &Dword); + + /* Third 32 bits */ + + Dword = 0; + ACPI_PLD_SET_USER_VISIBLE (&Dword, PldInfo->UserVisible); + ACPI_PLD_SET_DOCK (&Dword, PldInfo->Dock); + ACPI_PLD_SET_LID (&Dword, PldInfo->Lid); + ACPI_PLD_SET_PANEL (&Dword, PldInfo->Panel); + ACPI_PLD_SET_VERTICAL (&Dword, PldInfo->VerticalPosition); + ACPI_PLD_SET_HORIZONTAL (&Dword, PldInfo->HorizontalPosition); + ACPI_PLD_SET_SHAPE (&Dword, PldInfo->Shape); + ACPI_PLD_SET_ORIENTATION (&Dword, PldInfo->GroupOrientation); + ACPI_PLD_SET_TOKEN (&Dword, PldInfo->GroupToken); + ACPI_PLD_SET_POSITION (&Dword, PldInfo->GroupPosition); + ACPI_PLD_SET_BAY (&Dword, PldInfo->Bay); + ACPI_MOVE_32_TO_32 (&Buffer[2], &Dword); + + /* Fourth 32 bits */ + + Dword = 0; + ACPI_PLD_SET_EJECTABLE (&Dword, PldInfo->Ejectable); + ACPI_PLD_SET_OSPM_EJECT (&Dword, PldInfo->OspmEjectRequired); + ACPI_PLD_SET_CABINET (&Dword, PldInfo->CabinetNumber); + ACPI_PLD_SET_CARD_CAGE (&Dword, PldInfo->CardCageNumber); + ACPI_PLD_SET_REFERENCE (&Dword, PldInfo->Reference); + ACPI_PLD_SET_ROTATION (&Dword, PldInfo->Rotation); + ACPI_PLD_SET_ORDER (&Dword, PldInfo->Order); + ACPI_MOVE_32_TO_32 (&Buffer[3], &Dword); + + /* Revision 2 adds an additional DWORD */ + + if (PldInfo->Revision >= 2) + { + /* Fifth 32 bits */ + + Dword = 0; + ACPI_PLD_SET_VERT_OFFSET (&Dword, PldInfo->VerticalOffset); + ACPI_PLD_SET_HORIZ_OFFSET (&Dword, PldInfo->HorizontalOffset); + ACPI_MOVE_32_TO_32 (&Buffer[4], &Dword); + } + + return (ACPI_CAST_PTR (UINT8, Buffer)); +} + + +/******************************************************************************* + * + * FUNCTION: OpcFindName + * + * PARAMETERS: List - Array of char strings to be searched + * Name - Char string to string for + * Index - Index value to set if found + * + * RETURN: TRUE if any names matched, FALSE otherwise + * + * DESCRIPTION: Match PLD name to value in lookup table. Sets Value to + * equivalent parameter value. + * + ******************************************************************************/ + +static BOOLEAN +OpcFindName ( + const char **List, + char *Name, + UINT32 *Index) +{ + const char *NameString; + UINT32 i; + + + AcpiUtStrupr (Name); + + for (i = 0, NameString = List[0]; + NameString; + i++, NameString = List[i]) + { + if (!(strncmp (NameString, Name, strlen (Name)))) + { + *Index = i; + return (TRUE); + } + } + + return (FALSE); +} diff --git a/source/compiler/aslrestype2e.c b/source/compiler/aslrestype2e.c index fc07366..aa17a75 100644 --- a/source/compiler/aslrestype2e.c +++ b/source/compiler/aslrestype2e.c @@ -143,7 +143,7 @@ RsDoExtendedIoDescriptor ( RsCreateQwordField (InitializerOp, ACPI_RESTAG_GRANULARITY, CurrentByteOffset + ASL_RESDESC_OFFSET (ExtAddress64.Granularity)); GranOp = InitializerOp; - break; + break; case 6: /* Address Min */ diff --git a/source/compiler/aslstubs.c b/source/compiler/aslstubs.c index 47c4720..f0fbe03 100644 --- a/source/compiler/aslstubs.c +++ b/source/compiler/aslstubs.c @@ -64,6 +64,13 @@ AcpiNsExecModuleCodeList ( } ACPI_STATUS +AcpiNsInitializeObjects ( + void) +{ + return (AE_OK); +} + +ACPI_STATUS AcpiHwReadPort ( ACPI_IO_ADDRESS Address, UINT32 *Value, diff --git a/source/compiler/asltransform.c b/source/compiler/asltransform.c index 8de5ba1..e504220 100644 --- a/source/compiler/asltransform.c +++ b/source/compiler/asltransform.c @@ -350,7 +350,11 @@ TrTransformSubtree ( case PARSEOP_EXTERNAL: - ExDoExternal (Op); + if (Gbl_DoExternals == TRUE) + { + ExDoExternal (Op); + } + break; default: diff --git a/source/compiler/aslutils.c b/source/compiler/aslutils.c index 288fe1f..f5ca7b7 100644 --- a/source/compiler/aslutils.c +++ b/source/compiler/aslutils.c @@ -906,7 +906,9 @@ UtDoConstant ( char ErrBuf[64]; - Status = AcpiUtStrtoul64 (String, 0, &Converted); + Status = AcpiUtStrtoul64 (String, ACPI_ANY_BASE, + ACPI_MAX64_BYTE_WIDTH, &Converted); + if (ACPI_FAILURE (Status)) { sprintf (ErrBuf, "%s %s\n", "Conversion error:", diff --git a/source/compiler/aslwalks.c b/source/compiler/aslwalks.c index a4e5a8c..357b92d 100644 --- a/source/compiler/aslwalks.c +++ b/source/compiler/aslwalks.c @@ -104,9 +104,12 @@ AnMethodTypingWalkEnd ( * The called method is untyped at this time (typically a * forward reference). * - * Check for a recursive method call first. + * Check for a recursive method call first. Note: the + * Child->Node will be null if the method has not been + * resolved. */ - if (Op->Asl.ParentMethod != Op->Asl.Child->Asl.Node->Op) + if (Op->Asl.Child->Asl.Node && + (Op->Asl.ParentMethod != Op->Asl.Child->Asl.Node->Op)) { /* We must type the method here */ diff --git a/source/compiler/aslxrefout.c b/source/compiler/aslxrefout.c index 554f51f..701399c 100644 --- a/source/compiler/aslxrefout.c +++ b/source/compiler/aslxrefout.c @@ -252,7 +252,6 @@ OtXrefWalkPart1 ( MethodInfo->CurrentOp = Op; Node = Op->Asl.Node; - ParentPath = AcpiNsGetNormalizedPathname (Node, TRUE); /* Find all objects referenced by this method */ @@ -261,8 +260,11 @@ OtXrefWalkPart1 ( if (Status == AE_CTRL_TERMINATE) { + ParentPath = AcpiNsGetNormalizedPathname (Node, TRUE); + FlPrintFile (ASL_FILE_XREF_OUTPUT, " %-40s %s", ParentPath, AcpiUtGetTypeName (Node->Type)); + ACPI_FREE (ParentPath); switch (Node->Type) { @@ -324,12 +326,12 @@ OtXrefWalkPart1 ( } else { - ACPI_FREE (ParentPath); ParentPath = AcpiNsGetNormalizedPathname ( NextOp->Asl.Node, TRUE); FlPrintFile (ASL_FILE_XREF_OUTPUT, " (%.2u bit) in Buffer %s", Length, ParentPath); + ACPI_FREE (ParentPath); } break; @@ -339,13 +341,13 @@ OtXrefWalkPart1 ( FieldOp = NextOp->Asl.Parent; NextOp = FieldOp->Asl.Child; - ACPI_FREE (ParentPath); ParentPath = AcpiNsGetNormalizedPathname ( NextOp->Asl.Node, TRUE); FlPrintFile (ASL_FILE_XREF_OUTPUT, " (%.2u bit) in Region %s", (UINT32) Node->Op->Asl.Child->Asl.Value.Integer, ParentPath); + ACPI_FREE (ParentPath); if (FieldOp->Asl.ParseOpcode == PARSEOP_FIELD) { @@ -367,7 +369,6 @@ OtXrefWalkPart1 ( } FlPrintFile (ASL_FILE_XREF_OUTPUT, "\n"); - ACPI_FREE (ParentPath); } break; @@ -672,6 +673,7 @@ OtXrefWalkPart3 ( "\n[%5u] %-40s %s Declaration\n", Op->Asl.LogicalLineNumber, ParentPath, AcpiUtGetTypeName (Node->Type)); + ACPI_FREE (ParentPath); XrefInfo->MethodOp = Op; XrefInfo->ThisObjectReferences = 0; @@ -716,7 +718,7 @@ OtXrefAnalysisWalkPart3 ( void *Context) { ASL_XREF_INFO *XrefInfo = (ASL_XREF_INFO *) Context; - char *CallerFullPathname; + char *CallerFullPathname = NULL; ACPI_PARSE_OBJECT *CallerOp; const char *Operator; @@ -756,27 +758,24 @@ OtXrefAnalysisWalkPart3 ( CallerOp = CallerOp->Asl.Parent; } - /* There are some special cases for the oddball operators */ + if (CallerOp == XrefInfo->CurrentMethodOp) + { + return (AE_OK); + } + + /* Null CallerOp means the caller is at the namespace root */ if (CallerOp) { CallerFullPathname = AcpiNsGetNormalizedPathname ( CallerOp->Asl.Node, TRUE); } - else - { - CallerFullPathname = ""; - } - if (CallerOp == XrefInfo->CurrentMethodOp) - { - return (AE_OK); - } + /* There are some special cases for the oddball operators */ if (Op->Asl.ParseOpcode == PARSEOP_SCOPE) { Operator = "Scope"; - } else if (Op->Asl.Parent->Asl.ParseOpcode == PARSEOP_ALIAS) { @@ -794,7 +793,7 @@ OtXrefAnalysisWalkPart3 ( FlPrintFile (ASL_FILE_XREF_OUTPUT, "[%5u] %-40s %-8s via path: %s, Operator: %s\n", Op->Asl.LogicalLineNumber, - CallerFullPathname, + CallerFullPathname ? CallerFullPathname : "", Operator, Op->Asl.ExternalName, Op->Asl.Parent->Asl.ParseOpName); @@ -804,6 +803,11 @@ OtXrefAnalysisWalkPart3 ( CallerOp = ACPI_TO_POINTER (0xFFFFFFFF); } + if (CallerFullPathname) + { + ACPI_FREE (CallerFullPathname); + } + XrefInfo->CurrentMethodOp = CallerOp; XrefInfo->ThisObjectReferences++; return (AE_OK); diff --git a/source/compiler/dtparser.y b/source/compiler/dtparser.y index fbd424a..233aa96 100644 --- a/source/compiler/dtparser.y +++ b/source/compiler/dtparser.y @@ -169,15 +169,15 @@ Expression /* Default base for a non-prefixed integer is 16 */ - | EXPOP_NUMBER { AcpiUtStrtoul64 (DtParsertext, 16, &$$);} + | EXPOP_NUMBER { AcpiUtStrtoul64 (DtParsertext, 16, ACPI_MAX64_BYTE_WIDTH, &$$);} /* Standard hex number (0x1234) */ - | EXPOP_HEX_NUMBER { AcpiUtStrtoul64 (DtParsertext, 16, &$$);} + | EXPOP_HEX_NUMBER { AcpiUtStrtoul64 (DtParsertext, 16, ACPI_MAX64_BYTE_WIDTH, &$$);} /* TBD: Decimal number with prefix (0d1234) - Not supported by strtoul64 at this time */ - | EXPOP_DECIMAL_NUMBER { AcpiUtStrtoul64 (DtParsertext, 10, &$$);} + | EXPOP_DECIMAL_NUMBER { AcpiUtStrtoul64 (DtParsertext, 10, ACPI_MAX64_BYTE_WIDTH, &$$);} ; %% diff --git a/source/compiler/dttable1.c b/source/compiler/dttable1.c index 353d84a..a79d33b 100644 --- a/source/compiler/dttable1.c +++ b/source/compiler/dttable1.c @@ -1243,8 +1243,8 @@ DtCompileIort ( DtInsertSubtable (ParentTable, Subtable); /* - * Using ACPI_SUB_PTR, We needn't define a seperate structure. Care - * should be taken to avoid accessing ACPI_TABLE_HADER fields. + * Using ACPI_SUB_PTR, We needn't define a separate structure. Care + * should be taken to avoid accessing ACPI_TABLE_HEADER fields. */ Iort = ACPI_SUB_PTR (ACPI_TABLE_IORT, Subtable->Buffer, sizeof (ACPI_TABLE_HEADER)); @@ -1475,6 +1475,19 @@ DtCompileIort ( IortSmmu->PmuInterruptCount = PmuIrptNumber; break; + case ACPI_IORT_NODE_SMMU_V3: + + Status = DtCompileTable (PFieldList, AcpiDmTableInfoIort4, + &Subtable, TRUE); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + DtInsertSubtable (ParentTable, Subtable); + NodeLength += Subtable->Length; + break; + default: DtFatal (ASL_MSG_UNKNOWN_SUBTABLE, SubtableStart, "IORT"); diff --git a/source/compiler/dttable2.c b/source/compiler/dttable2.c index 9ebe3e5..65be505 100644 --- a/source/compiler/dttable2.c +++ b/source/compiler/dttable2.c @@ -976,7 +976,7 @@ DtCompileS3pt ( DT_FIELD **PFieldList) { ACPI_STATUS Status; - ACPI_S3PT_HEADER *S3ptHeader; + ACPI_FPDT_HEADER *S3ptHeader; DT_SUBTABLE *Subtable; DT_SUBTABLE *ParentTable; ACPI_DMTABLE_INFO *InfoTable; @@ -1006,7 +1006,7 @@ DtCompileS3pt ( DtInsertSubtable (ParentTable, Subtable); DtPushSubtable (Subtable); - S3ptHeader = ACPI_CAST_PTR (ACPI_S3PT_HEADER, Subtable->Buffer); + S3ptHeader = ACPI_CAST_PTR (ACPI_FPDT_HEADER, Subtable->Buffer); switch (S3ptHeader->Type) { diff --git a/source/compiler/dttemplate.h b/source/compiler/dttemplate.h index c93b761..93747fc 100644 --- a/source/compiler/dttemplate.h +++ b/source/compiler/dttemplate.h @@ -543,11 +543,11 @@ const unsigned char TemplateHpet[] = const unsigned char TemplateIort[] = { - 0x49,0x4F,0x52,0x54,0x0C,0x01,0x00,0x00, /* 00000000 "IORT...." */ - 0x00,0xBC,0x49,0x4E,0x54,0x45,0x4C,0x20, /* 00000008 "..INTEL " */ + 0x49,0x4F,0x52,0x54,0x48,0x01,0x00,0x00, /* 00000000 "IORTH..." */ + 0x00,0x02,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" */ - 0x10,0x04,0x15,0x20,0x04,0x00,0x00,0x00, /* 00000020 "... ...." */ + 0x12,0x02,0x16,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 "........" */ @@ -576,7 +576,14 @@ const unsigned char TemplateIort[] = 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, /* 00000100 "........" */ - 0x00,0x00,0x00,0x00 /* 00000108 "...." */ + 0x00,0x00,0x00,0x00,0x04,0x3C,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, /* 00000138 "........" */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 /* 00000140 "........" */ }; const unsigned char TemplateIvrs[] = diff --git a/source/compiler/prparser.y b/source/compiler/prparser.y index ba2dc55..d2f8405 100644 --- a/source/compiler/prparser.y +++ b/source/compiler/prparser.y @@ -182,11 +182,11 @@ Expression /* Default base for a non-prefixed integer is 10 */ - | EXPOP_NUMBER { AcpiUtStrtoul64 (PrParsertext, 10, &$$);} + | EXPOP_NUMBER { AcpiUtStrtoul64 (PrParsertext, 10, ACPI_MAX64_BYTE_WIDTH, &$$);} /* Standard hex number (0x1234) */ - | EXPOP_HEX_NUMBER { AcpiUtStrtoul64 (PrParsertext, 16, &$$);} + | EXPOP_HEX_NUMBER { AcpiUtStrtoul64 (PrParsertext, 16, ACPI_MAX64_BYTE_WIDTH, &$$);} ; %% diff --git a/source/compiler/prscan.c b/source/compiler/prscan.c index 8a4f241..b24b319 100644 --- a/source/compiler/prscan.c +++ b/source/compiler/prscan.c @@ -919,6 +919,17 @@ PrGetNextLine ( c = getc (Handle); if (c == EOF) { + /* + * On EOF: If there is anything in the line buffer, terminate + * it with a newline, and catch the EOF on the next call + * to this function. + */ + if (i > 0) + { + Gbl_CurrentLineBuffer[i] = '\n'; + return (AE_OK); + } + return (ASL_EOF); } diff --git a/source/components/debugger/dbconvert.c b/source/components/debugger/dbconvert.c index 01cb37a..47d2889 100644 --- a/source/components/debugger/dbconvert.c +++ b/source/components/debugger/dbconvert.c @@ -321,7 +321,8 @@ AcpiDbConvertToObject ( default: Object->Type = ACPI_TYPE_INTEGER; - Status = AcpiUtStrtoul64 (String, 16, &Object->Integer.Value); + Status = AcpiUtStrtoul64 (String, 16, AcpiGbl_IntegerByteWidth, + &Object->Integer.Value); break; } diff --git a/source/components/debugger/dbinput.c b/source/components/debugger/dbinput.c index 06d066c..9a71beb 100644 --- a/source/components/debugger/dbinput.c +++ b/source/components/debugger/dbinput.c @@ -69,7 +69,7 @@ AcpiDbSingleThread ( static void AcpiDbDisplayCommandInfo ( - char *Command, + const char *Command, BOOLEAN DisplayAll); static void @@ -78,7 +78,7 @@ AcpiDbDisplayHelp ( static BOOLEAN AcpiDbMatchCommandHelp ( - char *Command, + const char *Command, const ACPI_DB_COMMAND_HELP *Help); @@ -358,7 +358,7 @@ static const ACPI_DB_COMMAND_HELP AcpiGbl_DbCommandHelp[] = static BOOLEAN AcpiDbMatchCommandHelp ( - char *Command, + const char *Command, const ACPI_DB_COMMAND_HELP *Help) { char *Invocation = Help->Invocation; @@ -420,7 +420,7 @@ AcpiDbMatchCommandHelp ( static void AcpiDbDisplayCommandInfo ( - char *Command, + const char *Command, BOOLEAN DisplayAll) { const ACPI_DB_COMMAND_HELP *Next; @@ -720,7 +720,8 @@ AcpiDbMatchCommand ( for (i = CMD_FIRST_VALID; AcpiGbl_DbCommands[i].Name; i++) { - if (strstr (AcpiGbl_DbCommands[i].Name, UserCommand) == + if (strstr ( + ACPI_CAST_PTR (char, AcpiGbl_DbCommands[i].Name), UserCommand) == AcpiGbl_DbCommands[i].Name) { return (i); diff --git a/source/components/debugger/dbutils.c b/source/components/debugger/dbutils.c index 4cabc8b..ad242fa 100644 --- a/source/components/debugger/dbutils.c +++ b/source/components/debugger/dbutils.c @@ -63,8 +63,6 @@ AcpiDbDumpBuffer ( UINT32 Address); #endif -static char *Gbl_HexToAscii = "0123456789ABCDEF"; - /******************************************************************************* * @@ -94,7 +92,9 @@ AcpiDbMatchArgument ( for (i = 0; Arguments[i].Name; i++) { - if (strstr (Arguments[i].Name, UserArgument) == Arguments[i].Name) + if (strstr ( + ACPI_CAST_PTR (char, Arguments[i].Name), + ACPI_CAST_PTR (char, UserArgument)) == Arguments[i].Name) { return (i); } @@ -386,7 +386,7 @@ AcpiDbUint32ToHexString ( for (i = 7; i >= 0; i--) { - Buffer[i] = Gbl_HexToAscii [Value & 0x0F]; + Buffer[i] = AcpiGbl_UpperHexDigits [Value & 0x0F]; Value = Value >> 4; } } diff --git a/source/components/disassembler/dmbuffer.c b/source/components/disassembler/dmbuffer.c index f8fdbaa..79c37e2 100644 --- a/source/components/disassembler/dmbuffer.c +++ b/source/components/disassembler/dmbuffer.c @@ -73,53 +73,13 @@ AcpiDmPldBuffer ( UINT8 *ByteData, UINT32 ByteCount); +static const char * +AcpiDmFindNameByIndex ( + UINT64 Index, + const char **List); -#define ACPI_BUFFER_BYTES_PER_LINE 8 - - -/* Strings for ToPld */ - -static char *DmPanelList[] = -{ - "TOP", - "BOTTOM", - "LEFT", - "RIGHT", - "FRONT", - "BACK", - "UNKNOWN", - NULL -}; - -static char *DmVerticalPositionList[] = -{ - "UPPER", - "CENTER", - "LOWER", - NULL -}; - -static char *DmHorizontalPositionList[] = -{ - "LEFT", - "CENTER", - "RIGHT", - NULL -}; -static char *DmShapeList[] = -{ - "ROUND", - "OVAL", - "SQUARE", - "VERTICALRECTANGLE", - "HORIZONTALRECTANGLE", - "VERTICALTRAPEZOID", - "HORIZONTALTRAPEZOID", - "UNKNOWN", - "CHAMFERED", - NULL -}; +#define ACPI_BUFFER_BYTES_PER_LINE 8 /******************************************************************************* @@ -653,24 +613,24 @@ AcpiDmIsPldBuffer ( * ******************************************************************************/ -static char * +static const char * AcpiDmFindNameByIndex ( UINT64 Index, - char **List) + const char **List) { - char *Str; - UINT32 i; + const char *NameString; + UINT32 i; /* Bounds check */ - Str = List[0]; + NameString = List[0]; i = 0; - while(Str) + while (NameString) { i++; - Str = List[i]; + NameString = List[i]; } if (Index >= i) @@ -698,12 +658,12 @@ AcpiDmFindNameByIndex ( * ******************************************************************************/ -#define ACPI_PLD_OUTPUT08 "%*.s%-18s = 0x%X,\n", ACPI_MUL_4 (Level), " " -#define ACPI_PLD_OUTPUT08P "%*.s%-18s = 0x%X)\n", ACPI_MUL_4 (Level), " " -#define ACPI_PLD_OUTPUT16 "%*.s%-18s = 0x%X,\n", ACPI_MUL_4 (Level), " " -#define ACPI_PLD_OUTPUT16P "%*.s%-18s = 0x%X)\n", ACPI_MUL_4 (Level), " " -#define ACPI_PLD_OUTPUT24 "%*.s%-18s = 0x%X,\n", ACPI_MUL_4 (Level), " " -#define ACPI_PLD_OUTPUTSTR "%*.s%-18s = \"%s\",\n", ACPI_MUL_4 (Level), " " +#define ACPI_PLD_OUTPUT08 "%*.s%-22s = 0x%X,\n", ACPI_MUL_4 (Level), " " +#define ACPI_PLD_OUTPUT08P "%*.s%-22s = 0x%X)\n", ACPI_MUL_4 (Level), " " +#define ACPI_PLD_OUTPUT16 "%*.s%-22s = 0x%X,\n", ACPI_MUL_4 (Level), " " +#define ACPI_PLD_OUTPUT16P "%*.s%-22s = 0x%X)\n", ACPI_MUL_4 (Level), " " +#define ACPI_PLD_OUTPUT24 "%*.s%-22s = 0x%X,\n", ACPI_MUL_4 (Level), " " +#define ACPI_PLD_OUTPUTSTR "%*.s%-22s = \"%s\",\n", ACPI_MUL_4 (Level), " " static void AcpiDmPldBuffer ( @@ -751,16 +711,16 @@ AcpiDmPldBuffer ( AcpiOsPrintf (ACPI_PLD_OUTPUT08, "PLD_Dock", PldInfo->Dock); AcpiOsPrintf (ACPI_PLD_OUTPUT08, "PLD_Lid", PldInfo->Lid); AcpiOsPrintf (ACPI_PLD_OUTPUTSTR, "PLD_Panel", - AcpiDmFindNameByIndex(PldInfo->Panel, DmPanelList)); + AcpiDmFindNameByIndex(PldInfo->Panel, AcpiGbl_PldPanelList)); AcpiOsPrintf (ACPI_PLD_OUTPUTSTR, "PLD_VerticalPosition", - AcpiDmFindNameByIndex(PldInfo->VerticalPosition, DmVerticalPositionList)); + AcpiDmFindNameByIndex(PldInfo->VerticalPosition, AcpiGbl_PldVerticalPositionList)); AcpiOsPrintf (ACPI_PLD_OUTPUTSTR, "PLD_HorizontalPosition", - AcpiDmFindNameByIndex(PldInfo->HorizontalPosition, DmHorizontalPositionList)); + AcpiDmFindNameByIndex(PldInfo->HorizontalPosition, AcpiGbl_PldHorizontalPositionList)); AcpiOsPrintf (ACPI_PLD_OUTPUTSTR, "PLD_Shape", - AcpiDmFindNameByIndex(PldInfo->Shape, DmShapeList)); + AcpiDmFindNameByIndex(PldInfo->Shape, AcpiGbl_PldShapeList)); AcpiOsPrintf (ACPI_PLD_OUTPUT08, "PLD_GroupOrientation", PldInfo->GroupOrientation); AcpiOsPrintf (ACPI_PLD_OUTPUT08, "PLD_GroupToken", PldInfo->GroupToken); diff --git a/source/components/disassembler/dmopcode.c b/source/components/disassembler/dmopcode.c index 20d7ce5..8f163ca 100644 --- a/source/components/disassembler/dmopcode.c +++ b/source/components/disassembler/dmopcode.c @@ -646,8 +646,8 @@ AcpiDmMatchKeyword ( } else { - AcpiOsPrintf ("%s", ACPI_CAST_PTR (char, - AcpiGbl_MatchOps[(ACPI_SIZE) Op->Common.Value.Integer])); + AcpiOsPrintf ("%s", + AcpiGbl_MatchOps[(ACPI_SIZE) Op->Common.Value.Integer]); } } diff --git a/source/components/disassembler/dmresrc.c b/source/components/disassembler/dmresrc.c index 8bfab99..a486f1d 100644 --- a/source/components/disassembler/dmresrc.c +++ b/source/components/disassembler/dmresrc.c @@ -145,7 +145,7 @@ AcpiDmDescriptorName ( void AcpiDmDumpInteger8 ( UINT8 Value, - char *Name) + const char *Name) { AcpiOsPrintf ("0x%2.2X, // %s\n", Value, Name); } @@ -153,7 +153,7 @@ AcpiDmDumpInteger8 ( void AcpiDmDumpInteger16 ( UINT16 Value, - char *Name) + const char *Name) { AcpiOsPrintf ("0x%4.4X, // %s\n", Value, Name); } @@ -161,7 +161,7 @@ AcpiDmDumpInteger16 ( void AcpiDmDumpInteger32 ( UINT32 Value, - char *Name) + const char *Name) { AcpiOsPrintf ("0x%8.8X, // %s\n", Value, Name); } @@ -169,7 +169,7 @@ AcpiDmDumpInteger32 ( void AcpiDmDumpInteger64 ( UINT64 Value, - char *Name) + const char *Name) { AcpiOsPrintf ("0x%8.8X%8.8X, // %s\n", ACPI_FORMAT_UINT64 (Value), Name); } diff --git a/source/components/disassembler/dmresrcl.c b/source/components/disassembler/dmresrcl.c index 89071c6..52fd335 100644 --- a/source/components/disassembler/dmresrcl.c +++ b/source/components/disassembler/dmresrcl.c @@ -52,7 +52,7 @@ /* Common names for address and memory descriptors */ -static char *AcpiDmAddressNames[] = +static const char *AcpiDmAddressNames[] = { "Granularity", "Range Minimum", @@ -61,7 +61,7 @@ static char *AcpiDmAddressNames[] = "Length" }; -static char *AcpiDmMemoryNames[] = +static const char *AcpiDmMemoryNames[] = { "Range Minimum", "Range Maximum", @@ -1028,7 +1028,7 @@ AcpiDmInterruptDescriptor ( void AcpiDmVendorCommon ( - char *Name, + const char *Name, UINT8 *ByteData, UINT32 Length, UINT32 Level) diff --git a/source/components/disassembler/dmutils.c b/source/components/disassembler/dmutils.c index 9e2371b..2a82e1e 100644 --- a/source/components/disassembler/dmutils.c +++ b/source/components/disassembler/dmutils.c @@ -227,7 +227,7 @@ AcpiDmIndent ( return; } - AcpiOsPrintf ("%*.s", ACPI_MUL_4 (Level), " "); + AcpiOsPrintf ("%*.s", (Level * 4), " "); } diff --git a/source/components/events/evregion.c b/source/components/events/evregion.c index 0853a32..673d44d 100644 --- a/source/components/events/evregion.c +++ b/source/components/events/evregion.c @@ -551,58 +551,6 @@ AcpiEvAttachRegion ( /******************************************************************************* * - * FUNCTION: AcpiEvAssociateRegMethod - * - * PARAMETERS: RegionObj - Region object - * - * RETURN: Status - * - * DESCRIPTION: Find and associate _REG method to a region - * - ******************************************************************************/ - -void -AcpiEvAssociateRegMethod ( - ACPI_OPERAND_OBJECT *RegionObj) -{ - ACPI_NAME *RegNamePtr = (ACPI_NAME *) METHOD_NAME__REG; - ACPI_NAMESPACE_NODE *MethodNode; - ACPI_NAMESPACE_NODE *Node; - ACPI_OPERAND_OBJECT *RegionObj2; - ACPI_STATUS Status; - - - ACPI_FUNCTION_TRACE (EvAssociateRegMethod); - - - RegionObj2 = AcpiNsGetSecondaryObject (RegionObj); - if (!RegionObj2) - { - return_VOID; - } - - Node = RegionObj->Region.Node->Parent; - - /* Find any "_REG" method associated with this region definition */ - - Status = AcpiNsSearchOneScope ( - *RegNamePtr, Node, ACPI_TYPE_METHOD, &MethodNode); - if (ACPI_SUCCESS (Status)) - { - /* - * The _REG method is optional and there can be only one per region - * definition. This will be executed when the handler is attached - * or removed - */ - RegionObj2->Extra.Method_REG = MethodNode; - } - - return_VOID; -} - - -/******************************************************************************* - * * FUNCTION: AcpiEvExecuteRegMethod * * PARAMETERS: RegionObj - Region object @@ -622,21 +570,45 @@ AcpiEvExecuteRegMethod ( ACPI_EVALUATE_INFO *Info; ACPI_OPERAND_OBJECT *Args[3]; ACPI_OPERAND_OBJECT *RegionObj2; + const ACPI_NAME *RegNamePtr = ACPI_CAST_PTR (ACPI_NAME, METHOD_NAME__REG); + ACPI_NAMESPACE_NODE *MethodNode; + ACPI_NAMESPACE_NODE *Node; ACPI_STATUS Status; ACPI_FUNCTION_TRACE (EvExecuteRegMethod); + if (!AcpiGbl_NamespaceInitialized || + RegionObj->Region.Handler == NULL) + { + return_ACPI_STATUS (AE_OK); + } + RegionObj2 = AcpiNsGetSecondaryObject (RegionObj); if (!RegionObj2) { return_ACPI_STATUS (AE_NOT_EXIST); } - if (RegionObj2->Extra.Method_REG == NULL || - RegionObj->Region.Handler == NULL || - !AcpiGbl_NamespaceInitialized) + /* + * Find any "_REG" method associated with this region definition. + * The method should always be updated as this function may be + * invoked after a namespace change. + */ + Node = RegionObj->Region.Node->Parent; + Status = AcpiNsSearchOneScope ( + *RegNamePtr, Node, ACPI_TYPE_METHOD, &MethodNode); + if (ACPI_SUCCESS (Status)) + { + /* + * The _REG method is optional and there can be only one per + * region definition. This will be executed when the handler is + * attached or removed. + */ + RegionObj2->Extra.Method_REG = MethodNode; + } + if (RegionObj2->Extra.Method_REG == NULL) { return_ACPI_STATUS (AE_OK); } diff --git a/source/components/events/evrgnini.c b/source/components/events/evrgnini.c index 5bb177a..a9e6be0 100644 --- a/source/components/events/evrgnini.c +++ b/source/components/events/evrgnini.c @@ -582,7 +582,6 @@ AcpiEvInitializeRegion ( return_ACPI_STATUS (AE_OK); } - AcpiEvAssociateRegMethod (RegionObj); RegionObj->Common.Flags |= AOPOBJ_OBJECT_INITIALIZED; Node = RegionObj->Region.Node->Parent; diff --git a/source/components/executer/exconcat.c b/source/components/executer/exconcat.c new file mode 100644 index 0000000..49b279a --- /dev/null +++ b/source/components/executer/exconcat.c @@ -0,0 +1,460 @@ +/****************************************************************************** + * + * Module Name: exconcat - Concatenate-type AML operators + * + *****************************************************************************/ + +/* + * Copyright (C) 2000 - 2016, Intel Corp. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions, and the following disclaimer, + * without modification. + * 2. Redistributions in binary form must reproduce at minimum a disclaimer + * substantially similar to the "NO WARRANTY" disclaimer below + * ("Disclaimer") and any redistribution must be conditioned upon + * including a substantially similar Disclaimer requirement for further + * binary redistribution. + * 3. Neither the names of the above-listed copyright holders nor the names + * of any contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * Alternatively, this software may be distributed under the terms of the + * GNU General Public License ("GPL") version 2 as published by the Free + * Software Foundation. + * + * NO WARRANTY + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING + * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGES. + */ + +#include "acpi.h" +#include "accommon.h" +#include "acinterp.h" +#include "amlresrc.h" + + +#define _COMPONENT ACPI_EXECUTER + ACPI_MODULE_NAME ("exconcat") + +/* Local Prototypes */ + +static ACPI_STATUS +AcpiExConvertToObjectTypeString ( + ACPI_OPERAND_OBJECT *ObjDesc, + ACPI_OPERAND_OBJECT **ResultDesc); + + +/******************************************************************************* + * + * FUNCTION: AcpiExDoConcatenate + * + * PARAMETERS: Operand0 - First source object + * Operand1 - Second source object + * ActualReturnDesc - Where to place the return object + * WalkState - Current walk state + * + * RETURN: Status + * + * DESCRIPTION: Concatenate two objects with the ACPI-defined conversion + * rules as necessary. + * NOTE: + * Per the ACPI spec (up to 6.1), Concatenate only supports Integer, + * String, and Buffer objects. However, we support all objects here + * as an extension. This improves the usefulness of both Concatenate + * and the Printf/Fprintf macros. The extension returns a string + * describing the object type for the other objects. + * 02/2016. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiExDoConcatenate ( + ACPI_OPERAND_OBJECT *Operand0, + ACPI_OPERAND_OBJECT *Operand1, + ACPI_OPERAND_OBJECT **ActualReturnDesc, + ACPI_WALK_STATE *WalkState) +{ + ACPI_OPERAND_OBJECT *LocalOperand0 = Operand0; + ACPI_OPERAND_OBJECT *LocalOperand1 = Operand1; + ACPI_OPERAND_OBJECT *TempOperand1 = NULL; + ACPI_OPERAND_OBJECT *ReturnDesc; + char *Buffer; + ACPI_OBJECT_TYPE Operand0Type; + ACPI_OBJECT_TYPE Operand1Type; + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE (ExDoConcatenate); + + + /* Operand 0 preprocessing */ + + switch (Operand0->Common.Type) + { + case ACPI_TYPE_INTEGER: + case ACPI_TYPE_STRING: + case ACPI_TYPE_BUFFER: + + Operand0Type = Operand0->Common.Type; + break; + + default: + + /* For all other types, get the "object type" string */ + + Status = AcpiExConvertToObjectTypeString ( + Operand0, &LocalOperand0); + if (ACPI_FAILURE (Status)) + { + goto Cleanup; + } + + Operand0Type = ACPI_TYPE_STRING; + break; + } + + /* Operand 1 preprocessing */ + + switch (Operand1->Common.Type) + { + case ACPI_TYPE_INTEGER: + case ACPI_TYPE_STRING: + case ACPI_TYPE_BUFFER: + + Operand1Type = Operand1->Common.Type; + break; + + default: + + /* For all other types, get the "object type" string */ + + Status = AcpiExConvertToObjectTypeString ( + Operand1, &LocalOperand1); + if (ACPI_FAILURE (Status)) + { + goto Cleanup; + } + + Operand1Type = ACPI_TYPE_STRING; + break; + } + + /* + * Convert the second operand if necessary. The first operand (0) + * determines the type of the second operand (1) (See the Data Types + * section of the ACPI specification). Both object types are + * guaranteed to be either Integer/String/Buffer by the operand + * resolution mechanism. + */ + switch (Operand0Type) + { + case ACPI_TYPE_INTEGER: + + Status = AcpiExConvertToInteger (LocalOperand1, &TempOperand1, 16); + break; + + case ACPI_TYPE_BUFFER: + + Status = AcpiExConvertToBuffer (LocalOperand1, &TempOperand1); + break; + + case ACPI_TYPE_STRING: + + switch (Operand1Type) + { + case ACPI_TYPE_INTEGER: + case ACPI_TYPE_STRING: + case ACPI_TYPE_BUFFER: + + /* Other types have already been converted to string */ + + Status = AcpiExConvertToString ( + LocalOperand1, &TempOperand1, ACPI_IMPLICIT_CONVERT_HEX); + break; + + default: + + Status = AE_OK; + break; + } + break; + + default: + + ACPI_ERROR ((AE_INFO, "Invalid object type: 0x%X", + Operand0->Common.Type)); + Status = AE_AML_INTERNAL; + } + + if (ACPI_FAILURE (Status)) + { + goto Cleanup; + } + + /* Take care with any newly created operand objects */ + + if ((LocalOperand1 != Operand1) && + (LocalOperand1 != TempOperand1)) + { + AcpiUtRemoveReference (LocalOperand1); + } + + LocalOperand1 = TempOperand1; + + /* + * Both operands are now known to be the same object type + * (Both are Integer, String, or Buffer), and we can now perform + * the concatenation. + * + * There are three cases to handle, as per the ACPI spec: + * + * 1) Two Integers concatenated to produce a new Buffer + * 2) Two Strings concatenated to produce a new String + * 3) Two Buffers concatenated to produce a new Buffer + */ + switch (Operand0Type) + { + case ACPI_TYPE_INTEGER: + + /* Result of two Integers is a Buffer */ + /* Need enough buffer space for two integers */ + + ReturnDesc = AcpiUtCreateBufferObject ( + (ACPI_SIZE) ACPI_MUL_2 (AcpiGbl_IntegerByteWidth)); + if (!ReturnDesc) + { + Status = AE_NO_MEMORY; + goto Cleanup; + } + + Buffer = (char *) ReturnDesc->Buffer.Pointer; + + /* Copy the first integer, LSB first */ + + memcpy (Buffer, &Operand0->Integer.Value, + AcpiGbl_IntegerByteWidth); + + /* Copy the second integer (LSB first) after the first */ + + memcpy (Buffer + AcpiGbl_IntegerByteWidth, + &LocalOperand1->Integer.Value, AcpiGbl_IntegerByteWidth); + break; + + case ACPI_TYPE_STRING: + + /* Result of two Strings is a String */ + + ReturnDesc = AcpiUtCreateStringObject ( + ((ACPI_SIZE) LocalOperand0->String.Length + + LocalOperand1->String.Length)); + if (!ReturnDesc) + { + Status = AE_NO_MEMORY; + goto Cleanup; + } + + Buffer = ReturnDesc->String.Pointer; + + /* Concatenate the strings */ + + strcpy (Buffer, LocalOperand0->String.Pointer); + strcat (Buffer, LocalOperand1->String.Pointer); + break; + + case ACPI_TYPE_BUFFER: + + /* Result of two Buffers is a Buffer */ + + ReturnDesc = AcpiUtCreateBufferObject ( + ((ACPI_SIZE) Operand0->Buffer.Length + + LocalOperand1->Buffer.Length)); + if (!ReturnDesc) + { + Status = AE_NO_MEMORY; + goto Cleanup; + } + + Buffer = (char *) ReturnDesc->Buffer.Pointer; + + /* Concatenate the buffers */ + + memcpy (Buffer, Operand0->Buffer.Pointer, + Operand0->Buffer.Length); + memcpy (Buffer + Operand0->Buffer.Length, + LocalOperand1->Buffer.Pointer, + LocalOperand1->Buffer.Length); + break; + + default: + + /* Invalid object type, should not happen here */ + + ACPI_ERROR ((AE_INFO, "Invalid object type: 0x%X", + Operand0->Common.Type)); + Status = AE_AML_INTERNAL; + goto Cleanup; + } + + *ActualReturnDesc = ReturnDesc; + +Cleanup: + if (LocalOperand0 != Operand0) + { + AcpiUtRemoveReference (LocalOperand0); + } + + if (LocalOperand1 != Operand1) + { + AcpiUtRemoveReference (LocalOperand1); + } + + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiExConvertToObjectTypeString + * + * PARAMETERS: ObjDesc - Object to be converted + * ReturnDesc - Where to place the return object + * + * RETURN: Status + * + * DESCRIPTION: Convert an object of arbitrary type to a string object that + * contains the namestring for the object. Used for the + * concatenate operator. + * + ******************************************************************************/ + +static ACPI_STATUS +AcpiExConvertToObjectTypeString ( + ACPI_OPERAND_OBJECT *ObjDesc, + ACPI_OPERAND_OBJECT **ResultDesc) +{ + ACPI_OPERAND_OBJECT *ReturnDesc; + const char *TypeString; + + + TypeString = AcpiUtGetTypeName (ObjDesc->Common.Type); + + ReturnDesc = AcpiUtCreateStringObject ( + ((ACPI_SIZE) strlen (TypeString) + 9)); /* 9 For "[ Object]" */ + if (!ReturnDesc) + { + return (AE_NO_MEMORY); + } + + strcpy (ReturnDesc->String.Pointer, "["); + strcat (ReturnDesc->String.Pointer, TypeString); + strcat (ReturnDesc->String.Pointer, " Object]"); + + *ResultDesc = ReturnDesc; + return (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiExConcatTemplate + * + * PARAMETERS: Operand0 - First source object + * Operand1 - Second source object + * ActualReturnDesc - Where to place the return object + * WalkState - Current walk state + * + * RETURN: Status + * + * DESCRIPTION: Concatenate two resource templates + * + ******************************************************************************/ + +ACPI_STATUS +AcpiExConcatTemplate ( + ACPI_OPERAND_OBJECT *Operand0, + ACPI_OPERAND_OBJECT *Operand1, + ACPI_OPERAND_OBJECT **ActualReturnDesc, + ACPI_WALK_STATE *WalkState) +{ + ACPI_STATUS Status; + ACPI_OPERAND_OBJECT *ReturnDesc; + UINT8 *NewBuf; + UINT8 *EndTag; + ACPI_SIZE Length0; + ACPI_SIZE Length1; + ACPI_SIZE NewLength; + + + ACPI_FUNCTION_TRACE (ExConcatTemplate); + + + /* + * Find the EndTag descriptor in each resource template. + * Note1: returned pointers point TO the EndTag, not past it. + * Note2: zero-length buffers are allowed; treated like one EndTag + */ + + /* Get the length of the first resource template */ + + Status = AcpiUtGetResourceEndTag (Operand0, &EndTag); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + Length0 = ACPI_PTR_DIFF (EndTag, Operand0->Buffer.Pointer); + + /* Get the length of the second resource template */ + + Status = AcpiUtGetResourceEndTag (Operand1, &EndTag); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + Length1 = ACPI_PTR_DIFF (EndTag, Operand1->Buffer.Pointer); + + /* Combine both lengths, minimum size will be 2 for EndTag */ + + NewLength = Length0 + Length1 + sizeof (AML_RESOURCE_END_TAG); + + /* Create a new buffer object for the result (with one EndTag) */ + + ReturnDesc = AcpiUtCreateBufferObject (NewLength); + if (!ReturnDesc) + { + return_ACPI_STATUS (AE_NO_MEMORY); + } + + /* + * Copy the templates to the new buffer, 0 first, then 1 follows. One + * EndTag descriptor is copied from Operand1. + */ + NewBuf = ReturnDesc->Buffer.Pointer; + memcpy (NewBuf, Operand0->Buffer.Pointer, Length0); + memcpy (NewBuf + Length0, Operand1->Buffer.Pointer, Length1); + + /* Insert EndTag and set the checksum to zero, means "ignore checksum" */ + + NewBuf[NewLength - 1] = 0; + NewBuf[NewLength - 2] = ACPI_RESOURCE_NAME_END_TAG | 1; + + /* Return the completed resource template */ + + *ActualReturnDesc = ReturnDesc; + return_ACPI_STATUS (AE_OK); +} diff --git a/source/components/executer/exconfig.c b/source/components/executer/exconfig.c index 7a78e3c..bb0d2bb 100644 --- a/source/components/executer/exconfig.c +++ b/source/components/executer/exconfig.c @@ -129,7 +129,10 @@ AcpiExAddTable ( /* Execute any module-level code that was found in the table */ AcpiExExitInterpreter (); - AcpiNsExecModuleCodeList (); + if (AcpiGbl_GroupModuleLevelCode) + { + AcpiNsExecModuleCodeList (); + } AcpiExEnterInterpreter (); /* diff --git a/source/components/executer/exconvrt.c b/source/components/executer/exconvrt.c index 6f756d7..ea6f826 100644 --- a/source/components/executer/exconvrt.c +++ b/source/components/executer/exconvrt.c @@ -137,7 +137,8 @@ AcpiExConvertToInteger ( * of ACPI 3.0) is that the ToInteger() operator allows both decimal * and hexadecimal strings (hex prefixed with "0x"). */ - Status = AcpiUtStrtoul64 ((char *) Pointer, Flags, &Result); + Status = AcpiUtStrtoul64 ((char *) Pointer, Flags, + AcpiGbl_IntegerByteWidth, &Result); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); diff --git a/source/components/executer/exdump.c b/source/components/executer/exdump.c index 5dae1f4..f5d5fd0 100644 --- a/source/components/executer/exdump.c +++ b/source/components/executer/exdump.c @@ -60,13 +60,13 @@ static void AcpiExOutString ( - char *Title, - char *Value); + const char *Title, + const char *Value); static void AcpiExOutPointer ( - char *Title, - void *Value); + const char *Title, + const void *Value); static void AcpiExDumpObject ( @@ -380,8 +380,7 @@ AcpiExDumpObject ( ACPI_EXDUMP_INFO *Info) { UINT8 *Target; - char *Name; - const char *ReferenceName; + const char *Name; UINT8 Count; ACPI_OPERAND_OBJECT *Start; ACPI_OPERAND_OBJECT *Data = NULL; @@ -472,9 +471,7 @@ AcpiExDumpObject ( case ACPI_EXD_REFERENCE: - ReferenceName = AcpiUtGetReferenceName (ObjDesc); - AcpiExOutString ( - "Class Name", ACPI_CAST_PTR (char, ReferenceName)); + AcpiExOutString ("Class Name", AcpiUtGetReferenceName (ObjDesc)); AcpiExDumpReferenceObj (ObjDesc); break; @@ -971,16 +968,16 @@ AcpiExDumpOperands ( static void AcpiExOutString ( - char *Title, - char *Value) + const char *Title, + const char *Value) { AcpiOsPrintf ("%20s : %s\n", Title, Value); } static void AcpiExOutPointer ( - char *Title, - void *Value) + const char *Title, + const void *Value) { AcpiOsPrintf ("%20s : %p\n", Title, Value); } diff --git a/source/components/executer/exmisc.c b/source/components/executer/exmisc.c index c1dd227..a8e5497 100644 --- a/source/components/executer/exmisc.c +++ b/source/components/executer/exmisc.c @@ -45,7 +45,6 @@ #include "accommon.h" #include "acinterp.h" #include "amlcode.h" -#include "amlresrc.h" #define _COMPONENT ACPI_EXECUTER @@ -150,307 +149,6 @@ AcpiExGetObjectReference ( /******************************************************************************* * - * FUNCTION: AcpiExConcatTemplate - * - * PARAMETERS: Operand0 - First source object - * Operand1 - Second source object - * ActualReturnDesc - Where to place the return object - * WalkState - Current walk state - * - * RETURN: Status - * - * DESCRIPTION: Concatenate two resource templates - * - ******************************************************************************/ - -ACPI_STATUS -AcpiExConcatTemplate ( - ACPI_OPERAND_OBJECT *Operand0, - ACPI_OPERAND_OBJECT *Operand1, - ACPI_OPERAND_OBJECT **ActualReturnDesc, - ACPI_WALK_STATE *WalkState) -{ - ACPI_STATUS Status; - ACPI_OPERAND_OBJECT *ReturnDesc; - UINT8 *NewBuf; - UINT8 *EndTag; - ACPI_SIZE Length0; - ACPI_SIZE Length1; - ACPI_SIZE NewLength; - - - ACPI_FUNCTION_TRACE (ExConcatTemplate); - - - /* - * Find the EndTag descriptor in each resource template. - * Note1: returned pointers point TO the EndTag, not past it. - * Note2: zero-length buffers are allowed; treated like one EndTag - */ - - /* Get the length of the first resource template */ - - Status = AcpiUtGetResourceEndTag (Operand0, &EndTag); - if (ACPI_FAILURE (Status)) - { - return_ACPI_STATUS (Status); - } - - Length0 = ACPI_PTR_DIFF (EndTag, Operand0->Buffer.Pointer); - - /* Get the length of the second resource template */ - - Status = AcpiUtGetResourceEndTag (Operand1, &EndTag); - if (ACPI_FAILURE (Status)) - { - return_ACPI_STATUS (Status); - } - - Length1 = ACPI_PTR_DIFF (EndTag, Operand1->Buffer.Pointer); - - /* Combine both lengths, minimum size will be 2 for EndTag */ - - NewLength = Length0 + Length1 + sizeof (AML_RESOURCE_END_TAG); - - /* Create a new buffer object for the result (with one EndTag) */ - - ReturnDesc = AcpiUtCreateBufferObject (NewLength); - if (!ReturnDesc) - { - return_ACPI_STATUS (AE_NO_MEMORY); - } - - /* - * Copy the templates to the new buffer, 0 first, then 1 follows. One - * EndTag descriptor is copied from Operand1. - */ - NewBuf = ReturnDesc->Buffer.Pointer; - memcpy (NewBuf, Operand0->Buffer.Pointer, Length0); - memcpy (NewBuf + Length0, Operand1->Buffer.Pointer, Length1); - - /* Insert EndTag and set the checksum to zero, means "ignore checksum" */ - - NewBuf[NewLength - 1] = 0; - NewBuf[NewLength - 2] = ACPI_RESOURCE_NAME_END_TAG | 1; - - /* Return the completed resource template */ - - *ActualReturnDesc = ReturnDesc; - return_ACPI_STATUS (AE_OK); -} - - -/******************************************************************************* - * - * FUNCTION: AcpiExDoConcatenate - * - * PARAMETERS: Operand0 - First source object - * Operand1 - Second source object - * ActualReturnDesc - Where to place the return object - * WalkState - Current walk state - * - * RETURN: Status - * - * DESCRIPTION: Concatenate two objects OF THE SAME TYPE. - * - ******************************************************************************/ - -ACPI_STATUS -AcpiExDoConcatenate ( - ACPI_OPERAND_OBJECT *Operand0, - ACPI_OPERAND_OBJECT *Operand1, - ACPI_OPERAND_OBJECT **ActualReturnDesc, - ACPI_WALK_STATE *WalkState) -{ - ACPI_OPERAND_OBJECT *LocalOperand1 = Operand1; - ACPI_OPERAND_OBJECT *ReturnDesc; - char *NewBuf; - const char *TypeString; - ACPI_STATUS Status; - - - ACPI_FUNCTION_TRACE (ExDoConcatenate); - - - /* - * Convert the second operand if necessary. The first operand - * determines the type of the second operand, (See the Data Types - * section of the ACPI specification.) Both object types are - * guaranteed to be either Integer/String/Buffer by the operand - * resolution mechanism. - */ - switch (Operand0->Common.Type) - { - case ACPI_TYPE_INTEGER: - - Status = AcpiExConvertToInteger (Operand1, &LocalOperand1, 16); - break; - - case ACPI_TYPE_STRING: - /* - * Per the ACPI spec, Concatenate only supports int/str/buf. - * However, we support all objects here as an extension. - * This improves the usefulness of the Printf() macro. - * 12/2015. - */ - switch (Operand1->Common.Type) - { - case ACPI_TYPE_INTEGER: - case ACPI_TYPE_STRING: - case ACPI_TYPE_BUFFER: - - Status = AcpiExConvertToString ( - Operand1, &LocalOperand1, ACPI_IMPLICIT_CONVERT_HEX); - break; - - default: - /* - * Just emit a string containing the object type. - */ - TypeString = AcpiUtGetTypeName (Operand1->Common.Type); - - LocalOperand1 = AcpiUtCreateStringObject ( - ((ACPI_SIZE) strlen (TypeString) + 9)); /* 9 For "[Object]" */ - if (!LocalOperand1) - { - Status = AE_NO_MEMORY; - goto Cleanup; - } - - strcpy (LocalOperand1->String.Pointer, "["); - strcat (LocalOperand1->String.Pointer, TypeString); - strcat (LocalOperand1->String.Pointer, " Object]"); - Status = AE_OK; - break; - } - break; - - case ACPI_TYPE_BUFFER: - - Status = AcpiExConvertToBuffer (Operand1, &LocalOperand1); - break; - - default: - - ACPI_ERROR ((AE_INFO, "Invalid object type: 0x%X", - Operand0->Common.Type)); - Status = AE_AML_INTERNAL; - } - - if (ACPI_FAILURE (Status)) - { - goto Cleanup; - } - - /* - * Both operands are now known to be the same object type - * (Both are Integer, String, or Buffer), and we can now perform the - * concatenation. - */ - - /* - * There are three cases to handle: - * - * 1) Two Integers concatenated to produce a new Buffer - * 2) Two Strings concatenated to produce a new String - * 3) Two Buffers concatenated to produce a new Buffer - */ - switch (Operand0->Common.Type) - { - case ACPI_TYPE_INTEGER: - - /* Result of two Integers is a Buffer */ - /* Need enough buffer space for two integers */ - - ReturnDesc = AcpiUtCreateBufferObject ( - (ACPI_SIZE) ACPI_MUL_2 (AcpiGbl_IntegerByteWidth)); - if (!ReturnDesc) - { - Status = AE_NO_MEMORY; - goto Cleanup; - } - - NewBuf = (char *) ReturnDesc->Buffer.Pointer; - - /* Copy the first integer, LSB first */ - - memcpy (NewBuf, &Operand0->Integer.Value, - AcpiGbl_IntegerByteWidth); - - /* Copy the second integer (LSB first) after the first */ - - memcpy (NewBuf + AcpiGbl_IntegerByteWidth, - &LocalOperand1->Integer.Value, AcpiGbl_IntegerByteWidth); - break; - - case ACPI_TYPE_STRING: - - /* Result of two Strings is a String */ - - ReturnDesc = AcpiUtCreateStringObject ( - ((ACPI_SIZE) Operand0->String.Length + - LocalOperand1->String.Length)); - if (!ReturnDesc) - { - Status = AE_NO_MEMORY; - goto Cleanup; - } - - NewBuf = ReturnDesc->String.Pointer; - - /* Concatenate the strings */ - - strcpy (NewBuf, Operand0->String.Pointer); - strcat (NewBuf, LocalOperand1->String.Pointer); - break; - - case ACPI_TYPE_BUFFER: - - /* Result of two Buffers is a Buffer */ - - ReturnDesc = AcpiUtCreateBufferObject ( - ((ACPI_SIZE) Operand0->Buffer.Length + - LocalOperand1->Buffer.Length)); - if (!ReturnDesc) - { - Status = AE_NO_MEMORY; - goto Cleanup; - } - - NewBuf = (char *) ReturnDesc->Buffer.Pointer; - - /* Concatenate the buffers */ - - memcpy (NewBuf, Operand0->Buffer.Pointer, - Operand0->Buffer.Length); - memcpy (NewBuf + Operand0->Buffer.Length, - LocalOperand1->Buffer.Pointer, - LocalOperand1->Buffer.Length); - break; - - default: - - /* Invalid object type, should not happen here */ - - ACPI_ERROR ((AE_INFO, "Invalid object type: 0x%X", - Operand0->Common.Type)); - Status =AE_AML_INTERNAL; - goto Cleanup; - } - - *ActualReturnDesc = ReturnDesc; - -Cleanup: - if (LocalOperand1 != Operand1) - { - AcpiUtRemoveReference (LocalOperand1); - } - return_ACPI_STATUS (Status); -} - - -/******************************************************************************* - * * FUNCTION: AcpiExDoMathOp * * PARAMETERS: Opcode - AML opcode diff --git a/source/components/executer/exsystem.c b/source/components/executer/exsystem.c index 17eff66..a215e80 100644 --- a/source/components/executer/exsystem.c +++ b/source/components/executer/exsystem.c @@ -94,7 +94,7 @@ AcpiExSystemWaitSemaphore ( /* Reacquire the interpreter */ - AcpiExEnterInterpreter (); + AcpiExEnterInterpreter (); } return_ACPI_STATUS (Status); diff --git a/source/components/executer/exutils.c b/source/components/executer/exutils.c index a570ad6..4843a20 100644 --- a/source/components/executer/exutils.c +++ b/source/components/executer/exutils.c @@ -341,8 +341,8 @@ AcpiExDigitsNeeded ( * * FUNCTION: AcpiExEisaIdToString * - * PARAMETERS: CompressedId - EISAID to be converted - * OutString - Where to put the converted string (8 bytes) + * PARAMETERS: OutString - Where to put the converted string (8 bytes) + * CompressedId - EISAID to be converted * * RETURN: None * @@ -400,7 +400,7 @@ AcpiExEisaIdToString ( * possible 64-bit integer. * Value - Value to be converted * - * RETURN: None, string + * RETURN: Converted string in OutString * * DESCRIPTION: Convert a 64-bit integer to decimal string representation. * Assumes string buffer is large enough to hold the string. The @@ -437,9 +437,9 @@ AcpiExIntegerToString ( * FUNCTION: AcpiExPciClsToString * * PARAMETERS: OutString - Where to put the converted string (7 bytes) - * PARAMETERS: ClassCode - PCI class code to be converted (3 bytes) + * ClassCode - PCI class code to be converted (3 bytes) * - * RETURN: None + * RETURN: Converted string in OutString * * DESCRIPTION: Convert 3-bytes PCI class code to string representation. * Return buffer must be large enough to hold the string. The @@ -475,7 +475,7 @@ AcpiExPciClsToString ( * * PARAMETERS: SpaceId - ID to be validated * - * RETURN: TRUE if valid/supported ID. + * RETURN: TRUE if SpaceId is a valid/supported ID. * * DESCRIPTION: Validate an operation region SpaceID. * diff --git a/source/components/hardware/hwregs.c b/source/components/hardware/hwregs.c index bc85c96..55cdd07 100644 --- a/source/components/hardware/hwregs.c +++ b/source/components/hardware/hwregs.c @@ -91,6 +91,9 @@ AcpiHwValidateRegister ( UINT8 MaxBitWidth, UINT64 *Address) { + UINT8 BitWidth; + UINT8 AccessWidth; + /* Must have a valid pointer to a GAS structure */ @@ -120,24 +123,26 @@ AcpiHwValidateRegister ( return (AE_SUPPORT); } - /* Validate the BitWidth */ + /* Validate the AccessWidth */ - if ((Reg->BitWidth != 8) && - (Reg->BitWidth != 16) && - (Reg->BitWidth != 32) && - (Reg->BitWidth != MaxBitWidth)) + if (Reg->AccessWidth > 4) { ACPI_ERROR ((AE_INFO, - "Unsupported register bit width: 0x%X", Reg->BitWidth)); + "Unsupported register access width: 0x%X", Reg->AccessWidth)); return (AE_SUPPORT); } - /* Validate the BitOffset. Just a warning for now. */ + /* Validate the BitWidth, convert AccessWidth into number of bits */ - if (Reg->BitOffset != 0) + AccessWidth = Reg->AccessWidth ? Reg->AccessWidth : 1; + AccessWidth = 1 << (AccessWidth + 2); + BitWidth = ACPI_ROUND_UP (Reg->BitOffset + Reg->BitWidth, AccessWidth); + if (MaxBitWidth < BitWidth) { ACPI_WARNING ((AE_INFO, - "Unsupported register bit offset: 0x%X", Reg->BitOffset)); + "Requested bit width 0x%X is smaller than register bit width 0x%X", + MaxBitWidth, BitWidth)); + return (AE_SUPPORT); } return (AE_OK); @@ -158,10 +163,7 @@ AcpiHwValidateRegister ( * 64-bit values is not needed. * * LIMITATIONS: - * BitWidth must be exactly 8, 16, or 32. * SpaceID must be SystemMemory or SystemIO. - * BitOffset and AccessWidth are currently ignored, as there has - * not been a need to implement these. * ******************************************************************************/ @@ -171,7 +173,12 @@ AcpiHwRead ( ACPI_GENERIC_ADDRESS *Reg) { UINT64 Address; + UINT8 AccessWidth; + UINT32 BitWidth; + UINT8 BitOffset; UINT64 Value64; + UINT32 Value32; + UINT8 Index; ACPI_STATUS Status; @@ -186,30 +193,65 @@ AcpiHwRead ( return (Status); } - /* Initialize entire 32-bit return value to zero */ - + /* + * Initialize entire 32-bit return value to zero, convert AccessWidth + * into number of bits based + */ *Value = 0; + AccessWidth = Reg->AccessWidth ? Reg->AccessWidth : 1; + AccessWidth = 1 << (AccessWidth + 2); + BitWidth = ACPI_ROUND_UP (Reg->BitOffset + Reg->BitWidth, AccessWidth); + BitOffset = Reg->BitOffset; /* * Two address spaces supported: Memory or IO. PCI_Config is * not supported here because the GAS structure is insufficient */ - if (Reg->SpaceId == ACPI_ADR_SPACE_SYSTEM_MEMORY) + Index = 0; + while (BitWidth) { - Status = AcpiOsReadMemory ((ACPI_PHYSICAL_ADDRESS) - Address, &Value64, Reg->BitWidth); + if (BitOffset > AccessWidth) + { + Value32 = 0; + BitOffset -= AccessWidth; + } + else + { + if (Reg->SpaceId == ACPI_ADR_SPACE_SYSTEM_MEMORY) + { + Status = AcpiOsReadMemory ((ACPI_PHYSICAL_ADDRESS) + Address + Index * ACPI_DIV_8 (AccessWidth), + &Value64, AccessWidth); + Value32 = (UINT32) Value64; + } + else /* ACPI_ADR_SPACE_SYSTEM_IO, validated earlier */ + { + Status = AcpiHwReadPort ((ACPI_IO_ADDRESS) + Address + Index * ACPI_DIV_8 (AccessWidth), + &Value32, AccessWidth); + } + + if (BitOffset) + { + Value32 &= ACPI_MASK_BITS_BELOW (BitOffset); + BitOffset = 0; + } + if (BitWidth < AccessWidth) + { + Value32 &= ACPI_MASK_BITS_ABOVE (BitWidth); + } + } - *Value = (UINT32) Value64; - } - else /* ACPI_ADR_SPACE_SYSTEM_IO, validated earlier */ - { - Status = AcpiHwReadPort ((ACPI_IO_ADDRESS) - Address, Value, Reg->BitWidth); + ACPI_SET_BITS (Value, Index * AccessWidth, + ((1 << AccessWidth) - 1), Value32); + + BitWidth -= BitWidth > AccessWidth ? AccessWidth : BitWidth; + Index++; } ACPI_DEBUG_PRINT ((ACPI_DB_IO, "Read: %8.8X width %2d from %8.8X%8.8X (%s)\n", - *Value, Reg->BitWidth, ACPI_FORMAT_UINT64 (Address), + *Value, AccessWidth, ACPI_FORMAT_UINT64 (Address), AcpiUtGetRegionName (Reg->SpaceId))); return (Status); @@ -237,6 +279,12 @@ AcpiHwWrite ( ACPI_GENERIC_ADDRESS *Reg) { UINT64 Address; + UINT8 AccessWidth; + UINT32 BitWidth; + UINT8 BitOffset; + UINT64 Value64; + UINT32 NewValue32, OldValue32; + UINT8 Index; ACPI_STATUS Status; @@ -251,24 +299,110 @@ AcpiHwWrite ( return (Status); } + /* Convert AccessWidth into number of bits based */ + + AccessWidth = Reg->AccessWidth ? Reg->AccessWidth : 1; + AccessWidth = 1 << (AccessWidth + 2); + BitWidth = ACPI_ROUND_UP (Reg->BitOffset + Reg->BitWidth, AccessWidth); + BitOffset = Reg->BitOffset; + /* * Two address spaces supported: Memory or IO. PCI_Config is * not supported here because the GAS structure is insufficient */ - if (Reg->SpaceId == ACPI_ADR_SPACE_SYSTEM_MEMORY) + Index = 0; + while (BitWidth) { - Status = AcpiOsWriteMemory ((ACPI_PHYSICAL_ADDRESS) - Address, (UINT64) Value, Reg->BitWidth); - } - else /* ACPI_ADR_SPACE_SYSTEM_IO, validated earlier */ - { - Status = AcpiHwWritePort ((ACPI_IO_ADDRESS) - Address, Value, Reg->BitWidth); + NewValue32 = ACPI_GET_BITS (&Value, (Index * AccessWidth), + ((1 << AccessWidth) - 1)); + + if (BitOffset > AccessWidth) + { + BitOffset -= AccessWidth; + } + else + { + if (BitOffset) + { + NewValue32 &= ACPI_MASK_BITS_BELOW (BitOffset); + } + + if (BitWidth < AccessWidth) + { + NewValue32 &= ACPI_MASK_BITS_ABOVE (BitWidth); + } + + if (Reg->SpaceId == ACPI_ADR_SPACE_SYSTEM_MEMORY) + { + if (BitOffset || BitWidth < AccessWidth) + { + /* + * Read old values in order not to modify the bits that + * are beyond the register BitWidth/BitOffset setting. + */ + Status = AcpiOsReadMemory ((ACPI_PHYSICAL_ADDRESS) + Address + Index * ACPI_DIV_8 (AccessWidth), + &Value64, AccessWidth); + OldValue32 = (UINT32) Value64; + + if (BitOffset) + { + OldValue32 &= ACPI_MASK_BITS_ABOVE (BitOffset + 1); + BitOffset = 0; + } + + if (BitWidth < AccessWidth) + { + OldValue32 &= ACPI_MASK_BITS_BELOW (BitWidth - 1); + } + + NewValue32 |= OldValue32; + } + + Value64 = (UINT64) NewValue32; + Status = AcpiOsWriteMemory ((ACPI_PHYSICAL_ADDRESS) + Address + Index * ACPI_DIV_8 (AccessWidth), + Value64, AccessWidth); + } + else /* ACPI_ADR_SPACE_SYSTEM_IO, validated earlier */ + { + if (BitOffset || BitWidth < AccessWidth) + { + /* + * Read old values in order not to modify the bits that + * are beyond the register BitWidth/BitOffset setting. + */ + Status = AcpiHwReadPort ((ACPI_IO_ADDRESS) + Address + Index * ACPI_DIV_8 (AccessWidth), + &OldValue32, AccessWidth); + + if (BitOffset) + { + OldValue32 &= ACPI_MASK_BITS_ABOVE (BitOffset + 1); + BitOffset = 0; + } + + if (BitWidth < AccessWidth) + { + OldValue32 &= ACPI_MASK_BITS_BELOW (BitWidth - 1); + } + + NewValue32 |= OldValue32; + } + + Status = AcpiHwWritePort ((ACPI_IO_ADDRESS) + Address + Index * ACPI_DIV_8 (AccessWidth), + NewValue32, AccessWidth); + } + } + + BitWidth -= BitWidth > AccessWidth ? AccessWidth : BitWidth; + Index++; } ACPI_DEBUG_PRINT ((ACPI_DB_IO, "Wrote: %8.8X width %2d to %8.8X%8.8X (%s)\n", - Value, Reg->BitWidth, ACPI_FORMAT_UINT64 (Address), + Value, AccessWidth, ACPI_FORMAT_UINT64 (Address), AcpiUtGetRegionName (Reg->SpaceId))); return (Status); diff --git a/source/components/hardware/hwxface.c b/source/components/hardware/hwxface.c index e8b2fe6..f5d4fca 100644 --- a/source/components/hardware/hwxface.c +++ b/source/components/hardware/hwxface.c @@ -565,8 +565,7 @@ AcpiGetSleepTypeData ( * Evaluate the \_Sx namespace object containing the register values * for this state */ - Info->RelativePathname = ACPI_CAST_PTR (char, - AcpiGbl_SleepStateNames[SleepState]); + Info->RelativePathname = AcpiGbl_SleepStateNames[SleepState]; Status = AcpiNsEvaluate (Info); if (ACPI_FAILURE (Status)) diff --git a/source/components/namespace/nsaccess.c b/source/components/namespace/nsaccess.c index 64db3a9..42a6d80 100644 --- a/source/components/namespace/nsaccess.c +++ b/source/components/namespace/nsaccess.c @@ -116,7 +116,7 @@ AcpiNsRootInitialize ( continue; } - Status = AcpiNsLookup (NULL, InitVal->Name, InitVal->Type, + Status = AcpiNsLookup (NULL, (char *) InitVal->Name, InitVal->Type, ACPI_IMODE_LOAD_PASS2, ACPI_NS_NO_UPSEARCH, NULL, &NewNode); if (ACPI_FAILURE (Status)) diff --git a/source/components/namespace/nsconvert.c b/source/components/namespace/nsconvert.c index 8cccf99..2fa182e 100644 --- a/source/components/namespace/nsconvert.c +++ b/source/components/namespace/nsconvert.c @@ -84,7 +84,7 @@ AcpiNsConvertToInteger ( /* String-to-Integer conversion */ Status = AcpiUtStrtoul64 (OriginalObject->String.Pointer, - ACPI_ANY_BASE, &Value); + ACPI_ANY_BASE, AcpiGbl_IntegerByteWidth, &Value); if (ACPI_FAILURE (Status)) { return (Status); diff --git a/source/components/namespace/nsdump.c b/source/components/namespace/nsdump.c index 72ef07e..776653f 100644 --- a/source/components/namespace/nsdump.c +++ b/source/components/namespace/nsdump.c @@ -99,7 +99,7 @@ AcpiNsGetMaxDepth ( void AcpiNsPrintPathname ( UINT32 NumSegments, - char *Pathname) + const char *Pathname) { UINT32 i; @@ -139,6 +139,9 @@ AcpiNsPrintPathname ( } +#ifdef ACPI_OBSOLETE_FUNCTIONS +/* Not used at this time, perhaps later */ + /******************************************************************************* * * FUNCTION: AcpiNsDumpPathname @@ -158,7 +161,7 @@ AcpiNsPrintPathname ( void AcpiNsDumpPathname ( ACPI_HANDLE Handle, - char *Msg, + const char *Msg, UINT32 Level, UINT32 Component) { @@ -179,7 +182,7 @@ AcpiNsDumpPathname ( AcpiOsPrintf ("\n"); return_VOID; } - +#endif /******************************************************************************* * diff --git a/source/components/namespace/nsinit.c b/source/components/namespace/nsinit.c index 99f1527..067dffe 100644 --- a/source/components/namespace/nsinit.c +++ b/source/components/namespace/nsinit.c @@ -99,6 +99,8 @@ AcpiNsInitializeObjects ( ACPI_FUNCTION_TRACE (NsInitializeObjects); + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, + "[Init] Completing Initialization of ACPI Objects\n")); ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "**** Starting initialization of namespace objects ****\n")); ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INIT, @@ -156,6 +158,7 @@ AcpiNsInitializeDevices ( { ACPI_STATUS Status = AE_OK; ACPI_DEVICE_WALK_INFO Info; + ACPI_HANDLE Handle; ACPI_FUNCTION_TRACE (NsInitializeDevices); @@ -209,6 +212,27 @@ AcpiNsInitializeDevices ( { Info.Num_INI++; } + + /* + * Execute \_SB._INI. + * There appears to be a strict order requirement for \_SB._INI, + * which should be evaluated before any _REG evaluations. + */ + Status = AcpiGetHandle (NULL, "\\_SB", &Handle); + if (ACPI_SUCCESS (Status)) + { + memset (Info.EvaluateInfo, 0, sizeof (ACPI_EVALUATE_INFO)); + Info.EvaluateInfo->PrefixNode = Handle; + Info.EvaluateInfo->RelativePathname = METHOD_NAME__INI; + Info.EvaluateInfo->Parameters = NULL; + Info.EvaluateInfo->Flags = ACPI_IGNORE_RETURN_VALUE; + + Status = AcpiNsEvaluate (Info.EvaluateInfo); + if (ACPI_SUCCESS (Status)) + { + Info.Num_INI++; + } + } } /* @@ -217,6 +241,12 @@ AcpiNsInitializeDevices ( * Note: Any objects accessed by the _REG methods will be automatically * initialized, even if they contain executable AML (see the call to * AcpiNsInitializeObjects below). + * + * Note: According to the ACPI specification, we actually needn't execute + * _REG for SystemMemory/SystemIo operation regions, but for PCI_Config + * operation regions, it is required to evaluate _REG for those on a PCI + * root bus that doesn't contain _BBN object. So this code is kept here + * in order not to break things. */ if (!(Flags & ACPI_NO_ADDRESS_SPACE_INIT)) { @@ -640,33 +670,37 @@ AcpiNsInitOneDevice ( * Note: We know there is an _INI within this subtree, but it may not be * under this particular device, it may be lower in the branch. */ - ACPI_DEBUG_EXEC (AcpiUtDisplayInitPathname ( - ACPI_TYPE_METHOD, DeviceNode, METHOD_NAME__INI)); + if (!ACPI_COMPARE_NAME (DeviceNode->Name.Ascii, "_SB_") || + DeviceNode->Parent != AcpiGbl_RootNode) + { + ACPI_DEBUG_EXEC (AcpiUtDisplayInitPathname ( + ACPI_TYPE_METHOD, DeviceNode, METHOD_NAME__INI)); - memset (Info, 0, sizeof (ACPI_EVALUATE_INFO)); - Info->PrefixNode = DeviceNode; - Info->RelativePathname = METHOD_NAME__INI; - Info->Parameters = NULL; - Info->Flags = ACPI_IGNORE_RETURN_VALUE; + memset (Info, 0, sizeof (ACPI_EVALUATE_INFO)); + Info->PrefixNode = DeviceNode; + Info->RelativePathname = METHOD_NAME__INI; + Info->Parameters = NULL; + Info->Flags = ACPI_IGNORE_RETURN_VALUE; - Status = AcpiNsEvaluate (Info); - if (ACPI_SUCCESS (Status)) - { - WalkInfo->Num_INI++; - } + Status = AcpiNsEvaluate (Info); + if (ACPI_SUCCESS (Status)) + { + WalkInfo->Num_INI++; + } #ifdef ACPI_DEBUG_OUTPUT - else if (Status != AE_NOT_FOUND) - { - /* Ignore error and move on to next device */ + else if (Status != AE_NOT_FOUND) + { + /* Ignore error and move on to next device */ - char *ScopeName = AcpiNsGetNormalizedPathname (DeviceNode, TRUE); + char *ScopeName = AcpiNsGetNormalizedPathname (DeviceNode, TRUE); - ACPI_EXCEPTION ((AE_INFO, Status, "during %s._INI execution", - ScopeName)); - ACPI_FREE (ScopeName); - } + ACPI_EXCEPTION ((AE_INFO, Status, "during %s._INI execution", + ScopeName)); + ACPI_FREE (ScopeName); + } #endif + } /* Ignore errors from above */ diff --git a/source/components/namespace/nsload.c b/source/components/namespace/nsload.c index 5cfadf3..9c899e7 100644 --- a/source/components/namespace/nsload.c +++ b/source/components/namespace/nsload.c @@ -140,8 +140,8 @@ AcpiNsLoadTable ( (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); AcpiNsDeleteNamespaceByOwner ( AcpiGbl_RootTableList.Tables[TableIndex].OwnerId); - AcpiTbReleaseOwnerId (TableIndex); + AcpiTbReleaseOwnerId (TableIndex); return_ACPI_STATUS (Status); } diff --git a/source/components/namespace/nsprepkg.c b/source/components/namespace/nsprepkg.c index 3cc9f53..141251f 100644 --- a/source/components/namespace/nsprepkg.c +++ b/source/components/namespace/nsprepkg.c @@ -188,6 +188,7 @@ AcpiNsCheckPackage ( { return (Status); } + Elements++; } break; @@ -232,6 +233,7 @@ AcpiNsCheckPackage ( return (Status); } } + Elements++; } break; @@ -342,7 +344,7 @@ AcpiNsCheckPackage ( while (Count > 0) { Status = AcpiNsCheckObjectType(Info, Elements, - Package->RetInfo.ObjectType1, 0); + Package->RetInfo.ObjectType1, 0); if (ACPI_FAILURE(Status)) { return (Status); @@ -358,7 +360,7 @@ AcpiNsCheckPackage ( } Status = AcpiNsCheckObjectType(Info, Elements + 1, - Package->RetInfo.ObjectType2, 0); + Package->RetInfo.ObjectType2, 0); if (ACPI_FAILURE(Status)) { return (Status); @@ -366,8 +368,8 @@ AcpiNsCheckPackage ( Elements += 2; Count -= 2; - } - break; + } + break; default: @@ -442,7 +444,7 @@ AcpiNsCheckPackageList ( /* Each sub-object must be of type Package */ Status = AcpiNsCheckObjectType (Info, &SubPackage, - ACPI_RTYPE_PACKAGE, i); + ACPI_RTYPE_PACKAGE, i); if (ACPI_FAILURE (Status)) { return (Status); @@ -466,10 +468,10 @@ AcpiNsCheckPackageList ( } Status = AcpiNsCheckPackageElements (Info, SubElements, - Package->RetInfo.ObjectType1, - Package->RetInfo.Count1, - Package->RetInfo.ObjectType2, - Package->RetInfo.Count2, 0); + Package->RetInfo.ObjectType1, + Package->RetInfo.Count1, + Package->RetInfo.ObjectType2, + Package->RetInfo.Count2, 0); if (ACPI_FAILURE (Status)) { return (Status); @@ -488,10 +490,10 @@ AcpiNsCheckPackageList ( } Status = AcpiNsCheckPackageElements (Info, SubElements, - Package->RetInfo.ObjectType1, - Package->RetInfo.Count1, - Package->RetInfo.ObjectType2, - SubPackage->Package.Count - Package->RetInfo.Count1, 0); + Package->RetInfo.ObjectType1, + Package->RetInfo.Count1, + Package->RetInfo.ObjectType2, + SubPackage->Package.Count - Package->RetInfo.Count1, 0); if (ACPI_FAILURE (Status)) { return (Status); @@ -519,7 +521,7 @@ AcpiNsCheckPackageList ( for (j = 0; j < ExpectedCount; j++) { Status = AcpiNsCheckObjectType (Info, &SubElements[j], - Package->RetInfo2.ObjectType[j], j); + Package->RetInfo2.ObjectType[j], j); if (ACPI_FAILURE (Status)) { return (Status); @@ -540,8 +542,8 @@ AcpiNsCheckPackageList ( /* Check the type of each subpackage element */ Status = AcpiNsCheckPackageElements (Info, SubElements, - Package->RetInfo.ObjectType1, - SubPackage->Package.Count, 0, 0, 0); + Package->RetInfo.ObjectType1, + SubPackage->Package.Count, 0, 0, 0); if (ACPI_FAILURE (Status)) { return (Status); @@ -554,7 +556,7 @@ AcpiNsCheckPackageList ( * the count field (the ACPI name is NumElements) */ Status = AcpiNsCheckObjectType (Info, SubElements, - ACPI_RTYPE_INTEGER, 0); + ACPI_RTYPE_INTEGER, 0); if (ACPI_FAILURE (Status)) { return (Status); @@ -569,11 +571,13 @@ AcpiNsCheckPackageList ( { goto PackageTooSmall; } + if (SubPackage->Package.Count < Package->RetInfo.Count1) { ExpectedCount = Package->RetInfo.Count1; goto PackageTooSmall; } + if (ExpectedCount == 0) { /* @@ -589,8 +593,8 @@ AcpiNsCheckPackageList ( /* Check the type of each subpackage element */ Status = AcpiNsCheckPackageElements (Info, (SubElements + 1), - Package->RetInfo.ObjectType1, - (ExpectedCount - 1), 0, 0, 1); + Package->RetInfo.ObjectType1, + (ExpectedCount - 1), 0, 0, 1); if (ACPI_FAILURE (Status)) { return (Status); @@ -662,22 +666,24 @@ AcpiNsCheckPackageElements ( for (i = 0; i < Count1; i++) { Status = AcpiNsCheckObjectType (Info, ThisElement, - Type1, i + StartIndex); + Type1, i + StartIndex); if (ACPI_FAILURE (Status)) { return (Status); } + ThisElement++; } for (i = 0; i < Count2; i++) { Status = AcpiNsCheckObjectType (Info, ThisElement, - Type2, (i + Count1 + StartIndex)); + Type2, (i + Count1 + StartIndex)); if (ACPI_FAILURE (Status)) { return (Status); } + ThisElement++; } diff --git a/source/components/parser/psopinfo.c b/source/components/parser/psopinfo.c index 28fa0ed..324d87a 100644 --- a/source/components/parser/psopinfo.c +++ b/source/components/parser/psopinfo.c @@ -165,7 +165,7 @@ AcpiPsGetOpcodeInfo ( * ******************************************************************************/ -char * +const char * AcpiPsGetOpcodeName ( UINT16 Opcode) { diff --git a/source/components/resources/rsdump.c b/source/components/resources/rsdump.c index c0421cd..e794885 100644 --- a/source/components/resources/rsdump.c +++ b/source/components/resources/rsdump.c @@ -56,32 +56,32 @@ static void AcpiRsOutString ( - char *Title, - char *Value); + const char *Title, + const char *Value); static void AcpiRsOutInteger8 ( - char *Title, + const char *Title, UINT8 Value); static void AcpiRsOutInteger16 ( - char *Title, + const char *Title, UINT16 Value); static void AcpiRsOutInteger32 ( - char *Title, + const char *Title, UINT32 Value); static void AcpiRsOutInteger64 ( - char *Title, + const char *Title, UINT64 Value); static void AcpiRsOutTitle ( - char *Title); + const char *Title); static void AcpiRsDumpByteList ( @@ -263,8 +263,8 @@ AcpiRsDumpDescriptor ( { UINT8 *Target = NULL; UINT8 *PreviousTarget; - char *Name; - UINT8 Count; + const char *Name; + UINT8 Count; /* First table entry must contain the table length (# of table entries) */ @@ -307,8 +307,7 @@ AcpiRsDumpDescriptor ( if (Table->Pointer) { - AcpiRsOutString (Name, ACPI_CAST_PTR (char, - Table->Pointer [*Target])); + AcpiRsOutString (Name, Table->Pointer [*Target]); } else { @@ -335,20 +334,17 @@ AcpiRsDumpDescriptor ( case ACPI_RSD_1BITFLAG: - AcpiRsOutString (Name, ACPI_CAST_PTR (char, - Table->Pointer [*Target & 0x01])); + AcpiRsOutString (Name, Table->Pointer [*Target & 0x01]); break; case ACPI_RSD_2BITFLAG: - AcpiRsOutString (Name, ACPI_CAST_PTR (char, - Table->Pointer [*Target & 0x03])); + AcpiRsOutString (Name, Table->Pointer [*Target & 0x03]); break; case ACPI_RSD_3BITFLAG: - AcpiRsOutString (Name, ACPI_CAST_PTR (char, - Table->Pointer [*Target & 0x07])); + AcpiRsOutString (Name, Table->Pointer [*Target & 0x07]); break; case ACPI_RSD_SHORTLIST: @@ -542,8 +538,8 @@ AcpiRsDumpAddressCommon ( static void AcpiRsOutString ( - char *Title, - char *Value) + const char *Title, + const char *Value) { AcpiOsPrintf ("%27s : %s", Title, Value); @@ -556,7 +552,7 @@ AcpiRsOutString ( static void AcpiRsOutInteger8 ( - char *Title, + const char *Title, UINT8 Value) { AcpiOsPrintf ("%27s : %2.2X\n", Title, Value); @@ -564,7 +560,7 @@ AcpiRsOutInteger8 ( static void AcpiRsOutInteger16 ( - char *Title, + const char *Title, UINT16 Value) { @@ -573,7 +569,7 @@ AcpiRsOutInteger16 ( static void AcpiRsOutInteger32 ( - char *Title, + const char *Title, UINT32 Value) { @@ -582,7 +578,7 @@ AcpiRsOutInteger32 ( static void AcpiRsOutInteger64 ( - char *Title, + const char *Title, UINT64 Value) { @@ -592,7 +588,7 @@ AcpiRsOutInteger64 ( static void AcpiRsOutTitle ( - char *Title) + const char *Title) { AcpiOsPrintf ("%27s : ", Title); diff --git a/source/components/resources/rsutils.c b/source/components/resources/rsutils.c index fbd1c46..cec4180 100644 --- a/source/components/resources/rsutils.c +++ b/source/components/resources/rsutils.c @@ -740,7 +740,7 @@ AcpiRsGetAeiMethodData ( ACPI_STATUS AcpiRsGetMethodData ( ACPI_HANDLE Handle, - char *Path, + const char *Path, ACPI_BUFFER *RetBuffer) { ACPI_OPERAND_OBJECT *ObjDesc; diff --git a/source/components/tables/tbfadt.c b/source/components/tables/tbfadt.c index 2bceced..51eb49b 100644 --- a/source/components/tables/tbfadt.c +++ b/source/components/tables/tbfadt.c @@ -56,7 +56,7 @@ AcpiTbInitGenericAddress ( UINT8 SpaceId, UINT8 ByteWidth, UINT64 Address, - char *RegisterName, + const char *RegisterName, UINT8 Flags); static void @@ -78,7 +78,7 @@ AcpiTbSelectAddress ( typedef struct acpi_fadt_info { - char *Name; + const char *Name; UINT16 Address64; UINT16 Address32; UINT16 Length; @@ -212,7 +212,7 @@ AcpiTbInitGenericAddress ( UINT8 SpaceId, UINT8 ByteWidth, UINT64 Address, - char *RegisterName, + const char *RegisterName, UINT8 Flags) { UINT8 BitWidth; @@ -420,15 +420,16 @@ AcpiTbCreateLocalFadt ( /* * Check if the FADT is larger than the largest table that we expect - * (the ACPI 5.0 version). If so, truncate the table, and issue - * a warning. + * (typically the current ACPI specification version). If so, truncate + * the table, and issue a warning. */ if (Length > sizeof (ACPI_TABLE_FADT)) { ACPI_BIOS_WARNING ((AE_INFO, - "FADT (revision %u) is longer than ACPI 5.0 version, " + "FADT (revision %u) is longer than %s length, " "truncating length %u to %u", - Table->Revision, Length, (UINT32) sizeof (ACPI_TABLE_FADT))); + Table->Revision, ACPI_FADT_CONFORMANCE, Length, + (UINT32) sizeof (ACPI_TABLE_FADT))); } /* Clear the entire local FADT */ @@ -506,7 +507,7 @@ static void AcpiTbConvertFadt ( void) { - char *Name; + const char *Name; ACPI_GENERIC_ADDRESS *Address64; UINT32 Address32; UINT8 Length; @@ -676,9 +677,11 @@ AcpiTbConvertFadt ( (!Address64->Address && Length)) { ACPI_BIOS_WARNING ((AE_INFO, - "Optional FADT field %s has zero address or length: " - "0x%8.8X%8.8X/0x%X", - Name, ACPI_FORMAT_UINT64 (Address64->Address), Length)); + "Optional FADT field %s has valid %s but zero %s: " + "0x%8.8X%8.8X/0x%X", Name, + (Length ? "Length" : "Address"), + (Length ? "Address": "Length"), + ACPI_FORMAT_UINT64 (Address64->Address), Length)); } } } diff --git a/source/components/tables/tbxfload.c b/source/components/tables/tbxfload.c index 0302eb9..645b9d5 100644 --- a/source/components/tables/tbxfload.c +++ b/source/components/tables/tbxfload.c @@ -87,14 +87,11 @@ AcpiLoadTables ( * between AcpiInitializeSubsystem() and AcpiLoadTables() to use * their customized default region handlers. */ - if (AcpiGbl_GroupModuleLevelCode) + Status = AcpiEvInstallRegionHandlers (); + if (ACPI_FAILURE (Status)) { - Status = AcpiEvInstallRegionHandlers (); - if (ACPI_FAILURE (Status) && Status != AE_ALREADY_EXISTS) - { - ACPI_EXCEPTION ((AE_INFO, Status, "During Region initialization")); - return_ACPI_STATUS (Status); - } + ACPI_EXCEPTION ((AE_INFO, Status, "During Region initialization")); + return_ACPI_STATUS (Status); } /* Load the namespace from the tables */ @@ -114,6 +111,22 @@ AcpiLoadTables ( "While loading namespace from ACPI tables")); } + if (!AcpiGbl_GroupModuleLevelCode) + { + /* + * Initialize the objects that remain uninitialized. This + * runs the executable AML that may be part of the + * declaration of these objects: + * OperationRegions, BufferFields, Buffers, and Packages. + */ + Status = AcpiNsInitializeObjects (); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + } + + AcpiGbl_NamespaceInitialized = TRUE; return_ACPI_STATUS (Status); } diff --git a/source/components/utilities/utdebug.c b/source/components/utilities/utdebug.c index ccdca57..b6ae2c7 100644 --- a/source/components/utilities/utdebug.c +++ b/source/components/utilities/utdebug.c @@ -53,15 +53,9 @@ #ifdef ACPI_DEBUG_OUTPUT -static ACPI_THREAD_ID AcpiGbl_PrevThreadId = (ACPI_THREAD_ID) 0xFFFFFFFF; -static char *AcpiGbl_FnEntryStr = "----Entry"; -static char *AcpiGbl_FnExitStr = "----Exit-"; - -/* Local prototypes */ - -static const char * -AcpiUtTrimFunctionName ( - const char *FunctionName); +static ACPI_THREAD_ID AcpiGbl_PreviousThreadId = (ACPI_THREAD_ID) 0xFFFFFFFF; +static const char *AcpiGbl_FunctionEntryPrefix = "----Entry"; +static const char *AcpiGbl_FunctionExitPrefix = "----Exit-"; /******************************************************************************* @@ -201,16 +195,16 @@ AcpiDebugPrint ( * Thread tracking and context switch notification */ ThreadId = AcpiOsGetThreadId (); - if (ThreadId != AcpiGbl_PrevThreadId) + if (ThreadId != AcpiGbl_PreviousThreadId) { if (ACPI_LV_THREADS & AcpiDbgLevel) { AcpiOsPrintf ( "\n**** Context Switch from TID %u to TID %u ****\n\n", - (UINT32) AcpiGbl_PrevThreadId, (UINT32) ThreadId); + (UINT32) AcpiGbl_PreviousThreadId, (UINT32) ThreadId); } - AcpiGbl_PrevThreadId = ThreadId; + AcpiGbl_PreviousThreadId = ThreadId; AcpiGbl_NestingLevel = 0; } @@ -325,7 +319,7 @@ AcpiUtTrace ( { AcpiDebugPrint (ACPI_LV_FUNCTIONS, LineNumber, FunctionName, ModuleName, ComponentId, - "%s\n", AcpiGbl_FnEntryStr); + "%s\n", AcpiGbl_FunctionEntryPrefix); } } @@ -355,7 +349,7 @@ AcpiUtTracePtr ( const char *FunctionName, const char *ModuleName, UINT32 ComponentId, - void *Pointer) + const void *Pointer) { AcpiGbl_NestingLevel++; @@ -367,7 +361,7 @@ AcpiUtTracePtr ( { AcpiDebugPrint (ACPI_LV_FUNCTIONS, LineNumber, FunctionName, ModuleName, ComponentId, - "%s %p\n", AcpiGbl_FnEntryStr, Pointer); + "%s %p\n", AcpiGbl_FunctionEntryPrefix, Pointer); } } @@ -395,7 +389,7 @@ AcpiUtTraceStr ( const char *FunctionName, const char *ModuleName, UINT32 ComponentId, - char *String) + const char *String) { AcpiGbl_NestingLevel++; @@ -407,7 +401,7 @@ AcpiUtTraceStr ( { AcpiDebugPrint (ACPI_LV_FUNCTIONS, LineNumber, FunctionName, ModuleName, ComponentId, - "%s %s\n", AcpiGbl_FnEntryStr, String); + "%s %s\n", AcpiGbl_FunctionEntryPrefix, String); } } @@ -447,7 +441,7 @@ AcpiUtTraceU32 ( { AcpiDebugPrint (ACPI_LV_FUNCTIONS, LineNumber, FunctionName, ModuleName, ComponentId, - "%s %08X\n", AcpiGbl_FnEntryStr, Integer); + "%s %08X\n", AcpiGbl_FunctionEntryPrefix, Integer); } } @@ -482,7 +476,7 @@ AcpiUtExit ( { AcpiDebugPrint (ACPI_LV_FUNCTIONS, LineNumber, FunctionName, ModuleName, ComponentId, - "%s\n", AcpiGbl_FnExitStr); + "%s\n", AcpiGbl_FunctionExitPrefix); } if (AcpiGbl_NestingLevel) @@ -528,14 +522,14 @@ AcpiUtStatusExit ( { AcpiDebugPrint (ACPI_LV_FUNCTIONS, LineNumber, FunctionName, ModuleName, ComponentId, - "%s %s\n", AcpiGbl_FnExitStr, + "%s %s\n", AcpiGbl_FunctionExitPrefix, AcpiFormatException (Status)); } else { AcpiDebugPrint (ACPI_LV_FUNCTIONS, LineNumber, FunctionName, ModuleName, ComponentId, - "%s ****Exception****: %s\n", AcpiGbl_FnExitStr, + "%s ****Exception****: %s\n", AcpiGbl_FunctionExitPrefix, AcpiFormatException (Status)); } } @@ -581,7 +575,7 @@ AcpiUtValueExit ( { AcpiDebugPrint (ACPI_LV_FUNCTIONS, LineNumber, FunctionName, ModuleName, ComponentId, - "%s %8.8X%8.8X\n", AcpiGbl_FnExitStr, + "%s %8.8X%8.8X\n", AcpiGbl_FunctionExitPrefix, ACPI_FORMAT_UINT64 (Value)); } @@ -626,7 +620,7 @@ AcpiUtPtrExit ( { AcpiDebugPrint (ACPI_LV_FUNCTIONS, LineNumber, FunctionName, ModuleName, ComponentId, - "%s %p\n", AcpiGbl_FnExitStr, Ptr); + "%s %p\n", AcpiGbl_FunctionExitPrefix, Ptr); } if (AcpiGbl_NestingLevel) diff --git a/source/components/utilities/uteval.c b/source/components/utilities/uteval.c index bdde513..d4864f3 100644 --- a/source/components/utilities/uteval.c +++ b/source/components/utilities/uteval.c @@ -72,7 +72,7 @@ ACPI_STATUS AcpiUtEvaluateObject ( ACPI_NAMESPACE_NODE *PrefixNode, - char *Path, + const char *Path, UINT32 ExpectedReturnBtypes, ACPI_OPERAND_OBJECT **ReturnDesc) { @@ -219,7 +219,7 @@ Cleanup: ACPI_STATUS AcpiUtEvaluateNumericObject ( - char *ObjectName, + const char *ObjectName, ACPI_NAMESPACE_NODE *DeviceNode, UINT64 *Value) { diff --git a/source/components/utilities/utglobal.c b/source/components/utilities/utglobal.c index ed3a171..0d8dff8 100644 --- a/source/components/utilities/utglobal.c +++ b/source/components/utilities/utglobal.c @@ -87,6 +87,12 @@ const char *AcpiGbl_HighestDstateNames[ACPI_NUM_SxD_METHODS] = }; +/* Hex-to-ascii */ + +const char AcpiGbl_LowerHexDigits[] = "0123456789abcdef"; +const char AcpiGbl_UpperHexDigits[] = "0123456789ABCDEF"; + + /******************************************************************************* * * Namespace globals @@ -179,6 +185,55 @@ ACPI_FIXED_EVENT_INFO AcpiGbl_FixedEventInfo[ACPI_NUM_FIXED_EVENTS] = }; #endif /* !ACPI_REDUCED_HARDWARE */ + +#if defined (ACPI_DISASSEMBLER) || defined (ACPI_ASL_COMPILER) + +/* ToPld macro: compile/disassemble strings */ + +const char *AcpiGbl_PldPanelList[] = +{ + "TOP", + "BOTTOM", + "LEFT", + "RIGHT", + "FRONT", + "BACK", + "UNKNOWN", + NULL +}; + +const char *AcpiGbl_PldVerticalPositionList[] = +{ + "UPPER", + "CENTER", + "LOWER", + NULL +}; + +const char *AcpiGbl_PldHorizontalPositionList[] = +{ + "LEFT", + "CENTER", + "RIGHT", + NULL +}; + +const char *AcpiGbl_PldShapeList[] = +{ + "ROUND", + "OVAL", + "SQUARE", + "VERTICALRECTANGLE", + "HORIZONTALRECTANGLE", + "VERTICALTRAPEZOID", + "HORIZONTALTRAPEZOID", + "UNKNOWN", + "CHAMFERED", + NULL +}; +#endif + + /* Public globals */ ACPI_EXPORT_SYMBOL (AcpiGbl_FADT) diff --git a/source/components/utilities/utmisc.c b/source/components/utilities/utmisc.c index e35a0ef..ce8f254 100644 --- a/source/components/utilities/utmisc.c +++ b/source/components/utilities/utmisc.c @@ -401,7 +401,7 @@ void AcpiUtDisplayInitPathname ( UINT8 Type, ACPI_NAMESPACE_NODE *ObjHandle, - char *Path) + const char *Path) { ACPI_STATUS Status; ACPI_BUFFER Buffer; diff --git a/source/components/utilities/utnonansi.c b/source/components/utilities/utnonansi.c index 572d24a..70fb33e 100644 --- a/source/components/utilities/utnonansi.c +++ b/source/components/utilities/utnonansi.c @@ -244,41 +244,44 @@ AcpiUtSafeStrncat ( * * FUNCTION: AcpiUtStrtoul64 * - * PARAMETERS: String - Null terminated string - * Base - Radix of the string: 16 or ACPI_ANY_BASE; - * ACPI_ANY_BASE means 'in behalf of ToInteger' - * RetInteger - Where the converted integer is returned + * PARAMETERS: String - Null terminated string + * Base - Radix of the string: 16 or 10 or + * ACPI_ANY_BASE + * MaxIntegerByteWidth - Maximum allowable integer,in bytes: + * 4 or 8 (32 or 64 bits) + * RetInteger - Where the converted integer is + * returned * * RETURN: Status and Converted value * * DESCRIPTION: Convert a string into an unsigned value. Performs either a - * 32-bit or 64-bit conversion, depending on the current mode - * of the interpreter. + * 32-bit or 64-bit conversion, depending on the input integer + * size (often the current mode of the interpreter). * - * NOTES: AcpiGbl_IntegerByteWidth should be set to the proper width. + * NOTES: Negative numbers are not supported, as they are not supported + * by ACPI. + * + * AcpiGbl_IntegerByteWidth should be set to the proper width. * For the core ACPICA code, this width depends on the DSDT - * version. For iASL, the default byte width is always 8. + * version. For iASL, the default byte width is always 8 for the + * parser, but error checking is performed later to flag cases + * where a 64-bit constant is defined in a 32-bit DSDT/SSDT. * * Does not support Octal strings, not needed at this time. * - * There is an earlier version of the function after this one, - * below. It is slightly different than this one, and the two - * may eventually may need to be merged. (01/2016). - * ******************************************************************************/ ACPI_STATUS AcpiUtStrtoul64 ( char *String, UINT32 Base, + UINT32 MaxIntegerByteWidth, UINT64 *RetInteger) { UINT32 ThisDigit = 0; UINT64 ReturnValue = 0; UINT64 Quotient; UINT64 Dividend; - UINT32 ToIntegerOp = (Base == ACPI_ANY_BASE); - UINT32 Mode32 = (AcpiGbl_IntegerByteWidth == 4); UINT8 ValidDigits = 0; UINT8 SignOf0x = 0; UINT8 Term = 0; @@ -290,6 +293,7 @@ AcpiUtStrtoul64 ( switch (Base) { case ACPI_ANY_BASE: + case 10: case 16: break; @@ -313,10 +317,10 @@ AcpiUtStrtoul64 ( String++; } - if (ToIntegerOp) + if (Base == ACPI_ANY_BASE) { /* - * Base equal to ACPI_ANY_BASE means 'ToInteger operation case'. + * Base equal to ACPI_ANY_BASE means 'Either decimal or hex'. * We need to determine if it is decimal or hexadecimal. */ if ((*String == '0') && (tolower ((int) *(String + 1)) == 'x')) @@ -337,7 +341,7 @@ AcpiUtStrtoul64 ( if (!(*String) || isspace ((int) *String) || *String == '\t') { - if (ToIntegerOp) + if (Base == ACPI_ANY_BASE) { goto ErrorExit; } @@ -348,10 +352,11 @@ AcpiUtStrtoul64 ( } /* - * Perform a 32-bit or 64-bit conversion, depending upon the current - * execution mode of the interpreter + * Perform a 32-bit or 64-bit conversion, depending upon the input + * byte width */ - Dividend = (Mode32) ? ACPI_UINT32_MAX : ACPI_UINT64_MAX; + Dividend = (MaxIntegerByteWidth <= ACPI_MAX32_BYTE_WIDTH) ? + ACPI_UINT32_MAX : ACPI_UINT64_MAX; /* Main loop: convert the string to a 32- or 64-bit integer */ @@ -386,7 +391,7 @@ AcpiUtStrtoul64 ( if (Term) { - if (ToIntegerOp) + if (Base == ACPI_ANY_BASE) { goto ErrorExit; } @@ -404,11 +409,12 @@ AcpiUtStrtoul64 ( ValidDigits++; - if (SignOf0x && ((ValidDigits > 16) || ((ValidDigits > 8) && Mode32))) + if (SignOf0x && ((ValidDigits > 16) || + ((ValidDigits > 8) && (MaxIntegerByteWidth <= ACPI_MAX32_BYTE_WIDTH)))) { /* * This is ToInteger operation case. - * No any restrictions for string-to-integer conversion, + * No restrictions for string-to-integer conversion, * see ACPI spec. */ goto ErrorExit; @@ -421,7 +427,7 @@ AcpiUtStrtoul64 ( if (ReturnValue > Quotient) { - if (ToIntegerOp) + if (Base == ACPI_ANY_BASE) { goto ErrorExit; } @@ -448,7 +454,8 @@ AllDone: ErrorExit: - /* Base was set/validated above */ + + /* Base was set/validated above (10 or 16) */ if (Base == 10) { @@ -460,9 +467,9 @@ ErrorExit: } } + #ifdef _OBSOLETE_FUNCTIONS -/* TBD: use version in ACPICA main code base? */ -/* DONE: 01/2016 */ +/* Removed: 01/2016 */ /******************************************************************************* * diff --git a/source/components/utilities/utprint.c b/source/components/utilities/utprint.c index 7656924..e01f173 100644 --- a/source/components/utilities/utprint.c +++ b/source/components/utilities/utprint.c @@ -88,12 +88,6 @@ AcpiUtPutNumber ( BOOLEAN Upper); -/* Module globals */ - -static const char AcpiGbl_LowerHexDigits[] = "0123456789abcdef"; -static const char AcpiGbl_UpperHexDigits[] = "0123456789ABCDEF"; - - /******************************************************************************* * * FUNCTION: AcpiUtBoundStringLength diff --git a/source/components/utilities/uttrack.c b/source/components/utilities/uttrack.c index b6d6a33..9efa9d6 100644 --- a/source/components/utilities/uttrack.c +++ b/source/components/utilities/uttrack.c @@ -100,7 +100,7 @@ AcpiUtRemoveAllocation ( ACPI_STATUS AcpiUtCreateList ( - char *ListName, + const char *ListName, UINT16 ObjectSize, ACPI_MEMORY_LIST **ReturnCache) { diff --git a/source/components/utilities/utxfinit.c b/source/components/utilities/utxfinit.c index a8ea3fd..2a518bc 100644 --- a/source/components/utilities/utxfinit.c +++ b/source/components/utilities/utxfinit.c @@ -168,25 +168,6 @@ AcpiEnableSubsystem ( */ AcpiGbl_EarlyInitialization = FALSE; - /* - * Install the default operation region handlers. These are the - * handlers that are defined by the ACPI specification to be - * "always accessible" -- namely, SystemMemory, SystemIO, and - * PCI_Config. This also means that no _REG methods need to be - * run for these address spaces. We need to have these handlers - * installed before any AML code can be executed, especially any - * module-level code (11/2015). - */ - if (!AcpiGbl_GroupModuleLevelCode) - { - Status = AcpiEvInstallRegionHandlers (); - if (ACPI_FAILURE (Status)) - { - ACPI_EXCEPTION ((AE_INFO, Status, "During Region initialization")); - return_ACPI_STATUS (Status); - } - } - #if (!ACPI_REDUCED_HARDWARE) /* Enable ACPI mode */ @@ -315,27 +296,23 @@ AcpiInitializeObjects ( if (AcpiGbl_GroupModuleLevelCode) { AcpiNsExecModuleCodeList (); - } - /* - * Initialize the objects that remain uninitialized. This runs the - * executable AML that may be part of the declaration of these objects: - * OperationRegions, BufferFields, Buffers, and Packages. - */ - if (!(Flags & ACPI_NO_OBJECT_INIT)) - { - ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, - "[Init] Completing Initialization of ACPI Objects\n")); - - Status = AcpiNsInitializeObjects (); - if (ACPI_FAILURE (Status)) + /* + * Initialize the objects that remain uninitialized. This + * runs the executable AML that may be part of the + * declaration of these objects: + * OperationRegions, BufferFields, Buffers, and Packages. + */ + if (!(Flags & ACPI_NO_OBJECT_INIT)) { - return_ACPI_STATUS (Status); + Status = AcpiNsInitializeObjects (); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } } } - AcpiGbl_NamespaceInitialized = TRUE; - /* * Initialize all device/region objects in the namespace. This runs * the device _STA and _INI methods and region _REG methods. diff --git a/source/include/acdebug.h b/source/include/acdebug.h index 63b8be8..8f3f471 100644 --- a/source/include/acdebug.h +++ b/source/include/acdebug.h @@ -55,7 +55,7 @@ typedef struct acpi_db_command_info { - char *Name; /* Command Name */ + const char *Name; /* Command Name */ UINT8 MinArgs; /* Minimum arguments required */ } ACPI_DB_COMMAND_INFO; @@ -70,7 +70,7 @@ typedef struct acpi_db_command_help typedef struct acpi_db_argument_info { - char *Name; /* Argument Name */ + const char *Name; /* Argument Name */ } ACPI_DB_ARGUMENT_INFO; diff --git a/source/include/acdisasm.h b/source/include/acdisasm.h index e722416..3a066c8 100644 --- a/source/include/acdisasm.h +++ b/source/include/acdisasm.h @@ -319,6 +319,7 @@ extern ACPI_DMTABLE_INFO AcpiDmTableInfoIort3[]; extern ACPI_DMTABLE_INFO AcpiDmTableInfoIort3a[]; extern ACPI_DMTABLE_INFO AcpiDmTableInfoIort3b[]; extern ACPI_DMTABLE_INFO AcpiDmTableInfoIort3c[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoIort4[]; extern ACPI_DMTABLE_INFO AcpiDmTableInfoIortAcc[]; extern ACPI_DMTABLE_INFO AcpiDmTableInfoIortHdr[]; extern ACPI_DMTABLE_INFO AcpiDmTableInfoIortMap[]; @@ -808,22 +809,22 @@ AcpiDmGetExternalsFromFile ( void AcpiDmDumpInteger8 ( UINT8 Value, - char *Name); + const char *Name); void AcpiDmDumpInteger16 ( UINT16 Value, - char *Name); + const char *Name); void AcpiDmDumpInteger32 ( UINT32 Value, - char *Name); + const char *Name); void AcpiDmDumpInteger64 ( UINT64 Value, - char *Name); + const char *Name); void AcpiDmResourceTemplate ( @@ -935,7 +936,7 @@ AcpiDmSerialBusDescriptor ( void AcpiDmVendorCommon ( - char *Name, + const char *Name, UINT8 *ByteData, UINT32 Length, UINT32 Level); diff --git a/source/include/acevents.h b/source/include/acevents.h index 62bc0ed..a14dbe5 100644 --- a/source/include/acevents.h +++ b/source/include/acevents.h @@ -273,10 +273,6 @@ AcpiEvDetachRegion ( BOOLEAN AcpiNsIsLocked); void -AcpiEvAssociateRegMethod ( - ACPI_OPERAND_OBJECT *RegionObj); - -void AcpiEvExecuteRegMethods ( ACPI_NAMESPACE_NODE *Node, ACPI_ADR_SPACE_TYPE SpaceId, diff --git a/source/include/acglobal.h b/source/include/acglobal.h index 11361c5..1918e0c 100644 --- a/source/include/acglobal.h +++ b/source/include/acglobal.h @@ -189,6 +189,8 @@ extern const char *AcpiGbl_SleepStateNames[ACPI_S_STATE_COU extern const char *AcpiGbl_LowestDstateNames[ACPI_NUM_SxW_METHODS]; extern const char *AcpiGbl_HighestDstateNames[ACPI_NUM_SxD_METHODS]; extern const char *AcpiGbl_RegionTypes[ACPI_NUM_PREDEFINED_REGIONS]; +extern const char AcpiGbl_LowerHexDigits[]; +extern const char AcpiGbl_UpperHexDigits[]; extern const ACPI_OPCODE_INFO AcpiGbl_AmlOpInfo[AML_NUM_OPCODES]; @@ -370,6 +372,14 @@ ACPI_GLOBAL (ACPI_MUTEX, AcpiGbl_DbCommandComplete); #endif /* ACPI_DEBUGGER */ +#if defined (ACPI_DISASSEMBLER) || defined (ACPI_ASL_COMPILER) + +ACPI_GLOBAL (const char, *AcpiGbl_PldPanelList[]); +ACPI_GLOBAL (const char, *AcpiGbl_PldVerticalPositionList[]); +ACPI_GLOBAL (const char, *AcpiGbl_PldHorizontalPositionList[]); +ACPI_GLOBAL (const char, *AcpiGbl_PldShapeList[]); + +#endif /***************************************************************************** * diff --git a/source/include/acinterp.h b/source/include/acinterp.h index 454e8ba..148e8d0 100644 --- a/source/include/acinterp.h +++ b/source/include/acinterp.h @@ -69,7 +69,7 @@ typedef const struct acpi_exdump_info { UINT8 Opcode; UINT8 Offset; - char *Name; + const char *Name; } ACPI_EXDUMP_INFO; diff --git a/source/include/aclocal.h b/source/include/aclocal.h index 46d430a..48cff57 100644 --- a/source/include/aclocal.h +++ b/source/include/aclocal.h @@ -1285,6 +1285,7 @@ typedef struct acpi_external_list #define ACPI_EXT_ORIGIN_FROM_FILE 0x02 /* External came from a file */ #define ACPI_EXT_INTERNAL_PATH_ALLOCATED 0x04 /* Deallocate internal path on completion */ #define ACPI_EXT_EXTERNAL_EMITTED 0x08 /* External() statement has been emitted */ +#define ACPI_EXT_ORIGIN_FROM_OPCODE 0x10 /* External came from a External() opcode */ typedef struct acpi_external_file diff --git a/source/include/acmacros.h b/source/include/acmacros.h index 1393412..ecb8050 100644 --- a/source/include/acmacros.h +++ b/source/include/acmacros.h @@ -264,6 +264,10 @@ #define ACPI_IS_MISALIGNED(value) (((ACPI_SIZE) value) & (sizeof(ACPI_SIZE)-1)) +/* Generic (power-of-two) rounding */ + +#define ACPI_IS_POWER_OF_TWO(a) (((a) & ((a) - 1)) == 0) + /* * Bitmask creation * Bit positions start at zero. diff --git a/source/include/acnamesp.h b/source/include/acnamesp.h index e3c089f..11ee70d 100644 --- a/source/include/acnamesp.h +++ b/source/include/acnamesp.h @@ -258,14 +258,14 @@ AcpiNsDumpEntry ( void AcpiNsDumpPathname ( ACPI_HANDLE Handle, - char *Msg, + const char *Msg, UINT32 Level, UINT32 Component); void AcpiNsPrintPathname ( UINT32 NumSegments, - char *Pathname); + const char *Pathname); ACPI_STATUS AcpiNsDumpOneObject ( diff --git a/source/include/acparser.h b/source/include/acparser.h index 2665128..dd27821 100644 --- a/source/include/acparser.h +++ b/source/include/acparser.h @@ -171,7 +171,7 @@ const ACPI_OPCODE_INFO * AcpiPsGetOpcodeInfo ( UINT16 Opcode); -char * +const char * AcpiPsGetOpcodeName ( UINT16 Opcode); diff --git a/source/include/acpixf.h b/source/include/acpixf.h index 53adadc..0c7e021 100644 --- a/source/include/acpixf.h +++ b/source/include/acpixf.h @@ -46,7 +46,7 @@ /* Current ACPICA subsystem version in YYYYMMDD format */ -#define ACPI_CA_VERSION 0x20160212 +#define ACPI_CA_VERSION 0x20160318 #include "acconfig.h" #include "actypes.h" diff --git a/source/include/acresrc.h b/source/include/acresrc.h index cbce5de..1d077ca 100644 --- a/source/include/acresrc.h +++ b/source/include/acresrc.h @@ -130,7 +130,7 @@ typedef const struct acpi_rsdump_info { UINT8 Opcode; UINT8 Offset; - char *Name; + const char *Name; const char **Pointer; } ACPI_RSDUMP_INFO; @@ -227,7 +227,7 @@ AcpiRsGetPrsMethodData ( ACPI_STATUS AcpiRsGetMethodData ( ACPI_HANDLE Handle, - char *Path, + const char *Path, ACPI_BUFFER *RetBuffer); ACPI_STATUS diff --git a/source/include/acstruct.h b/source/include/acstruct.h index e1d8fa5..f7538ad 100644 --- a/source/include/acstruct.h +++ b/source/include/acstruct.h @@ -202,7 +202,7 @@ typedef struct acpi_evaluate_info /* The first 3 elements are passed by the caller to AcpiNsEvaluate */ ACPI_NAMESPACE_NODE *PrefixNode; /* Input: starting node */ - char *RelativePathname; /* Input: path relative to PrefixNode */ + const char *RelativePathname; /* Input: path relative to PrefixNode */ ACPI_OPERAND_OBJECT **Parameters; /* Input: argument list */ ACPI_NAMESPACE_NODE *Node; /* Resolved node (PrefixNode:RelativePathname) */ diff --git a/source/include/actbl.h b/source/include/actbl.h index 6aa1df2..faeb744 100644 --- a/source/include/actbl.h +++ b/source/include/actbl.h @@ -449,4 +449,6 @@ typedef struct acpi_table_desc #define ACPI_FADT_V5_SIZE (UINT32) (ACPI_FADT_OFFSET (HypervisorId)) #define ACPI_FADT_V6_SIZE (UINT32) (sizeof (ACPI_TABLE_FADT)) +#define ACPI_FADT_CONFORMANCE "ACPI 6.1 (FADT version 6)" + #endif /* __ACTBL_H__ */ diff --git a/source/include/actbl1.h b/source/include/actbl1.h index df5abe3..0fe925a 100644 --- a/source/include/actbl1.h +++ b/source/include/actbl1.h @@ -581,7 +581,11 @@ enum AcpiHestNotifyTypes ACPI_HEST_NOTIFY_NMI = 4, ACPI_HEST_NOTIFY_CMCI = 5, /* ACPI 5.0 */ ACPI_HEST_NOTIFY_MCE = 6, /* ACPI 5.0 */ - ACPI_HEST_NOTIFY_RESERVED = 7 /* 7 and greater are reserved */ + ACPI_HEST_NOTIFY_GPIO = 7, /* ACPI 6.0 */ + ACPI_HEST_NOTIFY_SEA = 8, /* ACPI 6.1 */ + ACPI_HEST_NOTIFY_SEI = 9, /* ACPI 6.1 */ + ACPI_HEST_NOTIFY_GSIV = 10, /* ACPI 6.1 */ + ACPI_HEST_NOTIFY_RESERVED = 11 /* 11 and greater are reserved */ }; /* Values for ConfigWriteEnable bitfield above */ @@ -754,10 +758,38 @@ typedef struct acpi_hest_generic_data UINT32 ErrorDataLength; UINT8 FruId[16]; UINT8 FruText[20]; - UINT64 TimeStamp; } ACPI_HEST_GENERIC_DATA; +/* Extension for revision 0x0300 */ + +typedef struct acpi_hest_generic_data_v300 +{ + UINT8 SectionType[16]; + UINT32 ErrorSeverity; + UINT16 Revision; + UINT8 ValidationBits; + UINT8 Flags; + UINT32 ErrorDataLength; + UINT8 FruId[16]; + UINT8 FruText[20]; + UINT64 TimeStamp; + +} ACPI_HEST_GENERIC_DATA_V300; + +/* Values for ErrorSeverity above */ + +#define ACPI_HEST_GEN_ERROR_RECOVERABLE 0 +#define ACPI_HEST_GEN_ERROR_FATAL 1 +#define ACPI_HEST_GEN_ERROR_CORRECTED 2 +#define ACPI_HEST_GEN_ERROR_NONE 3 + +/* Flags for ValidationBits above */ + +#define ACPI_HEST_GEN_VALID_FRU_ID (1) +#define ACPI_HEST_GEN_VALID_FRU_STRING (1<<1) +#define ACPI_HEST_GEN_VALID_TIMESTAMP (1<<2) + /******************************************************************************* * @@ -1120,7 +1152,7 @@ typedef struct acpi_msct_proximity /******************************************************************************* * - * NFIT - NVDIMM Interface Table (ACPI 6.0) + * NFIT - NVDIMM Interface Table (ACPI 6.0+) * Version 1 * ******************************************************************************/ @@ -1252,7 +1284,10 @@ typedef struct acpi_nfit_control_region UINT16 SubsystemVendorId; UINT16 SubsystemDeviceId; UINT16 SubsystemRevisionId; - UINT8 Reserved[6]; /* Reserved, must be zero */ + UINT8 ValidFields; + UINT8 ManufacturingLocation; + UINT16 ManufacturingDate; + UINT8 Reserved[2]; /* Reserved, must be zero */ UINT32 SerialNumber; UINT16 Code; UINT16 Windows; @@ -1268,7 +1303,11 @@ typedef struct acpi_nfit_control_region /* Flags */ -#define ACPI_NFIT_CONTROL_BUFFERED (1) /* Block Data Windows implementation is buffered */ +#define ACPI_NFIT_CONTROL_BUFFERED (1) /* Block Data Windows implementation is buffered */ + +/* ValidFields bits */ + +#define ACPI_NFIT_CONTROL_MFG_INFO_VALID (1) /* Manufacturing fields are valid */ /* 5: NVDIMM Block Data Window Region Structure */ diff --git a/source/include/actbl2.h b/source/include/actbl2.h index 2a955ba..625d33f 100644 --- a/source/include/actbl2.h +++ b/source/include/actbl2.h @@ -364,7 +364,7 @@ typedef struct acpi_csrt_descriptor * DBG2 - Debug Port Table 2 * Version 0 (Both main table and subtables) * - * Conforms to "Microsoft Debug Port Table 2 (DBG2)", May 22 2012. + * Conforms to "Microsoft Debug Port Table 2 (DBG2)", December 10, 2015 * ******************************************************************************/ @@ -421,6 +421,11 @@ typedef struct acpi_dbg2_device #define ACPI_DBG2_16550_COMPATIBLE 0x0000 #define ACPI_DBG2_16550_SUBSET 0x0001 +#define ACPI_DBG2_ARM_PL011 0x0003 +#define ACPI_DBG2_ARM_SBSA_32BIT 0x000D +#define ACPI_DBG2_ARM_SBSA_GENERIC 0x000E +#define ACPI_DBG2_ARM_DCC 0x000F +#define ACPI_DBG2_BCM2835 0x0010 #define ACPI_DBG2_1394_STANDARD 0x0000 @@ -453,7 +458,7 @@ typedef struct acpi_table_dbgp * Version 1 * * Conforms to "Intel Virtualization Technology for Directed I/O", - * Version 2.2, Sept. 2013 + * Version 2.3, October 2014 * ******************************************************************************/ @@ -469,6 +474,8 @@ typedef struct acpi_table_dmar /* Masks for Flags field above */ #define ACPI_DMAR_INTR_REMAP (1) +#define ACPI_DMAR_X2APIC_OPT_OUT (1<<1) +#define ACPI_DMAR_X2APIC_MODE (1<<2) /* DMAR subtable header */ @@ -757,7 +764,7 @@ typedef struct acpi_ibft_target * IORT - IO Remapping Table * * Conforms to "IO Remapping Table System Software on ARM Platforms", - * Document number: ARM DEN 0049A, 2015 + * Document number: ARM DEN 0049B, October 2015 * ******************************************************************************/ @@ -793,7 +800,8 @@ enum AcpiIortNodeType ACPI_IORT_NODE_ITS_GROUP = 0x00, ACPI_IORT_NODE_NAMED_COMPONENT = 0x01, ACPI_IORT_NODE_PCI_ROOT_COMPLEX = 0x02, - ACPI_IORT_NODE_SMMU = 0x03 + ACPI_IORT_NODE_SMMU = 0x03, + ACPI_IORT_NODE_SMMU_V3 = 0x04 }; @@ -902,6 +910,26 @@ typedef struct acpi_iort_smmu #define ACPI_IORT_SMMU_COHERENT_WALK (1<<1) +typedef struct acpi_iort_smmu_v3 +{ + UINT64 BaseAddress; /* SMMUv3 base address */ + UINT32 Flags; + UINT32 Reserved; + UINT64 VatosAddress; + UINT32 Model; /* O: generic SMMUv3 */ + UINT32 EventGsiv; + UINT32 PriGsiv; + UINT32 GerrGsiv; + UINT32 SyncGsiv; + +} ACPI_IORT_SMMU_V3; + +/* Masks for Flags field above */ + +#define ACPI_IORT_SMMU_V3_COHACC_OVERRIDE (1) +#define ACPI_IORT_SMMU_V3_HTTU_OVERRIDE (1<<1) + + /******************************************************************************* * * IVRS - I/O Virtualization Reporting Structure @@ -1284,10 +1312,10 @@ typedef struct acpi_table_slic /******************************************************************************* * * SPCR - Serial Port Console Redirection table - * Version 1 + * Version 2 * * Conforms to "Serial Port Console Redirection Table", - * Version 1.00, January 11, 2002 + * Version 1.03, August 10, 2015 * ******************************************************************************/ @@ -1321,6 +1349,8 @@ typedef struct acpi_table_spcr #define ACPI_SPCR_DO_NOT_DISABLE (1) +/* Values for Interface Type: See the definition of the DBG2 table */ + /******************************************************************************* * diff --git a/source/include/actbl3.h b/source/include/actbl3.h index c27bb96..bc876a9 100644 --- a/source/include/actbl3.h +++ b/source/include/actbl3.h @@ -205,7 +205,7 @@ typedef struct acpi_table_fpdt } ACPI_TABLE_FPDT; -/* FPDT subtable header */ +/* FPDT subtable header (Performance Record Structure) */ typedef struct acpi_fpdt_header { @@ -230,33 +230,29 @@ enum AcpiFpdtType /* 0: Firmware Basic Boot Performance Record */ -typedef struct acpi_fpdt_boot +typedef struct acpi_fpdt_boot_pointer { ACPI_FPDT_HEADER Header; UINT8 Reserved[4]; - UINT64 ResetEnd; - UINT64 LoadStart; - UINT64 StartupStart; - UINT64 ExitServicesEntry; - UINT64 ExitServicesExit; + UINT64 Address; -} ACPI_FPDT_BOOT; +} ACPI_FPDT_BOOT_POINTER; /* 1: S3 Performance Table Pointer Record */ -typedef struct acpi_fpdt_s3pt_ptr +typedef struct acpi_fpdt_s3pt_pointer { ACPI_FPDT_HEADER Header; UINT8 Reserved[4]; UINT64 Address; -} ACPI_FPDT_S3PT_PTR; +} ACPI_FPDT_S3PT_POINTER; /* * S3PT - S3 Performance Table. This table is pointed to by the - * FPDT S3 Pointer Record above. + * S3 Pointer Record above. */ typedef struct acpi_table_s3pt { @@ -267,27 +263,21 @@ typedef struct acpi_table_s3pt /* - * S3PT Subtables + * S3PT Subtables (Not part of the actual FPDT) */ -typedef struct acpi_s3pt_header -{ - UINT16 Type; - UINT8 Length; - UINT8 Revision; -} ACPI_S3PT_HEADER; - -/* Values for Type field above */ +/* Values for Type field in S3PT header */ enum AcpiS3ptType { ACPI_S3PT_TYPE_RESUME = 0, - ACPI_S3PT_TYPE_SUSPEND = 1 + ACPI_S3PT_TYPE_SUSPEND = 1, + ACPI_FPDT_BOOT_PERFORMANCE = 2 }; typedef struct acpi_s3pt_resume { - ACPI_S3PT_HEADER Header; + ACPI_FPDT_HEADER Header; UINT32 ResumeCount; UINT64 FullResume; UINT64 AverageResume; @@ -296,13 +286,29 @@ typedef struct acpi_s3pt_resume typedef struct acpi_s3pt_suspend { - ACPI_S3PT_HEADER Header; + ACPI_FPDT_HEADER Header; UINT64 SuspendStart; UINT64 SuspendEnd; } ACPI_S3PT_SUSPEND; +/* + * FPDT Boot Performance Record (Not part of the actual FPDT) + */ +typedef struct acpi_fpdt_boot +{ + ACPI_FPDT_HEADER Header; + UINT8 Reserved[4]; + UINT64 ResetEnd; + UINT64 LoadStart; + UINT64 StartupStart; + UINT64 ExitServicesEntry; + UINT64 ExitServicesExit; + +} ACPI_FPDT_BOOT; + + /******************************************************************************* * * GTDT - Generic Timer Description Table (ACPI 5.1) diff --git a/source/include/actypes.h b/source/include/actypes.h index e1a733e..395b915 100644 --- a/source/include/actypes.h +++ b/source/include/actypes.h @@ -1034,7 +1034,7 @@ typedef struct acpi_buffer */ typedef struct acpi_predefined_names { - char *Name; + const char *Name; UINT8 Type; char *Val; @@ -1325,7 +1325,7 @@ typedef struct acpi_mem_space_context */ typedef struct acpi_memory_list { - char *ListName; + const char *ListName; void *ListHead; UINT16 ObjectSize; UINT16 MaxDepth; diff --git a/source/include/acutils.h b/source/include/acutils.h index cbbf7c5..ed45ef8 100644 --- a/source/include/acutils.h +++ b/source/include/acutils.h @@ -194,8 +194,14 @@ ACPI_STATUS AcpiUtStrtoul64 ( char *String, UINT32 Base, + UINT32 MaxIntegerByteWidth, UINT64 *RetInteger); +/* Values for MaxIntegerByteWidth above */ + +#define ACPI_MAX32_BYTE_WIDTH 4 +#define ACPI_MAX64_BYTE_WIDTH 8 + /* * utglobal - Global data structures and procedures @@ -341,7 +347,7 @@ AcpiUtTracePtr ( const char *FunctionName, const char *ModuleName, UINT32 ComponentId, - void *Pointer); + const void *Pointer); void AcpiUtTraceU32 ( @@ -357,7 +363,7 @@ AcpiUtTraceStr ( const char *FunctionName, const char *ModuleName, UINT32 ComponentId, - char *String); + const char *String); void AcpiUtExit ( @@ -460,13 +466,13 @@ AcpiUtDeleteInternalObjectList ( ACPI_STATUS AcpiUtEvaluateObject ( ACPI_NAMESPACE_NODE *PrefixNode, - char *Path, + const char *Path, UINT32 ExpectedReturnBtypes, ACPI_OPERAND_OBJECT **ReturnDesc); ACPI_STATUS AcpiUtEvaluateNumericObject ( - char *ObjectName, + const char *ObjectName, ACPI_NAMESPACE_NODE *DeviceNode, UINT64 *Value); @@ -757,7 +763,7 @@ void AcpiUtDisplayInitPathname ( UINT8 Type, ACPI_NAMESPACE_NODE *ObjHandle, - char *Path); + const char *Path); #endif @@ -934,7 +940,7 @@ AcpiUtDumpAllocations ( ACPI_STATUS AcpiUtCreateList ( - char *ListName, + const char *ListName, UINT16 ObjectSize, ACPI_MEMORY_LIST **ReturnCache); diff --git a/source/include/platform/acenv.h b/source/include/platform/acenv.h index 6fab715..99adf5f 100644 --- a/source/include/platform/acenv.h +++ b/source/include/platform/acenv.h @@ -67,17 +67,28 @@ * *****************************************************************************/ +/* Common application configuration. All single threaded except for AcpiExec. */ + +#if (defined ACPI_ASL_COMPILER) || \ + (defined ACPI_BIN_APP) || \ + (defined ACPI_DUMP_APP) || \ + (defined ACPI_HELP_APP) || \ + (defined ACPI_NAMES_APP) || \ + (defined ACPI_SRC_APP) || \ + (defined ACPI_XTRACT_APP) || \ + (defined ACPI_EXAMPLE_APP) +#define ACPI_APPLICATION +#define ACPI_SINGLE_THREADED +#endif + /* iASL configuration */ #ifdef ACPI_ASL_COMPILER -#define ACPI_APPLICATION #define ACPI_DEBUG_OUTPUT #define ACPI_CONSTANT_EVAL_ONLY #define ACPI_LARGE_NAMESPACE_NODE #define ACPI_DATA_TABLE_DISASSEMBLY -#define ACPI_SINGLE_THREADED #define ACPI_32BIT_PHYSICAL_ADDRESS - #define ACPI_DISASSEMBLER 1 #endif @@ -90,21 +101,6 @@ #define ACPI_DBG_TRACK_ALLOCATIONS #endif -/* - * AcpiBin/AcpiDump/AcpiHelp/AcpiNames/AcpiSrc/AcpiXtract/Example - * configuration. All single threaded. - */ -#if (defined ACPI_BIN_APP) || \ - (defined ACPI_DUMP_APP) || \ - (defined ACPI_HELP_APP) || \ - (defined ACPI_NAMES_APP) || \ - (defined ACPI_SRC_APP) || \ - (defined ACPI_XTRACT_APP) || \ - (defined ACPI_EXAMPLE_APP) -#define ACPI_APPLICATION -#define ACPI_SINGLE_THREADED -#endif - /* AcpiHelp configuration. Error messages disabled. */ #ifdef ACPI_HELP_APP @@ -139,11 +135,16 @@ #define ACPI_REDUCED_HARDWARE 1 #endif -/* Linkable ACPICA library */ +/* Linkable ACPICA library. Two versions, one with full debug. */ #ifdef ACPI_LIBRARY #define ACPI_USE_LOCAL_CACHE -#define ACPI_FULL_DEBUG +#define ACPI_DEBUGGER 1 +#define ACPI_DISASSEMBLER 1 + +#ifdef _DEBUG +#define ACPI_DEBUG_OUTPUT +#endif #endif /* Common for all ACPICA applications */ @@ -218,6 +219,9 @@ #elif defined(__HAIKU__) #include "achaiku.h" +#elif defined(__QNX__) +#include "acqnx.h" + #else /* Unknown environment */ diff --git a/source/include/platform/acqnx.h b/source/include/platform/acqnx.h new file mode 100644 index 0000000..76252f8 --- /dev/null +++ b/source/include/platform/acqnx.h @@ -0,0 +1,74 @@ +/****************************************************************************** + * + * Name: acqnx.h - OS specific defines, etc. + * + *****************************************************************************/ + +/* + * Copyright (C) 2000 - 2016, Intel Corp. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions, and the following disclaimer, + * without modification. + * 2. Redistributions in binary form must reproduce at minimum a disclaimer + * substantially similar to the "NO WARRANTY" disclaimer below + * ("Disclaimer") and any redistribution must be conditioned upon + * including a substantially similar Disclaimer requirement for further + * binary redistribution. + * 3. Neither the names of the above-listed copyright holders nor the names + * of any contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * Alternatively, this software may be distributed under the terms of the + * GNU General Public License ("GPL") version 2 as published by the Free + * Software Foundation. + * + * NO WARRANTY + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING + * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGES. + */ + +#ifndef __ACQNX_H__ +#define __ACQNX_H__ + +/* QNX uses GCC */ + +#include "acgcc.h" + +#define ACPI_UINTPTR_T uintptr_t +#define ACPI_USE_LOCAL_CACHE +#define ACPI_CAST_PTHREAD_T(x) ((ACPI_THREAD_ID) ACPI_TO_INTEGER (x)) + +/* At present time (QNX 6.6) all supported architectures are 32 bits. */ +#define ACPI_MACHINE_WIDTH 32 + +#define COMPILER_DEPENDENT_INT64 int64_t +#define COMPILER_DEPENDENT_UINT64 uint64_t + +#include +#include +#include + +#define ACPI_USE_STANDARD_HEADERS + +#define __cli() InterruptDisable(); +#define __sti() InterruptEnable(); +#define __cdecl + +#define ACPI_USE_SYSTEM_CLIBRARY +#define ACPI_USE_NATIVE_DIVIDE + +#endif /* __ACQNX_H__ */ diff --git a/source/os_specific/service_layers/osbsdtbl.c b/source/os_specific/service_layers/osbsdtbl.c index 0fa499f..695f3a7 100644 --- a/source/os_specific/service_layers/osbsdtbl.c +++ b/source/os_specific/service_layers/osbsdtbl.c @@ -386,7 +386,9 @@ OslTableInitialize ( ACPI_SIZE RsdpSize; ACPI_STATUS Status; u_long Address = 0; +#if defined(SYSTEM_SYSCTL) size_t Length = sizeof (Address); +#endif /* Get main ACPI tables from memory on first invocation of this function */ @@ -408,6 +410,7 @@ OslTableInitialize ( Address = strtoul (Buffer, NULL, 0); } #endif +#if defined(SYSTEM_SYSCTL) if (!Address) { if (sysctlbyname (SYSTEM_SYSCTL, &Address, &Length, NULL, 0) != 0) @@ -415,6 +418,7 @@ OslTableInitialize ( Address = 0; } } +#endif if (Address) { RsdpBase = Address; diff --git a/source/os_specific/service_layers/osunixmap.c b/source/os_specific/service_layers/osunixmap.c index 9133f57..a4f0a24 100644 --- a/source/os_specific/service_layers/osunixmap.c +++ b/source/os_specific/service_layers/osunixmap.c @@ -56,7 +56,7 @@ #define O_BINARY 0 #endif -#if defined(_DragonFly) || defined(_FreeBSD) +#if defined(_DragonFly) || defined(_FreeBSD) || defined(_QNX) #define MMAP_FLAGS MAP_SHARED #else #define MMAP_FLAGS MAP_PRIVATE diff --git a/source/tools/acpidump/apdump.c b/source/tools/acpidump/apdump.c index 00d7e09..ac3e9ea 100644 --- a/source/tools/acpidump/apdump.c +++ b/source/tools/acpidump/apdump.c @@ -326,7 +326,8 @@ ApDumpTableByAddress ( /* Convert argument to an integer physical address */ - Status = AcpiUtStrtoul64 (AsciiAddress, 0, &LongAddress); + Status = AcpiUtStrtoul64 (AsciiAddress, ACPI_ANY_BASE, + ACPI_MAX64_BYTE_WIDTH, &LongAddress); if (ACPI_FAILURE (Status)) { AcpiLogError ("%s: Could not convert to a physical address\n", diff --git a/source/tools/acpidump/apmain.c b/source/tools/acpidump/apmain.c index e37ec2c..65d7b15 100644 --- a/source/tools/acpidump/apmain.c +++ b/source/tools/acpidump/apmain.c @@ -237,7 +237,8 @@ ApDoOptions ( case 'r': /* Dump tables from specified RSDP */ - Status = AcpiUtStrtoul64 (AcpiGbl_Optarg, 0, &Gbl_RsdpBase); + Status = AcpiUtStrtoul64 (AcpiGbl_Optarg, ACPI_ANY_BASE, + ACPI_MAX64_BYTE_WIDTH, &Gbl_RsdpBase); if (ACPI_FAILURE (Status)) { AcpiLogError ("%s: Could not convert to a physical address\n", diff --git a/source/tools/acpiexec/aeinitfile.c b/source/tools/acpiexec/aeinitfile.c index c8ceb20..9b2f45d 100644 --- a/source/tools/acpiexec/aeinitfile.c +++ b/source/tools/acpiexec/aeinitfile.c @@ -202,7 +202,8 @@ AeDoOneOverride ( /* Extract the 64-bit integer */ - Status = AcpiUtStrtoul64 (ValueString, 0, &Value); + Status = AcpiUtStrtoul64 (ValueString, ACPI_ANY_BASE, + ACPI_MAX64_BYTE_WIDTH, &Value); if (ACPI_FAILURE (Status)) { AcpiOsPrintf ("%s %s\n", ValueString, diff --git a/source/tools/acpisrc/asfile.c b/source/tools/acpisrc/asfile.c index 5cea124..257e2ab 100644 --- a/source/tools/acpisrc/asfile.c +++ b/source/tools/acpisrc/asfile.c @@ -759,7 +759,7 @@ AsGetFile ( { printf ("Could not read the input file %s (%u bytes)\n", Filename, Size); - goto ErrorExit; + goto ErrorFree; } Buffer [Size] = 0; /* Null terminate the buffer */ @@ -779,6 +779,8 @@ AsGetFile ( *FileSize = Size; return (0); +ErrorFree: + free (Buffer); ErrorExit: diff --git a/source/tools/acpisrc/astable.c b/source/tools/acpisrc/astable.c index 9f8853a..9671834 100644 --- a/source/tools/acpisrc/astable.c +++ b/source/tools/acpisrc/astable.c @@ -591,7 +591,8 @@ ACPI_TYPED_IDENTIFIER_TABLE AcpiIdentifiers[] = { {"ACPI_ERST_INFO", SRC_TYPE_STRUCT}, {"ACPI_FPDT_HEADER", SRC_TYPE_STRUCT}, {"ACPI_FPDT_BOOT", SRC_TYPE_STRUCT}, - {"ACPI_FPDT_S3PT_PTR", SRC_TYPE_STRUCT}, + {"ACPI_FPDT_BOOT_POINTER", SRC_TYPE_STRUCT}, + {"ACPI_FPDT_S3PT_POINTER", SRC_TYPE_STRUCT}, {"ACPI_GTDT_HEADER", SRC_TYPE_STRUCT}, {"ACPI_GTDT_TIMER_BLOCK", SRC_TYPE_STRUCT}, {"ACPI_GTDT_TIMER_ENTRY", SRC_TYPE_STRUCT}, @@ -610,6 +611,7 @@ ACPI_TYPED_IDENTIFIER_TABLE AcpiIdentifiers[] = { {"ACPI_HEST_GENERIC_V2", SRC_TYPE_STRUCT}, {"ACPI_HEST_GENERIC_STATUS", SRC_TYPE_STRUCT}, {"ACPI_HEST_GENERIC_DATA", SRC_TYPE_STRUCT}, + {"ACPI_HEST_GENERIC_DATA_V300", SRC_TYPE_STRUCT}, {"ACPI_IBFT_HEADER", SRC_TYPE_STRUCT}, {"ACPI_IBFT_CONTROL", SRC_TYPE_STRUCT}, {"ACPI_IBFT_INITIATOR", SRC_TYPE_STRUCT}, diff --git a/source/tools/acpixtract/acpixtract.c b/source/tools/acpixtract/acpixtract.c index b6cb4d0..e0d1755 100644 --- a/source/tools/acpixtract/acpixtract.c +++ b/source/tools/acpixtract/acpixtract.c @@ -44,6 +44,13 @@ #include "acpixtract.h" +/* Local prototypes */ + +static BOOLEAN +AxIsFileAscii ( + FILE *Handle); + + /****************************************************************************** * * FUNCTION: AxExtractTables @@ -72,7 +79,8 @@ AxExtractTables ( unsigned int FoundTable = 0; unsigned int Instances = 0; unsigned int ThisInstance; - char ThisSignature[4]; + char ThisSignature[5]; + char UpperSignature[5]; int Status = 0; unsigned int State = AX_STATE_FIND_HEADER; @@ -86,17 +94,27 @@ AxExtractTables ( return (-1); } + if (!AxIsFileAscii (InputFile)) + { + fclose (InputFile); + return (-1); + } + if (Signature) { + strncpy (UpperSignature, Signature, 4); + UpperSignature[4] = 0; + AcpiUtStrupr (UpperSignature); + /* Are there enough instances of the table to continue? */ - AxNormalizeSignature (Signature); + AxNormalizeSignature (UpperSignature); - Instances = AxCountTableInstances (InputPathname, Signature); + Instances = AxCountTableInstances (InputPathname, UpperSignature); if (Instances < MinimumInstances) { printf ("Table [%s] was not found in %s\n", - Signature, InputPathname); + UpperSignature, InputPathname); fclose (InputFile); return (-1); } @@ -126,7 +144,7 @@ AxExtractTables ( { /* Ignore signatures that don't match */ - if (!ACPI_COMPARE_NAME (ThisSignature, Signature)) + if (!ACPI_COMPARE_NAME (ThisSignature, UpperSignature)) { continue; } @@ -205,8 +223,7 @@ AxExtractTables ( if (!FoundTable) { - printf ("Table [%s] was not found in %s\n", - Signature, InputPathname); + printf ("No ACPI tables were found in %s\n", InputPathname); } @@ -276,6 +293,12 @@ AxExtractToMultiAmlFile ( return (-1); } + if (!AxIsFileAscii (InputFile)) + { + fclose (InputFile); + return (-1); + } + /* Open the output file in binary mode */ OutputFile = fopen (Gbl_OutputFilename, "w+b"); @@ -401,6 +424,12 @@ AxListTables ( return (-1); } + if (!AxIsFileAscii (InputFile)) + { + fclose (InputFile); + return (-1); + } + /* Dump the headers for all tables found in the input file */ printf ("\nSignature Length Revision OemId OemTableId" @@ -442,6 +471,11 @@ AxListTables ( continue; } + if (!AcpiIsValidSignature (TableHeader->Signature)) + { + continue; + } + /* Signature and Table length */ Gbl_TableCount++; @@ -470,7 +504,59 @@ AxListTables ( TableHeader->AslCompilerId, TableHeader->AslCompilerRevision); } - printf ("\nFound %u ACPI tables\n", Gbl_TableCount); + printf ("\nFound %u ACPI tables in %s\n", Gbl_TableCount, InputPathname); fclose (InputFile); return (0); } + + +/******************************************************************************* + * + * FUNCTION: AxIsFileAscii + * + * PARAMETERS: Handle - To open input file + * + * RETURN: TRUE if file is entirely ASCII and printable + * + * DESCRIPTION: Verify that the input file is entirely ASCII. + * + ******************************************************************************/ + +static BOOLEAN +AxIsFileAscii ( + FILE *Handle) +{ + UINT8 Byte; + + + /* Read the entire file */ + + while (fread (&Byte, 1, 1, Handle) == 1) + { + /* Check for an ASCII character */ + + if (!ACPI_IS_ASCII (Byte)) + { + goto ErrorExit; + } + + /* Ensure character is either printable or a "space" char */ + + else if (!isprint (Byte) && !isspace (Byte)) + { + goto ErrorExit; + } + } + + /* File is OK (100% ASCII) */ + + fseek (Handle, 0, SEEK_SET); + return (TRUE); + +ErrorExit: + + printf ("File is binary (contains non-text or non-ascii characters)\n"); + fseek (Handle, 0, SEEK_SET); + return (FALSE); + +} diff --git a/source/tools/acpixtract/acpixtract.h b/source/tools/acpixtract/acpixtract.h index 14df786..c280102 100644 --- a/source/tools/acpixtract/acpixtract.h +++ b/source/tools/acpixtract/acpixtract.h @@ -148,6 +148,10 @@ void AxNormalizeSignature ( char *Signature); +BOOLEAN +AcpiIsValidSignature ( + char *Signature); + void AxCheckAscii ( char *Name, diff --git a/source/tools/acpixtract/axutils.c b/source/tools/acpixtract/axutils.c index 6af8cdc..6d1d0d8 100644 --- a/source/tools/acpixtract/axutils.c +++ b/source/tools/acpixtract/axutils.c @@ -46,6 +46,81 @@ /******************************************************************************* * + * FUNCTION: AcpiIsValidSignature + * + * PARAMETERS: Signature - Sig string to be validated + * + * RETURN: TRUE if signature is has 4 valid ACPI characters + * + * DESCRIPTION: Validate an ACPI table signature. + * + ******************************************************************************/ + +BOOLEAN +AcpiIsValidSignature ( + char *Signature) +{ + UINT32 i; + + + /* Validate each character in the signature */ + + for (i = 0; i < ACPI_NAME_SIZE; i++) + { + if (!AcpiUtValidAcpiChar (Signature[i], i)) + { + return (FALSE); + } + } + + return (TRUE); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtValidAcpiChar + * + * PARAMETERS: Char - The character to be examined + * Position - Byte position (0-3) + * + * RETURN: TRUE if the character is valid, FALSE otherwise + * + * DESCRIPTION: Check for a valid ACPI character. Must be one of: + * 1) Upper case alpha + * 2) numeric + * 3) underscore + * + * We allow a '!' as the last character because of the ASF! table + * + ******************************************************************************/ + +BOOLEAN +AcpiUtValidAcpiChar ( + char Character, + UINT32 Position) +{ + + if (!((Character >= 'A' && Character <= 'Z') || + (Character >= '0' && Character <= '9') || + (Character == '_'))) + { + /* Allow a '!' in the last position */ + + if (Character == '!' && Position == 3) + { + return (TRUE); + } + + return (FALSE); + } + + return (TRUE); +} + + +/******************************************************************************* + * * FUNCTION: AxCheckAscii * * PARAMETERS: Name - Ascii string, at least as long as Count diff --git a/tests/misc/grammar.aml b/tests/misc/grammar.aml index 819dfee..51bc535 100755 Binary files a/tests/misc/grammar.aml and b/tests/misc/grammar.aml differ