1 /******************************************************************************* 2 * 3 * Module Name: rsmisc - Miscellaneous resource descriptors 4 * 5 ******************************************************************************/ 6 7 /* 8 * Copyright (C) 2000 - 2022, Intel Corp. 9 * All rights reserved. 10 * 11 * Redistribution and use in source and binary forms, with or without 12 * modification, are permitted provided that the following conditions 13 * are met: 14 * 1. Redistributions of source code must retain the above copyright 15 * notice, this list of conditions, and the following disclaimer, 16 * without modification. 17 * 2. Redistributions in binary form must reproduce at minimum a disclaimer 18 * substantially similar to the "NO WARRANTY" disclaimer below 19 * ("Disclaimer") and any redistribution must be conditioned upon 20 * including a substantially similar Disclaimer requirement for further 21 * binary redistribution. 22 * 3. Neither the names of the above-listed copyright holders nor the names 23 * of any contributors may be used to endorse or promote products derived 24 * from this software without specific prior written permission. 25 * 26 * Alternatively, this software may be distributed under the terms of the 27 * GNU General Public License ("GPL") version 2 as published by the Free 28 * Software Foundation. 29 * 30 * NO WARRANTY 31 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 32 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 33 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 34 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 35 * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 36 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 37 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 38 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 39 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 40 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 41 * POSSIBILITY OF SUCH DAMAGES. 42 */ 43 44 #include "acpi.h" 45 #include "accommon.h" 46 #include "acresrc.h" 47 48 #define _COMPONENT ACPI_RESOURCES 49 ACPI_MODULE_NAME ("rsmisc") 50 51 52 #define INIT_RESOURCE_TYPE(i) i->ResourceOffset 53 #define INIT_RESOURCE_LENGTH(i) i->AmlOffset 54 #define INIT_TABLE_LENGTH(i) i->Value 55 56 #define COMPARE_OPCODE(i) i->ResourceOffset 57 #define COMPARE_TARGET(i) i->AmlOffset 58 #define COMPARE_VALUE(i) i->Value 59 60 61 /******************************************************************************* 62 * 63 * FUNCTION: AcpiRsConvertAmlToResource 64 * 65 * PARAMETERS: Resource - Pointer to the resource descriptor 66 * Aml - Where the AML descriptor is returned 67 * Info - Pointer to appropriate conversion table 68 * 69 * RETURN: Status 70 * 71 * DESCRIPTION: Convert an external AML resource descriptor to the corresponding 72 * internal resource descriptor 73 * 74 ******************************************************************************/ 75 76 ACPI_STATUS 77 AcpiRsConvertAmlToResource ( 78 ACPI_RESOURCE *Resource, 79 AML_RESOURCE *Aml, 80 ACPI_RSCONVERT_INFO *Info) 81 { 82 ACPI_RS_LENGTH AmlResourceLength; 83 void *Source; 84 void *Destination; 85 char *Target; 86 UINT8 Count; 87 UINT8 FlagsMode = FALSE; 88 UINT16 ItemCount = 0; 89 UINT16 Temp16 = 0; 90 91 92 ACPI_FUNCTION_TRACE (RsConvertAmlToResource); 93 94 95 if (!Info) 96 { 97 return_ACPI_STATUS (AE_BAD_PARAMETER); 98 } 99 100 if (((ACPI_SIZE) Resource) & 0x3) 101 { 102 /* Each internal resource struct is expected to be 32-bit aligned */ 103 104 ACPI_WARNING ((AE_INFO, 105 "Misaligned resource pointer (get): %p Type 0x%2.2X Length %u", 106 Resource, Resource->Type, Resource->Length)); 107 } 108 109 /* Extract the resource Length field (does not include header length) */ 110 111 AmlResourceLength = AcpiUtGetResourceLength (Aml); 112 113 /* 114 * First table entry must be ACPI_RSC_INITxxx and must contain the 115 * table length (# of table entries) 116 */ 117 Count = INIT_TABLE_LENGTH (Info); 118 while (Count) 119 { 120 Target = NULL; 121 122 /* 123 * Source is the external AML byte stream buffer, 124 * destination is the internal resource descriptor 125 */ 126 Source = ACPI_ADD_PTR (void, Aml, Info->AmlOffset); 127 Destination = ACPI_ADD_PTR (void, Resource, Info->ResourceOffset); 128 129 switch (Info->Opcode) 130 { 131 case ACPI_RSC_INITGET: 132 /* 133 * Get the resource type and the initial (minimum) length 134 */ 135 memset (Resource, 0, INIT_RESOURCE_LENGTH (Info)); 136 Resource->Type = INIT_RESOURCE_TYPE (Info); 137 Resource->Length = INIT_RESOURCE_LENGTH (Info); 138 break; 139 140 case ACPI_RSC_INITSET: 141 break; 142 143 case ACPI_RSC_FLAGINIT: 144 145 FlagsMode = TRUE; 146 break; 147 148 case ACPI_RSC_1BITFLAG: 149 /* 150 * Mask and shift the flag bit 151 */ 152 ACPI_SET8 (Destination, 153 ((ACPI_GET8 (Source) >> Info->Value) & 0x01)); 154 break; 155 156 case ACPI_RSC_2BITFLAG: 157 /* 158 * Mask and shift the flag bits 159 */ 160 ACPI_SET8 (Destination, 161 ((ACPI_GET8 (Source) >> Info->Value) & 0x03)); 162 break; 163 164 case ACPI_RSC_3BITFLAG: 165 /* 166 * Mask and shift the flag bits 167 */ 168 ACPI_SET8 (Destination, 169 ((ACPI_GET8 (Source) >> Info->Value) & 0x07)); 170 break; 171 172 case ACPI_RSC_6BITFLAG: 173 /* 174 * Mask and shift the flag bits 175 */ 176 ACPI_SET8 (Destination, 177 ((ACPI_GET8 (Source) >> Info->Value) & 0x3F)); 178 break; 179 180 case ACPI_RSC_COUNT: 181 182 ItemCount = ACPI_GET8 (Source); 183 ACPI_SET8 (Destination, ItemCount); 184 185 Resource->Length = Resource->Length + 186 (Info->Value * (ItemCount - 1)); 187 break; 188 189 case ACPI_RSC_COUNT16: 190 191 ItemCount = AmlResourceLength; 192 ACPI_SET16 (Destination, ItemCount); 193 194 Resource->Length = Resource->Length + 195 (Info->Value * (ItemCount - 1)); 196 break; 197 198 case ACPI_RSC_COUNT_GPIO_PIN: 199 200 Target = ACPI_ADD_PTR (void, Aml, Info->Value); 201 ItemCount = ACPI_GET16 (Target) - ACPI_GET16 (Source); 202 203 Resource->Length = Resource->Length + ItemCount; 204 ItemCount = ItemCount / 2; 205 ACPI_SET16 (Destination, ItemCount); 206 break; 207 208 case ACPI_RSC_COUNT_GPIO_VEN: 209 210 ItemCount = ACPI_GET8 (Source); 211 ACPI_SET8 (Destination, ItemCount); 212 213 Resource->Length = Resource->Length + (Info->Value * ItemCount); 214 break; 215 216 case ACPI_RSC_COUNT_GPIO_RES: 217 /* 218 * Vendor data is optional (length/offset may both be zero) 219 * Examine vendor data length field first 220 */ 221 Target = ACPI_ADD_PTR (void, Aml, (Info->Value + 2)); 222 if (ACPI_GET16 (Target)) 223 { 224 /* Use vendor offset to get resource source length */ 225 226 Target = ACPI_ADD_PTR (void, Aml, Info->Value); 227 ItemCount = ACPI_GET16 (Target) - ACPI_GET16 (Source); 228 } 229 else 230 { 231 /* No vendor data to worry about */ 232 233 ItemCount = Aml->LargeHeader.ResourceLength + 234 sizeof (AML_RESOURCE_LARGE_HEADER) - 235 ACPI_GET16 (Source); 236 } 237 238 Resource->Length = Resource->Length + ItemCount; 239 ACPI_SET16 (Destination, ItemCount); 240 break; 241 242 case ACPI_RSC_COUNT_SERIAL_VEN: 243 244 ItemCount = ACPI_GET16 (Source) - Info->Value; 245 246 Resource->Length = Resource->Length + ItemCount; 247 ACPI_SET16 (Destination, ItemCount); 248 break; 249 250 case ACPI_RSC_COUNT_SERIAL_RES: 251 252 ItemCount = (AmlResourceLength + 253 sizeof (AML_RESOURCE_LARGE_HEADER)) - 254 ACPI_GET16 (Source) - Info->Value; 255 256 Resource->Length = Resource->Length + ItemCount; 257 ACPI_SET16 (Destination, ItemCount); 258 break; 259 260 case ACPI_RSC_LENGTH: 261 262 Resource->Length = Resource->Length + Info->Value; 263 break; 264 265 case ACPI_RSC_MOVE8: 266 case ACPI_RSC_MOVE16: 267 case ACPI_RSC_MOVE32: 268 case ACPI_RSC_MOVE64: 269 /* 270 * Raw data move. Use the Info value field unless ItemCount has 271 * been previously initialized via a COUNT opcode 272 */ 273 if (Info->Value) 274 { 275 ItemCount = Info->Value; 276 } 277 AcpiRsMoveData (Destination, Source, ItemCount, Info->Opcode); 278 break; 279 280 case ACPI_RSC_MOVE_GPIO_PIN: 281 282 /* Generate and set the PIN data pointer */ 283 284 Target = (char *) ACPI_ADD_PTR (void, Resource, 285 (Resource->Length - ItemCount * 2)); 286 *(UINT16 **) Destination = ACPI_CAST_PTR (UINT16, Target); 287 288 /* Copy the PIN data */ 289 290 Source = ACPI_ADD_PTR (void, Aml, ACPI_GET16 (Source)); 291 AcpiRsMoveData (Target, Source, ItemCount, Info->Opcode); 292 break; 293 294 case ACPI_RSC_MOVE_GPIO_RES: 295 296 /* Generate and set the ResourceSource string pointer */ 297 298 Target = (char *) ACPI_ADD_PTR (void, Resource, 299 (Resource->Length - ItemCount)); 300 *(UINT8 **) Destination = ACPI_CAST_PTR (UINT8, Target); 301 302 /* Copy the ResourceSource string */ 303 304 Source = ACPI_ADD_PTR (void, Aml, ACPI_GET16 (Source)); 305 AcpiRsMoveData (Target, Source, ItemCount, Info->Opcode); 306 break; 307 308 case ACPI_RSC_MOVE_SERIAL_VEN: 309 310 /* Generate and set the Vendor Data pointer */ 311 312 Target = (char *) ACPI_ADD_PTR (void, Resource, 313 (Resource->Length - ItemCount)); 314 *(UINT8 **) Destination = ACPI_CAST_PTR (UINT8, Target); 315 316 /* Copy the Vendor Data */ 317 318 Source = ACPI_ADD_PTR (void, Aml, Info->Value); 319 AcpiRsMoveData (Target, Source, ItemCount, Info->Opcode); 320 break; 321 322 case ACPI_RSC_MOVE_SERIAL_RES: 323 324 /* Generate and set the ResourceSource string pointer */ 325 326 Target = (char *) ACPI_ADD_PTR (void, Resource, 327 (Resource->Length - ItemCount)); 328 *(UINT8 **) Destination = ACPI_CAST_PTR (UINT8, Target); 329 330 /* Copy the ResourceSource string */ 331 332 Source = ACPI_ADD_PTR ( 333 void, Aml, (ACPI_GET16 (Source) + Info->Value)); 334 AcpiRsMoveData (Target, Source, ItemCount, Info->Opcode); 335 break; 336 337 case ACPI_RSC_SET8: 338 339 memset (Destination, Info->AmlOffset, Info->Value); 340 break; 341 342 case ACPI_RSC_DATA8: 343 344 Target = ACPI_ADD_PTR (char, Resource, Info->Value); 345 memcpy (Destination, Source, ACPI_GET16 (Target)); 346 break; 347 348 case ACPI_RSC_ADDRESS: 349 /* 350 * Common handler for address descriptor flags 351 */ 352 if (!AcpiRsGetAddressCommon (Resource, Aml)) 353 { 354 return_ACPI_STATUS (AE_AML_INVALID_RESOURCE_TYPE); 355 } 356 break; 357 358 case ACPI_RSC_SOURCE: 359 /* 360 * Optional ResourceSource (Index and String) 361 */ 362 Resource->Length += 363 AcpiRsGetResourceSource (AmlResourceLength, Info->Value, 364 Destination, Aml, NULL); 365 break; 366 367 case ACPI_RSC_SOURCEX: 368 /* 369 * Optional ResourceSource (Index and String). This is the more 370 * complicated case used by the Interrupt() macro 371 */ 372 Target = ACPI_ADD_PTR (char, Resource, 373 Info->AmlOffset + (ItemCount * 4)); 374 375 Resource->Length += 376 AcpiRsGetResourceSource (AmlResourceLength, (ACPI_RS_LENGTH) 377 (((ItemCount - 1) * sizeof (UINT32)) + Info->Value), 378 Destination, Aml, Target); 379 break; 380 381 case ACPI_RSC_BITMASK: 382 /* 383 * 8-bit encoded bitmask (DMA macro) 384 */ 385 ItemCount = AcpiRsDecodeBitmask (ACPI_GET8 (Source), Destination); 386 if (ItemCount) 387 { 388 Resource->Length += (ItemCount - 1); 389 } 390 391 Target = ACPI_ADD_PTR (char, Resource, Info->Value); 392 ACPI_SET8 (Target, ItemCount); 393 break; 394 395 case ACPI_RSC_BITMASK16: 396 /* 397 * 16-bit encoded bitmask (IRQ macro) 398 */ 399 ACPI_MOVE_16_TO_16 (&Temp16, Source); 400 401 ItemCount = AcpiRsDecodeBitmask (Temp16, Destination); 402 if (ItemCount) 403 { 404 Resource->Length += (ItemCount - 1); 405 } 406 407 Target = ACPI_ADD_PTR (char, Resource, Info->Value); 408 ACPI_SET8 (Target, ItemCount); 409 break; 410 411 case ACPI_RSC_EXIT_NE: 412 /* 413 * Control - Exit conversion if not equal 414 */ 415 switch (Info->ResourceOffset) 416 { 417 case ACPI_RSC_COMPARE_AML_LENGTH: 418 419 if (AmlResourceLength != Info->Value) 420 { 421 goto Exit; 422 } 423 break; 424 425 case ACPI_RSC_COMPARE_VALUE: 426 427 if (ACPI_GET8 (Source) != Info->Value) 428 { 429 goto Exit; 430 } 431 break; 432 433 default: 434 435 ACPI_ERROR ((AE_INFO, "Invalid conversion sub-opcode")); 436 return_ACPI_STATUS (AE_BAD_PARAMETER); 437 } 438 break; 439 440 default: 441 442 ACPI_ERROR ((AE_INFO, "Invalid conversion opcode")); 443 return_ACPI_STATUS (AE_BAD_PARAMETER); 444 } 445 446 Count--; 447 Info++; 448 } 449 450 Exit: 451 if (!FlagsMode) 452 { 453 /* Round the resource struct length up to the next boundary (32 or 64) */ 454 455 Resource->Length = (UINT32) 456 ACPI_ROUND_UP_TO_NATIVE_WORD (Resource->Length); 457 } 458 return_ACPI_STATUS (AE_OK); 459 } 460 461 462 /******************************************************************************* 463 * 464 * FUNCTION: AcpiRsConvertResourceToAml 465 * 466 * PARAMETERS: Resource - Pointer to the resource descriptor 467 * Aml - Where the AML descriptor is returned 468 * Info - Pointer to appropriate conversion table 469 * 470 * RETURN: Status 471 * 472 * DESCRIPTION: Convert an internal resource descriptor to the corresponding 473 * external AML resource descriptor. 474 * 475 ******************************************************************************/ 476 477 ACPI_STATUS 478 AcpiRsConvertResourceToAml ( 479 ACPI_RESOURCE *Resource, 480 AML_RESOURCE *Aml, 481 ACPI_RSCONVERT_INFO *Info) 482 { 483 void *Source = NULL; 484 void *Destination; 485 char *Target; 486 ACPI_RSDESC_SIZE AmlLength = 0; 487 UINT8 Count; 488 UINT16 Temp16 = 0; 489 UINT16 ItemCount = 0; 490 491 492 ACPI_FUNCTION_TRACE (RsConvertResourceToAml); 493 494 495 if (!Info) 496 { 497 return_ACPI_STATUS (AE_BAD_PARAMETER); 498 } 499 500 /* 501 * First table entry must be ACPI_RSC_INITxxx and must contain the 502 * table length (# of table entries) 503 */ 504 Count = INIT_TABLE_LENGTH (Info); 505 506 while (Count) 507 { 508 /* 509 * Source is the internal resource descriptor, 510 * destination is the external AML byte stream buffer 511 */ 512 Source = ACPI_ADD_PTR (void, Resource, Info->ResourceOffset); 513 Destination = ACPI_ADD_PTR (void, Aml, Info->AmlOffset); 514 515 switch (Info->Opcode) 516 { 517 case ACPI_RSC_INITSET: 518 519 memset (Aml, 0, INIT_RESOURCE_LENGTH (Info)); 520 AmlLength = INIT_RESOURCE_LENGTH (Info); 521 AcpiRsSetResourceHeader ( 522 INIT_RESOURCE_TYPE (Info), AmlLength, Aml); 523 break; 524 525 case ACPI_RSC_INITGET: 526 break; 527 528 case ACPI_RSC_FLAGINIT: 529 /* 530 * Clear the flag byte 531 */ 532 ACPI_SET8 (Destination, 0); 533 break; 534 535 case ACPI_RSC_1BITFLAG: 536 /* 537 * Mask and shift the flag bit 538 */ 539 ACPI_SET_BIT (*ACPI_CAST8 (Destination), (UINT8) 540 ((ACPI_GET8 (Source) & 0x01) << Info->Value)); 541 break; 542 543 case ACPI_RSC_2BITFLAG: 544 /* 545 * Mask and shift the flag bits 546 */ 547 ACPI_SET_BIT (*ACPI_CAST8 (Destination), (UINT8) 548 ((ACPI_GET8 (Source) & 0x03) << Info->Value)); 549 break; 550 551 case ACPI_RSC_3BITFLAG: 552 /* 553 * Mask and shift the flag bits 554 */ 555 ACPI_SET_BIT (*ACPI_CAST8 (Destination), (UINT8) 556 ((ACPI_GET8 (Source) & 0x07) << Info->Value)); 557 break; 558 559 case ACPI_RSC_6BITFLAG: 560 /* 561 * Mask and shift the flag bits 562 */ 563 ACPI_SET_BIT (*ACPI_CAST8 (Destination), (UINT8) 564 ((ACPI_GET8 (Source) & 0x3F) << Info->Value)); 565 break; 566 567 case ACPI_RSC_COUNT: 568 569 ItemCount = ACPI_GET8 (Source); 570 ACPI_SET8 (Destination, ItemCount); 571 572 AmlLength = (UINT16) 573 (AmlLength + (Info->Value * (ItemCount - 1))); 574 break; 575 576 case ACPI_RSC_COUNT16: 577 578 ItemCount = ACPI_GET16 (Source); 579 AmlLength = (UINT16) (AmlLength + ItemCount); 580 AcpiRsSetResourceLength (AmlLength, Aml); 581 break; 582 583 case ACPI_RSC_COUNT_GPIO_PIN: 584 585 ItemCount = ACPI_GET16 (Source); 586 ACPI_SET16 (Destination, AmlLength); 587 588 AmlLength = (UINT16) (AmlLength + ItemCount * 2); 589 Target = ACPI_ADD_PTR (void, Aml, Info->Value); 590 ACPI_SET16 (Target, AmlLength); 591 AcpiRsSetResourceLength (AmlLength, Aml); 592 break; 593 594 case ACPI_RSC_COUNT_GPIO_VEN: 595 596 ItemCount = ACPI_GET16 (Source); 597 ACPI_SET16 (Destination, ItemCount); 598 599 AmlLength = (UINT16) ( 600 AmlLength + (Info->Value * ItemCount)); 601 AcpiRsSetResourceLength (AmlLength, Aml); 602 break; 603 604 case ACPI_RSC_COUNT_GPIO_RES: 605 606 /* Set resource source string length */ 607 608 ItemCount = ACPI_GET16 (Source); 609 ACPI_SET16 (Destination, AmlLength); 610 611 /* Compute offset for the Vendor Data */ 612 613 AmlLength = (UINT16) (AmlLength + ItemCount); 614 Target = ACPI_ADD_PTR (void, Aml, Info->Value); 615 616 /* Set vendor offset only if there is vendor data */ 617 618 ACPI_SET16 (Target, AmlLength); 619 620 AcpiRsSetResourceLength (AmlLength, Aml); 621 break; 622 623 case ACPI_RSC_COUNT_SERIAL_VEN: 624 625 ItemCount = ACPI_GET16 (Source); 626 ACPI_SET16 (Destination, ItemCount + Info->Value); 627 AmlLength = (UINT16) (AmlLength + ItemCount); 628 AcpiRsSetResourceLength (AmlLength, Aml); 629 break; 630 631 case ACPI_RSC_COUNT_SERIAL_RES: 632 633 ItemCount = ACPI_GET16 (Source); 634 AmlLength = (UINT16) (AmlLength + ItemCount); 635 AcpiRsSetResourceLength (AmlLength, Aml); 636 break; 637 638 case ACPI_RSC_LENGTH: 639 640 AcpiRsSetResourceLength (Info->Value, Aml); 641 break; 642 643 case ACPI_RSC_MOVE8: 644 case ACPI_RSC_MOVE16: 645 case ACPI_RSC_MOVE32: 646 case ACPI_RSC_MOVE64: 647 648 if (Info->Value) 649 { 650 ItemCount = Info->Value; 651 } 652 AcpiRsMoveData (Destination, Source, ItemCount, Info->Opcode); 653 break; 654 655 case ACPI_RSC_MOVE_GPIO_PIN: 656 657 Destination = (char *) ACPI_ADD_PTR (void, Aml, 658 ACPI_GET16 (Destination)); 659 Source = * (UINT16 **) Source; 660 AcpiRsMoveData (Destination, Source, ItemCount, Info->Opcode); 661 break; 662 663 case ACPI_RSC_MOVE_GPIO_RES: 664 665 /* Used for both ResourceSource string and VendorData */ 666 667 Destination = (char *) ACPI_ADD_PTR (void, Aml, 668 ACPI_GET16 (Destination)); 669 Source = * (UINT8 **) Source; 670 AcpiRsMoveData (Destination, Source, ItemCount, Info->Opcode); 671 break; 672 673 case ACPI_RSC_MOVE_SERIAL_VEN: 674 675 Destination = (char *) ACPI_ADD_PTR (void, Aml, 676 (AmlLength - ItemCount)); 677 Source = * (UINT8 **) Source; 678 AcpiRsMoveData (Destination, Source, ItemCount, Info->Opcode); 679 break; 680 681 case ACPI_RSC_MOVE_SERIAL_RES: 682 683 Destination = (char *) ACPI_ADD_PTR (void, Aml, 684 (AmlLength - ItemCount)); 685 Source = * (UINT8 **) Source; 686 AcpiRsMoveData (Destination, Source, ItemCount, Info->Opcode); 687 break; 688 689 case ACPI_RSC_ADDRESS: 690 691 /* Set the Resource Type, General Flags, and Type-Specific Flags */ 692 693 AcpiRsSetAddressCommon (Aml, Resource); 694 break; 695 696 case ACPI_RSC_SOURCEX: 697 /* 698 * Optional ResourceSource (Index and String) 699 */ 700 AmlLength = AcpiRsSetResourceSource ( 701 Aml, (ACPI_RS_LENGTH) AmlLength, Source); 702 AcpiRsSetResourceLength (AmlLength, Aml); 703 break; 704 705 case ACPI_RSC_SOURCE: 706 /* 707 * Optional ResourceSource (Index and String). This is the more 708 * complicated case used by the Interrupt() macro 709 */ 710 AmlLength = AcpiRsSetResourceSource (Aml, Info->Value, Source); 711 AcpiRsSetResourceLength (AmlLength, Aml); 712 break; 713 714 case ACPI_RSC_BITMASK: 715 /* 716 * 8-bit encoded bitmask (DMA macro) 717 */ 718 ACPI_SET8 (Destination, 719 AcpiRsEncodeBitmask (Source, 720 *ACPI_ADD_PTR (UINT8, Resource, Info->Value))); 721 break; 722 723 case ACPI_RSC_BITMASK16: 724 /* 725 * 16-bit encoded bitmask (IRQ macro) 726 */ 727 Temp16 = AcpiRsEncodeBitmask ( 728 Source, *ACPI_ADD_PTR (UINT8, Resource, Info->Value)); 729 ACPI_MOVE_16_TO_16 (Destination, &Temp16); 730 break; 731 732 case ACPI_RSC_EXIT_LE: 733 /* 734 * Control - Exit conversion if less than or equal 735 */ 736 if (ItemCount <= Info->Value) 737 { 738 goto Exit; 739 } 740 break; 741 742 case ACPI_RSC_EXIT_NE: 743 /* 744 * Control - Exit conversion if not equal 745 */ 746 switch (COMPARE_OPCODE (Info)) 747 { 748 case ACPI_RSC_COMPARE_VALUE: 749 750 if (*ACPI_ADD_PTR (UINT8, Resource, 751 COMPARE_TARGET (Info)) != COMPARE_VALUE (Info)) 752 { 753 goto Exit; 754 } 755 break; 756 757 default: 758 759 ACPI_ERROR ((AE_INFO, "Invalid conversion sub-opcode")); 760 return_ACPI_STATUS (AE_BAD_PARAMETER); 761 } 762 break; 763 764 case ACPI_RSC_EXIT_EQ: 765 /* 766 * Control - Exit conversion if equal 767 */ 768 if (*ACPI_ADD_PTR (UINT8, Resource, 769 COMPARE_TARGET (Info)) == COMPARE_VALUE (Info)) 770 { 771 goto Exit; 772 } 773 break; 774 775 default: 776 777 ACPI_ERROR ((AE_INFO, "Invalid conversion opcode")); 778 return_ACPI_STATUS (AE_BAD_PARAMETER); 779 } 780 781 Count--; 782 Info++; 783 } 784 785 Exit: 786 return_ACPI_STATUS (AE_OK); 787 } 788 789 790 #if 0 791 /* Previous resource validations */ 792 793 if (Aml->ExtAddress64.RevisionID != 794 AML_RESOURCE_EXTENDED_ADDRESS_REVISION) 795 { 796 return_ACPI_STATUS (AE_SUPPORT); 797 } 798 799 if (Resource->Data.StartDpf.PerformanceRobustness >= 3) 800 { 801 return_ACPI_STATUS (AE_AML_BAD_RESOURCE_VALUE); 802 } 803 804 if (((Aml->Irq.Flags & 0x09) == 0x00) || 805 ((Aml->Irq.Flags & 0x09) == 0x09)) 806 { 807 /* 808 * Only [ActiveHigh, EdgeSensitive] or [ActiveLow, LevelSensitive] 809 * polarity/trigger interrupts are allowed (ACPI spec, section 810 * "IRQ Format"), so 0x00 and 0x09 are illegal. 811 */ 812 ACPI_ERROR ((AE_INFO, 813 "Invalid interrupt polarity/trigger in resource list, 0x%X", 814 Aml->Irq.Flags)); 815 return_ACPI_STATUS (AE_BAD_DATA); 816 } 817 818 Resource->Data.ExtendedIrq.InterruptCount = Temp8; 819 if (Temp8 < 1) 820 { 821 /* Must have at least one IRQ */ 822 823 return_ACPI_STATUS (AE_AML_BAD_RESOURCE_LENGTH); 824 } 825 826 if (Resource->Data.Dma.Transfer == 0x03) 827 { 828 ACPI_ERROR ((AE_INFO, 829 "Invalid DMA.Transfer preference (3)")); 830 return_ACPI_STATUS (AE_BAD_DATA); 831 } 832 #endif 833