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 - 2012, 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 213 case ACPI_RSC_INITSET: 214 break; 215 216 217 case ACPI_RSC_FLAGINIT: 218 219 FlagsMode = TRUE; 220 break; 221 222 223 case ACPI_RSC_1BITFLAG: 224 /* 225 * Mask and shift the flag bit 226 */ 227 ACPI_SET8 (Destination) = (UINT8) 228 ((ACPI_GET8 (Source) >> Info->Value) & 0x01); 229 break; 230 231 232 case ACPI_RSC_2BITFLAG: 233 /* 234 * Mask and shift the flag bits 235 */ 236 ACPI_SET8 (Destination) = (UINT8) 237 ((ACPI_GET8 (Source) >> Info->Value) & 0x03); 238 break; 239 240 241 case ACPI_RSC_3BITFLAG: 242 /* 243 * Mask and shift the flag bits 244 */ 245 ACPI_SET8 (Destination) = (UINT8) 246 ((ACPI_GET8 (Source) >> Info->Value) & 0x07); 247 break; 248 249 250 case ACPI_RSC_COUNT: 251 252 ItemCount = ACPI_GET8 (Source); 253 ACPI_SET8 (Destination) = (UINT8) ItemCount; 254 255 Resource->Length = Resource->Length + 256 (Info->Value * (ItemCount - 1)); 257 break; 258 259 260 case ACPI_RSC_COUNT16: 261 262 ItemCount = AmlResourceLength; 263 ACPI_SET16 (Destination) = ItemCount; 264 265 Resource->Length = Resource->Length + 266 (Info->Value * (ItemCount - 1)); 267 break; 268 269 270 case ACPI_RSC_COUNT_GPIO_PIN: 271 272 Target = ACPI_ADD_PTR (void, Aml, Info->Value); 273 ItemCount = ACPI_GET16 (Target) - ACPI_GET16 (Source); 274 275 Resource->Length = Resource->Length + ItemCount; 276 ItemCount = ItemCount / 2; 277 ACPI_SET16 (Destination) = ItemCount; 278 break; 279 280 281 case ACPI_RSC_COUNT_GPIO_VEN: 282 283 ItemCount = ACPI_GET8 (Source); 284 ACPI_SET8 (Destination) = (UINT8) ItemCount; 285 286 Resource->Length = Resource->Length + 287 (Info->Value * ItemCount); 288 break; 289 290 291 case ACPI_RSC_COUNT_GPIO_RES: 292 293 /* 294 * Vendor data is optional (length/offset may both be zero) 295 * Examine vendor data length field first 296 */ 297 Target = ACPI_ADD_PTR (void, Aml, (Info->Value + 2)); 298 if (ACPI_GET16 (Target)) 299 { 300 /* Use vendor offset to get resource source length */ 301 302 Target = ACPI_ADD_PTR (void, Aml, Info->Value); 303 ItemCount = ACPI_GET16 (Target) - ACPI_GET16 (Source); 304 } 305 else 306 { 307 /* No vendor data to worry about */ 308 309 ItemCount = Aml->LargeHeader.ResourceLength + 310 sizeof (AML_RESOURCE_LARGE_HEADER) - 311 ACPI_GET16 (Source); 312 } 313 314 Resource->Length = Resource->Length + ItemCount; 315 ACPI_SET16 (Destination) = ItemCount; 316 break; 317 318 319 case ACPI_RSC_COUNT_SERIAL_VEN: 320 321 ItemCount = ACPI_GET16 (Source) - Info->Value; 322 323 Resource->Length = Resource->Length + ItemCount; 324 ACPI_SET16 (Destination) = ItemCount; 325 break; 326 327 328 case ACPI_RSC_COUNT_SERIAL_RES: 329 330 ItemCount = (AmlResourceLength + 331 sizeof (AML_RESOURCE_LARGE_HEADER)) - 332 ACPI_GET16 (Source) - Info->Value; 333 334 Resource->Length = Resource->Length + ItemCount; 335 ACPI_SET16 (Destination) = ItemCount; 336 break; 337 338 339 case ACPI_RSC_LENGTH: 340 341 Resource->Length = Resource->Length + Info->Value; 342 break; 343 344 345 case ACPI_RSC_MOVE8: 346 case ACPI_RSC_MOVE16: 347 case ACPI_RSC_MOVE32: 348 case ACPI_RSC_MOVE64: 349 /* 350 * Raw data move. Use the Info value field unless ItemCount has 351 * been previously initialized via a COUNT opcode 352 */ 353 if (Info->Value) 354 { 355 ItemCount = Info->Value; 356 } 357 AcpiRsMoveData (Destination, Source, ItemCount, Info->Opcode); 358 break; 359 360 361 case ACPI_RSC_MOVE_GPIO_PIN: 362 363 /* Generate and set the PIN data pointer */ 364 365 Target = (char *) ACPI_ADD_PTR (void, Resource, 366 (Resource->Length - ItemCount * 2)); 367 *(UINT16 **) Destination = ACPI_CAST_PTR (UINT16, Target); 368 369 /* Copy the PIN data */ 370 371 Source = ACPI_ADD_PTR (void, Aml, ACPI_GET16 (Source)); 372 AcpiRsMoveData (Target, Source, ItemCount, Info->Opcode); 373 break; 374 375 376 case ACPI_RSC_MOVE_GPIO_RES: 377 378 /* Generate and set the ResourceSource string pointer */ 379 380 Target = (char *) ACPI_ADD_PTR (void, Resource, 381 (Resource->Length - ItemCount)); 382 *(UINT8 **) Destination = ACPI_CAST_PTR (UINT8, Target); 383 384 /* Copy the ResourceSource string */ 385 386 Source = ACPI_ADD_PTR (void, Aml, ACPI_GET16 (Source)); 387 AcpiRsMoveData (Target, Source, ItemCount, Info->Opcode); 388 break; 389 390 391 case ACPI_RSC_MOVE_SERIAL_VEN: 392 393 /* Generate and set the Vendor Data pointer */ 394 395 Target = (char *) ACPI_ADD_PTR (void, Resource, 396 (Resource->Length - ItemCount)); 397 *(UINT8 **) Destination = ACPI_CAST_PTR (UINT8, Target); 398 399 /* Copy the Vendor Data */ 400 401 Source = ACPI_ADD_PTR (void, Aml, Info->Value); 402 AcpiRsMoveData (Target, Source, ItemCount, Info->Opcode); 403 break; 404 405 406 case ACPI_RSC_MOVE_SERIAL_RES: 407 408 /* Generate and set the ResourceSource string pointer */ 409 410 Target = (char *) ACPI_ADD_PTR (void, Resource, 411 (Resource->Length - ItemCount)); 412 *(UINT8 **) Destination = ACPI_CAST_PTR (UINT8, Target); 413 414 /* Copy the ResourceSource string */ 415 416 Source = ACPI_ADD_PTR (void, Aml, (ACPI_GET16 (Source) + Info->Value)); 417 AcpiRsMoveData (Target, Source, ItemCount, Info->Opcode); 418 break; 419 420 421 case ACPI_RSC_SET8: 422 423 ACPI_MEMSET (Destination, Info->AmlOffset, Info->Value); 424 break; 425 426 427 case ACPI_RSC_DATA8: 428 429 Target = ACPI_ADD_PTR (char, Resource, Info->Value); 430 ACPI_MEMCPY (Destination, Source, ACPI_GET16 (Target)); 431 break; 432 433 434 case ACPI_RSC_ADDRESS: 435 /* 436 * Common handler for address descriptor flags 437 */ 438 if (!AcpiRsGetAddressCommon (Resource, Aml)) 439 { 440 return_ACPI_STATUS (AE_AML_INVALID_RESOURCE_TYPE); 441 } 442 break; 443 444 445 case ACPI_RSC_SOURCE: 446 /* 447 * Optional ResourceSource (Index and String) 448 */ 449 Resource->Length += 450 AcpiRsGetResourceSource (AmlResourceLength, Info->Value, 451 Destination, Aml, NULL); 452 break; 453 454 455 case ACPI_RSC_SOURCEX: 456 /* 457 * Optional ResourceSource (Index and String). This is the more 458 * complicated case used by the Interrupt() macro 459 */ 460 Target = ACPI_ADD_PTR (char, Resource, 461 Info->AmlOffset + (ItemCount * 4)); 462 463 Resource->Length += 464 AcpiRsGetResourceSource (AmlResourceLength, (ACPI_RS_LENGTH) 465 (((ItemCount - 1) * sizeof (UINT32)) + Info->Value), 466 Destination, Aml, Target); 467 break; 468 469 470 case ACPI_RSC_BITMASK: 471 /* 472 * 8-bit encoded bitmask (DMA macro) 473 */ 474 ItemCount = AcpiRsDecodeBitmask (ACPI_GET8 (Source), Destination); 475 if (ItemCount) 476 { 477 Resource->Length += (ItemCount - 1); 478 } 479 480 Target = ACPI_ADD_PTR (char, Resource, Info->Value); 481 ACPI_SET8 (Target) = (UINT8) ItemCount; 482 break; 483 484 485 case ACPI_RSC_BITMASK16: 486 /* 487 * 16-bit encoded bitmask (IRQ macro) 488 */ 489 ACPI_MOVE_16_TO_16 (&Temp16, Source); 490 491 ItemCount = AcpiRsDecodeBitmask (Temp16, Destination); 492 if (ItemCount) 493 { 494 Resource->Length += (ItemCount - 1); 495 } 496 497 Target = ACPI_ADD_PTR (char, Resource, Info->Value); 498 ACPI_SET8 (Target) = (UINT8) ItemCount; 499 break; 500 501 502 case ACPI_RSC_EXIT_NE: 503 /* 504 * Control - Exit conversion if not equal 505 */ 506 switch (Info->ResourceOffset) 507 { 508 case ACPI_RSC_COMPARE_AML_LENGTH: 509 if (AmlResourceLength != Info->Value) 510 { 511 goto Exit; 512 } 513 break; 514 515 case ACPI_RSC_COMPARE_VALUE: 516 if (ACPI_GET8 (Source) != Info->Value) 517 { 518 goto Exit; 519 } 520 break; 521 522 default: 523 524 ACPI_ERROR ((AE_INFO, "Invalid conversion sub-opcode")); 525 return_ACPI_STATUS (AE_BAD_PARAMETER); 526 } 527 break; 528 529 530 default: 531 532 ACPI_ERROR ((AE_INFO, "Invalid conversion opcode")); 533 return_ACPI_STATUS (AE_BAD_PARAMETER); 534 } 535 536 Count--; 537 Info++; 538 } 539 540 Exit: 541 if (!FlagsMode) 542 { 543 /* Round the resource struct length up to the next boundary (32 or 64) */ 544 545 Resource->Length = (UINT32) ACPI_ROUND_UP_TO_NATIVE_WORD (Resource->Length); 546 } 547 return_ACPI_STATUS (AE_OK); 548 } 549 550 551 /******************************************************************************* 552 * 553 * FUNCTION: AcpiRsConvertResourceToAml 554 * 555 * PARAMETERS: Resource - Pointer to the resource descriptor 556 * Aml - Where the AML descriptor is returned 557 * Info - Pointer to appropriate conversion table 558 * 559 * RETURN: Status 560 * 561 * DESCRIPTION: Convert an internal resource descriptor to the corresponding 562 * external AML resource descriptor. 563 * 564 ******************************************************************************/ 565 566 ACPI_STATUS 567 AcpiRsConvertResourceToAml ( 568 ACPI_RESOURCE *Resource, 569 AML_RESOURCE *Aml, 570 ACPI_RSCONVERT_INFO *Info) 571 { 572 void *Source = NULL; 573 void *Destination; 574 char *Target; 575 ACPI_RSDESC_SIZE AmlLength = 0; 576 UINT8 Count; 577 UINT16 Temp16 = 0; 578 UINT16 ItemCount = 0; 579 580 581 ACPI_FUNCTION_TRACE (RsConvertResourceToAml); 582 583 584 if (!Info) 585 { 586 return_ACPI_STATUS (AE_BAD_PARAMETER); 587 } 588 589 /* 590 * First table entry must be ACPI_RSC_INITxxx and must contain the 591 * table length (# of table entries) 592 */ 593 Count = INIT_TABLE_LENGTH (Info); 594 595 while (Count) 596 { 597 /* 598 * Source is the internal resource descriptor, 599 * destination is the external AML byte stream buffer 600 */ 601 Source = ACPI_ADD_PTR (void, Resource, Info->ResourceOffset); 602 Destination = ACPI_ADD_PTR (void, Aml, Info->AmlOffset); 603 604 switch (Info->Opcode) 605 { 606 case ACPI_RSC_INITSET: 607 608 ACPI_MEMSET (Aml, 0, INIT_RESOURCE_LENGTH (Info)); 609 AmlLength = INIT_RESOURCE_LENGTH (Info); 610 AcpiRsSetResourceHeader (INIT_RESOURCE_TYPE (Info), AmlLength, Aml); 611 break; 612 613 614 case ACPI_RSC_INITGET: 615 break; 616 617 618 case ACPI_RSC_FLAGINIT: 619 /* 620 * Clear the flag byte 621 */ 622 ACPI_SET8 (Destination) = 0; 623 break; 624 625 626 case ACPI_RSC_1BITFLAG: 627 /* 628 * Mask and shift the flag bit 629 */ 630 ACPI_SET8 (Destination) |= (UINT8) 631 ((ACPI_GET8 (Source) & 0x01) << Info->Value); 632 break; 633 634 635 case ACPI_RSC_2BITFLAG: 636 /* 637 * Mask and shift the flag bits 638 */ 639 ACPI_SET8 (Destination) |= (UINT8) 640 ((ACPI_GET8 (Source) & 0x03) << Info->Value); 641 break; 642 643 644 case ACPI_RSC_3BITFLAG: 645 /* 646 * Mask and shift the flag bits 647 */ 648 ACPI_SET8 (Destination) |= (UINT8) 649 ((ACPI_GET8 (Source) & 0x07) << Info->Value); 650 break; 651 652 653 case ACPI_RSC_COUNT: 654 655 ItemCount = ACPI_GET8 (Source); 656 ACPI_SET8 (Destination) = (UINT8) ItemCount; 657 658 AmlLength = (UINT16) (AmlLength + (Info->Value * (ItemCount - 1))); 659 break; 660 661 662 case ACPI_RSC_COUNT16: 663 664 ItemCount = ACPI_GET16 (Source); 665 AmlLength = (UINT16) (AmlLength + ItemCount); 666 AcpiRsSetResourceLength (AmlLength, Aml); 667 break; 668 669 670 case ACPI_RSC_COUNT_GPIO_PIN: 671 672 ItemCount = ACPI_GET16 (Source); 673 ACPI_SET16 (Destination) = (UINT16) AmlLength; 674 675 AmlLength = (UINT16) (AmlLength + ItemCount * 2); 676 Target = ACPI_ADD_PTR (void, Aml, Info->Value); 677 ACPI_SET16 (Target) = (UINT16) AmlLength; 678 AcpiRsSetResourceLength (AmlLength, Aml); 679 break; 680 681 682 case ACPI_RSC_COUNT_GPIO_VEN: 683 684 ItemCount = ACPI_GET16 (Source); 685 ACPI_SET16 (Destination) = (UINT16) ItemCount; 686 687 AmlLength = (UINT16) (AmlLength + (Info->Value * ItemCount)); 688 AcpiRsSetResourceLength (AmlLength, Aml); 689 break; 690 691 692 case ACPI_RSC_COUNT_GPIO_RES: 693 694 /* Set resource source string length */ 695 696 ItemCount = ACPI_GET16 (Source); 697 ACPI_SET16 (Destination) = (UINT16) AmlLength; 698 699 /* Compute offset for the Vendor Data */ 700 701 AmlLength = (UINT16) (AmlLength + ItemCount); 702 Target = ACPI_ADD_PTR (void, Aml, Info->Value); 703 704 /* Set vendor offset only if there is vendor data */ 705 706 if (Resource->Data.Gpio.VendorLength) 707 { 708 ACPI_SET16 (Target) = (UINT16) AmlLength; 709 } 710 711 AcpiRsSetResourceLength (AmlLength, Aml); 712 break; 713 714 715 case ACPI_RSC_COUNT_SERIAL_VEN: 716 717 ItemCount = ACPI_GET16 (Source); 718 ACPI_SET16 (Destination) = ItemCount + Info->Value; 719 AmlLength = (UINT16) (AmlLength + ItemCount); 720 AcpiRsSetResourceLength (AmlLength, Aml); 721 break; 722 723 724 case ACPI_RSC_COUNT_SERIAL_RES: 725 726 ItemCount = ACPI_GET16 (Source); 727 AmlLength = (UINT16) (AmlLength + ItemCount); 728 AcpiRsSetResourceLength (AmlLength, Aml); 729 break; 730 731 732 case ACPI_RSC_LENGTH: 733 734 AcpiRsSetResourceLength (Info->Value, Aml); 735 break; 736 737 738 case ACPI_RSC_MOVE8: 739 case ACPI_RSC_MOVE16: 740 case ACPI_RSC_MOVE32: 741 case ACPI_RSC_MOVE64: 742 743 if (Info->Value) 744 { 745 ItemCount = Info->Value; 746 } 747 AcpiRsMoveData (Destination, Source, ItemCount, Info->Opcode); 748 break; 749 750 751 case ACPI_RSC_MOVE_GPIO_PIN: 752 753 Destination = (char *) ACPI_ADD_PTR (void, Aml, 754 ACPI_GET16 (Destination)); 755 Source = * (UINT16 **) Source; 756 AcpiRsMoveData (Destination, Source, ItemCount, Info->Opcode); 757 break; 758 759 760 case ACPI_RSC_MOVE_GPIO_RES: 761 762 /* Used for both ResourceSource string and VendorData */ 763 764 Destination = (char *) ACPI_ADD_PTR (void, Aml, 765 ACPI_GET16 (Destination)); 766 Source = * (UINT8 **) Source; 767 AcpiRsMoveData (Destination, Source, ItemCount, Info->Opcode); 768 break; 769 770 771 case ACPI_RSC_MOVE_SERIAL_VEN: 772 773 Destination = (char *) ACPI_ADD_PTR (void, Aml, 774 (AmlLength - ItemCount)); 775 Source = * (UINT8 **) Source; 776 AcpiRsMoveData (Destination, Source, ItemCount, Info->Opcode); 777 break; 778 779 780 case ACPI_RSC_MOVE_SERIAL_RES: 781 782 Destination = (char *) ACPI_ADD_PTR (void, Aml, 783 (AmlLength - ItemCount)); 784 Source = * (UINT8 **) Source; 785 AcpiRsMoveData (Destination, Source, ItemCount, Info->Opcode); 786 break; 787 788 789 case ACPI_RSC_ADDRESS: 790 791 /* Set the Resource Type, General Flags, and Type-Specific Flags */ 792 793 AcpiRsSetAddressCommon (Aml, Resource); 794 break; 795 796 797 case ACPI_RSC_SOURCEX: 798 /* 799 * Optional ResourceSource (Index and String) 800 */ 801 AmlLength = AcpiRsSetResourceSource ( 802 Aml, (ACPI_RS_LENGTH) AmlLength, Source); 803 AcpiRsSetResourceLength (AmlLength, Aml); 804 break; 805 806 807 case ACPI_RSC_SOURCE: 808 /* 809 * Optional ResourceSource (Index and String). This is the more 810 * complicated case used by the Interrupt() macro 811 */ 812 AmlLength = AcpiRsSetResourceSource (Aml, Info->Value, Source); 813 AcpiRsSetResourceLength (AmlLength, Aml); 814 break; 815 816 817 case ACPI_RSC_BITMASK: 818 /* 819 * 8-bit encoded bitmask (DMA macro) 820 */ 821 ACPI_SET8 (Destination) = (UINT8) 822 AcpiRsEncodeBitmask (Source, 823 *ACPI_ADD_PTR (UINT8, Resource, Info->Value)); 824 break; 825 826 827 case ACPI_RSC_BITMASK16: 828 /* 829 * 16-bit encoded bitmask (IRQ macro) 830 */ 831 Temp16 = AcpiRsEncodeBitmask (Source, 832 *ACPI_ADD_PTR (UINT8, Resource, Info->Value)); 833 ACPI_MOVE_16_TO_16 (Destination, &Temp16); 834 break; 835 836 837 case ACPI_RSC_EXIT_LE: 838 /* 839 * Control - Exit conversion if less than or equal 840 */ 841 if (ItemCount <= Info->Value) 842 { 843 goto Exit; 844 } 845 break; 846 847 848 case ACPI_RSC_EXIT_NE: 849 /* 850 * Control - Exit conversion if not equal 851 */ 852 switch (COMPARE_OPCODE (Info)) 853 { 854 case ACPI_RSC_COMPARE_VALUE: 855 856 if (*ACPI_ADD_PTR (UINT8, Resource, 857 COMPARE_TARGET (Info)) != COMPARE_VALUE (Info)) 858 { 859 goto Exit; 860 } 861 break; 862 863 default: 864 865 ACPI_ERROR ((AE_INFO, "Invalid conversion sub-opcode")); 866 return_ACPI_STATUS (AE_BAD_PARAMETER); 867 } 868 break; 869 870 871 case ACPI_RSC_EXIT_EQ: 872 /* 873 * Control - Exit conversion if equal 874 */ 875 if (*ACPI_ADD_PTR (UINT8, Resource, 876 COMPARE_TARGET (Info)) == COMPARE_VALUE (Info)) 877 { 878 goto Exit; 879 } 880 break; 881 882 883 default: 884 885 ACPI_ERROR ((AE_INFO, "Invalid conversion opcode")); 886 return_ACPI_STATUS (AE_BAD_PARAMETER); 887 } 888 889 Count--; 890 Info++; 891 } 892 893 Exit: 894 return_ACPI_STATUS (AE_OK); 895 } 896 897 898 #if 0 899 /* Previous resource validations */ 900 901 if (Aml->ExtAddress64.RevisionID != AML_RESOURCE_EXTENDED_ADDRESS_REVISION) 902 { 903 return_ACPI_STATUS (AE_SUPPORT); 904 } 905 906 if (Resource->Data.StartDpf.PerformanceRobustness >= 3) 907 { 908 return_ACPI_STATUS (AE_AML_BAD_RESOURCE_VALUE); 909 } 910 911 if (((Aml->Irq.Flags & 0x09) == 0x00) || 912 ((Aml->Irq.Flags & 0x09) == 0x09)) 913 { 914 /* 915 * Only [ActiveHigh, EdgeSensitive] or [ActiveLow, LevelSensitive] 916 * polarity/trigger interrupts are allowed (ACPI spec, section 917 * "IRQ Format"), so 0x00 and 0x09 are illegal. 918 */ 919 ACPI_ERROR ((AE_INFO, 920 "Invalid interrupt polarity/trigger in resource list, 0x%X", 921 Aml->Irq.Flags)); 922 return_ACPI_STATUS (AE_BAD_DATA); 923 } 924 925 Resource->Data.ExtendedIrq.InterruptCount = Temp8; 926 if (Temp8 < 1) 927 { 928 /* Must have at least one IRQ */ 929 930 return_ACPI_STATUS (AE_AML_BAD_RESOURCE_LENGTH); 931 } 932 933 if (Resource->Data.Dma.Transfer == 0x03) 934 { 935 ACPI_ERROR ((AE_INFO, 936 "Invalid DMA.Transfer preference (3)")); 937 return_ACPI_STATUS (AE_BAD_DATA); 938 } 939 #endif 940