Print this page
acpica-unix2-20130823
PANKOVs restructure
Split |
Close |
Expand all |
Collapse all |
--- old/usr/src/uts/intel/io/acpica/parser/psargs.c
+++ new/usr/src/common/acpica/components/parser/psargs.c
1 1 /******************************************************************************
2 2 *
3 3 * Module Name: psargs - Parse AML opcode arguments
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 __PSARGS_C__
45 45
46 46 #include "acpi.h"
47 47 #include "accommon.h"
48 48 #include "acparser.h"
49 49 #include "amlcode.h"
50 50 #include "acnamesp.h"
51 51 #include "acdispat.h"
52 52
53 53 #define _COMPONENT ACPI_PARSER
54 54 ACPI_MODULE_NAME ("psargs")
55 55
56 56 /* Local prototypes */
57 57
58 58 static UINT32
59 59 AcpiPsGetNextPackageLength (
60 60 ACPI_PARSE_STATE *ParserState);
61 61
62 62 static ACPI_PARSE_OBJECT *
63 63 AcpiPsGetNextField (
64 64 ACPI_PARSE_STATE *ParserState);
65 65
66 66
67 67 /*******************************************************************************
68 68 *
69 69 * FUNCTION: AcpiPsGetNextPackageLength
70 70 *
71 71 * PARAMETERS: ParserState - Current parser state object
72 72 *
73 73 * RETURN: Decoded package length. On completion, the AML pointer points
74 74 * past the length byte or bytes.
75 75 *
76 76 * DESCRIPTION: Decode and return a package length field.
77 77 * Note: Largest package length is 28 bits, from ACPI specification
78 78 *
79 79 ******************************************************************************/
80 80
81 81 static UINT32
82 82 AcpiPsGetNextPackageLength (
83 83 ACPI_PARSE_STATE *ParserState)
84 84 {
85 85 UINT8 *Aml = ParserState->Aml;
86 86 UINT32 PackageLength = 0;
87 87 UINT32 ByteCount;
88 88 UINT8 ByteZeroMask = 0x3F; /* Default [0:5] */
89 89
90 90
91 91 ACPI_FUNCTION_TRACE (PsGetNextPackageLength);
92 92
93 93
94 94 /*
95 95 * Byte 0 bits [6:7] contain the number of additional bytes
96 96 * used to encode the package length, either 0,1,2, or 3
97 97 */
98 98 ByteCount = (Aml[0] >> 6);
99 99 ParserState->Aml += ((ACPI_SIZE) ByteCount + 1);
100 100
101 101 /* Get bytes 3, 2, 1 as needed */
102 102
103 103 while (ByteCount)
104 104 {
105 105 /*
106 106 * Final bit positions for the package length bytes:
107 107 * Byte3->[20:27]
108 108 * Byte2->[12:19]
109 109 * Byte1->[04:11]
110 110 * Byte0->[00:03]
111 111 */
112 112 PackageLength |= (Aml[ByteCount] << ((ByteCount << 3) - 4));
113 113
114 114 ByteZeroMask = 0x0F; /* Use bits [0:3] of byte 0 */
115 115 ByteCount--;
116 116 }
117 117
118 118 /* Byte 0 is a special case, either bits [0:3] or [0:5] are used */
119 119
120 120 PackageLength |= (Aml[0] & ByteZeroMask);
121 121 return_UINT32 (PackageLength);
122 122 }
123 123
↓ open down ↓ |
105 lines elided |
↑ open up ↑ |
124 124
125 125 /*******************************************************************************
126 126 *
127 127 * FUNCTION: AcpiPsGetNextPackageEnd
128 128 *
129 129 * PARAMETERS: ParserState - Current parser state object
130 130 *
131 131 * RETURN: Pointer to end-of-package +1
132 132 *
133 133 * DESCRIPTION: Get next package length and return a pointer past the end of
134 - * the package. Consumes the package length field
134 + * the package. Consumes the package length field
135 135 *
136 136 ******************************************************************************/
137 137
138 138 UINT8 *
139 139 AcpiPsGetNextPackageEnd (
140 140 ACPI_PARSE_STATE *ParserState)
141 141 {
142 142 UINT8 *Start = ParserState->Aml;
143 143 UINT32 PackageLength;
144 144
145 145
146 146 ACPI_FUNCTION_TRACE (PsGetNextPackageEnd);
147 147
148 148
149 149 /* Function below updates ParserState->Aml */
150 150
151 151 PackageLength = AcpiPsGetNextPackageLength (ParserState);
152 152
153 153 return_PTR (Start + PackageLength); /* end of package */
154 154 }
155 155
↓ open down ↓ |
11 lines elided |
↑ open up ↑ |
156 156
157 157 /*******************************************************************************
158 158 *
159 159 * FUNCTION: AcpiPsGetNextNamestring
160 160 *
161 161 * PARAMETERS: ParserState - Current parser state object
162 162 *
163 163 * RETURN: Pointer to the start of the name string (pointer points into
164 164 * the AML.
165 165 *
166 - * DESCRIPTION: Get next raw namestring within the AML stream. Handles all name
167 - * prefix characters. Set parser state to point past the string.
166 + * DESCRIPTION: Get next raw namestring within the AML stream. Handles all name
167 + * prefix characters. Set parser state to point past the string.
168 168 * (Name is consumed from the AML.)
169 169 *
170 170 ******************************************************************************/
171 171
172 172 char *
173 173 AcpiPsGetNextNamestring (
174 174 ACPI_PARSE_STATE *ParserState)
175 175 {
176 176 UINT8 *Start = ParserState->Aml;
177 177 UINT8 *End = ParserState->Aml;
178 178
179 179
180 180 ACPI_FUNCTION_TRACE (PsGetNextNamestring);
181 181
182 182
183 183 /* Point past any namestring prefix characters (backslash or carat) */
184 184
185 - while (AcpiPsIsPrefixChar (*End))
185 + while (ACPI_IS_ROOT_PREFIX (*End) ||
186 + ACPI_IS_PARENT_PREFIX (*End))
186 187 {
187 188 End++;
188 189 }
189 190
190 191 /* Decode the path prefix character */
191 192
192 193 switch (*End)
193 194 {
194 195 case 0:
195 196
196 197 /* NullName */
197 198
198 199 if (End == Start)
199 200 {
200 201 Start = NULL;
201 202 }
202 203 End++;
203 204 break;
204 205
205 206 case AML_DUAL_NAME_PREFIX:
206 207
207 208 /* Two name segments */
208 209
209 210 End += 1 + (2 * ACPI_NAME_SIZE);
210 211 break;
211 212
212 213 case AML_MULTI_NAME_PREFIX_OP:
213 214
214 215 /* Multiple name segments, 4 chars each, count in next byte */
215 216
216 217 End += 2 + (*(End + 1) * ACPI_NAME_SIZE);
217 218 break;
218 219
219 220 default:
220 221
221 222 /* Single name segment */
222 223
223 224 End += ACPI_NAME_SIZE;
224 225 break;
225 226 }
226 227
227 228 ParserState->Aml = End;
228 229 return_PTR ((char *) Start);
229 230 }
230 231
231 232
232 233 /*******************************************************************************
233 234 *
234 235 * FUNCTION: AcpiPsGetNextNamepath
235 236 *
236 237 * PARAMETERS: ParserState - Current parser state object
↓ open down ↓ |
41 lines elided |
↑ open up ↑ |
237 238 * Arg - Where the namepath will be stored
238 239 * ArgCount - If the namepath points to a control method
239 240 * the method's argument is returned here.
240 241 * PossibleMethodCall - Whether the namepath can possibly be the
241 242 * start of a method call
242 243 *
243 244 * RETURN: Status
244 245 *
245 246 * DESCRIPTION: Get next name (if method call, return # of required args).
246 247 * Names are looked up in the internal namespace to determine
247 - * if the name represents a control method. If a method
248 + * if the name represents a control method. If a method
248 249 * is found, the number of arguments to the method is returned.
249 250 * This information is critical for parsing to continue correctly.
250 251 *
251 252 ******************************************************************************/
252 253
253 254 ACPI_STATUS
254 255 AcpiPsGetNextNamepath (
255 256 ACPI_WALK_STATE *WalkState,
256 257 ACPI_PARSE_STATE *ParserState,
257 258 ACPI_PARSE_OBJECT *Arg,
258 259 BOOLEAN PossibleMethodCall)
259 260 {
260 261 ACPI_STATUS Status;
261 262 char *Path;
262 263 ACPI_PARSE_OBJECT *NameOp;
263 264 ACPI_OPERAND_OBJECT *MethodDesc;
264 265 ACPI_NAMESPACE_NODE *Node;
265 266 UINT8 *Start = ParserState->Aml;
266 267
267 268
268 269 ACPI_FUNCTION_TRACE (PsGetNextNamepath);
269 270
270 271
271 272 Path = AcpiPsGetNextNamestring (ParserState);
272 273 AcpiPsInitOp (Arg, AML_INT_NAMEPATH_OP);
273 274
274 275 /* Null path case is allowed, just exit */
275 276
276 277 if (!Path)
277 278 {
278 279 Arg->Common.Value.Name = Path;
279 280 return_ACPI_STATUS (AE_OK);
280 281 }
281 282
282 283 /*
283 284 * Lookup the name in the internal namespace, starting with the current
284 285 * scope. We don't want to add anything new to the namespace here,
285 286 * however, so we use MODE_EXECUTE.
286 287 * Allow searching of the parent tree, but don't open a new scope -
287 288 * we just want to lookup the object (must be mode EXECUTE to perform
288 289 * the upsearch)
289 290 */
290 291 Status = AcpiNsLookup (WalkState->ScopeInfo, Path,
291 292 ACPI_TYPE_ANY, ACPI_IMODE_EXECUTE,
292 293 ACPI_NS_SEARCH_PARENT | ACPI_NS_DONT_OPEN_SCOPE, NULL, &Node);
293 294
294 295 /*
295 296 * If this name is a control method invocation, we must
296 297 * setup the method call
297 298 */
298 299 if (ACPI_SUCCESS (Status) &&
299 300 PossibleMethodCall &&
300 301 (Node->Type == ACPI_TYPE_METHOD))
301 302 {
302 303 if (WalkState->Opcode == AML_UNLOAD_OP)
303 304 {
304 305 /*
305 306 * AcpiPsGetNextNamestring has increased the AML pointer,
306 307 * so we need to restore the saved AML pointer for method call.
307 308 */
308 309 WalkState->ParserState.Aml = Start;
309 310 WalkState->ArgCount = 1;
310 311 AcpiPsInitOp (Arg, AML_INT_METHODCALL_OP);
311 312 return_ACPI_STATUS (AE_OK);
312 313 }
313 314
314 315 /* This name is actually a control method invocation */
315 316
316 317 MethodDesc = AcpiNsGetAttachedObject (Node);
317 318 ACPI_DEBUG_PRINT ((ACPI_DB_PARSE,
318 319 "Control Method - %p Desc %p Path=%p\n", Node, MethodDesc, Path));
319 320
320 321 NameOp = AcpiPsAllocOp (AML_INT_NAMEPATH_OP);
321 322 if (!NameOp)
322 323 {
323 324 return_ACPI_STATUS (AE_NO_MEMORY);
324 325 }
325 326
326 327 /* Change Arg into a METHOD CALL and attach name to it */
327 328
328 329 AcpiPsInitOp (Arg, AML_INT_METHODCALL_OP);
329 330 NameOp->Common.Value.Name = Path;
330 331
331 332 /* Point METHODCALL/NAME to the METHOD Node */
332 333
333 334 NameOp->Common.Node = Node;
334 335 AcpiPsAppendArg (Arg, NameOp);
335 336
336 337 if (!MethodDesc)
337 338 {
338 339 ACPI_ERROR ((AE_INFO,
339 340 "Control Method %p has no attached object",
340 341 Node));
341 342 return_ACPI_STATUS (AE_AML_INTERNAL);
342 343 }
343 344
344 345 ACPI_DEBUG_PRINT ((ACPI_DB_PARSE,
345 346 "Control Method - %p Args %X\n",
346 347 Node, MethodDesc->Method.ParamCount));
347 348
348 349 /* Get the number of arguments to expect */
349 350
350 351 WalkState->ArgCount = MethodDesc->Method.ParamCount;
351 352 return_ACPI_STATUS (AE_OK);
352 353 }
353 354
354 355 /*
355 356 * Special handling if the name was not found during the lookup -
356 357 * some NotFound cases are allowed
357 358 */
358 359 if (Status == AE_NOT_FOUND)
359 360 {
360 361 /* 1) NotFound is ok during load pass 1/2 (allow forward references) */
361 362
362 363 if ((WalkState->ParseFlags & ACPI_PARSE_MODE_MASK) !=
363 364 ACPI_PARSE_EXECUTE)
364 365 {
365 366 Status = AE_OK;
366 367 }
367 368
368 369 /* 2) NotFound during a CondRefOf(x) is ok by definition */
369 370
370 371 else if (WalkState->Op->Common.AmlOpcode == AML_COND_REF_OF_OP)
371 372 {
372 373 Status = AE_OK;
373 374 }
374 375
375 376 /*
376 377 * 3) NotFound while building a Package is ok at this point, we
377 378 * may flag as an error later if slack mode is not enabled.
378 379 * (Some ASL code depends on allowing this behavior)
379 380 */
380 381 else if ((Arg->Common.Parent) &&
381 382 ((Arg->Common.Parent->Common.AmlOpcode == AML_PACKAGE_OP) ||
382 383 (Arg->Common.Parent->Common.AmlOpcode == AML_VAR_PACKAGE_OP)))
383 384 {
384 385 Status = AE_OK;
385 386 }
386 387 }
387 388
388 389 /* Final exception check (may have been changed from code above) */
389 390
390 391 if (ACPI_FAILURE (Status))
391 392 {
392 393 ACPI_ERROR_NAMESPACE (Path, Status);
393 394
394 395 if ((WalkState->ParseFlags & ACPI_PARSE_MODE_MASK) ==
395 396 ACPI_PARSE_EXECUTE)
396 397 {
397 398 /* Report a control method execution error */
398 399
399 400 Status = AcpiDsMethodError (Status, WalkState);
400 401 }
401 402 }
402 403
403 404 /* Save the namepath */
404 405
405 406 Arg->Common.Value.Name = Path;
406 407 return_ACPI_STATUS (Status);
407 408 }
408 409
409 410
410 411 /*******************************************************************************
411 412 *
412 413 * FUNCTION: AcpiPsGetNextSimpleArg
413 414 *
414 415 * PARAMETERS: ParserState - Current parser state object
415 416 * ArgType - The argument type (AML_*_ARG)
416 417 * Arg - Where the argument is returned
417 418 *
418 419 * RETURN: None
419 420 *
420 421 * DESCRIPTION: Get the next simple argument (constant, string, or namestring)
421 422 *
422 423 ******************************************************************************/
423 424
424 425 void
425 426 AcpiPsGetNextSimpleArg (
426 427 ACPI_PARSE_STATE *ParserState,
427 428 UINT32 ArgType,
428 429 ACPI_PARSE_OBJECT *Arg)
429 430 {
430 431 UINT32 Length;
431 432 UINT16 Opcode;
432 433 UINT8 *Aml = ParserState->Aml;
433 434
434 435
435 436 ACPI_FUNCTION_TRACE_U32 (PsGetNextSimpleArg, ArgType);
436 437
437 438
438 439 switch (ArgType)
↓ open down ↓ |
181 lines elided |
↑ open up ↑ |
439 440 {
440 441 case ARGP_BYTEDATA:
441 442
442 443 /* Get 1 byte from the AML stream */
443 444
444 445 Opcode = AML_BYTE_OP;
445 446 Arg->Common.Value.Integer = (UINT64) *Aml;
446 447 Length = 1;
447 448 break;
448 449
449 -
450 450 case ARGP_WORDDATA:
451 451
452 452 /* Get 2 bytes from the AML stream */
453 453
454 454 Opcode = AML_WORD_OP;
455 455 ACPI_MOVE_16_TO_64 (&Arg->Common.Value.Integer, Aml);
456 456 Length = 2;
457 457 break;
458 458
459 -
460 459 case ARGP_DWORDDATA:
461 460
462 461 /* Get 4 bytes from the AML stream */
463 462
464 463 Opcode = AML_DWORD_OP;
465 464 ACPI_MOVE_32_TO_64 (&Arg->Common.Value.Integer, Aml);
466 465 Length = 4;
467 466 break;
468 467
469 -
470 468 case ARGP_QWORDDATA:
471 469
472 470 /* Get 8 bytes from the AML stream */
473 471
474 472 Opcode = AML_QWORD_OP;
475 473 ACPI_MOVE_64_TO_64 (&Arg->Common.Value.Integer, Aml);
476 474 Length = 8;
477 475 break;
478 476
479 -
480 477 case ARGP_CHARLIST:
481 478
482 479 /* Get a pointer to the string, point past the string */
483 480
484 481 Opcode = AML_STRING_OP;
485 482 Arg->Common.Value.String = ACPI_CAST_PTR (char, Aml);
486 483
487 484 /* Find the null terminator */
488 485
489 486 Length = 0;
490 487 while (Aml[Length])
491 488 {
492 489 Length++;
493 490 }
494 491 Length++;
495 492 break;
496 493
497 -
498 494 case ARGP_NAME:
499 495 case ARGP_NAMESTRING:
500 496
501 497 AcpiPsInitOp (Arg, AML_INT_NAMEPATH_OP);
502 498 Arg->Common.Value.Name = AcpiPsGetNextNamestring (ParserState);
503 499 return_VOID;
504 500
505 -
506 501 default:
507 502
508 503 ACPI_ERROR ((AE_INFO, "Invalid ArgType 0x%X", ArgType));
509 504 return_VOID;
510 505 }
511 506
512 507 AcpiPsInitOp (Arg, Opcode);
513 508 ParserState->Aml += Length;
514 509 return_VOID;
515 510 }
516 511
517 512
518 513 /*******************************************************************************
519 514 *
520 515 * FUNCTION: AcpiPsGetNextField
521 516 *
522 517 * PARAMETERS: ParserState - Current parser state object
523 518 *
↓ open down ↓ |
8 lines elided |
↑ open up ↑ |
524 519 * RETURN: A newly allocated FIELD op
525 520 *
526 521 * DESCRIPTION: Get next field (NamedField, ReservedField, or AccessField)
527 522 *
528 523 ******************************************************************************/
529 524
530 525 static ACPI_PARSE_OBJECT *
531 526 AcpiPsGetNextField (
532 527 ACPI_PARSE_STATE *ParserState)
533 528 {
534 - UINT32 AmlOffset = (UINT32)
535 - ACPI_PTR_DIFF (ParserState->Aml,
536 - ParserState->AmlStart);
529 + UINT32 AmlOffset;
537 530 ACPI_PARSE_OBJECT *Field;
531 + ACPI_PARSE_OBJECT *Arg = NULL;
538 532 UINT16 Opcode;
539 533 UINT32 Name;
534 + UINT8 AccessType;
535 + UINT8 AccessAttribute;
536 + UINT8 AccessLength;
537 + UINT32 PkgLength;
538 + UINT8 *PkgEnd;
539 + UINT32 BufferLength;
540 540
541 541
542 542 ACPI_FUNCTION_TRACE (PsGetNextField);
543 543
544 544
545 + AmlOffset = (UINT32) ACPI_PTR_DIFF (
546 + ParserState->Aml, ParserState->AmlStart);
547 +
545 548 /* Determine field type */
546 549
547 550 switch (ACPI_GET8 (ParserState->Aml))
548 551 {
549 - default:
552 + case AML_FIELD_OFFSET_OP:
550 553
551 - Opcode = AML_INT_NAMEDFIELD_OP;
554 + Opcode = AML_INT_RESERVEDFIELD_OP;
555 + ParserState->Aml++;
552 556 break;
553 557
554 - case 0x00:
558 + case AML_FIELD_ACCESS_OP:
555 559
556 - Opcode = AML_INT_RESERVEDFIELD_OP;
560 + Opcode = AML_INT_ACCESSFIELD_OP;
557 561 ParserState->Aml++;
558 562 break;
559 563
560 - case 0x01:
564 + case AML_FIELD_CONNECTION_OP:
561 565
562 - Opcode = AML_INT_ACCESSFIELD_OP;
566 + Opcode = AML_INT_CONNECTION_OP;
563 567 ParserState->Aml++;
564 568 break;
569 +
570 + case AML_FIELD_EXT_ACCESS_OP:
571 +
572 + Opcode = AML_INT_EXTACCESSFIELD_OP;
573 + ParserState->Aml++;
574 + break;
575 +
576 + default:
577 +
578 + Opcode = AML_INT_NAMEDFIELD_OP;
579 + break;
565 580 }
566 581
567 582 /* Allocate a new field op */
568 583
569 584 Field = AcpiPsAllocOp (Opcode);
570 585 if (!Field)
571 586 {
572 587 return_PTR (NULL);
573 588 }
574 589
575 590 Field->Common.AmlOffset = AmlOffset;
576 591
577 592 /* Decode the field type */
578 593
579 594 switch (Opcode)
580 595 {
581 596 case AML_INT_NAMEDFIELD_OP:
582 597
583 598 /* Get the 4-character name */
584 599
585 600 ACPI_MOVE_32_TO_32 (&Name, ParserState->Aml);
586 601 AcpiPsSetName (Field, Name);
587 602 ParserState->Aml += ACPI_NAME_SIZE;
588 603
589 604 /* Get the length which is encoded as a package length */
590 605
591 606 Field->Common.Value.Size = AcpiPsGetNextPackageLength (ParserState);
592 607 break;
593 608
↓ open down ↓ |
19 lines elided |
↑ open up ↑ |
594 609
595 610 case AML_INT_RESERVEDFIELD_OP:
596 611
597 612 /* Get the length which is encoded as a package length */
598 613
599 614 Field->Common.Value.Size = AcpiPsGetNextPackageLength (ParserState);
600 615 break;
601 616
602 617
603 618 case AML_INT_ACCESSFIELD_OP:
619 + case AML_INT_EXTACCESSFIELD_OP:
604 620
605 621 /*
606 622 * Get AccessType and AccessAttrib and merge into the field Op
607 - * AccessType is first operand, AccessAttribute is second
623 + * AccessType is first operand, AccessAttribute is second. stuff
624 + * these bytes into the node integer value for convenience.
608 625 */
609 - Field->Common.Value.Integer = (((UINT32) ACPI_GET8 (ParserState->Aml) << 8));
626 +
627 + /* Get the two bytes (Type/Attribute) */
628 +
629 + AccessType = ACPI_GET8 (ParserState->Aml);
610 630 ParserState->Aml++;
611 - Field->Common.Value.Integer |= ACPI_GET8 (ParserState->Aml);
631 + AccessAttribute = ACPI_GET8 (ParserState->Aml);
612 632 ParserState->Aml++;
633 +
634 + Field->Common.Value.Integer = (UINT8) AccessType;
635 + Field->Common.Value.Integer |= (UINT16) (AccessAttribute << 8);
636 +
637 + /* This opcode has a third byte, AccessLength */
638 +
639 + if (Opcode == AML_INT_EXTACCESSFIELD_OP)
640 + {
641 + AccessLength = ACPI_GET8 (ParserState->Aml);
642 + ParserState->Aml++;
643 +
644 + Field->Common.Value.Integer |= (UINT32) (AccessLength << 16);
645 + }
613 646 break;
614 647
648 +
649 + case AML_INT_CONNECTION_OP:
650 +
651 + /*
652 + * Argument for Connection operator can be either a Buffer
653 + * (resource descriptor), or a NameString.
654 + */
655 + if (ACPI_GET8 (ParserState->Aml) == AML_BUFFER_OP)
656 + {
657 + ParserState->Aml++;
658 +
659 + PkgEnd = ParserState->Aml;
660 + PkgLength = AcpiPsGetNextPackageLength (ParserState);
661 + PkgEnd += PkgLength;
662 +
663 + if (ParserState->Aml < PkgEnd)
664 + {
665 + /* Non-empty list */
666 +
667 + Arg = AcpiPsAllocOp (AML_INT_BYTELIST_OP);
668 + if (!Arg)
669 + {
670 + AcpiPsFreeOp (Field);
671 + return_PTR (NULL);
672 + }
673 +
674 + /* Get the actual buffer length argument */
675 +
676 + Opcode = ACPI_GET8 (ParserState->Aml);
677 + ParserState->Aml++;
678 +
679 + switch (Opcode)
680 + {
681 + case AML_BYTE_OP: /* AML_BYTEDATA_ARG */
682 +
683 + BufferLength = ACPI_GET8 (ParserState->Aml);
684 + ParserState->Aml += 1;
685 + break;
686 +
687 + case AML_WORD_OP: /* AML_WORDDATA_ARG */
688 +
689 + BufferLength = ACPI_GET16 (ParserState->Aml);
690 + ParserState->Aml += 2;
691 + break;
692 +
693 + case AML_DWORD_OP: /* AML_DWORDATA_ARG */
694 +
695 + BufferLength = ACPI_GET32 (ParserState->Aml);
696 + ParserState->Aml += 4;
697 + break;
698 +
699 + default:
700 +
701 + BufferLength = 0;
702 + break;
703 + }
704 +
705 + /* Fill in bytelist data */
706 +
707 + Arg->Named.Value.Size = BufferLength;
708 + Arg->Named.Data = ParserState->Aml;
709 + }
710 +
711 + /* Skip to End of byte data */
712 +
713 + ParserState->Aml = PkgEnd;
714 + }
715 + else
716 + {
717 + Arg = AcpiPsAllocOp (AML_INT_NAMEPATH_OP);
718 + if (!Arg)
719 + {
720 + AcpiPsFreeOp (Field);
721 + return_PTR (NULL);
722 + }
723 +
724 + /* Get the Namestring argument */
725 +
726 + Arg->Common.Value.Name = AcpiPsGetNextNamestring (ParserState);
727 + }
728 +
729 + /* Link the buffer/namestring to parent (CONNECTION_OP) */
730 +
731 + AcpiPsAppendArg (Field, Arg);
732 + break;
733 +
734 +
615 735 default:
616 736
617 737 /* Opcode was set in previous switch */
618 738 break;
619 739 }
620 740
621 741 return_PTR (Field);
622 742 }
623 743
624 744
625 745 /*******************************************************************************
626 746 *
627 747 * FUNCTION: AcpiPsGetNextArg
628 748 *
629 749 * PARAMETERS: WalkState - Current state
630 750 * ParserState - Current parser state object
631 751 * ArgType - The argument type (AML_*_ARG)
632 752 * ReturnArg - Where the next arg is returned
633 753 *
634 754 * RETURN: Status, and an op object containing the next argument.
635 755 *
636 756 * DESCRIPTION: Get next argument (including complex list arguments that require
637 757 * pushing the parser stack)
638 758 *
639 759 ******************************************************************************/
640 760
641 761 ACPI_STATUS
642 762 AcpiPsGetNextArg (
643 763 ACPI_WALK_STATE *WalkState,
644 764 ACPI_PARSE_STATE *ParserState,
645 765 UINT32 ArgType,
646 766 ACPI_PARSE_OBJECT **ReturnArg)
647 767 {
648 768 ACPI_PARSE_OBJECT *Arg = NULL;
649 769 ACPI_PARSE_OBJECT *Prev = NULL;
650 770 ACPI_PARSE_OBJECT *Field;
651 771 UINT32 Subop;
652 772 ACPI_STATUS Status = AE_OK;
653 773
654 774
655 775 ACPI_FUNCTION_TRACE_PTR (PsGetNextArg, ParserState);
656 776
657 777
658 778 switch (ArgType)
659 779 {
660 780 case ARGP_BYTEDATA:
661 781 case ARGP_WORDDATA:
662 782 case ARGP_DWORDDATA:
663 783 case ARGP_CHARLIST:
664 784 case ARGP_NAME:
665 785 case ARGP_NAMESTRING:
666 786
↓ open down ↓ |
42 lines elided |
↑ open up ↑ |
667 787 /* Constants, strings, and namestrings are all the same size */
668 788
669 789 Arg = AcpiPsAllocOp (AML_BYTE_OP);
670 790 if (!Arg)
671 791 {
672 792 return_ACPI_STATUS (AE_NO_MEMORY);
673 793 }
674 794 AcpiPsGetNextSimpleArg (ParserState, ArgType, Arg);
675 795 break;
676 796
677 -
678 797 case ARGP_PKGLENGTH:
679 798
680 799 /* Package length, nothing returned */
681 800
682 801 ParserState->PkgEnd = AcpiPsGetNextPackageEnd (ParserState);
683 802 break;
684 803
685 -
686 804 case ARGP_FIELDLIST:
687 805
688 806 if (ParserState->Aml < ParserState->PkgEnd)
689 807 {
690 808 /* Non-empty list */
691 809
692 810 while (ParserState->Aml < ParserState->PkgEnd)
693 811 {
694 812 Field = AcpiPsGetNextField (ParserState);
695 813 if (!Field)
696 814 {
697 815 return_ACPI_STATUS (AE_NO_MEMORY);
698 816 }
699 817
700 818 if (Prev)
701 819 {
702 820 Prev->Common.Next = Field;
703 821 }
704 822 else
705 823 {
706 824 Arg = Field;
↓ open down ↓ |
11 lines elided |
↑ open up ↑ |
707 825 }
708 826 Prev = Field;
709 827 }
710 828
711 829 /* Skip to End of byte data */
712 830
713 831 ParserState->Aml = ParserState->PkgEnd;
714 832 }
715 833 break;
716 834
717 -
718 835 case ARGP_BYTELIST:
719 836
720 837 if (ParserState->Aml < ParserState->PkgEnd)
721 838 {
722 839 /* Non-empty list */
723 840
724 841 Arg = AcpiPsAllocOp (AML_INT_BYTELIST_OP);
725 842 if (!Arg)
726 843 {
727 844 return_ACPI_STATUS (AE_NO_MEMORY);
728 845 }
729 846
730 847 /* Fill in bytelist data */
731 848
↓ open down ↓ |
4 lines elided |
↑ open up ↑ |
732 849 Arg->Common.Value.Size = (UINT32)
733 850 ACPI_PTR_DIFF (ParserState->PkgEnd, ParserState->Aml);
734 851 Arg->Named.Data = ParserState->Aml;
735 852
736 853 /* Skip to End of byte data */
737 854
738 855 ParserState->Aml = ParserState->PkgEnd;
739 856 }
740 857 break;
741 858
742 -
743 859 case ARGP_TARGET:
744 860 case ARGP_SUPERNAME:
745 861 case ARGP_SIMPLENAME:
746 862
747 863 Subop = AcpiPsPeekOpcode (ParserState);
748 864 if (Subop == 0 ||
749 865 AcpiPsIsLeadingChar (Subop) ||
750 - AcpiPsIsPrefixChar (Subop))
866 + ACPI_IS_ROOT_PREFIX (Subop) ||
867 + ACPI_IS_PARENT_PREFIX (Subop))
751 868 {
752 869 /* NullName or NameString */
753 870
754 871 Arg = AcpiPsAllocOp (AML_INT_NAMEPATH_OP);
755 872 if (!Arg)
756 873 {
757 874 return_ACPI_STATUS (AE_NO_MEMORY);
758 875 }
759 876
760 877 /* To support SuperName arg of Unload */
761 878
762 879 if (WalkState->Opcode == AML_UNLOAD_OP)
763 880 {
764 881 Status = AcpiPsGetNextNamepath (WalkState, ParserState, Arg, 1);
765 882
766 883 /*
767 884 * If the SuperName arg of Unload is a method call,
768 885 * we have restored the AML pointer, just free this Arg
769 886 */
770 887 if (Arg->Common.AmlOpcode == AML_INT_METHODCALL_OP)
771 888 {
772 889 AcpiPsFreeOp (Arg);
773 890 Arg = NULL;
774 891 }
775 892 }
776 893 else
777 894 {
778 895 Status = AcpiPsGetNextNamepath (WalkState, ParserState, Arg, 0);
↓ open down ↓ |
18 lines elided |
↑ open up ↑ |
779 896 }
780 897 }
781 898 else
782 899 {
783 900 /* Single complex argument, nothing returned */
784 901
785 902 WalkState->ArgCount = 1;
786 903 }
787 904 break;
788 905
789 -
790 906 case ARGP_DATAOBJ:
791 907 case ARGP_TERMARG:
792 908
793 909 /* Single complex argument, nothing returned */
794 910
795 911 WalkState->ArgCount = 1;
796 912 break;
797 913
798 -
799 914 case ARGP_DATAOBJLIST:
800 915 case ARGP_TERMLIST:
801 916 case ARGP_OBJLIST:
802 917
803 918 if (ParserState->Aml < ParserState->PkgEnd)
804 919 {
805 920 /* Non-empty list of variable arguments, nothing returned */
806 921
807 922 WalkState->ArgCount = ACPI_VAR_ARGS;
808 923 }
809 924 break;
810 925
811 -
812 926 default:
813 927
814 928 ACPI_ERROR ((AE_INFO, "Invalid ArgType: 0x%X", ArgType));
815 929 Status = AE_AML_OPERAND_TYPE;
816 930 break;
817 931 }
818 932
819 933 *ReturnArg = Arg;
820 934 return_ACPI_STATUS (Status);
821 935 }
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX