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