rsmisc.c revision 77424
1/******************************************************************************* 2 * 3 * Module Name: rsmisc - Miscellaneous resource descriptors 4 * $Revision: 15 $ 5 * 6 ******************************************************************************/ 7 8/****************************************************************************** 9 * 10 * 1. Copyright Notice 11 * 12 * Some or all of this work - Copyright (c) 1999, 2000, 2001, 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#define __RSMISC_C__ 118 119#include "acpi.h" 120#include "acresrc.h" 121 122#define _COMPONENT ACPI_RESOURCES 123 MODULE_NAME ("rsmisc") 124 125 126/******************************************************************************* 127 * 128 * FUNCTION: AcpiRsEndTagResource 129 * 130 * PARAMETERS: ByteStreamBuffer - Pointer to the resource input byte 131 * stream 132 * BytesConsumed - UINT32 pointer that is filled with 133 * the number of bytes consumed from 134 * the ByteStreamBuffer 135 * OutputBuffer - Pointer to the user's return buffer 136 * StructureSize - UINT32 pointer that is filled with 137 * the number of bytes in the filled 138 * in structure 139 * 140 * RETURN: Status 141 * 142 * DESCRIPTION: Take the resource byte stream and fill out the appropriate 143 * structure pointed to by the OutputBuffer. Return the 144 * number of bytes consumed from the byte stream. 145 * 146 ******************************************************************************/ 147 148ACPI_STATUS 149AcpiRsEndTagResource ( 150 UINT8 *ByteStreamBuffer, 151 UINT32 *BytesConsumed, 152 UINT8 **OutputBuffer, 153 UINT32 *StructureSize) 154{ 155 ACPI_RESOURCE *OutputStruct = (ACPI_RESOURCE *) *OutputBuffer; 156 UINT32 StructSize = ACPI_RESOURCE_LENGTH; 157 158 159 FUNCTION_TRACE ("RsEndTagResource"); 160 161 162 /* 163 * The number of bytes consumed is static 164 */ 165 *BytesConsumed = 2; 166 167 /* 168 * Fill out the structure 169 */ 170 OutputStruct->Id = ACPI_RSTYPE_END_TAG; 171 172 /* 173 * Set the Length parameter 174 */ 175 OutputStruct->Length = 0; 176 177 /* 178 * Return the final size of the structure 179 */ 180 *StructureSize = StructSize; 181 return_ACPI_STATUS (AE_OK); 182} 183 184 185/******************************************************************************* 186 * 187 * FUNCTION: AcpiRsEndTagStream 188 * 189 * PARAMETERS: LinkedList - Pointer to the resource linked list 190 * OutputBuffer - Pointer to the user's return buffer 191 * BytesConsumed - UINT32 pointer that is filled with 192 * the number of bytes of the 193 * OutputBuffer used 194 * 195 * RETURN: Status 196 * 197 * DESCRIPTION: Take the linked list resource structure and fills in the 198 * the appropriate bytes in a byte stream 199 * 200 ******************************************************************************/ 201 202ACPI_STATUS 203AcpiRsEndTagStream ( 204 ACPI_RESOURCE *LinkedList, 205 UINT8 **OutputBuffer, 206 UINT32 *BytesConsumed) 207{ 208 UINT8 *Buffer = *OutputBuffer; 209 UINT8 Temp8 = 0; 210 211 212 FUNCTION_TRACE ("RsEndTagStream"); 213 214 215 /* 216 * The descriptor field is static 217 */ 218 *Buffer = 0x79; 219 Buffer += 1; 220 221 /* 222 * Set the Checksum - zero means that the resource data is treated as if 223 * the checksum operation succeeded (ACPI Spec 1.0b Section 6.4.2.8) 224 */ 225 Temp8 = 0; 226 227 *Buffer = Temp8; 228 Buffer += 1; 229 230 /* 231 * Return the number of bytes consumed in this operation 232 */ 233 *BytesConsumed = POINTER_DIFF (Buffer, *OutputBuffer); 234 return_ACPI_STATUS (AE_OK); 235} 236 237 238/******************************************************************************* 239 * 240 * FUNCTION: AcpiRsVendorResource 241 * 242 * PARAMETERS: ByteStreamBuffer - Pointer to the resource input byte 243 * stream 244 * BytesConsumed - UINT32 pointer that is filled with 245 * the number of bytes consumed from 246 * the ByteStreamBuffer 247 * OutputBuffer - Pointer to the user's return buffer 248 * StructureSize - UINT32 pointer that is filled with 249 * the number of bytes in the filled 250 * in structure 251 * 252 * RETURN: Status 253 * 254 * DESCRIPTION: Take the resource byte stream and fill out the appropriate 255 * structure pointed to by the OutputBuffer. Return the 256 * number of bytes consumed from the byte stream. 257 * 258 ******************************************************************************/ 259 260ACPI_STATUS 261AcpiRsVendorResource ( 262 UINT8 *ByteStreamBuffer, 263 UINT32 *BytesConsumed, 264 UINT8 **OutputBuffer, 265 UINT32 *StructureSize) 266{ 267 UINT8 *Buffer = ByteStreamBuffer; 268 ACPI_RESOURCE *OutputStruct = (ACPI_RESOURCE *) *OutputBuffer; 269 UINT16 Temp16 = 0; 270 UINT8 Temp8 = 0; 271 UINT8 Index; 272 UINT32 StructSize = SIZEOF_RESOURCE (ACPI_RESOURCE_VENDOR); 273 274 275 FUNCTION_TRACE ("RsVendorResource"); 276 277 278 /* 279 * Dereference the Descriptor to find if this is a large or small item. 280 */ 281 Temp8 = *Buffer; 282 283 if (Temp8 & 0x80) 284 { 285 /* 286 * Large Item 287 * Point to the length field 288 */ 289 Buffer += 1; 290 291 /* Dereference */ 292 293 MOVE_UNALIGNED16_TO_16 (&Temp16, Buffer); 294 295 /* Calculate bytes consumed */ 296 297 *BytesConsumed = Temp16 + 3; 298 299 /* Point to the first vendor byte */ 300 301 Buffer += 2; 302 } 303 304 else 305 { 306 /* 307 * Small Item 308 * Dereference the size 309 */ 310 Temp16 = (UINT8)(*Buffer & 0x07); 311 312 /* Calculate bytes consumed */ 313 314 *BytesConsumed = Temp16 + 1; 315 316 /* Point to the first vendor byte */ 317 318 Buffer += 1; 319 } 320 321 OutputStruct->Id = ACPI_RSTYPE_VENDOR; 322 OutputStruct->Data.VendorSpecific.Length = Temp16; 323 324 for (Index = 0; Index < Temp16; Index++) 325 { 326 OutputStruct->Data.VendorSpecific.Reserved[Index] = *Buffer; 327 Buffer += 1; 328 } 329 330 /* 331 * In order for the StructSize to fall on a 32-bit boundary, 332 * calculate the length of the vendor string and expand the 333 * StructSize to the next 32-bit boundary. 334 */ 335 StructSize += ROUND_UP_TO_32BITS (Temp16); 336 337 /* 338 * Set the Length parameter 339 */ 340 OutputStruct->Length = StructSize; 341 342 /* 343 * Return the final size of the structure 344 */ 345 *StructureSize = StructSize; 346 return_ACPI_STATUS (AE_OK); 347} 348 349 350/******************************************************************************* 351 * 352 * FUNCTION: AcpiRsVendorStream 353 * 354 * PARAMETERS: LinkedList - Pointer to the resource linked list 355 * OutputBuffer - Pointer to the user's return buffer 356 * BytesConsumed - UINT32 pointer that is filled with 357 * the number of bytes of the 358 * OutputBuffer used 359 * 360 * RETURN: Status 361 * 362 * DESCRIPTION: Take the linked list resource structure and fills in the 363 * the appropriate bytes in a byte stream 364 * 365 ******************************************************************************/ 366 367ACPI_STATUS 368AcpiRsVendorStream ( 369 ACPI_RESOURCE *LinkedList, 370 UINT8 **OutputBuffer, 371 UINT32 *BytesConsumed) 372{ 373 UINT8 *Buffer = *OutputBuffer; 374 UINT16 Temp16 = 0; 375 UINT8 Temp8 = 0; 376 UINT8 Index; 377 378 379 FUNCTION_TRACE ("RsVendorStream"); 380 381 382 /* 383 * Dereference the length to find if this is a large or small item. 384 */ 385 if(LinkedList->Data.VendorSpecific.Length > 7) 386 { 387 /* 388 * Large Item 389 * Set the descriptor field and length bytes 390 */ 391 *Buffer = 0x84; 392 Buffer += 1; 393 394 Temp16 = (UINT16) LinkedList->Data.VendorSpecific.Length; 395 396 MOVE_UNALIGNED16_TO_16 (Buffer, &Temp16); 397 Buffer += 2; 398 } 399 400 else 401 { 402 /* 403 * Small Item 404 * Set the descriptor field 405 */ 406 Temp8 = 0x70; 407 Temp8 |= LinkedList->Data.VendorSpecific.Length; 408 409 *Buffer = Temp8; 410 Buffer += 1; 411 } 412 413 /* 414 * Loop through all of the Vendor Specific fields 415 */ 416 for (Index = 0; Index < LinkedList->Data.VendorSpecific.Length; Index++) 417 { 418 Temp8 = LinkedList->Data.VendorSpecific.Reserved[Index]; 419 420 *Buffer = Temp8; 421 Buffer += 1; 422 } 423 424 /* 425 * Return the number of bytes consumed in this operation 426 */ 427 *BytesConsumed = POINTER_DIFF (Buffer, *OutputBuffer); 428 return_ACPI_STATUS (AE_OK); 429} 430 431 432/******************************************************************************* 433 * 434 * FUNCTION: AcpiRsStartDependentFunctionsResource 435 * 436 * PARAMETERS: ByteStreamBuffer - Pointer to the resource input byte 437 * stream 438 * BytesConsumed - UINT32 pointer that is filled with 439 * the number of bytes consumed from 440 * the ByteStreamBuffer 441 * OutputBuffer - Pointer to the user's return buffer 442 * StructureSize - UINT32 pointer that is filled with 443 * the number of bytes in the filled 444 * in structure 445 * 446 * RETURN: Status 447 * 448 * DESCRIPTION: Take the resource byte stream and fill out the appropriate 449 * structure pointed to by the OutputBuffer. Return the 450 * number of bytes consumed from the byte stream. 451 * 452 ******************************************************************************/ 453 454ACPI_STATUS 455AcpiRsStartDependentFunctionsResource ( 456 UINT8 *ByteStreamBuffer, 457 UINT32 *BytesConsumed, 458 UINT8 **OutputBuffer, 459 UINT32 *StructureSize) 460{ 461 UINT8 *Buffer = ByteStreamBuffer; 462 ACPI_RESOURCE *OutputStruct = (ACPI_RESOURCE *) *OutputBuffer; 463 UINT8 Temp8 = 0; 464 UINT32 StructSize = SIZEOF_RESOURCE (ACPI_RESOURCE_START_DPF); 465 466 467 FUNCTION_TRACE ("RsStartDependentFunctionsResource"); 468 469 470 /* 471 * The number of bytes consumed are contained in the descriptor (Bits:0-1) 472 */ 473 Temp8 = *Buffer; 474 475 *BytesConsumed = (Temp8 & 0x01) + 1; 476 477 OutputStruct->Id = ACPI_RSTYPE_START_DPF; 478 479 /* 480 * Point to Byte 1 if it is used 481 */ 482 if (2 == *BytesConsumed) 483 { 484 Buffer += 1; 485 Temp8 = *Buffer; 486 487 /* 488 * Check Compatibility priority 489 */ 490 OutputStruct->Data.StartDpf.CompatibilityPriority = Temp8 & 0x03; 491 492 if (3 == OutputStruct->Data.StartDpf.CompatibilityPriority) 493 { 494 return_ACPI_STATUS (AE_AML_ERROR); 495 } 496 497 /* 498 * Check Performance/Robustness preference 499 */ 500 OutputStruct->Data.StartDpf.PerformanceRobustness = (Temp8 >> 2) & 0x03; 501 502 if (3 == OutputStruct->Data.StartDpf.PerformanceRobustness) 503 { 504 return_ACPI_STATUS (AE_AML_ERROR); 505 } 506 } 507 508 else 509 { 510 OutputStruct->Data.StartDpf.CompatibilityPriority = 511 ACCEPTABLE_CONFIGURATION; 512 513 OutputStruct->Data.StartDpf.PerformanceRobustness = 514 ACCEPTABLE_CONFIGURATION; 515 } 516 517 /* 518 * Set the Length parameter 519 */ 520 OutputStruct->Length = StructSize; 521 522 /* 523 * Return the final size of the structure 524 */ 525 *StructureSize = StructSize; 526 return_ACPI_STATUS (AE_OK); 527} 528 529 530/******************************************************************************* 531 * 532 * FUNCTION: AcpiRsEndDependentFunctionsResource 533 * 534 * PARAMETERS: ByteStreamBuffer - Pointer to the resource input byte 535 * stream 536 * BytesConsumed - UINT32 pointer that is filled with 537 * the number of bytes consumed from 538 * the ByteStreamBuffer 539 * OutputBuffer - Pointer to the user's return buffer 540 * StructureSize - UINT32 pointer that is filled with 541 * the number of bytes in the filled 542 * in structure 543 * 544 * RETURN: Status 545 * 546 * DESCRIPTION: Take the resource byte stream and fill out the appropriate 547 * structure pointed to by the OutputBuffer. Return the 548 * number of bytes consumed from the byte stream. 549 * 550 ******************************************************************************/ 551 552ACPI_STATUS 553AcpiRsEndDependentFunctionsResource ( 554 UINT8 *ByteStreamBuffer, 555 UINT32 *BytesConsumed, 556 UINT8 **OutputBuffer, 557 UINT32 *StructureSize) 558{ 559 ACPI_RESOURCE *OutputStruct = (ACPI_RESOURCE *) *OutputBuffer; 560 UINT32 StructSize = ACPI_RESOURCE_LENGTH; 561 562 563 FUNCTION_TRACE ("RsEndDependentFunctionsResource"); 564 565 566 /* 567 * The number of bytes consumed is static 568 */ 569 *BytesConsumed = 1; 570 571 /* 572 * Fill out the structure 573 */ 574 OutputStruct->Id = ACPI_RSTYPE_END_DPF; 575 576 /* 577 * Set the Length parameter 578 */ 579 OutputStruct->Length = StructSize; 580 581 /* 582 * Return the final size of the structure 583 */ 584 *StructureSize = StructSize; 585 return_ACPI_STATUS (AE_OK); 586} 587 588 589/******************************************************************************* 590 * 591 * FUNCTION: AcpiRsStartDependentFunctionsStream 592 * 593 * PARAMETERS: LinkedList - Pointer to the resource linked list 594 * OutputBuffer - Pointer to the user's return buffer 595 * BytesConsumed - UINT32 pointer that is filled with 596 * the number of bytes of the 597 * OutputBuffer used 598 * 599 * RETURN: Status 600 * 601 * DESCRIPTION: Take the linked list resource structure and fills in the 602 * the appropriate bytes in a byte stream 603 * 604 ******************************************************************************/ 605 606ACPI_STATUS 607AcpiRsStartDependentFunctionsStream ( 608 ACPI_RESOURCE *LinkedList, 609 UINT8 **OutputBuffer, 610 UINT32 *BytesConsumed) 611{ 612 UINT8 *Buffer = *OutputBuffer; 613 UINT8 Temp8 = 0; 614 615 616 FUNCTION_TRACE ("RsStartDependentFunctionsStream"); 617 618 619 /* 620 * The descriptor field is set based upon whether a byte is needed 621 * to contain Priority data. 622 */ 623 if (ACCEPTABLE_CONFIGURATION == 624 LinkedList->Data.StartDpf.CompatibilityPriority && 625 ACCEPTABLE_CONFIGURATION == 626 LinkedList->Data.StartDpf.PerformanceRobustness) 627 { 628 *Buffer = 0x30; 629 } 630 else 631 { 632 *Buffer = 0x31; 633 Buffer += 1; 634 635 /* 636 * Set the Priority Byte Definition 637 */ 638 Temp8 = 0; 639 Temp8 = (UINT8) ((LinkedList->Data.StartDpf.PerformanceRobustness & 640 0x03) << 2); 641 Temp8 |= (LinkedList->Data.StartDpf.CompatibilityPriority & 642 0x03); 643 *Buffer = Temp8; 644 } 645 646 Buffer += 1; 647 648 /* 649 * Return the number of bytes consumed in this operation 650 */ 651 *BytesConsumed = POINTER_DIFF (Buffer, *OutputBuffer); 652 return_ACPI_STATUS (AE_OK); 653} 654 655 656/******************************************************************************* 657 * 658 * FUNCTION: AcpiRsEndDependentFunctionsStream 659 * 660 * PARAMETERS: LinkedList - Pointer to the resource linked list 661 * OutputBuffer - Pointer to the user's return buffer 662 * BytesConsumed - UINT32 pointer that is filled with 663 * the number of bytes of the 664 * OutputBuffer used 665 * 666 * RETURN: Status 667 * 668 * DESCRIPTION: Take the linked list resource structure and fills in the 669 * the appropriate bytes in a byte stream 670 * 671 ******************************************************************************/ 672 673ACPI_STATUS 674AcpiRsEndDependentFunctionsStream ( 675 ACPI_RESOURCE *LinkedList, 676 UINT8 **OutputBuffer, 677 UINT32 *BytesConsumed 678 ) 679{ 680 UINT8 *Buffer = *OutputBuffer; 681 682 683 FUNCTION_TRACE ("RsEndDependentFunctionsStream"); 684 685 686 /* 687 * The descriptor field is static 688 */ 689 *Buffer = 0x38; 690 Buffer += 1; 691 692 /* 693 * Return the number of bytes consumed in this operation 694 */ 695 *BytesConsumed = POINTER_DIFF (Buffer, *OutputBuffer); 696 return_ACPI_STATUS (AE_OK); 697} 698 699