From 0f552762e45d65746b7b1ee44d8ca1b52bf83450 Mon Sep 17 00:00:00 2001 From: njl Date: Tue, 29 Apr 2003 18:39:29 +0000 Subject: Import of Intel ACPI 20030228 vendor distribution --- sys/contrib/dev/acpica/uteval.c | 355 +++++++++++++++++----------------------- 1 file changed, 153 insertions(+), 202 deletions(-) (limited to 'sys/contrib/dev/acpica/uteval.c') diff --git a/sys/contrib/dev/acpica/uteval.c b/sys/contrib/dev/acpica/uteval.c index aaca246..6d69728 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: 41 $ + * $Revision: 45 $ * *****************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2002, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2003, Intel Corp. * All rights reserved. * * 2. License @@ -127,86 +127,165 @@ /******************************************************************************* * - * FUNCTION: AcpiUtEvaluateNumericObject + * FUNCTION: AcpiUtEvaluateObject * - * PARAMETERS: *ObjectName - Object name to be evaluated - * DeviceNode - Node for the device - * *Address - Where the value is returned + * PARAMETERS: PrefixNode - Starting node + * Path - Path to object from starting node + * ExpectedReturnTypes - Bitmap of allowed return types + * ReturnDesc - Where a return value is stored * * RETURN: Status * - * DESCRIPTION: evaluates a numeric namespace object for a selected device - * and stores results in *Address. + * DESCRIPTION: Evaluates a namespace object and verifies the type of the + * return object. Common code that simplifies accessing objects + * that have required return objects of fixed types. * * NOTE: Internal function, no parameter validation * ******************************************************************************/ ACPI_STATUS -AcpiUtEvaluateNumericObject ( - NATIVE_CHAR *ObjectName, - ACPI_NAMESPACE_NODE *DeviceNode, - ACPI_INTEGER *Address) +AcpiUtEvaluateObject ( + ACPI_NAMESPACE_NODE *PrefixNode, + char *Path, + UINT32 ExpectedReturnBtypes, + ACPI_OPERAND_OBJECT **ReturnDesc) { ACPI_OPERAND_OBJECT *ObjDesc; ACPI_STATUS Status; + UINT32 ReturnBtype; - ACPI_FUNCTION_TRACE ("UtEvaluateNumericObject"); + ACPI_FUNCTION_TRACE ("UtEvaluateObject"); - /* Execute the method */ + /* Evaluate the object/method */ - Status = AcpiNsEvaluateRelative (DeviceNode, ObjectName, NULL, &ObjDesc); + Status = AcpiNsEvaluateRelative (PrefixNode, Path, NULL, &ObjDesc); if (ACPI_FAILURE (Status)) { if (Status == AE_NOT_FOUND) { - ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "%s on %4.4s was not found\n", - ObjectName, DeviceNode->Name.Ascii)); + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "[%4.4s.%s] was not found\n", + PrefixNode->Name.Ascii, Path)); } else { - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "%s on %4.4s failed with status %s\n", - ObjectName, DeviceNode->Name.Ascii, - AcpiFormatException (Status))); + ACPI_REPORT_METHOD_ERROR ("Method execution failed", + PrefixNode, Path, Status); } return_ACPI_STATUS (Status); } - /* Did we get a return object? */ if (!ObjDesc) { - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "No object was returned from %s\n", - ObjectName)); - return_ACPI_STATUS (AE_TYPE); + if (ExpectedReturnBtypes) + { + ACPI_REPORT_METHOD_ERROR ("No object was returned from", + PrefixNode, Path, AE_NOT_EXIST); + + return_ACPI_STATUS (AE_NOT_EXIST); + } + + return_ACPI_STATUS (AE_OK); } - /* Is the return object of the correct type? */ + /* Map the return object type to the bitmapped type */ - if (ACPI_GET_OBJECT_TYPE (ObjDesc) != ACPI_TYPE_INTEGER) + switch (ACPI_GET_OBJECT_TYPE (ObjDesc)) { - Status = AE_TYPE; + case ACPI_TYPE_INTEGER: + ReturnBtype = ACPI_BTYPE_INTEGER; + break; + + case ACPI_TYPE_BUFFER: + ReturnBtype = ACPI_BTYPE_BUFFER; + break; + + case ACPI_TYPE_STRING: + ReturnBtype = ACPI_BTYPE_STRING; + break; + + case ACPI_TYPE_PACKAGE: + ReturnBtype = ACPI_BTYPE_PACKAGE; + break; + + default: + ReturnBtype = 0; + break; + } + + /* Is the return object one of the expected types? */ + + if (!(ExpectedReturnBtypes & ReturnBtype)) + { + ACPI_REPORT_METHOD_ERROR ("Return object type is incorrect", + PrefixNode, Path, AE_TYPE); + ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, - "Type returned from %s was not an Integer: %X \n", - ObjectName, ACPI_GET_OBJECT_TYPE (ObjDesc))); + "Type returned from %s was incorrect: %X\n", + Path, ACPI_GET_OBJECT_TYPE (ObjDesc))); + + /* On error exit, we must delete the return object */ + + AcpiUtRemoveReference (ObjDesc); + return_ACPI_STATUS (AE_TYPE); } - else + + /* Object type is OK, return it */ + + *ReturnDesc = ObjDesc; + return_ACPI_STATUS (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtEvaluateNumericObject + * + * PARAMETERS: *ObjectName - Object name to be evaluated + * DeviceNode - Node for the device + * *Address - Where the value is returned + * + * RETURN: Status + * + * DESCRIPTION: Evaluates a numeric namespace object for a selected device + * and stores result in *Address. + * + * NOTE: Internal function, no parameter validation + * + ******************************************************************************/ + +ACPI_STATUS +AcpiUtEvaluateNumericObject ( + char *ObjectName, + ACPI_NAMESPACE_NODE *DeviceNode, + ACPI_INTEGER *Address) +{ + ACPI_OPERAND_OBJECT *ObjDesc; + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE ("UtEvaluateNumericObject"); + + + Status = AcpiUtEvaluateObject (DeviceNode, ObjectName, + ACPI_BTYPE_INTEGER, &ObjDesc); + if (ACPI_FAILURE (Status)) { - /* - * Since the structure is a union, setting any field will set all - * of the variables in the union - */ - *Address = ObjDesc->Integer.Value; + return_ACPI_STATUS (Status); } + /* Get the returned Integer */ + + *Address = ObjDesc->Integer.Value; + /* On exit, we must delete the return object */ AcpiUtRemoveReference (ObjDesc); - return_ACPI_STATUS (Status); } @@ -239,67 +318,29 @@ AcpiUtExecute_HID ( ACPI_FUNCTION_TRACE ("UtExecute_HID"); - /* Execute the method */ - - Status = AcpiNsEvaluateRelative (DeviceNode, - METHOD_NAME__HID, NULL, &ObjDesc); + Status = AcpiUtEvaluateObject (DeviceNode, METHOD_NAME__HID, + ACPI_BTYPE_INTEGER | ACPI_BTYPE_STRING, &ObjDesc); if (ACPI_FAILURE (Status)) { - if (Status == AE_NOT_FOUND) - { - ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "_HID on %4.4s was not found\n", - DeviceNode->Name.Ascii)); - } - else - { - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "_HID on %4.4s failed %s\n", - DeviceNode->Name.Ascii, AcpiFormatException (Status))); - } - return_ACPI_STATUS (Status); } - /* Did we get a return object? */ - - if (!ObjDesc) + if (ACPI_GET_OBJECT_TYPE (ObjDesc) == ACPI_TYPE_INTEGER) { - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "No object was returned from _HID\n")); - return_ACPI_STATUS (AE_TYPE); - } + /* Convert the Numeric HID to string */ - /* - * A _HID can return either a Number (32 bit compressed EISA ID) or - * a string - */ - if ((ACPI_GET_OBJECT_TYPE (ObjDesc) != ACPI_TYPE_INTEGER) && - (ACPI_GET_OBJECT_TYPE (ObjDesc) != ACPI_TYPE_STRING)) - { - Status = AE_TYPE; - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, - "Type returned from _HID not a number or string: %s(%X) \n", - AcpiUtGetObjectTypeName (ObjDesc), - ACPI_GET_OBJECT_TYPE (ObjDesc))); + AcpiExEisaIdToString ((UINT32) ObjDesc->Integer.Value, Hid->Buffer); } else { - if (ACPI_GET_OBJECT_TYPE (ObjDesc) == ACPI_TYPE_INTEGER) - { - /* Convert the Numeric HID to string */ - - AcpiExEisaIdToString ((UINT32) ObjDesc->Integer.Value, Hid->Buffer); - } - else - { - /* Copy the String HID from the returned object */ + /* Copy the String HID from the returned object */ - ACPI_STRNCPY (Hid->Buffer, ObjDesc->String.Pointer, sizeof(Hid->Buffer)); - } + ACPI_STRNCPY (Hid->Buffer, ObjDesc->String.Pointer, sizeof(Hid->Buffer)); } /* On exit, we must delete the return object */ AcpiUtRemoveReference (ObjDesc); - return_ACPI_STATUS (Status); } @@ -331,34 +372,14 @@ AcpiUtExecute_CID ( ACPI_FUNCTION_TRACE ("UtExecute_CID"); - /* Execute the method */ - Status = AcpiNsEvaluateRelative (DeviceNode, - METHOD_NAME__CID, NULL, &ObjDesc); + Status = AcpiUtEvaluateObject (DeviceNode, METHOD_NAME__CID, + ACPI_BTYPE_INTEGER | ACPI_BTYPE_STRING | ACPI_BTYPE_PACKAGE, &ObjDesc); if (ACPI_FAILURE (Status)) { - if (Status == AE_NOT_FOUND) - { - ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "_CID on %4.4s was not found\n", - DeviceNode->Name.Ascii)); - } - else - { - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "_CID on %4.4s failed %s\n", - DeviceNode->Name.Ascii, AcpiFormatException (Status))); - } - return_ACPI_STATUS (Status); } - /* Did we get a return object? */ - - if (!ObjDesc) - { - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "No object was returned from _CID\n")); - return_ACPI_STATUS (AE_TYPE); - } - /* * 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 @@ -377,28 +398,25 @@ AcpiUtExecute_CID ( /* Copy the String CID from the returned object */ - ACPI_STRNCPY (Cid->Buffer, ObjDesc->String.Pointer, sizeof(Cid->Buffer)); + ACPI_STRNCPY (Cid->Buffer, ObjDesc->String.Pointer, sizeof (Cid->Buffer)); break; case ACPI_TYPE_PACKAGE: /* TBD: Parse package elements; need different return struct, etc. */ + + Status = AE_SUPPORT; break; default: Status = AE_TYPE; - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, - "Type returned from _CID not a number, string, or package: %s(%X) \n", - AcpiUtGetObjectTypeName (ObjDesc), - ACPI_GET_OBJECT_TYPE (ObjDesc))); break; } /* On exit, we must delete the return object */ AcpiUtRemoveReference (ObjDesc); - return_ACPI_STATUS (Status); } @@ -428,72 +446,33 @@ AcpiUtExecute_UID ( ACPI_STATUS Status; - ACPI_FUNCTION_NAME ("UtExecute_UID"); - + ACPI_FUNCTION_TRACE ("UtExecute_UID"); - /* Execute the method */ - Status = AcpiNsEvaluateRelative (DeviceNode, - METHOD_NAME__UID, NULL, &ObjDesc); + Status = AcpiUtEvaluateObject (DeviceNode, METHOD_NAME__UID, + ACPI_BTYPE_INTEGER | ACPI_BTYPE_STRING, &ObjDesc); if (ACPI_FAILURE (Status)) { - if (Status == AE_NOT_FOUND) - { - ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "_UID on %4.4s was not found\n", - DeviceNode->Name.Ascii)); - } - else - { - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, - "_UID on %4.4s failed %s\n", - DeviceNode->Name.Ascii, AcpiFormatException (Status))); - } - - return (Status); + return_ACPI_STATUS (Status); } - /* Did we get a return object? */ - - if (!ObjDesc) + if (ACPI_GET_OBJECT_TYPE (ObjDesc) == ACPI_TYPE_INTEGER) { - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "No object was returned from _UID\n")); - return (AE_TYPE); - } + /* Convert the Numeric UID to string */ - /* - * A _UID can return either a Number (32 bit compressed EISA ID) or - * a string - */ - if ((ACPI_GET_OBJECT_TYPE (ObjDesc) != ACPI_TYPE_INTEGER) && - (ACPI_GET_OBJECT_TYPE (ObjDesc) != ACPI_TYPE_STRING)) - { - Status = AE_TYPE; - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, - "Type returned from _UID was not a number or string: %X \n", - ACPI_GET_OBJECT_TYPE (ObjDesc))); + AcpiExUnsignedIntegerToString (ObjDesc->Integer.Value, Uid->Buffer); } else { - if (ACPI_GET_OBJECT_TYPE (ObjDesc) == ACPI_TYPE_INTEGER) - { - /* Convert the Numeric UID to string */ + /* Copy the String UID from the returned object */ - AcpiExUnsignedIntegerToString (ObjDesc->Integer.Value, Uid->Buffer); - } - else - { - /* Copy the String UID from the returned object */ - - ACPI_STRNCPY (Uid->Buffer, ObjDesc->String.Pointer, sizeof(Uid->Buffer)); - } + ACPI_STRNCPY (Uid->Buffer, ObjDesc->String.Pointer, sizeof (Uid->Buffer)); } - /* On exit, we must delete the return object */ AcpiUtRemoveReference (ObjDesc); - - return (Status); + return_ACPI_STATUS (Status); } @@ -525,57 +504,29 @@ AcpiUtExecute_STA ( ACPI_FUNCTION_TRACE ("UtExecute_STA"); - /* Execute the method */ - - Status = AcpiNsEvaluateRelative (DeviceNode, - METHOD_NAME__STA, NULL, &ObjDesc); - if (AE_NOT_FOUND == Status) - { - ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, - "_STA on %4.4s was not found, assuming present.\n", - DeviceNode->Name.Ascii)); - - *Flags = 0x0F; - Status = AE_OK; - } - - else if (ACPI_FAILURE (Status)) - { - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "_STA on %4.4s failed %s\n", - DeviceNode->Name.Ascii, - AcpiFormatException (Status))); - } - - else /* success */ + Status = AcpiUtEvaluateObject (DeviceNode, METHOD_NAME__STA, + ACPI_BTYPE_INTEGER, &ObjDesc); + if (ACPI_FAILURE (Status)) { - /* Did we get a return object? */ - - if (!ObjDesc) + if (AE_NOT_FOUND == Status) { - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "No object was returned from _STA\n")); - return_ACPI_STATUS (AE_TYPE); - } - - /* Is the return object of the correct type? */ + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, + "_STA on %4.4s was not found, assuming device is present\n", + DeviceNode->Name.Ascii)); - if (ACPI_GET_OBJECT_TYPE (ObjDesc) != ACPI_TYPE_INTEGER) - { - Status = AE_TYPE; - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, - "Type returned from _STA was not a number: %X \n", - ACPI_GET_OBJECT_TYPE (ObjDesc))); + *Flags = 0x0F; + Status = AE_OK; } - else - { - /* Extract the status flags */ - *Flags = (UINT32) ObjDesc->Integer.Value; - } + return_ACPI_STATUS (Status); + } - /* On exit, we must delete the return object */ + /* Extract the status flags */ - AcpiUtRemoveReference (ObjDesc); - } + *Flags = (UINT32) ObjDesc->Integer.Value; + /* On exit, we must delete the return object */ + + AcpiUtRemoveReference (ObjDesc); return_ACPI_STATUS (Status); } -- cgit v1.1