aslrestype1.c revision 202771
1 2/****************************************************************************** 3 * 4 * Module Name: aslrestype1 - Short (type1) resource templates and descriptors 5 * 6 *****************************************************************************/ 7 8/****************************************************************************** 9 * 10 * 1. Copyright Notice 11 * 12 * Some or all of this work - Copyright (c) 1999 - 2010, Intel Corp. 13 * All rights reserved. 14 * 15 * 2. License 16 * 17 * 2.1. This is your license from Intel Corp. under its intellectual property 18 * rights. You may have additional license terms from the party that provided 19 * you this software, covering your right to use that party's intellectual 20 * property rights. 21 * 22 * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a 23 * copy of the source code appearing in this file ("Covered Code") an 24 * irrevocable, perpetual, worldwide license under Intel's copyrights in the 25 * base code distributed originally by Intel ("Original Intel Code") to copy, 26 * make derivatives, distribute, use and display any portion of the Covered 27 * Code in any form, with the right to sublicense such rights; and 28 * 29 * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent 30 * license (with the right to sublicense), under only those claims of Intel 31 * patents that are infringed by the Original Intel Code, to make, use, sell, 32 * offer to sell, and import the Covered Code and derivative works thereof 33 * solely to the minimum extent necessary to exercise the above copyright 34 * license, and in no event shall the patent license extend to any additions 35 * to or modifications of the Original Intel Code. No other license or right 36 * is granted directly or by implication, estoppel or otherwise; 37 * 38 * The above copyright and patent license is granted only if the following 39 * conditions are met: 40 * 41 * 3. Conditions 42 * 43 * 3.1. Redistribution of Source with Rights to Further Distribute Source. 44 * Redistribution of source code of any substantial portion of the Covered 45 * Code or modification with rights to further distribute source must include 46 * the above Copyright Notice, the above License, this list of Conditions, 47 * and the following Disclaimer and Export Compliance provision. In addition, 48 * Licensee must cause all Covered Code to which Licensee contributes to 49 * contain a file documenting the changes Licensee made to create that Covered 50 * Code and the date of any change. Licensee must include in that file the 51 * documentation of any changes made by any predecessor Licensee. Licensee 52 * must include a prominent statement that the modification is derived, 53 * directly or indirectly, from Original Intel Code. 54 * 55 * 3.2. Redistribution of Source with no Rights to Further Distribute Source. 56 * Redistribution of source code of any substantial portion of the Covered 57 * Code or modification without rights to further distribute source must 58 * include the following Disclaimer and Export Compliance provision in the 59 * documentation and/or other materials provided with distribution. In 60 * addition, Licensee may not authorize further sublicense of source of any 61 * portion of the Covered Code, and must include terms to the effect that the 62 * license from Licensee to its licensee is limited to the intellectual 63 * property embodied in the software Licensee provides to its licensee, and 64 * not to intellectual property embodied in modifications its licensee may 65 * make. 66 * 67 * 3.3. Redistribution of Executable. Redistribution in executable form of any 68 * substantial portion of the Covered Code or modification must reproduce the 69 * above Copyright Notice, and the following Disclaimer and Export Compliance 70 * provision in the documentation and/or other materials provided with the 71 * distribution. 72 * 73 * 3.4. Intel retains all right, title, and interest in and to the Original 74 * Intel Code. 75 * 76 * 3.5. Neither the name Intel nor any other trademark owned or controlled by 77 * Intel shall be used in advertising or otherwise to promote the sale, use or 78 * other dealings in products derived from or relating to the Covered Code 79 * without prior written authorization from Intel. 80 * 81 * 4. Disclaimer and Export Compliance 82 * 83 * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED 84 * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE 85 * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, 86 * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY 87 * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY 88 * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A 89 * PARTICULAR PURPOSE. 90 * 91 * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES 92 * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR 93 * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, 94 * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY 95 * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL 96 * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS 97 * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY 98 * LIMITED REMEDY. 99 * 100 * 4.3. Licensee shall not export, either directly or indirectly, any of this 101 * software or system incorporating such software without first obtaining any 102 * required license or other approval from the U. S. Department of Commerce or 103 * any other agency or department of the United States Government. In the 104 * event Licensee exports any such software from the United States or 105 * re-exports any such software from a foreign destination, Licensee shall 106 * ensure that the distribution and export/re-export of the software is in 107 * compliance with all laws, regulations, orders, or other restrictions of the 108 * U.S. Export Administration Regulations. Licensee agrees that neither it nor 109 * any of its subsidiaries will export/re-export any technical data, process, 110 * software, or service, directly or indirectly, to any country for which the 111 * United States government or any agency thereof requires an export license, 112 * other governmental approval, or letter of assurance, without first obtaining 113 * such license, approval or letter. 114 * 115 *****************************************************************************/ 116 117 118#include <contrib/dev/acpica/compiler/aslcompiler.h> 119#include "aslcompiler.y.h" 120 121#define _COMPONENT ACPI_COMPILER 122 ACPI_MODULE_NAME ("aslrestype1") 123 124 125/******************************************************************************* 126 * 127 * FUNCTION: RsDoEndTagDescriptor 128 * 129 * PARAMETERS: Op - Parent resource descriptor parse node 130 * CurrentByteOffset - Offset into the resource template AML 131 * buffer (to track references to the desc) 132 * 133 * RETURN: Completed resource node 134 * 135 * DESCRIPTION: Construct a short "EndDependentFn" descriptor 136 * 137 ******************************************************************************/ 138 139ASL_RESOURCE_NODE * 140RsDoEndTagDescriptor ( 141 ACPI_PARSE_OBJECT *Op, 142 UINT32 CurrentByteOffset) 143{ 144 AML_RESOURCE *Descriptor; 145 ASL_RESOURCE_NODE *Rnode; 146 147 148 Rnode = RsAllocateResourceNode (sizeof (AML_RESOURCE_END_TAG)); 149 150 Descriptor = Rnode->Buffer; 151 Descriptor->EndTag.DescriptorType = ACPI_RESOURCE_NAME_END_TAG | 152 ASL_RDESC_END_TAG_SIZE; 153 Descriptor->EndTag.Checksum = 0; 154 155 return (Rnode); 156} 157 158 159/******************************************************************************* 160 * 161 * FUNCTION: RsDoDmaDescriptor 162 * 163 * PARAMETERS: Op - Parent resource descriptor parse node 164 * CurrentByteOffset - Offset into the resource template AML 165 * buffer (to track references to the desc) 166 * 167 * RETURN: Completed resource node 168 * 169 * DESCRIPTION: Construct a short "DMA" descriptor 170 * 171 ******************************************************************************/ 172 173ASL_RESOURCE_NODE * 174RsDoDmaDescriptor ( 175 ACPI_PARSE_OBJECT *Op, 176 UINT32 CurrentByteOffset) 177{ 178 AML_RESOURCE *Descriptor; 179 ACPI_PARSE_OBJECT *InitializerOp; 180 ASL_RESOURCE_NODE *Rnode; 181 UINT32 i; 182 UINT8 DmaChannelMask = 0; 183 UINT8 DmaChannels = 0; 184 185 186 InitializerOp = Op->Asl.Child; 187 Rnode = RsAllocateResourceNode (sizeof (AML_RESOURCE_DMA)); 188 189 Descriptor = Rnode->Buffer; 190 Descriptor->Dma.DescriptorType = ACPI_RESOURCE_NAME_DMA | 191 ASL_RDESC_DMA_SIZE; 192 193 /* Process all child initialization nodes */ 194 195 for (i = 0; InitializerOp; i++) 196 { 197 switch (i) 198 { 199 case 0: /* DMA type */ 200 201 RsSetFlagBits (&Descriptor->Dma.Flags, InitializerOp, 5, 0); 202 RsCreateBitField (InitializerOp, ACPI_RESTAG_DMATYPE, 203 CurrentByteOffset + ASL_RESDESC_OFFSET (Dma.Flags), 5); 204 break; 205 206 case 1: /* Bus Master */ 207 208 RsSetFlagBits (&Descriptor->Dma.Flags, InitializerOp, 2, 0); 209 RsCreateBitField (InitializerOp, ACPI_RESTAG_BUSMASTER, 210 CurrentByteOffset + ASL_RESDESC_OFFSET (Dma.Flags), 2); 211 break; 212 213 case 2: /* Xfer Type (transfer width) */ 214 215 RsSetFlagBits (&Descriptor->Dma.Flags, InitializerOp, 0, 0); 216 RsCreateBitField (InitializerOp, ACPI_RESTAG_XFERTYPE, 217 CurrentByteOffset + ASL_RESDESC_OFFSET (Dma.Flags), 0); 218 break; 219 220 case 3: /* Name */ 221 222 UtAttachNamepathToOwner (Op, InitializerOp); 223 break; 224 225 default: 226 227 /* All DMA channel bytes are handled here, after flags and name */ 228 229 if (InitializerOp->Asl.ParseOpcode != PARSEOP_DEFAULT_ARG) 230 { 231 /* Up to 8 channels can be specified in the list */ 232 233 DmaChannels++; 234 if (DmaChannels > 8) 235 { 236 AslError (ASL_ERROR, ASL_MSG_DMA_LIST, 237 InitializerOp, NULL); 238 return (Rnode); 239 } 240 241 /* Only DMA channels 0-7 are allowed (mask is 8 bits) */ 242 243 if (InitializerOp->Asl.Value.Integer > 7) 244 { 245 AslError (ASL_ERROR, ASL_MSG_DMA_CHANNEL, 246 InitializerOp, NULL); 247 } 248 249 /* Build the mask */ 250 251 DmaChannelMask |= 252 (1 << ((UINT8) InitializerOp->Asl.Value.Integer)); 253 } 254 255 if (i == 4) /* case 4: First DMA byte */ 256 { 257 /* Check now for duplicates in list */ 258 259 RsCheckListForDuplicates (InitializerOp); 260 261 /* Create a named field at the start of the list */ 262 263 RsCreateByteField (InitializerOp, ACPI_RESTAG_DMA, 264 CurrentByteOffset + 265 ASL_RESDESC_OFFSET (Dma.DmaChannelMask)); 266 } 267 break; 268 } 269 270 InitializerOp = RsCompleteNodeAndGetNext (InitializerOp); 271 } 272 273 /* Now we can set the channel mask */ 274 275 Descriptor->Dma.DmaChannelMask = DmaChannelMask; 276 return (Rnode); 277} 278 279 280/******************************************************************************* 281 * 282 * FUNCTION: RsDoEndDependentDescriptor 283 * 284 * PARAMETERS: Op - Parent resource descriptor parse node 285 * CurrentByteOffset - Offset into the resource template AML 286 * buffer (to track references to the desc) 287 * 288 * RETURN: Completed resource node 289 * 290 * DESCRIPTION: Construct a short "EndDependentFn" descriptor 291 * 292 ******************************************************************************/ 293 294ASL_RESOURCE_NODE * 295RsDoEndDependentDescriptor ( 296 ACPI_PARSE_OBJECT *Op, 297 UINT32 CurrentByteOffset) 298{ 299 AML_RESOURCE *Descriptor; 300 ASL_RESOURCE_NODE *Rnode; 301 302 303 Rnode = RsAllocateResourceNode (sizeof (AML_RESOURCE_END_DEPENDENT)); 304 305 Descriptor = Rnode->Buffer; 306 Descriptor->EndDpf.DescriptorType = ACPI_RESOURCE_NAME_END_DEPENDENT | 307 ASL_RDESC_END_DEPEND_SIZE; 308 return (Rnode); 309} 310 311 312/******************************************************************************* 313 * 314 * FUNCTION: RsDoFixedIoDescriptor 315 * 316 * PARAMETERS: Op - Parent resource descriptor parse node 317 * CurrentByteOffset - Offset into the resource template AML 318 * buffer (to track references to the desc) 319 * 320 * RETURN: Completed resource node 321 * 322 * DESCRIPTION: Construct a short "FixedIO" descriptor 323 * 324 ******************************************************************************/ 325 326ASL_RESOURCE_NODE * 327RsDoFixedIoDescriptor ( 328 ACPI_PARSE_OBJECT *Op, 329 UINT32 CurrentByteOffset) 330{ 331 AML_RESOURCE *Descriptor; 332 ACPI_PARSE_OBJECT *InitializerOp; 333 ASL_RESOURCE_NODE *Rnode; 334 UINT32 i; 335 336 337 InitializerOp = Op->Asl.Child; 338 Rnode = RsAllocateResourceNode (sizeof (AML_RESOURCE_FIXED_IO)); 339 340 Descriptor = Rnode->Buffer; 341 Descriptor->Io.DescriptorType = ACPI_RESOURCE_NAME_FIXED_IO | 342 ASL_RDESC_FIXED_IO_SIZE; 343 344 /* Process all child initialization nodes */ 345 346 for (i = 0; InitializerOp; i++) 347 { 348 switch (i) 349 { 350 case 0: /* Base Address */ 351 352 Descriptor->FixedIo.Address = 353 (UINT16) InitializerOp->Asl.Value.Integer; 354 RsCreateByteField (InitializerOp, ACPI_RESTAG_BASEADDRESS, 355 CurrentByteOffset + ASL_RESDESC_OFFSET (FixedIo.Address)); 356 break; 357 358 case 1: /* Length */ 359 360 Descriptor->FixedIo.AddressLength = 361 (UINT8) InitializerOp->Asl.Value.Integer; 362 RsCreateByteField (InitializerOp, ACPI_RESTAG_LENGTH, 363 CurrentByteOffset + ASL_RESDESC_OFFSET (FixedIo.AddressLength)); 364 break; 365 366 case 2: /* Name */ 367 368 UtAttachNamepathToOwner (Op, InitializerOp); 369 break; 370 371 default: 372 373 AslError (ASL_ERROR, ASL_MSG_RESOURCE_LIST, InitializerOp, NULL); 374 break; 375 } 376 377 InitializerOp = RsCompleteNodeAndGetNext (InitializerOp); 378 } 379 380 return (Rnode); 381} 382 383 384/******************************************************************************* 385 * 386 * FUNCTION: RsDoIoDescriptor 387 * 388 * PARAMETERS: Op - Parent resource descriptor parse node 389 * CurrentByteOffset - Offset into the resource template AML 390 * buffer (to track references to the desc) 391 * 392 * RETURN: Completed resource node 393 * 394 * DESCRIPTION: Construct a short "IO" descriptor 395 * 396 ******************************************************************************/ 397 398ASL_RESOURCE_NODE * 399RsDoIoDescriptor ( 400 ACPI_PARSE_OBJECT *Op, 401 UINT32 CurrentByteOffset) 402{ 403 AML_RESOURCE *Descriptor; 404 ACPI_PARSE_OBJECT *InitializerOp; 405 ASL_RESOURCE_NODE *Rnode; 406 UINT32 i; 407 408 409 InitializerOp = Op->Asl.Child; 410 Rnode = RsAllocateResourceNode (sizeof (AML_RESOURCE_IO)); 411 412 Descriptor = Rnode->Buffer; 413 Descriptor->Io.DescriptorType = ACPI_RESOURCE_NAME_IO | 414 ASL_RDESC_IO_SIZE; 415 416 /* Process all child initialization nodes */ 417 418 for (i = 0; InitializerOp; i++) 419 { 420 switch (i) 421 { 422 case 0: /* Decode size */ 423 424 RsSetFlagBits (&Descriptor->Io.Flags, InitializerOp, 0, 1); 425 RsCreateBitField (InitializerOp, ACPI_RESTAG_DECODE, 426 CurrentByteOffset + ASL_RESDESC_OFFSET (Io.Flags), 0); 427 break; 428 429 case 1: /* Min Address */ 430 431 Descriptor->Io.Minimum = 432 (UINT16) InitializerOp->Asl.Value.Integer; 433 RsCreateByteField (InitializerOp, ACPI_RESTAG_MINADDR, 434 CurrentByteOffset + ASL_RESDESC_OFFSET (Io.Minimum)); 435 break; 436 437 case 2: /* Max Address */ 438 439 Descriptor->Io.Maximum = 440 (UINT16) InitializerOp->Asl.Value.Integer; 441 RsCreateByteField (InitializerOp, ACPI_RESTAG_MAXADDR, 442 CurrentByteOffset + ASL_RESDESC_OFFSET (Io.Maximum)); 443 break; 444 445 case 3: /* Alignment */ 446 447 Descriptor->Io.Alignment = 448 (UINT8) InitializerOp->Asl.Value.Integer; 449 RsCreateByteField (InitializerOp, ACPI_RESTAG_ALIGNMENT, 450 CurrentByteOffset + ASL_RESDESC_OFFSET (Io.Alignment)); 451 break; 452 453 case 4: /* Length */ 454 455 Descriptor->Io.AddressLength = 456 (UINT8) InitializerOp->Asl.Value.Integer; 457 RsCreateByteField (InitializerOp, ACPI_RESTAG_LENGTH, 458 CurrentByteOffset + ASL_RESDESC_OFFSET (Io.AddressLength)); 459 break; 460 461 case 5: /* Name */ 462 463 UtAttachNamepathToOwner (Op, InitializerOp); 464 break; 465 466 default: 467 468 AslError (ASL_ERROR, ASL_MSG_RESOURCE_LIST, InitializerOp, NULL); 469 break; 470 } 471 472 InitializerOp = RsCompleteNodeAndGetNext (InitializerOp); 473 } 474 475 return (Rnode); 476} 477 478 479/******************************************************************************* 480 * 481 * FUNCTION: RsDoIrqDescriptor 482 * 483 * PARAMETERS: Op - Parent resource descriptor parse node 484 * CurrentByteOffset - Offset into the resource template AML 485 * buffer (to track references to the desc) 486 * 487 * RETURN: Completed resource node 488 * 489 * DESCRIPTION: Construct a short "IRQ" descriptor 490 * 491 ******************************************************************************/ 492 493ASL_RESOURCE_NODE * 494RsDoIrqDescriptor ( 495 ACPI_PARSE_OBJECT *Op, 496 UINT32 CurrentByteOffset) 497{ 498 AML_RESOURCE *Descriptor; 499 ACPI_PARSE_OBJECT *InitializerOp; 500 ASL_RESOURCE_NODE *Rnode; 501 UINT32 Interrupts = 0; 502 UINT16 IrqMask = 0; 503 UINT32 i; 504 505 506 InitializerOp = Op->Asl.Child; 507 Rnode = RsAllocateResourceNode (sizeof (AML_RESOURCE_IRQ)); 508 509 /* Length = 3 (with flag byte) */ 510 511 Descriptor = Rnode->Buffer; 512 Descriptor->Irq.DescriptorType = ACPI_RESOURCE_NAME_IRQ | 513 (ASL_RDESC_IRQ_SIZE + 0x01); 514 515 /* Process all child initialization nodes */ 516 517 for (i = 0; InitializerOp; i++) 518 { 519 switch (i) 520 { 521 case 0: /* Interrupt Type (or Mode - edge/level) */ 522 523 RsSetFlagBits (&Descriptor->Irq.Flags, InitializerOp, 0, 1); 524 RsCreateBitField (InitializerOp, ACPI_RESTAG_INTERRUPTTYPE, 525 CurrentByteOffset + ASL_RESDESC_OFFSET (Irq.Flags), 0); 526 break; 527 528 case 1: /* Interrupt Level (or Polarity - Active high/low) */ 529 530 RsSetFlagBits (&Descriptor->Irq.Flags, InitializerOp, 3, 0); 531 RsCreateBitField (InitializerOp, ACPI_RESTAG_INTERRUPTLEVEL, 532 CurrentByteOffset + ASL_RESDESC_OFFSET (Irq.Flags), 3); 533 break; 534 535 case 2: /* Share Type - Default: exclusive (0) */ 536 537 RsSetFlagBits (&Descriptor->Irq.Flags, InitializerOp, 4, 0); 538 RsCreateBitField (InitializerOp, ACPI_RESTAG_INTERRUPTSHARE, 539 CurrentByteOffset + ASL_RESDESC_OFFSET (Irq.Flags), 4); 540 break; 541 542 case 3: /* Name */ 543 544 UtAttachNamepathToOwner (Op, InitializerOp); 545 break; 546 547 default: 548 549 /* All IRQ bytes are handled here, after the flags and name */ 550 551 if (InitializerOp->Asl.ParseOpcode != PARSEOP_DEFAULT_ARG) 552 { 553 /* Up to 16 interrupts can be specified in the list */ 554 555 Interrupts++; 556 if (Interrupts > 16) 557 { 558 AslError (ASL_ERROR, ASL_MSG_INTERRUPT_LIST, 559 InitializerOp, NULL); 560 return (Rnode); 561 } 562 563 /* Only interrupts 0-15 are allowed (mask is 16 bits) */ 564 565 if (InitializerOp->Asl.Value.Integer > 15) 566 { 567 AslError (ASL_ERROR, ASL_MSG_INTERRUPT_NUMBER, 568 InitializerOp, NULL); 569 } 570 else 571 { 572 IrqMask |= (1 << (UINT8) InitializerOp->Asl.Value.Integer); 573 } 574 } 575 576 /* Case 4: First IRQ value in list */ 577 578 if (i == 4) 579 { 580 /* Check now for duplicates in list */ 581 582 RsCheckListForDuplicates (InitializerOp); 583 584 /* Create a named field at the start of the list */ 585 586 RsCreateByteField (InitializerOp, ACPI_RESTAG_INTERRUPT, 587 CurrentByteOffset + ASL_RESDESC_OFFSET (Irq.IrqMask)); 588 } 589 break; 590 } 591 592 InitializerOp = RsCompleteNodeAndGetNext (InitializerOp); 593 } 594 595 /* Now we can set the channel mask */ 596 597 Descriptor->Irq.IrqMask = IrqMask; 598 return (Rnode); 599} 600 601 602/******************************************************************************* 603 * 604 * FUNCTION: RsDoIrqNoFlagsDescriptor 605 * 606 * PARAMETERS: Op - Parent resource descriptor parse node 607 * CurrentByteOffset - Offset into the resource template AML 608 * buffer (to track references to the desc) 609 * 610 * RETURN: Completed resource node 611 * 612 * DESCRIPTION: Construct a short "IRQNoFlags" descriptor 613 * 614 ******************************************************************************/ 615 616ASL_RESOURCE_NODE * 617RsDoIrqNoFlagsDescriptor ( 618 ACPI_PARSE_OBJECT *Op, 619 UINT32 CurrentByteOffset) 620{ 621 AML_RESOURCE *Descriptor; 622 ACPI_PARSE_OBJECT *InitializerOp; 623 ASL_RESOURCE_NODE *Rnode; 624 UINT16 IrqMask = 0; 625 UINT32 Interrupts = 0; 626 UINT32 i; 627 628 629 InitializerOp = Op->Asl.Child; 630 Rnode = RsAllocateResourceNode (sizeof (AML_RESOURCE_IRQ_NOFLAGS)); 631 632 Descriptor = Rnode->Buffer; 633 Descriptor->Irq.DescriptorType = ACPI_RESOURCE_NAME_IRQ | 634 ASL_RDESC_IRQ_SIZE; 635 636 /* Process all child initialization nodes */ 637 638 for (i = 0; InitializerOp; i++) 639 { 640 switch (i) 641 { 642 case 0: /* Name */ 643 644 UtAttachNamepathToOwner (Op, InitializerOp); 645 break; 646 647 default: 648 649 /* IRQ bytes are handled here, after the flags and name */ 650 651 if (InitializerOp->Asl.ParseOpcode != PARSEOP_DEFAULT_ARG) 652 { 653 /* Up to 16 interrupts can be specified in the list */ 654 655 Interrupts++; 656 if (Interrupts > 16) 657 { 658 AslError (ASL_ERROR, ASL_MSG_INTERRUPT_LIST, 659 InitializerOp, NULL); 660 return (Rnode); 661 } 662 663 /* Only interrupts 0-15 are allowed (mask is 16 bits) */ 664 665 if (InitializerOp->Asl.Value.Integer > 15) 666 { 667 AslError (ASL_ERROR, ASL_MSG_INTERRUPT_NUMBER, 668 InitializerOp, NULL); 669 } 670 else 671 { 672 IrqMask |= (1 << ((UINT8) InitializerOp->Asl.Value.Integer)); 673 } 674 } 675 676 /* Case 1: First IRQ value in list */ 677 678 if (i == 1) 679 { 680 /* Check now for duplicates in list */ 681 682 RsCheckListForDuplicates (InitializerOp); 683 684 /* Create a named field at the start of the list */ 685 686 RsCreateByteField (InitializerOp, ACPI_RESTAG_INTERRUPT, 687 CurrentByteOffset + ASL_RESDESC_OFFSET (Irq.IrqMask)); 688 } 689 break; 690 } 691 692 InitializerOp = RsCompleteNodeAndGetNext (InitializerOp); 693 } 694 695 /* Now we can set the interrupt mask */ 696 697 Descriptor->Irq.IrqMask = IrqMask; 698 return (Rnode); 699} 700 701 702/******************************************************************************* 703 * 704 * FUNCTION: RsDoMemory24Descriptor 705 * 706 * PARAMETERS: Op - Parent resource descriptor parse node 707 * CurrentByteOffset - Offset into the resource template AML 708 * buffer (to track references to the desc) 709 * 710 * RETURN: Completed resource node 711 * 712 * DESCRIPTION: Construct a short "Memory24" descriptor 713 * 714 ******************************************************************************/ 715 716ASL_RESOURCE_NODE * 717RsDoMemory24Descriptor ( 718 ACPI_PARSE_OBJECT *Op, 719 UINT32 CurrentByteOffset) 720{ 721 AML_RESOURCE *Descriptor; 722 ACPI_PARSE_OBJECT *InitializerOp; 723 ASL_RESOURCE_NODE *Rnode; 724 UINT32 i; 725 726 727 InitializerOp = Op->Asl.Child; 728 Rnode = RsAllocateResourceNode (sizeof (AML_RESOURCE_MEMORY24)); 729 730 Descriptor = Rnode->Buffer; 731 Descriptor->Memory24.DescriptorType = ACPI_RESOURCE_NAME_MEMORY24; 732 Descriptor->Memory24.ResourceLength = 9; 733 734 /* Process all child initialization nodes */ 735 736 for (i = 0; InitializerOp; i++) 737 { 738 switch (i) 739 { 740 case 0: /* Read/Write type */ 741 742 RsSetFlagBits (&Descriptor->Memory24.Flags, InitializerOp, 0, 1); 743 RsCreateBitField (InitializerOp, ACPI_RESTAG_READWRITETYPE, 744 CurrentByteOffset + ASL_RESDESC_OFFSET (Memory24.Flags), 0); 745 break; 746 747 case 1: /* Min Address */ 748 749 Descriptor->Memory24.Minimum = (UINT16) InitializerOp->Asl.Value.Integer; 750 RsCreateByteField (InitializerOp, ACPI_RESTAG_MINADDR, 751 CurrentByteOffset + ASL_RESDESC_OFFSET (Memory24.Minimum)); 752 break; 753 754 case 2: /* Max Address */ 755 756 Descriptor->Memory24.Maximum = (UINT16) InitializerOp->Asl.Value.Integer; 757 RsCreateByteField (InitializerOp, ACPI_RESTAG_MAXADDR, 758 CurrentByteOffset + ASL_RESDESC_OFFSET (Memory24.Maximum)); 759 break; 760 761 case 3: /* Alignment */ 762 763 Descriptor->Memory24.Alignment = (UINT16) InitializerOp->Asl.Value.Integer; 764 RsCreateByteField (InitializerOp, ACPI_RESTAG_ALIGNMENT, 765 CurrentByteOffset + ASL_RESDESC_OFFSET (Memory24.Alignment)); 766 break; 767 768 case 4: /* Length */ 769 770 Descriptor->Memory24.AddressLength = (UINT16) InitializerOp->Asl.Value.Integer; 771 RsCreateByteField (InitializerOp, ACPI_RESTAG_LENGTH, 772 CurrentByteOffset + ASL_RESDESC_OFFSET (Memory24.AddressLength)); 773 break; 774 775 case 5: /* Name */ 776 777 UtAttachNamepathToOwner (Op, InitializerOp); 778 break; 779 780 default: 781 782 AslError (ASL_ERROR, ASL_MSG_RESOURCE_LIST, InitializerOp, NULL); 783 break; 784 } 785 786 InitializerOp = RsCompleteNodeAndGetNext (InitializerOp); 787 } 788 789 return (Rnode); 790} 791 792 793/******************************************************************************* 794 * 795 * FUNCTION: RsDoMemory32Descriptor 796 * 797 * PARAMETERS: Op - Parent resource descriptor parse node 798 * CurrentByteOffset - Offset into the resource template AML 799 * buffer (to track references to the desc) 800 * 801 * RETURN: Completed resource node 802 * 803 * DESCRIPTION: Construct a short "Memory32" descriptor 804 * 805 ******************************************************************************/ 806 807ASL_RESOURCE_NODE * 808RsDoMemory32Descriptor ( 809 ACPI_PARSE_OBJECT *Op, 810 UINT32 CurrentByteOffset) 811{ 812 AML_RESOURCE *Descriptor; 813 ACPI_PARSE_OBJECT *InitializerOp; 814 ASL_RESOURCE_NODE *Rnode; 815 UINT32 i; 816 817 818 InitializerOp = Op->Asl.Child; 819 Rnode = RsAllocateResourceNode (sizeof (AML_RESOURCE_MEMORY32)); 820 821 Descriptor = Rnode->Buffer; 822 Descriptor->Memory32.DescriptorType = ACPI_RESOURCE_NAME_MEMORY32; 823 Descriptor->Memory32.ResourceLength = 17; 824 825 /* Process all child initialization nodes */ 826 827 for (i = 0; InitializerOp; i++) 828 { 829 switch (i) 830 { 831 case 0: /* Read/Write type */ 832 833 RsSetFlagBits (&Descriptor->Memory32.Flags, InitializerOp, 0, 1); 834 RsCreateBitField (InitializerOp, ACPI_RESTAG_READWRITETYPE, 835 CurrentByteOffset + ASL_RESDESC_OFFSET (Memory32.Flags), 0); 836 break; 837 838 case 1: /* Min Address */ 839 840 Descriptor->Memory32.Minimum = (UINT32) InitializerOp->Asl.Value.Integer; 841 RsCreateByteField (InitializerOp, ACPI_RESTAG_MINADDR, 842 CurrentByteOffset + ASL_RESDESC_OFFSET (Memory32.Minimum)); 843 break; 844 845 case 2: /* Max Address */ 846 847 Descriptor->Memory32.Maximum = (UINT32) InitializerOp->Asl.Value.Integer; 848 RsCreateByteField (InitializerOp, ACPI_RESTAG_MAXADDR, 849 CurrentByteOffset + ASL_RESDESC_OFFSET (Memory32.Maximum)); 850 break; 851 852 case 3: /* Alignment */ 853 854 Descriptor->Memory32.Alignment = (UINT32) InitializerOp->Asl.Value.Integer; 855 RsCreateByteField (InitializerOp, ACPI_RESTAG_ALIGNMENT, 856 CurrentByteOffset + ASL_RESDESC_OFFSET (Memory32.Alignment)); 857 break; 858 859 case 4: /* Length */ 860 861 Descriptor->Memory32.AddressLength = (UINT32) InitializerOp->Asl.Value.Integer; 862 RsCreateByteField (InitializerOp, ACPI_RESTAG_LENGTH, 863 CurrentByteOffset + ASL_RESDESC_OFFSET (Memory32.AddressLength)); 864 break; 865 866 case 5: /* Name */ 867 868 UtAttachNamepathToOwner (Op, InitializerOp); 869 break; 870 871 default: 872 873 AslError (ASL_ERROR, ASL_MSG_RESOURCE_LIST, InitializerOp, NULL); 874 break; 875 } 876 877 InitializerOp = RsCompleteNodeAndGetNext (InitializerOp); 878 } 879 880 return (Rnode); 881} 882 883 884/******************************************************************************* 885 * 886 * FUNCTION: RsDoMemory32FixedDescriptor 887 * 888 * PARAMETERS: Op - Parent resource descriptor parse node 889 * CurrentByteOffset - Offset into the resource template AML 890 * buffer (to track references to the desc) 891 * 892 * RETURN: Completed resource node 893 * 894 * DESCRIPTION: Construct a short "Memory32Fixed" descriptor 895 * 896 ******************************************************************************/ 897 898ASL_RESOURCE_NODE * 899RsDoMemory32FixedDescriptor ( 900 ACPI_PARSE_OBJECT *Op, 901 UINT32 CurrentByteOffset) 902{ 903 AML_RESOURCE *Descriptor; 904 ACPI_PARSE_OBJECT *InitializerOp; 905 ASL_RESOURCE_NODE *Rnode; 906 UINT32 i; 907 908 909 InitializerOp = Op->Asl.Child; 910 Rnode = RsAllocateResourceNode (sizeof (AML_RESOURCE_FIXED_MEMORY32)); 911 912 Descriptor = Rnode->Buffer; 913 Descriptor->FixedMemory32.DescriptorType = ACPI_RESOURCE_NAME_FIXED_MEMORY32; 914 Descriptor->FixedMemory32.ResourceLength = 9; 915 916 /* Process all child initialization nodes */ 917 918 for (i = 0; InitializerOp; i++) 919 { 920 switch (i) 921 { 922 case 0: /* Read/Write type */ 923 924 RsSetFlagBits (&Descriptor->FixedMemory32.Flags, InitializerOp, 0, 1); 925 RsCreateBitField (InitializerOp, ACPI_RESTAG_READWRITETYPE, 926 CurrentByteOffset + ASL_RESDESC_OFFSET (FixedMemory32.Flags), 0); 927 break; 928 929 case 1: /* Address */ 930 931 Descriptor->FixedMemory32.Address = (UINT32) InitializerOp->Asl.Value.Integer; 932 RsCreateByteField (InitializerOp, ACPI_RESTAG_BASEADDRESS, 933 CurrentByteOffset + ASL_RESDESC_OFFSET (FixedMemory32.Address)); 934 break; 935 936 case 2: /* Length */ 937 938 Descriptor->FixedMemory32.AddressLength = (UINT32) InitializerOp->Asl.Value.Integer; 939 RsCreateByteField (InitializerOp, ACPI_RESTAG_LENGTH, 940 CurrentByteOffset + ASL_RESDESC_OFFSET (FixedMemory32.AddressLength)); 941 break; 942 943 case 3: /* Name */ 944 945 UtAttachNamepathToOwner (Op, InitializerOp); 946 break; 947 948 default: 949 950 AslError (ASL_ERROR, ASL_MSG_RESOURCE_LIST, InitializerOp, NULL); 951 break; 952 } 953 954 InitializerOp = RsCompleteNodeAndGetNext (InitializerOp); 955 } 956 957 return (Rnode); 958} 959 960 961/******************************************************************************* 962 * 963 * FUNCTION: RsDoStartDependentDescriptor 964 * 965 * PARAMETERS: Op - Parent resource descriptor parse node 966 * CurrentByteOffset - Offset into the resource template AML 967 * buffer (to track references to the desc) 968 * 969 * RETURN: Completed resource node 970 * 971 * DESCRIPTION: Construct a short "StartDependentFn" descriptor 972 * 973 ******************************************************************************/ 974 975ASL_RESOURCE_NODE * 976RsDoStartDependentDescriptor ( 977 ACPI_PARSE_OBJECT *Op, 978 UINT32 CurrentByteOffset) 979{ 980 AML_RESOURCE *Descriptor; 981 ACPI_PARSE_OBJECT *InitializerOp; 982 ASL_RESOURCE_NODE *Rnode; 983 ASL_RESOURCE_NODE *PreviousRnode; 984 ASL_RESOURCE_NODE *NextRnode; 985 UINT32 i; 986 UINT8 State; 987 988 989 InitializerOp = Op->Asl.Child; 990 Rnode = RsAllocateResourceNode (sizeof (AML_RESOURCE_START_DEPENDENT)); 991 992 PreviousRnode = Rnode; 993 Descriptor = Rnode->Buffer; 994 995 /* Descriptor has priority byte */ 996 997 Descriptor->StartDpf.DescriptorType = ACPI_RESOURCE_NAME_START_DEPENDENT | 998 (ASL_RDESC_ST_DEPEND_SIZE + 0x01); 999 1000 /* Process all child initialization nodes */ 1001 1002 State = ACPI_RSTATE_START_DEPENDENT; 1003 for (i = 0; InitializerOp; i++) 1004 { 1005 switch (i) 1006 { 1007 case 0: /* Compatibility Priority */ 1008 1009 if ((UINT8) InitializerOp->Asl.Value.Integer > 2) 1010 { 1011 AslError (ASL_ERROR, ASL_MSG_INVALID_PRIORITY, 1012 InitializerOp, NULL); 1013 } 1014 1015 RsSetFlagBits (&Descriptor->StartDpf.Flags, InitializerOp, 0, 0); 1016 break; 1017 1018 case 1: /* Performance/Robustness Priority */ 1019 1020 if ((UINT8) InitializerOp->Asl.Value.Integer > 2) 1021 { 1022 AslError (ASL_ERROR, ASL_MSG_INVALID_PERFORMANCE, 1023 InitializerOp, NULL); 1024 } 1025 1026 RsSetFlagBits (&Descriptor->StartDpf.Flags, InitializerOp, 2, 0); 1027 break; 1028 1029 default: 1030 NextRnode = RsDoOneResourceDescriptor (InitializerOp, 1031 CurrentByteOffset, &State); 1032 1033 /* 1034 * Update current byte offset to indicate the number of bytes from the 1035 * start of the buffer. Buffer can include multiple descriptors, we 1036 * must keep track of the offset of not only each descriptor, but each 1037 * element (field) within each descriptor as well. 1038 */ 1039 1040 CurrentByteOffset += RsLinkDescriptorChain (&PreviousRnode, 1041 NextRnode); 1042 break; 1043 } 1044 1045 InitializerOp = RsCompleteNodeAndGetNext (InitializerOp); 1046 } 1047 1048 return (Rnode); 1049} 1050 1051 1052/******************************************************************************* 1053 * 1054 * FUNCTION: RsDoStartDependentNoPriDescriptor 1055 * 1056 * PARAMETERS: Op - Parent resource descriptor parse node 1057 * CurrentByteOffset - Offset into the resource template AML 1058 * buffer (to track references to the desc) 1059 * 1060 * RETURN: Completed resource node 1061 * 1062 * DESCRIPTION: Construct a short "StartDependentNoPri" descriptor 1063 * 1064 ******************************************************************************/ 1065 1066ASL_RESOURCE_NODE * 1067RsDoStartDependentNoPriDescriptor ( 1068 ACPI_PARSE_OBJECT *Op, 1069 UINT32 CurrentByteOffset) 1070{ 1071 AML_RESOURCE *Descriptor; 1072 ACPI_PARSE_OBJECT *InitializerOp; 1073 ASL_RESOURCE_NODE *Rnode; 1074 ASL_RESOURCE_NODE *PreviousRnode; 1075 ASL_RESOURCE_NODE *NextRnode; 1076 UINT8 State; 1077 1078 1079 InitializerOp = Op->Asl.Child; 1080 Rnode = RsAllocateResourceNode (sizeof (AML_RESOURCE_START_DEPENDENT_NOPRIO)); 1081 1082 Descriptor = Rnode->Buffer; 1083 Descriptor->StartDpf.DescriptorType = ACPI_RESOURCE_NAME_START_DEPENDENT | 1084 ASL_RDESC_ST_DEPEND_SIZE; 1085 PreviousRnode = Rnode; 1086 1087 /* Process all child initialization nodes */ 1088 1089 State = ACPI_RSTATE_START_DEPENDENT; 1090 while (InitializerOp) 1091 { 1092 NextRnode = RsDoOneResourceDescriptor (InitializerOp, 1093 CurrentByteOffset, &State); 1094 1095 /* 1096 * Update current byte offset to indicate the number of bytes from the 1097 * start of the buffer. Buffer can include multiple descriptors, we 1098 * must keep track of the offset of not only each descriptor, but each 1099 * element (field) within each descriptor as well. 1100 */ 1101 CurrentByteOffset += RsLinkDescriptorChain (&PreviousRnode, NextRnode); 1102 1103 InitializerOp = RsCompleteNodeAndGetNext (InitializerOp); 1104 } 1105 1106 return (Rnode); 1107} 1108 1109 1110/******************************************************************************* 1111 * 1112 * FUNCTION: RsDoVendorSmallDescriptor 1113 * 1114 * PARAMETERS: Op - Parent resource descriptor parse node 1115 * CurrentByteOffset - Offset into the resource template AML 1116 * buffer (to track references to the desc) 1117 * 1118 * RETURN: Completed resource node 1119 * 1120 * DESCRIPTION: Construct a short "VendorShort" descriptor 1121 * 1122 ******************************************************************************/ 1123 1124ASL_RESOURCE_NODE * 1125RsDoVendorSmallDescriptor ( 1126 ACPI_PARSE_OBJECT *Op, 1127 UINT32 CurrentByteOffset) 1128{ 1129 AML_RESOURCE *Descriptor; 1130 ACPI_PARSE_OBJECT *InitializerOp; 1131 ASL_RESOURCE_NODE *Rnode; 1132 UINT8 *VendorData; 1133 UINT32 i; 1134 1135 1136 InitializerOp = Op->Asl.Child; 1137 1138 /* Allocate worst case - 7 vendor bytes */ 1139 1140 Rnode = RsAllocateResourceNode (sizeof (AML_RESOURCE_VENDOR_SMALL) + 7); 1141 1142 Descriptor = Rnode->Buffer; 1143 Descriptor->VendorSmall.DescriptorType = ACPI_RESOURCE_NAME_VENDOR_SMALL; 1144 VendorData = ((UINT8 *) Descriptor) + sizeof (AML_RESOURCE_SMALL_HEADER); 1145 1146 /* Process all child initialization nodes */ 1147 1148 InitializerOp = RsCompleteNodeAndGetNext (InitializerOp); 1149 for (i = 0; InitializerOp; i++) 1150 { 1151 if (InitializerOp->Asl.ParseOpcode == PARSEOP_DEFAULT_ARG) 1152 { 1153 break; 1154 } 1155 1156 /* Maximum 7 vendor data bytes allowed (0-6) */ 1157 1158 if (i >= 7) 1159 { 1160 AslError (ASL_ERROR, ASL_MSG_VENDOR_LIST, InitializerOp, NULL); 1161 1162 /* Eat the excess initializers */ 1163 1164 while (InitializerOp) 1165 { 1166 InitializerOp = RsCompleteNodeAndGetNext (InitializerOp); 1167 } 1168 break; 1169 } 1170 1171 VendorData[i] = (UINT8) InitializerOp->Asl.Value.Integer; 1172 InitializerOp = RsCompleteNodeAndGetNext (InitializerOp); 1173 } 1174 1175 /* Adjust the Rnode buffer size, so correct number of bytes are emitted */ 1176 1177 Rnode->BufferLength -= (7 - i); 1178 1179 /* Set the length in the Type Tag */ 1180 1181 Descriptor->VendorSmall.DescriptorType |= (UINT8) i; 1182 return (Rnode); 1183} 1184 1185 1186