1 /******************************************************************************
3 * Module Name: cmeval - Object evaluation
6 *****************************************************************************/
9 * Copyright (C) 2000, 2001 R. Byron Moore
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
32 #define _COMPONENT ACPI_UTILITIES
33 MODULE_NAME ("cmeval")
36 /****************************************************************************
38 * FUNCTION: Acpi_cm_evaluate_numeric_object
40 * PARAMETERS: *Object_name - Object name to be evaluated
41 * Device_node - Node for the device
42 * *Address - Where the value is returned
46 * DESCRIPTION: evaluates a numeric namespace object for a selected device
47 * and stores results in *Address.
49 * NOTE: Internal function, no parameter validation
51 ***************************************************************************/
54 acpi_cm_evaluate_numeric_object (
55 NATIVE_CHAR *object_name,
56 ACPI_NAMESPACE_NODE *device_node,
57 ACPI_INTEGER *address)
59 ACPI_OPERAND_OBJECT *obj_desc;
63 /* Execute the method */
65 status = acpi_ns_evaluate_relative (device_node, object_name, NULL, &obj_desc);
66 if (ACPI_FAILURE (status)) {
72 /* Did we get a return object? */
78 /* Is the return object of the correct type? */
80 if (obj_desc->common.type != ACPI_TYPE_INTEGER) {
85 * Since the structure is a union, setting any field will set all
86 * of the variables in the union
88 *address = obj_desc->integer.value;
91 /* On exit, we must delete the return object */
93 acpi_cm_remove_reference (obj_desc);
99 /****************************************************************************
101 * FUNCTION: Acpi_cm_execute_HID
103 * PARAMETERS: Device_node - Node for the device
104 * *Hid - Where the HID is returned
108 * DESCRIPTION: Executes the _HID control method that returns the hardware
111 * NOTE: Internal function, no parameter validation
113 ***************************************************************************/
116 acpi_cm_execute_HID (
117 ACPI_NAMESPACE_NODE *device_node,
120 ACPI_OPERAND_OBJECT *obj_desc;
124 /* Execute the method */
126 status = acpi_ns_evaluate_relative (device_node,
127 METHOD_NAME__HID, NULL, &obj_desc);
128 if (ACPI_FAILURE (status)) {
134 /* Did we get a return object? */
141 * A _HID can return either a Number (32 bit compressed EISA ID) or
145 if ((obj_desc->common.type != ACPI_TYPE_INTEGER) &&
146 (obj_desc->common.type != ACPI_TYPE_STRING)) {
151 if (obj_desc->common.type == ACPI_TYPE_INTEGER) {
152 /* Convert the Numeric HID to string */
154 acpi_aml_eisa_id_to_string ((u32) obj_desc->integer.value, hid->buffer);
158 /* Copy the String HID from the returned object */
160 STRNCPY(hid->buffer, obj_desc->string.pointer, sizeof(hid->buffer));
165 /* On exit, we must delete the return object */
167 acpi_cm_remove_reference (obj_desc);
173 /****************************************************************************
175 * FUNCTION: Acpi_cm_execute_UID
177 * PARAMETERS: Device_node - Node for the device
178 * *Uid - Where the UID is returned
182 * DESCRIPTION: Executes the _UID control method that returns the hardware
185 * NOTE: Internal function, no parameter validation
187 ***************************************************************************/
190 acpi_cm_execute_UID (
191 ACPI_NAMESPACE_NODE *device_node,
194 ACPI_OPERAND_OBJECT *obj_desc;
198 /* Execute the method */
200 status = acpi_ns_evaluate_relative (device_node,
201 METHOD_NAME__UID, NULL, &obj_desc);
202 if (ACPI_FAILURE (status)) {
208 /* Did we get a return object? */
215 * A _UID can return either a Number (32 bit compressed EISA ID) or
219 if ((obj_desc->common.type != ACPI_TYPE_INTEGER) &&
220 (obj_desc->common.type != ACPI_TYPE_STRING)) {
225 if (obj_desc->common.type == ACPI_TYPE_INTEGER) {
226 /* Convert the Numeric UID to string */
228 acpi_aml_unsigned_integer_to_string (obj_desc->integer.value, uid->buffer);
232 /* Copy the String UID from the returned object */
234 STRNCPY(uid->buffer, obj_desc->string.pointer, sizeof(uid->buffer));
239 /* On exit, we must delete the return object */
241 acpi_cm_remove_reference (obj_desc);
246 /****************************************************************************
248 * FUNCTION: Acpi_cm_execute_STA
250 * PARAMETERS: Device_node - Node for the device
251 * *Flags - Where the status flags are returned
255 * DESCRIPTION: Executes _STA for selected device and stores results in
258 * NOTE: Internal function, no parameter validation
260 ***************************************************************************/
263 acpi_cm_execute_STA (
264 ACPI_NAMESPACE_NODE *device_node,
267 ACPI_OPERAND_OBJECT *obj_desc;
271 /* Execute the method */
273 status = acpi_ns_evaluate_relative (device_node,
274 METHOD_NAME__STA, NULL, &obj_desc);
275 if (AE_NOT_FOUND == status) {
282 /* Did we get a return object? */
288 /* Is the return object of the correct type? */
290 if (obj_desc->common.type != ACPI_TYPE_INTEGER) {
295 /* Extract the status flags */
297 *flags = (u32) obj_desc->integer.value;
300 /* On exit, we must delete the return object */
302 acpi_cm_remove_reference (obj_desc);