|
||||
Warning, cross-references for /kernel/drivers/acpica/utresrc.c need to be fixed.
0001 /******************************************************************************* 0002 * 0003 * Module Name: utresrc - Resource managment utilities 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 0117 #define __UTRESRC_C__ 0118 0119 #include "acpi.h" 0120 #include "accommon.h" 0121 #include "amlresrc.h" 0122 0123 0124 #define _COMPONENT ACPI_UTILITIES 0125 ACPI_MODULE_NAME ("utresrc") 0126 0127 0128 #if defined(ACPI_DISASSEMBLER) || defined (ACPI_DEBUGGER) 0129 0130 /* 0131 * Strings used to decode resource descriptors. 0132 * Used by both the disasssembler and the debugger resource dump routines 0133 */ 0134 const char *AcpiGbl_BmDecode[] = 0135 { 0136 "NotBusMaster", 0137 "BusMaster" 0138 }; 0139 0140 const char *AcpiGbl_ConfigDecode[] = 0141 { 0142 "0 - Good Configuration", 0143 "1 - Acceptable Configuration", 0144 "2 - Suboptimal Configuration", 0145 "3 - ***Invalid Configuration***", 0146 }; 0147 0148 const char *AcpiGbl_ConsumeDecode[] = 0149 { 0150 "ResourceProducer", 0151 "ResourceConsumer" 0152 }; 0153 0154 const char *AcpiGbl_DecDecode[] = 0155 { 0156 "PosDecode", 0157 "SubDecode" 0158 }; 0159 0160 const char *AcpiGbl_HeDecode[] = 0161 { 0162 "Level", 0163 "Edge" 0164 }; 0165 0166 const char *AcpiGbl_IoDecode[] = 0167 { 0168 "Decode10", 0169 "Decode16" 0170 }; 0171 0172 const char *AcpiGbl_LlDecode[] = 0173 { 0174 "ActiveHigh", 0175 "ActiveLow" 0176 }; 0177 0178 const char *AcpiGbl_MaxDecode[] = 0179 { 0180 "MaxNotFixed", 0181 "MaxFixed" 0182 }; 0183 0184 const char *AcpiGbl_MemDecode[] = 0185 { 0186 "NonCacheable", 0187 "Cacheable", 0188 "WriteCombining", 0189 "Prefetchable" 0190 }; 0191 0192 const char *AcpiGbl_MinDecode[] = 0193 { 0194 "MinNotFixed", 0195 "MinFixed" 0196 }; 0197 0198 const char *AcpiGbl_MtpDecode[] = 0199 { 0200 "AddressRangeMemory", 0201 "AddressRangeReserved", 0202 "AddressRangeACPI", 0203 "AddressRangeNVS" 0204 }; 0205 0206 const char *AcpiGbl_RngDecode[] = 0207 { 0208 "InvalidRanges", 0209 "NonISAOnlyRanges", 0210 "ISAOnlyRanges", 0211 "EntireRange" 0212 }; 0213 0214 const char *AcpiGbl_RwDecode[] = 0215 { 0216 "ReadOnly", 0217 "ReadWrite" 0218 }; 0219 0220 const char *AcpiGbl_ShrDecode[] = 0221 { 0222 "Exclusive", 0223 "Shared" 0224 }; 0225 0226 const char *AcpiGbl_SizDecode[] = 0227 { 0228 "Transfer8", 0229 "Transfer8_16", 0230 "Transfer16", 0231 "InvalidSize" 0232 }; 0233 0234 const char *AcpiGbl_TrsDecode[] = 0235 { 0236 "DenseTranslation", 0237 "SparseTranslation" 0238 }; 0239 0240 const char *AcpiGbl_TtpDecode[] = 0241 { 0242 "TypeStatic", 0243 "TypeTranslation" 0244 }; 0245 0246 const char *AcpiGbl_TypDecode[] = 0247 { 0248 "Compatibility", 0249 "TypeA", 0250 "TypeB", 0251 "TypeF" 0252 }; 0253 0254 #endif 0255 0256 0257 /* 0258 * Base sizes of the raw AML resource descriptors, indexed by resource type. 0259 * Zero indicates a reserved (and therefore invalid) resource type. 0260 */ 0261 const UINT8 AcpiGbl_ResourceAmlSizes[] = 0262 { 0263 /* Small descriptors */ 0264 0265 0, 0266 0, 0267 0, 0268 0, 0269 ACPI_AML_SIZE_SMALL (AML_RESOURCE_IRQ), 0270 ACPI_AML_SIZE_SMALL (AML_RESOURCE_DMA), 0271 ACPI_AML_SIZE_SMALL (AML_RESOURCE_START_DEPENDENT), 0272 ACPI_AML_SIZE_SMALL (AML_RESOURCE_END_DEPENDENT), 0273 ACPI_AML_SIZE_SMALL (AML_RESOURCE_IO), 0274 ACPI_AML_SIZE_SMALL (AML_RESOURCE_FIXED_IO), 0275 0, 0276 0, 0277 0, 0278 0, 0279 ACPI_AML_SIZE_SMALL (AML_RESOURCE_VENDOR_SMALL), 0280 ACPI_AML_SIZE_SMALL (AML_RESOURCE_END_TAG), 0281 0282 /* Large descriptors */ 0283 0284 0, 0285 ACPI_AML_SIZE_LARGE (AML_RESOURCE_MEMORY24), 0286 ACPI_AML_SIZE_LARGE (AML_RESOURCE_GENERIC_REGISTER), 0287 0, 0288 ACPI_AML_SIZE_LARGE (AML_RESOURCE_VENDOR_LARGE), 0289 ACPI_AML_SIZE_LARGE (AML_RESOURCE_MEMORY32), 0290 ACPI_AML_SIZE_LARGE (AML_RESOURCE_FIXED_MEMORY32), 0291 ACPI_AML_SIZE_LARGE (AML_RESOURCE_ADDRESS32), 0292 ACPI_AML_SIZE_LARGE (AML_RESOURCE_ADDRESS16), 0293 ACPI_AML_SIZE_LARGE (AML_RESOURCE_EXTENDED_IRQ), 0294 ACPI_AML_SIZE_LARGE (AML_RESOURCE_ADDRESS64), 0295 ACPI_AML_SIZE_LARGE (AML_RESOURCE_EXTENDED_ADDRESS64) 0296 }; 0297 0298 0299 /* 0300 * Resource types, used to validate the resource length field. 0301 * The length of fixed-length types must match exactly, variable 0302 * lengths must meet the minimum required length, etc. 0303 * Zero indicates a reserved (and therefore invalid) resource type. 0304 */ 0305 static const UINT8 AcpiGbl_ResourceTypes[] = 0306 { 0307 /* Small descriptors */ 0308 0309 0, 0310 0, 0311 0, 0312 0, 0313 ACPI_SMALL_VARIABLE_LENGTH, 0314 ACPI_FIXED_LENGTH, 0315 ACPI_SMALL_VARIABLE_LENGTH, 0316 ACPI_FIXED_LENGTH, 0317 ACPI_FIXED_LENGTH, 0318 ACPI_FIXED_LENGTH, 0319 0, 0320 0, 0321 0, 0322 0, 0323 ACPI_VARIABLE_LENGTH, 0324 ACPI_FIXED_LENGTH, 0325 0326 /* Large descriptors */ 0327 0328 0, 0329 ACPI_FIXED_LENGTH, 0330 ACPI_FIXED_LENGTH, 0331 0, 0332 ACPI_VARIABLE_LENGTH, 0333 ACPI_FIXED_LENGTH, 0334 ACPI_FIXED_LENGTH, 0335 ACPI_VARIABLE_LENGTH, 0336 ACPI_VARIABLE_LENGTH, 0337 ACPI_VARIABLE_LENGTH, 0338 ACPI_VARIABLE_LENGTH, 0339 ACPI_FIXED_LENGTH 0340 }; 0341 0342 0343 /******************************************************************************* 0344 * 0345 * FUNCTION: AcpiUtWalkAmlResources 0346 * 0347 * PARAMETERS: Aml - Pointer to the raw AML resource template 0348 * AmlLength - Length of the entire template 0349 * UserFunction - Called once for each descriptor found. If 0350 * NULL, a pointer to the EndTag is returned 0351 * Context - Passed to UserFunction 0352 * 0353 * RETURN: Status 0354 * 0355 * DESCRIPTION: Walk a raw AML resource list(buffer). User function called 0356 * once for each resource found. 0357 * 0358 ******************************************************************************/ 0359 0360 ACPI_STATUS 0361 AcpiUtWalkAmlResources ( 0362 UINT8 *Aml, 0363 ACPI_SIZE AmlLength, 0364 ACPI_WALK_AML_CALLBACK UserFunction, 0365 void *Context) 0366 { 0367 ACPI_STATUS Status; 0368 UINT8 *EndAml; 0369 UINT8 ResourceIndex; 0370 UINT32 Length; 0371 UINT32 Offset = 0; 0372 0373 0374 ACPI_FUNCTION_TRACE (UtWalkAmlResources); 0375 0376 0377 /* The absolute minimum resource template is one EndTag descriptor */ 0378 0379 if (AmlLength < sizeof (AML_RESOURCE_END_TAG)) 0380 { 0381 return_ACPI_STATUS (AE_AML_NO_RESOURCE_END_TAG); 0382 } 0383 0384 /* Point to the end of the resource template buffer */ 0385 0386 EndAml = Aml + AmlLength; 0387 0388 /* Walk the byte list, abort on any invalid descriptor type or length */ 0389 0390 while (Aml < EndAml) 0391 { 0392 /* Validate the Resource Type and Resource Length */ 0393 0394 Status = AcpiUtValidateResource (Aml, &ResourceIndex); 0395 if (ACPI_FAILURE (Status)) 0396 { 0397 return_ACPI_STATUS (Status); 0398 } 0399 0400 /* Get the length of this descriptor */ 0401 0402 Length = AcpiUtGetDescriptorLength (Aml); 0403 0404 /* Invoke the user function */ 0405 0406 if (UserFunction) 0407 { 0408 Status = UserFunction (Aml, Length, Offset, ResourceIndex, Context); 0409 if (ACPI_FAILURE (Status)) 0410 { 0411 return (Status); 0412 } 0413 } 0414 0415 /* An EndTag descriptor terminates this resource template */ 0416 0417 if (AcpiUtGetResourceType (Aml) == ACPI_RESOURCE_NAME_END_TAG) 0418 { 0419 /* 0420 * There must be at least one more byte in the buffer for 0421 * the 2nd byte of the EndTag 0422 */ 0423 if ((Aml + 1) >= EndAml) 0424 { 0425 return_ACPI_STATUS (AE_AML_NO_RESOURCE_END_TAG); 0426 } 0427 0428 /* Return the pointer to the EndTag if requested */ 0429 0430 if (!UserFunction) 0431 { 0432 *(void **) Context = Aml; 0433 } 0434 0435 /* Normal exit */ 0436 0437 return_ACPI_STATUS (AE_OK); 0438 } 0439 0440 Aml += Length; 0441 Offset += Length; 0442 } 0443 0444 /* Did not find an EndTag descriptor */ 0445 0446 return (AE_AML_NO_RESOURCE_END_TAG); 0447 } 0448 0449 0450 /******************************************************************************* 0451 * 0452 * FUNCTION: AcpiUtValidateResource 0453 * 0454 * PARAMETERS: Aml - Pointer to the raw AML resource descriptor 0455 * ReturnIndex - Where the resource index is returned. NULL 0456 * if the index is not required. 0457 * 0458 * RETURN: Status, and optionally the Index into the global resource tables 0459 * 0460 * DESCRIPTION: Validate an AML resource descriptor by checking the Resource 0461 * Type and Resource Length. Returns an index into the global 0462 * resource information/dispatch tables for later use. 0463 * 0464 ******************************************************************************/ 0465 0466 ACPI_STATUS 0467 AcpiUtValidateResource ( 0468 void *Aml, 0469 UINT8 *ReturnIndex) 0470 { 0471 UINT8 ResourceType; 0472 UINT8 ResourceIndex; 0473 ACPI_RS_LENGTH ResourceLength; 0474 ACPI_RS_LENGTH MinimumResourceLength; 0475 0476 0477 ACPI_FUNCTION_ENTRY (); 0478 0479 0480 /* 0481 * 1) Validate the ResourceType field (Byte 0) 0482 */ 0483 ResourceType = ACPI_GET8 (Aml); 0484 0485 /* 0486 * Byte 0 contains the descriptor name (Resource Type) 0487 * Examine the large/small bit in the resource header 0488 */ 0489 if (ResourceType & ACPI_RESOURCE_NAME_LARGE) 0490 { 0491 /* Verify the large resource type (name) against the max */ 0492 0493 if (ResourceType > ACPI_RESOURCE_NAME_LARGE_MAX) 0494 { 0495 return (AE_AML_INVALID_RESOURCE_TYPE); 0496 } 0497 0498 /* 0499 * Large Resource Type -- bits 6:0 contain the name 0500 * Translate range 0x80-0x8B to index range 0x10-0x1B 0501 */ 0502 ResourceIndex = (UINT8) (ResourceType - 0x70); 0503 } 0504 else 0505 { 0506 /* 0507 * Small Resource Type -- bits 6:3 contain the name 0508 * Shift range to index range 0x00-0x0F 0509 */ 0510 ResourceIndex = (UINT8) 0511 ((ResourceType & ACPI_RESOURCE_NAME_SMALL_MASK) >> 3); 0512 } 0513 0514 /* Check validity of the resource type, zero indicates name is invalid */ 0515 0516 if (!AcpiGbl_ResourceTypes[ResourceIndex]) 0517 { 0518 return (AE_AML_INVALID_RESOURCE_TYPE); 0519 } 0520 0521 0522 /* 0523 * 2) Validate the ResourceLength field. This ensures that the length 0524 * is at least reasonable, and guarantees that it is non-zero. 0525 */ 0526 ResourceLength = AcpiUtGetResourceLength (Aml); 0527 MinimumResourceLength = AcpiGbl_ResourceAmlSizes[ResourceIndex]; 0528 0529 /* Validate based upon the type of resource - fixed length or variable */ 0530 0531 switch (AcpiGbl_ResourceTypes[ResourceIndex]) 0532 { 0533 case ACPI_FIXED_LENGTH: 0534 0535 /* Fixed length resource, length must match exactly */ 0536 0537 if (ResourceLength != MinimumResourceLength) 0538 { 0539 return (AE_AML_BAD_RESOURCE_LENGTH); 0540 } 0541 break; 0542 0543 case ACPI_VARIABLE_LENGTH: 0544 0545 /* Variable length resource, length must be at least the minimum */ 0546 0547 if (ResourceLength < MinimumResourceLength) 0548 { 0549 return (AE_AML_BAD_RESOURCE_LENGTH); 0550 } 0551 break; 0552 0553 case ACPI_SMALL_VARIABLE_LENGTH: 0554 0555 /* Small variable length resource, length can be (Min) or (Min-1) */ 0556 0557 if ((ResourceLength > MinimumResourceLength) || 0558 (ResourceLength < (MinimumResourceLength - 1))) 0559 { 0560 return (AE_AML_BAD_RESOURCE_LENGTH); 0561 } 0562 break; 0563 0564 default: 0565 0566 /* Shouldn't happen (because of validation earlier), but be sure */ 0567 0568 return (AE_AML_INVALID_RESOURCE_TYPE); 0569 } 0570 0571 /* Optionally return the resource table index */ 0572 0573 if (ReturnIndex) 0574 { 0575 *ReturnIndex = ResourceIndex; 0576 } 0577 0578 return (AE_OK); 0579 } 0580 0581 0582 /******************************************************************************* 0583 * 0584 * FUNCTION: AcpiUtGetResourceType 0585 * 0586 * PARAMETERS: Aml - Pointer to the raw AML resource descriptor 0587 * 0588 * RETURN: The Resource Type with no extraneous bits (except the 0589 * Large/Small descriptor bit -- this is left alone) 0590 * 0591 * DESCRIPTION: Extract the Resource Type/Name from the first byte of 0592 * a resource descriptor. 0593 * 0594 ******************************************************************************/ 0595 0596 UINT8 0597 AcpiUtGetResourceType ( 0598 void *Aml) 0599 { 0600 ACPI_FUNCTION_ENTRY (); 0601 0602 0603 /* 0604 * Byte 0 contains the descriptor name (Resource Type) 0605 * Examine the large/small bit in the resource header 0606 */ 0607 if (ACPI_GET8 (Aml) & ACPI_RESOURCE_NAME_LARGE) 0608 { 0609 /* Large Resource Type -- bits 6:0 contain the name */ 0610 0611 return (ACPI_GET8 (Aml)); 0612 } 0613 else 0614 { 0615 /* Small Resource Type -- bits 6:3 contain the name */ 0616 0617 return ((UINT8) (ACPI_GET8 (Aml) & ACPI_RESOURCE_NAME_SMALL_MASK)); 0618 } 0619 } 0620 0621 0622 /******************************************************************************* 0623 * 0624 * FUNCTION: AcpiUtGetResourceLength 0625 * 0626 * PARAMETERS: Aml - Pointer to the raw AML resource descriptor 0627 * 0628 * RETURN: Byte Length 0629 * 0630 * DESCRIPTION: Get the "Resource Length" of a raw AML descriptor. By 0631 * definition, this does not include the size of the descriptor 0632 * header or the length field itself. 0633 * 0634 ******************************************************************************/ 0635 0636 UINT16 0637 AcpiUtGetResourceLength ( 0638 void *Aml) 0639 { 0640 ACPI_RS_LENGTH ResourceLength; 0641 0642 0643 ACPI_FUNCTION_ENTRY (); 0644 0645 0646 /* 0647 * Byte 0 contains the descriptor name (Resource Type) 0648 * Examine the large/small bit in the resource header 0649 */ 0650 if (ACPI_GET8 (Aml) & ACPI_RESOURCE_NAME_LARGE) 0651 { 0652 /* Large Resource type -- bytes 1-2 contain the 16-bit length */ 0653 0654 ACPI_MOVE_16_TO_16 (&ResourceLength, ACPI_ADD_PTR (UINT8, Aml, 1)); 0655 0656 } 0657 else 0658 { 0659 /* Small Resource type -- bits 2:0 of byte 0 contain the length */ 0660 0661 ResourceLength = (UINT16) (ACPI_GET8 (Aml) & 0662 ACPI_RESOURCE_NAME_SMALL_LENGTH_MASK); 0663 } 0664 0665 return (ResourceLength); 0666 } 0667 0668 0669 /******************************************************************************* 0670 * 0671 * FUNCTION: AcpiUtGetResourceHeaderLength 0672 * 0673 * PARAMETERS: Aml - Pointer to the raw AML resource descriptor 0674 * 0675 * RETURN: Length of the AML header (depends on large/small descriptor) 0676 * 0677 * DESCRIPTION: Get the length of the header for this resource. 0678 * 0679 ******************************************************************************/ 0680 0681 UINT8 0682 AcpiUtGetResourceHeaderLength ( 0683 void *Aml) 0684 { 0685 ACPI_FUNCTION_ENTRY (); 0686 0687 0688 /* Examine the large/small bit in the resource header */ 0689 0690 if (ACPI_GET8 (Aml) & ACPI_RESOURCE_NAME_LARGE) 0691 { 0692 return (sizeof (AML_RESOURCE_LARGE_HEADER)); 0693 } 0694 else 0695 { 0696 return (sizeof (AML_RESOURCE_SMALL_HEADER)); 0697 } 0698 } 0699 0700 0701 /******************************************************************************* 0702 * 0703 * FUNCTION: AcpiUtGetDescriptorLength 0704 * 0705 * PARAMETERS: Aml - Pointer to the raw AML resource descriptor 0706 * 0707 * RETURN: Byte length 0708 * 0709 * DESCRIPTION: Get the total byte length of a raw AML descriptor, including the 0710 * length of the descriptor header and the length field itself. 0711 * Used to walk descriptor lists. 0712 * 0713 ******************************************************************************/ 0714 0715 UINT32 0716 AcpiUtGetDescriptorLength ( 0717 void *Aml) 0718 { 0719 ACPI_FUNCTION_ENTRY (); 0720 0721 0722 /* 0723 * Get the Resource Length (does not include header length) and add 0724 * the header length (depends on if this is a small or large resource) 0725 */ 0726 return (AcpiUtGetResourceLength (Aml) + 0727 AcpiUtGetResourceHeaderLength (Aml)); 0728 } 0729 0730 0731 /******************************************************************************* 0732 * 0733 * FUNCTION: AcpiUtGetResourceEndTag 0734 * 0735 * PARAMETERS: ObjDesc - The resource template buffer object 0736 * EndTag - Where the pointer to the EndTag is returned 0737 * 0738 * RETURN: Status, pointer to the end tag 0739 * 0740 * DESCRIPTION: Find the EndTag resource descriptor in an AML resource template 0741 * Note: allows a buffer length of zero. 0742 * 0743 ******************************************************************************/ 0744 0745 ACPI_STATUS 0746 AcpiUtGetResourceEndTag ( 0747 ACPI_OPERAND_OBJECT *ObjDesc, 0748 UINT8 **EndTag) 0749 { 0750 ACPI_STATUS Status; 0751 0752 0753 ACPI_FUNCTION_TRACE (UtGetResourceEndTag); 0754 0755 0756 /* Allow a buffer length of zero */ 0757 0758 if (!ObjDesc->Buffer.Length) 0759 { 0760 *EndTag = ObjDesc->Buffer.Pointer; 0761 return_ACPI_STATUS (AE_OK); 0762 } 0763 0764 /* Validate the template and get a pointer to the EndTag */ 0765 0766 Status = AcpiUtWalkAmlResources (ObjDesc->Buffer.Pointer, 0767 ObjDesc->Buffer.Length, NULL, EndTag); 0768 0769 return_ACPI_STATUS (Status); 0770 } 0771 0772
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 1.2.0 LXR engine. |