1 /******************************************************************************* 2 * 3 * Module Name: rsmisc - Miscellaneous resource descriptors 4 * 5 ******************************************************************************/ 6 7 /****************************************************************************** 8 * 9 * 1. Copyright Notice 10 * 11 * Some or all of this work - Copyright (c) 1999 - 2013, Intel Corp. 12 * All rights reserved. 13 * 14 * 2. License 15 * 16 * 2.1. This is your license from Intel Corp. under its intellectual property 17 * rights. You may have additional license terms from the party that provided 18 * you this software, covering your right to use that party's intellectual 19 * property rights. 20 * 21 * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a 22 * copy of the source code appearing in this file ("Covered Code") an 23 * irrevocable, perpetual, worldwide license under Intel's copyrights in the 24 * base code distributed originally by Intel ("Original Intel Code") to copy, 25 * make derivatives, distribute, use and display any portion of the Covered 26 * Code in any form, with the right to sublicense such rights; and 27 * 28 * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent 29 * license (with the right to sublicense), under only those claims of Intel 30 * patents that are infringed by the Original Intel Code, to make, use, sell, 31 * offer to sell, and import the Covered Code and derivative works thereof 32 * solely to the minimum extent necessary to exercise the above copyright 33 * license, and in no event shall the patent license extend to any additions 34 * to or modifications of the Original Intel Code. No other license or right 35 * is granted directly or by implication, estoppel or otherwise; 36 * 37 * The above copyright and patent license is granted only if the following 38 * conditions are met: 39 * 40 * 3. Conditions 41 * 42 * 3.1. Redistribution of Source with Rights to Further Distribute Source. 43 * Redistribution of source code of any substantial portion of the Covered 44 * Code or modification with rights to further distribute source must include 45 * the above Copyright Notice, the above License, this list of Conditions, 46 * and the following Disclaimer and Export Compliance provision. In addition, 47 * Licensee must cause all Covered Code to which Licensee contributes to 48 * contain a file documenting the changes Licensee made to create that Covered 49 * Code and the date of any change. Licensee must include in that file the 50 * documentation of any changes made by any predecessor Licensee. Licensee 51 * must include a prominent statement that the modification is derived, 52 * directly or indirectly, from Original Intel Code. 53 * 54 * 3.2. Redistribution of Source with no Rights to Further Distribute Source. 55 * Redistribution of source code of any substantial portion of the Covered 56 * Code or modification without rights to further distribute source must 57 * include the following Disclaimer and Export Compliance provision in the 58 * documentation and/or other materials provided with distribution. In 59 * addition, Licensee may not authorize further sublicense of source of any 60 * portion of the Covered Code, and must include terms to the effect that the 61 * license from Licensee to its licensee is limited to the intellectual 62 * property embodied in the software Licensee provides to its licensee, and 63 * not to intellectual property embodied in modifications its licensee may 64 * make. 65 * 66 * 3.3. Redistribution of Executable. Redistribution in executable form of any 67 * substantial portion of the Covered Code or modification must reproduce the 68 * above Copyright Notice, and the following Disclaimer and Export Compliance 69 * provision in the documentation and/or other materials provided with the 70 * distribution. 71 * 72 * 3.4. Intel retains all right, title, and interest in and to the Original 73 * Intel Code. 74 * 75 * 3.5. Neither the name Intel nor any other trademark owned or controlled by 76 * Intel shall be used in advertising or otherwise to promote the sale, use or 77 * other dealings in products derived from or relating to the Covered Code 78 * without prior written authorization from Intel. 79 * 80 * 4. Disclaimer and Export Compliance 81 * 82 * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED 83 * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE 84 * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, 85 * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY 86 * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY 87 * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A 88 * PARTICULAR PURPOSE. 89 * 90 * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES 91 * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR 92 * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, 93 * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY 94 * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL 95 * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS 96 * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY 97 * LIMITED REMEDY. 98 * 99 * 4.3. Licensee shall not export, either directly or indirectly, any of this 100 * software or system incorporating such software without first obtaining any 101 * required license or other approval from the U. S. Department of Commerce or 102 * any other agency or department of the United States Government. In the 103 * event Licensee exports any such software from the United States or 104 * re-exports any such software from a foreign destination, Licensee shall 105 * ensure that the distribution and export/re-export of the software is in 106 * compliance with all laws, regulations, orders, or other restrictions of the 107 * U.S. Export Administration Regulations. Licensee agrees that neither it nor 108 * any of its subsidiaries will export/re-export any technical data, process, 109 * software, or service, directly or indirectly, to any country for which the 110 * United States government or any agency thereof requires an export license, 111 * other governmental approval, or letter of assurance, without first obtaining 112 * such license, approval or letter. 113 * 114 *****************************************************************************/ 115 116 #define __RSMISC_C__ 117 118 #include "acpi.h" 119 #include "accommon.h" 120 #include "acresrc.h" 121 122 #define _COMPONENT ACPI_RESOURCES 123 ACPI_MODULE_NAME ("rsmisc") 124 125 126 #define INIT_RESOURCE_TYPE(i) i->ResourceOffset 127 #define INIT_RESOURCE_LENGTH(i) i->AmlOffset 128 #define INIT_TABLE_LENGTH(i) i->Value 129 130 #define COMPARE_OPCODE(i) i->ResourceOffset 131 #define COMPARE_TARGET(i) i->AmlOffset 132 #define COMPARE_VALUE(i) i->Value 133 134 135 /******************************************************************************* 136 * 137 * FUNCTION: AcpiRsConvertAmlToResource 138 * 139 * PARAMETERS: Resource - Pointer to the resource descriptor 140 * Aml - Where the AML descriptor is returned 141 * Info - Pointer to appropriate conversion table 142 * 143 * RETURN: Status 144 * 145 * DESCRIPTION: Convert an external AML resource descriptor to the corresponding 146 * internal resource descriptor 147 * 148 ******************************************************************************/ 149 150 ACPI_STATUS 151 AcpiRsConvertAmlToResource ( 152 ACPI_RESOURCE *Resource, 153 AML_RESOURCE *Aml, 154 ACPI_RSCONVERT_INFO *Info) 155 { 156 ACPI_RS_LENGTH AmlResourceLength; 157 void *Source; 158 void *Destination; 159 char *Target; 160 UINT8 Count; 161 UINT8 FlagsMode = FALSE; 162 UINT16 ItemCount = 0; 163 UINT16 Temp16 = 0; 164 165 166 ACPI_FUNCTION_TRACE (RsConvertAmlToResource); 167 168 169 if (!Info) 170 { 171 return_ACPI_STATUS (AE_BAD_PARAMETER); 172 } 173 174 if (((ACPI_SIZE) Resource) & 0x3) 175 { 176 /* Each internal resource struct is expected to be 32-bit aligned */ 177 178 ACPI_WARNING ((AE_INFO, 179 "Misaligned resource pointer (get): %p Type 0x%2.2X Length %u", 180 Resource, Resource->Type, Resource->Length)); 181 } 182 183 /* Extract the resource Length field (does not include header length) */ 184 185 AmlResourceLength = AcpiUtGetResourceLength (Aml); 186 187 /* 188 * First table entry must be ACPI_RSC_INITxxx and must contain the 189 * table length (# of table entries) 190 */ 191 Count = INIT_TABLE_LENGTH (Info); 192 while (Count) 193 { 194 /* 195 * Source is the external AML byte stream buffer, 196 * destination is the internal resource descriptor 197 */ 198 Source = ACPI_ADD_PTR (void, Aml, Info->AmlOffset); 199 Destination = ACPI_ADD_PTR (void, Resource, Info->ResourceOffset); 200 201 switch (Info->Opcode) 202 { 203 case ACPI_RSC_INITGET: 204 /* 205 * Get the resource type and the initial (minimum) length 206 */ 207 ACPI_MEMSET (Resource, 0, INIT_RESOURCE_LENGTH (Info)); 208 Resource->Type = INIT_RESOURCE_TYPE (Info); 209 Resource->Length = INIT_RESOURCE_LENGTH (Info); 210 break; 211 212 case ACPI_RSC_INITSET: 213 break; 214 215 case ACPI_RSC_FLAGINIT: 216 217 FlagsMode = TRUE; 218 break; 219 220 case ACPI_RSC_1BITFLAG: 221 /* 222 * Mask and shift the flag bit 223 */ 224 ACPI_SET8 (Destination, 225 ((ACPI_GET8 (Source) >> Info->Value) & 0x01)); 226 break; 227 228 case ACPI_RSC_2BITFLAG: 229 /* 230 * Mask and shift the flag bits 231 */ 232 ACPI_SET8 (Destination, 233 ((ACPI_GET8 (Source) >> Info->Value) & 0x03)); 234 break; 235 236 case ACPI_RSC_3BITFLAG: 237 /* 238 * Mask and shift the flag bits 239 */ 240 ACPI_SET8 (Destination, 241 ((ACPI_GET8 (Source) >> Info->Value) & 0x07)); 242 break; 243 244 case ACPI_RSC_COUNT: 245 246 ItemCount = ACPI_GET8 (Source); 247 ACPI_SET8 (Destination, ItemCount); 248 249 Resource->Length = Resource->Length + 250 (Info->Value * (ItemCount - 1)); 251 break; 252 253 case ACPI_RSC_COUNT16: 254 255 ItemCount = AmlResourceLength; 256 ACPI_SET16 (Destination, ItemCount); 257 258 Resource->Length = Resource->Length + 259 (Info->Value * (ItemCount - 1)); 260 break; 261 262 case ACPI_RSC_COUNT_GPIO_PIN: 263 264 Target = ACPI_ADD_PTR (void, Aml, Info->Value); 265 ItemCount = ACPI_GET16 (Target) - ACPI_GET16 (Source); 266 267 Resource->Length = Resource->Length + ItemCount; 268 ItemCount = ItemCount / 2; 269 ACPI_SET16 (Destination, ItemCount); 270 break; 271 272 case ACPI_RSC_COUNT_GPIO_VEN: 273 274 ItemCount = ACPI_GET8 (Source); 275 ACPI_SET8 (Destination, ItemCount); 276 277 Resource->Length = Resource->Length + 278 (Info->Value * ItemCount); 279 break; 280 281 case ACPI_RSC_COUNT_GPIO_RES: 282 /* 283 * Vendor data is optional (length/offset may both be zero) 284 * Examine vendor data length field first 285 */ 286 Target = ACPI_ADD_PTR (void, Aml, (Info->Value + 2)); 287 if (ACPI_GET16 (Target)) 288 { 289 /* Use vendor offset to get resource source length */ 290 291 Target = ACPI_ADD_PTR (void, Aml, Info->Value); 292 ItemCount = ACPI_GET16 (Target) - ACPI_GET16 (Source); 293 } 294 else 295 { 296 /* No vendor data to worry about */ 297 298 ItemCount = Aml->LargeHeader.ResourceLength + 299 sizeof (AML_RESOURCE_LARGE_HEADER) - 300 ACPI_GET16 (Source); 301 } 302 303 Resource->Length = Resource->Length + ItemCount; 304 ACPI_SET16 (Destination, ItemCount); 305 break; 306 307 case ACPI_RSC_COUNT_SERIAL_VEN: 308 309 ItemCount = ACPI_GET16 (Source) - Info->Value; 310 311 Resource->Length = Resource->Length + ItemCount; 312 ACPI_SET16 (Destination, ItemCount); 313 break; 314 315 case ACPI_RSC_COUNT_SERIAL_RES: 316 317 ItemCount = (AmlResourceLength + 318 sizeof (AML_RESOURCE_LARGE_HEADER)) - 319 ACPI_GET16 (Source) - Info->Value; 320 321 Resource->Length = Resource->Length + ItemCount; 322 ACPI_SET16 (Destination, ItemCount); 323 break; 324 325 case ACPI_RSC_LENGTH: 326 327 Resource->Length = Resource->Length + Info->Value; 328 break; 329 330 case ACPI_RSC_MOVE8: 331 case ACPI_RSC_MOVE16: 332 case ACPI_RSC_MOVE32: 333 case ACPI_RSC_MOVE64: 334 /* 335 * Raw data move. Use the Info value field unless ItemCount has 336 * been previously initialized via a COUNT opcode 337 */ 338 if (Info->Value) 339 { 340 ItemCount = Info->Value; 341 } 342 AcpiRsMoveData (Destination, Source, ItemCount, Info->Opcode); 343 break; 344 345 case ACPI_RSC_MOVE_GPIO_PIN: 346 347 /* Generate and set the PIN data pointer */ 348 349 Target = (char *) ACPI_ADD_PTR (void, Resource, 350 (Resource->Length - ItemCount * 2)); 351 *(UINT16 **) Destination = ACPI_CAST_PTR (UINT16, Target); 352 353 /* Copy the PIN data */ 354 355 Source = ACPI_ADD_PTR (void, Aml, ACPI_GET16 (Source)); 356 AcpiRsMoveData (Target, Source, ItemCount, Info->Opcode); 357 break; 358 359 case ACPI_RSC_MOVE_GPIO_RES: 360 361 /* Generate and set the ResourceSource string pointer */ 362 363 Target = (char *) ACPI_ADD_PTR (void, Resource, 364 (Resource->Length - ItemCount)); 365 *(UINT8 **) Destination = ACPI_CAST_PTR (UINT8, Target); 366 367 /* Copy the ResourceSource string */ 368 369 Source = ACPI_ADD_PTR (void, Aml, ACPI_GET16 (Source)); 370 AcpiRsMoveData (Target, Source, ItemCount, Info->Opcode); 371 break; 372 373 case ACPI_RSC_MOVE_SERIAL_VEN: 374 375 /* Generate and set the Vendor Data pointer */ 376 377 Target = (char *) ACPI_ADD_PTR (void, Resource, 378 (Resource->Length - ItemCount)); 379 *(UINT8 **) Destination = ACPI_CAST_PTR (UINT8, Target); 380 381 /* Copy the Vendor Data */ 382 383 Source = ACPI_ADD_PTR (void, Aml, Info->Value); 384 AcpiRsMoveData (Target, Source, ItemCount, Info->Opcode); 385 break; 386 387 case ACPI_RSC_MOVE_SERIAL_RES: 388 389 /* Generate and set the ResourceSource string pointer */ 390 391 Target = (char *) ACPI_ADD_PTR (void, Resource, 392 (Resource->Length - ItemCount)); 393 *(UINT8 **) Destination = ACPI_CAST_PTR (UINT8, Target); 394 395 /* Copy the ResourceSource string */ 396 397 Source = ACPI_ADD_PTR (void, Aml, (ACPI_GET16 (Source) + Info->Value)); 398 AcpiRsMoveData (Target, Source, ItemCount, Info->Opcode); 399 break; 400 401 case ACPI_RSC_SET8: 402 403 ACPI_MEMSET (Destination, Info->AmlOffset, Info->Value); 404 break; 405 406 case ACPI_RSC_DATA8: 407 408 Target = ACPI_ADD_PTR (char, Resource, Info->Value); 409 ACPI_MEMCPY (Destination, Source, ACPI_GET16 (Target)); 410 break; 411 412 case ACPI_RSC_ADDRESS: 413 /* 414 * Common handler for address descriptor flags 415 */ 416 if (!AcpiRsGetAddressCommon (Resource, Aml)) 417 { 418 return_ACPI_STATUS (AE_AML_INVALID_RESOURCE_TYPE); 419 } 420 break; 421 422 case ACPI_RSC_SOURCE: 423 /* 424 * Optional ResourceSource (Index and String) 425 */ 426 Resource->Length += 427 AcpiRsGetResourceSource (AmlResourceLength, Info->Value, 428 Destination, Aml, NULL); 429 break; 430 431 case ACPI_RSC_SOURCEX: 432 /* 433 * Optional ResourceSource (Index and String). This is the more 434 * complicated case used by the Interrupt() macro 435 */ 436 Target = ACPI_ADD_PTR (char, Resource, 437 Info->AmlOffset + (ItemCount * 4)); 438 439 Resource->Length += 440 AcpiRsGetResourceSource (AmlResourceLength, (ACPI_RS_LENGTH) 441 (((ItemCount - 1) * sizeof (UINT32)) + Info->Value), 442 Destination, Aml, Target); 443 break; 444 445 case ACPI_RSC_BITMASK: 446 /* 447 * 8-bit encoded bitmask (DMA macro) 448 */ 449 ItemCount = AcpiRsDecodeBitmask (ACPI_GET8 (Source), Destination); 450 if (ItemCount) 451 { 452 Resource->Length += (ItemCount - 1); 453 } 454 455 Target = ACPI_ADD_PTR (char, Resource, Info->Value); 456 ACPI_SET8 (Target, ItemCount); 457 break; 458 459 case ACPI_RSC_BITMASK16: 460 /* 461 * 16-bit encoded bitmask (IRQ macro) 462 */ 463 ACPI_MOVE_16_TO_16 (&Temp16, Source); 464 465 ItemCount = AcpiRsDecodeBitmask (Temp16, Destination); 466 if (ItemCount) 467 { 468 Resource->Length += (ItemCount - 1); 469 } 470 471 Target = ACPI_ADD_PTR (char, Resource, Info->Value); 472 ACPI_SET8 (Target, ItemCount); 473 break; 474 475 case ACPI_RSC_EXIT_NE: 476 /* 477 * Control - Exit conversion if not equal 478 */ 479 switch (Info->ResourceOffset) 480 { 481 case ACPI_RSC_COMPARE_AML_LENGTH: 482 483 if (AmlResourceLength != Info->Value) 484 { 485 goto Exit; 486 } 487 break; 488 489 case ACPI_RSC_COMPARE_VALUE: 490 491 if (ACPI_GET8 (Source) != Info->Value) 492 { 493 goto Exit; 494 } 495 break; 496 497 default: 498 499 ACPI_ERROR ((AE_INFO, "Invalid conversion sub-opcode")); 500 return_ACPI_STATUS (AE_BAD_PARAMETER); 501 } 502 break; 503 504 default: 505 506 ACPI_ERROR ((AE_INFO, "Invalid conversion opcode")); 507 return_ACPI_STATUS (AE_BAD_PARAMETER); 508 } 509 510 Count--; 511 Info++; 512 } 513 514 Exit: 515 if (!FlagsMode) 516 { 517 /* Round the resource struct length up to the next boundary (32 or 64) */ 518 519 Resource->Length = (UINT32) ACPI_ROUND_UP_TO_NATIVE_WORD (Resource->Length); 520 } 521 return_ACPI_STATUS (AE_OK); 522 } 523 524 525 /******************************************************************************* 526 * 527 * FUNCTION: AcpiRsConvertResourceToAml 528 * 529 * PARAMETERS: Resource - Pointer to the resource descriptor 530 * Aml - Where the AML descriptor is returned 531 * Info - Pointer to appropriate conversion table 532 * 533 * RETURN: Status 534 * 535 * DESCRIPTION: Convert an internal resource descriptor to the corresponding 536 * external AML resource descriptor. 537 * 538 ******************************************************************************/ 539 540 ACPI_STATUS 541 AcpiRsConvertResourceToAml ( 542 ACPI_RESOURCE *Resource, 543 AML_RESOURCE *Aml, 544 ACPI_RSCONVERT_INFO *Info) 545 { 546 void *Source = NULL; 547 void *Destination; 548 char *Target; 549 ACPI_RSDESC_SIZE AmlLength = 0; 550 UINT8 Count; 551 UINT16 Temp16 = 0; 552 UINT16 ItemCount = 0; 553 554 555 ACPI_FUNCTION_TRACE (RsConvertResourceToAml); 556 557 558 if (!Info) 559 { 560 return_ACPI_STATUS (AE_BAD_PARAMETER); 561 } 562 563 /* 564 * First table entry must be ACPI_RSC_INITxxx and must contain the 565 * table length (# of table entries) 566 */ 567 Count = INIT_TABLE_LENGTH (Info); 568 569 while (Count) 570 { 571 /* 572 * Source is the internal resource descriptor, 573 * destination is the external AML byte stream buffer 574 */ 575 Source = ACPI_ADD_PTR (void, Resource, Info->ResourceOffset); 576 Destination = ACPI_ADD_PTR (void, Aml, Info->AmlOffset); 577 578 switch (Info->Opcode) 579 { 580 case ACPI_RSC_INITSET: 581 582 ACPI_MEMSET (Aml, 0, INIT_RESOURCE_LENGTH (Info)); 583 AmlLength = INIT_RESOURCE_LENGTH (Info); 584 AcpiRsSetResourceHeader (INIT_RESOURCE_TYPE (Info), AmlLength, Aml); 585 break; 586 587 case ACPI_RSC_INITGET: 588 break; 589 590 case ACPI_RSC_FLAGINIT: 591 /* 592 * Clear the flag byte 593 */ 594 ACPI_SET8 (Destination, 0); 595 break; 596 597 case ACPI_RSC_1BITFLAG: 598 /* 599 * Mask and shift the flag bit 600 */ 601 ACPI_SET_BIT (*ACPI_CAST8 (Destination), (UINT8) 602 ((ACPI_GET8 (Source) & 0x01) << Info->Value)); 603 break; 604 605 case ACPI_RSC_2BITFLAG: 606 /* 607 * Mask and shift the flag bits 608 */ 609 ACPI_SET_BIT (*ACPI_CAST8 (Destination), (UINT8) 610 ((ACPI_GET8 (Source) & 0x03) << Info->Value)); 611 break; 612 613 case ACPI_RSC_3BITFLAG: 614 /* 615 * Mask and shift the flag bits 616 */ 617 ACPI_SET_BIT (*ACPI_CAST8 (Destination), (UINT8) 618 ((ACPI_GET8 (Source) & 0x07) << Info->Value)); 619 break; 620 621 case ACPI_RSC_COUNT: 622 623 ItemCount = ACPI_GET8 (Source); 624 ACPI_SET8 (Destination, ItemCount); 625 626 AmlLength = (UINT16) (AmlLength + (Info->Value * (ItemCount - 1))); 627 break; 628 629 case ACPI_RSC_COUNT16: 630 631 ItemCount = ACPI_GET16 (Source); 632 AmlLength = (UINT16) (AmlLength + ItemCount); 633 AcpiRsSetResourceLength (AmlLength, Aml); 634 break; 635 636 case ACPI_RSC_COUNT_GPIO_PIN: 637 638 ItemCount = ACPI_GET16 (Source); 639 ACPI_SET16 (Destination, AmlLength); 640 641 AmlLength = (UINT16) (AmlLength + ItemCount * 2); 642 Target = ACPI_ADD_PTR (void, Aml, Info->Value); 643 ACPI_SET16 (Target, AmlLength); 644 AcpiRsSetResourceLength (AmlLength, Aml); 645 break; 646 647 case ACPI_RSC_COUNT_GPIO_VEN: 648 649 ItemCount = ACPI_GET16 (Source); 650 ACPI_SET16 (Destination, ItemCount); 651 652 AmlLength = (UINT16) (AmlLength + (Info->Value * ItemCount)); 653 AcpiRsSetResourceLength (AmlLength, Aml); 654 break; 655 656 case ACPI_RSC_COUNT_GPIO_RES: 657 658 /* Set resource source string length */ 659 660 ItemCount = ACPI_GET16 (Source); 661 ACPI_SET16 (Destination, AmlLength); 662 663 /* Compute offset for the Vendor Data */ 664 665 AmlLength = (UINT16) (AmlLength + ItemCount); 666 Target = ACPI_ADD_PTR (void, Aml, Info->Value); 667 668 /* Set vendor offset only if there is vendor data */ 669 670 if (Resource->Data.Gpio.VendorLength) 671 { 672 ACPI_SET16 (Target, AmlLength); 673 } 674 675 AcpiRsSetResourceLength (AmlLength, Aml); 676 break; 677 678 case ACPI_RSC_COUNT_SERIAL_VEN: 679 680 ItemCount = ACPI_GET16 (Source); 681 ACPI_SET16 (Destination, ItemCount + Info->Value); 682 AmlLength = (UINT16) (AmlLength + ItemCount); 683 AcpiRsSetResourceLength (AmlLength, Aml); 684 break; 685 686 case ACPI_RSC_COUNT_SERIAL_RES: 687 688 ItemCount = ACPI_GET16 (Source); 689 AmlLength = (UINT16) (AmlLength + ItemCount); 690 AcpiRsSetResourceLength (AmlLength, Aml); 691 break; 692 693 case ACPI_RSC_LENGTH: 694 695 AcpiRsSetResourceLength (Info->Value, Aml); 696 break; 697 698 case ACPI_RSC_MOVE8: 699 case ACPI_RSC_MOVE16: 700 case ACPI_RSC_MOVE32: 701 case ACPI_RSC_MOVE64: 702 703 if (Info->Value) 704 { 705 ItemCount = Info->Value; 706 } 707 AcpiRsMoveData (Destination, Source, ItemCount, Info->Opcode); 708 break; 709 710 case ACPI_RSC_MOVE_GPIO_PIN: 711 712 Destination = (char *) ACPI_ADD_PTR (void, Aml, 713 ACPI_GET16 (Destination)); 714 Source = * (UINT16 **) Source; 715 AcpiRsMoveData (Destination, Source, ItemCount, Info->Opcode); 716 break; 717 718 case ACPI_RSC_MOVE_GPIO_RES: 719 720 /* Used for both ResourceSource string and VendorData */ 721 722 Destination = (char *) ACPI_ADD_PTR (void, Aml, 723 ACPI_GET16 (Destination)); 724 Source = * (UINT8 **) Source; 725 AcpiRsMoveData (Destination, Source, ItemCount, Info->Opcode); 726 break; 727 728 case ACPI_RSC_MOVE_SERIAL_VEN: 729 730 Destination = (char *) ACPI_ADD_PTR (void, Aml, 731 (AmlLength - ItemCount)); 732 Source = * (UINT8 **) Source; 733 AcpiRsMoveData (Destination, Source, ItemCount, Info->Opcode); 734 break; 735 736 case ACPI_RSC_MOVE_SERIAL_RES: 737 738 Destination = (char *) ACPI_ADD_PTR (void, Aml, 739 (AmlLength - ItemCount)); 740 Source = * (UINT8 **) Source; 741 AcpiRsMoveData (Destination, Source, ItemCount, Info->Opcode); 742 break; 743 744 case ACPI_RSC_ADDRESS: 745 746 /* Set the Resource Type, General Flags, and Type-Specific Flags */ 747 748 AcpiRsSetAddressCommon (Aml, Resource); 749 break; 750 751 case ACPI_RSC_SOURCEX: 752 /* 753 * Optional ResourceSource (Index and String) 754 */ 755 AmlLength = AcpiRsSetResourceSource ( 756 Aml, (ACPI_RS_LENGTH) AmlLength, Source); 757 AcpiRsSetResourceLength (AmlLength, Aml); 758 break; 759 760 case ACPI_RSC_SOURCE: 761 /* 762 * Optional ResourceSource (Index and String). This is the more 763 * complicated case used by the Interrupt() macro 764 */ 765 AmlLength = AcpiRsSetResourceSource (Aml, Info->Value, Source); 766 AcpiRsSetResourceLength (AmlLength, Aml); 767 break; 768 769 case ACPI_RSC_BITMASK: 770 /* 771 * 8-bit encoded bitmask (DMA macro) 772 */ 773 ACPI_SET8 (Destination, 774 AcpiRsEncodeBitmask (Source, 775 *ACPI_ADD_PTR (UINT8, Resource, Info->Value))); 776 break; 777 778 case ACPI_RSC_BITMASK16: 779 /* 780 * 16-bit encoded bitmask (IRQ macro) 781 */ 782 Temp16 = AcpiRsEncodeBitmask (Source, 783 *ACPI_ADD_PTR (UINT8, Resource, Info->Value)); 784 ACPI_MOVE_16_TO_16 (Destination, &Temp16); 785 break; 786 787 case ACPI_RSC_EXIT_LE: 788 /* 789 * Control - Exit conversion if less than or equal 790 */ 791 if (ItemCount <= Info->Value) 792 { 793 goto Exit; 794 } 795 break; 796 797 case ACPI_RSC_EXIT_NE: 798 /* 799 * Control - Exit conversion if not equal 800 */ 801 switch (COMPARE_OPCODE (Info)) 802 { 803 case ACPI_RSC_COMPARE_VALUE: 804 805 if (*ACPI_ADD_PTR (UINT8, Resource, 806 COMPARE_TARGET (Info)) != COMPARE_VALUE (Info)) 807 { 808 goto Exit; 809 } 810 break; 811 812 default: 813 814 ACPI_ERROR ((AE_INFO, "Invalid conversion sub-opcode")); 815 return_ACPI_STATUS (AE_BAD_PARAMETER); 816 } 817 break; 818 819 case ACPI_RSC_EXIT_EQ: 820 /* 821 * Control - Exit conversion if equal 822 */ 823 if (*ACPI_ADD_PTR (UINT8, Resource, 824 COMPARE_TARGET (Info)) == COMPARE_VALUE (Info)) 825 { 826 goto Exit; 827 } 828 break; 829 830 default: 831 832 ACPI_ERROR ((AE_INFO, "Invalid conversion opcode")); 833 return_ACPI_STATUS (AE_BAD_PARAMETER); 834 } 835 836 Count--; 837 Info++; 838 } 839 840 Exit: 841 return_ACPI_STATUS (AE_OK); 842 } 843 844 845 #if 0 846 /* Previous resource validations */ 847 848 if (Aml->ExtAddress64.RevisionID != AML_RESOURCE_EXTENDED_ADDRESS_REVISION) 849 { 850 return_ACPI_STATUS (AE_SUPPORT); 851 } 852 853 if (Resource->Data.StartDpf.PerformanceRobustness >= 3) 854 { 855 return_ACPI_STATUS (AE_AML_BAD_RESOURCE_VALUE); 856 } 857 858 if (((Aml->Irq.Flags & 0x09) == 0x00) || 859 ((Aml->Irq.Flags & 0x09) == 0x09)) 860 { 861 /* 862 * Only [ActiveHigh, EdgeSensitive] or [ActiveLow, LevelSensitive] 863 * polarity/trigger interrupts are allowed (ACPI spec, section 864 * "IRQ Format"), so 0x00 and 0x09 are illegal. 865 */ 866 ACPI_ERROR ((AE_INFO, 867 "Invalid interrupt polarity/trigger in resource list, 0x%X", 868 Aml->Irq.Flags)); 869 return_ACPI_STATUS (AE_BAD_DATA); 870 } 871 872 Resource->Data.ExtendedIrq.InterruptCount = Temp8; 873 if (Temp8 < 1) 874 { 875 /* Must have at least one IRQ */ 876 877 return_ACPI_STATUS (AE_AML_BAD_RESOURCE_LENGTH); 878 } 879 880 if (Resource->Data.Dma.Transfer == 0x03) 881 { 882 ACPI_ERROR ((AE_INFO, 883 "Invalid DMA.Transfer preference (3)")); 884 return_ACPI_STATUS (AE_BAD_DATA); 885 } 886 #endif 887