File: uteval.c

package info (click to toggle)
kernel-image-2.4.17-hppa 32.4
  • links: PTS
  • area: main
  • in suites: woody
  • size: 156,356 kB
  • ctags: 442,585
  • sloc: ansic: 2,542,442; asm: 144,771; makefile: 8,468; sh: 3,097; perl: 2,578; yacc: 1,177; tcl: 577; lex: 352; awk: 251; lisp: 218; sed: 72
file content (369 lines) | stat: -rw-r--r-- 9,560 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
/******************************************************************************
 *
 * Module Name: uteval - Object evaluation
 *              $Revision: 31 $
 *
 *****************************************************************************/

/*
 *  Copyright (C) 2000, 2001 R. Byron Moore
 *
 *  This program is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; either version 2 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program; if not, write to the Free Software
 *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */


#include "acpi.h"
#include "acnamesp.h"
#include "acinterp.h"


#define _COMPONENT          ACPI_UTILITIES
	 MODULE_NAME         ("uteval")


/*******************************************************************************
 *
 * FUNCTION:    Acpi_ut_evaluate_numeric_object
 *
 * PARAMETERS:  *Object_name        - Object name to be evaluated
 *              Device_node         - Node for the device
 *              *Address            - Where the value is returned
 *
 * RETURN:      Status
 *
 * DESCRIPTION: evaluates a numeric namespace object for a selected device
 *              and stores results in *Address.
 *
 *              NOTE: Internal function, no parameter validation
 *
 ******************************************************************************/

acpi_status
acpi_ut_evaluate_numeric_object (
	NATIVE_CHAR             *object_name,
	acpi_namespace_node     *device_node,
	acpi_integer            *address)
{
	acpi_operand_object     *obj_desc;
	acpi_status             status;


	FUNCTION_TRACE ("Ut_evaluate_numeric_object");


	/* Execute the method */

	status = acpi_ns_evaluate_relative (device_node, object_name, NULL, &obj_desc);
	if (ACPI_FAILURE (status)) {
		if (status == AE_NOT_FOUND) {
			ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "%s on %4.4s was not found\n",
				object_name, (char*)&device_node->name));
		}
		else {
			ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "%s on %4.4s failed with status %s\n",
				object_name, (char*)&device_node->name,
				acpi_format_exception (status)));
		}

		return_ACPI_STATUS (status);
	}


	/* Did we get a return object? */

	if (!obj_desc) {
		ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "No object was returned from %s\n",
			object_name));
		return_ACPI_STATUS (AE_TYPE);
	}

	/* Is the return object of the correct type? */

	if (obj_desc->common.type != ACPI_TYPE_INTEGER) {
		status = AE_TYPE;
		ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
			"Type returned from %s was not a number: %X \n",
			object_name, obj_desc->common.type));
	}
	else {
		/*
		 * Since the structure is a union, setting any field will set all
		 * of the variables in the union
		 */
		*address = obj_desc->integer.value;
	}

	/* On exit, we must delete the return object */

	acpi_ut_remove_reference (obj_desc);

	return_ACPI_STATUS (status);
}


/*******************************************************************************
 *
 * FUNCTION:    Acpi_ut_execute_HID
 *
 * PARAMETERS:  Device_node         - Node for the device
 *              *Hid                - Where the HID is returned
 *
 * RETURN:      Status
 *
 * DESCRIPTION: Executes the _HID control method that returns the hardware
 *              ID of the device.
 *
 *              NOTE: Internal function, no parameter validation
 *
 ******************************************************************************/

acpi_status
acpi_ut_execute_HID (
	acpi_namespace_node     *device_node,
	acpi_device_id          *hid)
{
	acpi_operand_object     *obj_desc;
	acpi_status             status;


	FUNCTION_TRACE ("Ut_execute_HID");


	/* Execute the method */

	status = acpi_ns_evaluate_relative (device_node,
			 METHOD_NAME__HID, NULL, &obj_desc);
	if (ACPI_FAILURE (status)) {
		if (status == AE_NOT_FOUND) {
			ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "_HID on %4.4s was not found\n",
				(char*)&device_node->name));
		}

		else {
			ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "_HID on %4.4s failed %s\n",
				(char*)&device_node->name, acpi_format_exception (status)));
		}

		return_ACPI_STATUS (status);
	}

	/* Did we get a return object? */

	if (!obj_desc) {
		ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "No object was returned from _HID\n"));
		return_ACPI_STATUS (AE_TYPE);
	}

	/*
	 *  A _HID can return either a Number (32 bit compressed EISA ID) or
	 *  a string
	 */
	if ((obj_desc->common.type != ACPI_TYPE_INTEGER) &&
		(obj_desc->common.type != ACPI_TYPE_STRING)) {
		status = AE_TYPE;
		ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
			"Type returned from _HID not a number or string: %s(%X) \n",
			acpi_ut_get_type_name (obj_desc->common.type), obj_desc->common.type));
	}

	else {
		if (obj_desc->common.type == ACPI_TYPE_INTEGER) {
			/* Convert the Numeric HID to string */

			acpi_ex_eisa_id_to_string ((u32) obj_desc->integer.value, hid->buffer);
		}

		else {
			/* Copy the String HID from the returned object */

			STRNCPY(hid->buffer, obj_desc->string.pointer, sizeof(hid->buffer));
		}
	}


	/* On exit, we must delete the return object */

	acpi_ut_remove_reference (obj_desc);

	return_ACPI_STATUS (status);
}


