19 * 20 * 2. License 21 * 22 * 2.1. This is your license from Intel Corp. under its intellectual property 23 * rights. You may have additional license terms from the party that provided 24 * you this software, covering your right to use that party's intellectual 25 * property rights. 26 * 27 * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a 28 * copy of the source code appearing in this file ("Covered Code") an 29 * irrevocable, perpetual, worldwide license under Intel's copyrights in the 30 * base code distributed originally by Intel ("Original Intel Code") to copy, 31 * make derivatives, distribute, use and display any portion of the Covered 32 * Code in any form, with the right to sublicense such rights; and 33 * 34 * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent 35 * license (with the right to sublicense), under only those claims of Intel 36 * patents that are infringed by the Original Intel Code, to make, use, sell, 37 * offer to sell, and import the Covered Code and derivative works thereof 38 * solely to the minimum extent necessary to exercise the above copyright 39 * license, and in no event shall the patent license extend to any additions 40 * to or modifications of the Original Intel Code. No other license or right 41 * is granted directly or by implication, estoppel or otherwise; 42 * 43 * The above copyright and patent license is granted only if the following 44 * conditions are met: 45 * 46 * 3. Conditions 47 * 48 * 3.1. Redistribution of Source with Rights to Further Distribute Source. 49 * Redistribution of source code of any substantial portion of the Covered 50 * Code or modification with rights to further distribute source must include 51 * the above Copyright Notice, the above License, this list of Conditions, 52 * and the following Disclaimer and Export Compliance provision. In addition, 53 * Licensee must cause all Covered Code to which Licensee contributes to 54 * contain a file documenting the changes Licensee made to create that Covered 55 * Code and the date of any change. Licensee must include in that file the 56 * documentation of any changes made by any predecessor Licensee. Licensee 57 * must include a prominent statement that the modification is derived, 58 * directly or indirectly, from Original Intel Code. 59 * 60 * 3.2. Redistribution of Source with no Rights to Further Distribute Source. 61 * Redistribution of source code of any substantial portion of the Covered 62 * Code or modification without rights to further distribute source must 63 * include the following Disclaimer and Export Compliance provision in the 64 * documentation and/or other materials provided with distribution. In 65 * addition, Licensee may not authorize further sublicense of source of any 66 * portion of the Covered Code, and must include terms to the effect that the 67 * license from Licensee to its licensee is limited to the intellectual 68 * property embodied in the software Licensee provides to its licensee, and 69 * not to intellectual property embodied in modifications its licensee may 70 * make. 71 * 72 * 3.3. Redistribution of Executable. Redistribution in executable form of any 73 * substantial portion of the Covered Code or modification must reproduce the 74 * above Copyright Notice, and the following Disclaimer and Export Compliance 75 * provision in the documentation and/or other materials provided with the 76 * distribution. 77 * 78 * 3.4. Intel retains all right, title, and interest in and to the Original 79 * Intel Code. 80 * 81 * 3.5. Neither the name Intel nor any other trademark owned or controlled by 82 * Intel shall be used in advertising or otherwise to promote the sale, use or 83 * other dealings in products derived from or relating to the Covered Code 84 * without prior written authorization from Intel. 85 * 86 * 4. Disclaimer and Export Compliance 87 * 88 * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED 89 * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE 90 * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, 91 * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY 92 * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY 93 * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A 94 * PARTICULAR PURPOSE. 95 * 96 * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES 97 * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR 98 * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, 99 * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY 100 * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL 101 * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS 102 * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY 103 * LIMITED REMEDY. 104 * 105 * 4.3. Licensee shall not export, either directly or indirectly, any of this 106 * software or system incorporating such software without first obtaining any 107 * required license or other approval from the U. S. Department of Commerce or 108 * any other agency or department of the United States Government. In the 109 * event Licensee exports any such software from the United States or 110 * re-exports any such software from a foreign destination, Licensee shall 111 * ensure that the distribution and export/re-export of the software is in 112 * compliance with all laws, regulations, orders, or other restrictions of the 113 * U.S. Export Administration Regulations. Licensee agrees that neither it nor 114 * any of its subsidiaries will export/re-export any technical data, process, 115 * software, or service, directly or indirectly, to any country for which the 116 * United States government or any agency thereof requires an export license, 117 * other governmental approval, or letter of assurance, without first obtaining 118 * such license, approval or letter. 119 * 120 *****************************************************************************/ 121 122#define __RSMEMORY_C__ 123 124#include "acpi.h" 125#include "acresrc.h" 126 127#define _COMPONENT RESOURCE_MANAGER 128 MODULE_NAME ("rsmemory") 129 130 131/******************************************************************************* 132 * 133 * FUNCTION: AcpiRsMemory24Resource 134 * 135 * PARAMETERS: ByteStreamBuffer - Pointer to the resource input byte 136 * stream 137 * BytesConsumed - UINT32 pointer that is filled with 138 * the number of bytes consumed from 139 * the ByteStreamBuffer 140 * OutputBuffer - Pointer to the user's return buffer 141 * StructureSize - UINT32 pointer that is filled with 142 * the number of bytes in the filled 143 * in structure 144 * 145 * RETURN: Status AE_OK if okay, else a valid ACPI_STATUS code 146 * 147 * DESCRIPTION: Take the resource byte stream and fill out the appropriate 148 * structure pointed to by the OutputBuffer. Return the 149 * number of bytes consumed from the byte stream. 150 * 151 ******************************************************************************/ 152 153ACPI_STATUS 154AcpiRsMemory24Resource ( 155 UINT8 *ByteStreamBuffer, 156 UINT32 *BytesConsumed, 157 UINT8 **OutputBuffer, 158 UINT32 *StructureSize) 159{ 160 UINT8 *Buffer = ByteStreamBuffer; 161 RESOURCE *OutputStruct = (RESOURCE *) * OutputBuffer; 162 UINT16 Temp16 = 0; 163 UINT8 Temp8 = 0; 164 UINT32 StructSize = sizeof (MEMORY24_RESOURCE) + 165 RESOURCE_LENGTH_NO_DATA; 166 167 168 FUNCTION_TRACE ("RsMemory24Resource"); 169 170 /* 171 * Point past the Descriptor to get the number of bytes consumed 172 */ 173 Buffer += 1; 174 175 MOVE_UNALIGNED16_TO_16 (&Temp16, Buffer); 176 Buffer += 2; 177 *BytesConsumed = Temp16 + 3; 178 OutputStruct->Id = Memory24; 179 180 /* 181 * Check Byte 3 the Read/Write bit 182 */ 183 Temp8 = *Buffer; 184 Buffer += 1; 185 OutputStruct->Data.Memory24.ReadWriteAttribute = Temp8 & 0x01; 186 187 /* 188 * Get MinBaseAddress (Bytes 4-5) 189 */ 190 MOVE_UNALIGNED16_TO_16 (&Temp16, Buffer); 191 Buffer += 2; 192 OutputStruct->Data.Memory24.MinBaseAddress = Temp16; 193 194 /* 195 * Get MaxBaseAddress (Bytes 6-7) 196 */ 197 MOVE_UNALIGNED16_TO_16 (&Temp16, Buffer); 198 Buffer += 2; 199 OutputStruct->Data.Memory24.MaxBaseAddress = Temp16; 200 201 /* 202 * Get Alignment (Bytes 8-9) 203 */ 204 MOVE_UNALIGNED16_TO_16 (&Temp16, Buffer); 205 Buffer += 2; 206 OutputStruct->Data.Memory24.Alignment = Temp16; 207 208 /* 209 * Get RangeLength (Bytes 10-11) 210 */ 211 MOVE_UNALIGNED16_TO_16 (&Temp16, Buffer); 212 OutputStruct->Data.Memory24.RangeLength = Temp16; 213 214 /* 215 * Set the Length parameter 216 */ 217 OutputStruct->Length = StructSize; 218 219 /* 220 * Return the final size of the structure 221 */ 222 *StructureSize = StructSize; 223 224 return_ACPI_STATUS (AE_OK); 225} 226 227 228/******************************************************************************* 229 * 230 * FUNCTION: AcpiRsMemory24Stream 231 * 232 * PARAMETERS: LinkedList - Pointer to the resource linked list 233 * OutputBuffer - Pointer to the user's return buffer 234 * BytesConsumed - UINT32 pointer that is filled with 235 * the number of bytes of the 236 * OutputBuffer used 237 * 238 * RETURN: Status AE_OK if okay, else a valid ACPI_STATUS code 239 * 240 * DESCRIPTION: Take the linked list resource structure and fills in the 241 * the appropriate bytes in a byte stream 242 * 243 ******************************************************************************/ 244 245ACPI_STATUS 246AcpiRsMemory24Stream ( 247 RESOURCE *LinkedList, 248 UINT8 **OutputBuffer, 249 UINT32 *BytesConsumed) 250{ 251 UINT8 *Buffer = *OutputBuffer; 252 UINT16 Temp16 = 0; 253 UINT8 Temp8 = 0; 254 255 256 FUNCTION_TRACE ("RsMemory24Stream"); 257 258 /* 259 * The descriptor field is static 260 */ 261 *Buffer = 0x81; 262 Buffer += 1; 263 264 /* 265 * The length field is static 266 */ 267 Temp16 = 0x09; 268 MOVE_UNALIGNED16_TO_16 (Buffer, &Temp16); 269 Buffer += 2; 270 271 /* 272 * Set the Information Byte 273 */ 274 Temp8 = (UINT8) (LinkedList->Data.Memory24.ReadWriteAttribute & 0x01); 275 *Buffer = Temp8; 276 Buffer += 1; 277 278 /* 279 * Set the Range minimum base address 280 */ 281 MOVE_UNALIGNED16_TO_16 (Buffer, &LinkedList->Data.Memory24.MinBaseAddress); 282 Buffer += 2; 283 284 /* 285 * Set the Range maximum base address 286 */ 287 MOVE_UNALIGNED16_TO_16 (Buffer, &LinkedList->Data.Memory24.MaxBaseAddress); 288 Buffer += 2; 289 290 /* 291 * Set the base alignment 292 */ 293 MOVE_UNALIGNED16_TO_16 (Buffer, &LinkedList->Data.Memory24.Alignment); 294 Buffer += 2; 295 296 /* 297 * Set the range length 298 */ 299 MOVE_UNALIGNED16_TO_16 (Buffer, &LinkedList->Data.Memory24.RangeLength); 300 Buffer += 2; 301 302 /* 303 * Return the number of bytes consumed in this operation 304 */ 305 *BytesConsumed = (UINT32) ((NATIVE_UINT) Buffer - 306 (NATIVE_UINT) *OutputBuffer); 307 308 return_ACPI_STATUS (AE_OK); 309} 310 311 312/******************************************************************************* 313 * 314 * FUNCTION: AcpiRsMemory32RangeResource 315 * 316 * PARAMETERS: ByteStreamBuffer - Pointer to the resource input byte 317 * stream 318 * BytesConsumed - UINT32 pointer that is filled with 319 * the number of bytes consumed from 320 * the ByteStreamBuffer 321 * OutputBuffer - Pointer to the user's return buffer 322 * StructureSize - UINT32 pointer that is filled with 323 * the number of bytes in the filled 324 * in structure 325 * 326 * RETURN: Status AE_OK if okay, else a valid ACPI_STATUS code 327 * 328 * DESCRIPTION: Take the resource byte stream and fill out the appropriate 329 * structure pointed to by the OutputBuffer. Return the 330 * number of bytes consumed from the byte stream. 331 * 332 ******************************************************************************/ 333 334ACPI_STATUS 335AcpiRsMemory32RangeResource ( 336 UINT8 *ByteStreamBuffer, 337 UINT32 *BytesConsumed, 338 UINT8 **OutputBuffer, 339 UINT32 *StructureSize) 340{ 341 UINT8 *Buffer = ByteStreamBuffer; 342 RESOURCE *OutputStruct = (RESOURCE *) * OutputBuffer; 343 UINT16 Temp16 = 0; 344 UINT8 Temp8 = 0; 345 UINT32 StructSize = sizeof (MEMORY32_RESOURCE) + 346 RESOURCE_LENGTH_NO_DATA; 347 348 349 FUNCTION_TRACE ("RsMemory32RangeResource"); 350 351 /* 352 * Point past the Descriptor to get the number of bytes consumed 353 */ 354 Buffer += 1; 355 356 MOVE_UNALIGNED16_TO_16 (&Temp16, Buffer); 357 Buffer += 2; 358 *BytesConsumed = Temp16 + 3; 359 360 OutputStruct->Id = Memory32; 361 362 /* 363 * Point to the place in the output buffer where the data portion will 364 * begin. 365 * 1. Set the RESOURCE_DATA * Data to point to it's own address, then 366 * 2. Set the pointer to the next address. 367 * 368 * NOTE: OutputStruct->Data is cast to UINT8, otherwise, this addition adds 369 * 4 * sizeof(RESOURCE_DATA) instead of 4 * sizeof(UINT8) 370 */ 371 372 /* 373 * Check Byte 3 the Read/Write bit 374 */ 375 Temp8 = *Buffer; 376 Buffer += 1; 377 378 OutputStruct->Data.Memory32.ReadWriteAttribute = Temp8 & 0x01; 379 380 /* 381 * Get MinBaseAddress (Bytes 4-7) 382 */ 383 MOVE_UNALIGNED32_TO_32 (&OutputStruct->Data.Memory32.MinBaseAddress, 384 Buffer); 385 Buffer += 4; 386 387 /* 388 * Get MaxBaseAddress (Bytes 8-11) 389 */ 390 MOVE_UNALIGNED32_TO_32 (&OutputStruct->Data.Memory32.MaxBaseAddress, 391 Buffer); 392 Buffer += 4; 393 394 /* 395 * Get Alignment (Bytes 12-15) 396 */ 397 MOVE_UNALIGNED32_TO_32 (&OutputStruct->Data.Memory32.Alignment, Buffer); 398 Buffer += 4; 399 400 /* 401 * Get RangeLength (Bytes 16-19) 402 */ 403 MOVE_UNALIGNED32_TO_32 (&OutputStruct->Data.Memory32.RangeLength, Buffer); 404 405 /* 406 * Set the Length parameter 407 */ 408 OutputStruct->Length = StructSize; 409 410 /* 411 * Return the final size of the structure 412 */ 413 *StructureSize = StructSize; 414 415 return_ACPI_STATUS (AE_OK); 416} 417 418 419/******************************************************************************* 420 * 421 * FUNCTION: AcpiRsFixedMemory32Resource 422 * 423 * PARAMETERS: ByteStreamBuffer - Pointer to the resource input byte 424 * stream 425 * BytesConsumed - UINT32 pointer that is filled with 426 * the number of bytes consumed from 427 * the ByteStreamBuffer 428 * OutputBuffer - Pointer to the user's return buffer 429 * StructureSize - UINT32 pointer that is filled with 430 * the number of bytes in the filled 431 * in structure 432 * 433 * RETURN: Status AE_OK if okay, else a valid ACPI_STATUS code 434 * 435 * DESCRIPTION: Take the resource byte stream and fill out the appropriate 436 * structure pointed to by the OutputBuffer. Return the 437 * number of bytes consumed from the byte stream. 438 * 439 ******************************************************************************/ 440 441ACPI_STATUS 442AcpiRsFixedMemory32Resource ( 443 UINT8 *ByteStreamBuffer, 444 UINT32 *BytesConsumed, 445 UINT8 **OutputBuffer, 446 UINT32 *StructureSize) 447{ 448 UINT8 *Buffer = ByteStreamBuffer; 449 RESOURCE *OutputStruct = (RESOURCE *) * OutputBuffer; 450 UINT16 Temp16 = 0; 451 UINT8 Temp8 = 0; 452 UINT32 StructSize = sizeof (FIXED_MEMORY32_RESOURCE) + 453 RESOURCE_LENGTH_NO_DATA; 454 455 456 FUNCTION_TRACE ("RsFixedMemory32Resource"); 457 458 /* 459 * Point past the Descriptor to get the number of bytes consumed 460 */ 461 Buffer += 1; 462 MOVE_UNALIGNED16_TO_16 (&Temp16, Buffer); 463 464 Buffer += 2; 465 *BytesConsumed = Temp16 + 3; 466 467 OutputStruct->Id = FixedMemory32; 468 469 /* 470 * Check Byte 3 the Read/Write bit 471 */ 472 Temp8 = *Buffer; 473 Buffer += 1; 474 OutputStruct->Data.FixedMemory32.ReadWriteAttribute = Temp8 & 0x01; 475 476 /* 477 * Get RangeBaseAddress (Bytes 4-7) 478 */ 479 MOVE_UNALIGNED32_TO_32 (&OutputStruct->Data.FixedMemory32.RangeBaseAddress, 480 Buffer); 481 Buffer += 4; 482 483 /* 484 * Get RangeLength (Bytes 8-11) 485 */ 486 MOVE_UNALIGNED32_TO_32 (&OutputStruct->Data.FixedMemory32.RangeLength, 487 Buffer); 488 489 /* 490 * Set the Length parameter 491 */ 492 OutputStruct->Length = StructSize; 493 494 /* 495 * Return the final size of the structure 496 */ 497 *StructureSize = StructSize; 498 499 return_ACPI_STATUS (AE_OK); 500} 501 502 503/******************************************************************************* 504 * 505 * FUNCTION: AcpiRsMemory32RangeStream 506 * 507 * PARAMETERS: LinkedList - Pointer to the resource linked list 508 * OutputBuffer - Pointer to the user's return buffer 509 * BytesConsumed - UINT32 pointer that is filled with 510 * the number of bytes of the 511 * OutputBuffer used 512 * 513 * RETURN: Status AE_OK if okay, else a valid ACPI_STATUS code 514 * 515 * DESCRIPTION: Take the linked list resource structure and fills in the 516 * the appropriate bytes in a byte stream 517 * 518 ******************************************************************************/ 519 520ACPI_STATUS 521AcpiRsMemory32RangeStream ( 522 RESOURCE *LinkedList, 523 UINT8 **OutputBuffer, 524 UINT32 *BytesConsumed) 525{ 526 UINT8 *Buffer = *OutputBuffer; 527 UINT16 Temp16 = 0; 528 UINT8 Temp8 = 0; 529 530 531 FUNCTION_TRACE ("RsMemory32RangeStream"); 532 533 /* 534 * The descriptor field is static 535 */ 536 *Buffer = 0x85; 537 Buffer += 1; 538 539 /* 540 * The length field is static 541 */ 542 Temp16 = 0x11; 543 544 MOVE_UNALIGNED16_TO_16 (Buffer, &Temp16); 545 Buffer += 2; 546 547 /* 548 * Set the Information Byte 549 */ 550 Temp8 = (UINT8) (LinkedList->Data.Memory32.ReadWriteAttribute & 0x01); 551 *Buffer = Temp8; 552 Buffer += 1; 553 554 /* 555 * Set the Range minimum base address 556 */ 557 MOVE_UNALIGNED32_TO_32 (Buffer, &LinkedList->Data.Memory32.MinBaseAddress); 558 Buffer += 4; 559 560 /* 561 * Set the Range maximum base address 562 */ 563 MOVE_UNALIGNED32_TO_32 (Buffer, &LinkedList->Data.Memory32.MaxBaseAddress); 564 Buffer += 4; 565 566 /* 567 * Set the base alignment 568 */ 569 MOVE_UNALIGNED32_TO_32 (Buffer, &LinkedList->Data.Memory32.Alignment); 570 Buffer += 4; 571 572 /* 573 * Set the range length 574 */ 575 MOVE_UNALIGNED32_TO_32 (Buffer, &LinkedList->Data.Memory32.RangeLength); 576 Buffer += 4; 577 578 /* 579 * Return the number of bytes consumed in this operation 580 */ 581 *BytesConsumed = (UINT32) ((NATIVE_UINT) Buffer - 582 (NATIVE_UINT) *OutputBuffer); 583 584 return_ACPI_STATUS (AE_OK); 585} 586 587 588/******************************************************************************* 589 * 590 * FUNCTION: AcpiRsFixedMemory32Stream 591 * 592 * PARAMETERS: LinkedList - Pointer to the resource linked list 593 * OutputBuffer - Pointer to the user's return buffer 594 * BytesConsumed - UINT32 pointer that is filled with 595 * the number of bytes of the 596 * OutputBuffer used 597 * 598 * RETURN: Status AE_OK if okay, else a valid ACPI_STATUS code 599 * 600 * DESCRIPTION: Take the linked list resource structure and fills in the 601 * the appropriate bytes in a byte stream 602 * 603 ******************************************************************************/ 604 605ACPI_STATUS 606AcpiRsFixedMemory32Stream ( 607 RESOURCE *LinkedList, 608 UINT8 **OutputBuffer, 609 UINT32 *BytesConsumed) 610{ 611 UINT8 *Buffer = *OutputBuffer; 612 UINT16 Temp16 = 0; 613 UINT8 Temp8 = 0; 614 615 616 FUNCTION_TRACE ("RsFixedMemory32Stream"); 617 618 /* 619 * The descriptor field is static 620 */ 621 *Buffer = 0x86; 622 Buffer += 1; 623 624 /* 625 * The length field is static 626 */ 627 Temp16 = 0x09; 628 629 MOVE_UNALIGNED16_TO_16 (Buffer, &Temp16); 630 Buffer += 2; 631 632 /* 633 * Set the Information Byte 634 */ 635 Temp8 = (UINT8) (LinkedList->Data.FixedMemory32.ReadWriteAttribute & 0x01); 636 *Buffer = Temp8; 637 Buffer += 1; 638 639 /* 640 * Set the Range base address 641 */ 642 MOVE_UNALIGNED32_TO_32 (Buffer, 643 &LinkedList->Data.FixedMemory32.RangeBaseAddress); 644 Buffer += 4; 645 646 /* 647 * Set the range length 648 */ 649 MOVE_UNALIGNED32_TO_32 (Buffer, 650 &LinkedList->Data.FixedMemory32.RangeLength); 651 Buffer += 4; 652 653 /* 654 * Return the number of bytes consumed in this operation 655 */ 656 *BytesConsumed = (UINT32) ((NATIVE_UINT) Buffer - 657 (NATIVE_UINT) *OutputBuffer); 658 659 return_ACPI_STATUS (AE_OK); 660} 661
|