status_t ns_handle_to_pathname(acpi_handle targetHandle, acpi_data *buffer) { status_t status = AcpiNsHandleToPathname(targetHandle, (ACPI_BUFFER*)buffer, false); return status == AE_OK ? B_OK : B_ERROR; }
ACPI_STATUS AcpiNsDumpPathname ( ACPI_HANDLE Handle, NATIVE_CHAR *Msg, UINT32 Level, UINT32 Component) { ACPI_BUFFER Buffer; ACPI_STATUS Status; ACPI_FUNCTION_TRACE ("NsDumpPathname"); /* Do this only if the requested debug level and component are enabled */ if (!(AcpiDbgLevel & Level) || !(AcpiDbgLayer & Component)) { return_ACPI_STATUS (AE_OK); } /* Convert handle to a full pathname and print it (with supplied message) */ Buffer.Length = ACPI_ALLOCATE_LOCAL_BUFFER; Status = AcpiNsHandleToPathname (Handle, &Buffer); if (ACPI_SUCCESS (Status)) { AcpiOsPrintf ("%s %s (Node %p)\n", Msg, (char *) Buffer.Pointer, Handle); ACPI_MEM_FREE (Buffer.Pointer); } return_ACPI_STATUS (Status); }
void AcpiNsPrintNodePathname ( ACPI_NAMESPACE_NODE *Node, const char *Message) { ACPI_BUFFER Buffer; ACPI_STATUS Status; if (!Node) { AcpiOsPrintf ("[NULL NAME]"); return; } /* Convert handle to full pathname and print it (with supplied message) */ Buffer.Length = ACPI_ALLOCATE_LOCAL_BUFFER; Status = AcpiNsHandleToPathname (Node, &Buffer, TRUE); if (ACPI_SUCCESS (Status)) { if (Message) { AcpiOsPrintf ("%s ", Message); } AcpiOsPrintf ("%s", (char *) Buffer.Pointer); ACPI_FREE (Buffer.Pointer); } }
static ACPI_STATUS AcpiDbWalkForSpecificObjects ( ACPI_HANDLE ObjHandle, UINT32 NestingLevel, void *Context, void **ReturnValue) { ACPI_WALK_INFO *Info = (ACPI_WALK_INFO *) Context; ACPI_BUFFER Buffer; ACPI_STATUS Status; Info->Count++; /* Get and display the full pathname to this object */ Buffer.Length = ACPI_ALLOCATE_LOCAL_BUFFER; Status = AcpiNsHandleToPathname (ObjHandle, &Buffer, FALSE); if (ACPI_FAILURE (Status)) { AcpiOsPrintf ("Could Not get pathname for object %p\n", ObjHandle); return (AE_OK); } AcpiOsPrintf ("%32s", (char *) Buffer.Pointer); ACPI_FREE (Buffer.Pointer); /* Dump short info about the object */ (void) AcpiNsDumpOneObject (ObjHandle, NestingLevel, Info, NULL); return (AE_OK); }
void AcpiUtDisplayInitPathname ( ACPI_HANDLE ObjHandle, char *Path) { ACPI_STATUS Status; UINT32 Length = 128; char Buffer[128]; PROC_NAME ("UtDisplayInitPathname"); Status = AcpiNsHandleToPathname (ObjHandle, &Length, Buffer); if (ACPI_SUCCESS (Status)) { if (Path) { ACPI_DEBUG_PRINT ((ACPI_DB_INIT, "%s.%s\n", Buffer, Path)); } else { ACPI_DEBUG_PRINT ((ACPI_DB_INIT, "%s\n", Buffer)); } } }
void AcpiUtDisplayInitPathname ( UINT8 Type, ACPI_NAMESPACE_NODE *ObjHandle, char *Path) { ACPI_STATUS Status; ACPI_BUFFER Buffer; ACPI_FUNCTION_ENTRY (); /* Only print the path if the appropriate debug level is enabled */ if (!(AcpiDbgLevel & ACPI_LV_INIT_NAMES)) { return; } /* Get the full pathname to the node */ Buffer.Length = ACPI_ALLOCATE_LOCAL_BUFFER; Status = AcpiNsHandleToPathname (ObjHandle, &Buffer); if (ACPI_FAILURE (Status)) { return; } /* Print what we're doing */ switch (Type) { case ACPI_TYPE_METHOD: AcpiOsPrintf ("Executing "); break; default: AcpiOsPrintf ("Initializing "); break; } /* Print the object type and pathname */ AcpiOsPrintf ("%-12s %s", AcpiUtGetTypeName (Type), (char *) Buffer.Pointer); /* Extra path is used to append names like _STA, _INI, etc. */ if (Path) { AcpiOsPrintf (".%s", Path); } AcpiOsPrintf ("\n"); ACPI_FREE (Buffer.Pointer); }
static void globalGPEHandler(UINT32 eventType, ACPI_HANDLE device, UINT32 eventNumber, void* context) { ACPI_BUFFER path; char deviceName[256]; path.Length = sizeof(deviceName); path.Pointer = deviceName; ACPI_STATUS status = AcpiNsHandleToPathname(device, &path); if (ACPI_FAILURE(status)) strcpy(deviceName, "(missing)"); switch (eventType) { case ACPI_EVENT_TYPE_GPE: dprintf("acpi: GPE Event %d for %s\n", eventNumber, deviceName); break; case ACPI_EVENT_TYPE_FIXED: { switch (eventNumber) { case ACPI_EVENT_PMTIMER: dprintf("acpi: PMTIMER(%d) event for %s\n", eventNumber, deviceName); break; case ACPI_EVENT_GLOBAL: dprintf("acpi: Global(%d) event for %s\n", eventNumber, deviceName); break; case ACPI_EVENT_POWER_BUTTON: dprintf("acpi: Powerbutton(%d) event for %s\n", eventNumber, deviceName); break; case ACPI_EVENT_SLEEP_BUTTON: dprintf("acpi: sleepbutton(%d) event for %s\n", eventNumber, deviceName); break; case ACPI_EVENT_RTC: dprintf("acpi: RTC(%d) event for %s\n", eventNumber, deviceName); break; default: dprintf("acpi: unknown fixed(%d) event for %s\n", eventNumber, deviceName); } break; } default: dprintf("acpi: unknown event type (%d:%d) event for %s\n", eventType, eventNumber, deviceName); } }
static ACPI_STATUS AcpiDbWalkAndMatchName ( ACPI_HANDLE ObjHandle, UINT32 NestingLevel, void *Context, void **ReturnValue) { ACPI_STATUS Status; char *RequestedName = (char *) Context; UINT32 i; ACPI_BUFFER Buffer; ACPI_WALK_INFO Info; /* Check for a name match */ for (i = 0; i < 4; i++) { /* Wildcard support */ if ((RequestedName[i] != '?') && (RequestedName[i] != ((ACPI_NAMESPACE_NODE *) ObjHandle)->Name.Ascii[i])) { /* No match, just exit */ return (AE_OK); } } /* Get the full pathname to this object */ Buffer.Length = ACPI_ALLOCATE_LOCAL_BUFFER; Status = AcpiNsHandleToPathname (ObjHandle, &Buffer, TRUE); if (ACPI_FAILURE (Status)) { AcpiOsPrintf ("Could Not get pathname for object %p\n", ObjHandle); } else { Info.Count = 0; Info.OwnerId = ACPI_OWNER_ID_MAX; Info.DebugLevel = ACPI_UINT32_MAX; Info.DisplayType = ACPI_DISPLAY_SUMMARY | ACPI_DISPLAY_SHORT; AcpiOsPrintf ("%32s", (char *) Buffer.Pointer); (void) AcpiNsDumpOneObject (ObjHandle, NestingLevel, &Info, NULL); ACPI_FREE (Buffer.Pointer); } return (AE_OK); }
static void globalNotifyHandler(ACPI_HANDLE device, UINT32 value, void* context) { ACPI_BUFFER path; char deviceName[256]; path.Length = sizeof(deviceName); path.Pointer = deviceName; ACPI_STATUS status = AcpiNsHandleToPathname(device, &path); if (ACPI_FAILURE(status)) strcpy(deviceName, "(missing)"); dprintf("acpi: Notify event %d for %s\n", value, deviceName); }
static void LsEmitOffsetTableEntry ( UINT32 FileId, ACPI_NAMESPACE_NODE *Node, UINT32 NamepathOffset, UINT32 Offset, char *OpName, UINT64 Value, UINT8 AmlOpcode, UINT16 ParentOpcode) { ACPI_BUFFER TargetPath; ACPI_STATUS Status; /* Get the full pathname to the namespace node */ TargetPath.Length = ACPI_ALLOCATE_LOCAL_BUFFER; Status = AcpiNsHandleToPathname (Node, &TargetPath, FALSE); if (ACPI_FAILURE (Status)) { return; } /* [1] - Skip the opening backslash for the path */ strcpy (MsgBuffer, "\""); strcat (MsgBuffer, &((char *) TargetPath.Pointer)[1]); strcat (MsgBuffer, "\","); ACPI_FREE (TargetPath.Pointer); /* * Max offset is 4G, constrained by 32-bit ACPI table length. * Max Length for Integers is 8 bytes. */ FlPrintFile (FileId, " {%-29s 0x%4.4X, 0x%8.8X, 0x%2.2X, 0x%8.8X, 0x%8.8X%8.8X}, /* %s */\n", MsgBuffer, ParentOpcode, NamepathOffset, AmlOpcode, Offset, ACPI_FORMAT_UINT64 (Value), OpName); }
ACPI_STATUS AcpiNsDumpPathname ( ACPI_HANDLE Handle, NATIVE_CHAR *Msg, UINT32 Level, UINT32 Component) { NATIVE_CHAR *Buffer; UINT32 Length; FUNCTION_TRACE ("NsDumpPathname"); /* Do this only if the requested debug level and component are enabled */ if (!(AcpiDbgLevel & Level) || !(AcpiDbgLayer & Component)) { return_ACPI_STATUS (AE_OK); } Buffer = ACPI_MEM_ALLOCATE (PATHNAME_MAX); if (!Buffer) { return_ACPI_STATUS (AE_NO_MEMORY); } /* Convert handle to a full pathname and print it (with supplied message) */ Length = PATHNAME_MAX; if (ACPI_SUCCESS (AcpiNsHandleToPathname (Handle, &Length, Buffer))) { AcpiOsPrintf ("%s %s (%p)\n", Msg, Buffer, Handle); } ACPI_MEM_FREE (Buffer); return_ACPI_STATUS (AE_OK); }
static ACPI_STATUS NsDoOnePathname ( ACPI_HANDLE ObjHandle, UINT32 Level, void *Context, void **ReturnValue) { ACPI_NAMESPACE_NODE *Node = (ACPI_NAMESPACE_NODE *) ObjHandle; ACPI_STATUS Status; ACPI_BUFFER TargetPath; TargetPath.Length = ACPI_ALLOCATE_LOCAL_BUFFER; Status = AcpiNsHandleToPathname (Node, &TargetPath, FALSE); if (ACPI_FAILURE (Status)) { return (Status); } FlPrintFile (ASL_FILE_NAMESPACE_OUTPUT, "%s\n", TargetPath.Pointer); ACPI_FREE (TargetPath.Pointer); return (AE_OK); }
static ACPI_STATUS AcpiDbBusWalk ( ACPI_HANDLE ObjHandle, UINT32 NestingLevel, void *Context, void **ReturnValue) { ACPI_NAMESPACE_NODE *Node = (ACPI_NAMESPACE_NODE *) ObjHandle; ACPI_STATUS Status; ACPI_BUFFER Buffer; ACPI_NAMESPACE_NODE *TempNode; ACPI_DEVICE_INFO *Info; UINT32 i; if ((Node->Type != ACPI_TYPE_DEVICE) && (Node->Type != ACPI_TYPE_PROCESSOR)) { return (AE_OK); } /* Exit if there is no _PRT under this device */ Status = AcpiGetHandle (Node, METHOD_NAME__PRT, ACPI_CAST_PTR (ACPI_HANDLE, &TempNode)); if (ACPI_FAILURE (Status)) { return (AE_OK); } /* Get the full path to this device object */ Buffer.Length = ACPI_ALLOCATE_LOCAL_BUFFER; Status = AcpiNsHandleToPathname (ObjHandle, &Buffer, FALSE); if (ACPI_FAILURE (Status)) { AcpiOsPrintf ("Could Not get pathname for object %p\n", ObjHandle); return (AE_OK); } Status = AcpiGetObjectInfo (ObjHandle, &Info); if (ACPI_FAILURE (Status)) { return (AE_OK); } /* Display the full path */ AcpiOsPrintf ("%-32s Type %X", (char *) Buffer.Pointer, Node->Type); ACPI_FREE (Buffer.Pointer); if (Info->Flags & ACPI_PCI_ROOT_BRIDGE) { AcpiOsPrintf (" - Is PCI Root Bridge"); } AcpiOsPrintf ("\n"); /* _PRT info */ AcpiOsPrintf ("_PRT: %p\n", TempNode); /* Dump _ADR, _HID, _UID, _CID */ if (Info->Valid & ACPI_VALID_ADR) { AcpiOsPrintf ("_ADR: %8.8X%8.8X\n", ACPI_FORMAT_UINT64 (Info->Address)); } else { AcpiOsPrintf ("_ADR: <Not Present>\n"); } if (Info->Valid & ACPI_VALID_HID) { AcpiOsPrintf ("_HID: %s\n", Info->HardwareId.String); } else { AcpiOsPrintf ("_HID: <Not Present>\n"); } if (Info->Valid & ACPI_VALID_UID) { AcpiOsPrintf ("_UID: %s\n", Info->UniqueId.String); } else { AcpiOsPrintf ("_UID: <Not Present>\n"); } if (Info->Valid & ACPI_VALID_CID) { for (i = 0; i < Info->CompatibleIdList.Count; i++) { AcpiOsPrintf ("_CID: %s\n", Info->CompatibleIdList.Ids[i].String); } } else { AcpiOsPrintf ("_CID: <Not Present>\n"); } ACPI_FREE (Info); return (AE_OK); }
ACPI_STATUS AcpiGetName ( ACPI_HANDLE Handle, UINT32 NameType, ACPI_BUFFER *RetPathPtr) { ACPI_STATUS Status; ACPI_NAMESPACE_NODE *Node; /* Ensure that ACPI has been initialized */ ACPI_IS_INITIALIZATION_COMPLETE (Status); if (ACPI_FAILURE (Status)) { return (Status); } /* Buffer pointer must be valid always */ if (!RetPathPtr || (NameType > ACPI_NAME_TYPE_MAX)) { return (AE_BAD_PARAMETER); } /* Allow length to be zero and ignore the pointer */ if ((RetPathPtr->Length) && (!RetPathPtr->Pointer)) { return (AE_BAD_PARAMETER); } if (NameType == ACPI_FULL_PATHNAME) { /* Get the full pathname (From the namespace root) */ Status = AcpiNsHandleToPathname (Handle, &RetPathPtr->Length, RetPathPtr->Pointer); return (Status); } /* * Wants the single segment ACPI name. * Validate handle and convert to an Node */ AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE); Node = AcpiNsConvertHandleToEntry (Handle); if (!Node) { Status = AE_BAD_PARAMETER; goto UnlockAndExit; } /* Check if name will fit in buffer */ if (RetPathPtr->Length < PATH_SEGMENT_LENGTH) { RetPathPtr->Length = PATH_SEGMENT_LENGTH; Status = AE_BUFFER_OVERFLOW; goto UnlockAndExit; } /* Just copy the ACPI name from the Node and zero terminate it */ STRNCPY (RetPathPtr->Pointer, (NATIVE_CHAR *) &Node->Name, ACPI_NAME_SIZE); ((NATIVE_CHAR *) RetPathPtr->Pointer) [ACPI_NAME_SIZE] = 0; Status = AE_OK; UnlockAndExit: AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); return (Status); }
ACPI_STATUS AcpiPsDisplayObjectPathname ( ACPI_WALK_STATE *WalkState, ACPI_PARSE_OBJECT *Op) { ACPI_STATUS Status; ACPI_NAMESPACE_NODE *Node; ACPI_BUFFER Buffer; UINT32 DebugLevel; /* Save current debug level so we don't get extraneous debug output */ DebugLevel = AcpiDbgLevel; AcpiDbgLevel = 0; /* Just get the Node out of the Op object */ Node = Op->Common.Node; if (!Node) { /* Node not defined in this scope, look it up */ Status = AcpiNsLookup (WalkState->ScopeInfo, Op->Common.Value.String, ACPI_TYPE_ANY, ACPI_IMODE_EXECUTE, ACPI_NS_SEARCH_PARENT, WalkState, &(Node)); if (ACPI_FAILURE (Status)) { /* * We can't get the pathname since the object * is not in the namespace. This can happen during single * stepping where a dynamic named object is *about* to be created. */ AcpiOsPrintf (" [Path not found]"); goto Exit; } /* Save it for next time. */ Op->Common.Node = Node; } /* Convert NamedDesc/handle to a full pathname */ Buffer.Length = ACPI_ALLOCATE_LOCAL_BUFFER; Status = AcpiNsHandleToPathname (Node, &Buffer); if (ACPI_FAILURE (Status)) { AcpiOsPrintf ("****Could not get pathname****)"); goto Exit; } AcpiOsPrintf (" (Path %s)", (char *) Buffer.Pointer); ACPI_FREE (Buffer.Pointer); Exit: /* Restore the debug level */ AcpiDbgLevel = DebugLevel; return (Status); }
void OptOptimizeNamePath ( ACPI_PARSE_OBJECT *Op, UINT32 Flags, ACPI_WALK_STATE *WalkState, char *AmlNameString, ACPI_NAMESPACE_NODE *TargetNode) { ACPI_STATUS Status; ACPI_BUFFER TargetPath; ACPI_BUFFER CurrentPath; ACPI_SIZE AmlNameStringLength; ACPI_NAMESPACE_NODE *CurrentNode; char *ExternalNameString; char *NewPath = NULL; ACPI_SIZE HowMuchShorter; ACPI_PARSE_OBJECT *NextOp; ACPI_FUNCTION_TRACE (OptOptimizeNamePath); /* This is an optional optimization */ if (!Gbl_ReferenceOptimizationFlag) { return_VOID; } /* Various required items */ if (!TargetNode || !WalkState || !AmlNameString || !Op->Common.Parent) { return_VOID; } 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))); if (!(Flags & (AML_NAMED | AML_CREATE))) { if (Op->Asl.CompileFlags & NODE_IS_NAME_DECLARATION) { /* We don't want to fuss with actual name declaration nodes here */ ACPI_DEBUG_PRINT_RAW ((ACPI_DB_OPTIMIZATIONS, "******* NAME DECLARATION\n")); return_VOID; } } /* * The original path must be longer than one NameSeg (4 chars) for there * to be any possibility that it can be optimized to a shorter string */ AmlNameStringLength = strlen (AmlNameString); if (AmlNameStringLength <= ACPI_NAME_SIZE) { ACPI_DEBUG_PRINT_RAW ((ACPI_DB_OPTIMIZATIONS, "NAMESEG %4.4s\n", AmlNameString)); return_VOID; } /* * We need to obtain the node that represents the current scope -- where * we are right now in the namespace. We will compare this path * against the Namepath, looking for commonality. */ CurrentNode = AcpiGbl_RootNode; if (WalkState->ScopeInfo) { CurrentNode = WalkState->ScopeInfo->Scope.Node; } if (Flags & (AML_NAMED | AML_CREATE)) { /* This is the declaration of a new name */ ACPI_DEBUG_PRINT_RAW ((ACPI_DB_OPTIMIZATIONS, "NAME\n")); /* * The node of interest is the parent of this node (the containing * scope). The actual namespace node may be up more than one level * of parse op or it may not exist at all (if we traverse back * up to the root.) */ NextOp = Op->Asl.Parent; while (NextOp && (!NextOp->Asl.Node)) { NextOp = NextOp->Asl.Parent; } if (NextOp && NextOp->Asl.Node) { CurrentNode = NextOp->Asl.Node; } else { CurrentNode = AcpiGbl_RootNode; } } else { /* This is a reference to an existing named object */ ACPI_DEBUG_PRINT_RAW ((ACPI_DB_OPTIMIZATIONS, "REFERENCE\n")); } /* * Obtain the full paths to the two nodes that we are interested in * (Target and current namespace location) in external * format -- something we can easily manipulate */ TargetPath.Length = ACPI_ALLOCATE_LOCAL_BUFFER; Status = AcpiNsHandleToPathname (TargetNode, &TargetPath, FALSE); if (ACPI_FAILURE (Status)) { AslCoreSubsystemError (Op, Status, "Getting Target NamePath", ASL_NO_ABORT); return_VOID; } TargetPath.Length--; /* Subtract one for null terminator */ /* CurrentPath is the path to this scope (where we are in the namespace) */ CurrentPath.Length = ACPI_ALLOCATE_LOCAL_BUFFER; Status = AcpiNsHandleToPathname (CurrentNode, &CurrentPath, FALSE); if (ACPI_FAILURE (Status)) { AslCoreSubsystemError (Op, Status, "Getting Current NamePath", ASL_NO_ABORT); return_VOID; } CurrentPath.Length--; /* Subtract one for null terminator */ /* Debug output only */ Status = AcpiNsExternalizeName (ACPI_UINT32_MAX, AmlNameString, NULL, &ExternalNameString); if (ACPI_FAILURE (Status)) { AslCoreSubsystemError (Op, Status, "Externalizing NamePath", ASL_NO_ABORT); return_VOID; } ACPI_DEBUG_PRINT_RAW ((ACPI_DB_OPTIMIZATIONS, "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); /* * Attempt an optmization depending on the type of namepath */ if (Flags & (AML_NAMED | AML_CREATE)) { /* * This is a named opcode and the namepath is a name declaration, not * a reference. */ Status = OptOptimizeNameDeclaration (Op, WalkState, CurrentNode, TargetNode, AmlNameString, &NewPath); if (ACPI_FAILURE (Status)) { /* * 2) now attempt to * optimize the namestring with carats (up-arrow) */ Status = OptBuildShortestPath (Op, WalkState, CurrentNode, TargetNode, &CurrentPath, &TargetPath, AmlNameStringLength, 1, &NewPath); } } else { /* * This is a reference to an existing named object * * 1) Check if search-to-root can be utilized using the last * NameSeg of the NamePath */ Status = OptSearchToRoot (Op, WalkState, CurrentNode, TargetNode, &TargetPath, &NewPath); if (ACPI_FAILURE (Status)) { /* * 2) Search-to-root could not be used, now attempt to * optimize the namestring with carats (up-arrow) */ Status = OptBuildShortestPath (Op, WalkState, CurrentNode, TargetNode, &CurrentPath, &TargetPath, AmlNameStringLength, 0, &NewPath); } } /* * Success from above indicates that the NamePath was successfully * optimized. We need to update the parse op with the new name */ if (ACPI_SUCCESS (Status)) { HowMuchShorter = (AmlNameStringLength - strlen (NewPath)); OptTotal += HowMuchShorter; ACPI_DEBUG_PRINT_RAW ((ACPI_DB_OPTIMIZATIONS, " REDUCED BY %2u (TOTAL SAVED %2u)", (UINT32) HowMuchShorter, OptTotal)); if (Flags & AML_NAMED) { if (Op->Asl.AmlOpcode == AML_ALIAS_OP) { /* * ALIAS is the only oddball opcode, the name declaration * (alias name) is the second operand */ Op->Asl.Child->Asl.Next->Asl.Value.String = NewPath; Op->Asl.Child->Asl.Next->Asl.AmlLength = strlen (NewPath); } else { Op->Asl.Child->Asl.Value.String = NewPath; Op->Asl.Child->Asl.AmlLength = strlen (NewPath); } } else if (Flags & AML_CREATE) { /* Name must appear as the last parameter */ NextOp = Op->Asl.Child; while (!(NextOp->Asl.CompileFlags & NODE_IS_NAME_DECLARATION)) { NextOp = NextOp->Asl.Next; } /* Update the parse node with the new NamePath */ NextOp->Asl.Value.String = NewPath; NextOp->Asl.AmlLength = strlen (NewPath); } else { /* Update the parse node with the new NamePath */ Op->Asl.Value.String = NewPath; Op->Asl.AmlLength = strlen (NewPath); } } else { ACPI_DEBUG_PRINT_RAW ((ACPI_DB_OPTIMIZATIONS, " ALREADY OPTIMAL")); } /* Cleanup path buffers */ ACPI_FREE (TargetPath.Pointer); ACPI_FREE (CurrentPath.Pointer); ACPI_DEBUG_PRINT_RAW ((ACPI_DB_OPTIMIZATIONS, "\n")); return_VOID; }
ACPI_STATUS AcpiRsCreatePciRoutingTable ( ACPI_OPERAND_OBJECT *PackageObject, ACPI_BUFFER *OutputBuffer) { UINT8 *Buffer; ACPI_OPERAND_OBJECT **TopObjectList; ACPI_OPERAND_OBJECT **SubObjectList; ACPI_OPERAND_OBJECT *ObjDesc; ACPI_SIZE BufferSizeNeeded = 0; UINT32 NumberOfElements; UINT32 Index; ACPI_PCI_ROUTING_TABLE *UserPrt; ACPI_NAMESPACE_NODE *Node; ACPI_STATUS Status; ACPI_BUFFER PathBuffer; ACPI_FUNCTION_TRACE (RsCreatePciRoutingTable); /* Params already validated, so we don't re-validate here */ /* Get the required buffer length */ Status = AcpiRsGetPciRoutingTableLength (PackageObject, &BufferSizeNeeded); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); } ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "BufferSizeNeeded = %X\n", (UINT32) BufferSizeNeeded)); /* Validate/Allocate/Clear caller buffer */ Status = AcpiUtInitializeBuffer (OutputBuffer, BufferSizeNeeded); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); } /* * Loop through the ACPI_INTERNAL_OBJECTS - Each object should be a * package that in turn contains an UINT64 Address, a UINT8 Pin, * a Name, and a UINT8 SourceIndex. */ TopObjectList = PackageObject->Package.Elements; NumberOfElements = PackageObject->Package.Count; Buffer = OutputBuffer->Pointer; UserPrt = ACPI_CAST_PTR (ACPI_PCI_ROUTING_TABLE, Buffer); for (Index = 0; Index < NumberOfElements; Index++) { /* * Point UserPrt past this current structure * * NOTE: On the first iteration, UserPrt->Length will * be zero because we cleared the return buffer earlier */ Buffer += UserPrt->Length; UserPrt = ACPI_CAST_PTR (ACPI_PCI_ROUTING_TABLE, Buffer); /* * Fill in the Length field with the information we have at this point. * The minus four is to subtract the size of the UINT8 Source[4] member * because it is added below. */ UserPrt->Length = (sizeof (ACPI_PCI_ROUTING_TABLE) - 4); /* Each element of the top-level package must also be a package */ if ((*TopObjectList)->Common.Type != ACPI_TYPE_PACKAGE) { ACPI_ERROR ((AE_INFO, "(PRT[%u]) Need sub-package, found %s", Index, AcpiUtGetObjectTypeName (*TopObjectList))); return_ACPI_STATUS (AE_AML_OPERAND_TYPE); } /* Each sub-package must be of length 4 */ if ((*TopObjectList)->Package.Count != 4) { ACPI_ERROR ((AE_INFO, "(PRT[%u]) Need package of length 4, found length %u", Index, (*TopObjectList)->Package.Count)); return_ACPI_STATUS (AE_AML_PACKAGE_LIMIT); } /* * Dereference the sub-package. * The SubObjectList will now point to an array of the four IRQ * elements: [Address, Pin, Source, SourceIndex] */ SubObjectList = (*TopObjectList)->Package.Elements; /* 1) First subobject: Dereference the PRT.Address */ ObjDesc = SubObjectList[0]; if (ObjDesc->Common.Type != ACPI_TYPE_INTEGER) { ACPI_ERROR ((AE_INFO, "(PRT[%u].Address) Need Integer, found %s", Index, AcpiUtGetObjectTypeName (ObjDesc))); return_ACPI_STATUS (AE_BAD_DATA); } UserPrt->Address = ObjDesc->Integer.Value; /* 2) Second subobject: Dereference the PRT.Pin */ ObjDesc = SubObjectList[1]; if (ObjDesc->Common.Type != ACPI_TYPE_INTEGER) { ACPI_ERROR ((AE_INFO, "(PRT[%u].Pin) Need Integer, found %s", Index, AcpiUtGetObjectTypeName (ObjDesc))); return_ACPI_STATUS (AE_BAD_DATA); } UserPrt->Pin = (UINT32) ObjDesc->Integer.Value; /* * If the BIOS has erroneously reversed the _PRT SourceName (index 2) * and the SourceIndex (index 3), fix it. _PRT is important enough to * workaround this BIOS error. This also provides compatibility with * other ACPI implementations. */ ObjDesc = SubObjectList[3]; if (!ObjDesc || (ObjDesc->Common.Type != ACPI_TYPE_INTEGER)) { SubObjectList[3] = SubObjectList[2]; SubObjectList[2] = ObjDesc; ACPI_WARNING ((AE_INFO, "(PRT[%X].Source) SourceName and SourceIndex are reversed, fixed", Index)); } /* * 3) Third subobject: Dereference the PRT.SourceName * The name may be unresolved (slack mode), so allow a null object */ ObjDesc = SubObjectList[2]; if (ObjDesc) { switch (ObjDesc->Common.Type) { case ACPI_TYPE_LOCAL_REFERENCE: if (ObjDesc->Reference.Class != ACPI_REFCLASS_NAME) { ACPI_ERROR ((AE_INFO, "(PRT[%u].Source) Need name, found Reference Class 0x%X", Index, ObjDesc->Reference.Class)); return_ACPI_STATUS (AE_BAD_DATA); } Node = ObjDesc->Reference.Node; /* Use *remaining* length of the buffer as max for pathname */ PathBuffer.Length = OutputBuffer->Length - (UINT32) ((UINT8 *) UserPrt->Source - (UINT8 *) OutputBuffer->Pointer); PathBuffer.Pointer = UserPrt->Source; Status = AcpiNsHandleToPathname ((ACPI_HANDLE) Node, &PathBuffer); /* +1 to include null terminator */ UserPrt->Length += (UINT32) ACPI_STRLEN (UserPrt->Source) + 1; break; case ACPI_TYPE_STRING: ACPI_STRCPY (UserPrt->Source, ObjDesc->String.Pointer); /* * Add to the Length field the length of the string * (add 1 for terminator) */ UserPrt->Length += ObjDesc->String.Length + 1; break; case ACPI_TYPE_INTEGER: /* * If this is a number, then the Source Name is NULL, since the * entire buffer was zeroed out, we can leave this alone. * * Add to the Length field the length of the UINT32 NULL */ UserPrt->Length += sizeof (UINT32); break; default: ACPI_ERROR ((AE_INFO, "(PRT[%u].Source) Need Ref/String/Integer, found %s", Index, AcpiUtGetObjectTypeName (ObjDesc))); return_ACPI_STATUS (AE_BAD_DATA); } } /* Now align the current length */ UserPrt->Length = (UINT32) ACPI_ROUND_UP_TO_64BIT (UserPrt->Length); /* 4) Fourth subobject: Dereference the PRT.SourceIndex */ ObjDesc = SubObjectList[3]; if (ObjDesc->Common.Type != ACPI_TYPE_INTEGER) { ACPI_ERROR ((AE_INFO, "(PRT[%u].SourceIndex) Need Integer, found %s", Index, AcpiUtGetObjectTypeName (ObjDesc))); return_ACPI_STATUS (AE_BAD_DATA); } UserPrt->SourceIndex = (UINT32) ObjDesc->Integer.Value; /* Point to the next ACPI_OPERAND_OBJECT in the top level package */ TopObjectList++; } ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "OutputBuffer %p Length %X\n", OutputBuffer->Pointer, (UINT32) OutputBuffer->Length)); return_ACPI_STATUS (AE_OK); }
ACPI_STATUS AcpiGetName ( ACPI_HANDLE Handle, UINT32 NameType, ACPI_BUFFER *Buffer) { ACPI_STATUS Status; ACPI_NAMESPACE_NODE *Node; /* Parameter validation */ if (NameType > ACPI_NAME_TYPE_MAX) { return (AE_BAD_PARAMETER); } Status = AcpiUtValidateBuffer (Buffer); if (ACPI_FAILURE (Status)) { return (Status); } if (NameType == ACPI_FULL_PATHNAME) { /* Get the full pathname (From the namespace root) */ Status = AcpiNsHandleToPathname (Handle, Buffer); return (Status); } /* * Wants the single segment ACPI name. * Validate handle and convert to a namespace Node */ Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE); if (ACPI_FAILURE (Status)) { return (Status); } Node = AcpiNsMapHandleToNode (Handle); if (!Node) { Status = AE_BAD_PARAMETER; goto UnlockAndExit; } /* Validate/Allocate/Clear caller buffer */ Status = AcpiUtInitializeBuffer (Buffer, ACPI_PATH_SEGMENT_LENGTH); if (ACPI_FAILURE (Status)) { goto UnlockAndExit; } /* Just copy the ACPI name from the Node and zero terminate it */ ACPI_STRNCPY (Buffer->Pointer, AcpiUtGetNodeName (Node), ACPI_NAME_SIZE); ((char *) Buffer->Pointer) [ACPI_NAME_SIZE] = 0; Status = AE_OK; UnlockAndExit: (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); return (Status); }