diff options
Diffstat (limited to 'sys/contrib/dev/acpica/components/namespace')
22 files changed, 953 insertions, 513 deletions
diff --git a/sys/contrib/dev/acpica/components/namespace/nsaccess.c b/sys/contrib/dev/acpica/components/namespace/nsaccess.c index 667b5af..bf32269 100644 --- a/sys/contrib/dev/acpica/components/namespace/nsaccess.c +++ b/sys/contrib/dev/acpica/components/namespace/nsaccess.c @@ -5,7 +5,7 @@ ******************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -111,14 +111,14 @@ AcpiNsRootInitialize ( { /* _OSI is optional for now, will be permanent later */ - if (!ACPI_STRCMP (InitVal->Name, "_OSI") && !AcpiGbl_CreateOsiMethod) + if (!strcmp (InitVal->Name, "_OSI") && !AcpiGbl_CreateOsiMethod) { continue; } - Status = AcpiNsLookup (NULL, InitVal->Name, InitVal->Type, - ACPI_IMODE_LOAD_PASS2, ACPI_NS_NO_UPSEARCH, - NULL, &NewNode); + Status = AcpiNsLookup (NULL, ACPI_CAST_PTR (char, InitVal->Name), + InitVal->Type, ACPI_IMODE_LOAD_PASS2, ACPI_NS_NO_UPSEARCH, + NULL, &NewNode); if (ACPI_FAILURE (Status)) { ACPI_EXCEPTION ((AE_INFO, Status, @@ -191,7 +191,7 @@ AcpiNsRootInitialize ( /* Build an object around the static string */ - ObjDesc->String.Length = (UINT32) ACPI_STRLEN (Val); + ObjDesc->String.Length = (UINT32) strlen (Val); ObjDesc->String.Pointer = Val; ObjDesc->Common.Flags |= AOPOBJ_STATIC_POINTER; break; @@ -212,14 +212,14 @@ AcpiNsRootInitialize ( /* Special case for ACPI Global Lock */ - if (ACPI_STRCMP (InitVal->Name, "_GL_") == 0) + if (strcmp (InitVal->Name, "_GL_") == 0) { AcpiGbl_GlobalLockMutex = ObjDesc; /* Create additional counting semaphore for global lock */ Status = AcpiOsCreateSemaphore ( - 1, 0, &AcpiGbl_GlobalLockSemaphore); + 1, 0, &AcpiGbl_GlobalLockSemaphore); if (ACPI_FAILURE (Status)) { AcpiUtRemoveReference (ObjDesc); @@ -240,7 +240,7 @@ AcpiNsRootInitialize ( /* Store pointer to value descriptor in the Node */ Status = AcpiNsAttachObject (NewNode, ObjDesc, - ObjDesc->Common.Type); + ObjDesc->Common.Type); /* Remove local reference to the object */ @@ -257,7 +257,7 @@ UnlockAndExit: if (ACPI_SUCCESS (Status)) { Status = AcpiNsGetNode (NULL, "\\_GPE", ACPI_NS_NO_UPSEARCH, - &AcpiGbl_FadtGpeDevice); + &AcpiGbl_FadtGpeDevice); } return_ACPI_STATUS (Status); @@ -319,7 +319,9 @@ AcpiNsLookup ( return_ACPI_STATUS (AE_BAD_PARAMETER); } - LocalFlags = Flags & ~(ACPI_NS_ERROR_IF_FOUND | ACPI_NS_SEARCH_PARENT); + LocalFlags = Flags & + ~(ACPI_NS_ERROR_IF_FOUND | ACPI_NS_OVERRIDE_IF_FOUND | + ACPI_NS_SEARCH_PARENT); *ReturnNode = ACPI_ENTRY_NOT_FOUND; AcpiGbl_NsLookupCount++; @@ -571,6 +573,13 @@ AcpiNsLookup ( { LocalFlags |= ACPI_NS_ERROR_IF_FOUND; } + + /* Set override flag according to caller */ + + if (Flags & ACPI_NS_OVERRIDE_IF_FOUND) + { + LocalFlags |= ACPI_NS_OVERRIDE_IF_FOUND; + } } /* Extract one ACPI name from the front of the pathname */ @@ -580,7 +589,7 @@ AcpiNsLookup ( /* Try to find the single (4 character) ACPI name */ Status = AcpiNsSearchAndEnter (SimpleName, WalkState, CurrentNode, - InterpreterMode, ThisSearchType, LocalFlags, &ThisNode); + InterpreterMode, ThisSearchType, LocalFlags, &ThisNode); if (ACPI_FAILURE (Status)) { if (Status == AE_NOT_FOUND) diff --git a/sys/contrib/dev/acpica/components/namespace/nsalloc.c b/sys/contrib/dev/acpica/components/namespace/nsalloc.c index 2a1e09e..c85593d 100644 --- a/sys/contrib/dev/acpica/components/namespace/nsalloc.c +++ b/sys/contrib/dev/acpica/components/namespace/nsalloc.c @@ -5,7 +5,7 @@ ******************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -85,7 +85,7 @@ AcpiNsCreateNode ( #ifdef ACPI_DBG_TRACK_ALLOCATIONS Temp = AcpiGbl_NsNodeList->TotalAllocated - - AcpiGbl_NsNodeList->TotalFreed; + AcpiGbl_NsNodeList->TotalFreed; if (Temp > AcpiGbl_NsNodeList->MaxOccupied) { AcpiGbl_NsNodeList->MaxOccupied = Temp; @@ -277,7 +277,8 @@ AcpiNsInstallNode ( * modified the namespace. This is used for cleanup when the * method exits. */ - WalkState->MethodDesc->Method.InfoFlags |= ACPI_METHOD_MODIFIED_NAMESPACE; + WalkState->MethodDesc->Method.InfoFlags |= + ACPI_METHOD_MODIFIED_NAMESPACE; } } diff --git a/sys/contrib/dev/acpica/components/namespace/nsarguments.c b/sys/contrib/dev/acpica/components/namespace/nsarguments.c index 5d41bb0..46d6eb91b 100644 --- a/sys/contrib/dev/acpica/components/namespace/nsarguments.c +++ b/sys/contrib/dev/acpica/components/namespace/nsarguments.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -137,7 +137,8 @@ AcpiNsCheckAcpiCompliance ( /* Get the ACPI-required arg count from the predefined info table */ - RequiredParamCount = METHOD_GET_ARG_COUNT (Predefined->Info.ArgumentList); + RequiredParamCount = + METHOD_GET_ARG_COUNT (Predefined->Info.ArgumentList); /* * If this object is not a control method, we can check if the ACPI @@ -283,7 +284,8 @@ AcpiNsCheckArgumentCount ( * Some methods are allowed to have a "minimum" number of args (_SCP) * because their definition in ACPI has changed over time. */ - RequiredParamCount = METHOD_GET_ARG_COUNT (Predefined->Info.ArgumentList); + RequiredParamCount = + METHOD_GET_ARG_COUNT (Predefined->Info.ArgumentList); if (UserParamCount < RequiredParamCount) { diff --git a/sys/contrib/dev/acpica/components/namespace/nsconvert.c b/sys/contrib/dev/acpica/components/namespace/nsconvert.c index 091c5cc..441710b 100644 --- a/sys/contrib/dev/acpica/components/namespace/nsconvert.c +++ b/sys/contrib/dev/acpica/components/namespace/nsconvert.c @@ -6,7 +6,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -84,7 +84,7 @@ AcpiNsConvertToInteger ( /* String-to-Integer conversion */ Status = AcpiUtStrtoul64 (OriginalObject->String.Pointer, - ACPI_ANY_BASE, &Value); + ACPI_ANY_BASE, AcpiGbl_IntegerByteWidth, &Value); if (ACPI_FAILURE (Status)) { return (Status); @@ -104,7 +104,8 @@ AcpiNsConvertToInteger ( for (i = 0; i < OriginalObject->Buffer.Length; i++) { - Value |= ((UINT64) OriginalObject->Buffer.Pointer[i] << (i * 8)); + Value |= ((UINT64) + OriginalObject->Buffer.Pointer[i] << (i * 8)); } break; @@ -167,8 +168,8 @@ AcpiNsConvertToString ( } else { - Status = AcpiExConvertToString (OriginalObject, &NewObject, - ACPI_IMPLICIT_CONVERT_HEX); + Status = AcpiExConvertToString (OriginalObject, + &NewObject, ACPI_IMPLICIT_CONVERT_HEX); if (ACPI_FAILURE (Status)) { return (Status); @@ -202,7 +203,7 @@ AcpiNsConvertToString ( * Copy the raw buffer data with no transform. String is already NULL * terminated at Length+1. */ - ACPI_MEMCPY (NewObject->String.Pointer, + memcpy (NewObject->String.Pointer, OriginalObject->Buffer.Pointer, Length); break; @@ -263,13 +264,14 @@ AcpiNsConvertToBuffer ( /* String-to-Buffer conversion. Simple data copy */ - NewObject = AcpiUtCreateBufferObject (OriginalObject->String.Length); + NewObject = AcpiUtCreateBufferObject + (OriginalObject->String.Length); if (!NewObject) { return (AE_NO_MEMORY); } - ACPI_MEMCPY (NewObject->Buffer.Pointer, + memcpy (NewObject->Buffer.Pointer, OriginalObject->String.Pointer, OriginalObject->String.Length); break; @@ -330,7 +332,8 @@ AcpiNsConvertToBuffer ( * * FUNCTION: AcpiNsConvertToUnicode * - * PARAMETERS: OriginalObject - ASCII String Object to be converted + * PARAMETERS: Scope - Namespace node for the method/object + * OriginalObject - ASCII String Object to be converted * ReturnObject - Where the new converted object is returned * * RETURN: Status. AE_OK if conversion was successful. @@ -341,6 +344,7 @@ AcpiNsConvertToBuffer ( ACPI_STATUS AcpiNsConvertToUnicode ( + ACPI_NAMESPACE_NODE *Scope, ACPI_OPERAND_OBJECT *OriginalObject, ACPI_OPERAND_OBJECT **ReturnObject) { @@ -402,7 +406,8 @@ AcpiNsConvertToUnicode ( * * FUNCTION: AcpiNsConvertToResource * - * PARAMETERS: OriginalObject - Object to be converted + * PARAMETERS: Scope - Namespace node for the method/object + * OriginalObject - Object to be converted * ReturnObject - Where the new converted object is returned * * RETURN: Status. AE_OK if conversion was successful @@ -414,6 +419,7 @@ AcpiNsConvertToUnicode ( ACPI_STATUS AcpiNsConvertToResource ( + ACPI_NAMESPACE_NODE *Scope, ACPI_OPERAND_OBJECT *OriginalObject, ACPI_OPERAND_OBJECT **ReturnObject) { @@ -480,3 +486,81 @@ AcpiNsConvertToResource ( *ReturnObject = NewObject; return (AE_OK); } + + +/******************************************************************************* + * + * FUNCTION: AcpiNsConvertToReference + * + * PARAMETERS: Scope - Namespace node for the method/object + * OriginalObject - Object to be converted + * ReturnObject - Where the new converted object is returned + * + * RETURN: Status. AE_OK if conversion was successful + * + * DESCRIPTION: Attempt to convert a Integer object to a ObjectReference. + * Buffer. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiNsConvertToReference ( + ACPI_NAMESPACE_NODE *Scope, + ACPI_OPERAND_OBJECT *OriginalObject, + ACPI_OPERAND_OBJECT **ReturnObject) +{ + ACPI_OPERAND_OBJECT *NewObject = NULL; + ACPI_STATUS Status; + ACPI_NAMESPACE_NODE *Node; + ACPI_GENERIC_STATE ScopeInfo; + char *Name; + + + ACPI_FUNCTION_NAME (NsConvertToReference); + + + /* Convert path into internal presentation */ + + Status = AcpiNsInternalizeName (OriginalObject->String.Pointer, &Name); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* Find the namespace node */ + + ScopeInfo.Scope.Node = ACPI_CAST_PTR (ACPI_NAMESPACE_NODE, Scope); + Status = AcpiNsLookup (&ScopeInfo, Name, + ACPI_TYPE_ANY, ACPI_IMODE_EXECUTE, + ACPI_NS_SEARCH_PARENT | ACPI_NS_DONT_OPEN_SCOPE, NULL, &Node); + if (ACPI_FAILURE (Status)) + { + /* Check if we are resolving a named reference within a package */ + + ACPI_ERROR_NAMESPACE (OriginalObject->String.Pointer, Status); + goto ErrorExit; + } + + /* Create and init a new internal ACPI object */ + + NewObject = AcpiUtCreateInternalObject (ACPI_TYPE_LOCAL_REFERENCE); + if (!NewObject) + { + Status = AE_NO_MEMORY; + goto ErrorExit; + } + NewObject->Reference.Node = Node; + NewObject->Reference.Object = Node->Object; + NewObject->Reference.Class = ACPI_REFCLASS_NAME; + + /* + * Increase reference of the object if needed (the object is likely a + * null for device nodes). + */ + AcpiUtAddReference (Node->Object); + +ErrorExit: + ACPI_FREE (Name); + *ReturnObject = NewObject; + return (AE_OK); +} diff --git a/sys/contrib/dev/acpica/components/namespace/nsdump.c b/sys/contrib/dev/acpica/components/namespace/nsdump.c index 77fb279..d34ff11 100644 --- a/sys/contrib/dev/acpica/components/namespace/nsdump.c +++ b/sys/contrib/dev/acpica/components/namespace/nsdump.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -99,7 +99,7 @@ AcpiNsGetMaxDepth ( void AcpiNsPrintPathname ( UINT32 NumSegments, - char *Pathname) + const char *Pathname) { UINT32 i; @@ -122,7 +122,7 @@ AcpiNsPrintPathname ( { for (i = 0; i < 4; i++) { - ACPI_IS_PRINT (Pathname[i]) ? + isprint ((int) Pathname[i]) ? AcpiOsPrintf ("%c", Pathname[i]) : AcpiOsPrintf ("?"); } @@ -139,6 +139,9 @@ AcpiNsPrintPathname ( } +#ifdef ACPI_OBSOLETE_FUNCTIONS +/* Not used at this time, perhaps later */ + /******************************************************************************* * * FUNCTION: AcpiNsDumpPathname @@ -158,7 +161,7 @@ AcpiNsPrintPathname ( void AcpiNsDumpPathname ( ACPI_HANDLE Handle, - char *Msg, + const char *Msg, UINT32 Level, UINT32 Component) { @@ -179,7 +182,7 @@ AcpiNsDumpPathname ( AcpiOsPrintf ("\n"); return_VOID; } - +#endif /******************************************************************************* * @@ -258,7 +261,8 @@ AcpiNsDumpOneObject ( if (Type > ACPI_TYPE_LOCAL_MAX) { - ACPI_WARNING ((AE_INFO, "Invalid ACPI Object Type 0x%08X", Type)); + ACPI_WARNING ((AE_INFO, + "Invalid ACPI Object Type 0x%08X", Type)); } AcpiOsPrintf ("%4.4s", AcpiUtGetNodeName (ThisNode)); @@ -267,7 +271,7 @@ AcpiNsDumpOneObject ( /* Now we can print out the pertinent information */ AcpiOsPrintf (" %-12s %p %2.2X ", - AcpiUtGetTypeName (Type), ThisNode, ThisNode->OwnerId); + AcpiUtGetTypeName (Type), ThisNode, ThisNode->OwnerId); DbgLevel = AcpiDbgLevel; AcpiDbgLevel = 0; @@ -354,7 +358,7 @@ AcpiNsDumpOneObject ( if (ObjDesc->Common.Flags & AOPOBJ_DATA_VALID) { AcpiOsPrintf ("Len %.2X", - ObjDesc->Buffer.Length); + ObjDesc->Buffer.Length); /* Dump some of the buffer */ @@ -377,7 +381,7 @@ AcpiNsDumpOneObject ( case ACPI_TYPE_STRING: AcpiOsPrintf ("Len %.2X ", ObjDesc->String.Length); - AcpiUtPrintString (ObjDesc->String.Pointer, 32); + AcpiUtPrintString (ObjDesc->String.Pointer, 80); AcpiOsPrintf ("\n"); break; @@ -535,9 +539,9 @@ AcpiNsDumpOneObject ( /* If there is an attached object, display it */ - DbgLevel = AcpiDbgLevel; + DbgLevel = AcpiDbgLevel; AcpiDbgLevel = 0; - ObjDesc = AcpiNsGetAttachedObject (ThisNode); + ObjDesc = AcpiNsGetAttachedObject (ThisNode); AcpiDbgLevel = DbgLevel; /* Dump attached objects */ @@ -564,14 +568,18 @@ AcpiNsDumpOneObject ( if (ObjType > ACPI_TYPE_LOCAL_MAX) { - AcpiOsPrintf ("(Pointer to ACPI Object type %.2X [UNKNOWN])\n", + AcpiOsPrintf ( + "(Pointer to ACPI Object type %.2X [UNKNOWN])\n", ObjType); + BytesToDump = 32; } else { - AcpiOsPrintf ("(Pointer to ACPI Object type %.2X [%s])\n", + AcpiOsPrintf ( + "(Pointer to ACPI Object type %.2X [%s])\n", ObjType, AcpiUtGetTypeName (ObjType)); + BytesToDump = sizeof (ACPI_OPERAND_OBJECT); } @@ -601,7 +609,8 @@ AcpiNsDumpOneObject ( */ BytesToDump = ObjDesc->String.Length; ObjDesc = (void *) ObjDesc->String.Pointer; - AcpiOsPrintf ( "(Buffer/String pointer %p length %X)\n", + + AcpiOsPrintf ("(Buffer/String pointer %p length %X)\n", ObjDesc, BytesToDump); ACPI_DUMP_BUFFER (ObjDesc, BytesToDump); goto Cleanup; @@ -702,8 +711,8 @@ AcpiNsDumpObjects ( Info.DisplayType = DisplayType; (void) AcpiNsWalkNamespace (Type, StartHandle, MaxDepth, - ACPI_NS_WALK_NO_UNLOCK | ACPI_NS_WALK_TEMP_NODES, - AcpiNsDumpOneObject, NULL, (void *) &Info, NULL); + ACPI_NS_WALK_NO_UNLOCK | ACPI_NS_WALK_TEMP_NODES, + AcpiNsDumpOneObject, NULL, (void *) &Info, NULL); (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); } @@ -753,7 +762,7 @@ AcpiNsDumpOneObjectPath ( return (AE_OK); } - Pathname = AcpiNsGetExternalPathname (Node); + Pathname = AcpiNsGetNormalizedPathname (Node, TRUE); PathIndent = 1; if (Level <= MaxLevel) @@ -839,14 +848,14 @@ AcpiNsDumpObjectPaths ( /* Get the max depth of the namespace tree, for formatting later */ (void) AcpiNsWalkNamespace (Type, StartHandle, MaxDepth, - ACPI_NS_WALK_NO_UNLOCK | ACPI_NS_WALK_TEMP_NODES, - AcpiNsGetMaxDepth, NULL, (void *) &MaxLevel, NULL); + ACPI_NS_WALK_NO_UNLOCK | ACPI_NS_WALK_TEMP_NODES, + AcpiNsGetMaxDepth, NULL, (void *) &MaxLevel, NULL); /* Now dump the entire namespace */ (void) AcpiNsWalkNamespace (Type, StartHandle, MaxDepth, - ACPI_NS_WALK_NO_UNLOCK | ACPI_NS_WALK_TEMP_NODES, - AcpiNsDumpOneObjectPath, NULL, (void *) &MaxLevel, NULL); + ACPI_NS_WALK_NO_UNLOCK | ACPI_NS_WALK_TEMP_NODES, + AcpiNsDumpOneObjectPath, NULL, (void *) &MaxLevel, NULL); (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); } @@ -917,7 +926,8 @@ AcpiNsDumpTables ( * If the name space has not been initialized, * there is nothing to dump. */ - ACPI_DEBUG_PRINT ((ACPI_DB_TABLES, "namespace not initialized!\n")); + ACPI_DEBUG_PRINT ((ACPI_DB_TABLES, + "namespace not initialized!\n")); return_VOID; } @@ -930,7 +940,7 @@ AcpiNsDumpTables ( } AcpiNsDumpObjects (ACPI_TYPE_ANY, ACPI_DISPLAY_OBJECTS, MaxDepth, - ACPI_OWNER_ID_MAX, SearchHandle); + ACPI_OWNER_ID_MAX, SearchHandle); return_VOID; } #endif diff --git a/sys/contrib/dev/acpica/components/namespace/nsdumpdv.c b/sys/contrib/dev/acpica/components/namespace/nsdumpdv.c index 05daaab..8adb76a 100644 --- a/sys/contrib/dev/acpica/components/namespace/nsdumpdv.c +++ b/sys/contrib/dev/acpica/components/namespace/nsdumpdv.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -149,8 +149,8 @@ AcpiNsDumpRootDevices ( "Display of all devices in the namespace:\n")); Status = AcpiNsWalkNamespace (ACPI_TYPE_DEVICE, SysBusHandle, - ACPI_UINT32_MAX, ACPI_NS_WALK_NO_UNLOCK, - AcpiNsDumpOneDevice, NULL, NULL, NULL); + ACPI_UINT32_MAX, ACPI_NS_WALK_NO_UNLOCK, + AcpiNsDumpOneDevice, NULL, NULL, NULL); } #endif diff --git a/sys/contrib/dev/acpica/components/namespace/nseval.c b/sys/contrib/dev/acpica/components/namespace/nseval.c index ac1d9a9..ea1cceb 100644 --- a/sys/contrib/dev/acpica/components/namespace/nseval.c +++ b/sys/contrib/dev/acpica/components/namespace/nseval.c @@ -5,7 +5,7 @@ ******************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -63,15 +63,14 @@ AcpiNsExecModuleCode ( * * FUNCTION: AcpiNsEvaluate * - * PARAMETERS: Info - Evaluation info block, contains: + * PARAMETERS: Info - Evaluation info block, contains these fields + * and more: * PrefixNode - Prefix or Method/Object Node to execute * RelativePath - Name of method to execute, If NULL, the * Node is the object to execute * Parameters - List of parameters to pass to the method, * terminated by NULL. Params itself may be * NULL if no parameters are being passed. - * ReturnObject - Where to put method's return value (if - * any). If NULL, no value is returned. * ParameterType - Type of Parameter list * ReturnObject - Where to put method's return value (if * any). If NULL, no value is returned. @@ -145,7 +144,7 @@ AcpiNsEvaluate ( /* Get the full pathname to the object, for use in warning messages */ - Info->FullPathname = AcpiNsGetExternalPathname (Info->Node); + Info->FullPathname = AcpiNsGetNormalizedPathname (Info->Node, TRUE); if (!Info->FullPathname) { return_ACPI_STATUS (AE_NO_MEMORY); @@ -285,6 +284,7 @@ AcpiNsEvaluate ( if (ACPI_FAILURE (Status)) { + Info->ReturnObject = NULL; goto Cleanup; } @@ -396,7 +396,7 @@ AcpiNsExecModuleCodeList ( AcpiUtRemoveReference (Prev); } - ACPI_INFO ((AE_INFO, + ACPI_INFO (( "Executed %u blocks of module-level executable AML code", MethodCount)); @@ -440,8 +440,8 @@ AcpiNsExecModuleCode ( * Get the parent node. We cheat by using the NextObject field * of the method object descriptor. */ - ParentNode = ACPI_CAST_PTR (ACPI_NAMESPACE_NODE, - MethodObj->Method.NextObject); + ParentNode = ACPI_CAST_PTR ( + ACPI_NAMESPACE_NODE, MethodObj->Method.NextObject); Type = AcpiNsGetType (ParentNode); /* @@ -463,13 +463,13 @@ AcpiNsExecModuleCode ( /* Initialize the evaluation information block */ - ACPI_MEMSET (Info, 0, sizeof (ACPI_EVALUATE_INFO)); + memset (Info, 0, sizeof (ACPI_EVALUATE_INFO)); Info->PrefixNode = ParentNode; /* - * Get the currently attached parent object. Add a reference, because the - * ref count will be decreased when the method object is installed to - * the parent node. + * Get the currently attached parent object. Add a reference, + * because the ref count will be decreased when the method object + * is installed to the parent node. */ ParentObj = AcpiNsGetAttachedObject (ParentNode); if (ParentObj) @@ -479,8 +479,7 @@ AcpiNsExecModuleCode ( /* Install the method (module-level code) in the parent node */ - Status = AcpiNsAttachObject (ParentNode, MethodObj, - ACPI_TYPE_METHOD); + Status = AcpiNsAttachObject (ParentNode, MethodObj, ACPI_TYPE_METHOD); if (ACPI_FAILURE (Status)) { goto Exit; @@ -490,7 +489,8 @@ AcpiNsExecModuleCode ( Status = AcpiNsEvaluate (Info); - ACPI_DEBUG_PRINT ((ACPI_DB_INIT, "Executed module-level code at %p\n", + ACPI_DEBUG_PRINT ((ACPI_DB_INIT_NAMES, + "Executed module-level code at %p\n", MethodObj->Method.AmlStart)); /* Delete a possible implicit return value (in slack mode) */ diff --git a/sys/contrib/dev/acpica/components/namespace/nsinit.c b/sys/contrib/dev/acpica/components/namespace/nsinit.c index 847bf72..a208469 100644 --- a/sys/contrib/dev/acpica/components/namespace/nsinit.c +++ b/sys/contrib/dev/acpica/components/namespace/nsinit.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -46,6 +46,7 @@ #include <contrib/dev/acpica/include/acnamesp.h> #include <contrib/dev/acpica/include/acdispat.h> #include <contrib/dev/acpica/include/acinterp.h> +#include <contrib/dev/acpica/include/acevents.h> #define _COMPONENT ACPI_NAMESPACE ACPI_MODULE_NAME ("nsinit") @@ -98,6 +99,8 @@ AcpiNsInitializeObjects ( ACPI_FUNCTION_TRACE (NsInitializeObjects); + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, + "[Init] Completing Initialization of ACPI Objects\n")); ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "**** Starting initialization of namespace objects ****\n")); ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INIT, @@ -105,13 +108,13 @@ AcpiNsInitializeObjects ( /* Set all init info to zero */ - ACPI_MEMSET (&Info, 0, sizeof (ACPI_INIT_WALK_INFO)); + memset (&Info, 0, sizeof (ACPI_INIT_WALK_INFO)); /* Walk entire namespace from the supplied root */ Status = AcpiWalkNamespace (ACPI_TYPE_ANY, ACPI_ROOT_OBJECT, - ACPI_UINT32_MAX, AcpiNsInitOneObject, NULL, - &Info, NULL); + ACPI_UINT32_MAX, AcpiNsInitOneObject, NULL, + &Info, NULL); if (ACPI_FAILURE (Status)) { ACPI_EXCEPTION ((AE_INFO, Status, "During WalkNamespace")); @@ -151,84 +154,140 @@ AcpiNsInitializeObjects ( ACPI_STATUS AcpiNsInitializeDevices ( - void) + UINT32 Flags) { - ACPI_STATUS Status; + ACPI_STATUS Status = AE_OK; ACPI_DEVICE_WALK_INFO Info; + ACPI_HANDLE Handle; ACPI_FUNCTION_TRACE (NsInitializeDevices); - /* Init counters */ + if (!(Flags & ACPI_NO_DEVICE_INIT)) + { + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, + "[Init] Initializing ACPI Devices\n")); - Info.DeviceCount = 0; - Info.Num_STA = 0; - Info.Num_INI = 0; + /* Init counters */ - ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INIT, - "Initializing Device/Processor/Thermal objects " - "and executing _INI/_STA methods:\n")); + Info.DeviceCount = 0; + Info.Num_STA = 0; + Info.Num_INI = 0; - /* Tree analysis: find all subtrees that contain _INI methods */ + ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INIT, + "Initializing Device/Processor/Thermal objects " + "and executing _INI/_STA methods:\n")); - Status = AcpiNsWalkNamespace (ACPI_TYPE_ANY, ACPI_ROOT_OBJECT, - ACPI_UINT32_MAX, FALSE, AcpiNsFindIniMethods, NULL, &Info, NULL); - if (ACPI_FAILURE (Status)) - { - goto ErrorExit; - } - - /* Allocate the evaluation information block */ + /* Tree analysis: find all subtrees that contain _INI methods */ - Info.EvaluateInfo = ACPI_ALLOCATE_ZEROED (sizeof (ACPI_EVALUATE_INFO)); - if (!Info.EvaluateInfo) - { - Status = AE_NO_MEMORY; - goto ErrorExit; - } + Status = AcpiNsWalkNamespace (ACPI_TYPE_ANY, ACPI_ROOT_OBJECT, + ACPI_UINT32_MAX, FALSE, AcpiNsFindIniMethods, NULL, &Info, NULL); + if (ACPI_FAILURE (Status)) + { + goto ErrorExit; + } - /* - * Execute the "global" _INI method that may appear at the root. This - * support is provided for Windows compatibility (Vista+) and is not - * part of the ACPI specification. - */ - Info.EvaluateInfo->PrefixNode = AcpiGbl_RootNode; - Info.EvaluateInfo->RelativePathname = METHOD_NAME__INI; - Info.EvaluateInfo->Parameters = NULL; - Info.EvaluateInfo->Flags = ACPI_IGNORE_RETURN_VALUE; + /* Allocate the evaluation information block */ - Status = AcpiNsEvaluate (Info.EvaluateInfo); - if (ACPI_SUCCESS (Status)) - { - Info.Num_INI++; - } + Info.EvaluateInfo = ACPI_ALLOCATE_ZEROED (sizeof (ACPI_EVALUATE_INFO)); + if (!Info.EvaluateInfo) + { + Status = AE_NO_MEMORY; + goto ErrorExit; + } - /* Walk namespace to execute all _INIs on present devices */ + /* + * Execute the "global" _INI method that may appear at the root. + * This support is provided for Windows compatibility (Vista+) and + * is not part of the ACPI specification. + */ + Info.EvaluateInfo->PrefixNode = AcpiGbl_RootNode; + Info.EvaluateInfo->RelativePathname = METHOD_NAME__INI; + Info.EvaluateInfo->Parameters = NULL; + Info.EvaluateInfo->Flags = ACPI_IGNORE_RETURN_VALUE; + + Status = AcpiNsEvaluate (Info.EvaluateInfo); + if (ACPI_SUCCESS (Status)) + { + Info.Num_INI++; + } - Status = AcpiNsWalkNamespace (ACPI_TYPE_ANY, ACPI_ROOT_OBJECT, - ACPI_UINT32_MAX, FALSE, AcpiNsInitOneDevice, NULL, &Info, NULL); + /* + * Execute \_SB._INI. + * There appears to be a strict order requirement for \_SB._INI, + * which should be evaluated before any _REG evaluations. + */ + Status = AcpiGetHandle (NULL, "\\_SB", &Handle); + if (ACPI_SUCCESS (Status)) + { + memset (Info.EvaluateInfo, 0, sizeof (ACPI_EVALUATE_INFO)); + Info.EvaluateInfo->PrefixNode = Handle; + Info.EvaluateInfo->RelativePathname = METHOD_NAME__INI; + Info.EvaluateInfo->Parameters = NULL; + Info.EvaluateInfo->Flags = ACPI_IGNORE_RETURN_VALUE; + + Status = AcpiNsEvaluate (Info.EvaluateInfo); + if (ACPI_SUCCESS (Status)) + { + Info.Num_INI++; + } + } + } /* - * Any _OSI requests should be completed by now. If the BIOS has - * requested any Windows OSI strings, we will always truncate - * I/O addresses to 16 bits -- for Windows compatibility. + * Run all _REG methods + * + * Note: Any objects accessed by the _REG methods will be automatically + * initialized, even if they contain executable AML (see the call to + * AcpiNsInitializeObjects below). + * + * Note: According to the ACPI specification, we actually needn't execute + * _REG for SystemMemory/SystemIo operation regions, but for PCI_Config + * operation regions, it is required to evaluate _REG for those on a PCI + * root bus that doesn't contain _BBN object. So this code is kept here + * in order not to break things. */ - if (AcpiGbl_OsiData >= ACPI_OSI_WIN_2000) + if (!(Flags & ACPI_NO_ADDRESS_SPACE_INIT)) { - AcpiGbl_TruncateIoAddresses = TRUE; + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, + "[Init] Executing _REG OpRegion methods\n")); + + Status = AcpiEvInitializeOpRegions (); + if (ACPI_FAILURE (Status)) + { + goto ErrorExit; + } } - ACPI_FREE (Info.EvaluateInfo); - if (ACPI_FAILURE (Status)) + if (!(Flags & ACPI_NO_DEVICE_INIT)) { - goto ErrorExit; - } + /* Walk namespace to execute all _INIs on present devices */ - ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INIT, - " Executed %u _INI methods requiring %u _STA executions " - "(examined %u objects)\n", - Info.Num_INI, Info.Num_STA, Info.DeviceCount)); + Status = AcpiNsWalkNamespace (ACPI_TYPE_ANY, ACPI_ROOT_OBJECT, + ACPI_UINT32_MAX, FALSE, AcpiNsInitOneDevice, NULL, &Info, NULL); + + /* + * Any _OSI requests should be completed by now. If the BIOS has + * requested any Windows OSI strings, we will always truncate + * I/O addresses to 16 bits -- for Windows compatibility. + */ + if (AcpiGbl_OsiData >= ACPI_OSI_WIN_2000) + { + AcpiGbl_TruncateIoAddresses = TRUE; + } + + ACPI_FREE (Info.EvaluateInfo); + if (ACPI_FAILURE (Status)) + { + goto ErrorExit; + } + + ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INIT, + " Executed %u _INI methods requiring %u _STA executions " + "(examined %u objects)\n", + Info.Num_INI, Info.Num_STA, Info.DeviceCount)); + } return_ACPI_STATUS (Status); @@ -611,33 +670,37 @@ AcpiNsInitOneDevice ( * Note: We know there is an _INI within this subtree, but it may not be * under this particular device, it may be lower in the branch. */ - ACPI_DEBUG_EXEC (AcpiUtDisplayInitPathname ( - ACPI_TYPE_METHOD, DeviceNode, METHOD_NAME__INI)); + if (!ACPI_COMPARE_NAME (DeviceNode->Name.Ascii, "_SB_") || + DeviceNode->Parent != AcpiGbl_RootNode) + { + ACPI_DEBUG_EXEC (AcpiUtDisplayInitPathname ( + ACPI_TYPE_METHOD, DeviceNode, METHOD_NAME__INI)); - ACPI_MEMSET (Info, 0, sizeof (ACPI_EVALUATE_INFO)); - Info->PrefixNode = DeviceNode; - Info->RelativePathname = METHOD_NAME__INI; - Info->Parameters = NULL; - Info->Flags = ACPI_IGNORE_RETURN_VALUE; + memset (Info, 0, sizeof (ACPI_EVALUATE_INFO)); + Info->PrefixNode = DeviceNode; + Info->RelativePathname = METHOD_NAME__INI; + Info->Parameters = NULL; + Info->Flags = ACPI_IGNORE_RETURN_VALUE; - Status = AcpiNsEvaluate (Info); - if (ACPI_SUCCESS (Status)) - { - WalkInfo->Num_INI++; - } + Status = AcpiNsEvaluate (Info); + if (ACPI_SUCCESS (Status)) + { + WalkInfo->Num_INI++; + } #ifdef ACPI_DEBUG_OUTPUT - else if (Status != AE_NOT_FOUND) - { - /* Ignore error and move on to next device */ + else if (Status != AE_NOT_FOUND) + { + /* Ignore error and move on to next device */ - char *ScopeName = AcpiNsGetExternalPathname (Info->Node); + char *ScopeName = AcpiNsGetNormalizedPathname (DeviceNode, TRUE); - ACPI_EXCEPTION ((AE_INFO, Status, "during %s._INI execution", - ScopeName)); - ACPI_FREE (ScopeName); - } + ACPI_EXCEPTION ((AE_INFO, Status, "during %s._INI execution", + ScopeName)); + ACPI_FREE (ScopeName); + } #endif + } /* Ignore errors from above */ diff --git a/sys/contrib/dev/acpica/components/namespace/nsload.c b/sys/contrib/dev/acpica/components/namespace/nsload.c index c9b1174..4c8c6bf 100644 --- a/sys/contrib/dev/acpica/components/namespace/nsload.c +++ b/sys/contrib/dev/acpica/components/namespace/nsload.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -128,7 +128,21 @@ AcpiNsLoadTable ( } else { - (void) AcpiTbReleaseOwnerId (TableIndex); + /* + * On error, delete any namespace objects created by this table. + * We cannot initialize these objects, so delete them. There are + * a couple of expecially bad cases: + * AE_ALREADY_EXISTS - namespace collision. + * AE_NOT_FOUND - the target of a Scope operator does not + * exist. This target of Scope must already exist in the + * namespace, as per the ACPI specification. + */ + (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); + AcpiNsDeleteNamespaceByOwner ( + AcpiGbl_RootTableList.Tables[TableIndex].OwnerId); + + AcpiTbReleaseOwnerId (TableIndex); + return_ACPI_STATUS (Status); } Unlock: @@ -153,6 +167,24 @@ Unlock: ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "**** Completed Table Object Initialization\n")); + /* + * Execute any module-level code that was detected during the table load + * phase. Although illegal since ACPI 2.0, there are many machines that + * contain this type of code. Each block of detected executable AML code + * outside of any control method is wrapped with a temporary control + * method object and placed on a global list. The methods on this list + * are executed below. + * + * This case executes the module-level code for each table immediately + * after the table has been loaded. This provides compatibility with + * other ACPI implementations. Optionally, the execution can be deferred + * until later, see AcpiInitializeObjects. + */ + if (!AcpiGbl_GroupModuleLevelCode) + { + AcpiNsExecModuleCodeList (); + } + return_ACPI_STATUS (Status); } @@ -245,8 +277,8 @@ AcpiNsDeleteSubtree ( ParentHandle = StartHandle; - ChildHandle = NULL; - Level = 1; + ChildHandle = NULL; + Level = 1; /* * Traverse the tree of objects until we bubble back up @@ -257,7 +289,7 @@ AcpiNsDeleteSubtree ( /* Attempt to get the next object in this scope */ Status = AcpiGetNextObject (ACPI_TYPE_ANY, ParentHandle, - ChildHandle, &NextChildHandle); + ChildHandle, &NextChildHandle); ChildHandle = NextChildHandle; @@ -268,7 +300,7 @@ AcpiNsDeleteSubtree ( /* Check if this object has any children */ if (ACPI_SUCCESS (AcpiGetNextObject (ACPI_TYPE_ANY, ChildHandle, - NULL, &Dummy))) + NULL, &Dummy))) { /* * There is at least one child of this object, @@ -346,7 +378,6 @@ AcpiNsUnloadNamespace ( /* This function does the real work */ Status = AcpiNsDeleteSubtree (Handle); - return_ACPI_STATUS (Status); } #endif diff --git a/sys/contrib/dev/acpica/components/namespace/nsnames.c b/sys/contrib/dev/acpica/components/namespace/nsnames.c index edd6517..f558c59 100644 --- a/sys/contrib/dev/acpica/components/namespace/nsnames.c +++ b/sys/contrib/dev/acpica/components/namespace/nsnames.c @@ -5,7 +5,7 @@ ******************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -53,82 +53,6 @@ /******************************************************************************* * - * FUNCTION: AcpiNsBuildExternalPath - * - * PARAMETERS: Node - NS node whose pathname is needed - * Size - Size of the pathname - * *NameBuffer - Where to return the pathname - * - * RETURN: Status - * Places the pathname into the NameBuffer, in external format - * (name segments separated by path separators) - * - * DESCRIPTION: Generate a full pathaname - * - ******************************************************************************/ - -ACPI_STATUS -AcpiNsBuildExternalPath ( - ACPI_NAMESPACE_NODE *Node, - ACPI_SIZE Size, - char *NameBuffer) -{ - ACPI_SIZE Index; - ACPI_NAMESPACE_NODE *ParentNode; - - - ACPI_FUNCTION_ENTRY (); - - - /* Special case for root */ - - Index = Size - 1; - if (Index < ACPI_NAME_SIZE) - { - NameBuffer[0] = AML_ROOT_PREFIX; - NameBuffer[1] = 0; - return (AE_OK); - } - - /* Store terminator byte, then build name backwards */ - - ParentNode = Node; - NameBuffer[Index] = 0; - - while ((Index > ACPI_NAME_SIZE) && (ParentNode != AcpiGbl_RootNode)) - { - Index -= ACPI_NAME_SIZE; - - /* Put the name into the buffer */ - - ACPI_MOVE_32_TO_32 ((NameBuffer + Index), &ParentNode->Name); - ParentNode = ParentNode->Parent; - - /* Prefix name with the path separator */ - - Index--; - NameBuffer[Index] = ACPI_PATH_SEPARATOR; - } - - /* Overwrite final separator with the root prefix character */ - - NameBuffer[Index] = AML_ROOT_PREFIX; - - if (Index != 0) - { - ACPI_ERROR ((AE_INFO, - "Could not construct external pathname; index=%u, size=%u, Path=%s", - (UINT32) Index, (UINT32) Size, &NameBuffer[Size])); - - return (AE_BAD_PARAMETER); - } - - return (AE_OK); -} - - -/******************************************************************************* - * * FUNCTION: AcpiNsGetExternalPathname * * PARAMETERS: Node - Namespace node whose pathname is needed @@ -146,40 +70,13 @@ char * AcpiNsGetExternalPathname ( ACPI_NAMESPACE_NODE *Node) { - ACPI_STATUS Status; char *NameBuffer; - ACPI_SIZE Size; ACPI_FUNCTION_TRACE_PTR (NsGetExternalPathname, Node); - /* Calculate required buffer size based on depth below root */ - - Size = AcpiNsGetPathnameLength (Node); - if (!Size) - { - return_PTR (NULL); - } - - /* Allocate a buffer to be returned to caller */ - - NameBuffer = ACPI_ALLOCATE_ZEROED (Size); - if (!NameBuffer) - { - ACPI_ERROR ((AE_INFO, "Could not allocate %u bytes", (UINT32) Size)); - return_PTR (NULL); - } - - /* Build the path in the allocated buffer */ - - Status = AcpiNsBuildExternalPath (Node, Size, NameBuffer); - if (ACPI_FAILURE (Status)) - { - ACPI_FREE (NameBuffer); - return_PTR (NULL); - } - + NameBuffer = AcpiNsGetNormalizedPathname (Node, FALSE); return_PTR (NameBuffer); } @@ -201,38 +98,13 @@ AcpiNsGetPathnameLength ( ACPI_NAMESPACE_NODE *Node) { ACPI_SIZE Size; - ACPI_NAMESPACE_NODE *NextNode; ACPI_FUNCTION_ENTRY (); - /* - * Compute length of pathname as 5 * number of name segments. - * Go back up the parent tree to the root - */ - Size = 0; - NextNode = Node; - - while (NextNode && (NextNode != AcpiGbl_RootNode)) - { - if (ACPI_GET_DESCRIPTOR_TYPE (NextNode) != ACPI_DESC_TYPE_NAMED) - { - ACPI_ERROR ((AE_INFO, - "Invalid Namespace Node (%p) while traversing namespace", - NextNode)); - return (0); - } - Size += ACPI_PATH_SEGMENT_LENGTH; - NextNode = NextNode->Parent; - } - - if (!Size) - { - Size = 1; /* Root node case */ - } - - return (Size + 1); /* +1 for null string terminator */ + Size = AcpiNsBuildNormalizedPath (Node, NULL, 0, FALSE); + return (Size); } @@ -243,6 +115,8 @@ AcpiNsGetPathnameLength ( * PARAMETERS: TargetHandle - Handle of named object whose name is * to be found * Buffer - Where the pathname is returned + * NoTrailing - Remove trailing '_' for each name + * segment * * RETURN: Status, Buffer is filled with pathname if status is AE_OK * @@ -253,7 +127,8 @@ AcpiNsGetPathnameLength ( ACPI_STATUS AcpiNsHandleToPathname ( ACPI_HANDLE TargetHandle, - ACPI_BUFFER *Buffer) + ACPI_BUFFER *Buffer, + BOOLEAN NoTrailing) { ACPI_STATUS Status; ACPI_NAMESPACE_NODE *Node; @@ -271,7 +146,7 @@ AcpiNsHandleToPathname ( /* Determine size required for the caller buffer */ - RequiredSize = AcpiNsGetPathnameLength (Node); + RequiredSize = AcpiNsBuildNormalizedPath (Node, NULL, 0, NoTrailing); if (!RequiredSize) { return_ACPI_STATUS (AE_BAD_PARAMETER); @@ -287,7 +162,8 @@ AcpiNsHandleToPathname ( /* Build the path in the caller buffer */ - Status = AcpiNsBuildExternalPath (Node, RequiredSize, Buffer->Pointer); + (void) AcpiNsBuildNormalizedPath (Node, Buffer->Pointer, + RequiredSize, NoTrailing); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); @@ -297,3 +173,174 @@ AcpiNsHandleToPathname ( (char *) Buffer->Pointer, (UINT32) RequiredSize)); return_ACPI_STATUS (AE_OK); } + + +/******************************************************************************* + * + * FUNCTION: AcpiNsBuildNormalizedPath + * + * PARAMETERS: Node - Namespace node + * FullPath - Where the path name is returned + * PathSize - Size of returned path name buffer + * NoTrailing - Remove trailing '_' from each name segment + * + * RETURN: Return 1 if the AML path is empty, otherwise returning (length + * of pathname + 1) which means the 'FullPath' contains a trailing + * null. + * + * DESCRIPTION: Build and return a full namespace pathname. + * Note that if the size of 'FullPath' isn't large enough to + * contain the namespace node's path name, the actual required + * buffer length is returned, and it should be greater than + * 'PathSize'. So callers are able to check the returning value + * to determine the buffer size of 'FullPath'. + * + ******************************************************************************/ + +UINT32 +AcpiNsBuildNormalizedPath ( + ACPI_NAMESPACE_NODE *Node, + char *FullPath, + UINT32 PathSize, + BOOLEAN NoTrailing) +{ + UINT32 Length = 0, i; + char Name[ACPI_NAME_SIZE]; + BOOLEAN DoNoTrailing; + char c, *Left, *Right; + ACPI_NAMESPACE_NODE *NextNode; + + + ACPI_FUNCTION_TRACE_PTR (NsBuildNormalizedPath, Node); + + +#define ACPI_PATH_PUT8(Path, Size, Byte, Length) \ + do { \ + if ((Length) < (Size)) \ + { \ + (Path)[(Length)] = (Byte); \ + } \ + (Length)++; \ + } while (0) + + /* + * Make sure the PathSize is correct, so that we don't need to + * validate both FullPath and PathSize. + */ + if (!FullPath) + { + PathSize = 0; + } + + if (!Node) + { + goto BuildTrailingNull; + } + + NextNode = Node; + while (NextNode && NextNode != AcpiGbl_RootNode) + { + if (NextNode != Node) + { + ACPI_PATH_PUT8(FullPath, PathSize, AML_DUAL_NAME_PREFIX, Length); + } + + ACPI_MOVE_32_TO_32 (Name, &NextNode->Name); + DoNoTrailing = NoTrailing; + for (i = 0; i < 4; i++) + { + c = Name[4-i-1]; + if (DoNoTrailing && c != '_') + { + DoNoTrailing = FALSE; + } + if (!DoNoTrailing) + { + ACPI_PATH_PUT8(FullPath, PathSize, c, Length); + } + } + + NextNode = NextNode->Parent; + } + + ACPI_PATH_PUT8(FullPath, PathSize, AML_ROOT_PREFIX, Length); + + /* Reverse the path string */ + + if (Length <= PathSize) + { + Left = FullPath; + Right = FullPath+Length - 1; + + while (Left < Right) + { + c = *Left; + *Left++ = *Right; + *Right-- = c; + } + } + + /* Append the trailing null */ + +BuildTrailingNull: + ACPI_PATH_PUT8 (FullPath, PathSize, '\0', Length); + +#undef ACPI_PATH_PUT8 + + return_UINT32 (Length); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiNsGetNormalizedPathname + * + * PARAMETERS: Node - Namespace node whose pathname is needed + * NoTrailing - Remove trailing '_' from each name segment + * + * RETURN: Pointer to storage containing the fully qualified name of + * the node, In external format (name segments separated by path + * separators.) + * + * DESCRIPTION: Used to obtain the full pathname to a namespace node, usually + * for error and debug statements. All trailing '_' will be + * removed from the full pathname if 'NoTrailing' is specified.. + * + ******************************************************************************/ + +char * +AcpiNsGetNormalizedPathname ( + ACPI_NAMESPACE_NODE *Node, + BOOLEAN NoTrailing) +{ + char *NameBuffer; + ACPI_SIZE Size; + + + ACPI_FUNCTION_TRACE_PTR (NsGetNormalizedPathname, Node); + + + /* Calculate required buffer size based on depth below root */ + + Size = AcpiNsBuildNormalizedPath (Node, NULL, 0, NoTrailing); + if (!Size) + { + return_PTR (NULL); + } + + /* Allocate a buffer to be returned to caller */ + + NameBuffer = ACPI_ALLOCATE_ZEROED (Size); + if (!NameBuffer) + { + ACPI_ERROR ((AE_INFO, + "Could not allocate %u bytes", (UINT32) Size)); + return_PTR (NULL); + } + + /* Build the path in the allocated buffer */ + + (void) AcpiNsBuildNormalizedPath (Node, NameBuffer, Size, NoTrailing); + + return_PTR (NameBuffer); +} diff --git a/sys/contrib/dev/acpica/components/namespace/nsobject.c b/sys/contrib/dev/acpica/components/namespace/nsobject.c index 8327b76..1e555d9 100644 --- a/sys/contrib/dev/acpica/components/namespace/nsobject.c +++ b/sys/contrib/dev/acpica/components/namespace/nsobject.c @@ -6,7 +6,7 @@ ******************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -145,7 +145,7 @@ AcpiNsAttachObject ( * Value passed is a name handle and that name has a * non-null value. Use that name's value and type. */ - ObjDesc = ((ACPI_NAMESPACE_NODE *) Object)->Object; + ObjDesc = ((ACPI_NAMESPACE_NODE *) Object)->Object; ObjectType = ((ACPI_NAMESPACE_NODE *) Object)->Type; } @@ -195,8 +195,8 @@ AcpiNsAttachObject ( LastObjDesc->Common.NextObject = Node->Object; } - Node->Type = (UINT8) ObjectType; - Node->Object = ObjDesc; + Node->Type = (UINT8) ObjectType; + Node->Object = ObjDesc; return_ACPI_STATUS (AE_OK); } diff --git a/sys/contrib/dev/acpica/components/namespace/nsparse.c b/sys/contrib/dev/acpica/components/namespace/nsparse.c index 0f87fa1..d0f9e95 100644 --- a/sys/contrib/dev/acpica/components/namespace/nsparse.c +++ b/sys/contrib/dev/acpica/components/namespace/nsparse.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -84,6 +84,22 @@ AcpiNsOneCompleteParse ( ACPI_FUNCTION_TRACE (NsOneCompleteParse); + Status = AcpiGetTableByIndex (TableIndex, &Table); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* Table must consist of at least a complete header */ + + if (Table->Length < sizeof (ACPI_TABLE_HEADER)) + { + return_ACPI_STATUS (AE_BAD_HEADER); + } + + AmlStart = (UINT8 *) Table + sizeof (ACPI_TABLE_HEADER); + AmlLength = Table->Length - sizeof (ACPI_TABLE_HEADER); + Status = AcpiTbGetOwnerId (TableIndex, &OwnerId); if (ACPI_FAILURE (Status)) { @@ -92,7 +108,7 @@ AcpiNsOneCompleteParse ( /* Create and init a Root Node */ - ParseRoot = AcpiPsCreateScopeOp (); + ParseRoot = AcpiPsCreateScopeOp (AmlStart); if (!ParseRoot) { return_ACPI_STATUS (AE_NO_MEMORY); @@ -107,39 +123,28 @@ AcpiNsOneCompleteParse ( return_ACPI_STATUS (AE_NO_MEMORY); } - Status = AcpiGetTableByIndex (TableIndex, &Table); + Status = AcpiDsInitAmlWalk (WalkState, ParseRoot, NULL, + AmlStart, AmlLength, NULL, (UINT8) PassNumber); if (ACPI_FAILURE (Status)) { AcpiDsDeleteWalkState (WalkState); - AcpiPsFreeOp (ParseRoot); - return_ACPI_STATUS (Status); + goto Cleanup; } - /* Table must consist of at least a complete header */ - - if (Table->Length < sizeof (ACPI_TABLE_HEADER)) - { - Status = AE_BAD_HEADER; - } - else - { - AmlStart = (UINT8 *) Table + sizeof (ACPI_TABLE_HEADER); - AmlLength = Table->Length - sizeof (ACPI_TABLE_HEADER); - Status = AcpiDsInitAmlWalk (WalkState, ParseRoot, NULL, - AmlStart, AmlLength, NULL, (UINT8) PassNumber); - } + /* Found OSDT table, enable the namespace override feature */ - if (ACPI_FAILURE (Status)) + if (ACPI_COMPARE_NAME(Table->Signature, ACPI_SIG_OSDT) && + PassNumber == ACPI_IMODE_LOAD_PASS1) { - AcpiDsDeleteWalkState (WalkState); - goto Cleanup; + WalkState->NamespaceOverride = TRUE; } /* StartNode is the default location to load the table */ if (StartNode && StartNode != AcpiGbl_RootNode) { - Status = AcpiDsScopeStackPush (StartNode, ACPI_TYPE_METHOD, WalkState); + Status = AcpiDsScopeStackPush ( + StartNode, ACPI_TYPE_METHOD, WalkState); if (ACPI_FAILURE (Status)) { AcpiDsDeleteWalkState (WalkState); @@ -149,7 +154,8 @@ AcpiNsOneCompleteParse ( /* Parse the AML */ - ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, "*PARSE* pass %u parse\n", PassNumber)); + ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, + "*PARSE* pass %u parse\n", PassNumber)); Status = AcpiPsParseAml (WalkState); Cleanup: @@ -193,8 +199,9 @@ AcpiNsParseTable ( * performs another complete parse of the AML. */ ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, "**** Start pass 1\n")); + Status = AcpiNsOneCompleteParse (ACPI_IMODE_LOAD_PASS1, - TableIndex, StartNode); + TableIndex, StartNode); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); @@ -211,7 +218,7 @@ AcpiNsParseTable ( */ ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, "**** Start pass 2\n")); Status = AcpiNsOneCompleteParse (ACPI_IMODE_LOAD_PASS2, - TableIndex, StartNode); + TableIndex, StartNode); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); diff --git a/sys/contrib/dev/acpica/components/namespace/nspredef.c b/sys/contrib/dev/acpica/components/namespace/nspredef.c index d885e5a..606b23d 100644 --- a/sys/contrib/dev/acpica/components/namespace/nspredef.c +++ b/sys/contrib/dev/acpica/components/namespace/nspredef.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -249,7 +249,7 @@ AcpiNsCheckObjectType ( { ACPI_OPERAND_OBJECT *ReturnObject = *ReturnObjectPtr; ACPI_STATUS Status = AE_OK; - char TypeBuffer[48]; /* Room for 5 types */ + char TypeBuffer[96]; /* Room for 10 types */ /* A Namespace node should not get here, but make sure */ diff --git a/sys/contrib/dev/acpica/components/namespace/nsprepkg.c b/sys/contrib/dev/acpica/components/namespace/nsprepkg.c index 905fe64..e4ea077 100644 --- a/sys/contrib/dev/acpica/components/namespace/nsprepkg.c +++ b/sys/contrib/dev/acpica/components/namespace/nsprepkg.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -70,6 +70,12 @@ AcpiNsCheckPackageElements ( UINT32 Count2, UINT32 StartIndex); +static ACPI_STATUS +AcpiNsCustomPackage ( + ACPI_EVALUATE_INFO *Info, + ACPI_OPERAND_OBJECT **Elements, + UINT32 Count); + /******************************************************************************* * @@ -148,6 +154,11 @@ AcpiNsCheckPackage ( */ switch (Package->RetInfo.Type) { + case ACPI_PTYPE_CUSTOM: + + Status = AcpiNsCustomPackage (Info, Elements, Count); + break; + case ACPI_PTYPE1_FIXED: /* * The package count is fixed and there are no subpackages @@ -171,8 +182,8 @@ AcpiNsCheckPackage ( /* Validate all elements of the returned package */ Status = AcpiNsCheckPackageElements (Info, Elements, - Package->RetInfo.ObjectType1, Package->RetInfo.Count1, - Package->RetInfo.ObjectType2, Package->RetInfo.Count2, 0); + Package->RetInfo.ObjectType1, Package->RetInfo.Count1, + Package->RetInfo.ObjectType2, Package->RetInfo.Count2, 0); break; case ACPI_PTYPE1_VAR: @@ -183,11 +194,12 @@ AcpiNsCheckPackage ( for (i = 0; i < Count; i++) { Status = AcpiNsCheckObjectType (Info, Elements, - Package->RetInfo.ObjectType1, i); + Package->RetInfo.ObjectType1, i); if (ACPI_FAILURE (Status)) { return (Status); } + Elements++; } break; @@ -215,7 +227,7 @@ AcpiNsCheckPackage ( /* These are the required package elements (0, 1, or 2) */ Status = AcpiNsCheckObjectType (Info, Elements, - Package->RetInfo3.ObjectType[i], i); + Package->RetInfo3.ObjectType[i], i); if (ACPI_FAILURE (Status)) { return (Status); @@ -226,12 +238,13 @@ AcpiNsCheckPackage ( /* These are the optional package elements */ Status = AcpiNsCheckObjectType (Info, Elements, - Package->RetInfo3.TailObjectType, i); + Package->RetInfo3.TailObjectType, i); if (ACPI_FAILURE (Status)) { return (Status); } } + Elements++; } break; @@ -240,8 +253,8 @@ AcpiNsCheckPackage ( /* First element is the (Integer) revision */ - Status = AcpiNsCheckObjectType (Info, Elements, - ACPI_RTYPE_INTEGER, 0); + Status = AcpiNsCheckObjectType ( + Info, Elements, ACPI_RTYPE_INTEGER, 0); if (ACPI_FAILURE (Status)) { return (Status); @@ -259,8 +272,8 @@ AcpiNsCheckPackage ( /* First element is the (Integer) count of subpackages to follow */ - Status = AcpiNsCheckObjectType (Info, Elements, - ACPI_RTYPE_INTEGER, 0); + Status = AcpiNsCheckObjectType ( + Info, Elements, ACPI_RTYPE_INTEGER, 0); if (ACPI_FAILURE (Status)) { return (Status); @@ -303,7 +316,8 @@ AcpiNsCheckPackage ( { /* Create the new outer package and populate it */ - Status = AcpiNsWrapWithPackage (Info, ReturnObject, ReturnObjectPtr); + Status = AcpiNsWrapWithPackage ( + Info, ReturnObject, ReturnObjectPtr); if (ACPI_FAILURE (Status)) { return (Status); @@ -341,7 +355,7 @@ AcpiNsCheckPackage ( while (Count > 0) { Status = AcpiNsCheckObjectType(Info, Elements, - Package->RetInfo.ObjectType1, 0); + Package->RetInfo.ObjectType1, 0); if (ACPI_FAILURE(Status)) { return (Status); @@ -357,7 +371,7 @@ AcpiNsCheckPackage ( } Status = AcpiNsCheckObjectType(Info, Elements + 1, - Package->RetInfo.ObjectType2, 0); + Package->RetInfo.ObjectType2, 0); if (ACPI_FAILURE(Status)) { return (Status); @@ -365,8 +379,8 @@ AcpiNsCheckPackage ( Elements += 2; Count -= 2; - } - break; + } + break; default: @@ -441,7 +455,7 @@ AcpiNsCheckPackageList ( /* Each sub-object must be of type Package */ Status = AcpiNsCheckObjectType (Info, &SubPackage, - ACPI_RTYPE_PACKAGE, i); + ACPI_RTYPE_PACKAGE, i); if (ACPI_FAILURE (Status)) { return (Status); @@ -465,10 +479,10 @@ AcpiNsCheckPackageList ( } Status = AcpiNsCheckPackageElements (Info, SubElements, - Package->RetInfo.ObjectType1, - Package->RetInfo.Count1, - Package->RetInfo.ObjectType2, - Package->RetInfo.Count2, 0); + Package->RetInfo.ObjectType1, + Package->RetInfo.Count1, + Package->RetInfo.ObjectType2, + Package->RetInfo.Count2, 0); if (ACPI_FAILURE (Status)) { return (Status); @@ -487,10 +501,10 @@ AcpiNsCheckPackageList ( } Status = AcpiNsCheckPackageElements (Info, SubElements, - Package->RetInfo.ObjectType1, - Package->RetInfo.Count1, - Package->RetInfo.ObjectType2, - SubPackage->Package.Count - Package->RetInfo.Count1, 0); + Package->RetInfo.ObjectType1, + Package->RetInfo.Count1, + Package->RetInfo.ObjectType2, + SubPackage->Package.Count - Package->RetInfo.Count1, 0); if (ACPI_FAILURE (Status)) { return (Status); @@ -518,7 +532,7 @@ AcpiNsCheckPackageList ( for (j = 0; j < ExpectedCount; j++) { Status = AcpiNsCheckObjectType (Info, &SubElements[j], - Package->RetInfo2.ObjectType[j], j); + Package->RetInfo2.ObjectType[j], j); if (ACPI_FAILURE (Status)) { return (Status); @@ -539,8 +553,8 @@ AcpiNsCheckPackageList ( /* Check the type of each subpackage element */ Status = AcpiNsCheckPackageElements (Info, SubElements, - Package->RetInfo.ObjectType1, - SubPackage->Package.Count, 0, 0, 0); + Package->RetInfo.ObjectType1, + SubPackage->Package.Count, 0, 0, 0); if (ACPI_FAILURE (Status)) { return (Status); @@ -553,7 +567,7 @@ AcpiNsCheckPackageList ( * the count field (the ACPI name is NumElements) */ Status = AcpiNsCheckObjectType (Info, SubElements, - ACPI_RTYPE_INTEGER, 0); + ACPI_RTYPE_INTEGER, 0); if (ACPI_FAILURE (Status)) { return (Status); @@ -568,11 +582,13 @@ AcpiNsCheckPackageList ( { goto PackageTooSmall; } + if (SubPackage->Package.Count < Package->RetInfo.Count1) { ExpectedCount = Package->RetInfo.Count1; goto PackageTooSmall; } + if (ExpectedCount == 0) { /* @@ -588,8 +604,8 @@ AcpiNsCheckPackageList ( /* Check the type of each subpackage element */ Status = AcpiNsCheckPackageElements (Info, (SubElements + 1), - Package->RetInfo.ObjectType1, - (ExpectedCount - 1), 0, 0, 1); + Package->RetInfo.ObjectType1, + (ExpectedCount - 1), 0, 0, 1); if (ACPI_FAILURE (Status)) { return (Status); @@ -621,6 +637,92 @@ PackageTooSmall: /******************************************************************************* * + * FUNCTION: AcpiNsCustomPackage + * + * PARAMETERS: Info - Method execution information block + * Elements - Pointer to the package elements array + * Count - Element count for the package + * + * RETURN: Status + * + * DESCRIPTION: Check a returned package object for the correct count and + * correct type of all sub-objects. + * + * NOTE: Currently used for the _BIX method only. When needed for two or more + * methods, probably a detect/dispatch mechanism will be required. + * + ******************************************************************************/ + +static ACPI_STATUS +AcpiNsCustomPackage ( + ACPI_EVALUATE_INFO *Info, + ACPI_OPERAND_OBJECT **Elements, + UINT32 Count) +{ + UINT32 ExpectedCount; + UINT32 Version; + ACPI_STATUS Status = AE_OK; + + + ACPI_FUNCTION_NAME (NsCustomPackage); + + + /* Get version number, must be Integer */ + + if ((*Elements)->Common.Type != ACPI_TYPE_INTEGER) + { + ACPI_WARN_PREDEFINED ((AE_INFO, Info->FullPathname, Info->NodeFlags, + "Return Package has invalid object type for version number")); + return_ACPI_STATUS (AE_AML_OPERAND_TYPE); + } + + Version = (UINT32) (*Elements)->Integer.Value; + ExpectedCount = 21; /* Version 1 */ + + if (Version == 0) + { + ExpectedCount = 20; /* Version 0 */ + } + + if (Count < ExpectedCount) + { + ACPI_WARN_PREDEFINED ((AE_INFO, Info->FullPathname, Info->NodeFlags, + "Return Package is too small - found %u elements, expected %u", + Count, ExpectedCount)); + return_ACPI_STATUS (AE_AML_OPERAND_VALUE); + } + else if (Count > ExpectedCount) + { + ACPI_DEBUG_PRINT ((ACPI_DB_REPAIR, + "%s: Return Package is larger than needed - " + "found %u, expected %u\n", + Info->FullPathname, Count, ExpectedCount)); + } + + /* Validate all elements of the returned package */ + + Status = AcpiNsCheckPackageElements (Info, Elements, + ACPI_RTYPE_INTEGER, 16, + ACPI_RTYPE_STRING, 4, 0); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* Version 1 has a single trailing integer */ + + if (Version > 0) + { + Status = AcpiNsCheckPackageElements (Info, Elements + 20, + ACPI_RTYPE_INTEGER, 1, 0, 0, 20); + } + + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * * FUNCTION: AcpiNsCheckPackageElements * * PARAMETERS: Info - Method execution information block @@ -661,22 +763,24 @@ AcpiNsCheckPackageElements ( for (i = 0; i < Count1; i++) { Status = AcpiNsCheckObjectType (Info, ThisElement, - Type1, i + StartIndex); + Type1, i + StartIndex); if (ACPI_FAILURE (Status)) { return (Status); } + ThisElement++; } for (i = 0; i < Count2; i++) { Status = AcpiNsCheckObjectType (Info, ThisElement, - Type2, (i + Count1 + StartIndex)); + Type2, (i + Count1 + StartIndex)); if (ACPI_FAILURE (Status)) { return (Status); } + ThisElement++; } diff --git a/sys/contrib/dev/acpica/components/namespace/nsrepair.c b/sys/contrib/dev/acpica/components/namespace/nsrepair.c index b4c2c99..a0d4935 100644 --- a/sys/contrib/dev/acpica/components/namespace/nsrepair.c +++ b/sys/contrib/dev/acpica/components/namespace/nsrepair.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -114,6 +114,11 @@ static const ACPI_SIMPLE_REPAIR_INFO AcpiObjectRepairInfo[] = ACPI_NOT_PACKAGE_ELEMENT, AcpiNsConvertToResource }, + /* Object reference conversions */ + + { "_DEP", ACPI_RTYPE_STRING, ACPI_ALL_PACKAGE_ELEMENTS, + AcpiNsConvertToReference }, + /* Unicode conversions */ { "_MLS", ACPI_RTYPE_STRING, 1, @@ -174,7 +179,8 @@ AcpiNsSimpleRepair ( ACPI_WARN_ALWAYS, "Missing expected return value")); } - Status = Predefined->ObjectConverter (ReturnObject, &NewObject); + Status = Predefined->ObjectConverter (Info->Node, ReturnObject, + &NewObject); if (ACPI_FAILURE (Status)) { /* A fatal error occurred during a conversion */ @@ -222,7 +228,7 @@ AcpiNsSimpleRepair ( ACPI_WARN_ALWAYS, "Found unexpected NULL package element")); Status = AcpiNsRepairNullElement (Info, ExpectedBtypes, - PackageIndex, ReturnObjectPtr); + PackageIndex, ReturnObjectPtr); if (ACPI_SUCCESS (Status)) { return (AE_OK); /* Repair was successful */ @@ -373,13 +379,15 @@ AcpiNsMatchSimpleRepair ( /* Check if we can actually repair this name/type combination */ if ((ReturnBtype & ThisName->UnexpectedBtypes) && - (PackageIndex == ThisName->PackageIndex)) + (ThisName->PackageIndex == ACPI_ALL_PACKAGE_ELEMENTS || + PackageIndex == ThisName->PackageIndex)) { return (ThisName); } return (NULL); } + ThisName++; } @@ -464,11 +472,13 @@ AcpiNsRepairNullElement ( /* Set the reference count according to the parent Package object */ - NewObject->Common.ReferenceCount = Info->ParentPackage->Common.ReferenceCount; + NewObject->Common.ReferenceCount = + Info->ParentPackage->Common.ReferenceCount; ACPI_DEBUG_PRINT ((ACPI_DB_REPAIR, "%s: Converted NULL package element to expected %s at index %u\n", - Info->FullPathname, AcpiUtGetObjectTypeName (NewObject), PackageIndex)); + Info->FullPathname, AcpiUtGetObjectTypeName (NewObject), + PackageIndex)); *ReturnObjectPtr = NewObject; Info->ReturnFlags |= ACPI_OBJECT_REPAIRED; @@ -551,6 +561,7 @@ AcpiNsRemoveNullElements ( *Dest = *Source; Dest++; } + Source++; } @@ -607,8 +618,8 @@ AcpiNsWrapWithPackage ( /* - * Create the new outer package and populate it. The new package will - * have a single element, the lone sub-object. + * Create the new outer package and populate it. The new + * package will have a single element, the lone sub-object. */ PkgObjDesc = AcpiUtCreatePackageObject (1); if (!PkgObjDesc) diff --git a/sys/contrib/dev/acpica/components/namespace/nsrepair2.c b/sys/contrib/dev/acpica/components/namespace/nsrepair2.c index 410b009..4873c7f 100644 --- a/sys/contrib/dev/acpica/components/namespace/nsrepair2.c +++ b/sys/contrib/dev/acpica/components/namespace/nsrepair2.c @@ -6,7 +6,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -254,6 +254,7 @@ AcpiNsMatchComplexRepair ( { return (ThisName); } + ThisName++; } @@ -286,7 +287,7 @@ AcpiNsRepair_ALR ( Status = AcpiNsCheckSortedList (Info, ReturnObject, 0, 2, 1, - ACPI_SORT_ASCENDING, "AmbientIlluminance"); + ACPI_SORT_ASCENDING, "AmbientIlluminance"); return (Status); } @@ -339,7 +340,8 @@ AcpiNsRepair_FDE ( if (ReturnObject->Buffer.Length != ACPI_FDE_BYTE_BUFFER_SIZE) { - ACPI_WARN_PREDEFINED ((AE_INFO, Info->FullPathname, Info->NodeFlags, + ACPI_WARN_PREDEFINED ((AE_INFO, + Info->FullPathname, Info->NodeFlags, "Incorrect return buffer length %u, expected %u", ReturnObject->Buffer.Length, ACPI_FDE_DWORD_BUFFER_SIZE)); @@ -348,7 +350,8 @@ AcpiNsRepair_FDE ( /* Create the new (larger) buffer object */ - BufferObject = AcpiUtCreateBufferObject (ACPI_FDE_DWORD_BUFFER_SIZE); + BufferObject = AcpiUtCreateBufferObject ( + ACPI_FDE_DWORD_BUFFER_SIZE); if (!BufferObject) { return (AE_NO_MEMORY); @@ -357,7 +360,8 @@ AcpiNsRepair_FDE ( /* Expand each byte to a DWORD */ ByteBuffer = ReturnObject->Buffer.Pointer; - DwordBuffer = ACPI_CAST_PTR (UINT32, BufferObject->Buffer.Pointer); + DwordBuffer = ACPI_CAST_PTR (UINT32, + BufferObject->Buffer.Pointer); for (i = 0; i < ACPI_FDE_FIELD_COUNT; i++) { @@ -510,7 +514,8 @@ AcpiNsRepair_CST ( if ((*OuterElements)->Package.Count == 0) { - ACPI_WARN_PREDEFINED ((AE_INFO, Info->FullPathname, Info->NodeFlags, + ACPI_WARN_PREDEFINED ((AE_INFO, + Info->FullPathname, Info->NodeFlags, "SubPackage[%u] - removing entry due to zero count", i)); Removing = TRUE; goto RemoveElement; @@ -519,7 +524,8 @@ AcpiNsRepair_CST ( ObjDesc = (*OuterElements)->Package.Elements[1]; /* Index1 = Type */ if ((UINT32) ObjDesc->Integer.Value == 0) { - ACPI_WARN_PREDEFINED ((AE_INFO, Info->FullPathname, Info->NodeFlags, + ACPI_WARN_PREDEFINED ((AE_INFO, + Info->FullPathname, Info->NodeFlags, "SubPackage[%u] - removing entry due to invalid Type(0)", i)); Removing = TRUE; } @@ -546,7 +552,7 @@ RemoveElement: * C-state type, in ascending order. */ Status = AcpiNsCheckSortedList (Info, ReturnObject, 1, 4, 1, - ACPI_SORT_ASCENDING, "C-State Type"); + ACPI_SORT_ASCENDING, "C-State Type"); if (ACPI_FAILURE (Status)) { return (Status); @@ -594,7 +600,8 @@ AcpiNsRepair_HID ( if (ReturnObject->String.Length == 0) { - ACPI_WARN_PREDEFINED ((AE_INFO, Info->FullPathname, Info->NodeFlags, + ACPI_WARN_PREDEFINED ((AE_INFO, + Info->FullPathname, Info->NodeFlags, "Invalid zero-length _HID or _CID string")); /* Return AE_OK anyway, let driver handle it */ @@ -637,7 +644,7 @@ AcpiNsRepair_HID ( */ for (Dest = NewString->String.Pointer; *Source; Dest++, Source++) { - *Dest = (char) ACPI_TOUPPER (*Source); + *Dest = (char) toupper ((int) *Source); } AcpiUtRemoveReference (ReturnObject); @@ -756,8 +763,8 @@ AcpiNsRepair_PSS ( * incorrectly sorted, sort it. We sort by CpuFrequency, since this * should be proportional to the power. */ - Status =AcpiNsCheckSortedList (Info, ReturnObject, 0, 6, 0, - ACPI_SORT_DESCENDING, "CpuFrequency"); + Status = AcpiNsCheckSortedList (Info, ReturnObject, 0, 6, 0, + ACPI_SORT_DESCENDING, "CpuFrequency"); if (ACPI_FAILURE (Status)) { return (Status); @@ -778,7 +785,8 @@ AcpiNsRepair_PSS ( if ((UINT32) ObjDesc->Integer.Value > PreviousValue) { - ACPI_WARN_PREDEFINED ((AE_INFO, Info->FullPathname, Info->NodeFlags, + ACPI_WARN_PREDEFINED ((AE_INFO, + Info->FullPathname, Info->NodeFlags, "SubPackage[%u,%u] - suspicious power dissipation values", i-1, i)); } @@ -832,7 +840,7 @@ AcpiNsRepair_TSS ( } Status = AcpiNsCheckSortedList (Info, ReturnObject, 0, 5, 1, - ACPI_SORT_DESCENDING, "PowerDissipation"); + ACPI_SORT_DESCENDING, "PowerDissipation"); return (Status); } @@ -1064,6 +1072,7 @@ AcpiNsRemoveElement ( *Dest = *Source; Dest++; } + Source++; } diff --git a/sys/contrib/dev/acpica/components/namespace/nssearch.c b/sys/contrib/dev/acpica/components/namespace/nssearch.c index 9f24f1c..85514aa 100644 --- a/sys/contrib/dev/acpica/components/namespace/nssearch.c +++ b/sys/contrib/dev/acpica/components/namespace/nssearch.c @@ -5,7 +5,7 @@ ******************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -112,7 +112,7 @@ AcpiNsSearchOneScope ( { char *ScopeName; - ScopeName = AcpiNsGetExternalPathname (ParentNode); + ScopeName = AcpiNsGetNormalizedPathname (ParentNode, TRUE); if (ScopeName) { ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, @@ -248,7 +248,7 @@ AcpiNsSearchParentTree ( * the actual name we are searching for. Typechecking comes later. */ Status = AcpiNsSearchOneScope ( - TargetName, ParentNode, ACPI_TYPE_ANY, ReturnNode); + TargetName, ParentNode, ACPI_TYPE_ANY, ReturnNode); if (ACPI_SUCCESS (Status)) { return_ACPI_STATUS (Status); @@ -338,10 +338,42 @@ AcpiNsSearchAndEnter ( * If we found it AND the request specifies that a find is an error, * return the error */ - if ((Status == AE_OK) && - (Flags & ACPI_NS_ERROR_IF_FOUND)) + if (Status == AE_OK) { - Status = AE_ALREADY_EXISTS; + /* The node was found in the namespace */ + + /* + * If the namespace override feature is enabled for this node, + * delete any existing attached sub-object and make the node + * look like a new node that is owned by the override table. + */ + if (Flags & ACPI_NS_OVERRIDE_IF_FOUND) + { + ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, + "Namespace override: %4.4s pass %u type %X Owner %X\n", + ACPI_CAST_PTR(char, &TargetName), InterpreterMode, + (*ReturnNode)->Type, WalkState->OwnerId)); + + AcpiNsDeleteChildren (*ReturnNode); + if (AcpiGbl_RuntimeNamespaceOverride) + { + AcpiUtRemoveReference ((*ReturnNode)->Object); + (*ReturnNode)->Object = NULL; + (*ReturnNode)->OwnerId = WalkState->OwnerId; + } + else + { + AcpiNsRemoveNode (*ReturnNode); + *ReturnNode = ACPI_ENTRY_NOT_FOUND; + } + } + + /* Return an error if we don't expect to find the object */ + + else if (Flags & ACPI_NS_ERROR_IF_FOUND) + { + Status = AE_ALREADY_EXISTS; + } } #ifdef ACPI_ASL_COMPILER diff --git a/sys/contrib/dev/acpica/components/namespace/nsutils.c b/sys/contrib/dev/acpica/components/namespace/nsutils.c index d7320a6..220ad90 100644 --- a/sys/contrib/dev/acpica/components/namespace/nsutils.c +++ b/sys/contrib/dev/acpica/components/namespace/nsutils.c @@ -6,7 +6,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -90,7 +90,7 @@ AcpiNsPrintNodePathname ( Buffer.Length = ACPI_ALLOCATE_LOCAL_BUFFER; - Status = AcpiNsHandleToPathname (Node, &Buffer); + Status = AcpiNsHandleToPathname (Node, &Buffer, TRUE); if (ACPI_SUCCESS (Status)) { if (Message) @@ -196,9 +196,10 @@ AcpiNsGetInternalNameLength ( Info->FullyQualified = FALSE; /* - * For the internal name, the required length is 4 bytes per segment, plus - * 1 each for RootPrefix, MultiNamePrefixOp, segment count, trailing null - * (which is not really needed, but no there's harm in putting it there) + * For the internal name, the required length is 4 bytes per segment, + * plus 1 each for RootPrefix, MultiNamePrefixOp, segment count, + * trailing null (which is not really needed, but no there's harm in + * putting it there) * * strlen() + 1 covers the first NameSeg, which has no path separator */ @@ -243,7 +244,7 @@ AcpiNsGetInternalNameLength ( } Info->Length = (ACPI_NAME_SIZE * Info->NumSegments) + - 4 + Info->NumCarats; + 4 + Info->NumCarats; Info->NextExternalChar = NextExternalChar; } @@ -347,7 +348,7 @@ AcpiNsBuildInternalName ( { /* Convert the character to uppercase and save it */ - Result[i] = (char) ACPI_TOUPPER ((int) *ExternalName); + Result[i] = (char) toupper ((int) *ExternalName); ExternalName++; } } @@ -574,7 +575,7 @@ AcpiNsExternalizeName ( * punctuation ('.') between object names, plus the NULL terminator. */ RequiredLength = PrefixLength + (4 * NumSegments) + - ((NumSegments > 0) ? (NumSegments - 1) : 0) + 1; + ((NumSegments > 0) ? (NumSegments - 1) : 0) + 1; /* * Check to see if we're still in bounds. If not, there's a problem @@ -612,7 +613,8 @@ AcpiNsExternalizeName ( /* Copy and validate the 4-char name segment */ - ACPI_MOVE_NAME (&(*ConvertedName)[j], &InternalName[NamesIndex]); + ACPI_MOVE_NAME (&(*ConvertedName)[j], + &InternalName[NamesIndex]); AcpiUtRepairName (&(*ConvertedName)[j]); j += ACPI_NAME_SIZE; @@ -697,6 +699,24 @@ AcpiNsTerminate ( ACPI_FUNCTION_TRACE (NsTerminate); +#ifdef ACPI_EXEC_APP + { + ACPI_OPERAND_OBJECT *Prev; + ACPI_OPERAND_OBJECT *Next; + + /* Delete any module-level code blocks */ + + Next = AcpiGbl_ModuleCodeList; + while (Next) + { + Prev = Next; + Next = Next->Method.Mutex; + Prev->Method.Mutex = NULL; /* Clear the Mutex (cheated) field */ + AcpiUtRemoveReference (Prev); + } + } +#endif + /* * Free the entire namespace -- all nodes and all objects * attached to the nodes @@ -795,6 +815,7 @@ AcpiNsGetNode ( { *ReturnNode = AcpiGbl_RootNode; } + return_ACPI_STATUS (AE_OK); } @@ -829,12 +850,12 @@ AcpiNsGetNode ( /* Lookup the name in the namespace */ Status = AcpiNsLookup (&ScopeInfo, InternalPath, ACPI_TYPE_ANY, - ACPI_IMODE_EXECUTE, (Flags | ACPI_NS_DONT_OPEN_SCOPE), - NULL, ReturnNode); + ACPI_IMODE_EXECUTE, (Flags | ACPI_NS_DONT_OPEN_SCOPE), + NULL, ReturnNode); if (ACPI_FAILURE (Status)) { ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "%s, %s\n", - Pathname, AcpiFormatException (Status))); + Pathname, AcpiFormatException (Status))); } (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); diff --git a/sys/contrib/dev/acpica/components/namespace/nswalk.c b/sys/contrib/dev/acpica/components/namespace/nswalk.c index 1674998..bdbfa76 100644 --- a/sys/contrib/dev/acpica/components/namespace/nswalk.c +++ b/sys/contrib/dev/acpica/components/namespace/nswalk.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -218,10 +218,10 @@ AcpiNsWalkNamespace ( /* Null child means "get first node" */ - ParentNode = StartNode; - ChildNode = AcpiNsGetNextNode (ParentNode, NULL); - ChildType = ACPI_TYPE_ANY; - Level = 1; + ParentNode = StartNode; + ChildNode = AcpiNsGetNextNode (ParentNode, NULL); + ChildType = ACPI_TYPE_ANY; + Level = 1; /* * Traverse the tree of nodes until we bubble back up to where we @@ -279,7 +279,7 @@ AcpiNsWalkNamespace ( if (DescendingCallback) { Status = DescendingCallback (ChildNode, Level, - Context, ReturnValue); + Context, ReturnValue); } } else @@ -287,7 +287,7 @@ AcpiNsWalkNamespace ( if (AscendingCallback) { Status = AscendingCallback (ChildNode, Level, - Context, ReturnValue); + Context, ReturnValue); } } diff --git a/sys/contrib/dev/acpica/components/namespace/nsxfeval.c b/sys/contrib/dev/acpica/components/namespace/nsxfeval.c index 93226ef..6467d7e 100644 --- a/sys/contrib/dev/acpica/components/namespace/nsxfeval.c +++ b/sys/contrib/dev/acpica/components/namespace/nsxfeval.c @@ -6,7 +6,7 @@ ******************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -305,13 +305,12 @@ AcpiEvaluateObject ( } -#if 0 +#ifdef _FUTURE_FEATURE /* * Begin incoming argument count analysis. Check for too few args * and too many args. */ - switch (AcpiNsGetType (Info->Node)) { case ACPI_TYPE_METHOD: @@ -399,69 +398,74 @@ AcpiEvaluateObject ( * If we are expecting a return value, and all went well above, * copy the return value to an external object. */ - if (ReturnBuffer) + if (!ReturnBuffer) + { + goto CleanupReturnObject; + } + + if (!Info->ReturnObject) + { + ReturnBuffer->Length = 0; + goto Cleanup; + } + + if (ACPI_GET_DESCRIPTOR_TYPE (Info->ReturnObject) == + ACPI_DESC_TYPE_NAMED) { - if (!Info->ReturnObject) + /* + * If we received a NS Node as a return object, this means that + * the object we are evaluating has nothing interesting to + * return (such as a mutex, etc.) We return an error because + * these types are essentially unsupported by this interface. + * We don't check up front because this makes it easier to add + * support for various types at a later date if necessary. + */ + Status = AE_TYPE; + Info->ReturnObject = NULL; /* No need to delete a NS Node */ + ReturnBuffer->Length = 0; + } + + if (ACPI_FAILURE (Status)) + { + goto CleanupReturnObject; + } + + /* Dereference Index and RefOf references */ + + AcpiNsResolveReferences (Info); + + /* Get the size of the returned object */ + + Status = AcpiUtGetObjectSize (Info->ReturnObject, + &BufferSpaceNeeded); + if (ACPI_SUCCESS (Status)) + { + /* Validate/Allocate/Clear caller buffer */ + + Status = AcpiUtInitializeBuffer (ReturnBuffer, + BufferSpaceNeeded); + if (ACPI_FAILURE (Status)) { - ReturnBuffer->Length = 0; + /* + * Caller's buffer is too small or a new one can't + * be allocated + */ + ACPI_DEBUG_PRINT ((ACPI_DB_INFO, + "Needed buffer size %X, %s\n", + (UINT32) BufferSpaceNeeded, + AcpiFormatException (Status))); } else { - if (ACPI_GET_DESCRIPTOR_TYPE (Info->ReturnObject) == - ACPI_DESC_TYPE_NAMED) - { - /* - * If we received a NS Node as a return object, this means that - * the object we are evaluating has nothing interesting to - * return (such as a mutex, etc.) We return an error because - * these types are essentially unsupported by this interface. - * We don't check up front because this makes it easier to add - * support for various types at a later date if necessary. - */ - Status = AE_TYPE; - Info->ReturnObject = NULL; /* No need to delete a NS Node */ - ReturnBuffer->Length = 0; - } + /* We have enough space for the object, build it */ - if (ACPI_SUCCESS (Status)) - { - /* Dereference Index and RefOf references */ - - AcpiNsResolveReferences (Info); - - /* Get the size of the returned object */ - - Status = AcpiUtGetObjectSize (Info->ReturnObject, - &BufferSpaceNeeded); - if (ACPI_SUCCESS (Status)) - { - /* Validate/Allocate/Clear caller buffer */ - - Status = AcpiUtInitializeBuffer (ReturnBuffer, - BufferSpaceNeeded); - if (ACPI_FAILURE (Status)) - { - /* - * Caller's buffer is too small or a new one can't - * be allocated - */ - ACPI_DEBUG_PRINT ((ACPI_DB_INFO, - "Needed buffer size %X, %s\n", - (UINT32) BufferSpaceNeeded, - AcpiFormatException (Status))); - } - else - { - /* We have enough space for the object, build it */ - - Status = AcpiUtCopyIobjectToEobject (Info->ReturnObject, - ReturnBuffer); - } - } - } + Status = AcpiUtCopyIobjectToEobject ( + Info->ReturnObject, ReturnBuffer); } } +CleanupReturnObject: + if (Info->ReturnObject) { /* @@ -668,8 +672,8 @@ AcpiWalkNamespace ( } Status = AcpiNsWalkNamespace (Type, StartObject, MaxDepth, - ACPI_NS_WALK_UNLOCK, DescendingCallback, - AscendingCallback, Context, ReturnValue); + ACPI_NS_WALK_UNLOCK, DescendingCallback, + AscendingCallback, Context, ReturnValue); UnlockAndExit2: (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); @@ -758,7 +762,7 @@ AcpiNsGetDeviceCallback ( return (AE_CTRL_DEPTH); } - NoMatch = ACPI_STRCMP (Hid->String, Info->Hid); + NoMatch = strcmp (Hid->String, Info->Hid); ACPI_FREE (Hid); if (NoMatch) @@ -782,7 +786,7 @@ AcpiNsGetDeviceCallback ( Found = FALSE; for (i = 0; i < Cid->Count; i++) { - if (ACPI_STRCMP (Cid->Ids[i].String, Info->Hid) == 0) + if (strcmp (Cid->Ids[i].String, Info->Hid) == 0) { /* Found a matching CID */ @@ -820,8 +824,8 @@ AcpiNsGetDeviceCallback ( /* We have a valid device, invoke the user function */ - Status = Info->UserFunction (ObjHandle, NestingLevel, Info->Context, - ReturnValue); + Status = Info->UserFunction (ObjHandle, NestingLevel, + Info->Context, ReturnValue); return (Status); } @@ -876,8 +880,8 @@ AcpiGetDevices ( * We're going to call their callback from OUR callback, so we need * to know what it is, and their context parameter. */ - Info.Hid = HID; - Info.Context = Context; + Info.Hid = HID; + Info.Context = Context; Info.UserFunction = UserFunction; /* @@ -893,8 +897,8 @@ AcpiGetDevices ( } Status = AcpiNsWalkNamespace (ACPI_TYPE_DEVICE, ACPI_ROOT_OBJECT, - ACPI_UINT32_MAX, ACPI_NS_WALK_UNLOCK, - AcpiNsGetDeviceCallback, NULL, &Info, ReturnValue); + ACPI_UINT32_MAX, ACPI_NS_WALK_UNLOCK, + AcpiNsGetDeviceCallback, NULL, &Info, ReturnValue); (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); return_ACPI_STATUS (Status); diff --git a/sys/contrib/dev/acpica/components/namespace/nsxfname.c b/sys/contrib/dev/acpica/components/namespace/nsxfname.c index 804ea94..55c515f 100644 --- a/sys/contrib/dev/acpica/components/namespace/nsxfname.c +++ b/sys/contrib/dev/acpica/components/namespace/nsxfname.c @@ -6,7 +6,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -126,7 +126,7 @@ AcpiGetHandle ( /* Special case for root-only, since we can't search for it */ - if (!ACPI_STRCMP (Pathname, ACPI_NS_ROOT_PATH)) + if (!strcmp (Pathname, ACPI_NS_ROOT_PATH)) { *RetHandle = ACPI_CAST_PTR (ACPI_HANDLE, AcpiGbl_RootNode); return (AE_OK); @@ -177,7 +177,7 @@ AcpiGetName ( { ACPI_STATUS Status; ACPI_NAMESPACE_NODE *Node; - char *NodeName; + const char *NodeName; /* Parameter validation */ @@ -193,11 +193,13 @@ AcpiGetName ( return (Status); } - if (NameType == ACPI_FULL_PATHNAME) + if (NameType == ACPI_FULL_PATHNAME || + NameType == ACPI_FULL_PATHNAME_NO_TRAILING) { /* Get the full pathname (From the namespace root) */ - Status = AcpiNsHandleToPathname (Handle, Buffer); + Status = AcpiNsHandleToPathname (Handle, Buffer, + NameType == ACPI_FULL_PATHNAME ? FALSE : TRUE); return (Status); } @@ -263,7 +265,6 @@ AcpiNsCopyDeviceId ( ACPI_PNP_DEVICE_ID *Source, char *StringArea) { - /* Create the destination PNP_DEVICE_ID */ Dest->String = StringArea; @@ -271,7 +272,7 @@ AcpiNsCopyDeviceId ( /* Copy actual string and return a pointer to the next string area */ - ACPI_MEMCPY (StringArea, Source->String, Source->Length); + memcpy (StringArea, Source->String, Source->Length); return (StringArea + Source->Length); } @@ -289,11 +290,18 @@ AcpiNsCopyDeviceId ( * namespace node and possibly by running several standard * control methods (Such as in the case of a device.) * - * For Device and Processor objects, run the Device _HID, _UID, _CID, _SUB, - * _STA, _ADR, _SxW, and _SxD methods. + * For Device and Processor objects, run the Device _HID, _UID, _CID, _STA, + * _CLS, _ADR, _SxW, and _SxD methods. * * Note: Allocates the return buffer, must be freed by the caller. * + * Note: This interface is intended to be used during the initial device + * discovery namespace traversal. Therefore, no complex methods can be + * executed, especially those that access operation regions. Therefore, do + * not add any additional methods that could cause problems in this area. + * this was the fate of the _SUB method which was found to cause such + * problems and was removed (11/2015). + * ******************************************************************************/ ACPI_STATUS @@ -306,12 +314,12 @@ AcpiGetObjectInfo ( ACPI_PNP_DEVICE_ID_LIST *CidList = NULL; ACPI_PNP_DEVICE_ID *Hid = NULL; ACPI_PNP_DEVICE_ID *Uid = NULL; - ACPI_PNP_DEVICE_ID *Sub = NULL; + ACPI_PNP_DEVICE_ID *Cls = NULL; char *NextIdString; ACPI_OBJECT_TYPE Type; ACPI_NAME Name; UINT8 ParamCount= 0; - UINT8 Valid = 0; + UINT16 Valid = 0; UINT32 InfoSize; UINT32 i; ACPI_STATUS Status; @@ -359,7 +367,7 @@ AcpiGetObjectInfo ( { /* * Get extra info for ACPI Device/Processor objects only: - * Run the Device _HID, _UID, _SUB, and _CID methods. + * Run the Device _HID, _UID, _CLS, and _CID methods. * * Note: none of these methods are required, so they may or may * not be present for this device. The Info->Valid bitfield is used @@ -384,15 +392,6 @@ AcpiGetObjectInfo ( Valid |= ACPI_VALID_UID; } - /* Execute the Device._SUB method */ - - Status = AcpiUtExecute_SUB (Node, &Sub); - if (ACPI_SUCCESS (Status)) - { - InfoSize += Sub->Length; - Valid |= ACPI_VALID_SUB; - } - /* Execute the Device._CID method */ Status = AcpiUtExecute_CID (Node, &CidList); @@ -403,6 +402,15 @@ AcpiGetObjectInfo ( InfoSize += (CidList->ListSize - sizeof (ACPI_PNP_DEVICE_ID_LIST)); Valid |= ACPI_VALID_CID; } + + /* Execute the Device._CLS method */ + + Status = AcpiUtExecute_CLS (Node, &Cls); + if (ACPI_SUCCESS (Status)) + { + InfoSize += Cls->Length; + Valid |= ACPI_VALID_CLS; + } } /* @@ -446,7 +454,7 @@ AcpiGetObjectInfo ( /* Execute the Device._ADR method */ Status = AcpiUtEvaluateNumericObject (METHOD_NAME__ADR, Node, - &Info->Address); + &Info->Address); if (ACPI_SUCCESS (Status)) { Valid |= ACPI_VALID_ADR; @@ -455,8 +463,8 @@ AcpiGetObjectInfo ( /* Execute the Device._SxW methods */ Status = AcpiUtExecutePowerMethods (Node, - AcpiGbl_LowestDstateNames, ACPI_NUM_SxW_METHODS, - Info->LowestDstates); + AcpiGbl_LowestDstateNames, ACPI_NUM_SxW_METHODS, + Info->LowestDstates); if (ACPI_SUCCESS (Status)) { Valid |= ACPI_VALID_SXWS; @@ -465,8 +473,8 @@ AcpiGetObjectInfo ( /* Execute the Device._SxD methods */ Status = AcpiUtExecutePowerMethods (Node, - AcpiGbl_HighestDstateNames, ACPI_NUM_SxD_METHODS, - Info->HighestDstates); + AcpiGbl_HighestDstateNames, ACPI_NUM_SxD_METHODS, + Info->HighestDstates); if (ACPI_SUCCESS (Status)) { Valid |= ACPI_VALID_SXDS; @@ -486,9 +494,8 @@ AcpiGetObjectInfo ( } /* - * Copy the HID, UID, SUB, and CIDs to the return buffer. - * The variable-length strings are copied to the reserved area - * at the end of the buffer. + * Copy the HID, UID, and CIDs to the return buffer. The variable-length + * strings are copied to the reserved area at the end of the buffer. * * For HID and CID, check if the ID is a PCI Root Bridge. */ @@ -509,12 +516,6 @@ AcpiGetObjectInfo ( Uid, NextIdString); } - if (Sub) - { - NextIdString = AcpiNsCopyDeviceId (&Info->SubsystemId, - Sub, NextIdString); - } - if (CidList) { Info->CompatibleIdList.Count = CidList->Count; @@ -534,6 +535,12 @@ AcpiGetObjectInfo ( } } + if (Cls) + { + NextIdString = AcpiNsCopyDeviceId (&Info->ClassCode, + Cls, NextIdString); + } + /* Copy the fixed-length data */ Info->InfoSize = InfoSize; @@ -555,14 +562,14 @@ Cleanup: { ACPI_FREE (Uid); } - if (Sub) - { - ACPI_FREE (Sub); - } if (CidList) { ACPI_FREE (CidList); } + if (Cls) + { + ACPI_FREE (Cls); + } return (Status); } @@ -630,6 +637,7 @@ AcpiInstallMethod ( ParserState.Aml += AcpiPsGetOpcodeSize (Opcode); ParserState.PkgEnd = AcpiPsGetNextPackageEnd (&ParserState); Path = AcpiPsGetNextNamestring (&ParserState); + MethodFlags = *ParserState.Aml++; AmlStart = ParserState.Aml; AmlLength = ACPI_PTR_DIFF (ParserState.PkgEnd, AmlStart); @@ -662,7 +670,7 @@ AcpiInstallMethod ( /* The lookup either returns an existing node or creates a new one */ Status = AcpiNsLookup (NULL, Path, ACPI_TYPE_METHOD, ACPI_IMODE_LOAD_PASS1, - ACPI_NS_DONT_OPEN_SCOPE | ACPI_NS_ERROR_IF_FOUND, NULL, &Node); + ACPI_NS_DONT_OPEN_SCOPE | ACPI_NS_ERROR_IF_FOUND, NULL, &Node); (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); @@ -684,7 +692,7 @@ AcpiInstallMethod ( /* Copy the method AML to the local buffer */ - ACPI_MEMCPY (AmlBuffer, AmlStart, AmlLength); + memcpy (AmlBuffer, AmlStart, AmlLength); /* Initialize the method object with the new method's information */ diff --git a/sys/contrib/dev/acpica/components/namespace/nsxfobj.c b/sys/contrib/dev/acpica/components/namespace/nsxfobj.c index 2481e7a..81a4756 100644 --- a/sys/contrib/dev/acpica/components/namespace/nsxfobj.c +++ b/sys/contrib/dev/acpica/components/namespace/nsxfobj.c @@ -6,7 +6,7 @@ ******************************************************************************/ /* - * Copyright (C) 2000 - 2015, Intel Corp. + * Copyright (C) 2000 - 2016, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -81,10 +81,8 @@ AcpiGetType ( return (AE_BAD_PARAMETER); } - /* - * Special case for the predefined Root Node - * (return type ANY) - */ + /* Special case for the predefined Root Node (return type ANY) */ + if (Handle == ACPI_ROOT_OBJECT) { *RetType = ACPI_TYPE_ANY; @@ -108,7 +106,6 @@ AcpiGetType ( *RetType = Node->Type; - Status = AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); return (Status); } |