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 __RSLIST_C__ 118 119#include "acpi.h" 120#include "acresrc.h" 121 122#define _COMPONENT ACPI_RESOURCES 123 ACPI_MODULE_NAME ("rslist") 124 125 126/******************************************************************************* 127 * 128 * FUNCTION: AcpiRsGetResourceType 129 * 130 * PARAMETERS: ResourceStartByte - Byte 0 of a resource descriptor 131 * 132 * RETURN: The Resource Type (Name) with no extraneous bits 133 * 134 * DESCRIPTION: Extract the Resource Type/Name from the first byte of 135 * a resource descriptor. 136 * 137 ******************************************************************************/ 138 139UINT8 140AcpiRsGetResourceType ( 141 UINT8 ResourceStartByte) 142{ 143 144 ACPI_FUNCTION_ENTRY (); 145 146 147 /* 148 * Determine if this is a small or large resource 149 */ 150 switch (ResourceStartByte & ACPI_RDESC_TYPE_MASK) 151 { 152 case ACPI_RDESC_TYPE_SMALL: 153 154 /* 155 * Small Resource Type -- Only bits 6:3 are valid 156 */ 157 return ((UINT8) (ResourceStartByte & ACPI_RDESC_SMALL_MASK)); 158 159 160 case ACPI_RDESC_TYPE_LARGE: 161 162 /* 163 * Large Resource Type -- All bits are valid 164 */ 165 return (ResourceStartByte); 166 167 168 default: 169 /* No other types of resource descriptor */ 170 break; 171 } 172 173 return (0xFF); 174} 175 176 177/******************************************************************************* 178 * 179 * FUNCTION: AcpiRsByteStreamToList 180 * 181 * PARAMETERS: ByteStreamBuffer - Pointer to the resource byte stream 182 * ByteStreamBufferLength - Length of ByteStreamBuffer 183 * OutputBuffer - Pointer to the buffer that will 184 * contain the output structures 185 * 186 * RETURN: Status 187 * 188 * DESCRIPTION: Takes the resource byte stream and parses it, creating a 189 * linked list of resources in the caller's output buffer 190 * 191 ******************************************************************************/ 192 193ACPI_STATUS 194AcpiRsByteStreamToList ( 195 UINT8 *ByteStreamBuffer, 196 UINT32 ByteStreamBufferLength, 197 UINT8 *OutputBuffer) 198{ 199 ACPI_STATUS Status; 200 ACPI_SIZE BytesParsed = 0; 201 UINT8 ResourceType = 0; 202 ACPI_SIZE BytesConsumed = 0; 203 UINT8 *Buffer = OutputBuffer; 204 ACPI_SIZE StructureSize = 0; 205 BOOLEAN EndTagProcessed = FALSE; 206 ACPI_RESOURCE *Resource; 207 208 ACPI_FUNCTION_TRACE ("RsByteStreamToList"); 209 210 211 while (BytesParsed < ByteStreamBufferLength && 212 !EndTagProcessed) 213 { 214 /* 215 * The next byte in the stream is the resource type 216 */ 217 ResourceType = AcpiRsGetResourceType (*ByteStreamBuffer); 218 219 switch (ResourceType) 220 { 221 case ACPI_RDESC_TYPE_MEMORY_24: 222 /* 223 * 24-Bit Memory Resource 224 */ 225 Status = AcpiRsMemory24Resource (ByteStreamBuffer, 226 &BytesConsumed, &Buffer, &StructureSize); 227 break; 228 229 230 case ACPI_RDESC_TYPE_LARGE_VENDOR: 231 /* 232 * Vendor Defined Resource 233 */ 234 Status = AcpiRsVendorResource (ByteStreamBuffer, 235 &BytesConsumed, &Buffer, &StructureSize); 236 break; 237 238 239 case ACPI_RDESC_TYPE_MEMORY_32: 240 /* 241 * 32-Bit Memory Range Resource 242 */ 243 Status = AcpiRsMemory32RangeResource (ByteStreamBuffer, 244 &BytesConsumed, &Buffer, &StructureSize); 245 break; 246 247 248 case ACPI_RDESC_TYPE_FIXED_MEMORY_32: 249 /* 250 * 32-Bit Fixed Memory Resource 251 */ 252 Status = AcpiRsFixedMemory32Resource (ByteStreamBuffer, 253 &BytesConsumed, &Buffer, &StructureSize); 254 break; 255 256 257 case ACPI_RDESC_TYPE_QWORD_ADDRESS_SPACE: 258 /* 259 * 64-Bit Address Resource 260 */ 261 Status = AcpiRsAddress64Resource (ByteStreamBuffer, 262 &BytesConsumed, &Buffer, &StructureSize); 263 break; 264 265 266 case ACPI_RDESC_TYPE_DWORD_ADDRESS_SPACE: 267 /* 268 * 32-Bit Address Resource 269 */ 270 Status = AcpiRsAddress32Resource (ByteStreamBuffer, 271 &BytesConsumed, &Buffer, &StructureSize); 272 break; 273 274 275 case ACPI_RDESC_TYPE_WORD_ADDRESS_SPACE: 276 /* 277 * 16-Bit Address Resource 278 */ 279 Status = AcpiRsAddress16Resource (ByteStreamBuffer, 280 &BytesConsumed, &Buffer, &StructureSize); 281 break; 282 283 284 case ACPI_RDESC_TYPE_EXTENDED_XRUPT: 285 /* 286 * Extended IRQ 287 */ 288 Status = AcpiRsExtendedIrqResource (ByteStreamBuffer, 289 &BytesConsumed, &Buffer, &StructureSize); 290 break; 291 292 293 case ACPI_RDESC_TYPE_IRQ_FORMAT: 294 /* 295 * IRQ Resource 296 */ 297 Status = AcpiRsIrqResource (ByteStreamBuffer, 298 &BytesConsumed, &Buffer, &StructureSize); 299 break; 300 301 302 case ACPI_RDESC_TYPE_DMA_FORMAT: 303 /* 304 * DMA Resource 305 */ 306 Status = AcpiRsDmaResource (ByteStreamBuffer, 307 &BytesConsumed, &Buffer, &StructureSize); 308 break; 309 310 311 case ACPI_RDESC_TYPE_START_DEPENDENT: 312 /* 313 * Start Dependent Functions Resource 314 */ 315 Status = AcpiRsStartDependFnsResource (ByteStreamBuffer, 316 &BytesConsumed, &Buffer, &StructureSize); 317 break; 318 319 320 case ACPI_RDESC_TYPE_END_DEPENDENT: 321 /* 322 * End Dependent Functions Resource 323 */ 324 Status = AcpiRsEndDependFnsResource (ByteStreamBuffer, 325 &BytesConsumed, &Buffer, &StructureSize); 326 break; 327 328 329 case ACPI_RDESC_TYPE_IO_PORT: 330 /* 331 * IO Port Resource 332 */ 333 Status = AcpiRsIoResource (ByteStreamBuffer, 334 &BytesConsumed, &Buffer, &StructureSize); 335 break; 336 337 338 case ACPI_RDESC_TYPE_FIXED_IO_PORT: 339 /* 340 * Fixed IO Port Resource 341 */ 342 Status = AcpiRsFixedIoResource (ByteStreamBuffer, 343 &BytesConsumed, &Buffer, &StructureSize); 344 break; 345 346 347 case ACPI_RDESC_TYPE_SMALL_VENDOR: 348 /* 349 * Vendor Specific Resource 350 */ 351 Status = AcpiRsVendorResource (ByteStreamBuffer, 352 &BytesConsumed, &Buffer, &StructureSize); 353 break; 354 355 356 case ACPI_RDESC_TYPE_END_TAG: 357 /* 358 * End Tag 359 */ 360 EndTagProcessed = TRUE; 361 Status = AcpiRsEndTagResource (ByteStreamBuffer, 362 &BytesConsumed, &Buffer, &StructureSize); 363 break; 364 365 366 default: 367 /* 368 * Invalid/Unknown resource type 369 */ 370 Status = AE_AML_INVALID_RESOURCE_TYPE; 371 break; 372 } 373 374 if (ACPI_FAILURE (Status)) 375 { 376 return_ACPI_STATUS (Status); 377 } 378 379 /* 380 * Update the return value and counter 381 */ 382 BytesParsed += BytesConsumed; 383 384 /* 385 * Set the byte stream to point to the next resource 386 */ 387 ByteStreamBuffer += BytesConsumed; 388 389 /* 390 * Set the Buffer to the next structure 391 */ 392 Resource = ACPI_CAST_PTR (ACPI_RESOURCE, Buffer); 393 Resource->Length = (UINT32) ACPI_ALIGN_RESOURCE_SIZE (Resource->Length); 394 Buffer += ACPI_ALIGN_RESOURCE_SIZE (StructureSize); 395 396 } /* end while */ 397 398 /* 399 * Check the reason for exiting the while loop 400 */ 401 if (!EndTagProcessed) 402 { 403 return_ACPI_STATUS (AE_AML_NO_RESOURCE_END_TAG); 404 } 405 406 return_ACPI_STATUS (AE_OK); 407} 408 409 410/******************************************************************************* 411 * 412 * FUNCTION: AcpiRsListToByteStream 413 * 414 * PARAMETERS: LinkedList - Pointer to the resource linked list 415 * ByteSteamSizeNeeded - Calculated size of the byte stream 416 * needed from calling 417 * AcpiRsGetByteStreamLength() 418 * The size of the OutputBuffer is 419 * guaranteed to be >= 420 * ByteStreamSizeNeeded 421 * OutputBuffer - Pointer to the buffer that will 422 * contain the byte stream 423 * 424 * RETURN: Status 425 * 426 * DESCRIPTION: Takes the resource linked list and parses it, creating a 427 * byte stream of resources in the caller's output buffer 428 * 429 ******************************************************************************/ 430 431ACPI_STATUS 432AcpiRsListToByteStream ( 433 ACPI_RESOURCE *LinkedList, 434 ACPI_SIZE ByteStreamSizeNeeded, 435 UINT8 *OutputBuffer) 436{ 437 ACPI_STATUS Status; 438 UINT8 *Buffer = OutputBuffer; 439 ACPI_SIZE BytesConsumed = 0; 440 BOOLEAN Done = FALSE; 441 442 443 ACPI_FUNCTION_TRACE ("RsListToByteStream"); 444 445 446 while (!Done) 447 { 448 switch (LinkedList->Id) 449 { 450 case ACPI_RSTYPE_IRQ: 451 /* 452 * IRQ Resource 453 */ 454 Status = AcpiRsIrqStream (LinkedList, &Buffer, &BytesConsumed); 455 break; 456 457 case ACPI_RSTYPE_DMA: 458 /* 459 * DMA Resource 460 */ 461 Status = AcpiRsDmaStream (LinkedList, &Buffer, &BytesConsumed); 462 break; 463 464 case ACPI_RSTYPE_START_DPF: 465 /* 466 * Start Dependent Functions Resource 467 */ 468 Status = AcpiRsStartDependFnsStream (LinkedList, 469 &Buffer, &BytesConsumed); 470 break; 471 472 case ACPI_RSTYPE_END_DPF: 473 /* 474 * End Dependent Functions Resource 475 */ 476 Status = AcpiRsEndDependFnsStream (LinkedList, 477 &Buffer, &BytesConsumed); 478 break; 479 480 case ACPI_RSTYPE_IO: 481 /* 482 * IO Port Resource 483 */ 484 Status = AcpiRsIoStream (LinkedList, &Buffer, &BytesConsumed); 485 break; 486 487 case ACPI_RSTYPE_FIXED_IO: 488 /* 489 * Fixed IO Port Resource 490 */ 491 Status = AcpiRsFixedIoStream (LinkedList, &Buffer, &BytesConsumed); 492 break; 493 494 case ACPI_RSTYPE_VENDOR: 495 /* 496 * Vendor Defined Resource 497 */ 498 Status = AcpiRsVendorStream (LinkedList, &Buffer, &BytesConsumed); 499 break; 500 501 case ACPI_RSTYPE_END_TAG: 502 /* 503 * End Tag 504 */ 505 Status = AcpiRsEndTagStream (LinkedList, &Buffer, &BytesConsumed); 506 507 /* 508 * An End Tag indicates the end of the Resource Template 509 */ 510 Done = TRUE; 511 break; 512 513 case ACPI_RSTYPE_MEM24: 514 /* 515 * 24-Bit Memory Resource 516 */ 517 Status = AcpiRsMemory24Stream (LinkedList, &Buffer, &BytesConsumed); 518 break; 519 520 case ACPI_RSTYPE_MEM32: 521 /* 522 * 32-Bit Memory Range Resource 523 */ 524 Status = AcpiRsMemory32RangeStream (LinkedList, &Buffer, 525 &BytesConsumed); 526 break; 527 528 case ACPI_RSTYPE_FIXED_MEM32: 529 /* 530 * 32-Bit Fixed Memory Resource 531 */ 532 Status = AcpiRsFixedMemory32Stream (LinkedList, &Buffer, 533 &BytesConsumed); 534 break; 535 536 case ACPI_RSTYPE_ADDRESS16: 537 /* 538 * 16-Bit Address Descriptor Resource 539 */ 540 Status = AcpiRsAddress16Stream (LinkedList, &Buffer, 541 &BytesConsumed); 542 break; 543 544 case ACPI_RSTYPE_ADDRESS32: 545 /* 546 * 32-Bit Address Descriptor Resource 547 */ 548 Status = AcpiRsAddress32Stream (LinkedList, &Buffer, 549 &BytesConsumed); 550 break; 551 552 case ACPI_RSTYPE_ADDRESS64: 553 /* 554 * 64-Bit Address Descriptor Resource 555 */ 556 Status = AcpiRsAddress64Stream (LinkedList, &Buffer, 557 &BytesConsumed); 558 break; 559 560 case ACPI_RSTYPE_EXT_IRQ: 561 /* 562 * Extended IRQ Resource 563 */ 564 Status = AcpiRsExtendedIrqStream (LinkedList, &Buffer, 565 &BytesConsumed); 566 break; 567 568 default: 569 /* 570 * If we get here, everything is out of sync, 571 * so exit with an error 572 */ 573 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Invalid descriptor type (%X) in resource list\n", 574 LinkedList->Id)); 575 Status = AE_BAD_DATA; 576 break; 577 578 } /* switch (LinkedList->Id) */ 579 580 if (ACPI_FAILURE (Status)) 581 { 582 return_ACPI_STATUS (Status); 583 } 584 585 /* 586 * Set the Buffer to point to the open byte 587 */ 588 Buffer += BytesConsumed; 589 590 /* 591 * Point to the next object 592 */ 593 LinkedList = ACPI_PTR_ADD (ACPI_RESOURCE, 594 LinkedList, LinkedList->Length); 595 } 596 597 return_ACPI_STATUS (AE_OK); 598} 599
| 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 __RSLIST_C__ 118 119#include "acpi.h" 120#include "acresrc.h" 121 122#define _COMPONENT ACPI_RESOURCES 123 ACPI_MODULE_NAME ("rslist") 124 125 126/******************************************************************************* 127 * 128 * FUNCTION: AcpiRsGetResourceType 129 * 130 * PARAMETERS: ResourceStartByte - Byte 0 of a resource descriptor 131 * 132 * RETURN: The Resource Type (Name) with no extraneous bits 133 * 134 * DESCRIPTION: Extract the Resource Type/Name from the first byte of 135 * a resource descriptor. 136 * 137 ******************************************************************************/ 138 139UINT8 140AcpiRsGetResourceType ( 141 UINT8 ResourceStartByte) 142{ 143 144 ACPI_FUNCTION_ENTRY (); 145 146 147 /* 148 * Determine if this is a small or large resource 149 */ 150 switch (ResourceStartByte & ACPI_RDESC_TYPE_MASK) 151 { 152 case ACPI_RDESC_TYPE_SMALL: 153 154 /* 155 * Small Resource Type -- Only bits 6:3 are valid 156 */ 157 return ((UINT8) (ResourceStartByte & ACPI_RDESC_SMALL_MASK)); 158 159 160 case ACPI_RDESC_TYPE_LARGE: 161 162 /* 163 * Large Resource Type -- All bits are valid 164 */ 165 return (ResourceStartByte); 166 167 168 default: 169 /* No other types of resource descriptor */ 170 break; 171 } 172 173 return (0xFF); 174} 175 176 177/******************************************************************************* 178 * 179 * FUNCTION: AcpiRsByteStreamToList 180 * 181 * PARAMETERS: ByteStreamBuffer - Pointer to the resource byte stream 182 * ByteStreamBufferLength - Length of ByteStreamBuffer 183 * OutputBuffer - Pointer to the buffer that will 184 * contain the output structures 185 * 186 * RETURN: Status 187 * 188 * DESCRIPTION: Takes the resource byte stream and parses it, creating a 189 * linked list of resources in the caller's output buffer 190 * 191 ******************************************************************************/ 192 193ACPI_STATUS 194AcpiRsByteStreamToList ( 195 UINT8 *ByteStreamBuffer, 196 UINT32 ByteStreamBufferLength, 197 UINT8 *OutputBuffer) 198{ 199 ACPI_STATUS Status; 200 ACPI_SIZE BytesParsed = 0; 201 UINT8 ResourceType = 0; 202 ACPI_SIZE BytesConsumed = 0; 203 UINT8 *Buffer = OutputBuffer; 204 ACPI_SIZE StructureSize = 0; 205 BOOLEAN EndTagProcessed = FALSE; 206 ACPI_RESOURCE *Resource; 207 208 ACPI_FUNCTION_TRACE ("RsByteStreamToList"); 209 210 211 while (BytesParsed < ByteStreamBufferLength && 212 !EndTagProcessed) 213 { 214 /* 215 * The next byte in the stream is the resource type 216 */ 217 ResourceType = AcpiRsGetResourceType (*ByteStreamBuffer); 218 219 switch (ResourceType) 220 { 221 case ACPI_RDESC_TYPE_MEMORY_24: 222 /* 223 * 24-Bit Memory Resource 224 */ 225 Status = AcpiRsMemory24Resource (ByteStreamBuffer, 226 &BytesConsumed, &Buffer, &StructureSize); 227 break; 228 229 230 case ACPI_RDESC_TYPE_LARGE_VENDOR: 231 /* 232 * Vendor Defined Resource 233 */ 234 Status = AcpiRsVendorResource (ByteStreamBuffer, 235 &BytesConsumed, &Buffer, &StructureSize); 236 break; 237 238 239 case ACPI_RDESC_TYPE_MEMORY_32: 240 /* 241 * 32-Bit Memory Range Resource 242 */ 243 Status = AcpiRsMemory32RangeResource (ByteStreamBuffer, 244 &BytesConsumed, &Buffer, &StructureSize); 245 break; 246 247 248 case ACPI_RDESC_TYPE_FIXED_MEMORY_32: 249 /* 250 * 32-Bit Fixed Memory Resource 251 */ 252 Status = AcpiRsFixedMemory32Resource (ByteStreamBuffer, 253 &BytesConsumed, &Buffer, &StructureSize); 254 break; 255 256 257 case ACPI_RDESC_TYPE_QWORD_ADDRESS_SPACE: 258 /* 259 * 64-Bit Address Resource 260 */ 261 Status = AcpiRsAddress64Resource (ByteStreamBuffer, 262 &BytesConsumed, &Buffer, &StructureSize); 263 break; 264 265 266 case ACPI_RDESC_TYPE_DWORD_ADDRESS_SPACE: 267 /* 268 * 32-Bit Address Resource 269 */ 270 Status = AcpiRsAddress32Resource (ByteStreamBuffer, 271 &BytesConsumed, &Buffer, &StructureSize); 272 break; 273 274 275 case ACPI_RDESC_TYPE_WORD_ADDRESS_SPACE: 276 /* 277 * 16-Bit Address Resource 278 */ 279 Status = AcpiRsAddress16Resource (ByteStreamBuffer, 280 &BytesConsumed, &Buffer, &StructureSize); 281 break; 282 283 284 case ACPI_RDESC_TYPE_EXTENDED_XRUPT: 285 /* 286 * Extended IRQ 287 */ 288 Status = AcpiRsExtendedIrqResource (ByteStreamBuffer, 289 &BytesConsumed, &Buffer, &StructureSize); 290 break; 291 292 293 case ACPI_RDESC_TYPE_IRQ_FORMAT: 294 /* 295 * IRQ Resource 296 */ 297 Status = AcpiRsIrqResource (ByteStreamBuffer, 298 &BytesConsumed, &Buffer, &StructureSize); 299 break; 300 301 302 case ACPI_RDESC_TYPE_DMA_FORMAT: 303 /* 304 * DMA Resource 305 */ 306 Status = AcpiRsDmaResource (ByteStreamBuffer, 307 &BytesConsumed, &Buffer, &StructureSize); 308 break; 309 310 311 case ACPI_RDESC_TYPE_START_DEPENDENT: 312 /* 313 * Start Dependent Functions Resource 314 */ 315 Status = AcpiRsStartDependFnsResource (ByteStreamBuffer, 316 &BytesConsumed, &Buffer, &StructureSize); 317 break; 318 319 320 case ACPI_RDESC_TYPE_END_DEPENDENT: 321 /* 322 * End Dependent Functions Resource 323 */ 324 Status = AcpiRsEndDependFnsResource (ByteStreamBuffer, 325 &BytesConsumed, &Buffer, &StructureSize); 326 break; 327 328 329 case ACPI_RDESC_TYPE_IO_PORT: 330 /* 331 * IO Port Resource 332 */ 333 Status = AcpiRsIoResource (ByteStreamBuffer, 334 &BytesConsumed, &Buffer, &StructureSize); 335 break; 336 337 338 case ACPI_RDESC_TYPE_FIXED_IO_PORT: 339 /* 340 * Fixed IO Port Resource 341 */ 342 Status = AcpiRsFixedIoResource (ByteStreamBuffer, 343 &BytesConsumed, &Buffer, &StructureSize); 344 break; 345 346 347 case ACPI_RDESC_TYPE_SMALL_VENDOR: 348 /* 349 * Vendor Specific Resource 350 */ 351 Status = AcpiRsVendorResource (ByteStreamBuffer, 352 &BytesConsumed, &Buffer, &StructureSize); 353 break; 354 355 356 case ACPI_RDESC_TYPE_END_TAG: 357 /* 358 * End Tag 359 */ 360 EndTagProcessed = TRUE; 361 Status = AcpiRsEndTagResource (ByteStreamBuffer, 362 &BytesConsumed, &Buffer, &StructureSize); 363 break; 364 365 366 default: 367 /* 368 * Invalid/Unknown resource type 369 */ 370 Status = AE_AML_INVALID_RESOURCE_TYPE; 371 break; 372 } 373 374 if (ACPI_FAILURE (Status)) 375 { 376 return_ACPI_STATUS (Status); 377 } 378 379 /* 380 * Update the return value and counter 381 */ 382 BytesParsed += BytesConsumed; 383 384 /* 385 * Set the byte stream to point to the next resource 386 */ 387 ByteStreamBuffer += BytesConsumed; 388 389 /* 390 * Set the Buffer to the next structure 391 */ 392 Resource = ACPI_CAST_PTR (ACPI_RESOURCE, Buffer); 393 Resource->Length = (UINT32) ACPI_ALIGN_RESOURCE_SIZE (Resource->Length); 394 Buffer += ACPI_ALIGN_RESOURCE_SIZE (StructureSize); 395 396 } /* end while */ 397 398 /* 399 * Check the reason for exiting the while loop 400 */ 401 if (!EndTagProcessed) 402 { 403 return_ACPI_STATUS (AE_AML_NO_RESOURCE_END_TAG); 404 } 405 406 return_ACPI_STATUS (AE_OK); 407} 408 409 410/******************************************************************************* 411 * 412 * FUNCTION: AcpiRsListToByteStream 413 * 414 * PARAMETERS: LinkedList - Pointer to the resource linked list 415 * ByteSteamSizeNeeded - Calculated size of the byte stream 416 * needed from calling 417 * AcpiRsGetByteStreamLength() 418 * The size of the OutputBuffer is 419 * guaranteed to be >= 420 * ByteStreamSizeNeeded 421 * OutputBuffer - Pointer to the buffer that will 422 * contain the byte stream 423 * 424 * RETURN: Status 425 * 426 * DESCRIPTION: Takes the resource linked list and parses it, creating a 427 * byte stream of resources in the caller's output buffer 428 * 429 ******************************************************************************/ 430 431ACPI_STATUS 432AcpiRsListToByteStream ( 433 ACPI_RESOURCE *LinkedList, 434 ACPI_SIZE ByteStreamSizeNeeded, 435 UINT8 *OutputBuffer) 436{ 437 ACPI_STATUS Status; 438 UINT8 *Buffer = OutputBuffer; 439 ACPI_SIZE BytesConsumed = 0; 440 BOOLEAN Done = FALSE; 441 442 443 ACPI_FUNCTION_TRACE ("RsListToByteStream"); 444 445 446 while (!Done) 447 { 448 switch (LinkedList->Id) 449 { 450 case ACPI_RSTYPE_IRQ: 451 /* 452 * IRQ Resource 453 */ 454 Status = AcpiRsIrqStream (LinkedList, &Buffer, &BytesConsumed); 455 break; 456 457 case ACPI_RSTYPE_DMA: 458 /* 459 * DMA Resource 460 */ 461 Status = AcpiRsDmaStream (LinkedList, &Buffer, &BytesConsumed); 462 break; 463 464 case ACPI_RSTYPE_START_DPF: 465 /* 466 * Start Dependent Functions Resource 467 */ 468 Status = AcpiRsStartDependFnsStream (LinkedList, 469 &Buffer, &BytesConsumed); 470 break; 471 472 case ACPI_RSTYPE_END_DPF: 473 /* 474 * End Dependent Functions Resource 475 */ 476 Status = AcpiRsEndDependFnsStream (LinkedList, 477 &Buffer, &BytesConsumed); 478 break; 479 480 case ACPI_RSTYPE_IO: 481 /* 482 * IO Port Resource 483 */ 484 Status = AcpiRsIoStream (LinkedList, &Buffer, &BytesConsumed); 485 break; 486 487 case ACPI_RSTYPE_FIXED_IO: 488 /* 489 * Fixed IO Port Resource 490 */ 491 Status = AcpiRsFixedIoStream (LinkedList, &Buffer, &BytesConsumed); 492 break; 493 494 case ACPI_RSTYPE_VENDOR: 495 /* 496 * Vendor Defined Resource 497 */ 498 Status = AcpiRsVendorStream (LinkedList, &Buffer, &BytesConsumed); 499 break; 500 501 case ACPI_RSTYPE_END_TAG: 502 /* 503 * End Tag 504 */ 505 Status = AcpiRsEndTagStream (LinkedList, &Buffer, &BytesConsumed); 506 507 /* 508 * An End Tag indicates the end of the Resource Template 509 */ 510 Done = TRUE; 511 break; 512 513 case ACPI_RSTYPE_MEM24: 514 /* 515 * 24-Bit Memory Resource 516 */ 517 Status = AcpiRsMemory24Stream (LinkedList, &Buffer, &BytesConsumed); 518 break; 519 520 case ACPI_RSTYPE_MEM32: 521 /* 522 * 32-Bit Memory Range Resource 523 */ 524 Status = AcpiRsMemory32RangeStream (LinkedList, &Buffer, 525 &BytesConsumed); 526 break; 527 528 case ACPI_RSTYPE_FIXED_MEM32: 529 /* 530 * 32-Bit Fixed Memory Resource 531 */ 532 Status = AcpiRsFixedMemory32Stream (LinkedList, &Buffer, 533 &BytesConsumed); 534 break; 535 536 case ACPI_RSTYPE_ADDRESS16: 537 /* 538 * 16-Bit Address Descriptor Resource 539 */ 540 Status = AcpiRsAddress16Stream (LinkedList, &Buffer, 541 &BytesConsumed); 542 break; 543 544 case ACPI_RSTYPE_ADDRESS32: 545 /* 546 * 32-Bit Address Descriptor Resource 547 */ 548 Status = AcpiRsAddress32Stream (LinkedList, &Buffer, 549 &BytesConsumed); 550 break; 551 552 case ACPI_RSTYPE_ADDRESS64: 553 /* 554 * 64-Bit Address Descriptor Resource 555 */ 556 Status = AcpiRsAddress64Stream (LinkedList, &Buffer, 557 &BytesConsumed); 558 break; 559 560 case ACPI_RSTYPE_EXT_IRQ: 561 /* 562 * Extended IRQ Resource 563 */ 564 Status = AcpiRsExtendedIrqStream (LinkedList, &Buffer, 565 &BytesConsumed); 566 break; 567 568 default: 569 /* 570 * If we get here, everything is out of sync, 571 * so exit with an error 572 */ 573 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Invalid descriptor type (%X) in resource list\n", 574 LinkedList->Id)); 575 Status = AE_BAD_DATA; 576 break; 577 578 } /* switch (LinkedList->Id) */ 579 580 if (ACPI_FAILURE (Status)) 581 { 582 return_ACPI_STATUS (Status); 583 } 584 585 /* 586 * Set the Buffer to point to the open byte 587 */ 588 Buffer += BytesConsumed; 589 590 /* 591 * Point to the next object 592 */ 593 LinkedList = ACPI_PTR_ADD (ACPI_RESOURCE, 594 LinkedList, LinkedList->Length); 595 } 596 597 return_ACPI_STATUS (AE_OK); 598} 599
|