Blame view
drivers/acpi/acpica/uteval.c
10.1 KB
1da177e4c Linux-2.6.12-rc2 |
1 2 3 4 5 6 7 |
/****************************************************************************** * * Module Name: uteval - Object evaluation * *****************************************************************************/ /* |
c8100dc46 ACPICA: Additiona... |
8 |
* Copyright (C) 2000 - 2016, Intel Corp. |
1da177e4c Linux-2.6.12-rc2 |
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 |
* All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions, and the following disclaimer, * without modification. * 2. Redistributions in binary form must reproduce at minimum a disclaimer * substantially similar to the "NO WARRANTY" disclaimer below * ("Disclaimer") and any redistribution must be conditioned upon * including a substantially similar Disclaimer requirement for further * binary redistribution. * 3. Neither the names of the above-listed copyright holders nor the names * of any contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * Alternatively, this software may be distributed under the terms of the * GNU General Public License ("GPL") version 2 as published by the Free * Software Foundation. * * NO WARRANTY * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGES. */ |
1da177e4c Linux-2.6.12-rc2 |
43 |
#include <acpi/acpi.h> |
e2f7a7772 ACPICA: hide priv... |
44 45 |
#include "accommon.h" #include "acnamesp.h" |
1da177e4c Linux-2.6.12-rc2 |
46 |
|
1da177e4c Linux-2.6.12-rc2 |
47 |
#define _COMPONENT ACPI_UTILITIES |
4be44fcd3 [ACPI] Lindent al... |
48 |
ACPI_MODULE_NAME("uteval") |
1da177e4c Linux-2.6.12-rc2 |
49 |
|
ae00d8124 ACPI: extend "acp... |
50 51 |
/******************************************************************************* * |
1da177e4c Linux-2.6.12-rc2 |
52 53 54 |
* FUNCTION: acpi_ut_evaluate_object * * PARAMETERS: prefix_node - Starting node |
ba494beea ACPICA: AcpiSrc: ... |
55 |
* path - Path to object from starting node |
1da177e4c Linux-2.6.12-rc2 |
56 57 58 59 60 61 |
* expected_return_types - Bitmap of allowed return types * return_desc - Where a return value is stored * * RETURN: Status * * DESCRIPTION: Evaluates a namespace object and verifies the type of the |
15b8dd53f ACPICA: Major upd... |
62 |
* return object. Common code that simplifies accessing objects |
1da177e4c Linux-2.6.12-rc2 |
63 64 65 66 67 68 69 |
* that have required return objects of fixed types. * * NOTE: Internal function, no parameter validation * ******************************************************************************/ acpi_status |
b6872ff9a ACPICA: Split int... |
70 |
acpi_ut_evaluate_object(struct acpi_namespace_node *prefix_node, |
0dfaaa3d5 ACPICA: All: cons... |
71 |
const char *path, |
4be44fcd3 [ACPI] Lindent al... |
72 73 |
u32 expected_return_btypes, union acpi_operand_object **return_desc) |
1da177e4c Linux-2.6.12-rc2 |
74 |
{ |
4119532c9 ACPI: ACPICA 2006... |
75 |
struct acpi_evaluate_info *info; |
4be44fcd3 [ACPI] Lindent al... |
76 77 |
acpi_status status; u32 return_btype; |
1da177e4c Linux-2.6.12-rc2 |
78 |
|
b229cf92e ACPI: ACPICA 2006... |
79 |
ACPI_FUNCTION_TRACE(ut_evaluate_object); |
1da177e4c Linux-2.6.12-rc2 |
80 |
|
4119532c9 ACPI: ACPICA 2006... |
81 82 83 84 85 86 87 88 |
/* Allocate the evaluation information block */ info = ACPI_ALLOCATE_ZEROED(sizeof(struct acpi_evaluate_info)); if (!info) { return_ACPI_STATUS(AE_NO_MEMORY); } info->prefix_node = prefix_node; |
29a241cc0 ACPICA: Add argum... |
89 |
info->relative_pathname = path; |
1da177e4c Linux-2.6.12-rc2 |
90 91 |
/* Evaluate the object/method */ |
4119532c9 ACPI: ACPICA 2006... |
92 |
status = acpi_ns_evaluate(info); |
4be44fcd3 [ACPI] Lindent al... |
93 |
if (ACPI_FAILURE(status)) { |
1da177e4c Linux-2.6.12-rc2 |
94 |
if (status == AE_NOT_FOUND) { |
4be44fcd3 [ACPI] Lindent al... |
95 96 97 98 99 100 |
ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "[%4.4s.%s] was not found ", acpi_ut_get_node_name(prefix_node), path)); } else { |
b8e4d8935 [ACPI] ACPICA 200... |
101 102 |
ACPI_ERROR_METHOD("Method execution failed", prefix_node, path, status); |
1da177e4c Linux-2.6.12-rc2 |
103 |
} |
4119532c9 ACPI: ACPICA 2006... |
104 |
goto cleanup; |
1da177e4c Linux-2.6.12-rc2 |
105 106 107 |
} /* Did we get a return object? */ |
4119532c9 ACPI: ACPICA 2006... |
108 |
if (!info->return_object) { |
1da177e4c Linux-2.6.12-rc2 |
109 |
if (expected_return_btypes) { |
b8e4d8935 [ACPI] ACPICA 200... |
110 111 |
ACPI_ERROR_METHOD("No object was returned from", prefix_node, path, AE_NOT_EXIST); |
1da177e4c Linux-2.6.12-rc2 |
112 |
|
4119532c9 ACPI: ACPICA 2006... |
113 |
status = AE_NOT_EXIST; |
1da177e4c Linux-2.6.12-rc2 |
114 |
} |
4119532c9 ACPI: ACPICA 2006... |
115 |
goto cleanup; |
1da177e4c Linux-2.6.12-rc2 |
116 117 118 |
} /* Map the return object type to the bitmapped type */ |
3371c19c2 ACPICA: Remove AC... |
119 |
switch ((info->return_object)->common.type) { |
1da177e4c Linux-2.6.12-rc2 |
120 |
case ACPI_TYPE_INTEGER: |
1d1ea1b72 ACPICA: Standardi... |
121 |
|
1da177e4c Linux-2.6.12-rc2 |
122 123 124 125 |
return_btype = ACPI_BTYPE_INTEGER; break; case ACPI_TYPE_BUFFER: |
1d1ea1b72 ACPICA: Standardi... |
126 |
|
1da177e4c Linux-2.6.12-rc2 |
127 128 129 130 |
return_btype = ACPI_BTYPE_BUFFER; break; case ACPI_TYPE_STRING: |
1d1ea1b72 ACPICA: Standardi... |
131 |
|
1da177e4c Linux-2.6.12-rc2 |
132 133 134 135 |
return_btype = ACPI_BTYPE_STRING; break; case ACPI_TYPE_PACKAGE: |
1d1ea1b72 ACPICA: Standardi... |
136 |
|
1da177e4c Linux-2.6.12-rc2 |
137 138 139 140 |
return_btype = ACPI_BTYPE_PACKAGE; break; default: |
1d1ea1b72 ACPICA: Standardi... |
141 |
|
1da177e4c Linux-2.6.12-rc2 |
142 143 144 |
return_btype = 0; break; } |
4be44fcd3 [ACPI] Lindent al... |
145 |
if ((acpi_gbl_enable_interpreter_slack) && (!expected_return_btypes)) { |
1da177e4c Linux-2.6.12-rc2 |
146 |
/* |
15b8dd53f ACPICA: Major upd... |
147 |
* We received a return object, but one was not expected. This can |
1da177e4c Linux-2.6.12-rc2 |
148 149 150 |
* happen frequently if the "implicit return" feature is enabled. * Just delete the return object and return AE_OK. */ |
4119532c9 ACPI: ACPICA 2006... |
151 152 |
acpi_ut_remove_reference(info->return_object); goto cleanup; |
1da177e4c Linux-2.6.12-rc2 |
153 154 155 156 157 |
} /* Is the return object one of the expected types? */ if (!(expected_return_btypes & return_btype)) { |
b8e4d8935 [ACPI] ACPICA 200... |
158 159 160 161 |
ACPI_ERROR_METHOD("Return object type is incorrect", prefix_node, path, AE_TYPE); ACPI_ERROR((AE_INFO, |
f6a22b0bc ACPICA: Standardi... |
162 |
"Type returned from %s was incorrect: %s, expected Btypes: 0x%X", |
b8e4d8935 [ACPI] ACPICA 200... |
163 |
path, |
4119532c9 ACPI: ACPICA 2006... |
164 |
acpi_ut_get_object_type_name(info->return_object), |
b8e4d8935 [ACPI] ACPICA 200... |
165 |
expected_return_btypes)); |
1da177e4c Linux-2.6.12-rc2 |
166 167 |
/* On error exit, we must delete the return object */ |
4119532c9 ACPI: ACPICA 2006... |
168 169 170 |
acpi_ut_remove_reference(info->return_object); status = AE_TYPE; goto cleanup; |
1da177e4c Linux-2.6.12-rc2 |
171 172 173 |
} /* Object type is OK, return it */ |
4119532c9 ACPI: ACPICA 2006... |
174 |
*return_desc = info->return_object; |
10622bf8c ACPICA: Linuxize:... |
175 |
cleanup: |
4119532c9 ACPI: ACPICA 2006... |
176 177 |
ACPI_FREE(info); return_ACPI_STATUS(status); |
1da177e4c Linux-2.6.12-rc2 |
178 |
} |
1da177e4c Linux-2.6.12-rc2 |
179 180 181 182 |
/******************************************************************************* * * FUNCTION: acpi_ut_evaluate_numeric_object * |
44f6c0124 ACPICA 20050408 f... |
183 |
* PARAMETERS: object_name - Object name to be evaluated |
1da177e4c Linux-2.6.12-rc2 |
184 |
* device_node - Node for the device |
ba494beea ACPICA: AcpiSrc: ... |
185 |
* value - Where the value is returned |
1da177e4c Linux-2.6.12-rc2 |
186 187 188 189 |
* * RETURN: Status * * DESCRIPTION: Evaluates a numeric namespace object for a selected device |
15b8dd53f ACPICA: Major upd... |
190 |
* and stores result in *Value. |
1da177e4c Linux-2.6.12-rc2 |
191 192 193 194 195 196 |
* * NOTE: Internal function, no parameter validation * ******************************************************************************/ acpi_status |
0dfaaa3d5 ACPICA: All: cons... |
197 |
acpi_ut_evaluate_numeric_object(const char *object_name, |
4be44fcd3 [ACPI] Lindent al... |
198 |
struct acpi_namespace_node *device_node, |
5df7e6cb4 ACPICA: Remove ob... |
199 |
u64 *value) |
1da177e4c Linux-2.6.12-rc2 |
200 |
{ |
4be44fcd3 [ACPI] Lindent al... |
201 202 |
union acpi_operand_object *obj_desc; acpi_status status; |
1da177e4c Linux-2.6.12-rc2 |
203 |
|
b229cf92e ACPI: ACPICA 2006... |
204 |
ACPI_FUNCTION_TRACE(ut_evaluate_numeric_object); |
1da177e4c Linux-2.6.12-rc2 |
205 |
|
4be44fcd3 [ACPI] Lindent al... |
206 207 208 209 |
status = acpi_ut_evaluate_object(device_node, object_name, ACPI_BTYPE_INTEGER, &obj_desc); if (ACPI_FAILURE(status)) { return_ACPI_STATUS(status); |
1da177e4c Linux-2.6.12-rc2 |
210 211 212 |
} /* Get the returned Integer */ |
15b8dd53f ACPICA: Major upd... |
213 |
*value = obj_desc->integer.value; |
1da177e4c Linux-2.6.12-rc2 |
214 215 |
/* On exit, we must delete the return object */ |
4be44fcd3 [ACPI] Lindent al... |
216 217 |
acpi_ut_remove_reference(obj_desc); return_ACPI_STATUS(status); |
1da177e4c Linux-2.6.12-rc2 |
218 |
} |
1da177e4c Linux-2.6.12-rc2 |
219 220 221 222 223 |
/******************************************************************************* * * FUNCTION: acpi_ut_execute_STA * * PARAMETERS: device_node - Node for the device |
ba494beea ACPICA: AcpiSrc: ... |
224 |
* flags - Where the status flags are returned |
1da177e4c Linux-2.6.12-rc2 |
225 226 227 228 |
* * RETURN: Status * * DESCRIPTION: Executes _STA for selected device and stores results in |
a7d5caf6d ACPICA: Update co... |
229 230 |
* *Flags. If _STA does not exist, then the device is assumed * to be present/functional/enabled (as per the ACPI spec). |
1da177e4c Linux-2.6.12-rc2 |
231 232 233 234 235 236 |
* * NOTE: Internal function, no parameter validation * ******************************************************************************/ acpi_status |
4be44fcd3 [ACPI] Lindent al... |
237 |
acpi_ut_execute_STA(struct acpi_namespace_node *device_node, u32 * flags) |
1da177e4c Linux-2.6.12-rc2 |
238 |
{ |
4be44fcd3 [ACPI] Lindent al... |
239 240 |
union acpi_operand_object *obj_desc; acpi_status status; |
1da177e4c Linux-2.6.12-rc2 |
241 |
|
b229cf92e ACPI: ACPICA 2006... |
242 |
ACPI_FUNCTION_TRACE(ut_execute_STA); |
1da177e4c Linux-2.6.12-rc2 |
243 |
|
4be44fcd3 [ACPI] Lindent al... |
244 245 246 |
status = acpi_ut_evaluate_object(device_node, METHOD_NAME__STA, ACPI_BTYPE_INTEGER, &obj_desc); if (ACPI_FAILURE(status)) { |
1da177e4c Linux-2.6.12-rc2 |
247 |
if (AE_NOT_FOUND == status) { |
a7d5caf6d ACPICA: Update co... |
248 249 250 251 252 |
/* * if _STA does not exist, then (as per the ACPI specification), * the returned flags will indicate that the device is present, * functional, and enabled. */ |
4be44fcd3 [ACPI] Lindent al... |
253 254 255 256 |
ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "_STA on %4.4s was not found, assuming device is present ", acpi_ut_get_node_name(device_node))); |
1da177e4c Linux-2.6.12-rc2 |
257 |
|
defba1d8f [ACPI] ACPICA 200... |
258 |
*flags = ACPI_UINT32_MAX; |
1da177e4c Linux-2.6.12-rc2 |
259 260 |
status = AE_OK; } |
4be44fcd3 [ACPI] Lindent al... |
261 |
return_ACPI_STATUS(status); |
1da177e4c Linux-2.6.12-rc2 |
262 263 264 265 266 267 268 |
} /* Extract the status flags */ *flags = (u32) obj_desc->integer.value; /* On exit, we must delete the return object */ |
4be44fcd3 [ACPI] Lindent al... |
269 270 |
acpi_ut_remove_reference(obj_desc); return_ACPI_STATUS(status); |
1da177e4c Linux-2.6.12-rc2 |
271 |
} |
1da177e4c Linux-2.6.12-rc2 |
272 273 |
/******************************************************************************* * |
15b8dd53f ACPICA: Major upd... |
274 |
* FUNCTION: acpi_ut_execute_power_methods |
1da177e4c Linux-2.6.12-rc2 |
275 276 |
* * PARAMETERS: device_node - Node for the device |
15b8dd53f ACPICA: Major upd... |
277 278 279 |
* method_names - Array of power method names * method_count - Number of methods to execute * out_values - Where the power method values are returned |
1da177e4c Linux-2.6.12-rc2 |
280 |
* |
15b8dd53f ACPICA: Major upd... |
281 |
* RETURN: Status, out_values |
1da177e4c Linux-2.6.12-rc2 |
282 |
* |
15b8dd53f ACPICA: Major upd... |
283 284 |
* DESCRIPTION: Executes the specified power methods for the device and returns * the result(s). |
1da177e4c Linux-2.6.12-rc2 |
285 286 287 |
* * NOTE: Internal function, no parameter validation * |
15b8dd53f ACPICA: Major upd... |
288 |
******************************************************************************/ |
1da177e4c Linux-2.6.12-rc2 |
289 290 |
acpi_status |
15b8dd53f ACPICA: Major upd... |
291 292 293 |
acpi_ut_execute_power_methods(struct acpi_namespace_node *device_node, const char **method_names, u8 method_count, u8 *out_values) |
1da177e4c Linux-2.6.12-rc2 |
294 |
{ |
4be44fcd3 [ACPI] Lindent al... |
295 296 |
union acpi_operand_object *obj_desc; acpi_status status; |
15b8dd53f ACPICA: Major upd... |
297 |
acpi_status final_status = AE_NOT_FOUND; |
4be44fcd3 [ACPI] Lindent al... |
298 |
u32 i; |
1da177e4c Linux-2.6.12-rc2 |
299 |
|
15b8dd53f ACPICA: Major upd... |
300 |
ACPI_FUNCTION_TRACE(ut_execute_power_methods); |
1da177e4c Linux-2.6.12-rc2 |
301 |
|
15b8dd53f ACPICA: Major upd... |
302 303 304 305 306 |
for (i = 0; i < method_count; i++) { /* * Execute the power method (_sx_d or _sx_w). The only allowable * return type is an Integer. */ |
4be44fcd3 [ACPI] Lindent al... |
307 |
status = acpi_ut_evaluate_object(device_node, |
defba1d8f [ACPI] ACPICA 200... |
308 |
ACPI_CAST_PTR(char, |
15b8dd53f ACPICA: Major upd... |
309 |
method_names[i]), |
defba1d8f [ACPI] ACPICA 200... |
310 |
ACPI_BTYPE_INTEGER, &obj_desc); |
15b8dd53f ACPICA: Major upd... |
311 312 |
if (ACPI_SUCCESS(status)) { out_values[i] = (u8)obj_desc->integer.value; |
1da177e4c Linux-2.6.12-rc2 |
313 314 |
/* Delete the return object */ |
4be44fcd3 [ACPI] Lindent al... |
315 |
acpi_ut_remove_reference(obj_desc); |
15b8dd53f ACPICA: Major upd... |
316 317 |
final_status = AE_OK; /* At least one value is valid */ continue; |
1da177e4c Linux-2.6.12-rc2 |
318 |
} |
15b8dd53f ACPICA: Major upd... |
319 320 321 322 323 324 325 326 327 328 329 330 |
out_values[i] = ACPI_UINT8_MAX; if (status == AE_NOT_FOUND) { continue; /* Ignore if not found */ } ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "Failed %s on Device %4.4s, %s ", ACPI_CAST_PTR(char, method_names[i]), acpi_ut_get_node_name(device_node), acpi_format_exception(status))); |
1da177e4c Linux-2.6.12-rc2 |
331 |
} |
15b8dd53f ACPICA: Major upd... |
332 |
return_ACPI_STATUS(final_status); |
1da177e4c Linux-2.6.12-rc2 |
333 |
} |