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