- Kai Germaschewski: ISDN update (including Makefiles)
[davej-history.git] / drivers / acpi / common / cmeval.c
blob29a5cefa6411789f957ed90421e03b0c7fa00796
1 /******************************************************************************
3 * Module Name: cmeval - Object evaluation
4 * $Revision: 19 $
6 *****************************************************************************/
8 /*
9 * Copyright (C) 2000 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
27 #include "acpi.h"
28 #include "acnamesp.h"
29 #include "acinterp.h"
32 #define _COMPONENT MISCELLANEOUS
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
44 * RETURN: Status
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 ***************************************************************************/
53 ACPI_STATUS
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;
60 ACPI_STATUS status;
63 /* Execute the method */
65 status = acpi_ns_evaluate_relative (device_node, object_name, NULL, &obj_desc);
66 if (ACPI_FAILURE (status)) {
68 return (status);
72 /* Did we get a return object? */
74 if (!obj_desc) {
75 return (AE_TYPE);
78 /* Is the return object of the correct type? */
80 if (obj_desc->common.type != ACPI_TYPE_NUMBER) {
81 status = AE_TYPE;
83 else {
85 * Since the structure is a union, setting any field will set all
86 * of the variables in the union
88 *address = obj_desc->number.value;
91 /* On exit, we must delete the return object */
93 acpi_cm_remove_reference (obj_desc);
95 return (status);
99 /****************************************************************************
101 * FUNCTION: Acpi_cm_execute_HID
103 * PARAMETERS: Device_node - Node for the device
104 * *Hid - Where the HID is returned
106 * RETURN: Status
108 * DESCRIPTION: Executes the _HID control method that returns the hardware
109 * ID of the device.
111 * NOTE: Internal function, no parameter validation
113 ***************************************************************************/
115 ACPI_STATUS
116 acpi_cm_execute_HID (
117 ACPI_NAMESPACE_NODE *device_node,
118 DEVICE_ID *hid)
120 ACPI_OPERAND_OBJECT *obj_desc;
121 ACPI_STATUS status;
124 /* Execute the method */
126 status = acpi_ns_evaluate_relative (device_node,
127 METHOD_NAME__HID, NULL, &obj_desc);
128 if (ACPI_FAILURE (status)) {
131 return (status);
134 /* Did we get a return object? */
136 if (!obj_desc) {
137 return (AE_TYPE);
141 * A _HID can return either a Number (32 bit compressed EISA ID) or
142 * a string
145 if ((obj_desc->common.type != ACPI_TYPE_NUMBER) &&
146 (obj_desc->common.type != ACPI_TYPE_STRING))
148 status = AE_TYPE;
151 else {
152 if (obj_desc->common.type == ACPI_TYPE_NUMBER) {
153 /* Convert the Numeric HID to string */
155 acpi_aml_eisa_id_to_string ((u32) obj_desc->number.value, hid->buffer);
158 else {
159 /* Copy the String HID from the returned object */
161 STRNCPY(hid->buffer, obj_desc->string.pointer, sizeof(hid->buffer));
166 /* On exit, we must delete the return object */
168 acpi_cm_remove_reference (obj_desc);
170 return (status);
174 /****************************************************************************
176 * FUNCTION: Acpi_cm_execute_UID
178 * PARAMETERS: Device_node - Node for the device
179 * *Uid - Where the UID is returned
181 * RETURN: Status
183 * DESCRIPTION: Executes the _UID control method that returns the hardware
184 * ID of the device.
186 * NOTE: Internal function, no parameter validation
188 ***************************************************************************/
190 ACPI_STATUS
191 acpi_cm_execute_UID (
192 ACPI_NAMESPACE_NODE *device_node,
193 DEVICE_ID *uid)
195 ACPI_OPERAND_OBJECT *obj_desc;
196 ACPI_STATUS status;
199 /* Execute the method */
201 status = acpi_ns_evaluate_relative (device_node,
202 METHOD_NAME__UID, NULL, &obj_desc);
203 if (ACPI_FAILURE (status)) {
206 return (status);
209 /* Did we get a return object? */
211 if (!obj_desc) {
212 return (AE_TYPE);
216 * A _UID can return either a Number (32 bit compressed EISA ID) or
217 * a string
220 if ((obj_desc->common.type != ACPI_TYPE_NUMBER) &&
221 (obj_desc->common.type != ACPI_TYPE_STRING))
223 status = AE_TYPE;
226 else {
227 if (obj_desc->common.type == ACPI_TYPE_NUMBER) {
228 /* Convert the Numeric UID to string */
230 acpi_aml_unsigned_integer_to_string (obj_desc->number.value, uid->buffer);
233 else {
234 /* Copy the String UID from the returned object */
236 STRNCPY(uid->buffer, obj_desc->string.pointer, sizeof(uid->buffer));
241 /* On exit, we must delete the return object */
243 acpi_cm_remove_reference (obj_desc);
245 return (status);
248 /****************************************************************************
250 * FUNCTION: Acpi_cm_execute_STA
252 * PARAMETERS: Device_node - Node for the device
253 * *Flags - Where the status flags are returned
255 * RETURN: Status
257 * DESCRIPTION: Executes _STA for selected device and stores results in
258 * *Flags.
260 * NOTE: Internal function, no parameter validation
262 ***************************************************************************/
264 ACPI_STATUS
265 acpi_cm_execute_STA (
266 ACPI_NAMESPACE_NODE *device_node,
267 u32 *flags)
269 ACPI_OPERAND_OBJECT *obj_desc;
270 ACPI_STATUS status;
273 /* Execute the method */
275 status = acpi_ns_evaluate_relative (device_node,
276 METHOD_NAME__STA, NULL, &obj_desc);
277 if (AE_NOT_FOUND == status) {
278 *flags = 0x0F;
279 status = AE_OK;
283 else /* success */ {
284 /* Did we get a return object? */
286 if (!obj_desc) {
287 return (AE_TYPE);
290 /* Is the return object of the correct type? */
292 if (obj_desc->common.type != ACPI_TYPE_NUMBER) {
293 status = AE_TYPE;
296 else {
297 /* Extract the status flags */
299 *flags = (u32) obj_desc->number.value;
302 /* On exit, we must delete the return object */
304 acpi_cm_remove_reference (obj_desc);
307 return (status);