Home | Info | Community | Development | myReactOS | Contact Us
ReactOS Development > Doxygenutresrc.c
Go to the documentation of this file.
00001 /******************************************************************************* 00002 * 00003 * Module Name: utresrc - Resource managment utilities 00004 * 00005 ******************************************************************************/ 00006 00007 /****************************************************************************** 00008 * 00009 * 1. Copyright Notice 00010 * 00011 * Some or all of this work - Copyright (c) 1999 - 2011, Intel Corp. 00012 * All rights reserved. 00013 * 00014 * 2. License 00015 * 00016 * 2.1. This is your license from Intel Corp. under its intellectual property 00017 * rights. You may have additional license terms from the party that provided 00018 * you this software, covering your right to use that party's intellectual 00019 * property rights. 00020 * 00021 * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a 00022 * copy of the source code appearing in this file ("Covered Code") an 00023 * irrevocable, perpetual, worldwide license under Intel's copyrights in the 00024 * base code distributed originally by Intel ("Original Intel Code") to copy, 00025 * make derivatives, distribute, use and display any portion of the Covered 00026 * Code in any form, with the right to sublicense such rights; and 00027 * 00028 * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent 00029 * license (with the right to sublicense), under only those claims of Intel 00030 * patents that are infringed by the Original Intel Code, to make, use, sell, 00031 * offer to sell, and import the Covered Code and derivative works thereof 00032 * solely to the minimum extent necessary to exercise the above copyright 00033 * license, and in no event shall the patent license extend to any additions 00034 * to or modifications of the Original Intel Code. No other license or right 00035 * is granted directly or by implication, estoppel or otherwise; 00036 * 00037 * The above copyright and patent license is granted only if the following 00038 * conditions are met: 00039 * 00040 * 3. Conditions 00041 * 00042 * 3.1. Redistribution of Source with Rights to Further Distribute Source. 00043 * Redistribution of source code of any substantial portion of the Covered 00044 * Code or modification with rights to further distribute source must include 00045 * the above Copyright Notice, the above License, this list of Conditions, 00046 * and the following Disclaimer and Export Compliance provision. In addition, 00047 * Licensee must cause all Covered Code to which Licensee contributes to 00048 * contain a file documenting the changes Licensee made to create that Covered 00049 * Code and the date of any change. Licensee must include in that file the 00050 * documentation of any changes made by any predecessor Licensee. Licensee 00051 * must include a prominent statement that the modification is derived, 00052 * directly or indirectly, from Original Intel Code. 00053 * 00054 * 3.2. Redistribution of Source with no Rights to Further Distribute Source. 00055 * Redistribution of source code of any substantial portion of the Covered 00056 * Code or modification without rights to further distribute source must 00057 * include the following Disclaimer and Export Compliance provision in the 00058 * documentation and/or other materials provided with distribution. In 00059 * addition, Licensee may not authorize further sublicense of source of any 00060 * portion of the Covered Code, and must include terms to the effect that the 00061 * license from Licensee to its licensee is limited to the intellectual 00062 * property embodied in the software Licensee provides to its licensee, and 00063 * not to intellectual property embodied in modifications its licensee may 00064 * make. 00065 * 00066 * 3.3. Redistribution of Executable. Redistribution in executable form of any 00067 * substantial portion of the Covered Code or modification must reproduce the 00068 * above Copyright Notice, and the following Disclaimer and Export Compliance 00069 * provision in the documentation and/or other materials provided with the 00070 * distribution. 00071 * 00072 * 3.4. Intel retains all right, title, and interest in and to the Original 00073 * Intel Code. 00074 * 00075 * 3.5. Neither the name Intel nor any other trademark owned or controlled by 00076 * Intel shall be used in advertising or otherwise to promote the sale, use or 00077 * other dealings in products derived from or relating to the Covered Code 00078 * without prior written authorization from Intel. 00079 * 00080 * 4. Disclaimer and Export Compliance 00081 * 00082 * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED 00083 * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE 00084 * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, 00085 * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY 00086 * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY 00087 * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A 00088 * PARTICULAR PURPOSE. 00089 * 00090 * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES 00091 * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR 00092 * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, 00093 * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY 00094 * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL 00095 * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS 00096 * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY 00097 * LIMITED REMEDY. 00098 * 00099 * 4.3. Licensee shall not export, either directly or indirectly, any of this 00100 * software or system incorporating such software without first obtaining any 00101 * required license or other approval from the U. S. Department of Commerce or 00102 * any other agency or department of the United States Government. In the 00103 * event Licensee exports any such software from the United States or 00104 * re-exports any such software from a foreign destination, Licensee shall 00105 * ensure that the distribution and export/re-export of the software is in 00106 * compliance with all laws, regulations, orders, or other restrictions of the 00107 * U.S. Export Administration Regulations. Licensee agrees that neither it nor 00108 * any of its subsidiaries will export/re-export any technical data, process, 00109 * software, or service, directly or indirectly, to any country for which the 00110 * United States government or any agency thereof requires an export license, 00111 * other governmental approval, or letter of assurance, without first obtaining 00112 * such license, approval or letter. 00113 * 00114 *****************************************************************************/ 00115 00116 00117 #define __UTRESRC_C__ 00118 00119 #include "acpi.h" 00120 #include "accommon.h" 00121 #include "amlresrc.h" 00122 00123 00124 #define _COMPONENT ACPI_UTILITIES 00125 ACPI_MODULE_NAME ("utresrc") 00126 00127 00128 #if defined(ACPI_DISASSEMBLER) || defined (ACPI_DEBUGGER) 00129 00130 /* 00131 * Strings used to decode resource descriptors. 00132 * Used by both the disasssembler and the debugger resource dump routines 00133 */ 00134 const char *AcpiGbl_BmDecode[] = 00135 { 00136 "NotBusMaster", 00137 "BusMaster" 00138 }; 00139 00140 const char *AcpiGbl_ConfigDecode[] = 00141 { 00142 "0 - Good Configuration", 00143 "1 - Acceptable Configuration", 00144 "2 - Suboptimal Configuration", 00145 "3 - ***Invalid Configuration***", 00146 }; 00147 00148 const char *AcpiGbl_ConsumeDecode[] = 00149 { 00150 "ResourceProducer", 00151 "ResourceConsumer" 00152 }; 00153 00154 const char *AcpiGbl_DecDecode[] = 00155 { 00156 "PosDecode", 00157 "SubDecode" 00158 }; 00159 00160 const char *AcpiGbl_HeDecode[] = 00161 { 00162 "Level", 00163 "Edge" 00164 }; 00165 00166 const char *AcpiGbl_IoDecode[] = 00167 { 00168 "Decode10", 00169 "Decode16" 00170 }; 00171 00172 const char *AcpiGbl_LlDecode[] = 00173 { 00174 "ActiveHigh", 00175 "ActiveLow" 00176 }; 00177 00178 const char *AcpiGbl_MaxDecode[] = 00179 { 00180 "MaxNotFixed", 00181 "MaxFixed" 00182 }; 00183 00184 const char *AcpiGbl_MemDecode[] = 00185 { 00186 "NonCacheable", 00187 "Cacheable", 00188 "WriteCombining", 00189 "Prefetchable" 00190 }; 00191 00192 const char *AcpiGbl_MinDecode[] = 00193 { 00194 "MinNotFixed", 00195 "MinFixed" 00196 }; 00197 00198 const char *AcpiGbl_MtpDecode[] = 00199 { 00200 "AddressRangeMemory", 00201 "AddressRangeReserved", 00202 "AddressRangeACPI", 00203 "AddressRangeNVS" 00204 }; 00205 00206 const char *AcpiGbl_RngDecode[] = 00207 { 00208 "InvalidRanges", 00209 "NonISAOnlyRanges", 00210 "ISAOnlyRanges", 00211 "EntireRange" 00212 }; 00213 00214 const char *AcpiGbl_RwDecode[] = 00215 { 00216 "ReadOnly", 00217 "ReadWrite" 00218 }; 00219 00220 const char *AcpiGbl_ShrDecode[] = 00221 { 00222 "Exclusive", 00223 "Shared" 00224 }; 00225 00226 const char *AcpiGbl_SizDecode[] = 00227 { 00228 "Transfer8", 00229 "Transfer8_16", 00230 "Transfer16", 00231 "InvalidSize" 00232 }; 00233 00234 const char *AcpiGbl_TrsDecode[] = 00235 { 00236 "DenseTranslation", 00237 "SparseTranslation" 00238 }; 00239 00240 const char *AcpiGbl_TtpDecode[] = 00241 { 00242 "TypeStatic", 00243 "TypeTranslation" 00244 }; 00245 00246 const char *AcpiGbl_TypDecode[] = 00247 { 00248 "Compatibility", 00249 "TypeA", 00250 "TypeB", 00251 "TypeF" 00252 }; 00253 00254 #endif 00255 00256 00257 /* 00258 * Base sizes of the raw AML resource descriptors, indexed by resource type. 00259 * Zero indicates a reserved (and therefore invalid) resource type. 00260 */ 00261 const UINT8 AcpiGbl_ResourceAmlSizes[] = 00262 { 00263 /* Small descriptors */ 00264 00265 0, 00266 0, 00267 0, 00268 0, 00269 ACPI_AML_SIZE_SMALL (AML_RESOURCE_IRQ), 00270 ACPI_AML_SIZE_SMALL (AML_RESOURCE_DMA), 00271 ACPI_AML_SIZE_SMALL (AML_RESOURCE_START_DEPENDENT), 00272 ACPI_AML_SIZE_SMALL (AML_RESOURCE_END_DEPENDENT), 00273 ACPI_AML_SIZE_SMALL (AML_RESOURCE_IO), 00274 ACPI_AML_SIZE_SMALL (AML_RESOURCE_FIXED_IO), 00275 0, 00276 0, 00277 0, 00278 0, 00279 ACPI_AML_SIZE_SMALL (AML_RESOURCE_VENDOR_SMALL), 00280 ACPI_AML_SIZE_SMALL (AML_RESOURCE_END_TAG), 00281 00282 /* Large descriptors */ 00283 00284 0, 00285 ACPI_AML_SIZE_LARGE (AML_RESOURCE_MEMORY24), 00286 ACPI_AML_SIZE_LARGE (AML_RESOURCE_GENERIC_REGISTER), 00287 0, 00288 ACPI_AML_SIZE_LARGE (AML_RESOURCE_VENDOR_LARGE), 00289 ACPI_AML_SIZE_LARGE (AML_RESOURCE_MEMORY32), 00290 ACPI_AML_SIZE_LARGE (AML_RESOURCE_FIXED_MEMORY32), 00291 ACPI_AML_SIZE_LARGE (AML_RESOURCE_ADDRESS32), 00292 ACPI_AML_SIZE_LARGE (AML_RESOURCE_ADDRESS16), 00293 ACPI_AML_SIZE_LARGE (AML_RESOURCE_EXTENDED_IRQ), 00294 ACPI_AML_SIZE_LARGE (AML_RESOURCE_ADDRESS64), 00295 ACPI_AML_SIZE_LARGE (AML_RESOURCE_EXTENDED_ADDRESS64) 00296 }; 00297 00298 00299 /* 00300 * Resource types, used to validate the resource length field. 00301 * The length of fixed-length types must match exactly, variable 00302 * lengths must meet the minimum required length, etc. 00303 * Zero indicates a reserved (and therefore invalid) resource type. 00304 */ 00305 static const UINT8 AcpiGbl_ResourceTypes[] = 00306 { 00307 /* Small descriptors */ 00308 00309 0, 00310 0, 00311 0, 00312 0, 00313 ACPI_SMALL_VARIABLE_LENGTH, 00314 ACPI_FIXED_LENGTH, 00315 ACPI_SMALL_VARIABLE_LENGTH, 00316 ACPI_FIXED_LENGTH, 00317 ACPI_FIXED_LENGTH, 00318 ACPI_FIXED_LENGTH, 00319 0, 00320 0, 00321 0, 00322 0, 00323 ACPI_VARIABLE_LENGTH, 00324 ACPI_FIXED_LENGTH, 00325 00326 /* Large descriptors */ 00327 00328 0, 00329 ACPI_FIXED_LENGTH, 00330 ACPI_FIXED_LENGTH, 00331 0, 00332 ACPI_VARIABLE_LENGTH, 00333 ACPI_FIXED_LENGTH, 00334 ACPI_FIXED_LENGTH, 00335 ACPI_VARIABLE_LENGTH, 00336 ACPI_VARIABLE_LENGTH, 00337 ACPI_VARIABLE_LENGTH, 00338 ACPI_VARIABLE_LENGTH, 00339 ACPI_FIXED_LENGTH 00340 }; 00341 00342 00343 /******************************************************************************* 00344 * 00345 * FUNCTION: AcpiUtWalkAmlResources 00346 * 00347 * PARAMETERS: Aml - Pointer to the raw AML resource template 00348 * AmlLength - Length of the entire template 00349 * UserFunction - Called once for each descriptor found. If 00350 * NULL, a pointer to the EndTag is returned 00351 * Context - Passed to UserFunction 00352 * 00353 * RETURN: Status 00354 * 00355 * DESCRIPTION: Walk a raw AML resource list(buffer). User function called 00356 * once for each resource found. 00357 * 00358 ******************************************************************************/ 00359 00360 ACPI_STATUS 00361 AcpiUtWalkAmlResources ( 00362 UINT8 *Aml, 00363 ACPI_SIZE AmlLength, 00364 ACPI_WALK_AML_CALLBACK UserFunction, 00365 void *Context) 00366 { 00367 ACPI_STATUS Status; 00368 UINT8 *EndAml; 00369 UINT8 ResourceIndex; 00370 UINT32 Length; 00371 UINT32 Offset = 0; 00372 00373 00374 ACPI_FUNCTION_TRACE (UtWalkAmlResources); 00375 00376 00377 /* The absolute minimum resource template is one EndTag descriptor */ 00378 00379 if (AmlLength < sizeof (AML_RESOURCE_END_TAG)) 00380 { 00381 return_ACPI_STATUS (AE_AML_NO_RESOURCE_END_TAG); 00382 } 00383 00384 /* Point to the end of the resource template buffer */ 00385 00386 EndAml = Aml + AmlLength; 00387 00388 /* Walk the byte list, abort on any invalid descriptor type or length */ 00389 00390 while (Aml < EndAml) 00391 { 00392 /* Validate the Resource Type and Resource Length */ 00393 00394 Status = AcpiUtValidateResource (Aml, &ResourceIndex); 00395 if (ACPI_FAILURE (Status)) 00396 { 00397 return_ACPI_STATUS (Status); 00398 } 00399 00400 /* Get the length of this descriptor */ 00401 00402 Length = AcpiUtGetDescriptorLength (Aml); 00403 00404 /* Invoke the user function */ 00405 00406 if (UserFunction) 00407 { 00408 Status = UserFunction (Aml, Length, Offset, ResourceIndex, Context); 00409 if (ACPI_FAILURE (Status)) 00410 { 00411 return (Status); 00412 } 00413 } 00414 00415 /* An EndTag descriptor terminates this resource template */ 00416 00417 if (AcpiUtGetResourceType (Aml) == ACPI_RESOURCE_NAME_END_TAG) 00418 { 00419 /* 00420 * There must be at least one more byte in the buffer for 00421 * the 2nd byte of the EndTag 00422 */ 00423 if ((Aml + 1) >= EndAml) 00424 { 00425 return_ACPI_STATUS (AE_AML_NO_RESOURCE_END_TAG); 00426 } 00427 00428 /* Return the pointer to the EndTag if requested */ 00429 00430 if (!UserFunction) 00431 { 00432 *(void **) Context = Aml; 00433 } 00434 00435 /* Normal exit */ 00436 00437 return_ACPI_STATUS (AE_OK); 00438 } 00439 00440 Aml += Length; 00441 Offset += Length; 00442 } 00443 00444 /* Did not find an EndTag descriptor */ 00445 00446 return (AE_AML_NO_RESOURCE_END_TAG); 00447 } 00448 00449 00450 /******************************************************************************* 00451 * 00452 * FUNCTION: AcpiUtValidateResource 00453 * 00454 * PARAMETERS: Aml - Pointer to the raw AML resource descriptor 00455 * ReturnIndex - Where the resource index is returned. NULL 00456 * if the index is not required. 00457 * 00458 * RETURN: Status, and optionally the Index into the global resource tables 00459 * 00460 * DESCRIPTION: Validate an AML resource descriptor by checking the Resource 00461 * Type and Resource Length. Returns an index into the global 00462 * resource information/dispatch tables for later use. 00463 * 00464 ******************************************************************************/ 00465 00466 ACPI_STATUS 00467 AcpiUtValidateResource ( 00468 void *Aml, 00469 UINT8 *ReturnIndex) 00470 { 00471 UINT8 ResourceType; 00472 UINT8 ResourceIndex; 00473 ACPI_RS_LENGTH ResourceLength; 00474 ACPI_RS_LENGTH MinimumResourceLength; 00475 00476 00477 ACPI_FUNCTION_ENTRY (); 00478 00479 00480 /* 00481 * 1) Validate the ResourceType field (Byte 0) 00482 */ 00483 ResourceType = ACPI_GET8 (Aml); 00484 00485 /* 00486 * Byte 0 contains the descriptor name (Resource Type) 00487 * Examine the large/small bit in the resource header 00488 */ 00489 if (ResourceType & ACPI_RESOURCE_NAME_LARGE) 00490 { 00491 /* Verify the large resource type (name) against the max */ 00492 00493 if (ResourceType > ACPI_RESOURCE_NAME_LARGE_MAX) 00494 { 00495 return (AE_AML_INVALID_RESOURCE_TYPE); 00496 } 00497 00498 /* 00499 * Large Resource Type -- bits 6:0 contain the name 00500 * Translate range 0x80-0x8B to index range 0x10-0x1B 00501 */ 00502 ResourceIndex = (UINT8) (ResourceType - 0x70); 00503 } 00504 else 00505 { 00506 /* 00507 * Small Resource Type -- bits 6:3 contain the name 00508 * Shift range to index range 0x00-0x0F 00509 */ 00510 ResourceIndex = (UINT8) 00511 ((ResourceType & ACPI_RESOURCE_NAME_SMALL_MASK) >> 3); 00512 } 00513 00514 /* Check validity of the resource type, zero indicates name is invalid */ 00515 00516 if (!AcpiGbl_ResourceTypes[ResourceIndex]) 00517 { 00518 return (AE_AML_INVALID_RESOURCE_TYPE); 00519 } 00520 00521 00522 /* 00523 * 2) Validate the ResourceLength field. This ensures that the length 00524 * is at least reasonable, and guarantees that it is non-zero. 00525 */ 00526 ResourceLength = AcpiUtGetResourceLength (Aml); 00527 MinimumResourceLength = AcpiGbl_ResourceAmlSizes[ResourceIndex]; 00528 00529 /* Validate based upon the type of resource - fixed length or variable */ 00530 00531 switch (AcpiGbl_ResourceTypes[ResourceIndex]) 00532 { 00533 case ACPI_FIXED_LENGTH: 00534 00535 /* Fixed length resource, length must match exactly */ 00536 00537 if (ResourceLength != MinimumResourceLength) 00538 { 00539 return (AE_AML_BAD_RESOURCE_LENGTH); 00540 } 00541 break; 00542 00543 case ACPI_VARIABLE_LENGTH: 00544 00545 /* Variable length resource, length must be at least the minimum */ 00546 00547 if (ResourceLength < MinimumResourceLength) 00548 { 00549 return (AE_AML_BAD_RESOURCE_LENGTH); 00550 } 00551 break; 00552 00553 case ACPI_SMALL_VARIABLE_LENGTH: 00554 00555 /* Small variable length resource, length can be (Min) or (Min-1) */ 00556 00557 if ((ResourceLength > MinimumResourceLength) || 00558 (ResourceLength < (MinimumResourceLength - 1))) 00559 { 00560 return (AE_AML_BAD_RESOURCE_LENGTH); 00561 } 00562 break; 00563 00564 default: 00565 00566 /* Shouldn't happen (because of validation earlier), but be sure */ 00567 00568 return (AE_AML_INVALID_RESOURCE_TYPE); 00569 } 00570 00571 /* Optionally return the resource table index */ 00572 00573 if (ReturnIndex) 00574 { 00575 *ReturnIndex = ResourceIndex; 00576 } 00577 00578 return (AE_OK); 00579 } 00580 00581 00582 /******************************************************************************* 00583 * 00584 * FUNCTION: AcpiUtGetResourceType 00585 * 00586 * PARAMETERS: Aml - Pointer to the raw AML resource descriptor 00587 * 00588 * RETURN: The Resource Type with no extraneous bits (except the 00589 * Large/Small descriptor bit -- this is left alone) 00590 * 00591 * DESCRIPTION: Extract the Resource Type/Name from the first byte of 00592 * a resource descriptor. 00593 * 00594 ******************************************************************************/ 00595 00596 UINT8 00597 AcpiUtGetResourceType ( 00598 void *Aml) 00599 { 00600 ACPI_FUNCTION_ENTRY (); 00601 00602 00603 /* 00604 * Byte 0 contains the descriptor name (Resource Type) 00605 * Examine the large/small bit in the resource header 00606 */ 00607 if (ACPI_GET8 (Aml) & ACPI_RESOURCE_NAME_LARGE) 00608 { 00609 /* Large Resource Type -- bits 6:0 contain the name */ 00610 00611 return (ACPI_GET8 (Aml)); 00612 } 00613 else 00614 { 00615 /* Small Resource Type -- bits 6:3 contain the name */ 00616 00617 return ((UINT8) (ACPI_GET8 (Aml) & ACPI_RESOURCE_NAME_SMALL_MASK)); 00618 } 00619 } 00620 00621 00622 /******************************************************************************* 00623 * 00624 * FUNCTION: AcpiUtGetResourceLength 00625 * 00626 * PARAMETERS: Aml - Pointer to the raw AML resource descriptor 00627 * 00628 * RETURN: Byte Length 00629 * 00630 * DESCRIPTION: Get the "Resource Length" of a raw AML descriptor. By 00631 * definition, this does not include the size of the descriptor 00632 * header or the length field itself. 00633 * 00634 ******************************************************************************/ 00635 00636 UINT16 00637 AcpiUtGetResourceLength ( 00638 void *Aml) 00639 { 00640 ACPI_RS_LENGTH ResourceLength; 00641 00642 00643 ACPI_FUNCTION_ENTRY (); 00644 00645 00646 /* 00647 * Byte 0 contains the descriptor name (Resource Type) 00648 * Examine the large/small bit in the resource header 00649 */ 00650 if (ACPI_GET8 (Aml) & ACPI_RESOURCE_NAME_LARGE) 00651 { 00652 /* Large Resource type -- bytes 1-2 contain the 16-bit length */ 00653 00654 ACPI_MOVE_16_TO_16 (&ResourceLength, ACPI_ADD_PTR (UINT8, Aml, 1)); 00655 00656 } 00657 else 00658 { 00659 /* Small Resource type -- bits 2:0 of byte 0 contain the length */ 00660 00661 ResourceLength = (UINT16) (ACPI_GET8 (Aml) & 00662 ACPI_RESOURCE_NAME_SMALL_LENGTH_MASK); 00663 } 00664 00665 return (ResourceLength); 00666 } 00667 00668 00669 /******************************************************************************* 00670 * 00671 * FUNCTION: AcpiUtGetResourceHeaderLength 00672 * 00673 * PARAMETERS: Aml - Pointer to the raw AML resource descriptor 00674 * 00675 * RETURN: Length of the AML header (depends on large/small descriptor) 00676 * 00677 * DESCRIPTION: Get the length of the header for this resource. 00678 * 00679 ******************************************************************************/ 00680 00681 UINT8 00682 AcpiUtGetResourceHeaderLength ( 00683 void *Aml) 00684 { 00685 ACPI_FUNCTION_ENTRY (); 00686 00687 00688 /* Examine the large/small bit in the resource header */ 00689 00690 if (ACPI_GET8 (Aml) & ACPI_RESOURCE_NAME_LARGE) 00691 { 00692 return (sizeof (AML_RESOURCE_LARGE_HEADER)); 00693 } 00694 else 00695 { 00696 return (sizeof (AML_RESOURCE_SMALL_HEADER)); 00697 } 00698 } 00699 00700 00701 /******************************************************************************* 00702 * 00703 * FUNCTION: AcpiUtGetDescriptorLength 00704 * 00705 * PARAMETERS: Aml - Pointer to the raw AML resource descriptor 00706 * 00707 * RETURN: Byte length 00708 * 00709 * DESCRIPTION: Get the total byte length of a raw AML descriptor, including the 00710 * length of the descriptor header and the length field itself. 00711 * Used to walk descriptor lists. 00712 * 00713 ******************************************************************************/ 00714 00715 UINT32 00716 AcpiUtGetDescriptorLength ( 00717 void *Aml) 00718 { 00719 ACPI_FUNCTION_ENTRY (); 00720 00721 00722 /* 00723 * Get the Resource Length (does not include header length) and add 00724 * the header length (depends on if this is a small or large resource) 00725 */ 00726 return (AcpiUtGetResourceLength (Aml) + 00727 AcpiUtGetResourceHeaderLength (Aml)); 00728 } 00729 00730 00731 /******************************************************************************* 00732 * 00733 * FUNCTION: AcpiUtGetResourceEndTag 00734 * 00735 * PARAMETERS: ObjDesc - The resource template buffer object 00736 * EndTag - Where the pointer to the EndTag is returned 00737 * 00738 * RETURN: Status, pointer to the end tag 00739 * 00740 * DESCRIPTION: Find the EndTag resource descriptor in an AML resource template 00741 * Note: allows a buffer length of zero. 00742 * 00743 ******************************************************************************/ 00744 00745 ACPI_STATUS 00746 AcpiUtGetResourceEndTag ( 00747 ACPI_OPERAND_OBJECT *ObjDesc, 00748 UINT8 **EndTag) 00749 { 00750 ACPI_STATUS Status; 00751 00752 00753 ACPI_FUNCTION_TRACE (UtGetResourceEndTag); 00754 00755 00756 /* Allow a buffer length of zero */ 00757 00758 if (!ObjDesc->Buffer.Length) 00759 { 00760 *EndTag = ObjDesc->Buffer.Pointer; 00761 return_ACPI_STATUS (AE_OK); 00762 } 00763 00764 /* Validate the template and get a pointer to the EndTag */ 00765 00766 Status = AcpiUtWalkAmlResources (ObjDesc->Buffer.Pointer, 00767 ObjDesc->Buffer.Length, NULL, EndTag); 00768 00769 return_ACPI_STATUS (Status); 00770 } 00771 00772 Generated on Thu May 24 2012 04:27:59 for ReactOS by
1.7.6.1
|