diff options
author | jkim <jkim@FreeBSD.org> | 2013-12-19 05:51:01 +0000 |
---|---|---|
committer | jkim <jkim@FreeBSD.org> | 2013-12-19 05:51:01 +0000 |
commit | b37c83dbb637fc63c5ba07fe61555d4d6e29dd7c (patch) | |
tree | 7fcfdcc62c3319ffd669b18b080d40c9c5897210 /source | |
parent | a1672476f94b0c9ac84a682574aeb1eb481c484c (diff) | |
download | FreeBSD-src-b37c83dbb637fc63c5ba07fe61555d4d6e29dd7c.zip FreeBSD-src-b37c83dbb637fc63c5ba07fe61555d4d6e29dd7c.tar.gz |
Import ACPICA 20131218.
Diffstat (limited to 'source')
70 files changed, 2502 insertions, 726 deletions
diff --git a/source/common/adfile.c b/source/common/adfile.c index dd5abee..27271ee 100644 --- a/source/common/adfile.c +++ b/source/common/adfile.c @@ -199,6 +199,7 @@ FlGenerateFilename ( { char *Position; char *NewFilename; + char *DirectoryPosition; /* @@ -211,8 +212,10 @@ FlGenerateFilename ( /* Try to find the last dot in the filename */ + DirectoryPosition = strrchr (NewFilename, '/'); Position = strrchr (NewFilename, '.'); - if (Position) + + if (Position && (Position > DirectoryPosition)) { /* Tack on the new suffix */ diff --git a/source/common/adwalk.c b/source/common/adwalk.c index 5b04859..3aaae52 100644 --- a/source/common/adwalk.c +++ b/source/common/adwalk.c @@ -469,8 +469,9 @@ AcpiDmFindOrphanDescending ( !ChildOp->Common.Node) { AcpiNsExternalizeName (ACPI_UINT32_MAX, ChildOp->Common.Value.String, - NULL, &Path); - AcpiOsPrintf ("/* %-16s A-NAMEPATH: %s */\n", Op->Common.AmlOpName, Path); + NULL, &Path); + AcpiOsPrintf ("/* %-16s A-NAMEPATH: %s */\n", + Op->Common.AmlOpName, Path); ACPI_FREE (Path); NextOp = Op->Common.Next; @@ -478,22 +479,26 @@ AcpiDmFindOrphanDescending ( { /* This NamePath has no args, assume it is an integer */ - AcpiDmAddToExternalList (ChildOp, ChildOp->Common.Value.String, ACPI_TYPE_INTEGER, 0); + AcpiDmAddOpToExternalList (ChildOp, + ChildOp->Common.Value.String, ACPI_TYPE_INTEGER, 0, 0); return (AE_OK); } ArgCount = AcpiDmInspectPossibleArgs (3, 1, NextOp); - AcpiOsPrintf ("/* A-CHILDREN: %u Actual %u */\n", ArgCount, AcpiDmCountChildren (Op)); + AcpiOsPrintf ("/* A-CHILDREN: %u Actual %u */\n", + ArgCount, AcpiDmCountChildren (Op)); if (ArgCount < 1) { /* One Arg means this is just a Store(Name,Target) */ - AcpiDmAddToExternalList (ChildOp, ChildOp->Common.Value.String, ACPI_TYPE_INTEGER, 0); + AcpiDmAddOpToExternalList (ChildOp, + ChildOp->Common.Value.String, ACPI_TYPE_INTEGER, 0, 0); return (AE_OK); } - AcpiDmAddToExternalList (ChildOp, ChildOp->Common.Value.String, ACPI_TYPE_METHOD, ArgCount); + AcpiDmAddOpToExternalList (ChildOp, + ChildOp->Common.Value.String, ACPI_TYPE_METHOD, ArgCount, 0); } break; #endif @@ -509,7 +514,8 @@ AcpiDmFindOrphanDescending ( { /* This NamePath has no args, assume it is an integer */ - AcpiDmAddToExternalList (ChildOp, ChildOp->Common.Value.String, ACPI_TYPE_INTEGER, 0); + AcpiDmAddOpToExternalList (ChildOp, + ChildOp->Common.Value.String, ACPI_TYPE_INTEGER, 0, 0); return (AE_OK); } @@ -518,11 +524,13 @@ AcpiDmFindOrphanDescending ( { /* One Arg means this is just a Store(Name,Target) */ - AcpiDmAddToExternalList (ChildOp, ChildOp->Common.Value.String, ACPI_TYPE_INTEGER, 0); + AcpiDmAddOpToExternalList (ChildOp, + ChildOp->Common.Value.String, ACPI_TYPE_INTEGER, 0, 0); return (AE_OK); } - AcpiDmAddToExternalList (ChildOp, ChildOp->Common.Value.String, ACPI_TYPE_METHOD, ArgCount); + AcpiDmAddOpToExternalList (ChildOp, + ChildOp->Common.Value.String, ACPI_TYPE_METHOD, ArgCount, 0); } break; @@ -554,7 +562,8 @@ AcpiDmFindOrphanDescending ( /* And namepath is the first argument */ (ParentOp->Common.Value.Arg == Op)) { - AcpiDmAddToExternalList (Op, Op->Common.Value.String, ACPI_TYPE_INTEGER, 0); + AcpiDmAddOpToExternalList (Op, + Op->Common.Value.String, ACPI_TYPE_INTEGER, 0, 0); break; } } @@ -564,8 +573,8 @@ AcpiDmFindOrphanDescending ( * operator) - it *must* be a method invocation, nothing else is * grammatically possible. */ - AcpiDmAddToExternalList (Op, Op->Common.Value.String, ACPI_TYPE_METHOD, ArgCount); - + AcpiDmAddOpToExternalList (Op, + Op->Common.Value.String, ACPI_TYPE_METHOD, ArgCount, 0); } break; @@ -741,6 +750,7 @@ AcpiDmXrefDescendingOp ( ACPI_NAMESPACE_NODE *Node; ACPI_OPERAND_OBJECT *Object; UINT32 ParamCount = 0; + char *Pathname; WalkState = Info->WalkState; @@ -808,11 +818,14 @@ AcpiDmXrefDescendingOp ( * The namespace is also used as a lookup table for references to resource * descriptors and the fields within them. */ + Node = NULL; 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; } @@ -830,16 +843,28 @@ AcpiDmXrefDescendingOp ( if (!(Op->Asl.Parent && (Op->Asl.Parent->Asl.AmlOpcode == AML_COND_REF_OF_OP))) { - AcpiDmAddToExternalList (Op, Path, (UINT8) ObjectType, 0); + if (Node) + { + AcpiDmAddNodeToExternalList (Node, + (UINT8) ObjectType, 0, 0); + } + else + { + AcpiDmAddOpToExternalList (Op, Path, + (UINT8) ObjectType, 0, 0); + } } } } /* - * Found the node in external table, add it to external list - * Node->OwnerId == 0 indicates built-in ACPI Names, _OS_ etc + * Found the node, but check if it came from an external table. + * Add it to external list. Note: Node->OwnerId == 0 indicates + * one of the built-in ACPI Names (_OS_ etc.) which can safely + * be ignored. */ - else if (Node->OwnerId && WalkState->OwnerId != Node->OwnerId) + else if (Node->OwnerId && + (WalkState->OwnerId != Node->OwnerId)) { ObjectType2 = ObjectType; @@ -853,7 +878,16 @@ AcpiDmXrefDescendingOp ( } } - AcpiDmAddToExternalList (Op, Path, (UINT8) ObjectType2, ParamCount | 0x80); + Pathname = AcpiNsGetExternalPathname (Node); + if (!Pathname) + { + return (AE_NO_MEMORY); + } + + AcpiDmAddNodeToExternalList (Node, (UINT8) ObjectType2, + ParamCount, ACPI_EXT_RESOLVED_REFERENCE); + + ACPI_FREE (Pathname); Op->Common.Node = Node; } else diff --git a/source/common/dmextern.c b/source/common/dmextern.c index 002d088..13ed0e6 100644 --- a/source/common/dmextern.c +++ b/source/common/dmextern.c @@ -104,10 +104,19 @@ AcpiDmNormalizeParentPrefix ( char *Path); static void -AcpiDmAddToExternalListFromFile ( +AcpiDmAddPathToExternalList ( char *Path, UINT8 Type, - UINT32 Value); + UINT32 Value, + UINT16 Flags); + +static ACPI_STATUS +AcpiDmCreateNewExternal ( + char *ExternalPath, + char *InternalPath, + UINT8 Type, + UINT32 Value, + UINT16 Flags); /******************************************************************************* @@ -349,196 +358,6 @@ AcpiDmClearExternalFileList ( /******************************************************************************* * - * FUNCTION: AcpiDmAddToExternalList - * - * PARAMETERS: Op - Current parser Op - * Path - Internal (AML) path to the object - * Type - ACPI object type to be added - * Value - Arg count if adding a Method object - * - * RETURN: None - * - * DESCRIPTION: Insert a new name into the global list of Externals which - * will in turn be later emitted as an External() declaration - * in the disassembled output. - * - ******************************************************************************/ - -void -AcpiDmAddToExternalList ( - ACPI_PARSE_OBJECT *Op, - char *Path, - UINT8 Type, - UINT32 Value) -{ - char *ExternalPath; - char *Fullpath = NULL; - ACPI_EXTERNAL_LIST *NewExternal; - ACPI_EXTERNAL_LIST *NextExternal; - ACPI_EXTERNAL_LIST *PrevExternal = NULL; - ACPI_STATUS Status; - BOOLEAN Resolved = FALSE; - - - if (!Path) - { - return; - } - - if (Type == ACPI_TYPE_METHOD) - { - if (Value & 0x80) - { - Resolved = TRUE; - } - Value &= 0x07; - } - - /* - * We don't want External() statements to contain a leading '\'. - * This prevents duplicate external statements of the form: - * - * External (\ABCD) - * External (ABCD) - * - * This would cause a compile time error when the disassembled - * output file is recompiled. - */ - if ((*Path == AML_ROOT_PREFIX) && (Path[1])) - { - Path++; - } - - /* Externalize the ACPI pathname */ - - Status = AcpiNsExternalizeName (ACPI_UINT32_MAX, Path, - NULL, &ExternalPath); - if (ACPI_FAILURE (Status)) - { - return; - } - - /* - * Get the full pathname from the root if "Path" has one or more - * parent prefixes (^). Note: path will not contain a leading '\'. - */ - if (*Path == (UINT8) AML_PARENT_PREFIX) - { - Fullpath = AcpiDmNormalizeParentPrefix (Op, ExternalPath); - if (Fullpath) - { - /* Set new external path */ - - ACPI_FREE (ExternalPath); - ExternalPath = Fullpath; - } - } - - /* Check all existing externals to ensure no duplicates */ - - NextExternal = AcpiGbl_ExternalList; - while (NextExternal) - { - if (!ACPI_STRCMP (ExternalPath, NextExternal->Path)) - { - /* Duplicate method, check that the Value (ArgCount) is the same */ - - if ((NextExternal->Type == ACPI_TYPE_METHOD) && - (NextExternal->Value != Value)) - { - ACPI_ERROR ((AE_INFO, - "External method arg count mismatch %s: Current %u, attempted %u", - NextExternal->Path, NextExternal->Value, Value)); - } - - /* Allow upgrade of type from ANY */ - - else if (NextExternal->Type == ACPI_TYPE_ANY) - { - NextExternal->Type = Type; - NextExternal->Value = Value; - } - - ACPI_FREE (ExternalPath); - return; - } - - NextExternal = NextExternal->Next; - } - - /* Allocate and init a new External() descriptor */ - - NewExternal = ACPI_ALLOCATE_ZEROED (sizeof (ACPI_EXTERNAL_LIST)); - if (!NewExternal) - { - ACPI_FREE (ExternalPath); - return; - } - - NewExternal->Path = ExternalPath; - NewExternal->Type = Type; - NewExternal->Value = Value; - NewExternal->Resolved = Resolved; - NewExternal->Length = (UINT16) ACPI_STRLEN (ExternalPath); - - /* Was the external path with parent prefix normalized to a fullpath? */ - - if (Fullpath == ExternalPath) - { - /* Get new internal path */ - - Status = AcpiNsInternalizeName (ExternalPath, &Path); - if (ACPI_FAILURE (Status)) - { - ACPI_FREE (ExternalPath); - ACPI_FREE (NewExternal); - return; - } - - /* Set flag to indicate External->InternalPath need to be freed */ - - NewExternal->Flags |= ACPI_IPATH_ALLOCATED; - } - - NewExternal->InternalPath = Path; - - /* Link the new descriptor into the global list, alphabetically ordered */ - - NextExternal = AcpiGbl_ExternalList; - while (NextExternal) - { - if (AcpiUtStricmp (NewExternal->Path, NextExternal->Path) < 0) - { - if (PrevExternal) - { - PrevExternal->Next = NewExternal; - } - else - { - AcpiGbl_ExternalList = NewExternal; - } - - NewExternal->Next = NextExternal; - return; - } - - PrevExternal = NextExternal; - NextExternal = NextExternal->Next; - } - - if (PrevExternal) - { - PrevExternal->Next = NewExternal; - } - else - { - AcpiGbl_ExternalList = NewExternal; - } -} - - -/******************************************************************************* - * * FUNCTION: AcpiDmGetExternalsFromFile * * PARAMETERS: None @@ -619,7 +438,8 @@ AcpiDmGetExternalsFromFile ( AcpiOsPrintf ("%s: Importing method external (%u arguments) %s\n", Gbl_ExternalRefFilename, ArgCount, MethodName); - AcpiDmAddToExternalListFromFile (MethodName, ACPI_TYPE_METHOD, ArgCount | 0x80); + AcpiDmAddPathToExternalList (MethodName, ACPI_TYPE_METHOD, + ArgCount, (ACPI_EXT_RESOLVED_REFERENCE | ACPI_EXT_ORIGIN_FROM_FILE)); ImportCount++; } @@ -644,11 +464,13 @@ AcpiDmGetExternalsFromFile ( /******************************************************************************* * - * FUNCTION: AcpiDmAddToExternalListFromFile + * FUNCTION: AcpiDmAddOpToExternalList * - * PARAMETERS: Path - Internal (AML) path to the object + * PARAMETERS: Op - Current parser Op + * Path - Internal (AML) path to the object * Type - ACPI object type to be added * Value - Arg count if adding a Method object + * Flags - To be passed to the external object * * RETURN: None * @@ -656,60 +478,315 @@ AcpiDmGetExternalsFromFile ( * will in turn be later emitted as an External() declaration * in the disassembled output. * + * This function handles the most common case where the referenced + * name is simply not found in the constructed namespace. + * ******************************************************************************/ -static void -AcpiDmAddToExternalListFromFile ( +void +AcpiDmAddOpToExternalList ( + ACPI_PARSE_OBJECT *Op, char *Path, UINT8 Type, - UINT32 Value) + UINT32 Value, + UINT16 Flags) { - char *InternalPath; char *ExternalPath; - ACPI_EXTERNAL_LIST *NewExternal; - ACPI_EXTERNAL_LIST *NextExternal; - ACPI_EXTERNAL_LIST *PrevExternal = NULL; + char *InternalPath = Path; + char *Temp; ACPI_STATUS Status; - BOOLEAN Resolved = FALSE; + + + ACPI_FUNCTION_TRACE (DmAddOpToExternalList); if (!Path) { - return; + return_VOID; } - /* TBD: Add a flags parameter */ + /* Remove a root backslash if present */ - if (Type == ACPI_TYPE_METHOD) + if ((*Path == AML_ROOT_PREFIX) && (Path[1])) { - if (Value & 0x80) - { - Resolved = TRUE; - } - Value &= 0x07; + Path++; + } + + /* Externalize the pathname */ + + Status = AcpiNsExternalizeName (ACPI_UINT32_MAX, Path, + NULL, &ExternalPath); + if (ACPI_FAILURE (Status)) + { + return_VOID; } /* - * We don't want External() statements to contain a leading '\'. - * This prevents duplicate external statements of the form: - * - * External (\ABCD) - * External (ABCD) - * - * This would cause a compile time error when the disassembled - * output file is recompiled. + * Get the full pathname from the root if "Path" has one or more + * parent prefixes (^). Note: path will not contain a leading '\'. */ + if (*Path == (UINT8) AML_PARENT_PREFIX) + { + Temp = AcpiDmNormalizeParentPrefix (Op, ExternalPath); + + /* Set new external path */ + + ACPI_FREE (ExternalPath); + ExternalPath = Temp; + if (!Temp) + { + return_VOID; + } + + /* Create the new internal pathname */ + + Flags |= ACPI_EXT_INTERNAL_PATH_ALLOCATED; + Status = AcpiNsInternalizeName (ExternalPath, &InternalPath); + if (ACPI_FAILURE (Status)) + { + ACPI_FREE (ExternalPath); + return_VOID; + } + } + + /* Create the new External() declaration node */ + + Status = AcpiDmCreateNewExternal (ExternalPath, InternalPath, + Type, Value, Flags); + if (ACPI_FAILURE (Status)) + { + ACPI_FREE (ExternalPath); + if (Flags & ACPI_EXT_INTERNAL_PATH_ALLOCATED) + { + ACPI_FREE (InternalPath); + } + } + + return_VOID; +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDmAddNodeToExternalList + * + * PARAMETERS: Node - Namespace node for object to be added + * Type - ACPI object type to be added + * Value - Arg count if adding a Method object + * Flags - To be passed to the external object + * + * RETURN: None + * + * DESCRIPTION: Insert a new name into the global list of Externals which + * will in turn be later emitted as an External() declaration + * in the disassembled output. + * + * This function handles the case where the referenced name has + * been found in the namespace, but the name originated in a + * table other than the one that is being disassembled (such + * as a table that is added via the iASL -e option). + * + ******************************************************************************/ + +void +AcpiDmAddNodeToExternalList ( + ACPI_NAMESPACE_NODE *Node, + UINT8 Type, + UINT32 Value, + UINT16 Flags) +{ + char *ExternalPath; + char *InternalPath; + char *Temp; + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE (DmAddNodeToExternalList); + + + if (!Node) + { + return_VOID; + } + + /* Get the full external and internal pathnames to the node */ + + ExternalPath = AcpiNsGetExternalPathname (Node); + if (!ExternalPath) + { + return_VOID; + } + + Status = AcpiNsInternalizeName (ExternalPath, &InternalPath); + if (ACPI_FAILURE (Status)) + { + ACPI_FREE (ExternalPath); + return_VOID; + } + + /* Remove the root backslash */ + + if ((*ExternalPath == AML_ROOT_PREFIX) && (ExternalPath[1])) + { + Temp = ACPI_ALLOCATE_ZEROED (ACPI_STRLEN (ExternalPath) + 1); + if (!Temp) + { + return_VOID; + } + + ACPI_STRCPY (Temp, &ExternalPath[1]); + ACPI_FREE (ExternalPath); + ExternalPath = Temp; + } + + /* Create the new External() declaration node */ + + Status = AcpiDmCreateNewExternal (ExternalPath, InternalPath, Type, + Value, (Flags | ACPI_EXT_INTERNAL_PATH_ALLOCATED)); + if (ACPI_FAILURE (Status)) + { + ACPI_FREE (ExternalPath); + ACPI_FREE (InternalPath); + } + + return_VOID; +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDmAddPathToExternalList + * + * PARAMETERS: Path - External name of the object to be added + * Type - ACPI object type to be added + * Value - Arg count if adding a Method object + * Flags - To be passed to the external object + * + * RETURN: None + * + * DESCRIPTION: Insert a new name into the global list of Externals which + * will in turn be later emitted as an External() declaration + * in the disassembled output. + * + * This function currently is used to add externals via a + * reference file (via the -fe iASL option). + * + ******************************************************************************/ + +static void +AcpiDmAddPathToExternalList ( + char *Path, + UINT8 Type, + UINT32 Value, + UINT16 Flags) +{ + char *InternalPath; + char *ExternalPath; + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE (DmAddPathToExternalList); + + + if (!Path) + { + return_VOID; + } + + /* Remove a root backslash if present */ + if ((*Path == AML_ROOT_PREFIX) && (Path[1])) { Path++; } + /* Create the internal and external pathnames */ + + Status = AcpiNsInternalizeName (Path, &InternalPath); + if (ACPI_FAILURE (Status)) + { + return_VOID; + } + + Status = AcpiNsExternalizeName (ACPI_UINT32_MAX, InternalPath, + NULL, &ExternalPath); + if (ACPI_FAILURE (Status)) + { + ACPI_FREE (InternalPath); + return_VOID; + } + + /* Create the new External() declaration node */ + + Status = AcpiDmCreateNewExternal (ExternalPath, InternalPath, + Type, Value, (Flags | ACPI_EXT_INTERNAL_PATH_ALLOCATED)); + if (ACPI_FAILURE (Status)) + { + ACPI_FREE (ExternalPath); + ACPI_FREE (InternalPath); + } + + return_VOID; +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDmCreateNewExternal + * + * PARAMETERS: ExternalPath - External path to the object + * InternalPath - Internal (AML) path to the object + * Type - ACPI object type to be added + * Value - Arg count if adding a Method object + * Flags - To be passed to the external object + * + * RETURN: Status + * + * DESCRIPTION: Common low-level function to insert a new name into the global + * list of Externals which will in turn be later emitted as + * External() declarations in the disassembled output. + * + * Note: The external name should not include a root prefix + * (backslash). We do not want External() statements to contain + * a leading '\', as this prevents duplicate external statements + * of the form: + * + * External (\ABCD) + * External (ABCD) + * + * This would cause a compile time error when the disassembled + * output file is recompiled. + * + * There are two cases that are handled here. For both, we emit + * an External() statement: + * 1) The name was simply not found in the namespace. + * 2) The name was found, but it originated in a table other than + * the table that is being disassembled. + * + ******************************************************************************/ + +static ACPI_STATUS +AcpiDmCreateNewExternal ( + char *ExternalPath, + char *InternalPath, + UINT8 Type, + UINT32 Value, + UINT16 Flags) +{ + ACPI_EXTERNAL_LIST *NewExternal; + ACPI_EXTERNAL_LIST *NextExternal; + ACPI_EXTERNAL_LIST *PrevExternal = NULL; + + + ACPI_FUNCTION_TRACE (DmCreateNewExternal); + + /* Check all existing externals to ensure no duplicates */ NextExternal = AcpiGbl_ExternalList; while (NextExternal) { - if (!ACPI_STRCMP (Path, NextExternal->Path)) + if (!ACPI_STRCMP (ExternalPath, NextExternal->Path)) { /* Duplicate method, check that the Value (ArgCount) is the same */ @@ -717,12 +794,8 @@ AcpiDmAddToExternalListFromFile ( (NextExternal->Value != Value)) { ACPI_ERROR ((AE_INFO, - "(File) External method arg count mismatch %s: Current %u, override to %u", + "External method arg count mismatch %s: Current %u, attempted %u", NextExternal->Path, NextExternal->Value, Value)); - - /* Override, since new value came from external reference file */ - - NextExternal->Value = Value; } /* Allow upgrade of type from ANY */ @@ -733,44 +806,31 @@ AcpiDmAddToExternalListFromFile ( NextExternal->Value = Value; } - return; + return_ACPI_STATUS (AE_ALREADY_EXISTS); } NextExternal = NextExternal->Next; } - /* Get the internal pathname (AML format) */ - - Status = AcpiNsInternalizeName (Path, &InternalPath); - if (ACPI_FAILURE (Status)) - { - return; - } - /* Allocate and init a new External() descriptor */ NewExternal = ACPI_ALLOCATE_ZEROED (sizeof (ACPI_EXTERNAL_LIST)); if (!NewExternal) { - ACPI_FREE (InternalPath); - return; + return_ACPI_STATUS (AE_NO_MEMORY); } - /* Must copy and normalize the input path */ - - AcpiNsExternalizeName (ACPI_UINT32_MAX, InternalPath, NULL, &ExternalPath); + ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, + "Adding external reference node (%s) type [%s]\n", + ExternalPath, AcpiUtGetTypeName (Type))); + NewExternal->Flags = Flags; + NewExternal->Value = Value; NewExternal->Path = ExternalPath; NewExternal->Type = Type; - NewExternal->Value = Value; - NewExternal->Resolved = Resolved; - NewExternal->Length = (UINT16) ACPI_STRLEN (Path); + NewExternal->Length = (UINT16) ACPI_STRLEN (ExternalPath); NewExternal->InternalPath = InternalPath; - /* Set flag to indicate External->InternalPath needs to be freed */ - - NewExternal->Flags |= ACPI_IPATH_ALLOCATED | ACPI_FROM_REFERENCE_FILE; - /* Link the new descriptor into the global list, alphabetically ordered */ NextExternal = AcpiGbl_ExternalList; @@ -788,7 +848,7 @@ AcpiDmAddToExternalListFromFile ( } NewExternal->Next = NextExternal; - return; + return_ACPI_STATUS (AE_OK); } PrevExternal = NextExternal; @@ -803,6 +863,8 @@ AcpiDmAddToExternalListFromFile ( { AcpiGbl_ExternalList = NewExternal; } + + return_ACPI_STATUS (AE_OK); } @@ -978,7 +1040,7 @@ AcpiDmEmitExternals ( if (NextExternal->Type == ACPI_TYPE_METHOD) { AcpiGbl_NumExternalMethods++; - if (NextExternal->Resolved) + if (NextExternal->Flags & ACPI_EXT_RESOLVED_REFERENCE) { AcpiGbl_ResolvedExternalMethods++; } @@ -997,7 +1059,7 @@ AcpiDmEmitExternals ( while (NextExternal) { if ((NextExternal->Type == ACPI_TYPE_METHOD) && - (!NextExternal->Resolved)) + (!(NextExternal->Flags & ACPI_EXT_RESOLVED_REFERENCE))) { AcpiOsPrintf (" External (%s%s", NextExternal->Path, @@ -1008,7 +1070,7 @@ AcpiDmEmitExternals ( "guessing %u arguments (may be incorrect, see warning above)\n", NextExternal->Value); - NextExternal->Emitted = TRUE; + NextExternal->Flags |= ACPI_EXT_EXTERNAL_EMITTED; } NextExternal = NextExternal->Next; @@ -1029,7 +1091,8 @@ AcpiDmEmitExternals ( NextExternal = AcpiGbl_ExternalList; while (NextExternal) { - if (!NextExternal->Emitted && (NextExternal->Flags & ACPI_FROM_REFERENCE_FILE)) + if (!(NextExternal->Flags & ACPI_EXT_EXTERNAL_EMITTED) && + (NextExternal->Flags & ACPI_EXT_ORIGIN_FROM_FILE)) { AcpiOsPrintf (" External (%s%s", NextExternal->Path, @@ -1044,7 +1107,7 @@ AcpiDmEmitExternals ( { AcpiOsPrintf (")\n"); } - NextExternal->Emitted = TRUE; + NextExternal->Flags |= ACPI_EXT_EXTERNAL_EMITTED; } NextExternal = NextExternal->Next; @@ -1058,7 +1121,7 @@ AcpiDmEmitExternals ( */ while (AcpiGbl_ExternalList) { - if (!AcpiGbl_ExternalList->Emitted) + if (!(AcpiGbl_ExternalList->Flags & ACPI_EXT_EXTERNAL_EMITTED)) { AcpiOsPrintf (" External (%s%s", AcpiGbl_ExternalList->Path, @@ -1080,7 +1143,7 @@ AcpiDmEmitExternals ( /* Free this external info block and move on to next external */ NextExternal = AcpiGbl_ExternalList->Next; - if (AcpiGbl_ExternalList->Flags & ACPI_IPATH_ALLOCATED) + if (AcpiGbl_ExternalList->Flags & ACPI_EXT_INTERNAL_PATH_ALLOCATED) { ACPI_FREE (AcpiGbl_ExternalList->InternalPath); } diff --git a/source/common/dmtable.c b/source/common/dmtable.c index 255c3c2..74a2188 100644 --- a/source/common/dmtable.c +++ b/source/common/dmtable.c @@ -205,6 +205,12 @@ static const char *AcpiDmMadtSubnames[] = "Unknown SubTable Type" /* Reserved */ }; +static const char *AcpiDmPcctSubnames[] = +{ + "Generic Communications Subspace", /* ACPI_PCCT_TYPE_GENERIC_SUBSPACE */ + "Unknown SubTable Type" /* Reserved */ +}; + static const char *AcpiDmPmttSubnames[] = { "Socket", /* ACPI_PMTT_TYPE_SOCKET */ @@ -286,7 +292,7 @@ ACPI_DMTABLE_DATA AcpiDmTableData[] = {ACPI_SIG_BOOT, AcpiDmTableInfoBoot, NULL, NULL, TemplateBoot, "Simple Boot Flag Table"}, {ACPI_SIG_CPEP, NULL, AcpiDmDumpCpep, DtCompileCpep, TemplateCpep, "Corrected Platform Error Polling table"}, {ACPI_SIG_CSRT, NULL, AcpiDmDumpCsrt, DtCompileCsrt, TemplateCsrt, "Core System Resource Table"}, - {ACPI_SIG_DBG2, NULL, AcpiDmDumpDbg2, NULL, NULL, "Debug Port table type 2"}, + {ACPI_SIG_DBG2, AcpiDmTableInfoDbg2, AcpiDmDumpDbg2, DtCompileDbg2, TemplateDbg2, "Debug Port table type 2"}, {ACPI_SIG_DBGP, AcpiDmTableInfoDbgp, NULL, NULL, TemplateDbgp, "Debug Port table"}, {ACPI_SIG_DMAR, NULL, AcpiDmDumpDmar, DtCompileDmar, TemplateDmar, "DMA Remapping table"}, {ACPI_SIG_ECDT, AcpiDmTableInfoEcdt, NULL, NULL, TemplateEcdt, "Embedded Controller Boot Resources Table"}, @@ -304,7 +310,7 @@ ACPI_DMTABLE_DATA AcpiDmTableData[] = {ACPI_SIG_MPST, AcpiDmTableInfoMpst, AcpiDmDumpMpst, DtCompileMpst, TemplateMpst, "Memory Power State Table"}, {ACPI_SIG_MSCT, NULL, AcpiDmDumpMsct, DtCompileMsct, TemplateMsct, "Maximum System Characteristics Table"}, {ACPI_SIG_MTMR, NULL, AcpiDmDumpMtmr, DtCompileMtmr, TemplateMtmr, "MID Timer Table"}, - {ACPI_SIG_PCCT, NULL, AcpiDmDumpPcct, NULL, NULL, "Platform Communications Channel Table"}, + {ACPI_SIG_PCCT, AcpiDmTableInfoPcct, AcpiDmDumpPcct, DtCompilePcct, TemplatePcct, "Platform Communications Channel Table"}, {ACPI_SIG_PMTT, NULL, AcpiDmDumpPmtt, DtCompilePmtt, TemplatePmtt, "Platform Memory Topology Table"}, {ACPI_SIG_RSDT, NULL, AcpiDmDumpRsdt, DtCompileRsdt, TemplateRsdt, "Root System Description Table"}, {ACPI_SIG_S3PT, NULL, NULL, NULL, TemplateS3pt, "S3 Performance Table"}, @@ -650,6 +656,7 @@ AcpiDmDumpTable ( UINT32 ByteLength; UINT8 Temp8; UINT16 Temp16; + UINT64 Value; ACPI_DMTABLE_DATA *TableData; const char *Name; BOOLEAN LastOutputBlankLine = FALSE; @@ -692,6 +699,7 @@ AcpiDmDumpTable ( case ACPI_DMT_ACCWIDTH: case ACPI_DMT_IVRS: case ACPI_DMT_MADT: + case ACPI_DMT_PCCT: case ACPI_DMT_PMTT: case ACPI_DMT_SRAT: case ACPI_DMT_ASF: @@ -863,10 +871,19 @@ AcpiDmDumpTable ( * Dump bytes - high byte first, low byte last. * Note: All ACPI tables are little-endian. */ + Value = 0; for (Temp8 = (UINT8) ByteLength; Temp8 > 0; Temp8--) { AcpiOsPrintf ("%2.2X", Target[Temp8 - 1]); + Value |= Target[Temp8 - 1]; + Value <<= 8; + } + + if (!Value && (Info->Flags & DT_DESCRIBES_OPTIONAL)) + { + AcpiOsPrintf (" [Optional field not present]"); } + AcpiOsPrintf ("\n"); break; @@ -1122,6 +1139,19 @@ AcpiDmDumpTable ( AcpiOsPrintf (UINT8_FORMAT, *Target, AcpiDmMadtSubnames[Temp8]); break; + case ACPI_DMT_PCCT: + + /* PCCT subtable types */ + + Temp8 = *Target; + if (Temp8 > ACPI_PCCT_TYPE_RESERVED) + { + Temp8 = ACPI_PCCT_TYPE_RESERVED; + } + + AcpiOsPrintf (UINT8_FORMAT, *Target, AcpiDmPcctSubnames[Temp8]); + break; + case ACPI_DMT_PMTT: /* PMTT subtable types */ diff --git a/source/common/dmtbdump.c b/source/common/dmtbdump.c index 5b98191..41a78b6 100644 --- a/source/common/dmtbdump.c +++ b/source/common/dmtbdump.c @@ -809,8 +809,11 @@ AcpiDmDumpDbg2 ( /* Dump the OemData (optional) */ - AcpiDmDumpBuffer (SubTable, SubTable->OemDataOffset, SubTable->OemDataLength, - Offset + SubTable->OemDataOffset, "OEM Data"); + if (SubTable->OemDataOffset) + { + AcpiDmDumpBuffer (SubTable, SubTable->OemDataOffset, SubTable->OemDataLength, + Offset + SubTable->OemDataOffset, "OEM Data"); + } /* Point to next sub-table */ @@ -1947,11 +1950,31 @@ AcpiDmDumpPcct ( return; } - /* Sub-tables */ + /* Subtables */ SubTable = ACPI_ADD_PTR (ACPI_PCCT_SUBSPACE, Table, Offset); while (Offset < Table->Length) { + /* Common subtable header */ + + AcpiOsPrintf ("\n"); + Status = AcpiDmDumpTable (Length, Offset, SubTable, + SubTable->Header.Length, AcpiDmTableInfoPcctHdr); + if (ACPI_FAILURE (Status)) + { + return; + } + + /* ACPI 5.0: Only one type of PCCT subtable is supported */ + + if (SubTable->Header.Type != ACPI_PCCT_TYPE_GENERIC_SUBSPACE) + { + AcpiOsPrintf ( + "\n**** Unexpected or unknown PCCT subtable type 0x%X\n\n", + SubTable->Header.Type); + return; + } + AcpiOsPrintf ("\n"); Status = AcpiDmDumpTable (Length, Offset, SubTable, SubTable->Header.Length, AcpiDmTableInfoPcct0); @@ -1960,7 +1983,7 @@ AcpiDmDumpPcct ( return; } - /* Point to next sub-table */ + /* Point to next subtable */ Offset += SubTable->Header.Length; SubTable = ACPI_ADD_PTR (ACPI_PCCT_SUBSPACE, SubTable, diff --git a/source/common/dmtbinfo.c b/source/common/dmtbinfo.c index ed675c1..89ea1b2 100644 --- a/source/common/dmtbinfo.c +++ b/source/common/dmtbinfo.c @@ -720,12 +720,12 @@ ACPI_DMTABLE_INFO AcpiDmTableInfoDbg2[] = ACPI_DMTABLE_INFO AcpiDmTableInfoDbg2Device[] = { {ACPI_DMT_UINT8, ACPI_DBG20_OFFSET (Revision), "Revision", 0}, - {ACPI_DMT_UINT16, ACPI_DBG20_OFFSET (Length), "Length", 0}, + {ACPI_DMT_UINT16, ACPI_DBG20_OFFSET (Length), "Length", DT_LENGTH}, {ACPI_DMT_UINT8, ACPI_DBG20_OFFSET (RegisterCount), "Register Count", 0}, {ACPI_DMT_UINT16, ACPI_DBG20_OFFSET (NamepathLength), "Namepath Length", 0}, {ACPI_DMT_UINT16, ACPI_DBG20_OFFSET (NamepathOffset), "Namepath Offset", 0}, - {ACPI_DMT_UINT16, ACPI_DBG20_OFFSET (OemDataLength), "OEM Data Length", 0}, - {ACPI_DMT_UINT16, ACPI_DBG20_OFFSET (OemDataOffset), "OEM Data Offset", 0}, + {ACPI_DMT_UINT16, ACPI_DBG20_OFFSET (OemDataLength), "OEM Data Length", DT_DESCRIBES_OPTIONAL}, + {ACPI_DMT_UINT16, ACPI_DBG20_OFFSET (OemDataOffset), "OEM Data Offset", DT_DESCRIBES_OPTIONAL}, {ACPI_DMT_UINT16, ACPI_DBG20_OFFSET (PortType), "Port Type", 0}, {ACPI_DMT_UINT16, ACPI_DBG20_OFFSET (PortSubtype), "Port Subtype", 0}, {ACPI_DMT_UINT16, ACPI_DBG20_OFFSET (Reserved), "Reserved", 0}, @@ -754,6 +754,12 @@ ACPI_DMTABLE_INFO AcpiDmTableInfoDbg2Name[] = ACPI_DMT_TERMINATOR }; +ACPI_DMTABLE_INFO AcpiDmTableInfoDbg2OemData[] = +{ + {ACPI_DMT_BUFFER, 0, "OEM Data", DT_OPTIONAL}, + ACPI_DMT_TERMINATOR +}; + /******************************************************************************* * @@ -1677,25 +1683,32 @@ ACPI_DMTABLE_INFO AcpiDmTableInfoPcct[] = { {ACPI_DMT_UINT32, ACPI_PCCT_OFFSET (Flags), "Flags (decoded below)", DT_FLAG}, {ACPI_DMT_FLAG0, ACPI_PCCT_FLAG_OFFSET (Flags,0), "Doorbell", 0}, - {ACPI_DMT_UINT32, ACPI_PCCT_OFFSET (Latency), "Command Latency", 0}, - {ACPI_DMT_UINT32, ACPI_PCCT_OFFSET (Reserved), "Reserved", 0}, + {ACPI_DMT_UINT64, ACPI_PCCT_OFFSET (Reserved), "Reserved", 0}, ACPI_DMT_TERMINATOR }; /* PCCT subtables */ +ACPI_DMTABLE_INFO AcpiDmTableInfoPcctHdr[] = +{ + {ACPI_DMT_PCCT, ACPI_PCCT0_OFFSET (Header.Type), "Subtable Type", 0}, + {ACPI_DMT_UINT8, ACPI_PCCT0_OFFSET (Header.Length), "Length", DT_LENGTH}, + ACPI_DMT_TERMINATOR +}; + /* 0: Generic Communications Subspace */ ACPI_DMTABLE_INFO AcpiDmTableInfoPcct0[] = { - {ACPI_DMT_UINT8, ACPI_PCCT0_OFFSET (Header.Type), "Subtable Type", 0}, - {ACPI_DMT_UINT8, ACPI_PCCT0_OFFSET (Header.Length), "Length", DT_LENGTH}, {ACPI_DMT_UINT48, ACPI_PCCT0_OFFSET (Reserved[0]), "Reserved", 0}, {ACPI_DMT_UINT64, ACPI_PCCT0_OFFSET (BaseAddress), "Base Address", 0}, {ACPI_DMT_UINT64, ACPI_PCCT0_OFFSET (Length), "Address Length", 0}, {ACPI_DMT_GAS, ACPI_PCCT0_OFFSET (DoorbellRegister), "Doorbell Register", 0}, {ACPI_DMT_UINT64, ACPI_PCCT0_OFFSET (PreserveMask), "Preserve Mask", 0}, {ACPI_DMT_UINT64, ACPI_PCCT0_OFFSET (WriteMask), "Write Mask", 0}, + {ACPI_DMT_UINT32, ACPI_PCCT0_OFFSET (Latency), "Command Latency", 0}, + {ACPI_DMT_UINT32, ACPI_PCCT0_OFFSET (MaxAccessRate), "Maximum Access Rate", 0}, + {ACPI_DMT_UINT16, ACPI_PCCT0_OFFSET (MinTurnaroundTime), "Minimum Turnaround Time", 0}, ACPI_DMT_TERMINATOR }; diff --git a/source/compiler/aslbtypes.c b/source/compiler/aslbtypes.c index f9dc107..6c15465 100644 --- a/source/compiler/aslbtypes.c +++ b/source/compiler/aslbtypes.c @@ -243,7 +243,7 @@ AnMapEtypeToBtype ( return (ACPI_BTYPE_INTEGER | ACPI_BTYPE_DDB_HANDLE); - case ACPI_BTYPE_DEBUG_OBJECT: + case ACPI_TYPE_DEBUG_OBJECT: /* Cannot be used as a source operand */ diff --git a/source/compiler/asldefine.h b/source/compiler/asldefine.h index 76e2e12..127723d 100644 --- a/source/compiler/asldefine.h +++ b/source/compiler/asldefine.h @@ -55,7 +55,7 @@ #define ASL_INVOCATION_NAME "iasl" #define ASL_CREATOR_ID "INTL" -#define ASL_COMPLIANCE "Supports ACPI Specification Revision 5.0" +#define ASL_COMPLIANCE "Supports ACPI Specification Revision 5.0A" /* Configuration constants */ diff --git a/source/compiler/aslerror.c b/source/compiler/aslerror.c index d0e8e03..87651ec 100644 --- a/source/compiler/aslerror.c +++ b/source/compiler/aslerror.c @@ -200,6 +200,16 @@ AePrintException ( switch (Enode->Level) { + case ASL_WARNING: + case ASL_WARNING2: + case ASL_WARNING3: + + if (!Gbl_DisplayWarnings) + { + return; + } + break; + case ASL_REMARK: if (!Gbl_DisplayRemarks) @@ -222,11 +232,10 @@ AePrintException ( } } - /* Get the file handles */ + /* Get the various required file handles */ OutputFile = Gbl_Files[FileId].Handle; - if (!Enode->SourceLine) { /* Use the merged header/source file if present, otherwise use input file */ diff --git a/source/compiler/aslfiles.c b/source/compiler/aslfiles.c index 0881fd4..43136e9 100644 --- a/source/compiler/aslfiles.c +++ b/source/compiler/aslfiles.c @@ -824,6 +824,7 @@ FlParseInputPathname ( *(Substring+1) = 0; } + UtConvertBackslashes (Gbl_OutputFilenamePrefix); return (AE_OK); } #endif diff --git a/source/compiler/aslglobal.h b/source/compiler/aslglobal.h index 3f2c401..26d9a00 100644 --- a/source/compiler/aslglobal.h +++ b/source/compiler/aslglobal.h @@ -163,6 +163,7 @@ ASL_EXTERN BOOLEAN ASL_INIT_GLOBAL (Gbl_GetAllTables, FALSE); ASL_EXTERN BOOLEAN ASL_INIT_GLOBAL (Gbl_IntegerOptimizationFlag, TRUE); ASL_EXTERN BOOLEAN ASL_INIT_GLOBAL (Gbl_ReferenceOptimizationFlag, TRUE); ASL_EXTERN BOOLEAN ASL_INIT_GLOBAL (Gbl_DisplayRemarks, TRUE); +ASL_EXTERN BOOLEAN ASL_INIT_GLOBAL (Gbl_DisplayWarnings, TRUE); ASL_EXTERN BOOLEAN ASL_INIT_GLOBAL (Gbl_DisplayOptimizations, FALSE); ASL_EXTERN UINT8 ASL_INIT_GLOBAL (Gbl_WarningLevel, ASL_WARNING); ASL_EXTERN BOOLEAN ASL_INIT_GLOBAL (Gbl_UseOriginalCompilerId, FALSE); @@ -232,7 +233,6 @@ ASL_EXTERN UINT32 ASL_INIT_GLOBAL (Gbl_NumNamespaceObjects, 0) ASL_EXTERN UINT32 ASL_INIT_GLOBAL (Gbl_ReservedMethods, 0); ASL_EXTERN char ASL_INIT_GLOBAL (*Gbl_TableSignature, "NO_SIG"); ASL_EXTERN char ASL_INIT_GLOBAL (*Gbl_TableId, "NO_ID"); -ASL_EXTERN FILE *AcpiGbl_DebugFile; /* Placeholder for oswinxf only */ /* Static structures */ diff --git a/source/compiler/asllookup.c b/source/compiler/asllookup.c index e965f18..0f22664 100644 --- a/source/compiler/asllookup.c +++ b/source/compiler/asllookup.c @@ -105,7 +105,9 @@ LkFindUnreferencedObjects ( * DESCRIPTION: Check for an unreferenced namespace object and emit a warning. * We have to be careful, because some types and names are * typically or always unreferenced, we don't want to issue - * excessive warnings. + * excessive warnings. Note: Names that are declared within a + * control method are temporary, so we always issue a remark + * if they are not referenced. * ******************************************************************************/ @@ -117,6 +119,7 @@ LkIsObjectUsed ( void **ReturnValue) { ACPI_NAMESPACE_NODE *Node = ACPI_CAST_PTR (ACPI_NAMESPACE_NODE, ObjHandle); + ACPI_NAMESPACE_NODE *Next; /* Referenced flag is set during the namespace xref */ @@ -126,23 +129,19 @@ LkIsObjectUsed ( return (AE_OK); } - /* - * Ignore names that start with an underscore, - * these are the reserved ACPI names and are typically not referenced, - * they are called by the host OS. - */ - if (Node->Name.Ascii[0] == '_') + if (!Node->Op) { return (AE_OK); } - /* There are some types that are typically not referenced, ignore them */ + /* These types are typically never directly referenced, ignore them */ switch (Node->Type) { case ACPI_TYPE_DEVICE: case ACPI_TYPE_PROCESSOR: case ACPI_TYPE_POWER: + case ACPI_TYPE_THERMAL: case ACPI_TYPE_LOCAL_RESOURCE: return (AE_OK); @@ -152,12 +151,47 @@ LkIsObjectUsed ( break; } - /* All others are valid unreferenced namespace objects */ + /* Determine if the name is within a control method */ - if (Node->Op) + Next = Node->Parent; + while (Next) { - AslError (ASL_WARNING2, ASL_MSG_NOT_REFERENCED, LkGetNameOp (Node->Op), NULL); + if (Next->Type == ACPI_TYPE_METHOD) + { + /* + * Name is within a method, therefore it is temporary. + * Issue a remark even if it is a reserved name (starts + * with an underscore). + */ + sprintf (MsgBuffer, "Name is within method [%4.4s]", + Next->Name.Ascii); + AslError (ASL_REMARK, ASL_MSG_NOT_REFERENCED, + LkGetNameOp (Node->Op), MsgBuffer); + return (AE_OK); + } + + Next = Next->Parent; } + + /* The name is not within a control method */ + + /* + * Ignore names that start with an underscore. These are the reserved + * ACPI names and are typically not referenced since they are meant + * to be called by the host OS. + */ + if (Node->Name.Ascii[0] == '_') + { + return (AE_OK); + } + + /* + * What remains is an unresolved user name that is not within a method. + * However, the object could be referenced via another table, so issue + * the warning at level 2. + */ + AslError (ASL_WARNING2, ASL_MSG_NOT_REFERENCED, + LkGetNameOp (Node->Op), NULL); return (AE_OK); } diff --git a/source/compiler/aslmain.c b/source/compiler/aslmain.c index 81e102f..3ccb70c 100644 --- a/source/compiler/aslmain.c +++ b/source/compiler/aslmain.c @@ -94,11 +94,21 @@ Usage ( printf ("%s\n\n", ASL_COMPLIANCE); ACPI_USAGE_HEADER ("iasl [Options] [Files]"); - printf ("\nGlobal:\n"); + printf ("\nGeneral:\n"); ACPI_OPTION ("-@ <file>", "Specify command file"); ACPI_OPTION ("-I <dir>", "Specify additional include directory"); ACPI_OPTION ("-T <sig>|ALL|*", "Create table template file for ACPI <Sig>"); + ACPI_OPTION ("-p <prefix>", "Specify path/filename prefix for all output files"); ACPI_OPTION ("-v", "Display compiler version"); + ACPI_OPTION ("-vo", "Enable optimization comments"); + ACPI_OPTION ("-vs", "Disable signon"); + + printf ("\nHelp:\n"); + ACPI_OPTION ("-h", "This message"); + ACPI_OPTION ("-hc", "Display operators allowed in constant expressions"); + ACPI_OPTION ("-hf", "Display help for output filename generation"); + ACPI_OPTION ("-hr", "Display ACPI reserved method names"); + ACPI_OPTION ("-ht", "Display currently supported ACPI table names"); printf ("\nPreprocessor:\n"); ACPI_OPTION ("-D <symbol>", "Define symbol for preprocessor use"); @@ -106,13 +116,11 @@ Usage ( ACPI_OPTION ("-P", "Preprocess only and create preprocessor output file (*.i)"); ACPI_OPTION ("-Pn", "Disable preprocessor"); - printf ("\nGeneral Processing:\n"); - ACPI_OPTION ("-p <prefix>", "Specify path/filename prefix for all output files"); - ACPI_OPTION ("-va", "Disable all errors and warnings (summary only)"); + printf ("\nErrors, Warnings, and Remarks:\n"); + ACPI_OPTION ("-va", "Disable all errors/warnings/remarks"); + ACPI_OPTION ("-ve", "Report only errors (ignore warnings and remarks)"); ACPI_OPTION ("-vi", "Less verbose errors and warnings for use with IDEs"); - ACPI_OPTION ("-vo", "Enable optimization comments"); ACPI_OPTION ("-vr", "Disable remarks"); - ACPI_OPTION ("-vs", "Disable signon"); ACPI_OPTION ("-vw <messageid>", "Disable specific warning or remark"); ACPI_OPTION ("-w1 -w2 -w3", "Set warning reporting level"); ACPI_OPTION ("-we", "Report warnings as errors"); @@ -154,13 +162,6 @@ Usage ( ACPI_OPTION ("-in", "Ignore NoOp opcodes"); ACPI_OPTION ("-vt", "Dump binary table data in hex format within output file"); - printf ("\nHelp:\n"); - ACPI_OPTION ("-h", "This message"); - ACPI_OPTION ("-hc", "Display operators allowed in constant expressions"); - ACPI_OPTION ("-hf", "Display help for output filename generation"); - ACPI_OPTION ("-hr", "Display ACPI reserved method names"); - ACPI_OPTION ("-ht", "Display currently supported ACPI table names"); - printf ("\nDebug Options:\n"); ACPI_OPTION ("-bf -bt", "Create debug file (full or parse tree only) (*.txt)"); ACPI_OPTION ("-f", "Ignore errors, force creation of AML output file(s)"); @@ -353,6 +354,7 @@ main ( if (Gbl_UseDefaultAmlFilename) { Gbl_OutputFilenamePrefix = argv[Index2]; + UtConvertBackslashes (Gbl_OutputFilenamePrefix); } Status = AslDoOneFile (argv[Index2]); diff --git a/source/compiler/aslmessages.h b/source/compiler/aslmessages.h index 9fb7229..f95042c 100644 --- a/source/compiler/aslmessages.h +++ b/source/compiler/aslmessages.h @@ -369,7 +369,7 @@ char *AslMessages [] = /* ASL_MSG_NOT_METHOD */ "Not a control method, cannot invoke", /* ASL_MSG_NOT_PARAMETER */ "Not a parameter, used as local only", /* ASL_MSG_NOT_REACHABLE */ "Object is not accessible from this scope", -/* ASL_MSG_NOT_REFERENCED */ "Namespace object is not referenced", +/* ASL_MSG_NOT_REFERENCED */ "Object is not referenced", /* ASL_MSG_NULL_DESCRIPTOR */ "Min/Max/Length/Gran are all zero, but no resource tag", /* ASL_MSG_NULL_STRING */ "Invalid zero-length (null) string", /* ASL_MSG_OPEN */ "Could not open file", diff --git a/source/compiler/asloperands.c b/source/compiler/asloperands.c index 4afbd96..8d03ae5 100644 --- a/source/compiler/asloperands.c +++ b/source/compiler/asloperands.c @@ -922,6 +922,7 @@ OpnDoDefinitionBlock ( strcat (Filename, (char *) Child->Asl.Value.Buffer); Gbl_OutputFilenamePrefix = Filename; + UtConvertBackslashes (Gbl_OutputFilenamePrefix); } Child->Asl.ParseOpcode = PARSEOP_DEFAULT_ARG; diff --git a/source/compiler/aslopt.c b/source/compiler/aslopt.c index 682737e..7a41ce8 100644 --- a/source/compiler/aslopt.c +++ b/source/compiler/aslopt.c @@ -576,7 +576,8 @@ OptOptimizeNamePath ( return_VOID; } - ACPI_DEBUG_PRINT_RAW ((ACPI_DB_OPTIMIZATIONS, "%5d [%12.12s] [%12.12s] ", + ACPI_DEBUG_PRINT_RAW ((ACPI_DB_OPTIMIZATIONS, + "PATH OPTIMIZE: Line %5d ParentOp [%12.12s] ThisOp [%12.12s] ", Op->Asl.LogicalLineNumber, AcpiPsGetOpcodeName (Op->Common.Parent->Common.AmlOpcode), AcpiPsGetOpcodeName (Op->Common.AmlOpcode))); @@ -620,7 +621,7 @@ OptOptimizeNamePath ( { /* This is the declaration of a new name */ - ACPI_DEBUG_PRINT_RAW ((ACPI_DB_OPTIMIZATIONS, "NAME")); + ACPI_DEBUG_PRINT_RAW ((ACPI_DB_OPTIMIZATIONS, "NAME\n")); /* * The node of interest is the parent of this node (the containing @@ -646,7 +647,7 @@ OptOptimizeNamePath ( { /* This is a reference to an existing named object */ - ACPI_DEBUG_PRINT_RAW ((ACPI_DB_OPTIMIZATIONS, "REF ")); + ACPI_DEBUG_PRINT_RAW ((ACPI_DB_OPTIMIZATIONS, "REFERENCE\n")); } /* @@ -688,9 +689,10 @@ OptOptimizeNamePath ( } ACPI_DEBUG_PRINT_RAW ((ACPI_DB_OPTIMIZATIONS, - "%37s (%2u) ==> %-32s(%2u) %-32s", - (char *) CurrentPath.Pointer, (UINT32) CurrentPath.Length, - (char *) TargetPath.Pointer, (UINT32) TargetPath.Length, ExternalNameString)); + "CURRENT SCOPE: (%2u) %-37s FULL PATH TO NAME: (%2u) %-32s ACTUAL AML:%-32s\n", + (UINT32) CurrentPath.Length, (char *) CurrentPath.Pointer, + (UINT32) TargetPath.Length, (char *) TargetPath.Pointer, + ExternalNameString)); ACPI_FREE (ExternalNameString); @@ -747,7 +749,8 @@ OptOptimizeNamePath ( HowMuchShorter = (AmlNameStringLength - ACPI_STRLEN (NewPath)); OptTotal += HowMuchShorter; - ACPI_DEBUG_PRINT_RAW ((ACPI_DB_OPTIMIZATIONS, " REDUCED %2u (%u)", + ACPI_DEBUG_PRINT_RAW ((ACPI_DB_OPTIMIZATIONS, + " REDUCED BY %2u (TOTAL SAVED %2u)", (UINT32) HowMuchShorter, OptTotal)); if (Flags & AML_NAMED) diff --git a/source/compiler/asloptions.c b/source/compiler/asloptions.c index 00e3000..d623567 100644 --- a/source/compiler/asloptions.c +++ b/source/compiler/asloptions.c @@ -523,6 +523,8 @@ AslDoOptions ( case 'p': /* Override default AML output filename */ Gbl_OutputFilenamePrefix = AcpiGbl_Optarg; + UtConvertBackslashes (Gbl_OutputFilenamePrefix); + Gbl_UseDefaultAmlFilename = FALSE; break; @@ -606,11 +608,19 @@ AslDoOptions ( case 'a': - /* Disable All error/warning messages */ + /* Disable all error/warning/remark messages */ Gbl_NoErrors = TRUE; break; + case 'e': + + /* Disable all warning/remark messages (errors only) */ + + Gbl_DisplayRemarks = FALSE; + Gbl_DisplayWarnings = FALSE; + break; + case 'i': /* * Support for integrated development environment(s). diff --git a/source/compiler/aslstartup.c b/source/compiler/aslstartup.c index b57b3b0..3e2841f 100644 --- a/source/compiler/aslstartup.c +++ b/source/compiler/aslstartup.c @@ -326,6 +326,7 @@ AslDoOneFile ( } Gbl_Files[ASL_FILE_INPUT].Filename = Filename; + UtConvertBackslashes (Filename); /* * AML Disassembly (Optional) diff --git a/source/compiler/aslstubs.c b/source/compiler/aslstubs.c index 5df167b..2b56ae7 100644 --- a/source/compiler/aslstubs.c +++ b/source/compiler/aslstubs.c @@ -239,7 +239,7 @@ ACPI_THREAD_ID AcpiOsGetThreadId ( void) { - return (0xFFFF); + return (1); } ACPI_STATUS diff --git a/source/compiler/aslxref.c b/source/compiler/aslxref.c index a04fefb..363bb9c 100644 --- a/source/compiler/aslxref.c +++ b/source/compiler/aslxref.c @@ -316,7 +316,7 @@ XfNamespaceLocateBegin ( */ if (Op->Asl.CompileFlags & NODE_IS_NAME_DECLARATION) { - return (AE_OK); + return_ACPI_STATUS (AE_OK); } /* We are only interested in opcodes that have an associated name */ @@ -329,7 +329,7 @@ XfNamespaceLocateBegin ( (Op->Asl.ParseOpcode != PARSEOP_NAMESEG) && (Op->Asl.ParseOpcode != PARSEOP_METHODCALL)) { - return (AE_OK); + return_ACPI_STATUS (AE_OK); } /* @@ -340,7 +340,7 @@ XfNamespaceLocateBegin ( if ((Op->Asl.Parent) && (Op->Asl.Parent->Asl.ParseOpcode == PARSEOP_CONDREFOF)) { - return (AE_OK); + return_ACPI_STATUS (AE_OK); } /* @@ -459,7 +459,8 @@ XfNamespaceLocateBegin ( Status = AE_OK; } - return (Status); + + return_ACPI_STATUS (Status); } /* Check for a reference vs. name declaration */ @@ -624,7 +625,6 @@ XfNamespaceLocateBegin ( (Op->Asl.ParseOpcode == PARSEOP_METHODCALL)) { - /* * A reference to a method within one of these opcodes is not an * invocation of the method, it is simply a reference to the method. @@ -634,7 +634,7 @@ XfNamespaceLocateBegin ( (Op->Asl.Parent->Asl.ParseOpcode == PARSEOP_DEREFOF) || (Op->Asl.Parent->Asl.ParseOpcode == PARSEOP_OBJECTTYPE))) { - return (AE_OK); + return_ACPI_STATUS (AE_OK); } /* * There are two types of method invocation: @@ -650,7 +650,7 @@ XfNamespaceLocateBegin ( Op->Asl.ExternalName, AcpiUtGetTypeName (Node->Type)); AslError (ASL_ERROR, ASL_MSG_NOT_METHOD, Op, MsgBuffer); - return (AE_OK); + return_ACPI_STATUS (AE_OK); } /* Save the method node in the caller's op */ @@ -658,7 +658,7 @@ XfNamespaceLocateBegin ( Op->Asl.Node = Node; if (Op->Asl.Parent->Asl.ParseOpcode == PARSEOP_CONDREFOF) { - return (AE_OK); + return_ACPI_STATUS (AE_OK); } /* @@ -823,7 +823,7 @@ XfNamespaceLocateBegin ( } Op->Asl.Node = Node; - return (Status); + return_ACPI_STATUS (Status); } @@ -858,7 +858,7 @@ XfNamespaceLocateEnd ( OpInfo = AcpiPsGetOpcodeInfo (Op->Asl.AmlOpcode); if (!(OpInfo->Flags & AML_NAMED)) { - return (AE_OK); + return_ACPI_STATUS (AE_OK); } /* Not interested in name references, we did not open a scope for them */ @@ -867,7 +867,7 @@ XfNamespaceLocateEnd ( (Op->Asl.ParseOpcode == PARSEOP_NAMESEG) || (Op->Asl.ParseOpcode == PARSEOP_METHODCALL)) { - return (AE_OK); + return_ACPI_STATUS (AE_OK); } /* Pop the scope stack if necessary */ @@ -882,5 +882,5 @@ XfNamespaceLocateEnd ( (void) AcpiDsScopeStackPop (WalkState); } - return (AE_OK); + return_ACPI_STATUS (AE_OK); } diff --git a/source/compiler/dtcompile.c b/source/compiler/dtcompile.c index 2b92322..41e0fc4 100644 --- a/source/compiler/dtcompile.c +++ b/source/compiler/dtcompile.c @@ -446,6 +446,15 @@ DtCompileTable ( return (AE_BAD_PARAMETER); } + /* Ignore optional subtable if name does not match */ + + if ((Info->Flags & DT_OPTIONAL) && + ACPI_STRCMP ((*Field)->Name, Info->Name)) + { + *RetSubtable = NULL; + return (AE_OK); + } + Length = DtGetSubtableLength (*Field, Info); if (Length == ASL_EOF) { diff --git a/source/compiler/dtcompiler.h b/source/compiler/dtcompiler.h index f83ef77..cdf7121 100644 --- a/source/compiler/dtcompiler.h +++ b/source/compiler/dtcompiler.h @@ -400,6 +400,10 @@ DtCompileCsrt ( void **PFieldList); ACPI_STATUS +DtCompileDbg2 ( + void **PFieldList); + +ACPI_STATUS DtCompileDmar ( void **PFieldList); @@ -452,6 +456,10 @@ DtCompilePmtt ( void **PFieldList); ACPI_STATUS +DtCompilePcct ( + void **PFieldList); + +ACPI_STATUS DtCompileRsdt ( void **PFieldList); @@ -503,6 +511,7 @@ extern const unsigned char TemplateBert[]; extern const unsigned char TemplateBgrt[]; extern const unsigned char TemplateCpep[]; extern const unsigned char TemplateCsrt[]; +extern const unsigned char TemplateDbg2[]; extern const unsigned char TemplateDbgp[]; extern const unsigned char TemplateDmar[]; extern const unsigned char TemplateEcdt[]; @@ -520,6 +529,7 @@ extern const unsigned char TemplateMchi[]; extern const unsigned char TemplateMpst[]; extern const unsigned char TemplateMsct[]; extern const unsigned char TemplateMtmr[]; +extern const unsigned char TemplatePcct[]; extern const unsigned char TemplatePmtt[]; extern const unsigned char TemplateRsdt[]; extern const unsigned char TemplateS3pt[]; diff --git a/source/compiler/dtfield.c b/source/compiler/dtfield.c index a5642a1..f9524dd 100644 --- a/source/compiler/dtfield.c +++ b/source/compiler/dtfield.c @@ -340,7 +340,8 @@ DtCompileInteger ( if (Value > MaxValue) { - sprintf (MsgBuffer, "%8.8X%8.8X", ACPI_FORMAT_UINT64 (Value)); + sprintf (MsgBuffer, "%8.8X%8.8X - max %u bytes", + ACPI_FORMAT_UINT64 (Value), ByteLength); DtError (ASL_ERROR, ASL_MSG_INTEGER_SIZE, Field, MsgBuffer); } diff --git a/source/compiler/dttable.c b/source/compiler/dttable.c index 3b84956..7ff5921 100644 --- a/source/compiler/dttable.c +++ b/source/compiler/dttable.c @@ -520,6 +520,156 @@ DtCompileCsrt ( /****************************************************************************** * + * FUNCTION: DtCompileDbg2 + * + * PARAMETERS: List - Current field list pointer + * + * RETURN: Status + * + * DESCRIPTION: Compile DBG2. + * + *****************************************************************************/ + +ACPI_STATUS +DtCompileDbg2 ( + void **List) +{ + ACPI_STATUS Status; + DT_SUBTABLE *Subtable; + DT_SUBTABLE *ParentTable; + DT_FIELD **PFieldList = (DT_FIELD **) List; + UINT32 SubtableCount; + ACPI_DBG2_HEADER *Dbg2Header; + ACPI_DBG2_DEVICE *DeviceInfo; + UINT16 CurrentOffset; + UINT32 i; + + + /* Main table */ + + Status = DtCompileTable (PFieldList, AcpiDmTableInfoDbg2, &Subtable, TRUE); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + ParentTable = DtPeekSubtable (); + DtInsertSubtable (ParentTable, Subtable); + + /* Main table fields */ + + Dbg2Header = ACPI_CAST_PTR (ACPI_DBG2_HEADER, Subtable->Buffer); + Dbg2Header->InfoOffset = sizeof (ACPI_TABLE_HEADER) + ACPI_PTR_DIFF ( + ACPI_ADD_PTR (UINT8, Dbg2Header, sizeof (ACPI_DBG2_HEADER)), Dbg2Header); + + SubtableCount = Dbg2Header->InfoCount; + DtPushSubtable (Subtable); + + /* Process all Device Information subtables (Count = InfoCount) */ + + while (*PFieldList && SubtableCount) + { + /* Subtable: Debug Device Information */ + + Status = DtCompileTable (PFieldList, AcpiDmTableInfoDbg2Device, + &Subtable, TRUE); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + DeviceInfo = ACPI_CAST_PTR (ACPI_DBG2_DEVICE, Subtable->Buffer); + CurrentOffset = (UINT16) sizeof (ACPI_DBG2_DEVICE); + + ParentTable = DtPeekSubtable (); + DtInsertSubtable (ParentTable, Subtable); + DtPushSubtable (Subtable); + + ParentTable = DtPeekSubtable (); + + /* BaseAddressRegister GAS array (Required, size is RegisterCount) */ + + DeviceInfo->BaseAddressOffset = CurrentOffset; + for (i = 0; *PFieldList && (i < DeviceInfo->RegisterCount); i++) + { + Status = DtCompileTable (PFieldList, AcpiDmTableInfoDbg2Addr, + &Subtable, TRUE); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + CurrentOffset += (UINT16) sizeof (ACPI_GENERIC_ADDRESS); + DtInsertSubtable (ParentTable, Subtable); + } + + /* AddressSize array (Required, size = RegisterCount) */ + + DeviceInfo->AddressSizeOffset = CurrentOffset; + for (i = 0; *PFieldList && (i < DeviceInfo->RegisterCount); i++) + { + Status = DtCompileTable (PFieldList, AcpiDmTableInfoDbg2Size, + &Subtable, TRUE); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + CurrentOffset += (UINT16) sizeof (UINT32); + DtInsertSubtable (ParentTable, Subtable); + } + + /* NamespaceString device identifier (Required, size = NamePathLength) */ + + DeviceInfo->NamepathOffset = CurrentOffset; + Status = DtCompileTable (PFieldList, AcpiDmTableInfoDbg2Name, + &Subtable, TRUE); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + /* Update the device info header */ + + DeviceInfo->NamepathLength = (UINT16) Subtable->Length; + CurrentOffset += (UINT16) DeviceInfo->NamepathLength; + DtInsertSubtable (ParentTable, Subtable); + + /* OemData - Variable-length data (Optional, size = OemDataLength) */ + + Status = DtCompileTable (PFieldList, AcpiDmTableInfoDbg2OemData, + &Subtable, TRUE); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + /* Update the device info header (zeros if no OEM data present) */ + + DeviceInfo->OemDataOffset = 0; + DeviceInfo->OemDataLength = 0; + + /* Optional subtable (OemData) */ + + if (Subtable && Subtable->Length) + { + DeviceInfo->OemDataOffset = CurrentOffset; + DeviceInfo->OemDataLength = (UINT16) Subtable->Length; + + DtInsertSubtable (ParentTable, Subtable); + } + + SubtableCount--; + DtPopSubtable (); /* Get next Device Information subtable */ + } + + DtPopSubtable (); + return (AE_OK); +} + + +/****************************************************************************** + * * FUNCTION: DtCompileDmar * * PARAMETERS: List - Current field list pointer @@ -1505,6 +1655,85 @@ DtCompileMtmr ( /****************************************************************************** * + * FUNCTION: DtCompilePcct + * + * PARAMETERS: List - Current field list pointer + * + * RETURN: Status + * + * DESCRIPTION: Compile PCCT. + * + *****************************************************************************/ + +ACPI_STATUS +DtCompilePcct ( + void **List) +{ + ACPI_STATUS Status; + DT_SUBTABLE *Subtable; + DT_SUBTABLE *ParentTable; + DT_FIELD **PFieldList = (DT_FIELD **) List; + DT_FIELD *SubtableStart; + ACPI_SUBTABLE_HEADER *PcctHeader; + ACPI_DMTABLE_INFO *InfoTable; + + + Status = DtCompileTable (PFieldList, AcpiDmTableInfoPcct, + &Subtable, TRUE); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + ParentTable = DtPeekSubtable (); + DtInsertSubtable (ParentTable, Subtable); + + while (*PFieldList) + { + SubtableStart = *PFieldList; + Status = DtCompileTable (PFieldList, AcpiDmTableInfoPcctHdr, + &Subtable, TRUE); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + ParentTable = DtPeekSubtable (); + DtInsertSubtable (ParentTable, Subtable); + DtPushSubtable (Subtable); + + PcctHeader = ACPI_CAST_PTR (ACPI_SUBTABLE_HEADER, Subtable->Buffer); + + switch (PcctHeader->Type) + { + case ACPI_PCCT_TYPE_GENERIC_SUBSPACE: + + InfoTable = AcpiDmTableInfoPcct0; + break; + + default: + + DtFatal (ASL_MSG_UNKNOWN_SUBTABLE, SubtableStart, "PCCT"); + return (AE_ERROR); + } + + Status = DtCompileTable (PFieldList, InfoTable, &Subtable, TRUE); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + ParentTable = DtPeekSubtable (); + DtInsertSubtable (ParentTable, Subtable); + DtPopSubtable (); + } + + return (AE_OK); +} + + +/****************************************************************************** + * * FUNCTION: DtCompilePmtt * * PARAMETERS: List - Current field list pointer diff --git a/source/compiler/dttemplate.h b/source/compiler/dttemplate.h index f620abd..5080eee 100644 --- a/source/compiler/dttemplate.h +++ b/source/compiler/dttemplate.h @@ -174,6 +174,33 @@ const unsigned char TemplateCsrt[] = 0x43,0x48,0x41,0x37 /* 00000148 "CHA7" */ }; +const unsigned char TemplateDbg2[] = +{ + 0x44,0x42,0x47,0x32,0xB2,0x00,0x00,0x00, /* 00000000 "DBG2...." */ + 0x01,0xBA,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" */ + 0x15,0x11,0x13,0x20,0x2C,0x00,0x00,0x00, /* 00000020 "... ,..." */ + 0x02,0x00,0x00,0x00,0xEE,0x3F,0x00,0x02, /* 00000028 ".....?.." */ + 0x09,0x00,0x36,0x00,0x00,0x00,0x00,0x00, /* 00000030 "..6....." */ + 0x00,0x80,0x00,0x00,0x00,0x00,0x16,0x00, /* 00000038 "........" */ + 0x2E,0x00,0x01,0x32,0x00,0x03,0x88,0x77, /* 00000040 "...2...w" */ + 0x66,0x55,0x44,0x33,0x22,0x11,0x01,0x64, /* 00000048 "fUD3"..d" */ + 0x00,0x04,0x11,0x00,0xFF,0xEE,0xDD,0xCC, /* 00000050 "........" */ + 0xBB,0xAA,0x10,0x32,0x54,0x76,0x98,0xBA, /* 00000058 "...2Tv.." */ + 0xDC,0xFE,0x4D,0x79,0x44,0x65,0x76,0x69, /* 00000060 "..MyDevi" */ + 0x63,0x65,0x00,0xEE,0x47,0x00,0x01,0x11, /* 00000068 "ce..G..." */ + 0x00,0x26,0x00,0x10,0x00,0x37,0x00,0x00, /* 00000070 ".&...7.." */ + 0x80,0x00,0x00,0x00,0x00,0x16,0x00,0x22, /* 00000078 "......."" */ + 0x00,0x01,0x64,0x00,0x04,0x11,0x00,0xFF, /* 00000080 "..d....." */ + 0xEE,0xDD,0xCC,0xBB,0xAA,0x98,0xBA,0xDC, /* 00000088 "........" */ + 0xFE,0x5C,0x5C,0x5F,0x53,0x42,0x5F,0x2E, /* 00000090 ".\\_SB_." */ + 0x50,0x43,0x49,0x30,0x2E,0x44,0x42,0x47, /* 00000098 "PCI0.DBG" */ + 0x50,0x00,0x41,0x42,0x43,0x44,0x45,0x46, /* 000000A0 "P.ABCDEF" */ + 0x47,0x48,0x49,0x50,0x51,0x52,0x53,0x54, /* 000000A8 "GHIPQRST" */ + 0x55,0x56 /* 000000B0 "UV" */ +}; + const unsigned char TemplateDbgp[] = { 0x44,0x42,0x47,0x50,0x34,0x00,0x00,0x00, /* 00000000 "DBGP4..." */ @@ -353,10 +380,10 @@ const unsigned char TemplateFacs[] = const unsigned char TemplateFadt[] = { 0x46,0x41,0x43,0x50,0x0C,0x01,0x00,0x00, /* 00000000 "FACP...." */ - 0x05,0x18,0x49,0x4E,0x54,0x45,0x4C,0x20, /* 00000008 "..INTEL " */ + 0x05,0x64,0x49,0x4E,0x54,0x45,0x4C,0x20, /* 00000008 ".dINTEL " */ 0x54,0x45,0x4D,0x50,0x4C,0x41,0x54,0x45, /* 00000010 "TEMPLATE" */ 0x00,0x00,0x00,0x00,0x49,0x4E,0x54,0x4C, /* 00000018 "....INTL" */ - 0x23,0x11,0x11,0x20,0x01,0x00,0x00,0x00, /* 00000020 "#.. ...." */ + 0x15,0x11,0x13,0x20,0x01,0x00,0x00,0x00, /* 00000020 "... ...." */ 0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000028 "........" */ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000030 "........" */ 0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000038 "........" */ @@ -379,7 +406,7 @@ const unsigned char TemplateFadt[] = 0x00,0x00,0x00,0x00,0x01,0x08,0x00,0x00, /* 000000C0 "........" */ 0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 000000C8 "........" */ 0x01,0x20,0x00,0x03,0x01,0x00,0x00,0x00, /* 000000D0 ". ......" */ - 0x00,0x00,0x00,0x00,0x01,0x80,0x00,0x01, /* 000000D8 "........" */ + 0x00,0x00,0x00,0x00,0x01,0x40,0x00,0x01, /* 000000D8 ".....@.." */ 0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 000000E0 "........" */ 0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 000000E8 "........" */ 0x00,0x00,0x00,0x00,0x01,0x08,0x00,0x01, /* 000000F0 "........" */ @@ -646,6 +673,32 @@ const unsigned char TemplateMtmr[] = 0x00,0x00,0x00,0x00 /* 00000048 "...." */ }; +const unsigned char TemplatePcct[] = +{ + 0x50,0x43,0x43,0x54,0xAC,0x00,0x00,0x00, /* 00000000 "PCCT...." */ + 0x01,0x97,0x49,0x4E,0x54,0x45,0x4C,0x20, /* 00000008 "..INTEL " */ + 0x54,0x45,0x4D,0x50,0x4C,0x41,0x54,0x45, /* 00000010 "TEMPLATE" */ + 0x01,0x00,0x00,0x00,0x49,0x4E,0x54,0x4C, /* 00000018 "....INTL" */ + 0x15,0x11,0x13,0x20,0x01,0x00,0x00,0x00, /* 00000020 "... ...." */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000028 "........" */ + 0x00,0x3E,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000030 ".>......" */ + 0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11, /* 00000038 "........" */ + 0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22, /* 00000040 """""""""" */ + 0x01,0x32,0x00,0x03,0x33,0x33,0x33,0x33, /* 00000048 ".2..3333" */ + 0x33,0x33,0x33,0x33,0x44,0x44,0x44,0x44, /* 00000050 "3333DDDD" */ + 0x44,0x44,0x44,0x44,0x55,0x55,0x55,0x55, /* 00000058 "DDDDUUUU" */ + 0x55,0x55,0x55,0x55,0x66,0x66,0x66,0x66, /* 00000060 "UUUUffff" */ + 0x77,0x77,0x77,0x77,0x88,0x88,0x00,0x3E, /* 00000068 "wwww...>" */ + 0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF, /* 00000070 "........" */ + 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xEE,0xEE, /* 00000078 "........" */ + 0xEE,0xEE,0xEE,0xEE,0xEE,0xEE,0x01,0x32, /* 00000080 ".......2" */ + 0x00,0x03,0xDD,0xDD,0xDD,0xDD,0xDD,0xDD, /* 00000088 "........" */ + 0xDD,0xDD,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC, /* 00000090 "........" */ + 0xCC,0xCC,0xBB,0xBB,0xBB,0xBB,0xBB,0xBB, /* 00000098 "........" */ + 0xBB,0xBB,0xAA,0xAA,0xAA,0xAA,0x99,0x99, /* 000000A0 "........" */ + 0x99,0x99,0x88,0x88 /* 000000A8 "...." */ +}; + const unsigned char TemplatePmtt[] = { 0x50,0x4D,0x54,0x54,0xB4,0x00,0x00,0x00, /* 00000000 "PMTT...." */ diff --git a/source/compiler/dtutils.c b/source/compiler/dtutils.c index e7376f4..d61620d 100644 --- a/source/compiler/dtutils.c +++ b/source/compiler/dtutils.c @@ -532,6 +532,7 @@ DtGetFieldLength ( case ACPI_DMT_ACCWIDTH: case ACPI_DMT_IVRS: case ACPI_DMT_MADT: + case ACPI_DMT_PCCT: case ACPI_DMT_PMTT: case ACPI_DMT_SRAT: case ACPI_DMT_ASF: diff --git a/source/compiler/readme.txt b/source/compiler/readme.txt index e47b99b..12f4cd0 100644 --- a/source/compiler/readme.txt +++ b/source/compiler/readme.txt @@ -1,8 +1,7 @@ /* * Miscellaneous instructions for building and using the iASL compiler. */ - -Last update: 24 October 2012 +Last update 9 December 2013. 1) Generating iASL from source @@ -30,17 +29,23 @@ be installed): 1a) Notes for Linux/Unix generation ----------------------------------- +iASL has been generated with these versions of Flex/Bison: + + flex: Version 2.5.32 + bison: Version 2.6.2 + +Other required packages: + + make + gcc C compiler + m4 (macro processor required by bison) + On Linux/Unix systems, the following commands will build the compiler: cd acpica (or cd acpica/generate/unix) make clean make iasl -iASL has been generated with these versions of Flex/Bison: - - Flex: Version 2.5.32 - Bison: Version 2.6.2 - 1b) Notes for Windows generation -------------------------------- @@ -58,12 +63,15 @@ iASL assumes that these tools are installed at this location: c:\GnuWin32 Once the tools are installed, ensure that this path is added to the -default system $PATH environment variable: +default system $Path environment variable: c:\GnuWin32\bin -At this point, you will need to reboot Windows to make system aware of -the updated $PATH. +Goto: ControlPanel/System/AdvancedSystemSettings/EnvironmentVariables + +Important: Now Windows must be rebooted to make the system aware of +the updated $Path. Otherwise, Bison will not be able to find the M4 +interpreter library and will fail. iASL has been generated with these versions of Flex/Bison for Windows: diff --git a/source/components/debugger/dbfileio.c b/source/components/debugger/dbfileio.c index 373e7ad..0785c7d 100644 --- a/source/components/debugger/dbfileio.c +++ b/source/components/debugger/dbfileio.c @@ -60,16 +60,6 @@ #define _COMPONENT ACPI_CA_DEBUGGER ACPI_MODULE_NAME ("dbfileio") -/* - * NOTE: this is here for lack of a better place. It is used in all - * flavors of the debugger, need LCD file - */ -#ifdef ACPI_APPLICATION -#include <stdio.h> -FILE *AcpiGbl_DebugFile = NULL; -#endif - - #ifdef ACPI_DEBUGGER /* Local prototypes */ diff --git a/source/components/debugger/dbinput.c b/source/components/debugger/dbinput.c index 147a023..e1beed3 100644 --- a/source/components/debugger/dbinput.c +++ b/source/components/debugger/dbinput.c @@ -128,7 +128,7 @@ enum AcpiExDebuggerCommands CMD_METHODS, CMD_NAMESPACE, CMD_NOTIFY, - CMD_OBJECT, + CMD_OBJECTS, CMD_OPEN, CMD_OSI, CMD_OWNER, @@ -201,7 +201,7 @@ static const ACPI_DB_COMMAND_INFO AcpiGbl_DbCommands[] = {"METHODS", 0}, {"NAMESPACE", 0}, {"NOTIFY", 2}, - {"OBJECT", 1}, + {"OBJECTS", 1}, {"OPEN", 1}, {"OSI", 0}, {"OWNER", 1}, @@ -1000,7 +1000,7 @@ AcpiDbCommandDispatch ( AcpiDbSendNotify (AcpiGbl_DbArgs[1], Temp); break; - case CMD_OBJECT: + case CMD_OBJECTS: AcpiUtStrupr (AcpiGbl_DbArgs[1]); Status = AcpiDbDisplayObjects (AcpiGbl_DbArgs[1], AcpiGbl_DbArgs[2]); diff --git a/source/components/dispatcher/dsfield.c b/source/components/dispatcher/dsfield.c index 2fb4f0e..90428aa 100644 --- a/source/components/dispatcher/dsfield.c +++ b/source/components/dispatcher/dsfield.c @@ -116,7 +116,7 @@ AcpiDsCreateExternalRegion ( * OperationRegion not found. Generate an External for it, and * insert the name into the namespace. */ - AcpiDmAddToExternalList (Op, Path, ACPI_TYPE_REGION, 0); + AcpiDmAddOpToExternalList (Op, Path, ACPI_TYPE_REGION, 0, 0); Status = AcpiNsLookup (WalkState->ScopeInfo, Path, ACPI_TYPE_REGION, ACPI_IMODE_LOAD_PASS1, ACPI_NS_SEARCH_PARENT, WalkState, Node); if (ACPI_FAILURE (Status)) diff --git a/source/components/dispatcher/dsutils.c b/source/components/dispatcher/dsutils.c index 9fedbe6..08cb250 100644 --- a/source/components/dispatcher/dsutils.c +++ b/source/components/dispatcher/dsutils.c @@ -779,16 +779,16 @@ AcpiDsCreateOperands ( Index++; } - Index--; + ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, + "NumOperands %d, ArgCount %d, Index %d\n", + WalkState->NumOperands, ArgCount, Index)); - /* It is the appropriate order to get objects from the Result stack */ + /* Create the interpreter arguments, in reverse order */ + Index--; for (i = 0; i < ArgCount; i++) { Arg = Arguments[Index]; - - /* Force the filling of the operand stack in inverse order */ - WalkState->OperandIndex = (UINT8) Index; Status = AcpiDsCreateOperand (WalkState, Arg, Index); @@ -797,10 +797,10 @@ AcpiDsCreateOperands ( goto Cleanup; } + ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, + "Created Arg #%u (%p) %u args total\n", + Index, Arg, ArgCount)); Index--; - - ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "Arg #%u (%p) done, Arg1=%p\n", - Index, Arg, FirstArg)); } return_ACPI_STATUS (Status); diff --git a/source/components/dispatcher/dswexec.c b/source/components/dispatcher/dswexec.c index 25de7f7..e9c178b 100644 --- a/source/components/dispatcher/dswexec.c +++ b/source/components/dispatcher/dswexec.c @@ -541,7 +541,8 @@ AcpiDsExecEndOp ( return_ACPI_STATUS (AE_OK); } - ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "Method invocation, Op=%p\n", Op)); + ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, + "Method invocation, Op=%p\n", Op)); /* * (AML_METHODCALL) Op->Asl.Value.Arg->Asl.Node contains diff --git a/source/components/dispatcher/dswload.c b/source/components/dispatcher/dswload.c index 7050c87..339586a 100644 --- a/source/components/dispatcher/dswload.c +++ b/source/components/dispatcher/dswload.c @@ -193,7 +193,7 @@ AcpiDsLoad1BeginOp ( * Target of Scope() not found. Generate an External for it, and * insert the name into the namespace. */ - AcpiDmAddToExternalList (Op, Path, ACPI_TYPE_DEVICE, 0); + AcpiDmAddOpToExternalList (Op, Path, ACPI_TYPE_DEVICE, 0, 0); Status = AcpiNsLookup (WalkState->ScopeInfo, Path, ObjectType, ACPI_IMODE_LOAD_PASS1, ACPI_NS_SEARCH_PARENT, WalkState, &Node); diff --git a/source/components/events/evgpeblk.c b/source/components/events/evgpeblk.c index ccbe6a61..0f0da18 100644 --- a/source/components/events/evgpeblk.c +++ b/source/components/events/evgpeblk.c @@ -97,10 +97,9 @@ AcpiEvInstallGpeBlock ( return_ACPI_STATUS (Status); } - GpeXruptBlock = AcpiEvGetGpeXruptBlock (InterruptNumber); - if (!GpeXruptBlock) + Status = AcpiEvGetGpeXruptBlock (InterruptNumber, &GpeXruptBlock); + if (ACPI_FAILURE (Status)) { - Status = AE_NO_MEMORY; goto UnlockAndExit; } @@ -128,7 +127,7 @@ AcpiEvInstallGpeBlock ( UnlockAndExit: - Status = AcpiUtReleaseMutex (ACPI_MTX_EVENTS); + (void) AcpiUtReleaseMutex (ACPI_MTX_EVENTS); return_ACPI_STATUS (Status); } diff --git a/source/components/events/evgpeutil.c b/source/components/events/evgpeutil.c index 492c16f..a48520c 100644 --- a/source/components/events/evgpeutil.c +++ b/source/components/events/evgpeutil.c @@ -217,8 +217,9 @@ AcpiEvGetGpeDevice ( * FUNCTION: AcpiEvGetGpeXruptBlock * * PARAMETERS: InterruptNumber - Interrupt for a GPE block + * GpeXruptBlock - Where the block is returned * - * RETURN: A GPE interrupt block + * RETURN: Status * * DESCRIPTION: Get or Create a GPE interrupt block. There is one interrupt * block per unique interrupt level used for GPEs. Should be @@ -227,9 +228,10 @@ AcpiEvGetGpeDevice ( * ******************************************************************************/ -ACPI_GPE_XRUPT_INFO * +ACPI_STATUS AcpiEvGetGpeXruptBlock ( - UINT32 InterruptNumber) + UINT32 InterruptNumber, + ACPI_GPE_XRUPT_INFO **GpeXruptBlock) { ACPI_GPE_XRUPT_INFO *NextGpeXrupt; ACPI_GPE_XRUPT_INFO *GpeXrupt; @@ -247,7 +249,8 @@ AcpiEvGetGpeXruptBlock ( { if (NextGpeXrupt->InterruptNumber == InterruptNumber) { - return_PTR (NextGpeXrupt); + *GpeXruptBlock = NextGpeXrupt; + return_ACPI_STATUS (AE_OK); } NextGpeXrupt = NextGpeXrupt->Next; @@ -258,7 +261,7 @@ AcpiEvGetGpeXruptBlock ( GpeXrupt = ACPI_ALLOCATE_ZEROED (sizeof (ACPI_GPE_XRUPT_INFO)); if (!GpeXrupt) { - return_PTR (NULL); + return_ACPI_STATUS (AE_NO_MEMORY); } GpeXrupt->InterruptNumber = InterruptNumber; @@ -281,6 +284,7 @@ AcpiEvGetGpeXruptBlock ( { AcpiGbl_GpeXruptListHead = GpeXrupt; } + AcpiOsReleaseLock (AcpiGbl_GpeLock, Flags); /* Install new interrupt handler if not SCI_INT */ @@ -291,14 +295,15 @@ AcpiEvGetGpeXruptBlock ( AcpiEvGpeXruptHandler, GpeXrupt); if (ACPI_FAILURE (Status)) { - ACPI_ERROR ((AE_INFO, + ACPI_EXCEPTION ((AE_INFO, Status, "Could not install GPE interrupt handler at level 0x%X", InterruptNumber)); - return_PTR (NULL); + return_ACPI_STATUS (Status); } } - return_PTR (GpeXrupt); + *GpeXruptBlock = GpeXrupt; + return_ACPI_STATUS (AE_OK); } diff --git a/source/components/executer/exresnte.c b/source/components/executer/exresnte.c index c26cbb9..56a7a32 100644 --- a/source/components/executer/exresnte.c +++ b/source/components/executer/exresnte.c @@ -134,8 +134,8 @@ AcpiExResolveNodeToValue ( if (!SourceDesc) { - ACPI_ERROR ((AE_INFO, "No object attached to node %p", - Node)); + ACPI_ERROR ((AE_INFO, "No object attached to node [%4.4s] %p", + Node->Name.Ascii, Node)); return_ACPI_STATUS (AE_AML_NO_OPERAND); } diff --git a/source/components/namespace/nsxfeval.c b/source/components/namespace/nsxfeval.c index a1af583..e0022a8 100644 --- a/source/components/namespace/nsxfeval.c +++ b/source/components/namespace/nsxfeval.c @@ -92,7 +92,7 @@ AcpiEvaluateObjectTyped ( ACPI_OBJECT_TYPE ReturnType) { ACPI_STATUS Status; - BOOLEAN MustFree = FALSE; + BOOLEAN FreeBufferOnError = FALSE; ACPI_FUNCTION_TRACE (AcpiEvaluateObjectTyped); @@ -107,12 +107,13 @@ AcpiEvaluateObjectTyped ( if (ReturnBuffer->Length == ACPI_ALLOCATE_BUFFER) { - MustFree = TRUE; + FreeBufferOnError = TRUE; } /* Evaluate the object */ - Status = AcpiEvaluateObject (Handle, Pathname, ExternalParams, ReturnBuffer); + Status = AcpiEvaluateObject (Handle, Pathname, + ExternalParams, ReturnBuffer); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); @@ -147,13 +148,14 @@ AcpiEvaluateObjectTyped ( AcpiUtGetTypeName (((ACPI_OBJECT *) ReturnBuffer->Pointer)->Type), AcpiUtGetTypeName (ReturnType))); - if (MustFree) + if (FreeBufferOnError) { /* - * Caller used ACPI_ALLOCATE_BUFFER, free the return buffer. + * Free a buffer created via ACPI_ALLOCATE_BUFFER. * Note: We use AcpiOsFree here because AcpiOsAllocate was used - * to allocate the buffer. This purposefully bypasses the internal - * allocation tracking mechanism (if it is enabled). + * to allocate the buffer. This purposefully bypasses the + * (optionally enabled) allocation tracking mechanism since we + * only want to track internal allocations. */ AcpiOsFree (ReturnBuffer->Pointer); ReturnBuffer->Pointer = NULL; diff --git a/source/components/parser/psopinfo.c b/source/components/parser/psopinfo.c index f079c33..081b808 100644 --- a/source/components/parser/psopinfo.c +++ b/source/components/parser/psopinfo.c @@ -76,6 +76,10 @@ const ACPI_OPCODE_INFO * AcpiPsGetOpcodeInfo ( UINT16 Opcode) { +#ifdef ACPI_DEBUG_OUTPUT + const char *OpcodeName = "Unknown AML opcode"; +#endif + ACPI_FUNCTION_NAME (PsGetOpcodeInfo); @@ -97,10 +101,56 @@ AcpiPsGetOpcodeInfo ( return (&AcpiGbl_AmlOpInfo [AcpiGbl_LongOpIndex [(UINT8) Opcode]]); } +#if defined ACPI_ASL_COMPILER && defined ACPI_DEBUG_OUTPUT +#include "asldefine.h" + + switch (Opcode) + { + case AML_RAW_DATA_BYTE: + OpcodeName = "-Raw Data Byte-"; + break; + + case AML_RAW_DATA_WORD: + OpcodeName = "-Raw Data Word-"; + break; + + case AML_RAW_DATA_DWORD: + OpcodeName = "-Raw Data Dword-"; + break; + + case AML_RAW_DATA_QWORD: + OpcodeName = "-Raw Data Qword-"; + break; + + case AML_RAW_DATA_BUFFER: + OpcodeName = "-Raw Data Buffer-"; + break; + + case AML_RAW_DATA_CHAIN: + OpcodeName = "-Raw Data Buffer Chain-"; + break; + + case AML_PACKAGE_LENGTH: + OpcodeName = "-Package Length-"; + break; + + case AML_UNASSIGNED_OPCODE: + OpcodeName = "-Unassigned Opcode-"; + break; + + case AML_DEFAULT_ARG_OP: + OpcodeName = "-Default Arg-"; + break; + + default: + break; + } +#endif + /* Unknown AML opcode */ ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, - "Unknown AML opcode [%4.4X]\n", Opcode)); + "%s [%4.4X]\n", OpcodeName, Opcode)); return (&AcpiGbl_AmlOpInfo [_UNK]); } diff --git a/source/components/tables/tbfadt.c b/source/components/tables/tbfadt.c index eb4e0e5..5e315ef 100644 --- a/source/components/tables/tbfadt.c +++ b/source/components/tables/tbfadt.c @@ -65,13 +65,15 @@ AcpiTbConvertFadt ( void); static void -AcpiTbValidateFadt ( - void); - -static void AcpiTbSetupFadtRegisters ( void); +static UINT64 +AcpiTbSelectAddress ( + char *RegisterName, + UINT32 Address32, + UINT64 Address64); + /* Table for conversion of FADT to common internal format and FADT validation */ @@ -194,6 +196,7 @@ static ACPI_FADT_PM_INFO FadtPmInfoTable[] = * SpaceId - ACPI Space ID for this register * ByteWidth - Width of this register * Address - Address of the register + * RegisterName - ASCII name of the ACPI register * * RETURN: None * @@ -245,6 +248,72 @@ AcpiTbInitGenericAddress ( /******************************************************************************* * + * FUNCTION: AcpiTbSelectAddress + * + * PARAMETERS: RegisterName - ASCII name of the ACPI register + * Address32 - 32-bit address of the register + * Address64 - 64-bit address of the register + * + * RETURN: The resolved 64-bit address + * + * DESCRIPTION: Select between 32-bit and 64-bit versions of addresses within + * the FADT. Used for the FACS and DSDT addresses. + * + * NOTES: + * + * Check for FACS and DSDT address mismatches. An address mismatch between + * the 32-bit and 64-bit address fields (FIRMWARE_CTRL/X_FIRMWARE_CTRL and + * DSDT/X_DSDT) could be a corrupted address field or it might indicate + * the presence of two FACS or two DSDT tables. + * + * November 2013: + * By default, as per the ACPICA specification, a valid 64-bit address is + * used regardless of the value of the 32-bit address. However, this + * behavior can be overridden via the AcpiGbl_Use32BitFadtAddresses flag. + * + ******************************************************************************/ + +static UINT64 +AcpiTbSelectAddress ( + char *RegisterName, + UINT32 Address32, + UINT64 Address64) +{ + + if (!Address64) + { + /* 64-bit address is zero, use 32-bit address */ + + return ((UINT64) Address32); + } + + if (Address32 && + (Address64 != (UINT64) Address32)) + { + /* Address mismatch between 32-bit and 64-bit versions */ + + ACPI_BIOS_WARNING ((AE_INFO, + "32/64X %s address mismatch in FADT: " + "0x%8.8X/0x%8.8X%8.8X, using %u-bit address", + RegisterName, Address32, ACPI_FORMAT_UINT64 (Address64), + AcpiGbl_Use32BitFadtAddresses ? 32 : 64)); + + /* 32-bit address override */ + + if (AcpiGbl_Use32BitFadtAddresses) + { + return ((UINT64) Address32); + } + } + + /* Default is to use the 64-bit address */ + + return (Address64); +} + + +/******************************************************************************* + * * FUNCTION: AcpiTbParseFadt * * PARAMETERS: TableIndex - Index for the FADT @@ -365,10 +434,6 @@ AcpiTbCreateLocalFadt ( AcpiTbConvertFadt (); - /* Validate FADT values now, before we make any changes */ - - AcpiTbValidateFadt (); - /* Initialize the global ACPI register structures */ AcpiTbSetupFadtRegisters (); @@ -379,33 +444,43 @@ AcpiTbCreateLocalFadt ( * * FUNCTION: AcpiTbConvertFadt * - * PARAMETERS: None, uses AcpiGbl_FADT + * PARAMETERS: None - AcpiGbl_FADT is used. * * RETURN: None * * DESCRIPTION: Converts all versions of the FADT to a common internal format. - * Expand 32-bit addresses to 64-bit as necessary. + * Expand 32-bit addresses to 64-bit as necessary. Also validate + * important fields within the FADT. * - * NOTE: AcpiGbl_FADT must be of size (ACPI_TABLE_FADT), - * and must contain a copy of the actual FADT. + * NOTE: AcpiGbl_FADT must be of size (ACPI_TABLE_FADT), and must + * contain a copy of the actual BIOS-provided FADT. * * Notes on 64-bit register addresses: * * After this FADT conversion, later ACPICA code will only use the 64-bit "X" * fields of the FADT for all ACPI register addresses. * - * The 64-bit "X" fields are optional extensions to the original 32-bit FADT + * The 64-bit X fields are optional extensions to the original 32-bit FADT * V1.0 fields. Even if they are present in the FADT, they are optional and * are unused if the BIOS sets them to zero. Therefore, we must copy/expand - * 32-bit V1.0 fields if the corresponding X field is zero. + * 32-bit V1.0 fields to the 64-bit X fields if the the 64-bit X field is + * originally zero. * - * For ACPI 1.0 FADTs, all 32-bit address fields are expanded to the - * corresponding "X" fields in the internal FADT. + * For ACPI 1.0 FADTs (that contain no 64-bit addresses), all 32-bit address + * fields are expanded to the corresponding 64-bit X fields in the internal + * common FADT. * * For ACPI 2.0+ FADTs, all valid (non-zero) 32-bit address fields are expanded - * to the corresponding 64-bit X fields. For compatibility with other ACPI - * implementations, we ignore the 64-bit field if the 32-bit field is valid, - * regardless of whether the host OS is 32-bit or 64-bit. + * to the corresponding 64-bit X fields, if the 64-bit field is originally + * zero. Adhering to the ACPI specification, we completely ignore the 32-bit + * field if the 64-bit field is valid, regardless of whether the host OS is + * 32-bit or 64-bit. + * + * Possible additional checks: + * (AcpiGbl_FADT.Pm1EventLength >= 4) + * (AcpiGbl_FADT.Pm1ControlLength >= 2) + * (AcpiGbl_FADT.PmTimerLength >= 4) + * Gpe block lengths must be multiple of 2 * ******************************************************************************/ @@ -413,25 +488,14 @@ static void AcpiTbConvertFadt ( void) { + char *Name; ACPI_GENERIC_ADDRESS *Address64; UINT32 Address32; + UINT8 Length; UINT32 i; /* - * Expand the 32-bit FACS and DSDT addresses to 64-bit as necessary. - * Later code will always use the X 64-bit field. - */ - if (!AcpiGbl_FADT.XFacs) - { - AcpiGbl_FADT.XFacs = (UINT64) AcpiGbl_FADT.Facs; - } - if (!AcpiGbl_FADT.XDsdt) - { - AcpiGbl_FADT.XDsdt = (UINT64) AcpiGbl_FADT.Dsdt; - } - - /* * For ACPI 1.0 FADTs (revision 1 or 2), ensure that reserved fields which * should be zero are indeed zero. This will workaround BIOSs that * inadvertently place values in these fields. @@ -458,113 +522,14 @@ AcpiTbConvertFadt ( AcpiGbl_FADT.Header.Length = sizeof (ACPI_TABLE_FADT); /* - * Expand the ACPI 1.0 32-bit addresses to the ACPI 2.0 64-bit "X" - * generic address structures as necessary. Later code will always use - * the 64-bit address structures. - * - * March 2009: - * We now always use the 32-bit address if it is valid (non-null). This - * is not in accordance with the ACPI specification which states that - * the 64-bit address supersedes the 32-bit version, but we do this for - * compatibility with other ACPI implementations. Most notably, in the - * case where both the 32 and 64 versions are non-null, we use the 32-bit - * version. This is the only address that is guaranteed to have been - * tested by the BIOS manufacturer. - */ - for (i = 0; i < ACPI_FADT_INFO_ENTRIES; i++) - { - Address32 = *ACPI_ADD_PTR (UINT32, - &AcpiGbl_FADT, FadtInfoTable[i].Address32); - - Address64 = ACPI_ADD_PTR (ACPI_GENERIC_ADDRESS, - &AcpiGbl_FADT, FadtInfoTable[i].Address64); - - /* - * If both 32- and 64-bit addresses are valid (non-zero), - * they must match. - */ - if (Address64->Address && Address32 && - (Address64->Address != (UINT64) Address32)) - { - ACPI_BIOS_ERROR ((AE_INFO, - "32/64X address mismatch in FADT/%s: " - "0x%8.8X/0x%8.8X%8.8X, using 32", - FadtInfoTable[i].Name, Address32, - ACPI_FORMAT_UINT64 (Address64->Address))); - } - - /* Always use 32-bit address if it is valid (non-null) */ - - if (Address32) - { - /* - * Copy the 32-bit address to the 64-bit GAS structure. The - * Space ID is always I/O for 32-bit legacy address fields - */ - AcpiTbInitGenericAddress (Address64, ACPI_ADR_SPACE_SYSTEM_IO, - *ACPI_ADD_PTR (UINT8, &AcpiGbl_FADT, FadtInfoTable[i].Length), - (UINT64) Address32, FadtInfoTable[i].Name); - } - } -} - - -/******************************************************************************* - * - * FUNCTION: AcpiTbValidateFadt - * - * PARAMETERS: Table - Pointer to the FADT to be validated - * - * RETURN: None - * - * DESCRIPTION: Validate various important fields within the FADT. If a problem - * is found, issue a message, but no status is returned. - * Used by both the table manager and the disassembler. - * - * Possible additional checks: - * (AcpiGbl_FADT.Pm1EventLength >= 4) - * (AcpiGbl_FADT.Pm1ControlLength >= 2) - * (AcpiGbl_FADT.PmTimerLength >= 4) - * Gpe block lengths must be multiple of 2 - * - ******************************************************************************/ - -static void -AcpiTbValidateFadt ( - void) -{ - char *Name; - ACPI_GENERIC_ADDRESS *Address64; - UINT8 Length; - UINT32 i; - - - /* - * Check for FACS and DSDT address mismatches. An address mismatch between - * the 32-bit and 64-bit address fields (FIRMWARE_CTRL/X_FIRMWARE_CTRL and - * DSDT/X_DSDT) would indicate the presence of two FACS or two DSDT tables. + * Expand the 32-bit FACS and DSDT addresses to 64-bit as necessary. + * Later ACPICA code will always use the X 64-bit field. */ - if (AcpiGbl_FADT.Facs && - (AcpiGbl_FADT.XFacs != (UINT64) AcpiGbl_FADT.Facs)) - { - ACPI_BIOS_WARNING ((AE_INFO, - "32/64X FACS address mismatch in FADT - " - "0x%8.8X/0x%8.8X%8.8X, using 32", - AcpiGbl_FADT.Facs, ACPI_FORMAT_UINT64 (AcpiGbl_FADT.XFacs))); + AcpiGbl_FADT.XFacs = AcpiTbSelectAddress ("FACS", + AcpiGbl_FADT.Facs, AcpiGbl_FADT.XFacs); - AcpiGbl_FADT.XFacs = (UINT64) AcpiGbl_FADT.Facs; - } - - if (AcpiGbl_FADT.Dsdt && - (AcpiGbl_FADT.XDsdt != (UINT64) AcpiGbl_FADT.Dsdt)) - { - ACPI_BIOS_WARNING ((AE_INFO, - "32/64X DSDT address mismatch in FADT - " - "0x%8.8X/0x%8.8X%8.8X, using 32", - AcpiGbl_FADT.Dsdt, ACPI_FORMAT_UINT64 (AcpiGbl_FADT.XDsdt))); - - AcpiGbl_FADT.XDsdt = (UINT64) AcpiGbl_FADT.Dsdt; - } + AcpiGbl_FADT.XDsdt = AcpiTbSelectAddress ("DSDT", + AcpiGbl_FADT.Dsdt, AcpiGbl_FADT.XDsdt); /* If Hardware Reduced flag is set, we are all done */ @@ -578,16 +543,82 @@ AcpiTbValidateFadt ( for (i = 0; i < ACPI_FADT_INFO_ENTRIES; i++) { /* - * Generate pointer to the 64-bit address, get the register - * length (width) and the register name + * Get the 32-bit and 64-bit addresses, as well as the register + * length and register name. */ + Address32 = *ACPI_ADD_PTR (UINT32, + &AcpiGbl_FADT, FadtInfoTable[i].Address32); + Address64 = ACPI_ADD_PTR (ACPI_GENERIC_ADDRESS, - &AcpiGbl_FADT, FadtInfoTable[i].Address64); + &AcpiGbl_FADT, FadtInfoTable[i].Address64); + Length = *ACPI_ADD_PTR (UINT8, - &AcpiGbl_FADT, FadtInfoTable[i].Length); + &AcpiGbl_FADT, FadtInfoTable[i].Length); + Name = FadtInfoTable[i].Name; /* + * Expand the ACPI 1.0 32-bit addresses to the ACPI 2.0 64-bit "X" + * generic address structures as necessary. Later code will always use + * the 64-bit address structures. + * + * November 2013: + * Now always use the 64-bit address if it is valid (non-zero), in + * accordance with the ACPI specification which states that a 64-bit + * address supersedes the 32-bit version. This behavior can be + * overridden by the AcpiGbl_Use32BitFadtAddresses flag. + * + * During 64-bit address construction and verification, + * these cases are handled: + * + * Address32 zero, Address64 [don't care] - Use Address64 + * + * Address32 non-zero, Address64 zero - Copy/use Address32 + * Address32 non-zero == Address64 non-zero - Use Address64 + * Address32 non-zero != Address64 non-zero - Warning, use Address64 + * + * Override: if AcpiGbl_Use32BitFadtAddresses is TRUE, and: + * Address32 non-zero != Address64 non-zero - Warning, copy/use Address32 + * + * Note: SpaceId is always I/O for 32-bit legacy address fields + */ + if (Address32) + { + if (!Address64->Address) + { + /* 64-bit address is zero, use 32-bit address */ + + AcpiTbInitGenericAddress (Address64, + ACPI_ADR_SPACE_SYSTEM_IO, + *ACPI_ADD_PTR (UINT8, &AcpiGbl_FADT, + FadtInfoTable[i].Length), + (UINT64) Address32, Name); + } + else if (Address64->Address != (UINT64) Address32) + { + /* Address mismatch */ + + ACPI_BIOS_WARNING ((AE_INFO, + "32/64X address mismatch in FADT/%s: " + "0x%8.8X/0x%8.8X%8.8X, using %u-bit address", + Name, Address32, + ACPI_FORMAT_UINT64 (Address64->Address), + AcpiGbl_Use32BitFadtAddresses ? 32 : 64)); + + if (AcpiGbl_Use32BitFadtAddresses) + { + /* 32-bit address override */ + + AcpiTbInitGenericAddress (Address64, + ACPI_ADR_SPACE_SYSTEM_IO, + *ACPI_ADD_PTR (UINT8, &AcpiGbl_FADT, + FadtInfoTable[i].Length), + (UINT64) Address32, Name); + } + } + } + + /* * For each extended field, check for length mismatch between the * legacy length field and the corresponding 64-bit X length field. * Note: If the legacy length field is > 0xFF bits, ignore this diff --git a/source/components/tables/tbutils.c b/source/components/tables/tbutils.c index 7c84d5e..159a7d9 100644 --- a/source/components/tables/tbutils.c +++ b/source/components/tables/tbutils.c @@ -53,6 +53,10 @@ /* Local prototypes */ +static ACPI_STATUS +AcpiTbValidateXsdt ( + ACPI_PHYSICAL_ADDRESS Address); + static ACPI_PHYSICAL_ADDRESS AcpiTbGetRootTableEntry ( UINT8 *TableEntry, @@ -353,7 +357,7 @@ AcpiTbGetRootTableEntry ( * Get the table physical address (32-bit for RSDT, 64-bit for XSDT): * Note: Addresses are 32-bit aligned (not 64) in both RSDT and XSDT */ - if (TableEntrySize == sizeof (UINT32)) + if (TableEntrySize == ACPI_RSDT_ENTRY_SIZE) { /* * 32-bit platform, RSDT: Return 32-bit table entry @@ -388,6 +392,92 @@ AcpiTbGetRootTableEntry ( /******************************************************************************* * + * FUNCTION: AcpiTbValidateXsdt + * + * PARAMETERS: Address - Physical address of the XSDT (from RSDP) + * + * RETURN: Status. AE_OK if the table appears to be valid. + * + * DESCRIPTION: Validate an XSDT to ensure that it is of minimum size and does + * not contain any NULL entries. A problem that is seen in the + * field is that the XSDT exists, but is actually useless because + * of one or more (or all) NULL entries. + * + ******************************************************************************/ + +static ACPI_STATUS +AcpiTbValidateXsdt ( + ACPI_PHYSICAL_ADDRESS XsdtAddress) +{ + ACPI_TABLE_HEADER *Table; + UINT8 *NextEntry; + ACPI_PHYSICAL_ADDRESS Address; + UINT32 Length; + UINT32 EntryCount; + ACPI_STATUS Status; + UINT32 i; + + + /* Get the XSDT length */ + + Table = AcpiOsMapMemory (XsdtAddress, sizeof (ACPI_TABLE_HEADER)); + if (!Table) + { + return (AE_NO_MEMORY); + } + + Length = Table->Length; + AcpiOsUnmapMemory (Table, sizeof (ACPI_TABLE_HEADER)); + + /* + * Minimum XSDT length is the size of the standard ACPI header + * plus one physical address entry + */ + if (Length < (sizeof (ACPI_TABLE_HEADER) + ACPI_XSDT_ENTRY_SIZE)) + { + return (AE_INVALID_TABLE_LENGTH); + } + + /* Map the entire XSDT */ + + Table = AcpiOsMapMemory (XsdtAddress, Length); + if (!Table) + { + return (AE_NO_MEMORY); + } + + /* Get the number of entries and pointer to first entry */ + + Status = AE_OK; + NextEntry = ACPI_ADD_PTR (UINT8, Table, sizeof (ACPI_TABLE_HEADER)); + EntryCount = (UINT32) ((Table->Length - sizeof (ACPI_TABLE_HEADER)) / + ACPI_XSDT_ENTRY_SIZE); + + /* Validate each entry (physical address) within the XSDT */ + + for (i = 0; i < EntryCount; i++) + { + Address = AcpiTbGetRootTableEntry (NextEntry, ACPI_XSDT_ENTRY_SIZE); + if (!Address) + { + /* Detected a NULL entry, XSDT is invalid */ + + Status = AE_NULL_ENTRY; + break; + } + + NextEntry += ACPI_XSDT_ENTRY_SIZE; + } + + /* Unmap table */ + + AcpiOsUnmapMemory (Table, Length); + return (Status); +} + + +/******************************************************************************* + * * FUNCTION: AcpiTbParseRootTable * * PARAMETERS: Rsdp - Pointer to the RSDP @@ -421,9 +511,8 @@ AcpiTbParseRootTable ( ACPI_FUNCTION_TRACE (TbParseRootTable); - /* - * Map the entire RSDP and extract the address of the RSDT or XSDT - */ + /* Map the entire RSDP and extract the address of the RSDT or XSDT */ + Rsdp = AcpiOsMapMemory (RsdpAddress, sizeof (ACPI_TABLE_RSDP)); if (!Rsdp) { @@ -433,24 +522,26 @@ AcpiTbParseRootTable ( AcpiTbPrintTableHeader (RsdpAddress, ACPI_CAST_PTR (ACPI_TABLE_HEADER, Rsdp)); - /* Differentiate between RSDT and XSDT root tables */ + /* Use XSDT if present and not overridden. Otherwise, use RSDT */ - if (Rsdp->Revision > 1 && Rsdp->XsdtPhysicalAddress) + if ((Rsdp->Revision > 1) && + Rsdp->XsdtPhysicalAddress && + !AcpiGbl_DoNotUseXsdt) { /* - * Root table is an XSDT (64-bit physical addresses). We must use the - * XSDT if the revision is > 1 and the XSDT pointer is present, as per - * the ACPI specification. + * RSDP contains an XSDT (64-bit physical addresses). We must use + * the XSDT if the revision is > 1 and the XSDT pointer is present, + * as per the ACPI specification. */ Address = (ACPI_PHYSICAL_ADDRESS) Rsdp->XsdtPhysicalAddress; - TableEntrySize = sizeof (UINT64); + TableEntrySize = ACPI_XSDT_ENTRY_SIZE; } else { /* Root table is an RSDT (32-bit physical addresses) */ Address = (ACPI_PHYSICAL_ADDRESS) Rsdp->RsdtPhysicalAddress; - TableEntrySize = sizeof (UINT32); + TableEntrySize = ACPI_RSDT_ENTRY_SIZE; } /* @@ -459,6 +550,24 @@ AcpiTbParseRootTable ( */ AcpiOsUnmapMemory (Rsdp, sizeof (ACPI_TABLE_RSDP)); + /* + * If it is present and used, validate the XSDT for access/size + * and ensure that all table entries are at least non-NULL + */ + if (TableEntrySize == ACPI_XSDT_ENTRY_SIZE) + { + Status = AcpiTbValidateXsdt (Address); + if (ACPI_FAILURE (Status)) + { + ACPI_BIOS_WARNING ((AE_INFO, "XSDT is invalid (%s), using RSDT", + AcpiFormatException (Status))); + + /* Fall back to the RSDT */ + + Address = (ACPI_PHYSICAL_ADDRESS) Rsdp->RsdtPhysicalAddress; + TableEntrySize = ACPI_RSDT_ENTRY_SIZE; + } + } /* Map the RSDT/XSDT table header to get the full table length */ @@ -470,12 +579,14 @@ AcpiTbParseRootTable ( AcpiTbPrintTableHeader (Address, Table); - /* Get the length of the full table, verify length and map entire table */ - + /* + * Validate length of the table, and map entire table. + * Minimum length table must contain at least one entry. + */ Length = Table->Length; AcpiOsUnmapMemory (Table, sizeof (ACPI_TABLE_HEADER)); - if (Length < sizeof (ACPI_TABLE_HEADER)) + if (Length < (sizeof (ACPI_TABLE_HEADER) + TableEntrySize)) { ACPI_BIOS_ERROR ((AE_INFO, "Invalid table length 0x%X in RSDT/XSDT", Length)); @@ -497,22 +608,21 @@ AcpiTbParseRootTable ( return_ACPI_STATUS (Status); } - /* Calculate the number of tables described in the root table */ + /* Get the number of entries and pointer to first entry */ TableCount = (UINT32) ((Table->Length - sizeof (ACPI_TABLE_HEADER)) / TableEntrySize); + TableEntry = ACPI_ADD_PTR (UINT8, Table, sizeof (ACPI_TABLE_HEADER)); /* * First two entries in the table array are reserved for the DSDT * and FACS, which are not actually present in the RSDT/XSDT - they * come from the FADT */ - TableEntry = ACPI_CAST_PTR (UINT8, Table) + sizeof (ACPI_TABLE_HEADER); AcpiGbl_RootTableList.CurrentTableCount = 2; - /* - * Initialize the root table array from the RSDT/XSDT - */ + /* Initialize the root table array from the RSDT/XSDT */ + for (i = 0; i < TableCount; i++) { if (AcpiGbl_RootTableList.CurrentTableCount >= @@ -554,7 +664,7 @@ AcpiTbParseRootTable ( AcpiTbInstallTable (AcpiGbl_RootTableList.Tables[i].Address, NULL, i); - /* Special case for FADT - get the DSDT and FACS */ + /* Special case for FADT - validate it then get the DSDT and FACS */ if (ACPI_COMPARE_NAME ( &AcpiGbl_RootTableList.Tables[i].Signature, ACPI_SIG_FADT)) diff --git a/source/components/utilities/utaddress.c b/source/components/utilities/utaddress.c index 7eae5a5..a361cb3 100644 --- a/source/components/utilities/utaddress.c +++ b/source/components/utilities/utaddress.c @@ -248,10 +248,11 @@ AcpiUtCheckAddressRange ( while (RangeInfo) { /* - * Check if the requested Address/Length overlaps this AddressRange. - * Four cases to consider: + * Check if the requested address/length overlaps this + * address range. There are four cases to consider: * - * 1) Input address/length is contained completely in the address range + * 1) Input address/length is contained completely in the + * address range * 2) Input address/length overlaps range at the range start * 3) Input address/length overlaps range at the range end * 4) Input address/length completely encompasses the range @@ -267,10 +268,13 @@ AcpiUtCheckAddressRange ( Pathname = AcpiNsGetExternalPathname (RangeInfo->RegionNode); ACPI_WARNING ((AE_INFO, - "0x%p-0x%p %s conflicts with Region %s %d", + "%s range 0x%p-0x%p conflicts with OpRegion 0x%p-0x%p (%s)", + AcpiUtGetRegionName (SpaceId), ACPI_CAST_PTR (void, Address), ACPI_CAST_PTR (void, EndAddress), - AcpiUtGetRegionName (SpaceId), Pathname, OverlapCount)); + ACPI_CAST_PTR (void, RangeInfo->StartAddress), + ACPI_CAST_PTR (void, RangeInfo->EndAddress), + Pathname)); ACPI_FREE (Pathname); } } diff --git a/source/components/utilities/utalloc.c b/source/components/utilities/utalloc.c index 51eee97..be7eaf07 100644 --- a/source/components/utilities/utalloc.c +++ b/source/components/utilities/utalloc.c @@ -324,9 +324,13 @@ AcpiUtInitializeBuffer ( return (AE_BUFFER_OVERFLOW); case ACPI_ALLOCATE_BUFFER: - - /* Allocate a new buffer */ - + /* + * Allocate a new buffer. We directectly call AcpiOsAllocate here to + * purposefully bypass the (optionally enabled) internal allocation + * tracking mechanism since we only want to track internal + * allocations. Note: The caller should use AcpiOsFree to free this + * buffer created via ACPI_ALLOCATE_BUFFER. + */ Buffer->Pointer = AcpiOsAllocate (RequiredLength); break; diff --git a/source/components/utilities/utcache.c b/source/components/utilities/utcache.c index 54c73e2..7d84f84 100644 --- a/source/components/utilities/utcache.c +++ b/source/components/utilities/utcache.c @@ -286,13 +286,13 @@ AcpiOsAcquireObject ( if (!Cache) { - return (NULL); + return_PTR (NULL); } Status = AcpiUtAcquireMutex (ACPI_MTX_CACHES); if (ACPI_FAILURE (Status)) { - return (NULL); + return_PTR (NULL); } ACPI_MEM_TRACKING (Cache->Requests++); @@ -315,7 +315,7 @@ AcpiOsAcquireObject ( Status = AcpiUtReleaseMutex (ACPI_MTX_CACHES); if (ACPI_FAILURE (Status)) { - return (NULL); + return_PTR (NULL); } /* Clear (zero) the previously used Object */ @@ -340,16 +340,16 @@ AcpiOsAcquireObject ( Status = AcpiUtReleaseMutex (ACPI_MTX_CACHES); if (ACPI_FAILURE (Status)) { - return (NULL); + return_PTR (NULL); } Object = ACPI_ALLOCATE_ZEROED (Cache->ObjectSize); if (!Object) { - return (NULL); + return_PTR (NULL); } } - return (Object); + return_PTR (Object); } #endif /* ACPI_USE_LOCAL_CACHE */ diff --git a/source/components/utilities/utdebug.c b/source/components/utilities/utdebug.c index 87dbf53..0b9018b 100644 --- a/source/components/utilities/utdebug.c +++ b/source/components/utilities/utdebug.c @@ -220,9 +220,9 @@ AcpiDebugPrint ( */ AcpiOsPrintf ("%9s-%04ld ", ModuleName, LineNumber); -#ifdef ACPI_EXEC_APP +#ifdef ACPI_APPLICATION /* - * For AcpiExec only, emit the thread ID and nesting level. + * For AcpiExec/iASL only, emit the thread ID and nesting level. * Note: nesting level is really only useful during a single-thread * execution. Otherwise, multiple threads will keep resetting the * level. diff --git a/source/components/utilities/utxfinit.c b/source/components/utilities/utxfinit.c index b395c15..984a600 100644 --- a/source/components/utilities/utxfinit.c +++ b/source/components/utilities/utxfinit.c @@ -131,8 +131,16 @@ AcpiInitializeSubsystem ( /* If configured, initialize the AML debugger */ - ACPI_DEBUGGER_EXEC (Status = AcpiDbInitialize ()); - return_ACPI_STATUS (Status); +#ifdef ACPI_DEBUGGER + Status = AcpiDbInitialize (); + if (ACPI_FAILURE (Status)) + { + ACPI_EXCEPTION ((AE_INFO, Status, "During Debugger initialization")); + return_ACPI_STATUS (Status); + } +#endif + + return_ACPI_STATUS (AE_OK); } ACPI_EXPORT_SYMBOL_INIT (AcpiInitializeSubsystem) diff --git a/source/include/acdisasm.h b/source/include/acdisasm.h index d9257e9..b2c9f10 100644 --- a/source/include/acdisasm.h +++ b/source/include/acdisasm.h @@ -69,14 +69,14 @@ typedef const struct acpi_dmtable_info } ACPI_DMTABLE_INFO; +/* Values for Flags field above */ + #define DT_LENGTH 0x01 /* Field is a subtable length */ #define DT_FLAG 0x02 /* Field is a flag value */ #define DT_NON_ZERO 0x04 /* Field must be non-zero */ - -/* TBD: Not used at this time */ - -#define DT_OPTIONAL 0x08 -#define DT_COUNT 0x10 +#define DT_OPTIONAL 0x08 /* Field is optional */ +#define DT_DESCRIBES_OPTIONAL 0x10 /* Field describes an optional field (length, etc.) */ +#define DT_COUNT 0x20 /* Currently not used */ /* * Values for Opcode above. @@ -147,6 +147,7 @@ typedef enum ACPI_DMT_HESTNTYP, ACPI_DMT_IVRS, ACPI_DMT_MADT, + ACPI_DMT_PCCT, ACPI_DMT_PMTT, ACPI_DMT_SLIC, ACPI_DMT_SRAT, @@ -244,6 +245,7 @@ extern ACPI_DMTABLE_INFO AcpiDmTableInfoDbg2Device[]; extern ACPI_DMTABLE_INFO AcpiDmTableInfoDbg2Addr[]; extern ACPI_DMTABLE_INFO AcpiDmTableInfoDbg2Size[]; extern ACPI_DMTABLE_INFO AcpiDmTableInfoDbg2Name[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoDbg2OemData[]; extern ACPI_DMTABLE_INFO AcpiDmTableInfoDbgp[]; extern ACPI_DMTABLE_INFO AcpiDmTableInfoDmar[]; extern ACPI_DMTABLE_INFO AcpiDmTableInfoDmarHdr[]; @@ -324,6 +326,7 @@ extern ACPI_DMTABLE_INFO AcpiDmTableInfoPmtt1a[]; extern ACPI_DMTABLE_INFO AcpiDmTableInfoPmtt2[]; extern ACPI_DMTABLE_INFO AcpiDmTableInfoPmttHdr[]; extern ACPI_DMTABLE_INFO AcpiDmTableInfoPcct[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoPcctHdr[]; extern ACPI_DMTABLE_INFO AcpiDmTableInfoPcct0[]; extern ACPI_DMTABLE_INFO AcpiDmTableInfoRsdp1[]; extern ACPI_DMTABLE_INFO AcpiDmTableInfoRsdp2[]; @@ -668,11 +671,19 @@ AcpiDmClearExternalFileList ( void); void -AcpiDmAddToExternalList ( +AcpiDmAddOpToExternalList ( ACPI_PARSE_OBJECT *Op, char *Path, UINT8 Type, - UINT32 Value); + UINT32 Value, + UINT16 Flags); + +void +AcpiDmAddNodeToExternalList ( + ACPI_NAMESPACE_NODE *Node, + UINT8 Type, + UINT32 Value, + UINT16 Flags); void AcpiDmAddExternalsToNamespace ( diff --git a/source/include/acevents.h b/source/include/acevents.h index 67095aa..28bb6ce 100644 --- a/source/include/acevents.h +++ b/source/include/acevents.h @@ -206,9 +206,10 @@ AcpiEvGetGpeDevice ( ACPI_GPE_BLOCK_INFO *GpeBlock, void *Context); -ACPI_GPE_XRUPT_INFO * +ACPI_STATUS AcpiEvGetGpeXruptBlock ( - UINT32 InterruptNumber); + UINT32 InterruptNumber, + ACPI_GPE_XRUPT_INFO **GpeXruptBlock); ACPI_STATUS AcpiEvDeleteGpeXrupt ( diff --git a/source/include/acglobal.h b/source/include/acglobal.h index cb76f65..e23aab9 100644 --- a/source/include/acglobal.h +++ b/source/include/acglobal.h @@ -121,6 +121,25 @@ UINT8 ACPI_INIT_GLOBAL (AcpiGbl_EnableAmlDebugObject, FALSE); UINT8 ACPI_INIT_GLOBAL (AcpiGbl_CopyDsdtLocally, FALSE); /* + * Optionally ignore an XSDT if present and use the RSDT instead. + * Although the ACPI specification requires that an XSDT be used instead + * of the RSDT, the XSDT has been found to be corrupt or ill-formed on + * some machines. Default behavior is to use the XSDT if present. + */ +UINT8 ACPI_INIT_GLOBAL (AcpiGbl_DoNotUseXsdt, FALSE); + + +/* + * Optionally use 32-bit FADT addresses if and when there is a conflict + * (address mismatch) between the 32-bit and 64-bit versions of the + * address. Although ACPICA adheres to the ACPI specification which + * requires the use of the corresponding 64-bit address if it is non-zero, + * some machines have been found to have a corrupted non-zero 64-bit + * address. Default is FALSE, do not favor the 32-bit addresses. + */ +UINT8 ACPI_INIT_GLOBAL (AcpiGbl_Use32BitFadtAddresses, FALSE); + +/* * Optionally truncate I/O addresses to 16 bits. Provides compatibility * with other ACPI implementations. NOTE: During ACPICA initialization, * this value is set to TRUE if any Windows OSI strings have been @@ -492,6 +511,19 @@ ACPI_EXTERN UINT32 AcpiGbl_SizeOfAcpiObjects; /***************************************************************************** * + * Application globals + * + ****************************************************************************/ + +#ifdef ACPI_APPLICATION + +ACPI_FILE ACPI_INIT_GLOBAL (AcpiGbl_DebugFile, NULL); + +#endif /* ACPI_APPLICATION */ + + +/***************************************************************************** + * * Info/help support * ****************************************************************************/ diff --git a/source/include/aclocal.h b/source/include/aclocal.h index 0febef4..7e4d63a 100644 --- a/source/include/aclocal.h +++ b/source/include/aclocal.h @@ -1218,17 +1218,17 @@ typedef struct acpi_external_list struct acpi_external_list *Next; UINT32 Value; UINT16 Length; + UINT16 Flags; UINT8 Type; - UINT8 Flags; - BOOLEAN Resolved; - BOOLEAN Emitted; } ACPI_EXTERNAL_LIST; /* Values for Flags field above */ -#define ACPI_IPATH_ALLOCATED 0x01 -#define ACPI_FROM_REFERENCE_FILE 0x02 +#define ACPI_EXT_RESOLVED_REFERENCE 0x01 /* Object was resolved during cross ref */ +#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 */ typedef struct acpi_external_file diff --git a/source/include/acpixf.h b/source/include/acpixf.h index 15273ad..0e93bb3 100644 --- a/source/include/acpixf.h +++ b/source/include/acpixf.h @@ -47,7 +47,7 @@ /* Current ACPICA subsystem version in YYYYMMDD format */ -#define ACPI_CA_VERSION 0x20131115 +#define ACPI_CA_VERSION 0x20131218 #include "acconfig.h" #include "actypes.h" @@ -70,17 +70,19 @@ extern UINT32 AcpiDbgLayer; /* ACPICA runtime options */ -extern UINT8 AcpiGbl_EnableInterpreterSlack; extern UINT8 AcpiGbl_AllMethodsSerialized; -extern UINT8 AcpiGbl_CreateOsiMethod; -extern UINT8 AcpiGbl_UseDefaultRegisterWidths; -extern ACPI_NAME AcpiGbl_TraceMethodName; -extern UINT32 AcpiGbl_TraceFlags; -extern UINT8 AcpiGbl_EnableAmlDebugObject; extern UINT8 AcpiGbl_CopyDsdtLocally; -extern UINT8 AcpiGbl_TruncateIoAddresses; +extern UINT8 AcpiGbl_CreateOsiMethod; extern UINT8 AcpiGbl_DisableAutoRepair; extern UINT8 AcpiGbl_DisableSsdtTableLoad; +extern UINT8 AcpiGbl_DoNotUseXsdt; +extern UINT8 AcpiGbl_EnableAmlDebugObject; +extern UINT8 AcpiGbl_EnableInterpreterSlack; +extern UINT32 AcpiGbl_TraceFlags; +extern ACPI_NAME AcpiGbl_TraceMethodName; +extern UINT8 AcpiGbl_TruncateIoAddresses; +extern UINT8 AcpiGbl_Use32BitFadtAddresses; +extern UINT8 AcpiGbl_UseDefaultRegisterWidths; /* diff --git a/source/include/actbl.h b/source/include/actbl.h index cbcdb1d..407be1f 100644 --- a/source/include/actbl.h +++ b/source/include/actbl.h @@ -203,6 +203,9 @@ typedef struct acpi_table_xsdt } ACPI_TABLE_XSDT; +#define ACPI_RSDT_ENTRY_SIZE (sizeof (UINT32)) +#define ACPI_XSDT_ENTRY_SIZE (sizeof (UINT64)) + /******************************************************************************* * diff --git a/source/include/actbl1.h b/source/include/actbl1.h index 67579da..574ae5c 100644 --- a/source/include/actbl1.h +++ b/source/include/actbl1.h @@ -524,7 +524,7 @@ typedef struct acpi_hest_aer_common UINT8 Enabled; UINT32 RecordsToPreallocate; UINT32 MaxSectionsPerRecord; - UINT32 Bus; + UINT32 Bus; /* Bus and Segment numbers */ UINT16 Device; UINT16 Function; UINT16 DeviceControl; @@ -541,6 +541,14 @@ typedef struct acpi_hest_aer_common #define ACPI_HEST_FIRMWARE_FIRST (1) #define ACPI_HEST_GLOBAL (1<<1) +/* + * Macros to access the bus/segment numbers in Bus field above: + * Bus number is encoded in bits 7:0 + * Segment number is encoded in bits 23:8 + */ +#define ACPI_HEST_BUS(Bus) ((Bus) & 0xFF) +#define ACPI_HEST_SEGMENT(Bus) (((Bus) >> 8) & 0xFFFF) + /* Hardware Error Notification */ diff --git a/source/include/actbl2.h b/source/include/actbl2.h index 327a810..081ea2e 100644 --- a/source/include/actbl2.h +++ b/source/include/actbl2.h @@ -373,6 +373,14 @@ typedef struct acpi_table_dbg2 } ACPI_TABLE_DBG2; +typedef struct acpi_dbg2_header +{ + UINT32 InfoOffset; + UINT32 InfoCount; + +} ACPI_DBG2_HEADER; + + /* Debug Device Information Subtable */ typedef struct acpi_dbg2_device diff --git a/source/include/actbl3.h b/source/include/actbl3.h index acf2e13..e63d672 100644 --- a/source/include/actbl3.h +++ b/source/include/actbl3.h @@ -440,8 +440,7 @@ typedef struct acpi_table_pcct { ACPI_TABLE_HEADER Header; /* Common ACPI table header */ UINT32 Flags; - UINT32 Latency; - UINT32 Reserved; + UINT64 Reserved; } ACPI_TABLE_PCCT; @@ -449,8 +448,16 @@ typedef struct acpi_table_pcct #define ACPI_PCCT_DOORBELL 1 +/* Values for subtable type in ACPI_SUBTABLE_HEADER */ + +enum AcpiPcctType +{ + ACPI_PCCT_TYPE_GENERIC_SUBSPACE = 0, + ACPI_PCCT_TYPE_RESERVED = 1 /* 1 and greater are reserved */ +}; + /* - * PCCT subtables + * PCCT Subtables, correspond to Type in ACPI_SUBTABLE_HEADER */ /* 0: Generic Communications Subspace */ @@ -464,6 +471,9 @@ typedef struct acpi_pcct_subspace ACPI_GENERIC_ADDRESS DoorbellRegister; UINT64 PreserveMask; UINT64 WriteMask; + UINT32 Latency; + UINT32 MaxAccessRate; + UINT16 MinTurnaroundTime; } ACPI_PCCT_SUBSPACE; diff --git a/source/include/actypes.h b/source/include/actypes.h index 7c484b2..4ffb014 100644 --- a/source/include/actypes.h +++ b/source/include/actypes.h @@ -954,8 +954,8 @@ typedef struct acpi_object_list * Miscellaneous common Data Structures used by the interfaces */ #define ACPI_NO_BUFFER 0 -#define ACPI_ALLOCATE_BUFFER (ACPI_SIZE) (-1) -#define ACPI_ALLOCATE_LOCAL_BUFFER (ACPI_SIZE) (-2) +#define ACPI_ALLOCATE_BUFFER (ACPI_SIZE) (-1) /* Let ACPICA allocate buffer */ +#define ACPI_ALLOCATE_LOCAL_BUFFER (ACPI_SIZE) (-2) /* For internal use only (enables tracking) */ typedef struct acpi_buffer { @@ -964,10 +964,6 @@ typedef struct acpi_buffer } ACPI_BUFFER; -/* Free a buffer created in an ACPI_BUFFER via ACPI_ALLOCATE_LOCAL_BUFFER */ - -#define ACPI_FREE_BUFFER(b) ACPI_FREE(b.Pointer) - /* * NameType for AcpiGetName diff --git a/source/include/platform/acenv.h b/source/include/platform/acenv.h index 8895ceb..6608571 100644 --- a/source/include/platform/acenv.h +++ b/source/include/platform/acenv.h @@ -97,13 +97,14 @@ #endif /* - * AcpiBin/AcpiDump/AcpiSrc/AcpiXtract configuration. All single + * AcpiBin/AcpiDump/AcpiSrc/AcpiXtract/Example configuration. All single * threaded, with no debug output. */ -#if (defined ACPI_BIN_APP) || \ - (defined ACPI_DUMP_APP) || \ - (defined ACPI_SRC_APP) || \ - (defined ACPI_XTRACT_APP) +#if (defined ACPI_BIN_APP) || \ + (defined ACPI_DUMP_APP) || \ + (defined ACPI_SRC_APP) || \ + (defined ACPI_XTRACT_APP) || \ + (defined ACPI_EXAMPLE_APP) #define ACPI_APPLICATION #define ACPI_SINGLE_THREADED #endif @@ -396,4 +397,13 @@ typedef char *va_list; #endif /* ACPI_USE_SYSTEM_CLIBRARY */ +#ifndef ACPI_FILE +#ifdef ACPI_APPLICATION +#include <stdio.h> +#define ACPI_FILE FILE * +#else +#define ACPI_FILE void * +#endif /* ACPI_APPLICATION */ +#endif /* ACPI_FILE */ + #endif /* __ACENV_H__ */ diff --git a/source/include/platform/aclinux.h b/source/include/platform/aclinux.h index f56aff1..51cc4c2 100644 --- a/source/include/platform/aclinux.h +++ b/source/include/platform/aclinux.h @@ -257,14 +257,6 @@ EarlyAcpiOsUnmapMemory ( void __iomem *Virt, ACPI_SIZE Size); -void -AcpiOsGpeCount ( - UINT32 GpeNumber); - -void -AcpiOsFixedEventCount ( - UINT32 FixedEventNumber); - ACPI_STATUS AcpiOsHotplugExecute ( ACPI_OSD_EXEC_CALLBACK Function, diff --git a/source/os_specific/service_layers/osunixdir.c b/source/os_specific/service_layers/osunixdir.c index 2e007e9..828a9f9 100644 --- a/source/os_specific/service_layers/osunixdir.c +++ b/source/os_specific/service_layers/osunixdir.c @@ -167,15 +167,17 @@ AcpiOsGetNextFilename ( strcat (temp_str, dir_entry->d_name); err = stat (temp_str, &temp_stat); - free (temp_str); if (err == -1) { fprintf (stderr, "Cannot stat file (should not happen) - %s\n", temp_str); + free (temp_str); return (NULL); } + free (temp_str); + if ((S_ISDIR (temp_stat.st_mode) && (ExternalInfo->RequestedFileType == REQUEST_DIR_ONLY)) || diff --git a/source/os_specific/service_layers/osunixxf.c b/source/os_specific/service_layers/osunixxf.c index 74c4c24..b520402 100644 --- a/source/os_specific/service_layers/osunixxf.c +++ b/source/os_specific/service_layers/osunixxf.c @@ -65,7 +65,6 @@ ACPI_MODULE_NAME ("osunixxf") -extern FILE *AcpiGbl_DebugFile; FILE *AcpiGbl_OutputFile; BOOLEAN AcpiGbl_DebugTimeout = FALSE; diff --git a/source/os_specific/service_layers/oswinxf.c b/source/os_specific/service_layers/oswinxf.c index 697fd45..09de803 100644 --- a/source/os_specific/service_layers/oswinxf.c +++ b/source/os_specific/service_layers/oswinxf.c @@ -64,8 +64,6 @@ ACPI_MODULE_NAME ("oswinxf") -extern FILE *AcpiGbl_DebugFile; - FILE *AcpiGbl_OutputFile; UINT64 TimerFrequency; char TableName[ACPI_NAME_SIZE + 1]; diff --git a/source/tools/acpibin/acpibin.h b/source/tools/acpibin/acpibin.h index 6780a35..ed1ec2f 100644 --- a/source/tools/acpibin/acpibin.h +++ b/source/tools/acpibin/acpibin.h @@ -66,7 +66,6 @@ /* Globals */ EXTERN BOOLEAN INIT_GLOBAL (Gbl_TerseMode, FALSE); -EXTERN FILE INIT_GLOBAL (*AcpiGbl_DebugFile, NULL); /* Prototypes */ diff --git a/source/tools/acpiexec/aecommon.h b/source/tools/acpiexec/aecommon.h index ab8c942..b214868 100644 --- a/source/tools/acpiexec/aecommon.h +++ b/source/tools/acpiexec/aecommon.h @@ -63,7 +63,6 @@ #include <string.h> #include <signal.h> -extern FILE *AcpiGbl_DebugFile; extern BOOLEAN AcpiGbl_IgnoreErrors; extern UINT8 AcpiGbl_RegionFillValue; extern UINT8 AcpiGbl_UseHwReducedFadt; diff --git a/source/tools/acpiexec/aeexec.c b/source/tools/acpiexec/aeexec.c index be4d8d6..8f6d6da 100644 --- a/source/tools/acpiexec/aeexec.c +++ b/source/tools/acpiexec/aeexec.c @@ -344,31 +344,42 @@ ExecuteOSI ( return (Status); } + Status = AE_ERROR; + if (ReturnValue.Length < sizeof (ACPI_OBJECT)) { AcpiOsPrintf ("Return value from _OSI method too small, %.8X\n", ReturnValue.Length); - return (AE_ERROR); + goto ErrorExit; } Obj = ReturnValue.Pointer; if (Obj->Type != ACPI_TYPE_INTEGER) { AcpiOsPrintf ("Invalid return type from _OSI method, %.2X\n", Obj->Type); - return (AE_ERROR); + goto ErrorExit; } if (Obj->Integer.Value != ExpectedResult) { AcpiOsPrintf ("Invalid return value from _OSI, expected %.8X found %.8X\n", ExpectedResult, (UINT32) Obj->Integer.Value); - return (AE_ERROR); + goto ErrorExit; } + Status = AE_OK; + /* Reset the OSI data */ AcpiGbl_OsiData = 0; - return (AE_OK); + +ErrorExit: + + /* Free a buffer created via ACPI_ALLOCATE_BUFFER */ + + AcpiOsFree (ReturnValue.Pointer); + + return (Status); } diff --git a/source/tools/acpiexec/aehandlers.c b/source/tools/acpiexec/aehandlers.c index 2447414..aa6540d 100644 --- a/source/tools/acpiexec/aehandlers.c +++ b/source/tools/acpiexec/aehandlers.c @@ -460,6 +460,8 @@ AeExceptionHandler ( NewAmlStatus = (ACPI_STATUS) ((ACPI_OBJECT *) ReturnObj.Pointer)->Integer.Value; + /* Free a buffer created via ACPI_ALLOCATE_BUFFER */ + AcpiOsFree (ReturnObj.Pointer); } } @@ -1049,21 +1051,11 @@ AeInstallEarlyHandlers ( Status = AcpiDetachData (Handle, AeAttachedDataHandler); AE_CHECK_OK (AcpiDetachData, Status); - /* Test attach data at the root object */ - - Status = AcpiAttachData (ACPI_ROOT_OBJECT, AeAttachedDataHandler, - AcpiGbl_RootNode); - AE_CHECK_OK (AcpiAttachData, Status); - - Status = AcpiAttachData (ACPI_ROOT_OBJECT, AeAttachedDataHandler2, - AcpiGbl_RootNode); + Status = AcpiAttachData (Handle, AeAttachedDataHandler, Handle); AE_CHECK_OK (AcpiAttachData, Status); /* Test support for multiple attaches */ - Status = AcpiAttachData (Handle, AeAttachedDataHandler, Handle); - AE_CHECK_OK (AcpiAttachData, Status); - Status = AcpiAttachData (Handle, AeAttachedDataHandler2, Handle); AE_CHECK_OK (AcpiAttachData, Status); } diff --git a/source/tools/acpinames/anmain.c b/source/tools/acpinames/anmain.c index c30ae7a..4a079c4 100644 --- a/source/tools/acpinames/anmain.c +++ b/source/tools/acpinames/anmain.c @@ -49,7 +49,6 @@ extern ACPI_TABLE_DESC Tables[]; -FILE *AcpiGbl_DebugFile; static AE_TABLE_DESC *AeTableListHead = NULL; diff --git a/source/tools/acpisrc/asremove.c b/source/tools/acpisrc/asremove.c index 37b167b..78cbd6e 100644 --- a/source/tools/acpisrc/asremove.c +++ b/source/tools/acpisrc/asremove.c @@ -638,7 +638,9 @@ AsCleanupSpecialMacro ( { char *SubString; char *SubBuffer; - char *LastNonSpace; + char *CommentEnd; + int NewLine; + int NestLevel; SubBuffer = Buffer; @@ -650,40 +652,84 @@ AsCleanupSpecialMacro ( if (SubString) { - /* Find start of the line */ + /* Find start of the macro parameters */ - SubBuffer = SubString; - while (*(SubBuffer - 1) == ' ') + while (*SubString != '(') { - SubBuffer--; + SubString++; } + SubString++; - if (*(SubBuffer - 1) == '\n') + NestLevel = 1; + while (*SubString) { - /* Find last non-space character */ + if (*SubString == '(') + { + NestLevel++; + } + else if (*SubString == ')') + { + NestLevel--; + } + + SubString++; - LastNonSpace = SubBuffer - 1; - while (isspace ((int) *LastNonSpace)) + if (NestLevel == 0) { - LastNonSpace--; + break; } + } + +SkipLine: + + /* Find end of the line */ - if (*LastNonSpace != '\\') + NewLine = FALSE; + while (!NewLine && *SubString) + { + if (*SubString == '\n' && *(SubString - 1) != '\\') { - /* Remove the extra spaces */ + NewLine = TRUE; + } + SubString++; + } + + /* Find end of the line */ + + if (*SubString == '#' || *SubString == '\n') + { + goto SkipLine; + } - SubString = AsRemoveData (SubBuffer, SubString); + SubBuffer = SubString; - /* Enforce an empty line between the invocations */ + /* Find start of the non-space */ - if (*(SubBuffer - 2) == ')') - { - AsInsertData (SubBuffer, "\n", 1); - } + while (*SubString == ' ') + { + SubString++; + } + + /* Find end of the line */ + + if (*SubString == '#' || *SubString == '\n') + { + goto SkipLine; + } + + /* Find end of the line */ + + if (*SubString == '/' || *SubString == '*') + { + CommentEnd = strstr (SubString, "*/"); + if (CommentEnd) + { + SubString = CommentEnd + 2; + goto SkipLine; } } - SubBuffer = SubString + strlen (Keyword); + SubString = AsRemoveData (SubBuffer, SubString); } } } diff --git a/source/tools/examples/examples.c b/source/tools/examples/examples.c index d90715d..ad31945 100644 --- a/source/tools/examples/examples.c +++ b/source/tools/examples/examples.c @@ -1,6 +1,6 @@ /****************************************************************************** * - * Module Name: examples - Example ACPICA code + * Module Name: examples - Example ACPICA initialization and execution code * *****************************************************************************/ @@ -41,18 +41,8 @@ * POSSIBILITY OF SUCH DAMAGES. */ - -/* Set the ACPICA application type for use in include/platform/acenv.h */ - -#ifndef WIN32 -#define WIN32 -#endif - -#define ACPI_DEBUG_OUTPUT - -/* ACPICA public headers */ - -#include "acpi.h" +#define __EXAMPLES_C__ +#include "examples.h" #define _COMPONENT ACPI_EXAMPLE ACPI_MODULE_NAME ("examples") @@ -81,22 +71,35 @@ * *****************************************************************************/ -/* Standard Clib headers */ - -#include <stdio.h> -#include <string.h> /* Local Prototypes */ -ACPI_STATUS -InitializeFullAcpi (void); +static ACPI_STATUS +InitializeFullAcpica (void); -ACPI_STATUS +static ACPI_STATUS InstallHandlers (void); -void +static void +NotifyHandler ( + ACPI_HANDLE Device, + UINT32 Value, + void *Context); + +static void +ExecuteMAIN (void); + +static void ExecuteOSI (void); +ACPI_STATUS +InitializeAcpiTables ( + void); + +ACPI_STATUS +InitializeAcpi ( + void); + /****************************************************************************** * @@ -116,26 +119,28 @@ main ( int argc, char **argv) { - ACPI_FUNCTION_NAME (Examples-main); - ACPI_DEBUG_INITIALIZE (); /* For debug version only */ - InitializeFullAcpi (); - /* Enable debug output, example debug print */ + printf (ACPI_COMMON_SIGNON ("ACPI Example Code")); + + /* Initialize the local ACPI tables (RSDP/RSDT/XSDT/FADT/DSDT/FACS) */ - AcpiDbgLayer = ACPI_EXAMPLE; - AcpiDbgLevel = ACPI_LV_INIT; - ACPI_DEBUG_PRINT ((ACPI_DB_INIT, "Example Debug output\n")); + ExInitializeAcpiTables (); + + /* Initialize the ACPICA subsystem */ + + InitializeFullAcpica (); /* Example warning and error output */ - ACPI_INFO ((AE_INFO, "ACPICA example info message")); - ACPI_WARNING ((AE_INFO, "ACPICA example warning message")); - ACPI_ERROR ((AE_INFO, "ACPICA example error message")); - ACPI_EXCEPTION ((AE_INFO, AE_AML_OPERAND_TYPE, "Example exception message")); + ACPI_INFO ((AE_INFO, "Example ACPICA info message")); + ACPI_WARNING ((AE_INFO, "Example ACPICA warning message")); + ACPI_ERROR ((AE_INFO, "Example ACPICA error message")); + ACPI_EXCEPTION ((AE_INFO, AE_AML_OPERAND_TYPE, "Example ACPICA exception message")); ExecuteOSI (); + ExecuteMAIN (); return (0); } @@ -147,8 +152,8 @@ main ( * *****************************************************************************/ -ACPI_STATUS -InitializeFullAcpi (void) +static ACPI_STATUS +InitializeFullAcpica (void) { ACPI_STATUS Status; @@ -164,6 +169,8 @@ InitializeFullAcpi (void) /* Initialize the ACPICA Table Manager and get all ACPI tables */ + ACPI_INFO ((AE_INFO, "Loading ACPI tables")); + Status = AcpiInitializeTables (NULL, 16, FALSE); if (ACPI_FAILURE (Status)) { @@ -233,7 +240,8 @@ static ACPI_TABLE_DESC TableArray[ACPI_MAX_INIT_TABLES]; * is called, all ACPI tables are available to the host. */ ACPI_STATUS -InitializeAcpiTables (void) +InitializeAcpiTables ( + void) { ACPI_STATUS Status; @@ -251,7 +259,8 @@ InitializeAcpiTables (void) * the ACPICA subsystem. */ ACPI_STATUS -InitializeAcpi (void) +InitializeAcpi ( + void) { ACPI_STATUS Status; @@ -315,7 +324,7 @@ InitializeAcpi (void) * *****************************************************************************/ -void +static void NotifyHandler ( ACPI_HANDLE Device, UINT32 Value, @@ -326,7 +335,7 @@ NotifyHandler ( } -ACPI_STATUS +static ACPI_STATUS InstallHandlers (void) { ACPI_STATUS Status; @@ -348,7 +357,7 @@ InstallHandlers (void) /****************************************************************************** * - * Example control method execution. + * Examples of control method execution. * * _OSI is a predefined method that is implemented internally within ACPICA. * @@ -362,7 +371,7 @@ InstallHandlers (void) * *****************************************************************************/ -void +static void ExecuteOSI (void) { ACPI_STATUS Status; @@ -372,7 +381,7 @@ ExecuteOSI (void) ACPI_OBJECT *Object; - ACPI_INFO ((AE_INFO, "Executing OSI method")); + ACPI_INFO ((AE_INFO, "Executing _OSI reserved method")); /* Setup input argument */ @@ -400,7 +409,7 @@ ExecuteOSI (void) { AcpiOsPrintf ("Return value from _OSI method too small, %.8X\n", ReturnValue.Length); - return; + goto ErrorExit; } /* Expect an integer return value from execution of _OSI */ @@ -412,39 +421,64 @@ ExecuteOSI (void) } ACPI_INFO ((AE_INFO, "_OSI returned 0x%8.8X", (UINT32) Object->Integer.Value)); - AcpiOsFree (Object); - return; + + +ErrorExit: + + /* Free a buffer created via ACPI_ALLOCATE_BUFFER */ + + AcpiOsFree (ReturnValue.Pointer); } /****************************************************************************** * - * OSL support (only needed to link to the windows OSL) + * Execute an actual control method in the DSDT (MAIN) * *****************************************************************************/ -FILE *AcpiGbl_DebugFile; - -ACPI_PHYSICAL_ADDRESS -AeLocalGetRootPointer ( - void) +static void +ExecuteMAIN (void) { + ACPI_STATUS Status; + ACPI_OBJECT_LIST ArgList; + ACPI_OBJECT Arg[1]; + ACPI_BUFFER ReturnValue; + ACPI_OBJECT *Object; - return (0); -} -ACPI_THREAD_ID -AcpiOsGetThreadId ( - void) -{ - return (0xFFFF); -} + ACPI_INFO ((AE_INFO, "Executing MAIN method")); -ACPI_STATUS -AcpiOsExecute ( - ACPI_EXECUTE_TYPE Type, - ACPI_OSD_EXEC_CALLBACK Function, - void *Context) -{ - return (AE_SUPPORT); + /* Setup input argument */ + + ArgList.Count = 1; + ArgList.Pointer = Arg; + + Arg[0].Type = ACPI_TYPE_STRING; + Arg[0].String.Pointer = "Method [MAIN] is executing"; + Arg[0].String.Length = strlen (Arg[0].String.Pointer); + + /* Ask ACPICA to allocate space for the return object */ + + ReturnValue.Length = ACPI_ALLOCATE_BUFFER; + + Status = AcpiEvaluateObject (NULL, "\\MAIN", &ArgList, &ReturnValue); + if (ACPI_FAILURE (Status)) + { + ACPI_EXCEPTION ((AE_INFO, Status, "While executing MAIN")); + return; + } + + if (ReturnValue.Pointer) + { + /* Obtain and validate the returned ACPI_OBJECT */ + + Object = ReturnValue.Pointer; + if (Object->Type == ACPI_TYPE_STRING) + { + AcpiOsPrintf ("Method [MAIN] returned: \"%s\"\n", Object->String.Pointer); + } + + ACPI_FREE (ReturnValue.Pointer); + } } diff --git a/source/tools/examples/examples.h b/source/tools/examples/examples.h new file mode 100644 index 0000000..13b8c2d --- /dev/null +++ b/source/tools/examples/examples.h @@ -0,0 +1,59 @@ +/****************************************************************************** + * + * Module Name: examples.h - Common include for Examples program + * + *****************************************************************************/ + +/* + * Copyright (C) 2000 - 2013, 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 _EXAMPLES_H +#define _EXAMPLES_H + +#include "acpi.h" +#include "accommon.h" +#include "acapps.h" +#include "../acpiexec/aecommon.h" + +#include <stdio.h> + + +void +ExInitializeAcpiTables ( + void); + +#endif diff --git a/source/tools/examples/exstubs.c b/source/tools/examples/exstubs.c new file mode 100644 index 0000000..7028a88 --- /dev/null +++ b/source/tools/examples/exstubs.c @@ -0,0 +1,339 @@ +/****************************************************************************** + * + * Module Name: exstubs - Stub routines for the Example program + * + *****************************************************************************/ + +/* + * Copyright (C) 2000 - 2013, 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 "examples.h" + +#include <acutils.h> +#include <acevents.h> +#include <acdispat.h> + +#define _COMPONENT ACPI_EXAMPLE + ACPI_MODULE_NAME ("exstubs") + + +/****************************************************************************** + * + * DESCRIPTION: Stubs used to facilitate linkage of the example program + * + *****************************************************************************/ + + +/* Utilities */ + +void +AcpiUtSubsystemShutdown ( + void) +{ +} + +ACPI_STATUS +AcpiUtExecute_STA ( + ACPI_NAMESPACE_NODE *DeviceNode, + UINT32 *StatusFlags) +{ + return (AE_NOT_IMPLEMENTED); +} + +ACPI_STATUS +AcpiUtExecute_HID ( + ACPI_NAMESPACE_NODE *DeviceNode, + ACPI_PNP_DEVICE_ID **ReturnId) +{ + return (AE_NOT_IMPLEMENTED); +} + +ACPI_STATUS +AcpiUtExecute_CID ( + ACPI_NAMESPACE_NODE *DeviceNode, + ACPI_PNP_DEVICE_ID_LIST **ReturnCidList) +{ + return (AE_NOT_IMPLEMENTED); +} + +ACPI_STATUS +AcpiUtExecute_UID ( + ACPI_NAMESPACE_NODE *DeviceNode, + ACPI_PNP_DEVICE_ID **ReturnId) +{ + return (AE_NOT_IMPLEMENTED); +} + +ACPI_STATUS +AcpiUtExecute_SUB ( + ACPI_NAMESPACE_NODE *DeviceNode, + ACPI_PNP_DEVICE_ID **ReturnId) +{ + return (AE_NOT_IMPLEMENTED); +} + +ACPI_STATUS +AcpiUtExecutePowerMethods ( + ACPI_NAMESPACE_NODE *DeviceNode, + const char **MethodNames, + UINT8 MethodCount, + UINT8 *OutValues) +{ + return (AE_NOT_IMPLEMENTED); +} + +ACPI_STATUS +AcpiUtEvaluateNumericObject ( + char *ObjectName, + ACPI_NAMESPACE_NODE *DeviceNode, + UINT64 *Value) +{ + return (AE_NOT_IMPLEMENTED); +} + +ACPI_STATUS +AcpiUtGetResourceEndTag ( + ACPI_OPERAND_OBJECT *ObjDesc, + UINT8 **EndTag) +{ + return (AE_OK); +} + + +/* Hardware manager */ + +UINT32 +AcpiHwGetMode ( + void) +{ + return (0); +} + +ACPI_STATUS +AcpiHwReadPort ( + ACPI_IO_ADDRESS Address, + UINT32 *Value, + UINT32 Width) +{ + return (AE_OK); +} + +ACPI_STATUS +AcpiHwWritePort ( + ACPI_IO_ADDRESS Address, + UINT32 Value, + UINT32 Width) +{ + return (AE_OK); +} + + +/* Event manager */ + +ACPI_STATUS +AcpiInstallNotifyHandler ( + ACPI_HANDLE Device, + UINT32 HandlerType, + ACPI_NOTIFY_HANDLER Handler, + void *Context) +{ + return (AE_OK); +} + +ACPI_STATUS +AcpiEvInstallXruptHandlers ( + void) +{ + return (AE_OK); +} + +ACPI_STATUS +AcpiEvInitializeEvents ( + void) +{ + return (AE_OK); +} + +ACPI_STATUS +AcpiEvInstallRegionHandlers ( + void) +{ + return (AE_OK); +} + +ACPI_STATUS +AcpiEvInitializeOpRegions ( + void) +{ + return (AE_OK); +} + +ACPI_STATUS +AcpiEvInitializeRegion ( + ACPI_OPERAND_OBJECT *RegionObj, + BOOLEAN AcpiNsLocked) +{ + return (AE_OK); +} + +#if (!ACPI_REDUCED_HARDWARE) +ACPI_STATUS +AcpiEvDeleteGpeBlock ( + ACPI_GPE_BLOCK_INFO *GpeBlock) +{ + return (AE_OK); +} + +ACPI_STATUS +AcpiEnable ( + void) +{ + return (AE_OK); +} +#endif /* !ACPI_REDUCED_HARDWARE */ + +void +AcpiEvUpdateGpes ( + ACPI_OWNER_ID TableOwnerId) +{ +} + +ACPI_STATUS +AcpiEvAddressSpaceDispatch ( + ACPI_OPERAND_OBJECT *RegionObj, + ACPI_OPERAND_OBJECT *FieldObj, + UINT32 Function, + UINT32 RegionOffset, + UINT32 BitWidth, + UINT64 *Value) +{ + return (AE_OK); +} + +ACPI_STATUS +AcpiEvAcquireGlobalLock ( + UINT16 Timeout) +{ + return (AE_OK); +} + +ACPI_STATUS +AcpiEvReleaseGlobalLock ( + void) +{ + return (AE_OK); +} + +ACPI_STATUS +AcpiEvQueueNotifyRequest ( + ACPI_NAMESPACE_NODE *Node, + UINT32 NotifyValue) +{ + return (AE_OK); +} + +BOOLEAN +AcpiEvIsNotifyObject ( + ACPI_NAMESPACE_NODE *Node) +{ + return (TRUE); +} + + +/* Namespace manager */ + +ACPI_STATUS +AcpiNsCheckReturnValue ( + ACPI_NAMESPACE_NODE *Node, + ACPI_EVALUATE_INFO *Info, + UINT32 UserParamCount, + ACPI_STATUS ReturnStatus, + ACPI_OPERAND_OBJECT **ReturnObjectPtr) +{ + return (AE_OK); +} + +void +AcpiNsCheckArgumentTypes ( + ACPI_EVALUATE_INFO *Info) +{ + return; +} + +void +AcpiNsCheckArgumentCount ( + char *Pathname, + ACPI_NAMESPACE_NODE *Node, + UINT32 UserParamCount, + const ACPI_PREDEFINED_INFO *Predefined) +{ + return; +} + +void +AcpiNsCheckAcpiCompliance ( + char *Pathname, + ACPI_NAMESPACE_NODE *Node, + const ACPI_PREDEFINED_INFO *Predefined) +{ + return; +} + +const ACPI_PREDEFINED_INFO * +AcpiUtMatchPredefinedMethod ( + char *Name) +{ + return (NULL); +} + +/* OSL interfaces */ + +ACPI_THREAD_ID +AcpiOsGetThreadId ( + void) +{ + return (1); +} + +ACPI_STATUS +AcpiOsExecute ( + ACPI_EXECUTE_TYPE Type, + ACPI_OSD_EXEC_CALLBACK Function, + void *Context) +{ + return (AE_SUPPORT); +} diff --git a/source/tools/examples/extables.c b/source/tools/examples/extables.c new file mode 100644 index 0000000..307fe2f --- /dev/null +++ b/source/tools/examples/extables.c @@ -0,0 +1,484 @@ +/****************************************************************************** + * + * Module Name: extables - ACPI tables for Example program + * + *****************************************************************************/ + +/* + * Copyright (C) 2000 - 2013, 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. + */ + +#define __EXTABLES_C__ + +#include "examples.h" +#include "actables.h" + +#define _COMPONENT ACPI_EXAMPLE + ACPI_MODULE_NAME ("extables") + +ACPI_PHYSICAL_ADDRESS +AeLocalGetRootPointer ( + void); + + +/****************************************************************************** + * + * ACPICA Example tables and table setup + * + * This module contains the ACPI tables used for the example program. The + * original source code for the tables appears at the end of the module. + * + *****************************************************************************/ + + +/* These tables will be modified at runtime */ + +unsigned char RsdpCode[] = +{ + 0x52,0x53,0x44,0x20,0x50,0x54,0x52,0x20, /* 00000000 "RSD PTR " */ + 0x43,0x49,0x4E,0x54,0x45,0x4C,0x20,0x02, /* 00000008 "CINTEL ." */ + 0x00,0x00,0x00,0x00,0x24,0x00,0x00,0x00, /* 00000010 "....$..." */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000018 "........" */ + 0xDC,0x00,0x00,0x00 /* 00000020 "...." */ +}; + +unsigned char RsdtCode[] = +{ + 0x52,0x53,0x44,0x54,0x28,0x00,0x00,0x00, /* 00000000 "RSDT(..." */ + 0x01,0x10,0x49,0x4E,0x54,0x45,0x4C,0x20, /* 00000008 "..INTEL " */ + 0x54,0x45,0x4D,0x50,0x4C,0x41,0x54,0x45, /* 00000010 "TEMPLATE" */ + 0x01,0x00,0x00,0x00,0x49,0x4E,0x54,0x4C, /* 00000018 "....INTL" */ + 0x15,0x11,0x13,0x20,0x01,0x00,0x00,0x00 /* 00000020 "... ...." */ +}; + +unsigned char XsdtCode[] = +{ + 0x58,0x53,0x44,0x54,0x2C,0x00,0x00,0x00, /* 00000000 "XSDT,..." */ + 0x01,0x06,0x49,0x4E,0x54,0x45,0x4C,0x20, /* 00000008 "..INTEL " */ + 0x54,0x45,0x4D,0x50,0x4C,0x41,0x54,0x45, /* 00000010 "TEMPLATE" */ + 0x01,0x00,0x00,0x00,0x49,0x4E,0x54,0x4C, /* 00000018 "....INTL" */ + 0x15,0x11,0x13,0x20,0x01,0x00,0x00,0x00, /* 00000020 "... ...." */ + 0x00,0x00,0x00,0x00 /* 00000028 "...." */ +}; + +unsigned char FadtCode[] = +{ + 0x46,0x41,0x43,0x50,0x0C,0x01,0x00,0x00, /* 00000000 "FACP...." */ + 0x05,0x64,0x49,0x4E,0x54,0x45,0x4C,0x20, /* 00000008 ".dINTEL " */ + 0x54,0x45,0x4D,0x50,0x4C,0x41,0x54,0x45, /* 00000010 "TEMPLATE" */ + 0x00,0x00,0x00,0x00,0x49,0x4E,0x54,0x4C, /* 00000018 "....INTL" */ + 0x15,0x11,0x13,0x20,0x01,0x00,0x00,0x00, /* 00000020 "... ...." */ + 0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000028 "........" */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000030 "........" */ + 0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000038 "........" */ + 0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000040 "........" */ + 0x01,0x00,0x00,0x00,0x01,0x00,0x00,0x00, /* 00000048 "........" */ + 0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000050 "........" */ + 0x04,0x02,0x01,0x04,0x08,0x00,0x00,0x00, /* 00000058 "........" */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000060 "........" */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000068 "........" */ + 0x00,0x00,0x00,0x00,0x01,0x08,0x00,0x01, /* 00000070 "........" */ + 0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000078 "........" */ + 0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00, /* 00000080 "........" */ + 0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00, /* 00000088 "........" */ + 0x00,0x00,0x00,0x00,0x01,0x20,0x00,0x02, /* 00000090 "..... .." */ + 0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000098 "........" */ + 0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 000000A0 "........" */ + 0x00,0x00,0x00,0x00,0x01,0x10,0x00,0x02, /* 000000A8 "........" */ + 0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 000000B0 "........" */ + 0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 000000B8 "........" */ + 0x00,0x00,0x00,0x00,0x01,0x08,0x00,0x00, /* 000000C0 "........" */ + 0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 000000C8 "........" */ + 0x01,0x20,0x00,0x03,0x01,0x00,0x00,0x00, /* 000000D0 ". ......" */ + 0x00,0x00,0x00,0x00,0x01,0x40,0x00,0x01, /* 000000D8 ".....@.." */ + 0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 000000E0 "........" */ + 0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 000000E8 "........" */ + 0x00,0x00,0x00,0x00,0x01,0x08,0x00,0x01, /* 000000F0 "........" */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 000000F8 "........" */ + 0x01,0x08,0x00,0x01,0x00,0x00,0x00,0x00, /* 00000100 "........" */ + 0x00,0x00,0x00,0x00 /* 00000108 "...." */ +}; + +/* Fixed tables */ + +static unsigned char FacsCode[] = +{ + 0x46,0x41,0x43,0x53,0x40,0x00,0x00,0x00, /* 00000000 "FACS@..." */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000008 "........" */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000010 "........" */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000018 "........" */ + 0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000020 "........" */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000028 "........" */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000030 "........" */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 /* 00000038 "........" */ +}; + +static unsigned char DsdtCode[] = +{ + 0x44,0x53,0x44,0x54,0x67,0x00,0x00,0x00, /* 00000000 "DSDTg..." */ + 0x02,0x97,0x49,0x6E,0x74,0x65,0x6C,0x00, /* 00000008 "..Intel." */ + 0x54,0x65,0x6D,0x70,0x6C,0x61,0x74,0x65, /* 00000010 "Template" */ + 0x01,0x00,0x00,0x00,0x49,0x4E,0x54,0x4C, /* 00000018 "....INTL" */ + 0x15,0x11,0x13,0x20,0x14,0x42,0x04,0x4D, /* 00000020 "... .B.M" */ + 0x41,0x49,0x4E,0x01,0x70,0x73,0x0D,0x4D, /* 00000028 "AIN.ps.M" */ + 0x61,0x69,0x6E,0x2F,0x41,0x72,0x67,0x30, /* 00000030 "ain/Arg0" */ + 0x3A,0x20,0x00,0x68,0x00,0x5B,0x31,0xA4, /* 00000038 ": .h.[1." */ + 0x0D,0x4D,0x61,0x69,0x6E,0x20,0x73,0x75, /* 00000040 ".Main su" */ + 0x63,0x63,0x65,0x73,0x73,0x66,0x75,0x6C, /* 00000048 "ccessful" */ + 0x6C,0x79,0x20,0x63,0x6F,0x6D,0x70,0x6C, /* 00000050 "ly compl" */ + 0x65,0x74,0x65,0x64,0x20,0x65,0x78,0x65, /* 00000058 "eted exe" */ + 0x63,0x75,0x74,0x69,0x6F,0x6E,0x00 /* 00000060 "cution." */ +}; + + +/* Useful pointers */ + +ACPI_TABLE_RSDP *Rsdp = ACPI_CAST_PTR (ACPI_TABLE_RSDP, RsdpCode); +ACPI_TABLE_RSDT *Rsdt = ACPI_CAST_PTR (ACPI_TABLE_RSDT, RsdtCode); +ACPI_TABLE_XSDT *Xsdt = ACPI_CAST_PTR (ACPI_TABLE_XSDT, XsdtCode); +ACPI_TABLE_FADT *Fadt = ACPI_CAST_PTR (ACPI_TABLE_FADT, FadtCode); + + +/****************************************************************************** + * + * Build the various required ACPI tables: + * + * 1) Setup RSDP to point to the RSDT and XSDT + * 2) Setup RSDT/XSDT to point to the FADT + * 3) Setup FADT to point to the DSDT and FACS + * 4) Update checksums for all modified tables + * + *****************************************************************************/ + +void +ExInitializeAcpiTables ( + void) +{ + + /* Setup RSDP */ + + Rsdp->RsdtPhysicalAddress = (UINT32) ACPI_TO_INTEGER (RsdtCode); + Rsdp->XsdtPhysicalAddress = (UINT64) ACPI_TO_INTEGER (XsdtCode); + + /* RSDT and XSDT */ + + Rsdt->TableOffsetEntry[0] = (UINT32) ACPI_TO_INTEGER (FadtCode); + Xsdt->TableOffsetEntry[0] = (UINT64) ACPI_TO_INTEGER (FadtCode); + + /* FADT */ + + Fadt->Facs = 0; + Fadt->Dsdt = 0; + Fadt->XFacs = (UINT64) ACPI_TO_INTEGER (FacsCode); + Fadt->XDsdt = (UINT64) ACPI_TO_INTEGER (DsdtCode); + + /* Set new checksums for the modified tables */ + + Rsdp->Checksum = 0; + Rsdp->Checksum = (UINT8) -AcpiTbChecksum ( + (void *) RsdpCode, ACPI_RSDP_CHECKSUM_LENGTH); + + Rsdt->Header.Checksum = 0; + Rsdt->Header.Checksum = (UINT8) -AcpiTbChecksum ( + (void *) Rsdt, Rsdt->Header.Length); + + Xsdt->Header.Checksum = 0; + Xsdt->Header.Checksum = (UINT8) -AcpiTbChecksum ( + (void *) Xsdt, Xsdt->Header.Length); + + Fadt->Header.Checksum = 0; + Fadt->Header.Checksum = (UINT8) -AcpiTbChecksum ( + (void *) Fadt, Fadt->Header.Length); +} + + +/****************************************************************************** + * + * OSL support - return the address of the RSDP + * + *****************************************************************************/ + +ACPI_PHYSICAL_ADDRESS +AeLocalGetRootPointer ( + void) +{ + + return ((ACPI_PHYSICAL_ADDRESS) RsdpCode); +} + + +#ifdef DO_NOT_COMPILE_ACPI_TABLE_CODE +/****************************************************************************** + * + * ACPICA Example table source code + * + * This is the original source code for the tables above + * + *****************************************************************************/ + +/* RSDP */ + +[0008] Signature : "RSD PTR " +[0001] Checksum : 43 +[0006] Oem ID : "INTEL " +[0001] Revision : 02 +[0004] RSDT Address : 00000000 +[0004] Length : 00000024 +[0008] XSDT Address : 0000000000000000 +[0001] Extended Checksum : DC +[0003] Reserved : 000000 + + +/* RSDT */ + +[0004] Signature : "RSDT" [Root System Description Table] +[0004] Table Length : 00000044 +[0001] Revision : 01 +[0001] Checksum : B1 +[0006] Oem ID : "INTEL " +[0008] Oem Table ID : "TEMPLATE" +[0004] Oem Revision : 00000001 +[0004] Asl Compiler ID : "INTL" +[0004] Asl Compiler Revision : 20100528 + +[0004] ACPI Table Address 0 : 00000001 + + +/* XSDT */ + +[0004] Signature : "XSDT" [Extended System Description Table] +[0004] Table Length : 00000064 +[0001] Revision : 01 +[0001] Checksum : 8B +[0006] Oem ID : "INTEL " +[0008] Oem Table ID : "TEMPLATE" +[0004] Oem Revision : 00000001 +[0004] Asl Compiler ID : "INTL" +[0004] Asl Compiler Revision : 20100528 + +[0008] ACPI Table Address 0 : 0000000000000001 + + +/* FADT */ + +[0004] Signature : "FACP" [Fixed ACPI Description Table (FADT)] +[0004] Table Length : 0000010C +[0001] Revision : 05 +[0001] Checksum : 18 +[0006] Oem ID : "INTEL " +[0008] Oem Table ID : "TEMPLATE" +[0004] Oem Revision : 00000000 +[0004] Asl Compiler ID : "INTL" +[0004] Asl Compiler Revision : 20111123 + +[0004] FACS Address : 00000001 +[0004] DSDT Address : 00000001 +[0001] Model : 00 +[0001] PM Profile : 00 [Unspecified] +[0002] SCI Interrupt : 0000 +[0004] SMI Command Port : 00000000 +[0001] ACPI Enable Value : 00 +[0001] ACPI Disable Value : 00 +[0001] S4BIOS Command : 00 +[0001] P-State Control : 00 +[0004] PM1A Event Block Address : 00000001 +[0004] PM1B Event Block Address : 00000000 +[0004] PM1A Control Block Address : 00000001 +[0004] PM1B Control Block Address : 00000000 +[0004] PM2 Control Block Address : 00000001 +[0004] PM Timer Block Address : 00000001 +[0004] GPE0 Block Address : 00000001 +[0004] GPE1 Block Address : 00000000 +[0001] PM1 Event Block Length : 04 +[0001] PM1 Control Block Length : 02 +[0001] PM2 Control Block Length : 01 +[0001] PM Timer Block Length : 04 +[0001] GPE0 Block Length : 08 +[0001] GPE1 Block Length : 00 +[0001] GPE1 Base Offset : 00 +[0001] _CST Support : 00 +[0002] C2 Latency : 0000 +[0002] C3 Latency : 0000 +[0002] CPU Cache Size : 0000 +[0002] Cache Flush Stride : 0000 +[0001] Duty Cycle Offset : 00 +[0001] Duty Cycle Width : 00 +[0001] RTC Day Alarm Index : 00 +[0001] RTC Month Alarm Index : 00 +[0001] RTC Century Index : 00 +[0002] Boot Flags (decoded below) : 0000 + Legacy Devices Supported (V2) : 0 + 8042 Present on ports 60/64 (V2) : 0 + VGA Not Present (V4) : 0 + MSI Not Supported (V4) : 0 + PCIe ASPM Not Supported (V4) : 0 + CMOS RTC Not Present (V5) : 0 +[0001] Reserved : 00 +[0004] Flags (decoded below) : 00000000 + WBINVD instruction is operational (V1) : 0 + WBINVD flushes all caches (V1) : 0 + All CPUs support C1 (V1) : 0 + C2 works on MP system (V1) : 0 + Control Method Power Button (V1) : 0 + Control Method Sleep Button (V1) : 0 + RTC wake not in fixed reg space (V1) : 0 + RTC can wake system from S4 (V1) : 0 + 32-bit PM Timer (V1) : 0 + Docking Supported (V1) : 0 + Reset Register Supported (V2) : 0 + Sealed Case (V3) : 0 + Headless - No Video (V3) : 0 + Use native instr after SLP_TYPx (V3) : 0 + PCIEXP_WAK Bits Supported (V4) : 0 + Use Platform Timer (V4) : 0 + RTC_STS valid on S4 wake (V4) : 0 + Remote Power-on capable (V4) : 0 + Use APIC Cluster Model (V4) : 0 + Use APIC Physical Destination Mode (V4) : 0 + Hardware Reduced (V5) : 0 + Low Power S0 Idle (V5) : 0 + +[0012] Reset Register : [Generic Address Structure] +[0001] Space ID : 01 [SystemIO] +[0001] Bit Width : 08 +[0001] Bit Offset : 00 +[0001] Encoded Access Width : 01 [Byte Access:8] +[0008] Address : 0000000000000001 + +[0001] Value to cause reset : 00 +[0003] Reserved : 000000 +[0008] FACS Address : 0000000000000001 +[0008] DSDT Address : 0000000000000001 +[0012] PM1A Event Block : [Generic Address Structure] +[0001] Space ID : 01 [SystemIO] +[0001] Bit Width : 20 +[0001] Bit Offset : 00 +[0001] Encoded Access Width : 02 [Word Access:16] +[0008] Address : 0000000000000001 + +[0012] PM1B Event Block : [Generic Address Structure] +[0001] Space ID : 01 [SystemIO] +[0001] Bit Width : 00 +[0001] Bit Offset : 00 +[0001] Encoded Access Width : 00 [Undefined/Legacy] +[0008] Address : 0000000000000000 + +[0012] PM1A Control Block : [Generic Address Structure] +[0001] Space ID : 01 [SystemIO] +[0001] Bit Width : 10 +[0001] Bit Offset : 00 +[0001] Encoded Access Width : 02 [Word Access:16] +[0008] Address : 0000000000000001 + +[0012] PM1B Control Block : [Generic Address Structure] +[0001] Space ID : 01 [SystemIO] +[0001] Bit Width : 00 +[0001] Bit Offset : 00 +[0001] Encoded Access Width : 00 [Undefined/Legacy] +[0008] Address : 0000000000000000 + +[0012] PM2 Control Block : [Generic Address Structure] +[0001] Space ID : 01 [SystemIO] +[0001] Bit Width : 08 +[0001] Bit Offset : 00 +[0001] Encoded Access Width : 00 [Undefined/Legacy] +[0008] Address : 0000000000000001 + +[0012] PM Timer Block : [Generic Address Structure] +[0001] Space ID : 01 [SystemIO] +[0001] Bit Width : 20 +[0001] Bit Offset : 00 +[0001] Encoded Access Width : 03 [DWord Access:32] +[0008] Address : 0000000000000001 + +[0012] GPE0 Block : [Generic Address Structure] +[0001] Space ID : 01 [SystemIO] +[0001] Bit Width : 40 +[0001] Bit Offset : 00 +[0001] Encoded Access Width : 01 [Byte Access:8] +[0008] Address : 0000000000000001 + +[0012] GPE1 Block : [Generic Address Structure] +[0001] Space ID : 01 [SystemIO] +[0001] Bit Width : 00 +[0001] Bit Offset : 00 +[0001] Encoded Access Width : 00 [Undefined/Legacy] +[0008] Address : 0000000000000000 + + +[0012] Sleep Control Register : [Generic Address Structure] +[0001] Space ID : 01 [SystemIO] +[0001] Bit Width : 08 +[0001] Bit Offset : 00 +[0001] Encoded Access Width : 01 [Byte Access:8] +[0008] Address : 0000000000000000 + +[0012] Sleep Status Register : [Generic Address Structure] +[0001] Space ID : 01 [SystemIO] +[0001] Bit Width : 08 +[0001] Bit Offset : 00 +[0001] Encoded Access Width : 01 [Byte Access:8] +[0008] Address : 0000000000000000 + + +/* FACS */ + +[0004] Signature : "FACS" +[0004] Length : 00000040 +[0004] Hardware Signature : 00000000 +[0004] 32 Firmware Waking Vector : 00000000 +[0004] Global Lock : 00000000 +[0004] Flags (decoded below) : 00000000 + S4BIOS Support Present : 0 + 64-bit Wake Supported (V2) : 0 +[0008] 64 Firmware Waking Vector : 0000000000000000 +[0001] Version : 02 +[0003] Reserved : 000000 +[0004] OspmFlags (decoded below) : 00000000 + 64-bit Wake Env Required (V2) : 0 + + +/* DSDT - ASL code */ + +DefinitionBlock ("dsdt.aml", "DSDT", 2, "Intel", "Template", 0x00000001) +{ + Method (MAIN, 1, NotSerialized) + { + Store (Concatenate ("Main/Arg0: ", Arg0), Debug) + Return ("Main successfully completed execution") + } +} +#endif |