summaryrefslogtreecommitdiffstats
path: root/sys/contrib/dev/acpica/uteval.c
diff options
context:
space:
mode:
authornjl <njl@FreeBSD.org>2003-07-13 22:44:13 +0000
committernjl <njl@FreeBSD.org>2003-07-13 22:44:13 +0000
commit148a8cc4ac210f6d3692eb478d20cc64818d274a (patch)
treedd1a453ab93efa28848b21047ec45d003c6f262e /sys/contrib/dev/acpica/uteval.c
parent857b9ae7f340e84e806f355c2a19d9cac1ab3faf (diff)
downloadFreeBSD-src-148a8cc4ac210f6d3692eb478d20cc64818d274a.zip
FreeBSD-src-148a8cc4ac210f6d3692eb478d20cc64818d274a.tar.gz
ACPICA import from the 0619 dist.
Diffstat (limited to 'sys/contrib/dev/acpica/uteval.c')
-rw-r--r--sys/contrib/dev/acpica/uteval.c192
1 files changed, 163 insertions, 29 deletions
diff --git a/sys/contrib/dev/acpica/uteval.c b/sys/contrib/dev/acpica/uteval.c
index 6d69728..49ef9e0 100644
--- a/sys/contrib/dev/acpica/uteval.c
+++ b/sys/contrib/dev/acpica/uteval.c
@@ -1,7 +1,7 @@
/******************************************************************************
*
* Module Name: uteval - Object evaluation
- * $Revision: 45 $
+ * $Revision: 48 $
*
*****************************************************************************/
@@ -292,6 +292,47 @@ AcpiUtEvaluateNumericObject (
/*******************************************************************************
*
+ * FUNCTION: AcpiUtCopyIdString
+ *
+ * PARAMETERS: Destination - Where to copy the string
+ * Source - Source string
+ * MaxLength - Length of the destination buffer
+ *
+ * RETURN: None
+ *
+ * DESCRIPTION: Copies an ID string for the _HID, _CID, and _UID methods.
+ * Performs removal of a leading asterisk if present -- workaround
+ * for a known issue on a bunch of machines.
+ *
+ ******************************************************************************/
+
+static void
+AcpiUtCopyIdString (
+ char *Destination,
+ char *Source,
+ ACPI_SIZE MaxLength)
+{
+
+
+ /*
+ * Workaround for ID strings that have a leading asterisk. This construct
+ * is not allowed by the ACPI specification (ID strings must be
+ * alphanumeric), but enough existing machines have this embedded in their
+ * ID strings that the following code is useful.
+ */
+ if (*Source == '*')
+ {
+ Source++;
+ }
+
+ /* Do the actual copy */
+
+ ACPI_STRNCPY (Destination, Source, MaxLength);
+}
+
+
+/*******************************************************************************
+ *
* FUNCTION: AcpiUtExecute_HID
*
* PARAMETERS: DeviceNode - Node for the device
@@ -329,13 +370,14 @@ AcpiUtExecute_HID (
{
/* Convert the Numeric HID to string */
- AcpiExEisaIdToString ((UINT32) ObjDesc->Integer.Value, Hid->Buffer);
+ AcpiExEisaIdToString ((UINT32) ObjDesc->Integer.Value, Hid->Value);
}
else
{
/* Copy the String HID from the returned object */
- ACPI_STRNCPY (Hid->Buffer, ObjDesc->String.Pointer, sizeof(Hid->Buffer));
+ AcpiUtCopyIdString (Hid->Value, ObjDesc->String.Pointer,
+ sizeof (Hid->Value));
}
/* On exit, we must delete the return object */
@@ -347,6 +389,59 @@ AcpiUtExecute_HID (
/*******************************************************************************
*
+ * FUNCTION: AcpiUtTranslateOneCid
+ *
+ * PARAMETERS: ObjDesc - _CID object, must be integer or string
+ * OneCid - Where the CID string is returned
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Return a numeric or string _CID value as a string.
+ * (Compatible ID)
+ *
+ * NOTE: Assumes a maximum _CID string length of
+ * ACPI_MAX_CID_LENGTH.
+ *
+ ******************************************************************************/
+
+static ACPI_STATUS
+AcpiUtTranslateOneCid (
+ ACPI_OPERAND_OBJECT *ObjDesc,
+ ACPI_COMPATIBLE_ID *OneCid)
+{
+
+
+ switch (ACPI_GET_OBJECT_TYPE (ObjDesc))
+ {
+ case ACPI_TYPE_INTEGER:
+
+ /* Convert the Numeric CID to string */
+
+ AcpiExEisaIdToString ((UINT32) ObjDesc->Integer.Value, OneCid->Value);
+ return (AE_OK);
+
+ case ACPI_TYPE_STRING:
+
+ if (ObjDesc->String.Length > ACPI_MAX_CID_LENGTH)
+ {
+ return (AE_AML_STRING_LIMIT);
+ }
+
+ /* Copy the String CID from the returned object */
+
+ AcpiUtCopyIdString (OneCid->Value, ObjDesc->String.Pointer,
+ ACPI_MAX_CID_LENGTH);
+ return (AE_OK);
+
+ default:
+
+ return (AE_TYPE);
+ }
+}
+
+
+/*******************************************************************************
+ *
* FUNCTION: AcpiUtExecute_CID
*
* PARAMETERS: DeviceNode - Node for the device
@@ -364,57 +459,95 @@ AcpiUtExecute_HID (
ACPI_STATUS
AcpiUtExecute_CID (
ACPI_NAMESPACE_NODE *DeviceNode,
- ACPI_DEVICE_ID *Cid)
+ ACPI_COMPATIBLE_ID_LIST **ReturnCidList)
{
ACPI_OPERAND_OBJECT *ObjDesc;
ACPI_STATUS Status;
+ UINT32 Count;
+ UINT32 Size;
+ ACPI_COMPATIBLE_ID_LIST *CidList;
+ ACPI_NATIVE_UINT i;
ACPI_FUNCTION_TRACE ("UtExecute_CID");
+ /* Evaluate the _CID method for this device */
+
Status = AcpiUtEvaluateObject (DeviceNode, METHOD_NAME__CID,
- ACPI_BTYPE_INTEGER | ACPI_BTYPE_STRING | ACPI_BTYPE_PACKAGE, &ObjDesc);
+ ACPI_BTYPE_INTEGER | ACPI_BTYPE_STRING | ACPI_BTYPE_PACKAGE,
+ &ObjDesc);
if (ACPI_FAILURE (Status))
{
return_ACPI_STATUS (Status);
}
- /*
- * A _CID can return either a single compatible ID or a package of compatible
- * IDs. Each compatible ID can be a Number (32 bit compressed EISA ID) or
- * string (PCI ID format, e.g. "PCI\VEN_vvvv&DEV_dddd&SUBSYS_ssssssss").
- */
- switch (ACPI_GET_OBJECT_TYPE (ObjDesc))
+ /* Get the number of _CIDs returned */
+
+ Count = 1;
+ if (ACPI_GET_OBJECT_TYPE (ObjDesc) == ACPI_TYPE_PACKAGE)
{
- case ACPI_TYPE_INTEGER:
+ Count = ObjDesc->Package.Count;
+ }
- /* Convert the Numeric CID to string */
+ /* Allocate a worst-case buffer for the _CIDs */
- AcpiExEisaIdToString ((UINT32) ObjDesc->Integer.Value, Cid->Buffer);
- break;
+ Size = (((Count - 1) * sizeof (ACPI_COMPATIBLE_ID)) +
+ sizeof (ACPI_COMPATIBLE_ID_LIST));
- case ACPI_TYPE_STRING:
+ CidList = ACPI_MEM_CALLOCATE ((ACPI_SIZE) Size);
+ if (!CidList)
+ {
+ return_ACPI_STATUS (AE_NO_MEMORY);
+ }
- /* Copy the String CID from the returned object */
+ /* Init CID list */
- ACPI_STRNCPY (Cid->Buffer, ObjDesc->String.Pointer, sizeof (Cid->Buffer));
- break;
+ CidList->Count = Count;
+ CidList->Size = Size;
- case ACPI_TYPE_PACKAGE:
+ /*
+ * A _CID can return either a single compatible ID or a package of compatible
+ * IDs. Each compatible ID can be one of the following:
+ * -- Number (32 bit compressed EISA ID) or
+ * -- String (PCI ID format, e.g. "PCI\VEN_vvvv&DEV_dddd&SUBSYS_ssssssss").
+ */
- /* TBD: Parse package elements; need different return struct, etc. */
+ /* The _CID object can be either a single CID or a package (list) of CIDs */
- Status = AE_SUPPORT;
- break;
+ if (ACPI_GET_OBJECT_TYPE (ObjDesc) == ACPI_TYPE_PACKAGE)
+ {
+ /* Translate each package element */
- default:
+ for (i = 0; i < Count; i++)
+ {
+ Status = AcpiUtTranslateOneCid (ObjDesc->Package.Elements[i],
+ &CidList->Id[i]);
+ if (ACPI_FAILURE (Status))
+ {
+ break;
+ }
+ }
+ }
+ else
+ {
+ /* Only one CID, translate to a string */
- Status = AE_TYPE;
- break;
+ Status = AcpiUtTranslateOneCid (ObjDesc, CidList->Id);
}
- /* On exit, we must delete the return object */
+ /* Cleanup on error */
+
+ if (ACPI_FAILURE (Status))
+ {
+ ACPI_MEM_FREE (CidList);
+ }
+ else
+ {
+ *ReturnCidList = CidList;
+ }
+
+ /* On exit, we must delete the _CID return object */
AcpiUtRemoveReference (ObjDesc);
return_ACPI_STATUS (Status);
@@ -460,13 +593,14 @@ AcpiUtExecute_UID (
{
/* Convert the Numeric UID to string */
- AcpiExUnsignedIntegerToString (ObjDesc->Integer.Value, Uid->Buffer);
+ AcpiExUnsignedIntegerToString (ObjDesc->Integer.Value, Uid->Value);
}
else
{
/* Copy the String UID from the returned object */
- ACPI_STRNCPY (Uid->Buffer, ObjDesc->String.Pointer, sizeof (Uid->Buffer));
+ AcpiUtCopyIdString (Uid->Value, ObjDesc->String.Pointer,
+ sizeof (Uid->Value));
}
/* On exit, we must delete the return object */
OpenPOWER on IntegriCloud