Print this page
acpica-unix2-20130823
PANKOVs restructure
Split |
Close |
Expand all |
Collapse all |
--- old/usr/src/uts/intel/io/acpica/utilities/uteval.c
+++ new/usr/src/common/acpica/components/utilities/uteval.c
1 1 /******************************************************************************
2 2 *
3 3 * Module Name: uteval - Object evaluation
4 4 *
5 5 *****************************************************************************/
6 6
7 7 /*
8 - * Copyright (C) 2000 - 2011, Intel Corp.
8 + * Copyright (C) 2000 - 2013, Intel Corp.
9 9 * All rights reserved.
10 10 *
11 11 * Redistribution and use in source and binary forms, with or without
12 12 * modification, are permitted provided that the following conditions
13 13 * are met:
14 14 * 1. Redistributions of source code must retain the above copyright
15 15 * notice, this list of conditions, and the following disclaimer,
16 16 * without modification.
17 17 * 2. Redistributions in binary form must reproduce at minimum a disclaimer
18 18 * substantially similar to the "NO WARRANTY" disclaimer below
19 19 * ("Disclaimer") and any redistribution must be conditioned upon
20 20 * including a substantially similar Disclaimer requirement for further
21 21 * binary redistribution.
22 22 * 3. Neither the names of the above-listed copyright holders nor the names
23 23 * of any contributors may be used to endorse or promote products derived
24 24 * from this software without specific prior written permission.
25 25 *
26 26 * Alternatively, this software may be distributed under the terms of the
27 27 * GNU General Public License ("GPL") version 2 as published by the Free
28 28 * Software Foundation.
29 29 *
30 30 * NO WARRANTY
31 31 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
32 32 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
33 33 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
34 34 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
35 35 * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
36 36 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
37 37 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
38 38 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
39 39 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
40 40 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
41 41 * POSSIBILITY OF SUCH DAMAGES.
42 42 */
43 43
44 44 #define __UTEVAL_C__
45 45
46 46 #include "acpi.h"
47 47 #include "accommon.h"
48 48 #include "acnamesp.h"
49 49
50 50
51 51 #define _COMPONENT ACPI_UTILITIES
52 52 ACPI_MODULE_NAME ("uteval")
53 53
54 54
55 55 /*******************************************************************************
56 56 *
57 57 * FUNCTION: AcpiUtEvaluateObject
58 58 *
59 59 * PARAMETERS: PrefixNode - Starting node
60 60 * Path - Path to object from starting node
61 61 * ExpectedReturnTypes - Bitmap of allowed return types
62 62 * ReturnDesc - Where a return value is stored
63 63 *
64 64 * RETURN: Status
65 65 *
66 66 * DESCRIPTION: Evaluates a namespace object and verifies the type of the
67 67 * return object. Common code that simplifies accessing objects
68 68 * that have required return objects of fixed types.
69 69 *
70 70 * NOTE: Internal function, no parameter validation
71 71 *
72 72 ******************************************************************************/
73 73
74 74 ACPI_STATUS
75 75 AcpiUtEvaluateObject (
76 76 ACPI_NAMESPACE_NODE *PrefixNode,
77 77 char *Path,
78 78 UINT32 ExpectedReturnBtypes,
79 79 ACPI_OPERAND_OBJECT **ReturnDesc)
80 80 {
81 81 ACPI_EVALUATE_INFO *Info;
82 82 ACPI_STATUS Status;
83 83 UINT32 ReturnBtype;
84 84
85 85
86 86 ACPI_FUNCTION_TRACE (UtEvaluateObject);
87 87
↓ open down ↓ |
69 lines elided |
↑ open up ↑ |
88 88
89 89 /* Allocate the evaluation information block */
90 90
91 91 Info = ACPI_ALLOCATE_ZEROED (sizeof (ACPI_EVALUATE_INFO));
92 92 if (!Info)
93 93 {
94 94 return_ACPI_STATUS (AE_NO_MEMORY);
95 95 }
96 96
97 97 Info->PrefixNode = PrefixNode;
98 - Info->Pathname = Path;
98 + Info->RelativePathname = Path;
99 99
100 100 /* Evaluate the object/method */
101 101
102 102 Status = AcpiNsEvaluate (Info);
103 103 if (ACPI_FAILURE (Status))
104 104 {
105 105 if (Status == AE_NOT_FOUND)
106 106 {
107 107 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "[%4.4s.%s] was not found\n",
108 108 AcpiUtGetNodeName (PrefixNode), Path));
109 109 }
110 110 else
111 111 {
112 112 ACPI_ERROR_METHOD ("Method execution failed",
113 113 PrefixNode, Path, Status);
114 114 }
115 115
116 116 goto Cleanup;
117 117 }
118 118
119 119 /* Did we get a return object? */
120 120
121 121 if (!Info->ReturnObject)
122 122 {
123 123 if (ExpectedReturnBtypes)
124 124 {
125 125 ACPI_ERROR_METHOD ("No object was returned from",
126 126 PrefixNode, Path, AE_NOT_EXIST);
127 127
128 128 Status = AE_NOT_EXIST;
↓ open down ↓ |
20 lines elided |
↑ open up ↑ |
129 129 }
130 130
131 131 goto Cleanup;
132 132 }
133 133
134 134 /* Map the return object type to the bitmapped type */
135 135
136 136 switch ((Info->ReturnObject)->Common.Type)
137 137 {
138 138 case ACPI_TYPE_INTEGER:
139 +
139 140 ReturnBtype = ACPI_BTYPE_INTEGER;
140 141 break;
141 142
142 143 case ACPI_TYPE_BUFFER:
144 +
143 145 ReturnBtype = ACPI_BTYPE_BUFFER;
144 146 break;
145 147
146 148 case ACPI_TYPE_STRING:
149 +
147 150 ReturnBtype = ACPI_BTYPE_STRING;
148 151 break;
149 152
150 153 case ACPI_TYPE_PACKAGE:
154 +
151 155 ReturnBtype = ACPI_BTYPE_PACKAGE;
152 156 break;
153 157
154 158 default:
159 +
155 160 ReturnBtype = 0;
156 161 break;
157 162 }
158 163
159 164 if ((AcpiGbl_EnableInterpreterSlack) &&
160 165 (!ExpectedReturnBtypes))
161 166 {
162 167 /*
163 168 * We received a return object, but one was not expected. This can
164 169 * happen frequently if the "implicit return" feature is enabled.
165 170 * Just delete the return object and return AE_OK.
166 171 */
167 172 AcpiUtRemoveReference (Info->ReturnObject);
168 173 goto Cleanup;
169 174 }
170 175
171 176 /* Is the return object one of the expected types? */
172 177
173 178 if (!(ExpectedReturnBtypes & ReturnBtype))
174 179 {
175 180 ACPI_ERROR_METHOD ("Return object type is incorrect",
176 181 PrefixNode, Path, AE_TYPE);
177 182
178 183 ACPI_ERROR ((AE_INFO,
179 184 "Type returned from %s was incorrect: %s, expected Btypes: 0x%X",
180 185 Path, AcpiUtGetObjectTypeName (Info->ReturnObject),
181 186 ExpectedReturnBtypes));
182 187
183 188 /* On error exit, we must delete the return object */
184 189
185 190 AcpiUtRemoveReference (Info->ReturnObject);
186 191 Status = AE_TYPE;
187 192 goto Cleanup;
188 193 }
189 194
190 195 /* Object type is OK, return it */
191 196
192 197 *ReturnDesc = Info->ReturnObject;
193 198
194 199 Cleanup:
195 200 ACPI_FREE (Info);
196 201 return_ACPI_STATUS (Status);
197 202 }
198 203
199 204
200 205 /*******************************************************************************
201 206 *
202 207 * FUNCTION: AcpiUtEvaluateNumericObject
203 208 *
204 209 * PARAMETERS: ObjectName - Object name to be evaluated
205 210 * DeviceNode - Node for the device
206 211 * Value - Where the value is returned
207 212 *
208 213 * RETURN: Status
209 214 *
210 215 * DESCRIPTION: Evaluates a numeric namespace object for a selected device
211 216 * and stores result in *Value.
212 217 *
213 218 * NOTE: Internal function, no parameter validation
214 219 *
215 220 ******************************************************************************/
216 221
217 222 ACPI_STATUS
218 223 AcpiUtEvaluateNumericObject (
219 224 char *ObjectName,
220 225 ACPI_NAMESPACE_NODE *DeviceNode,
221 226 UINT64 *Value)
222 227 {
223 228 ACPI_OPERAND_OBJECT *ObjDesc;
224 229 ACPI_STATUS Status;
225 230
226 231
227 232 ACPI_FUNCTION_TRACE (UtEvaluateNumericObject);
228 233
229 234
230 235 Status = AcpiUtEvaluateObject (DeviceNode, ObjectName,
231 236 ACPI_BTYPE_INTEGER, &ObjDesc);
232 237 if (ACPI_FAILURE (Status))
233 238 {
234 239 return_ACPI_STATUS (Status);
235 240 }
236 241
237 242 /* Get the returned Integer */
238 243
239 244 *Value = ObjDesc->Integer.Value;
240 245
241 246 /* On exit, we must delete the return object */
242 247
243 248 AcpiUtRemoveReference (ObjDesc);
244 249 return_ACPI_STATUS (Status);
245 250 }
246 251
247 252
↓ open down ↓ |
83 lines elided |
↑ open up ↑ |
248 253 /*******************************************************************************
249 254 *
250 255 * FUNCTION: AcpiUtExecute_STA
251 256 *
252 257 * PARAMETERS: DeviceNode - Node for the device
253 258 * Flags - Where the status flags are returned
254 259 *
255 260 * RETURN: Status
256 261 *
257 262 * DESCRIPTION: Executes _STA for selected device and stores results in
258 - * *Flags.
263 + * *Flags. If _STA does not exist, then the device is assumed
264 + * to be present/functional/enabled (as per the ACPI spec).
259 265 *
260 266 * NOTE: Internal function, no parameter validation
261 267 *
262 268 ******************************************************************************/
263 269
264 270 ACPI_STATUS
265 271 AcpiUtExecute_STA (
266 272 ACPI_NAMESPACE_NODE *DeviceNode,
267 273 UINT32 *Flags)
268 274 {
269 275 ACPI_OPERAND_OBJECT *ObjDesc;
270 276 ACPI_STATUS Status;
271 277
↓ open down ↓ |
3 lines elided |
↑ open up ↑ |
272 278
273 279 ACPI_FUNCTION_TRACE (UtExecute_STA);
274 280
275 281
276 282 Status = AcpiUtEvaluateObject (DeviceNode, METHOD_NAME__STA,
277 283 ACPI_BTYPE_INTEGER, &ObjDesc);
278 284 if (ACPI_FAILURE (Status))
279 285 {
280 286 if (AE_NOT_FOUND == Status)
281 287 {
288 + /*
289 + * if _STA does not exist, then (as per the ACPI specification),
290 + * the returned flags will indicate that the device is present,
291 + * functional, and enabled.
292 + */
282 293 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
283 294 "_STA on %4.4s was not found, assuming device is present\n",
284 295 AcpiUtGetNodeName (DeviceNode)));
285 296
286 297 *Flags = ACPI_UINT32_MAX;
287 298 Status = AE_OK;
288 299 }
289 300
290 301 return_ACPI_STATUS (Status);
291 302 }
292 303
293 304 /* Extract the status flags */
294 305
295 306 *Flags = (UINT32) ObjDesc->Integer.Value;
296 307
297 308 /* On exit, we must delete the return object */
298 309
299 310 AcpiUtRemoveReference (ObjDesc);
300 311 return_ACPI_STATUS (Status);
301 312 }
302 313
303 314
304 315 /*******************************************************************************
305 316 *
306 317 * FUNCTION: AcpiUtExecutePowerMethods
307 318 *
308 319 * PARAMETERS: DeviceNode - Node for the device
309 320 * MethodNames - Array of power method names
310 321 * MethodCount - Number of methods to execute
311 322 * OutValues - Where the power method values are returned
312 323 *
313 324 * RETURN: Status, OutValues
314 325 *
315 326 * DESCRIPTION: Executes the specified power methods for the device and returns
316 327 * the result(s).
317 328 *
318 329 * NOTE: Internal function, no parameter validation
319 330 *
320 331 ******************************************************************************/
321 332
322 333 ACPI_STATUS
323 334 AcpiUtExecutePowerMethods (
324 335 ACPI_NAMESPACE_NODE *DeviceNode,
325 336 const char **MethodNames,
326 337 UINT8 MethodCount,
327 338 UINT8 *OutValues)
328 339 {
329 340 ACPI_OPERAND_OBJECT *ObjDesc;
330 341 ACPI_STATUS Status;
331 342 ACPI_STATUS FinalStatus = AE_NOT_FOUND;
332 343 UINT32 i;
333 344
334 345
335 346 ACPI_FUNCTION_TRACE (UtExecutePowerMethods);
336 347
337 348
338 349 for (i = 0; i < MethodCount; i++)
339 350 {
340 351 /*
341 352 * Execute the power method (_SxD or _SxW). The only allowable
342 353 * return type is an Integer.
343 354 */
344 355 Status = AcpiUtEvaluateObject (DeviceNode,
345 356 ACPI_CAST_PTR (char, MethodNames[i]),
346 357 ACPI_BTYPE_INTEGER, &ObjDesc);
347 358 if (ACPI_SUCCESS (Status))
348 359 {
349 360 OutValues[i] = (UINT8) ObjDesc->Integer.Value;
350 361
351 362 /* Delete the return object */
352 363
353 364 AcpiUtRemoveReference (ObjDesc);
354 365 FinalStatus = AE_OK; /* At least one value is valid */
355 366 continue;
356 367 }
357 368
358 369 OutValues[i] = ACPI_UINT8_MAX;
359 370 if (Status == AE_NOT_FOUND)
360 371 {
361 372 continue; /* Ignore if not found */
362 373 }
363 374
364 375 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Failed %s on Device %4.4s, %s\n",
365 376 ACPI_CAST_PTR (char, MethodNames[i]),
366 377 AcpiUtGetNodeName (DeviceNode), AcpiFormatException (Status)));
367 378 }
368 379
369 380 return_ACPI_STATUS (FinalStatus);
370 381 }
↓ open down ↓ |
79 lines elided |
↑ open up ↑ |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX