Print this page
acpica-unix2-20130823
PANKOVs restructure
Split |
Close |
Expand all |
Collapse all |
--- old/usr/src/uts/intel/io/acpica/executer/exoparg6.c
+++ new/usr/src/common/acpica/components/executer/exoparg6.c
1 -
2 1 /******************************************************************************
3 2 *
4 3 * Module Name: exoparg6 - AML execution - opcodes with 6 arguments
5 4 *
6 5 *****************************************************************************/
7 6
8 7 /*
9 - * Copyright (C) 2000 - 2011, Intel Corp.
8 + * Copyright (C) 2000 - 2013, Intel Corp.
10 9 * All rights reserved.
11 10 *
12 11 * Redistribution and use in source and binary forms, with or without
13 12 * modification, are permitted provided that the following conditions
14 13 * are met:
15 14 * 1. Redistributions of source code must retain the above copyright
16 15 * notice, this list of conditions, and the following disclaimer,
17 16 * without modification.
18 17 * 2. Redistributions in binary form must reproduce at minimum a disclaimer
19 18 * substantially similar to the "NO WARRANTY" disclaimer below
20 19 * ("Disclaimer") and any redistribution must be conditioned upon
21 20 * including a substantially similar Disclaimer requirement for further
22 21 * binary redistribution.
23 22 * 3. Neither the names of the above-listed copyright holders nor the names
24 23 * of any contributors may be used to endorse or promote products derived
25 24 * from this software without specific prior written permission.
26 25 *
27 26 * Alternatively, this software may be distributed under the terms of the
28 27 * GNU General Public License ("GPL") version 2 as published by the Free
29 28 * Software Foundation.
30 29 *
31 30 * NO WARRANTY
32 31 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
33 32 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
34 33 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
35 34 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
36 35 * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
37 36 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
38 37 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
39 38 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
40 39 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
41 40 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
42 41 * POSSIBILITY OF SUCH DAMAGES.
43 42 */
44 43
45 44 #define __EXOPARG6_C__
46 45
47 46 #include "acpi.h"
48 47 #include "accommon.h"
49 48 #include "acinterp.h"
50 49 #include "acparser.h"
51 50 #include "amlcode.h"
52 51
53 52
54 53 #define _COMPONENT ACPI_EXECUTER
55 54 ACPI_MODULE_NAME ("exoparg6")
56 55
57 56
58 57 /*!
59 58 * Naming convention for AML interpreter execution routines.
60 59 *
61 60 * The routines that begin execution of AML opcodes are named with a common
62 61 * convention based upon the number of arguments, the number of target operands,
63 62 * and whether or not a value is returned:
64 63 *
65 64 * AcpiExOpcode_xA_yT_zR
66 65 *
67 66 * Where:
68 67 *
69 68 * xA - ARGUMENTS: The number of arguments (input operands) that are
70 69 * required for this opcode type (1 through 6 args).
71 70 * yT - TARGETS: The number of targets (output operands) that are required
72 71 * for this opcode type (0, 1, or 2 targets).
73 72 * zR - RETURN VALUE: Indicates whether this opcode type returns a value
74 73 * as the function return (0 or 1).
75 74 *
76 75 * The AcpiExOpcode* functions are called via the Dispatcher component with
77 76 * fully resolved operands.
78 77 !*/
79 78
80 79 /* Local prototypes */
81 80
82 81 static BOOLEAN
83 82 AcpiExDoMatch (
84 83 UINT32 MatchOp,
85 84 ACPI_OPERAND_OBJECT *PackageObj,
86 85 ACPI_OPERAND_OBJECT *MatchObj);
87 86
88 87
89 88 /*******************************************************************************
90 89 *
91 90 * FUNCTION: AcpiExDoMatch
92 91 *
93 92 * PARAMETERS: MatchOp - The AML match operand
94 93 * PackageObj - Object from the target package
95 94 * MatchObj - Object to be matched
96 95 *
97 96 * RETURN: TRUE if the match is successful, FALSE otherwise
98 97 *
99 98 * DESCRIPTION: Implements the low-level match for the ASL Match operator.
100 99 * Package elements will be implicitly converted to the type of
101 100 * the match object (Integer/Buffer/String).
102 101 *
103 102 ******************************************************************************/
104 103
105 104 static BOOLEAN
106 105 AcpiExDoMatch (
107 106 UINT32 MatchOp,
108 107 ACPI_OPERAND_OBJECT *PackageObj,
109 108 ACPI_OPERAND_OBJECT *MatchObj)
110 109 {
111 110 BOOLEAN LogicalResult = TRUE;
112 111 ACPI_STATUS Status;
113 112
114 113
115 114 /*
116 115 * Note: Since the PackageObj/MatchObj ordering is opposite to that of
117 116 * the standard logical operators, we have to reverse them when we call
118 117 * DoLogicalOp in order to make the implicit conversion rules work
119 118 * correctly. However, this means we have to flip the entire equation
120 119 * also. A bit ugly perhaps, but overall, better than fussing the
121 120 * parameters around at runtime, over and over again.
122 121 *
123 122 * Below, P[i] refers to the package element, M refers to the Match object.
↓ open down ↓ |
104 lines elided |
↑ open up ↑ |
124 123 */
125 124 switch (MatchOp)
126 125 {
127 126 case MATCH_MTR:
128 127
129 128 /* Always true */
130 129
131 130 break;
132 131
133 132 case MATCH_MEQ:
134 -
135 133 /*
136 134 * True if equal: (P[i] == M)
137 135 * Change to: (M == P[i])
138 136 */
139 137 Status = AcpiExDoLogicalOp (AML_LEQUAL_OP, MatchObj, PackageObj,
140 138 &LogicalResult);
141 139 if (ACPI_FAILURE (Status))
142 140 {
143 141 return (FALSE);
144 142 }
145 143 break;
146 144
147 145 case MATCH_MLE:
148 -
149 146 /*
150 147 * True if less than or equal: (P[i] <= M) (P[i] NotGreater than M)
151 148 * Change to: (M >= P[i]) (M NotLess than P[i])
152 149 */
153 150 Status = AcpiExDoLogicalOp (AML_LLESS_OP, MatchObj, PackageObj,
154 151 &LogicalResult);
155 152 if (ACPI_FAILURE (Status))
156 153 {
157 154 return (FALSE);
158 155 }
159 156 LogicalResult = (BOOLEAN) !LogicalResult;
160 157 break;
161 158
162 159 case MATCH_MLT:
163 -
164 160 /*
165 161 * True if less than: (P[i] < M)
166 162 * Change to: (M > P[i])
167 163 */
168 164 Status = AcpiExDoLogicalOp (AML_LGREATER_OP, MatchObj, PackageObj,
169 165 &LogicalResult);
170 166 if (ACPI_FAILURE (Status))
171 167 {
172 168 return (FALSE);
173 169 }
174 170 break;
175 171
176 172 case MATCH_MGE:
177 -
178 173 /*
179 174 * True if greater than or equal: (P[i] >= M) (P[i] NotLess than M)
180 175 * Change to: (M <= P[i]) (M NotGreater than P[i])
181 176 */
182 177 Status = AcpiExDoLogicalOp (AML_LGREATER_OP, MatchObj, PackageObj,
183 178 &LogicalResult);
184 179 if (ACPI_FAILURE (Status))
185 180 {
186 181 return (FALSE);
187 182 }
188 183 LogicalResult = (BOOLEAN)!LogicalResult;
189 184 break;
190 185
191 186 case MATCH_MGT:
192 -
193 187 /*
194 188 * True if greater than: (P[i] > M)
195 189 * Change to: (M < P[i])
196 190 */
197 191 Status = AcpiExDoLogicalOp (AML_LLESS_OP, MatchObj, PackageObj,
198 192 &LogicalResult);
199 193 if (ACPI_FAILURE (Status))
200 194 {
201 195 return (FALSE);
202 196 }
203 197 break;
204 198
205 199 default:
206 200
207 201 /* Undefined */
208 202
209 203 return (FALSE);
210 204 }
211 205
212 - return LogicalResult;
206 + return (LogicalResult);
213 207 }
214 208
215 209
216 210 /*******************************************************************************
217 211 *
218 212 * FUNCTION: AcpiExOpcode_6A_0T_1R
219 213 *
220 214 * PARAMETERS: WalkState - Current walk state
221 215 *
222 216 * RETURN: Status
223 217 *
224 218 * DESCRIPTION: Execute opcode with 6 arguments, no target, and a return value
225 219 *
226 220 ******************************************************************************/
227 221
228 222 ACPI_STATUS
229 223 AcpiExOpcode_6A_0T_1R (
230 224 ACPI_WALK_STATE *WalkState)
231 225 {
232 226 ACPI_OPERAND_OBJECT **Operand = &WalkState->Operands[0];
233 227 ACPI_OPERAND_OBJECT *ReturnDesc = NULL;
234 228 ACPI_STATUS Status = AE_OK;
235 229 UINT64 Index;
236 230 ACPI_OPERAND_OBJECT *ThisElement;
237 231
238 232
239 233 ACPI_FUNCTION_TRACE_STR (ExOpcode_6A_0T_1R,
240 234 AcpiPsGetOpcodeName (WalkState->Opcode));
241 235
242 236
243 237 switch (WalkState->Opcode)
244 238 {
245 239 case AML_MATCH_OP:
246 240 /*
247 241 * Match (SearchPkg[0], MatchOp1[1], MatchObj1[2],
248 242 * MatchOp2[3], MatchObj2[4], StartIndex[5])
249 243 */
250 244
251 245 /* Validate both Match Term Operators (MTR, MEQ, etc.) */
252 246
253 247 if ((Operand[1]->Integer.Value > MAX_MATCH_OPERATOR) ||
254 248 (Operand[3]->Integer.Value > MAX_MATCH_OPERATOR))
255 249 {
256 250 ACPI_ERROR ((AE_INFO, "Match operator out of range"));
257 251 Status = AE_AML_OPERAND_VALUE;
258 252 goto Cleanup;
259 253 }
260 254
261 255 /* Get the package StartIndex, validate against the package length */
262 256
263 257 Index = Operand[5]->Integer.Value;
264 258 if (Index >= Operand[0]->Package.Count)
265 259 {
266 260 ACPI_ERROR ((AE_INFO,
267 261 "Index (0x%8.8X%8.8X) beyond package end (0x%X)",
268 262 ACPI_FORMAT_UINT64 (Index), Operand[0]->Package.Count));
269 263 Status = AE_AML_PACKAGE_LIMIT;
270 264 goto Cleanup;
271 265 }
272 266
273 267 /* Create an integer for the return value */
274 268 /* Default return value is ACPI_UINT64_MAX if no match found */
275 269
276 270 ReturnDesc = AcpiUtCreateIntegerObject (ACPI_UINT64_MAX);
277 271 if (!ReturnDesc)
278 272 {
279 273 Status = AE_NO_MEMORY;
280 274 goto Cleanup;
↓ open down ↓ |
58 lines elided |
↑ open up ↑ |
281 275
282 276 }
283 277
284 278 /*
285 279 * Examine each element until a match is found. Both match conditions
286 280 * must be satisfied for a match to occur. Within the loop,
287 281 * "continue" signifies that the current element does not match
288 282 * and the next should be examined.
289 283 *
290 284 * Upon finding a match, the loop will terminate via "break" at
291 - * the bottom. If it terminates "normally", MatchValue will be
285 + * the bottom. If it terminates "normally", MatchValue will be
292 286 * ACPI_UINT64_MAX (Ones) (its initial value) indicating that no
293 287 * match was found.
294 288 */
295 289 for ( ; Index < Operand[0]->Package.Count; Index++)
296 290 {
297 291 /* Get the current package element */
298 292
299 293 ThisElement = Operand[0]->Package.Elements[Index];
300 294
301 295 /* Treat any uninitialized (NULL) elements as non-matching */
302 296
303 297 if (!ThisElement)
304 298 {
305 299 continue;
306 300 }
307 301
308 302 /*
309 303 * Both match conditions must be satisfied. Execution of a continue
310 304 * (proceed to next iteration of enclosing for loop) signifies a
311 305 * non-match.
312 306 */
313 307 if (!AcpiExDoMatch ((UINT32) Operand[1]->Integer.Value,
314 308 ThisElement, Operand[2]))
315 309 {
316 310 continue;
317 311 }
318 312
319 313 if (!AcpiExDoMatch ((UINT32) Operand[3]->Integer.Value,
320 314 ThisElement, Operand[4]))
321 315 {
↓ open down ↓ |
20 lines elided |
↑ open up ↑ |
322 316 continue;
323 317 }
324 318
325 319 /* Match found: Index is the return value */
326 320
327 321 ReturnDesc->Integer.Value = Index;
328 322 break;
329 323 }
330 324 break;
331 325
332 -
333 326 case AML_LOAD_TABLE_OP:
334 327
335 328 Status = AcpiExLoadTableOp (WalkState, &ReturnDesc);
336 329 break;
337 330
338 -
339 331 default:
340 332
341 333 ACPI_ERROR ((AE_INFO, "Unknown AML opcode 0x%X",
342 334 WalkState->Opcode));
343 335 Status = AE_AML_BAD_OPCODE;
344 336 goto Cleanup;
345 337 }
346 338
347 339
348 340 Cleanup:
349 341
350 342 /* Delete return object on error */
351 343
352 344 if (ACPI_FAILURE (Status))
353 345 {
354 346 AcpiUtRemoveReference (ReturnDesc);
355 347 }
356 348
357 349 /* Save return object on success */
358 350
359 351 else
360 352 {
361 353 WalkState->ResultObj = ReturnDesc;
362 354 }
363 355
364 356 return_ACPI_STATUS (Status);
365 357 }
↓ open down ↓ |
17 lines elided |
↑ open up ↑ |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX