From 8e7a8753827660c3dd1f571f3185610402b756f0 Mon Sep 17 00:00:00 2001 From: Robert Moore Date: Wed, 17 Oct 2012 10:24:40 -0700 Subject: [PATCH] AcpiGetObjectInfo: Add support for ACPI 5.0 _SUB method. Now calls _SUB in addition to the other ID methods: _HID, _CID, and _UID. --- source/components/debugger/dbdisply.c | 49 ++++++++++++------ source/components/namespace/nsxfname.c | 32 ++++++++++-- source/components/utilities/utids.c | 71 ++++++++++++++++++++++++++ source/include/acnames.h | 1 + source/include/actypes.h | 12 +++-- source/include/acutils.h | 5 ++ source/tools/acpinames/anstubs.c | 8 +++ 7 files changed, 151 insertions(+), 27 deletions(-) diff --git a/source/components/debugger/dbdisply.c b/source/components/debugger/dbdisply.c index dc94d415d..aea5c2e4d 100644 --- a/source/components/debugger/dbdisply.c +++ b/source/components/debugger/dbdisply.c @@ -715,7 +715,7 @@ AcpiDbDisplayCallingTree ( * * FUNCTION: AcpiDbDisplayObjectType * - * PARAMETERS: ObjectArg - User entered NS node handle + * PARAMETERS: Name - User entered NS node handle or name * * RETURN: None * @@ -725,17 +725,21 @@ AcpiDbDisplayCallingTree ( void AcpiDbDisplayObjectType ( - char *ObjectArg) + char *Name) { - ACPI_HANDLE Handle; + ACPI_NAMESPACE_NODE *Node; ACPI_DEVICE_INFO *Info; ACPI_STATUS Status; UINT32 i; - Handle = ACPI_TO_POINTER (ACPI_STRTOUL (ObjectArg, NULL, 16)); + Node = AcpiDbConvertToNode (Name); + if (!Node) + { + return; + } - Status = AcpiGetObjectInfo (Handle, &Info); + Status = AcpiGetObjectInfo (ACPI_CAST_PTR (ACPI_HANDLE, Node), &Info); if (ACPI_FAILURE (Status)) { AcpiOsPrintf ("Could not get object info, %s\n", @@ -743,18 +747,25 @@ AcpiDbDisplayObjectType ( return; } - AcpiOsPrintf ("ADR: %8.8X%8.8X, STA: %8.8X, Flags: %X\n", - ACPI_FORMAT_UINT64 (Info->Address), - Info->CurrentStatus, Info->Flags); - - AcpiOsPrintf ("S1D-%2.2X S2D-%2.2X S3D-%2.2X S4D-%2.2X\n", - Info->HighestDstates[0], Info->HighestDstates[1], - Info->HighestDstates[2], Info->HighestDstates[3]); - - AcpiOsPrintf ("S0W-%2.2X S1W-%2.2X S2W-%2.2X S3W-%2.2X S4W-%2.2X\n", - Info->LowestDstates[0], Info->LowestDstates[1], - Info->LowestDstates[2], Info->LowestDstates[3], - Info->LowestDstates[4]); + if (Info->Valid & ACPI_VALID_ADR) + { + AcpiOsPrintf ("ADR: %8.8X%8.8X, STA: %8.8X, Flags: %X\n", + ACPI_FORMAT_UINT64 (Info->Address), + Info->CurrentStatus, Info->Flags); + } + if (Info->Valid & ACPI_VALID_SXDS) + { + AcpiOsPrintf ("S1D-%2.2X S2D-%2.2X S3D-%2.2X S4D-%2.2X\n", + Info->HighestDstates[0], Info->HighestDstates[1], + Info->HighestDstates[2], Info->HighestDstates[3]); + } + if (Info->Valid & ACPI_VALID_SXWS) + { + AcpiOsPrintf ("S0W-%2.2X S1W-%2.2X S2W-%2.2X S3W-%2.2X S4W-%2.2X\n", + Info->LowestDstates[0], Info->LowestDstates[1], + Info->LowestDstates[2], Info->LowestDstates[3], + Info->LowestDstates[4]); + } if (Info->Valid & ACPI_VALID_HID) { @@ -764,6 +775,10 @@ AcpiDbDisplayObjectType ( { AcpiOsPrintf ("UID: %s\n", Info->UniqueId.String); } + if (Info->Valid & ACPI_VALID_SUB) + { + AcpiOsPrintf ("SUB: %s\n", Info->SubsystemId.String); + } if (Info->Valid & ACPI_VALID_CID) { for (i = 0; i < Info->CompatibleIdList.Count; i++) diff --git a/source/components/namespace/nsxfname.c b/source/components/namespace/nsxfname.c index 05f84f896..1364acca8 100644 --- a/source/components/namespace/nsxfname.c +++ b/source/components/namespace/nsxfname.c @@ -333,6 +333,7 @@ AcpiNsCopyDeviceId ( ACPI_PNP_DEVICE_ID *Source, char *StringArea) { + /* Create the destination PNP_DEVICE_ID */ Dest->String = StringArea; @@ -358,8 +359,8 @@ 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, _STA, - * _ADR, _SxW, and _SxD methods. + * For Device and Processor objects, run the Device _HID, _UID, _CID, _SUB, + * _STA, _ADR, _SxW, and _SxD methods. * * Note: Allocates the return buffer, must be freed by the caller. * @@ -375,6 +376,7 @@ 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; char *NextIdString; ACPI_OBJECT_TYPE Type; ACPI_NAME Name; @@ -427,7 +429,7 @@ AcpiGetObjectInfo ( { /* * Get extra info for ACPI Device/Processor objects only: - * Run the Device _HID, _UID, and _CID methods. + * Run the Device _HID, _UID, _SUB, 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 @@ -452,6 +454,15 @@ 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); @@ -540,8 +551,9 @@ AcpiGetObjectInfo ( } /* - * 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. + * 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. * * For HID and CID, check if the ID is a PCI Root Bridge. */ @@ -562,6 +574,12 @@ AcpiGetObjectInfo ( Uid, NextIdString); } + if (Sub) + { + NextIdString = AcpiNsCopyDeviceId (&Info->SubsystemId, + Sub, NextIdString); + } + if (CidList) { Info->CompatibleIdList.Count = CidList->Count; @@ -602,6 +620,10 @@ Cleanup: { ACPI_FREE (Uid); } + if (Sub) + { + ACPI_FREE (Sub); + } if (CidList) { ACPI_FREE (CidList); diff --git a/source/components/utilities/utids.c b/source/components/utilities/utids.c index 137ce8e0e..017f2e933 100644 --- a/source/components/utilities/utids.c +++ b/source/components/utilities/utids.c @@ -211,6 +211,77 @@ Cleanup: } +/******************************************************************************* + * + * FUNCTION: AcpiUtExecute_SUB + * + * PARAMETERS: DeviceNode - Node for the device + * ReturnId - Where the _SUB is returned + * + * RETURN: Status + * + * DESCRIPTION: Executes the _SUB control method that returns the subsystem + * ID of the device. The _SUB value is always a string containing + * either a valid PNP or ACPI ID. + * + * NOTE: Internal function, no parameter validation + * + ******************************************************************************/ + +ACPI_STATUS +AcpiUtExecute_SUB ( + ACPI_NAMESPACE_NODE *DeviceNode, + ACPI_PNP_DEVICE_ID **ReturnId) +{ + ACPI_OPERAND_OBJECT *ObjDesc; + ACPI_PNP_DEVICE_ID *Sub; + UINT32 Length; + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE (UtExecute_SUB); + + + Status = AcpiUtEvaluateObject (DeviceNode, METHOD_NAME__SUB, + ACPI_BTYPE_STRING, &ObjDesc); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* Get the size of the String to be returned, includes null terminator */ + + Length = ObjDesc->String.Length + 1; + + /* Allocate a buffer for the SUB */ + + Sub = ACPI_ALLOCATE_ZEROED (sizeof (ACPI_PNP_DEVICE_ID) + (ACPI_SIZE) Length); + if (!Sub) + { + Status = AE_NO_MEMORY; + goto Cleanup; + } + + /* Area for the string starts after PNP_DEVICE_ID struct */ + + Sub->String = ACPI_ADD_PTR (char, Sub, sizeof (ACPI_PNP_DEVICE_ID)); + + /* Simply copy existing string */ + + ACPI_STRCPY (Sub->String, ObjDesc->String.Pointer); + Sub->Length = Length; + *ReturnId = Sub; + + +Cleanup: + + /* On exit, we must delete the return object */ + + AcpiUtRemoveReference (ObjDesc); + return_ACPI_STATUS (Status); +} + + /******************************************************************************* * * FUNCTION: AcpiUtExecute_UID diff --git a/source/include/acnames.h b/source/include/acnames.h index ce3f7b374..61d680601 100644 --- a/source/include/acnames.h +++ b/source/include/acnames.h @@ -122,6 +122,7 @@ #define METHOD_NAME__HID "_HID" #define METHOD_NAME__CID "_CID" #define METHOD_NAME__UID "_UID" +#define METHOD_NAME__SUB "_SUB" #define METHOD_NAME__ADR "_ADR" #define METHOD_NAME__INI "_INI" #define METHOD_NAME__STA "_STA" diff --git a/source/include/actypes.h b/source/include/actypes.h index 720839ea3..ca4501541 100644 --- a/source/include/actypes.h +++ b/source/include/actypes.h @@ -1181,7 +1181,7 @@ UINT32 (*ACPI_INTERFACE_HANDLER) ( #define ACPI_UUID_LENGTH 16 -/* Structures used for device/processor HID, UID, CID */ +/* Structures used for device/processor HID, UID, CID, and SUB */ typedef struct acpi_pnp_device_id { @@ -1216,6 +1216,7 @@ typedef struct acpi_device_info UINT64 Address; /* _ADR value */ ACPI_PNP_DEVICE_ID HardwareId; /* _HID value */ ACPI_PNP_DEVICE_ID UniqueId; /* _UID value */ + ACPI_PNP_DEVICE_ID SubsystemId; /* _SUB value */ ACPI_PNP_DEVICE_ID_LIST CompatibleIdList; /* _CID list */ } ACPI_DEVICE_INFO; @@ -1230,11 +1231,12 @@ typedef struct acpi_device_info #define ACPI_VALID_ADR 0x02 #define ACPI_VALID_HID 0x04 #define ACPI_VALID_UID 0x08 -#define ACPI_VALID_CID 0x10 -#define ACPI_VALID_SXDS 0x20 -#define ACPI_VALID_SXWS 0x40 +#define ACPI_VALID_SUB 0x10 +#define ACPI_VALID_CID 0x20 +#define ACPI_VALID_SXDS 0x40 +#define ACPI_VALID_SXWS 0x80 -/* Flags for _STA method */ +/* Flags for _STA return value (CurrentStatus above) */ #define ACPI_STA_DEVICE_PRESENT 0x01 #define ACPI_STA_DEVICE_ENABLED 0x02 diff --git a/source/include/acutils.h b/source/include/acutils.h index 0fefef34d..fb6bc4813 100644 --- a/source/include/acutils.h +++ b/source/include/acutils.h @@ -591,6 +591,11 @@ AcpiUtExecute_UID ( ACPI_NAMESPACE_NODE *DeviceNode, ACPI_PNP_DEVICE_ID **ReturnId); +ACPI_STATUS +AcpiUtExecute_SUB ( + ACPI_NAMESPACE_NODE *DeviceNode, + ACPI_PNP_DEVICE_ID **ReturnId); + ACPI_STATUS AcpiUtExecute_CID ( ACPI_NAMESPACE_NODE *DeviceNode, diff --git a/source/tools/acpinames/anstubs.c b/source/tools/acpinames/anstubs.c index d0459ee00..80564c487 100644 --- a/source/tools/acpinames/anstubs.c +++ b/source/tools/acpinames/anstubs.c @@ -170,6 +170,14 @@ AcpiUtExecute_UID ( return (AE_NOT_IMPLEMENTED); } +ACPI_STATUS +AcpiUtExecute_SUB ( + ACPI_NAMESPACE_NODE *DeviceNode, + ACPI_PNP_DEVICE_ID **ReturnId) +{ + return (AE_NOT_IMPLEMENTED); +} + ACPI_STATUS AcpiUtExecutePowerMethods ( ACPI_NAMESPACE_NODE *DeviceNode,