|
||||
Warning, cross-references for /kernel/drivers/acpica/rscalc.c need to be fixed.
0001 /******************************************************************************* 0002 * 0003 * Module Name: rscalc - Calculate stream and list lengths 0004 * 0005 ******************************************************************************/ 0006 0007 /****************************************************************************** 0008 * 0009 * 1. Copyright Notice 0010 * 0011 * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. 0012 * All rights reserved. 0013 * 0014 * 2. License 0015 * 0016 * 2.1. This is your license from Intel Corp. under its intellectual property 0017 * rights. You may have additional license terms from the party that provided 0018 * you this software, covering your right to use that party's intellectual 0019 * property rights. 0020 * 0021 * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a 0022 * copy of the source code appearing in this file ("Covered Code") an 0023 * irrevocable, perpetual, worldwide license under Intel's copyrights in the 0024 * base code distributed originally by Intel ("Original Intel Code") to copy, 0025 * make derivatives, distribute, use and display any portion of the Covered 0026 * Code in any form, with the right to sublicense such rights; and 0027 * 0028 * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent 0029 * license (with the right to sublicense), under only those claims of Intel 0030 * patents that are infringed by the Original Intel Code, to make, use, sell, 0031 * offer to sell, and import the Covered Code and derivative works thereof 0032 * solely to the minimum extent necessary to exercise the above copyright 0033 * license, and in no event shall the patent license extend to any additions 0034 * to or modifications of the Original Intel Code. No other license or right 0035 * is granted directly or by implication, estoppel or otherwise; 0036 * 0037 * The above copyright and patent license is granted only if the following 0038 * conditions are met: 0039 * 0040 * 3. Conditions 0041 * 0042 * 3.1. Redistribution of Source with Rights to Further Distribute Source. 0043 * Redistribution of source code of any substantial portion of the Covered 0044 * Code or modification with rights to further distribute source must include 0045 * the above Copyright Notice, the above License, this list of Conditions, 0046 * and the following Disclaimer and Export Compliance provision. In addition, 0047 * Licensee must cause all Covered Code to which Licensee contributes to 0048 * contain a file documenting the changes Licensee made to create that Covered 0049 * Code and the date of any change. Licensee must include in that file the 0050 * documentation of any changes made by any predecessor Licensee. Licensee 0051 * must include a prominent statement that the modification is derived, 0052 * directly or indirectly, from Original Intel Code. 0053 * 0054 * 3.2. Redistribution of Source with no Rights to Further Distribute Source. 0055 * Redistribution of source code of any substantial portion of the Covered 0056 * Code or modification without rights to further distribute source must 0057 * include the following Disclaimer and Export Compliance provision in the 0058 * documentation and/or other materials provided with distribution. In 0059 * addition, Licensee may not authorize further sublicense of source of any 0060 * portion of the Covered Code, and must include terms to the effect that the 0061 * license from Licensee to its licensee is limited to the intellectual 0062 * property embodied in the software Licensee provides to its licensee, and 0063 * not to intellectual property embodied in modifications its licensee may 0064 * make. 0065 * 0066 * 3.3. Redistribution of Executable. Redistribution in executable form of any 0067 * substantial portion of the Covered Code or modification must reproduce the 0068 * above Copyright Notice, and the following Disclaimer and Export Compliance 0069 * provision in the documentation and/or other materials provided with the 0070 * distribution. 0071 * 0072 * 3.4. Intel retains all right, title, and interest in and to the Original 0073 * Intel Code. 0074 * 0075 * 3.5. Neither the name Intel nor any other trademark owned or controlled by 0076 * Intel shall be used in advertising or otherwise to promote the sale, use or 0077 * other dealings in products derived from or relating to the Covered Code 0078 * without prior written authorization from Intel. 0079 * 0080 * 4. Disclaimer and Export Compliance 0081 * 0082 * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED 0083 * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE 0084 * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, 0085 * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY 0086 * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY 0087 * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A 0088 * PARTICULAR PURPOSE. 0089 * 0090 * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES 0091 * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR 0092 * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, 0093 * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY 0094 * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL 0095 * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS 0096 * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY 0097 * LIMITED REMEDY. 0098 * 0099 * 4.3. Licensee shall not export, either directly or indirectly, any of this 0100 * software or system incorporating such software without first obtaining any 0101 * required license or other approval from the U. S. Department of Commerce or 0102 * any other agency or department of the United States Government. In the 0103 * event Licensee exports any such software from the United States or 0104 * re-exports any such software from a foreign destination, Licensee shall 0105 * ensure that the distribution and export/re-export of the software is in 0106 * compliance with all laws, regulations, orders, or other restrictions of the 0107 * U.S. Export Administration Regulations. Licensee agrees that neither it nor 0108 * any of its subsidiaries will export/re-export any technical data, process, 0109 * software, or service, directly or indirectly, to any country for which the 0110 * United States government or any agency thereof requires an export license, 0111 * other governmental approval, or letter of assurance, without first obtaining 0112 * such license, approval or letter. 0113 * 0114 *****************************************************************************/ 0115 0116 #define __RSCALC_C__ 0117 0118 #include "acpi.h" 0119 #include "accommon.h" 0120 #include "acresrc.h" 0121 #include "acnamesp.h" 0122 0123 0124 #define _COMPONENT ACPI_RESOURCES 0125 ACPI_MODULE_NAME ("rscalc") 0126 0127 0128 /* Local prototypes */ 0129 0130 static UINT8 0131 AcpiRsCountSetBits ( 0132 UINT16 BitField); 0133 0134 static ACPI_RS_LENGTH 0135 AcpiRsStructOptionLength ( 0136 ACPI_RESOURCE_SOURCE *ResourceSource); 0137 0138 static UINT32 0139 AcpiRsStreamOptionLength ( 0140 UINT32 ResourceLength, 0141 UINT32 MinimumTotalLength); 0142 0143 0144 /******************************************************************************* 0145 * 0146 * FUNCTION: AcpiRsCountSetBits 0147 * 0148 * PARAMETERS: BitField - Field in which to count bits 0149 * 0150 * RETURN: Number of bits set within the field 0151 * 0152 * DESCRIPTION: Count the number of bits set in a resource field. Used for 0153 * (Short descriptor) interrupt and DMA lists. 0154 * 0155 ******************************************************************************/ 0156 0157 static UINT8 0158 AcpiRsCountSetBits ( 0159 UINT16 BitField) 0160 { 0161 UINT8 BitsSet; 0162 0163 0164 ACPI_FUNCTION_ENTRY (); 0165 0166 0167 for (BitsSet = 0; BitField; BitsSet++) 0168 { 0169 /* Zero the least significant bit that is set */ 0170 0171 BitField &= (UINT16) (BitField - 1); 0172 } 0173 0174 return (BitsSet); 0175 } 0176 0177 0178 /******************************************************************************* 0179 * 0180 * FUNCTION: AcpiRsStructOptionLength 0181 * 0182 * PARAMETERS: ResourceSource - Pointer to optional descriptor field 0183 * 0184 * RETURN: Status 0185 * 0186 * DESCRIPTION: Common code to handle optional ResourceSourceIndex and 0187 * ResourceSource fields in some Large descriptors. Used during 0188 * list-to-stream conversion 0189 * 0190 ******************************************************************************/ 0191 0192 static ACPI_RS_LENGTH 0193 AcpiRsStructOptionLength ( 0194 ACPI_RESOURCE_SOURCE *ResourceSource) 0195 { 0196 ACPI_FUNCTION_ENTRY (); 0197 0198 0199 /* 0200 * If the ResourceSource string is valid, return the size of the string 0201 * (StringLength includes the NULL terminator) plus the size of the 0202 * ResourceSourceIndex (1). 0203 */ 0204 if (ResourceSource->StringPtr) 0205 { 0206 return ((ACPI_RS_LENGTH) (ResourceSource->StringLength + 1)); 0207 } 0208 0209 return (0); 0210 } 0211 0212 0213 /******************************************************************************* 0214 * 0215 * FUNCTION: AcpiRsStreamOptionLength 0216 * 0217 * PARAMETERS: ResourceLength - Length from the resource header 0218 * MinimumTotalLength - Minimum length of this resource, before 0219 * any optional fields. Includes header size 0220 * 0221 * RETURN: Length of optional string (0 if no string present) 0222 * 0223 * DESCRIPTION: Common code to handle optional ResourceSourceIndex and 0224 * ResourceSource fields in some Large descriptors. Used during 0225 * stream-to-list conversion 0226 * 0227 ******************************************************************************/ 0228 0229 static UINT32 0230 AcpiRsStreamOptionLength ( 0231 UINT32 ResourceLength, 0232 UINT32 MinimumAmlResourceLength) 0233 { 0234 UINT32 StringLength = 0; 0235 0236 0237 ACPI_FUNCTION_ENTRY (); 0238 0239 0240 /* 0241 * The ResourceSourceIndex and ResourceSource are optional elements of some 0242 * Large-type resource descriptors. 0243 */ 0244 0245 /* 0246 * If the length of the actual resource descriptor is greater than the ACPI 0247 * spec-defined minimum length, it means that a ResourceSourceIndex exists 0248 * and is followed by a (required) null terminated string. The string length 0249 * (including the null terminator) is the resource length minus the minimum 0250 * length, minus one byte for the ResourceSourceIndex itself. 0251 */ 0252 if (ResourceLength > MinimumAmlResourceLength) 0253 { 0254 /* Compute the length of the optional string */ 0255 0256 StringLength = ResourceLength - MinimumAmlResourceLength - 1; 0257 } 0258 0259 /* 0260 * Round the length up to a multiple of the native word in order to 0261 * guarantee that the entire resource descriptor is native word aligned 0262 */ 0263 return ((UINT32) ACPI_ROUND_UP_TO_NATIVE_WORD (StringLength)); 0264 } 0265 0266 0267 /******************************************************************************* 0268 * 0269 * FUNCTION: AcpiRsGetAmlLength 0270 * 0271 * PARAMETERS: Resource - Pointer to the resource linked list 0272 * SizeNeeded - Where the required size is returned 0273 * 0274 * RETURN: Status 0275 * 0276 * DESCRIPTION: Takes a linked list of internal resource descriptors and 0277 * calculates the size buffer needed to hold the corresponding 0278 * external resource byte stream. 0279 * 0280 ******************************************************************************/ 0281 0282 ACPI_STATUS 0283 AcpiRsGetAmlLength ( 0284 ACPI_RESOURCE *Resource, 0285 ACPI_SIZE *SizeNeeded) 0286 { 0287 ACPI_SIZE AmlSizeNeeded = 0; 0288 ACPI_RS_LENGTH TotalSize; 0289 0290 0291 ACPI_FUNCTION_TRACE (RsGetAmlLength); 0292 0293 0294 /* Traverse entire list of internal resource descriptors */ 0295 0296 while (Resource) 0297 { 0298 /* Validate the descriptor type */ 0299 0300 if (Resource->Type > ACPI_RESOURCE_TYPE_MAX) 0301 { 0302 return_ACPI_STATUS (AE_AML_INVALID_RESOURCE_TYPE); 0303 } 0304 0305 /* Get the base size of the (external stream) resource descriptor */ 0306 0307 TotalSize = AcpiGbl_AmlResourceSizes [Resource->Type]; 0308 0309 /* 0310 * Augment the base size for descriptors with optional and/or 0311 * variable-length fields 0312 */ 0313 switch (Resource->Type) 0314 { 0315 case ACPI_RESOURCE_TYPE_IRQ: 0316 0317 /* Length can be 3 or 2 */ 0318 0319 if (Resource->Data.Irq.DescriptorLength == 2) 0320 { 0321 TotalSize--; 0322 } 0323 break; 0324 0325 0326 case ACPI_RESOURCE_TYPE_START_DEPENDENT: 0327 0328 /* Length can be 1 or 0 */ 0329 0330 if (Resource->Data.Irq.DescriptorLength == 0) 0331 { 0332 TotalSize--; 0333 } 0334 break; 0335 0336 0337 case ACPI_RESOURCE_TYPE_VENDOR: 0338 /* 0339 * Vendor Defined Resource: 0340 * For a Vendor Specific resource, if the Length is between 1 and 7 0341 * it will be created as a Small Resource data type, otherwise it 0342 * is a Large Resource data type. 0343 */ 0344 if (Resource->Data.Vendor.ByteLength > 7) 0345 { 0346 /* Base size of a Large resource descriptor */ 0347 0348 TotalSize = sizeof (AML_RESOURCE_LARGE_HEADER); 0349 } 0350 0351 /* Add the size of the vendor-specific data */ 0352 0353 TotalSize = (ACPI_RS_LENGTH) 0354 (TotalSize + Resource->Data.Vendor.ByteLength); 0355 break; 0356 0357 0358 case ACPI_RESOURCE_TYPE_END_TAG: 0359 /* 0360 * End Tag: 0361 * We are done -- return the accumulated total size. 0362 */ 0363 *SizeNeeded = AmlSizeNeeded + TotalSize; 0364 0365 /* Normal exit */ 0366 0367 return_ACPI_STATUS (AE_OK); 0368 0369 0370 case ACPI_RESOURCE_TYPE_ADDRESS16: 0371 /* 0372 * 16-Bit Address Resource: 0373 * Add the size of the optional ResourceSource info 0374 */ 0375 TotalSize = (ACPI_RS_LENGTH) 0376 (TotalSize + AcpiRsStructOptionLength ( 0377 &Resource->Data.Address16.ResourceSource)); 0378 break; 0379 0380 0381 case ACPI_RESOURCE_TYPE_ADDRESS32: 0382 /* 0383 * 32-Bit Address Resource: 0384 * Add the size of the optional ResourceSource info 0385 */ 0386 TotalSize = (ACPI_RS_LENGTH) 0387 (TotalSize + AcpiRsStructOptionLength ( 0388 &Resource->Data.Address32.ResourceSource)); 0389 break; 0390 0391 0392 case ACPI_RESOURCE_TYPE_ADDRESS64: 0393 /* 0394 * 64-Bit Address Resource: 0395 * Add the size of the optional ResourceSource info 0396 */ 0397 TotalSize = (ACPI_RS_LENGTH) 0398 (TotalSize + AcpiRsStructOptionLength ( 0399 &Resource->Data.Address64.ResourceSource)); 0400 break; 0401 0402 0403 case ACPI_RESOURCE_TYPE_EXTENDED_IRQ: 0404 /* 0405 * Extended IRQ Resource: 0406 * Add the size of each additional optional interrupt beyond the 0407 * required 1 (4 bytes for each UINT32 interrupt number) 0408 */ 0409 TotalSize = (ACPI_RS_LENGTH) 0410 (TotalSize + 0411 ((Resource->Data.ExtendedIrq.InterruptCount - 1) * 4) + 0412 0413 /* Add the size of the optional ResourceSource info */ 0414 0415 AcpiRsStructOptionLength ( 0416 &Resource->Data.ExtendedIrq.ResourceSource)); 0417 break; 0418 0419 0420 default: 0421 break; 0422 } 0423 0424 /* Update the total */ 0425 0426 AmlSizeNeeded += TotalSize; 0427 0428 /* Point to the next object */ 0429 0430 Resource = ACPI_ADD_PTR (ACPI_RESOURCE, Resource, Resource->Length); 0431 } 0432 0433 /* Did not find an EndTag resource descriptor */ 0434 0435 return_ACPI_STATUS (AE_AML_NO_RESOURCE_END_TAG); 0436 } 0437 0438 0439 /******************************************************************************* 0440 * 0441 * FUNCTION: AcpiRsGetListLength 0442 * 0443 * PARAMETERS: AmlBuffer - Pointer to the resource byte stream 0444 * AmlBufferLength - Size of AmlBuffer 0445 * SizeNeeded - Where the size needed is returned 0446 * 0447 * RETURN: Status 0448 * 0449 * DESCRIPTION: Takes an external resource byte stream and calculates the size 0450 * buffer needed to hold the corresponding internal resource 0451 * descriptor linked list. 0452 * 0453 ******************************************************************************/ 0454 0455 ACPI_STATUS 0456 AcpiRsGetListLength ( 0457 UINT8 *AmlBuffer, 0458 UINT32 AmlBufferLength, 0459 ACPI_SIZE *SizeNeeded) 0460 { 0461 ACPI_STATUS Status; 0462 UINT8 *EndAml; 0463 UINT8 *Buffer; 0464 UINT32 BufferSize; 0465 UINT16 Temp16; 0466 UINT16 ResourceLength; 0467 UINT32 ExtraStructBytes; 0468 UINT8 ResourceIndex; 0469 UINT8 MinimumAmlResourceLength; 0470 0471 0472 ACPI_FUNCTION_TRACE (RsGetListLength); 0473 0474 0475 *SizeNeeded = 0; 0476 EndAml = AmlBuffer + AmlBufferLength; 0477 0478 /* Walk the list of AML resource descriptors */ 0479 0480 while (AmlBuffer < EndAml) 0481 { 0482 /* Validate the Resource Type and Resource Length */ 0483 0484 Status = AcpiUtValidateResource (AmlBuffer, &ResourceIndex); 0485 if (ACPI_FAILURE (Status)) 0486 { 0487 return_ACPI_STATUS (Status); 0488 } 0489 0490 /* Get the resource length and base (minimum) AML size */ 0491 0492 ResourceLength = AcpiUtGetResourceLength (AmlBuffer); 0493 MinimumAmlResourceLength = AcpiGbl_ResourceAmlSizes[ResourceIndex]; 0494 0495 /* 0496 * Augment the size for descriptors with optional 0497 * and/or variable length fields 0498 */ 0499 ExtraStructBytes = 0; 0500 Buffer = AmlBuffer + AcpiUtGetResourceHeaderLength (AmlBuffer); 0501 0502 switch (AcpiUtGetResourceType (AmlBuffer)) 0503 { 0504 case ACPI_RESOURCE_NAME_IRQ: 0505 /* 0506 * IRQ Resource: 0507 * Get the number of bits set in the 16-bit IRQ mask 0508 */ 0509 ACPI_MOVE_16_TO_16 (&Temp16, Buffer); 0510 ExtraStructBytes = AcpiRsCountSetBits (Temp16); 0511 break; 0512 0513 0514 case ACPI_RESOURCE_NAME_DMA: 0515 /* 0516 * DMA Resource: 0517 * Get the number of bits set in the 8-bit DMA mask 0518 */ 0519 ExtraStructBytes = AcpiRsCountSetBits (*Buffer); 0520 break; 0521 0522 0523 case ACPI_RESOURCE_NAME_VENDOR_SMALL: 0524 case ACPI_RESOURCE_NAME_VENDOR_LARGE: 0525 /* 0526 * Vendor Resource: 0527 * Get the number of vendor data bytes 0528 */ 0529 ExtraStructBytes = ResourceLength; 0530 break; 0531 0532 0533 case ACPI_RESOURCE_NAME_END_TAG: 0534 /* 0535 * End Tag: 0536 * This is the normal exit, add size of EndTag 0537 */ 0538 *SizeNeeded += ACPI_RS_SIZE_MIN; 0539 return_ACPI_STATUS (AE_OK); 0540 0541 0542 case ACPI_RESOURCE_NAME_ADDRESS32: 0543 case ACPI_RESOURCE_NAME_ADDRESS16: 0544 case ACPI_RESOURCE_NAME_ADDRESS64: 0545 /* 0546 * Address Resource: 0547 * Add the size of the optional ResourceSource 0548 */ 0549 ExtraStructBytes = AcpiRsStreamOptionLength ( 0550 ResourceLength, MinimumAmlResourceLength); 0551 break; 0552 0553 0554 case ACPI_RESOURCE_NAME_EXTENDED_IRQ: 0555 /* 0556 * Extended IRQ Resource: 0557 * Using the InterruptTableLength, add 4 bytes for each additional 0558 * interrupt. Note: at least one interrupt is required and is 0559 * included in the minimum descriptor size (reason for the -1) 0560 */ 0561 ExtraStructBytes = (Buffer[1] - 1) * sizeof (UINT32); 0562 0563 /* Add the size of the optional ResourceSource */ 0564 0565 ExtraStructBytes += AcpiRsStreamOptionLength ( 0566 ResourceLength - ExtraStructBytes, MinimumAmlResourceLength); 0567 break; 0568 0569 0570 default: 0571 break; 0572 } 0573 0574 /* 0575 * Update the required buffer size for the internal descriptor structs 0576 * 0577 * Important: Round the size up for the appropriate alignment. This 0578 * is a requirement on IA64. 0579 */ 0580 BufferSize = AcpiGbl_ResourceStructSizes[ResourceIndex] + 0581 ExtraStructBytes; 0582 BufferSize = (UINT32) ACPI_ROUND_UP_TO_NATIVE_WORD (BufferSize); 0583 0584 *SizeNeeded += BufferSize; 0585 0586 ACPI_DEBUG_PRINT ((ACPI_DB_RESOURCES, 0587 "Type %.2X, AmlLength %.2X InternalLength %.2X\n", 0588 AcpiUtGetResourceType (AmlBuffer), 0589 AcpiUtGetDescriptorLength (AmlBuffer), BufferSize)); 0590 0591 /* 0592 * Point to the next resource within the AML stream using the length 0593 * contained in the resource descriptor header 0594 */ 0595 AmlBuffer += AcpiUtGetDescriptorLength (AmlBuffer); 0596 } 0597 0598 /* Did not find an EndTag resource descriptor */ 0599 0600 return_ACPI_STATUS (AE_AML_NO_RESOURCE_END_TAG); 0601 } 0602 0603 0604 /******************************************************************************* 0605 * 0606 * FUNCTION: AcpiRsGetPciRoutingTableLength 0607 * 0608 * PARAMETERS: PackageObject - Pointer to the package object 0609 * BufferSizeNeeded - UINT32 pointer of the size buffer 0610 * needed to properly return the 0611 * parsed data 0612 * 0613 * RETURN: Status 0614 * 0615 * DESCRIPTION: Given a package representing a PCI routing table, this 0616 * calculates the size of the corresponding linked list of 0617 * descriptions. 0618 * 0619 ******************************************************************************/ 0620 0621 ACPI_STATUS 0622 AcpiRsGetPciRoutingTableLength ( 0623 ACPI_OPERAND_OBJECT *PackageObject, 0624 ACPI_SIZE *BufferSizeNeeded) 0625 { 0626 UINT32 NumberOfElements; 0627 ACPI_SIZE TempSizeNeeded = 0; 0628 ACPI_OPERAND_OBJECT **TopObjectList; 0629 UINT32 Index; 0630 ACPI_OPERAND_OBJECT *PackageElement; 0631 ACPI_OPERAND_OBJECT **SubObjectList; 0632 BOOLEAN NameFound; 0633 UINT32 TableIndex; 0634 0635 0636 ACPI_FUNCTION_TRACE (RsGetPciRoutingTableLength); 0637 0638 0639 NumberOfElements = PackageObject->Package.Count; 0640 0641 /* 0642 * Calculate the size of the return buffer. 0643 * The base size is the number of elements * the sizes of the 0644 * structures. Additional space for the strings is added below. 0645 * The minus one is to subtract the size of the UINT8 Source[1] 0646 * member because it is added below. 0647 * 0648 * But each PRT_ENTRY structure has a pointer to a string and 0649 * the size of that string must be found. 0650 */ 0651 TopObjectList = PackageObject->Package.Elements; 0652 0653 for (Index = 0; Index < NumberOfElements; Index++) 0654 { 0655 /* Dereference the sub-package */ 0656 0657 PackageElement = *TopObjectList; 0658 0659 /* We must have a valid Package object */ 0660 0661 if (!PackageElement || 0662 (PackageElement->Common.Type != ACPI_TYPE_PACKAGE)) 0663 { 0664 return_ACPI_STATUS (AE_AML_OPERAND_TYPE); 0665 } 0666 0667 /* 0668 * The SubObjectList will now point to an array of the 0669 * four IRQ elements: Address, Pin, Source and SourceIndex 0670 */ 0671 SubObjectList = PackageElement->Package.Elements; 0672 0673 /* Scan the IrqTableElements for the Source Name String */ 0674 0675 NameFound = FALSE; 0676 0677 for (TableIndex = 0; TableIndex < 4 && !NameFound; TableIndex++) 0678 { 0679 if (*SubObjectList && /* Null object allowed */ 0680 0681 ((ACPI_TYPE_STRING == 0682 (*SubObjectList)->Common.Type) || 0683 0684 ((ACPI_TYPE_LOCAL_REFERENCE == 0685 (*SubObjectList)->Common.Type) && 0686 0687 ((*SubObjectList)->Reference.Class == 0688 ACPI_REFCLASS_NAME)))) 0689 { 0690 NameFound = TRUE; 0691 } 0692 else 0693 { 0694 /* Look at the next element */ 0695 0696 SubObjectList++; 0697 } 0698 } 0699 0700 TempSizeNeeded += (sizeof (ACPI_PCI_ROUTING_TABLE) - 4); 0701 0702 /* Was a String type found? */ 0703 0704 if (NameFound) 0705 { 0706 if ((*SubObjectList)->Common.Type == ACPI_TYPE_STRING) 0707 { 0708 /* 0709 * The length String.Length field does not include the 0710 * terminating NULL, add 1 0711 */ 0712 TempSizeNeeded += ((ACPI_SIZE) 0713 (*SubObjectList)->String.Length + 1); 0714 } 0715 else 0716 { 0717 TempSizeNeeded += AcpiNsGetPathnameLength ( 0718 (*SubObjectList)->Reference.Node); 0719 } 0720 } 0721 else 0722 { 0723 /* 0724 * If no name was found, then this is a NULL, which is 0725 * translated as a UINT32 zero. 0726 */ 0727 TempSizeNeeded += sizeof (UINT32); 0728 } 0729 0730 /* Round up the size since each element must be aligned */ 0731 0732 TempSizeNeeded = ACPI_ROUND_UP_TO_64BIT (TempSizeNeeded); 0733 0734 /* Point to the next ACPI_OPERAND_OBJECT */ 0735 0736 TopObjectList++; 0737 } 0738 0739 /* 0740 * Add an extra element to the end of the list, essentially a 0741 * NULL terminator 0742 */ 0743 *BufferSizeNeeded = TempSizeNeeded + sizeof (ACPI_PCI_ROUTING_TABLE); 0744 return_ACPI_STATUS (AE_OK); 0745 }
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 1.2.0 LXR engine. |