/*******************************************************************************
 *
 * FUNCTION:    Acpi_ut_execute_UID
 *
 * PARAMETERS:  Device_node         - Node for the device
 *              *Uid                - Where the UID is returned
 *
 * RETURN:      Status
 *
 * DESCRIPTION: Executes the _UID control method that returns the hardware
 *              ID of the device.
 *
 *              NOTE: Internal function, no parameter validation
 *
 ******************************************************************************/

acpi_status
acpi_ut_execute_UID (
	acpi_namespace_node     *device_node,
	acpi_device_id          *uid)
{
	acpi_operand_object     *obj_desc;
	acpi_status             status;


	PROC_NAME ("Ut_execute_UID");


	/* Execute the method */

	status = acpi_ns_evaluate_relative (device_node,
			 METHOD_NAME__UID, NULL, &obj_desc);
	if (ACPI_FAILURE (status)) {
		if (status == AE_NOT_FOUND) {
			ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "_UID on %4.4s was not found\n",
				(char*)&device_node->name));
		}

		else {
			ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
				"_UID on %4.4s failed %s\n",
				(char*)&device_node->name, acpi_format_exception (status)));
		}

		return (status);
	}

	/* Did we get a return object? */

	if (!obj_desc) {
		ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "No object was returned from _UID\n"));
		return (AE_TYPE);
	}

	/*
	 *  A _UID can return either a Number (32 bit compressed EISA ID) or
	 *  a string
	 */
	if ((obj_desc->common.type != ACPI_TYPE_INTEGER) &&
		(obj_desc->common.type != ACPI_TYPE_STRING)) {
		status = AE_TYPE;
		ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
			"Type returned from _UID was not a number or string: %X \n",
			obj_desc->common.type));
	}

	else {
		if (obj_desc->common.type == ACPI_TYPE_INTEGER) {
			/* Convert the Numeric UID to string */

			acpi_ex_unsigned_integer_to_string (obj_desc->integer.value, uid->buffer);
		}

		else {
			/* Copy the String UID from the returned object */

			STRNCPY(uid->buffer, obj_desc->string.pointer, sizeof(uid->buffer));
		}
	}


	/* On exit, we must delete the return object */

	acpi_ut_remove_reference (obj_desc);

	return (status);
}


/*******************************************************************************
 *
 * FUNCTION:    Acpi_ut_execute_STA
 *
 * PARAMETERS:  Device_node         - Node for the device
 *              *Flags              - Where the status flags are returned
 *
 * RETURN:      Status
 *
 * DESCRIPTION: Executes _STA for selected device and stores results in
 *              *Flags.
 *
 *              NOTE: Internal function, no parameter validation
 *
 ******************************************************************************/

acpi_status
acpi_ut_execute_STA (
	acpi_namespace_node     *device_node,
	u32                     *flags)
{
	acpi_operand_object     *obj_desc;
	acpi_status             status;


	FUNCTION_TRACE ("Ut_execute_STA");


	/* Execute the method */

	status = acpi_ns_evaluate_relative (device_node,
			 METHOD_NAME__STA, NULL, &obj_desc);
	if (AE_NOT_FOUND == status) {
		ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
			"_STA on %4.4s was not found, assuming present.\n",
			(char*)&device_node->name));

		*flags = 0x0F;
		status = AE_OK;
	}

	else if (ACPI_FAILURE (status)) {
		ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "_STA on %4.4s failed %s\n",
			(char*)&device_node->name,
			acpi_format_exception (status)));
	}

	else /* success */ {
		/* Did we get a return object? */

		if (!obj_desc) {
			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? */

		if (obj_desc->common.type != ACPI_TYPE_INTEGER) {
			status = AE_TYPE;
			ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
				"Type returned from _STA was not a number: %X \n",
				obj_desc->common.type));
		}

		else {
			/* Extract the status flags */

			*flags = (u32) obj_desc->integer.value;
		}

		/* On exit, we must delete the return object */

		acpi_ut_remove_reference (obj_desc);
	}

	return_ACPI_STATUS (status);
}