aslrestype1.c revision 229989
1 2/****************************************************************************** 3 * 4 * Module Name: aslrestype1 - Miscellaneous small resource descriptors 5 * 6 *****************************************************************************/ 7 8/* 9 * Copyright (C) 2000 - 2012, Intel Corp. 10 * All rights reserved. 11 * 12 * Redistribution and use in source and binary forms, with or without 13 * modification, are permitted provided that the following conditions 14 * are met: 15 * 1. Redistributions of source code must retain the above copyright 16 * notice, this list of conditions, and the following disclaimer, 17 * without modification. 18 * 2. Redistributions in binary form must reproduce at minimum a disclaimer 19 * substantially similar to the "NO WARRANTY" disclaimer below 20 * ("Disclaimer") and any redistribution must be conditioned upon 21 * including a substantially similar Disclaimer requirement for further 22 * binary redistribution. 23 * 3. Neither the names of the above-listed copyright holders nor the names 24 * of any contributors may be used to endorse or promote products derived 25 * from this software without specific prior written permission. 26 * 27 * Alternatively, this software may be distributed under the terms of the 28 * GNU General Public License ("GPL") version 2 as published by the Free 29 * Software Foundation. 30 * 31 * NO WARRANTY 32 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 33 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 34 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR 35 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 36 * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 37 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 38 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 39 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 40 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 41 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 42 * POSSIBILITY OF SUCH DAMAGES. 43 */ 44 45 46#include <contrib/dev/acpica/compiler/aslcompiler.h> 47#include "aslcompiler.y.h" 48 49#define _COMPONENT ACPI_COMPILER 50 ACPI_MODULE_NAME ("aslrestype1") 51 52/* 53 * This module contains miscellaneous small resource descriptors: 54 * 55 * EndTag 56 * EndDependentFn 57 * Memory24 58 * Memory32 59 * Memory32Fixed 60 * StartDependentFn 61 * StartDependentFnNoPri 62 * VendorShort 63 */ 64 65/******************************************************************************* 66 * 67 * FUNCTION: RsDoEndTagDescriptor 68 * 69 * PARAMETERS: Op - Parent resource descriptor parse node 70 * CurrentByteOffset - Offset into the resource template AML 71 * buffer (to track references to the desc) 72 * 73 * RETURN: Completed resource node 74 * 75 * DESCRIPTION: Construct a short "EndDependentFn" descriptor 76 * 77 ******************************************************************************/ 78 79ASL_RESOURCE_NODE * 80RsDoEndTagDescriptor ( 81 ACPI_PARSE_OBJECT *Op, 82 UINT32 CurrentByteOffset) 83{ 84 AML_RESOURCE *Descriptor; 85 ASL_RESOURCE_NODE *Rnode; 86 87 88 Rnode = RsAllocateResourceNode (sizeof (AML_RESOURCE_END_TAG)); 89 90 Descriptor = Rnode->Buffer; 91 Descriptor->EndTag.DescriptorType = ACPI_RESOURCE_NAME_END_TAG | 92 ASL_RDESC_END_TAG_SIZE; 93 Descriptor->EndTag.Checksum = 0; 94 95 return (Rnode); 96} 97 98 99/******************************************************************************* 100 * 101 * FUNCTION: RsDoEndDependentDescriptor 102 * 103 * PARAMETERS: Op - Parent resource descriptor parse node 104 * CurrentByteOffset - Offset into the resource template AML 105 * buffer (to track references to the desc) 106 * 107 * RETURN: Completed resource node 108 * 109 * DESCRIPTION: Construct a short "EndDependentFn" descriptor 110 * 111 ******************************************************************************/ 112 113ASL_RESOURCE_NODE * 114RsDoEndDependentDescriptor ( 115 ACPI_PARSE_OBJECT *Op, 116 UINT32 CurrentByteOffset) 117{ 118 AML_RESOURCE *Descriptor; 119 ASL_RESOURCE_NODE *Rnode; 120 121 122 Rnode = RsAllocateResourceNode (sizeof (AML_RESOURCE_END_DEPENDENT)); 123 124 Descriptor = Rnode->Buffer; 125 Descriptor->EndDpf.DescriptorType = ACPI_RESOURCE_NAME_END_DEPENDENT | 126 ASL_RDESC_END_DEPEND_SIZE; 127 return (Rnode); 128} 129 130 131/******************************************************************************* 132 * 133 * FUNCTION: RsDoMemory24Descriptor 134 * 135 * PARAMETERS: Op - Parent resource descriptor parse node 136 * CurrentByteOffset - Offset into the resource template AML 137 * buffer (to track references to the desc) 138 * 139 * RETURN: Completed resource node 140 * 141 * DESCRIPTION: Construct a short "Memory24" descriptor 142 * 143 ******************************************************************************/ 144 145ASL_RESOURCE_NODE * 146RsDoMemory24Descriptor ( 147 ACPI_PARSE_OBJECT *Op, 148 UINT32 CurrentByteOffset) 149{ 150 AML_RESOURCE *Descriptor; 151 ACPI_PARSE_OBJECT *InitializerOp; 152 ACPI_PARSE_OBJECT *MinOp = NULL; 153 ACPI_PARSE_OBJECT *MaxOp = NULL; 154 ACPI_PARSE_OBJECT *LengthOp = NULL; 155 ASL_RESOURCE_NODE *Rnode; 156 UINT32 i; 157 158 159 InitializerOp = Op->Asl.Child; 160 Rnode = RsAllocateResourceNode (sizeof (AML_RESOURCE_MEMORY24)); 161 162 Descriptor = Rnode->Buffer; 163 Descriptor->Memory24.DescriptorType = ACPI_RESOURCE_NAME_MEMORY24; 164 Descriptor->Memory24.ResourceLength = 9; 165 166 /* Process all child initialization nodes */ 167 168 for (i = 0; InitializerOp; i++) 169 { 170 switch (i) 171 { 172 case 0: /* Read/Write type */ 173 174 RsSetFlagBits (&Descriptor->Memory24.Flags, InitializerOp, 0, 1); 175 RsCreateBitField (InitializerOp, ACPI_RESTAG_READWRITETYPE, 176 CurrentByteOffset + ASL_RESDESC_OFFSET (Memory24.Flags), 0); 177 break; 178 179 case 1: /* Min Address */ 180 181 Descriptor->Memory24.Minimum = (UINT16) InitializerOp->Asl.Value.Integer; 182 RsCreateWordField (InitializerOp, ACPI_RESTAG_MINADDR, 183 CurrentByteOffset + ASL_RESDESC_OFFSET (Memory24.Minimum)); 184 MinOp = InitializerOp; 185 break; 186 187 case 2: /* Max Address */ 188 189 Descriptor->Memory24.Maximum = (UINT16) InitializerOp->Asl.Value.Integer; 190 RsCreateWordField (InitializerOp, ACPI_RESTAG_MAXADDR, 191 CurrentByteOffset + ASL_RESDESC_OFFSET (Memory24.Maximum)); 192 MaxOp = InitializerOp; 193 break; 194 195 case 3: /* Alignment */ 196 197 Descriptor->Memory24.Alignment = (UINT16) InitializerOp->Asl.Value.Integer; 198 RsCreateWordField (InitializerOp, ACPI_RESTAG_ALIGNMENT, 199 CurrentByteOffset + ASL_RESDESC_OFFSET (Memory24.Alignment)); 200 break; 201 202 case 4: /* Length */ 203 204 Descriptor->Memory24.AddressLength = (UINT16) InitializerOp->Asl.Value.Integer; 205 RsCreateWordField (InitializerOp, ACPI_RESTAG_LENGTH, 206 CurrentByteOffset + ASL_RESDESC_OFFSET (Memory24.AddressLength)); 207 LengthOp = InitializerOp; 208 break; 209 210 case 5: /* Name */ 211 212 UtAttachNamepathToOwner (Op, InitializerOp); 213 break; 214 215 default: 216 217 AslError (ASL_ERROR, ASL_MSG_RESOURCE_LIST, InitializerOp, NULL); 218 break; 219 } 220 221 InitializerOp = RsCompleteNodeAndGetNext (InitializerOp); 222 } 223 224 /* Validate the Min/Max/Len/Align values (Alignment==0 means 64K) */ 225 226 RsSmallAddressCheck (ACPI_RESOURCE_NAME_MEMORY24, 227 Descriptor->Memory24.Minimum, 228 Descriptor->Memory24.Maximum, 229 Descriptor->Memory24.AddressLength, 230 Descriptor->Memory24.Alignment, 231 MinOp, MaxOp, LengthOp, NULL, Op); 232 233 return (Rnode); 234} 235 236 237/******************************************************************************* 238 * 239 * FUNCTION: RsDoMemory32Descriptor 240 * 241 * PARAMETERS: Op - Parent resource descriptor parse node 242 * CurrentByteOffset - Offset into the resource template AML 243 * buffer (to track references to the desc) 244 * 245 * RETURN: Completed resource node 246 * 247 * DESCRIPTION: Construct a short "Memory32" descriptor 248 * 249 ******************************************************************************/ 250 251ASL_RESOURCE_NODE * 252RsDoMemory32Descriptor ( 253 ACPI_PARSE_OBJECT *Op, 254 UINT32 CurrentByteOffset) 255{ 256 AML_RESOURCE *Descriptor; 257 ACPI_PARSE_OBJECT *InitializerOp; 258 ACPI_PARSE_OBJECT *MinOp = NULL; 259 ACPI_PARSE_OBJECT *MaxOp = NULL; 260 ACPI_PARSE_OBJECT *LengthOp = NULL; 261 ACPI_PARSE_OBJECT *AlignOp = NULL; 262 ASL_RESOURCE_NODE *Rnode; 263 UINT32 i; 264 265 266 InitializerOp = Op->Asl.Child; 267 Rnode = RsAllocateResourceNode (sizeof (AML_RESOURCE_MEMORY32)); 268 269 Descriptor = Rnode->Buffer; 270 Descriptor->Memory32.DescriptorType = ACPI_RESOURCE_NAME_MEMORY32; 271 Descriptor->Memory32.ResourceLength = 17; 272 273 /* Process all child initialization nodes */ 274 275 for (i = 0; InitializerOp; i++) 276 { 277 switch (i) 278 { 279 case 0: /* Read/Write type */ 280 281 RsSetFlagBits (&Descriptor->Memory32.Flags, InitializerOp, 0, 1); 282 RsCreateBitField (InitializerOp, ACPI_RESTAG_READWRITETYPE, 283 CurrentByteOffset + ASL_RESDESC_OFFSET (Memory32.Flags), 0); 284 break; 285 286 case 1: /* Min Address */ 287 288 Descriptor->Memory32.Minimum = (UINT32) InitializerOp->Asl.Value.Integer; 289 RsCreateDwordField (InitializerOp, ACPI_RESTAG_MINADDR, 290 CurrentByteOffset + ASL_RESDESC_OFFSET (Memory32.Minimum)); 291 MinOp = InitializerOp; 292 break; 293 294 case 2: /* Max Address */ 295 296 Descriptor->Memory32.Maximum = (UINT32) InitializerOp->Asl.Value.Integer; 297 RsCreateDwordField (InitializerOp, ACPI_RESTAG_MAXADDR, 298 CurrentByteOffset + ASL_RESDESC_OFFSET (Memory32.Maximum)); 299 MaxOp = InitializerOp; 300 break; 301 302 case 3: /* Alignment */ 303 304 Descriptor->Memory32.Alignment = (UINT32) InitializerOp->Asl.Value.Integer; 305 RsCreateDwordField (InitializerOp, ACPI_RESTAG_ALIGNMENT, 306 CurrentByteOffset + ASL_RESDESC_OFFSET (Memory32.Alignment)); 307 AlignOp = InitializerOp; 308 break; 309 310 case 4: /* Length */ 311 312 Descriptor->Memory32.AddressLength = (UINT32) InitializerOp->Asl.Value.Integer; 313 RsCreateDwordField (InitializerOp, ACPI_RESTAG_LENGTH, 314 CurrentByteOffset + ASL_RESDESC_OFFSET (Memory32.AddressLength)); 315 LengthOp = InitializerOp; 316 break; 317 318 case 5: /* Name */ 319 320 UtAttachNamepathToOwner (Op, InitializerOp); 321 break; 322 323 default: 324 325 AslError (ASL_ERROR, ASL_MSG_RESOURCE_LIST, InitializerOp, NULL); 326 break; 327 } 328 329 InitializerOp = RsCompleteNodeAndGetNext (InitializerOp); 330 } 331 332 /* Validate the Min/Max/Len/Align values */ 333 334 RsSmallAddressCheck (ACPI_RESOURCE_NAME_MEMORY32, 335 Descriptor->Memory32.Minimum, 336 Descriptor->Memory32.Maximum, 337 Descriptor->Memory32.AddressLength, 338 Descriptor->Memory32.Alignment, 339 MinOp, MaxOp, LengthOp, AlignOp, Op); 340 341 return (Rnode); 342} 343 344 345/******************************************************************************* 346 * 347 * FUNCTION: RsDoMemory32FixedDescriptor 348 * 349 * PARAMETERS: Op - Parent resource descriptor parse node 350 * CurrentByteOffset - Offset into the resource template AML 351 * buffer (to track references to the desc) 352 * 353 * RETURN: Completed resource node 354 * 355 * DESCRIPTION: Construct a short "Memory32Fixed" descriptor 356 * 357 ******************************************************************************/ 358 359ASL_RESOURCE_NODE * 360RsDoMemory32FixedDescriptor ( 361 ACPI_PARSE_OBJECT *Op, 362 UINT32 CurrentByteOffset) 363{ 364 AML_RESOURCE *Descriptor; 365 ACPI_PARSE_OBJECT *InitializerOp; 366 ASL_RESOURCE_NODE *Rnode; 367 UINT32 i; 368 369 370 InitializerOp = Op->Asl.Child; 371 Rnode = RsAllocateResourceNode (sizeof (AML_RESOURCE_FIXED_MEMORY32)); 372 373 Descriptor = Rnode->Buffer; 374 Descriptor->FixedMemory32.DescriptorType = ACPI_RESOURCE_NAME_FIXED_MEMORY32; 375 Descriptor->FixedMemory32.ResourceLength = 9; 376 377 /* Process all child initialization nodes */ 378 379 for (i = 0; InitializerOp; i++) 380 { 381 switch (i) 382 { 383 case 0: /* Read/Write type */ 384 385 RsSetFlagBits (&Descriptor->FixedMemory32.Flags, InitializerOp, 0, 1); 386 RsCreateBitField (InitializerOp, ACPI_RESTAG_READWRITETYPE, 387 CurrentByteOffset + ASL_RESDESC_OFFSET (FixedMemory32.Flags), 0); 388 break; 389 390 case 1: /* Address */ 391 392 Descriptor->FixedMemory32.Address = (UINT32) InitializerOp->Asl.Value.Integer; 393 RsCreateDwordField (InitializerOp, ACPI_RESTAG_BASEADDRESS, 394 CurrentByteOffset + ASL_RESDESC_OFFSET (FixedMemory32.Address)); 395 break; 396 397 case 2: /* Length */ 398 399 Descriptor->FixedMemory32.AddressLength = (UINT32) InitializerOp->Asl.Value.Integer; 400 RsCreateDwordField (InitializerOp, ACPI_RESTAG_LENGTH, 401 CurrentByteOffset + ASL_RESDESC_OFFSET (FixedMemory32.AddressLength)); 402 break; 403 404 case 3: /* Name */ 405 406 UtAttachNamepathToOwner (Op, InitializerOp); 407 break; 408 409 default: 410 411 AslError (ASL_ERROR, ASL_MSG_RESOURCE_LIST, InitializerOp, NULL); 412 break; 413 } 414 415 InitializerOp = RsCompleteNodeAndGetNext (InitializerOp); 416 } 417 418 return (Rnode); 419} 420 421 422/******************************************************************************* 423 * 424 * FUNCTION: RsDoStartDependentDescriptor 425 * 426 * PARAMETERS: Op - Parent resource descriptor parse node 427 * CurrentByteOffset - Offset into the resource template AML 428 * buffer (to track references to the desc) 429 * 430 * RETURN: Completed resource node 431 * 432 * DESCRIPTION: Construct a short "StartDependentFn" descriptor 433 * 434 ******************************************************************************/ 435 436ASL_RESOURCE_NODE * 437RsDoStartDependentDescriptor ( 438 ACPI_PARSE_OBJECT *Op, 439 UINT32 CurrentByteOffset) 440{ 441 AML_RESOURCE *Descriptor; 442 ACPI_PARSE_OBJECT *InitializerOp; 443 ASL_RESOURCE_NODE *Rnode; 444 ASL_RESOURCE_NODE *PreviousRnode; 445 ASL_RESOURCE_NODE *NextRnode; 446 UINT32 i; 447 UINT8 State; 448 449 450 InitializerOp = Op->Asl.Child; 451 Rnode = RsAllocateResourceNode (sizeof (AML_RESOURCE_START_DEPENDENT)); 452 453 PreviousRnode = Rnode; 454 Descriptor = Rnode->Buffer; 455 456 /* Descriptor has priority byte */ 457 458 Descriptor->StartDpf.DescriptorType = ACPI_RESOURCE_NAME_START_DEPENDENT | 459 (ASL_RDESC_ST_DEPEND_SIZE + 0x01); 460 461 /* Process all child initialization nodes */ 462 463 State = ACPI_RSTATE_START_DEPENDENT; 464 for (i = 0; InitializerOp; i++) 465 { 466 switch (i) 467 { 468 case 0: /* Compatibility Priority */ 469 470 if ((UINT8) InitializerOp->Asl.Value.Integer > 2) 471 { 472 AslError (ASL_ERROR, ASL_MSG_INVALID_PRIORITY, 473 InitializerOp, NULL); 474 } 475 476 RsSetFlagBits (&Descriptor->StartDpf.Flags, InitializerOp, 0, 0); 477 break; 478 479 case 1: /* Performance/Robustness Priority */ 480 481 if ((UINT8) InitializerOp->Asl.Value.Integer > 2) 482 { 483 AslError (ASL_ERROR, ASL_MSG_INVALID_PERFORMANCE, 484 InitializerOp, NULL); 485 } 486 487 RsSetFlagBits (&Descriptor->StartDpf.Flags, InitializerOp, 2, 0); 488 break; 489 490 default: 491 492 NextRnode = RsDoOneResourceDescriptor (InitializerOp, 493 CurrentByteOffset, &State); 494 495 /* 496 * Update current byte offset to indicate the number of bytes from the 497 * start of the buffer. Buffer can include multiple descriptors, we 498 * must keep track of the offset of not only each descriptor, but each 499 * element (field) within each descriptor as well. 500 */ 501 CurrentByteOffset += RsLinkDescriptorChain (&PreviousRnode, 502 NextRnode); 503 break; 504 } 505 506 InitializerOp = RsCompleteNodeAndGetNext (InitializerOp); 507 } 508 509 return (Rnode); 510} 511 512 513/******************************************************************************* 514 * 515 * FUNCTION: RsDoStartDependentNoPriDescriptor 516 * 517 * PARAMETERS: Op - Parent resource descriptor parse node 518 * CurrentByteOffset - Offset into the resource template AML 519 * buffer (to track references to the desc) 520 * 521 * RETURN: Completed resource node 522 * 523 * DESCRIPTION: Construct a short "StartDependentNoPri" descriptor 524 * 525 ******************************************************************************/ 526 527ASL_RESOURCE_NODE * 528RsDoStartDependentNoPriDescriptor ( 529 ACPI_PARSE_OBJECT *Op, 530 UINT32 CurrentByteOffset) 531{ 532 AML_RESOURCE *Descriptor; 533 ACPI_PARSE_OBJECT *InitializerOp; 534 ASL_RESOURCE_NODE *Rnode; 535 ASL_RESOURCE_NODE *PreviousRnode; 536 ASL_RESOURCE_NODE *NextRnode; 537 UINT8 State; 538 539 540 InitializerOp = Op->Asl.Child; 541 Rnode = RsAllocateResourceNode (sizeof (AML_RESOURCE_START_DEPENDENT_NOPRIO)); 542 543 Descriptor = Rnode->Buffer; 544 Descriptor->StartDpf.DescriptorType = ACPI_RESOURCE_NAME_START_DEPENDENT | 545 ASL_RDESC_ST_DEPEND_SIZE; 546 PreviousRnode = Rnode; 547 548 /* Process all child initialization nodes */ 549 550 State = ACPI_RSTATE_START_DEPENDENT; 551 while (InitializerOp) 552 { 553 NextRnode = RsDoOneResourceDescriptor (InitializerOp, 554 CurrentByteOffset, &State); 555 556 /* 557 * Update current byte offset to indicate the number of bytes from the 558 * start of the buffer. Buffer can include multiple descriptors, we 559 * must keep track of the offset of not only each descriptor, but each 560 * element (field) within each descriptor as well. 561 */ 562 CurrentByteOffset += RsLinkDescriptorChain (&PreviousRnode, NextRnode); 563 564 InitializerOp = RsCompleteNodeAndGetNext (InitializerOp); 565 } 566 567 return (Rnode); 568} 569 570 571/******************************************************************************* 572 * 573 * FUNCTION: RsDoVendorSmallDescriptor 574 * 575 * PARAMETERS: Op - Parent resource descriptor parse node 576 * CurrentByteOffset - Offset into the resource template AML 577 * buffer (to track references to the desc) 578 * 579 * RETURN: Completed resource node 580 * 581 * DESCRIPTION: Construct a short "VendorShort" descriptor 582 * 583 ******************************************************************************/ 584 585ASL_RESOURCE_NODE * 586RsDoVendorSmallDescriptor ( 587 ACPI_PARSE_OBJECT *Op, 588 UINT32 CurrentByteOffset) 589{ 590 AML_RESOURCE *Descriptor; 591 ACPI_PARSE_OBJECT *InitializerOp; 592 ASL_RESOURCE_NODE *Rnode; 593 UINT8 *VendorData; 594 UINT32 i; 595 596 597 InitializerOp = Op->Asl.Child; 598 599 /* Allocate worst case - 7 vendor bytes */ 600 601 Rnode = RsAllocateResourceNode (sizeof (AML_RESOURCE_VENDOR_SMALL) + 7); 602 603 Descriptor = Rnode->Buffer; 604 Descriptor->VendorSmall.DescriptorType = ACPI_RESOURCE_NAME_VENDOR_SMALL; 605 VendorData = ((UINT8 *) Descriptor) + sizeof (AML_RESOURCE_SMALL_HEADER); 606 607 /* Process all child initialization nodes */ 608 609 InitializerOp = RsCompleteNodeAndGetNext (InitializerOp); 610 for (i = 0; InitializerOp; i++) 611 { 612 if (InitializerOp->Asl.ParseOpcode == PARSEOP_DEFAULT_ARG) 613 { 614 break; 615 } 616 617 /* Maximum 7 vendor data bytes allowed (0-6) */ 618 619 if (i >= 7) 620 { 621 AslError (ASL_ERROR, ASL_MSG_VENDOR_LIST, InitializerOp, NULL); 622 623 /* Eat the excess initializers */ 624 625 while (InitializerOp) 626 { 627 InitializerOp = RsCompleteNodeAndGetNext (InitializerOp); 628 } 629 break; 630 } 631 632 VendorData[i] = (UINT8) InitializerOp->Asl.Value.Integer; 633 InitializerOp = RsCompleteNodeAndGetNext (InitializerOp); 634 } 635 636 /* Adjust the Rnode buffer size, so correct number of bytes are emitted */ 637 638 Rnode->BufferLength -= (7 - i); 639 640 /* Set the length in the Type Tag */ 641 642 Descriptor->VendorSmall.DescriptorType |= (UINT8) i; 643 return (Rnode); 644} 645 646