Back to home page

LXR

 
 

    


File indexing completed on 2025-05-11 08:24:03

0001 /******************************************************************************
0002  *
0003  * Module Name: tbutils - ACPI Table utilities
0004  *
0005  *****************************************************************************/
0006 
0007 /******************************************************************************
0008  *
0009  * 1. Copyright Notice
0010  *
0011  * Some or all of this work - Copyright (c) 1999 - 2024, 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  * Alternatively, you may choose to be licensed under the terms of the
0117  * following license:
0118  *
0119  * Redistribution and use in source and binary forms, with or without
0120  * modification, are permitted provided that the following conditions
0121  * are met:
0122  * 1. Redistributions of source code must retain the above copyright
0123  *    notice, this list of conditions, and the following disclaimer,
0124  *    without modification.
0125  * 2. Redistributions in binary form must reproduce at minimum a disclaimer
0126  *    substantially similar to the "NO WARRANTY" disclaimer below
0127  *    ("Disclaimer") and any redistribution must be conditioned upon
0128  *    including a substantially similar Disclaimer requirement for further
0129  *    binary redistribution.
0130  * 3. Neither the names of the above-listed copyright holders nor the names
0131  *    of any contributors may be used to endorse or promote products derived
0132  *    from this software without specific prior written permission.
0133  *
0134  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
0135  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
0136  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
0137  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
0138  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
0139  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
0140  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
0141  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
0142  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
0143  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
0144  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
0145  *
0146  * Alternatively, you may choose to be licensed under the terms of the
0147  * GNU General Public License ("GPL") version 2 as published by the Free
0148  * Software Foundation.
0149  *
0150  *****************************************************************************/
0151 
0152 #include "acpi.h"
0153 #include "accommon.h"
0154 #include "actables.h"
0155 
0156 #define _COMPONENT          ACPI_TABLES
0157         ACPI_MODULE_NAME    ("tbutils")
0158 
0159 
0160 /* Local prototypes */
0161 
0162 static ACPI_PHYSICAL_ADDRESS
0163 AcpiTbGetRootTableEntry (
0164     UINT8                   *TableEntry,
0165     UINT32                  TableEntrySize);
0166 
0167 
0168 #if (!ACPI_REDUCED_HARDWARE)
0169 /*******************************************************************************
0170  *
0171  * FUNCTION:    AcpiTbInitializeFacs
0172  *
0173  * PARAMETERS:  None
0174  *
0175  * RETURN:      Status
0176  *
0177  * DESCRIPTION: Create a permanent mapping for the FADT and save it in a global
0178  *              for accessing the Global Lock and Firmware Waking Vector
0179  *
0180  ******************************************************************************/
0181 
0182 ACPI_STATUS
0183 AcpiTbInitializeFacs (
0184     void)
0185 {
0186     ACPI_TABLE_FACS         *Facs;
0187 
0188     if (AcpiGbl_FADT.XFacs &&
0189          (!AcpiGbl_FADT.Facs || !AcpiGbl_Use32BitFacsAddresses))
0190     {
0191         (void) AcpiGetTableByIndex (AcpiGbl_XFacsIndex,
0192             ACPI_CAST_INDIRECT_PTR (ACPI_TABLE_HEADER, &Facs));
0193         AcpiGbl_FACS = Facs;
0194     }
0195     else if (AcpiGbl_FADT.Facs)
0196     {
0197         (void) AcpiGetTableByIndex (AcpiGbl_FacsIndex,
0198             ACPI_CAST_INDIRECT_PTR (ACPI_TABLE_HEADER, &Facs));
0199         AcpiGbl_FACS = Facs;
0200     }
0201 
0202     /* If there is no FACS, just continue. There was already an error msg */
0203 
0204     return (AE_OK);
0205 }
0206 #endif /* !ACPI_REDUCED_HARDWARE */
0207 
0208 
0209 /*******************************************************************************
0210  *
0211  * FUNCTION:    AcpiTbCheckDsdtHeader
0212  *
0213  * PARAMETERS:  None
0214  *
0215  * RETURN:      None
0216  *
0217  * DESCRIPTION: Quick compare to check validity of the DSDT. This will detect
0218  *              if the DSDT has been replaced from outside the OS and/or if
0219  *              the DSDT header has been corrupted.
0220  *
0221  ******************************************************************************/
0222 
0223 void
0224 AcpiTbCheckDsdtHeader (
0225     void)
0226 {
0227 
0228     /* Compare original length and checksum to current values */
0229 
0230     if (AcpiGbl_OriginalDsdtHeader.Length != AcpiGbl_DSDT->Length ||
0231         AcpiGbl_OriginalDsdtHeader.Checksum != AcpiGbl_DSDT->Checksum)
0232     {
0233         ACPI_BIOS_ERROR ((AE_INFO,
0234             "The DSDT has been corrupted or replaced - "
0235             "old, new headers below"));
0236 
0237         AcpiTbPrintTableHeader (0, &AcpiGbl_OriginalDsdtHeader);
0238         AcpiTbPrintTableHeader (0, AcpiGbl_DSDT);
0239 
0240         /* Disable further error messages */
0241 
0242         AcpiGbl_OriginalDsdtHeader.Length = AcpiGbl_DSDT->Length;
0243         AcpiGbl_OriginalDsdtHeader.Checksum = AcpiGbl_DSDT->Checksum;
0244     }
0245 }
0246 
0247 
0248 /*******************************************************************************
0249  *
0250  * FUNCTION:    AcpiTbCopyDsdt
0251  *
0252  * PARAMETERS:  TableIndex          - Index of installed table to copy
0253  *
0254  * RETURN:      The copied DSDT
0255  *
0256  * DESCRIPTION: Implements a subsystem option to copy the DSDT to local memory.
0257  *              Some very bad BIOSs are known to either corrupt the DSDT or
0258  *              install a new, bad DSDT. This copy works around the problem.
0259  *
0260  ******************************************************************************/
0261 
0262 ACPI_TABLE_HEADER *
0263 AcpiTbCopyDsdt (
0264     UINT32                  TableIndex)
0265 {
0266     ACPI_TABLE_HEADER       *NewTable;
0267     ACPI_TABLE_DESC         *TableDesc;
0268 
0269 
0270     TableDesc = &AcpiGbl_RootTableList.Tables[TableIndex];
0271 
0272     NewTable = ACPI_ALLOCATE (TableDesc->Length);
0273     if (!NewTable)
0274     {
0275         ACPI_ERROR ((AE_INFO, "Could not copy DSDT of length 0x%X",
0276             TableDesc->Length));
0277         return (NULL);
0278     }
0279 
0280     memcpy (NewTable, TableDesc->Pointer, TableDesc->Length);
0281     AcpiTbUninstallTable (TableDesc);
0282 
0283     AcpiTbInitTableDescriptor (
0284         &AcpiGbl_RootTableList.Tables[AcpiGbl_DsdtIndex],
0285         ACPI_PTR_TO_PHYSADDR (NewTable),
0286         ACPI_TABLE_ORIGIN_INTERNAL_VIRTUAL, NewTable);
0287 
0288     ACPI_INFO ((
0289         "Forced DSDT copy: length 0x%05X copied locally, original unmapped",
0290         NewTable->Length));
0291 
0292     return (NewTable);
0293 }
0294 
0295 
0296 /*******************************************************************************
0297  *
0298  * FUNCTION:    AcpiTbGetRootTableEntry
0299  *
0300  * PARAMETERS:  TableEntry          - Pointer to the RSDT/XSDT table entry
0301  *              TableEntrySize      - sizeof 32 or 64 (RSDT or XSDT)
0302  *
0303  * RETURN:      Physical address extracted from the root table
0304  *
0305  * DESCRIPTION: Get one root table entry. Handles 32-bit and 64-bit cases on
0306  *              both 32-bit and 64-bit platforms
0307  *
0308  * NOTE:        ACPI_PHYSICAL_ADDRESS is 32-bit on 32-bit platforms, 64-bit on
0309  *              64-bit platforms.
0310  *
0311  ******************************************************************************/
0312 
0313 static ACPI_PHYSICAL_ADDRESS
0314 AcpiTbGetRootTableEntry (
0315     UINT8                   *TableEntry,
0316     UINT32                  TableEntrySize)
0317 {
0318     UINT32                  Address32;
0319     UINT64                  Address64;
0320 
0321 
0322     /*
0323      * Get the table physical address (32-bit for RSDT, 64-bit for XSDT):
0324      * Note: Addresses are 32-bit aligned (not 64) in both RSDT and XSDT
0325      */
0326     if (TableEntrySize == ACPI_RSDT_ENTRY_SIZE)
0327     {
0328         /*
0329          * 32-bit platform, RSDT: Return 32-bit table entry
0330          * 64-bit platform, RSDT: Expand 32-bit to 64-bit and return
0331          */
0332         ACPI_MOVE_32_TO_32(&Address32, TableEntry);
0333         return Address32;
0334     }
0335     else
0336     {
0337         /*
0338          * 32-bit platform, XSDT: Truncate 64-bit to 32-bit and return
0339          * 64-bit platform, XSDT: Move (unaligned) 64-bit to local,
0340          *  return 64-bit
0341          */
0342         ACPI_MOVE_64_TO_64 (&Address64, TableEntry);
0343 
0344 #if ACPI_MACHINE_WIDTH == 32
0345         if (Address64 > ACPI_UINT32_MAX)
0346         {
0347             /* Will truncate 64-bit address to 32 bits, issue warning */
0348 
0349             ACPI_BIOS_WARNING ((AE_INFO,
0350                 "64-bit Physical Address in XSDT is too large (0x%8.8X%8.8X),"
0351                 " truncating",
0352                 ACPI_FORMAT_UINT64 (Address64)));
0353         }
0354 #endif
0355         return ((ACPI_PHYSICAL_ADDRESS) (Address64));
0356     }
0357 }
0358 
0359 
0360 /*******************************************************************************
0361  *
0362  * FUNCTION:    AcpiTbParseRootTable
0363  *
0364  * PARAMETERS:  RsdpAddress         - Pointer to the RSDP
0365  *
0366  * RETURN:      Status
0367  *
0368  * DESCRIPTION: This function is called to parse the Root System Description
0369  *              Table (RSDT or XSDT)
0370  *
0371  * NOTE:        Tables are mapped (not copied) for efficiency. The FACS must
0372  *              be mapped and cannot be copied because it contains the actual
0373  *              memory location of the ACPI Global Lock.
0374  *
0375  ******************************************************************************/
0376 
0377 ACPI_STATUS ACPI_INIT_FUNCTION
0378 AcpiTbParseRootTable (
0379     ACPI_PHYSICAL_ADDRESS   RsdpAddress)
0380 {
0381     ACPI_TABLE_RSDP         *Rsdp;
0382     UINT32                  TableEntrySize;
0383     UINT32                  i;
0384     UINT32                  TableCount;
0385     ACPI_TABLE_HEADER       *Table;
0386     ACPI_PHYSICAL_ADDRESS   Address;
0387     UINT32                  Length;
0388     UINT8                   *TableEntry;
0389     ACPI_STATUS             Status;
0390     UINT32                  TableIndex;
0391 
0392 
0393     ACPI_FUNCTION_TRACE (TbParseRootTable);
0394 
0395 
0396     /* Map the entire RSDP and extract the address of the RSDT or XSDT */
0397 
0398     Rsdp = AcpiOsMapMemory (RsdpAddress, sizeof (ACPI_TABLE_RSDP));
0399     if (!Rsdp)
0400     {
0401         return_ACPI_STATUS (AE_NO_MEMORY);
0402     }
0403 
0404     AcpiTbPrintTableHeader (RsdpAddress,
0405         ACPI_CAST_PTR (ACPI_TABLE_HEADER, Rsdp));
0406 
0407     /* Use XSDT if present and not overridden. Otherwise, use RSDT */
0408 
0409     if ((Rsdp->Revision > 1) &&
0410         Rsdp->XsdtPhysicalAddress &&
0411         !AcpiGbl_DoNotUseXsdt)
0412     {
0413         /*
0414          * RSDP contains an XSDT (64-bit physical addresses). We must use
0415          * the XSDT if the revision is > 1 and the XSDT pointer is present,
0416          * as per the ACPI specification.
0417          */
0418         Address = (ACPI_PHYSICAL_ADDRESS) Rsdp->XsdtPhysicalAddress;
0419         TableEntrySize = ACPI_XSDT_ENTRY_SIZE;
0420     }
0421     else
0422     {
0423         /* Root table is an RSDT (32-bit physical addresses) */
0424 
0425         Address = (ACPI_PHYSICAL_ADDRESS) Rsdp->RsdtPhysicalAddress;
0426         TableEntrySize = ACPI_RSDT_ENTRY_SIZE;
0427     }
0428 
0429     /*
0430      * It is not possible to map more than one entry in some environments,
0431      * so unmap the RSDP here before mapping other tables
0432      */
0433     AcpiOsUnmapMemory (Rsdp, sizeof (ACPI_TABLE_RSDP));
0434 
0435     /* Map the RSDT/XSDT table header to get the full table length */
0436 
0437     Table = AcpiOsMapMemory (Address, sizeof (ACPI_TABLE_HEADER));
0438     if (!Table)
0439     {
0440         return_ACPI_STATUS (AE_NO_MEMORY);
0441     }
0442 
0443     AcpiTbPrintTableHeader (Address, Table);
0444 
0445     /*
0446      * Validate length of the table, and map entire table.
0447      * Minimum length table must contain at least one entry.
0448      */
0449     Length = Table->Length;
0450     AcpiOsUnmapMemory (Table, sizeof (ACPI_TABLE_HEADER));
0451 
0452     if (Length < (sizeof (ACPI_TABLE_HEADER) + TableEntrySize))
0453     {
0454         ACPI_BIOS_ERROR ((AE_INFO,
0455             "Invalid table length 0x%X in RSDT/XSDT", Length));
0456         return_ACPI_STATUS (AE_INVALID_TABLE_LENGTH);
0457     }
0458 
0459     Table = AcpiOsMapMemory (Address, Length);
0460     if (!Table)
0461     {
0462         return_ACPI_STATUS (AE_NO_MEMORY);
0463     }
0464 
0465     /* Validate the root table checksum */
0466 
0467     Status = AcpiUtVerifyChecksum (Table, Length);
0468     if (ACPI_FAILURE (Status))
0469     {
0470         AcpiOsUnmapMemory (Table, Length);
0471         return_ACPI_STATUS (Status);
0472     }
0473 
0474     /* Get the number of entries and pointer to first entry */
0475 
0476     TableCount = (UINT32) ((Table->Length - sizeof (ACPI_TABLE_HEADER)) /
0477         TableEntrySize);
0478     TableEntry = ACPI_ADD_PTR (UINT8, Table, sizeof (ACPI_TABLE_HEADER));
0479 
0480     /* Initialize the root table array from the RSDT/XSDT */
0481 
0482     for (i = 0; i < TableCount; i++)
0483     {
0484         /* Get the table physical address (32-bit for RSDT, 64-bit for XSDT) */
0485 
0486         Address = AcpiTbGetRootTableEntry (TableEntry, TableEntrySize);
0487 
0488         /* Skip NULL entries in RSDT/XSDT */
0489 
0490         if (!Address)
0491         {
0492             goto NextTable;
0493         }
0494 
0495         Status = AcpiTbInstallStandardTable (Address,
0496             ACPI_TABLE_ORIGIN_INTERNAL_PHYSICAL, NULL, FALSE, TRUE,
0497             &TableIndex);
0498 
0499         if (ACPI_SUCCESS (Status) &&
0500             ACPI_COMPARE_NAMESEG (
0501                 &AcpiGbl_RootTableList.Tables[TableIndex].Signature,
0502                 ACPI_SIG_FADT))
0503         {
0504             AcpiGbl_FadtIndex = TableIndex;
0505             AcpiTbParseFadt ();
0506         }
0507 
0508 NextTable:
0509 
0510         TableEntry += TableEntrySize;
0511     }
0512 
0513     AcpiOsUnmapMemory (Table, Length);
0514     return_ACPI_STATUS (AE_OK);
0515 }
0516 
0517 
0518 /*******************************************************************************
0519  *
0520  * FUNCTION:    AcpiTbGetTable
0521  *
0522  * PARAMETERS:  TableDesc           - Table descriptor
0523  *              OutTable            - Where the pointer to the table is returned
0524  *
0525  * RETURN:      Status and pointer to the requested table
0526  *
0527  * DESCRIPTION: Increase a reference to a table descriptor and return the
0528  *              validated table pointer.
0529  *              If the table descriptor is an entry of the root table list,
0530  *              this API must be invoked with ACPI_MTX_TABLES acquired.
0531  *
0532  ******************************************************************************/
0533 
0534 ACPI_STATUS
0535 AcpiTbGetTable (
0536     ACPI_TABLE_DESC        *TableDesc,
0537     ACPI_TABLE_HEADER      **OutTable)
0538 {
0539     ACPI_STATUS            Status;
0540 
0541 
0542     ACPI_FUNCTION_TRACE (AcpiTbGetTable);
0543 
0544 
0545     if (TableDesc->ValidationCount == 0)
0546     {
0547         /* Table need to be "VALIDATED" */
0548 
0549         Status = AcpiTbValidateTable (TableDesc);
0550         if (ACPI_FAILURE (Status))
0551         {
0552             return_ACPI_STATUS (Status);
0553         }
0554     }
0555 
0556     if (TableDesc->ValidationCount < ACPI_MAX_TABLE_VALIDATIONS)
0557     {
0558         TableDesc->ValidationCount++;
0559 
0560         /*
0561          * Detect ValidationCount overflows to ensure that the warning
0562          * message will only be printed once.
0563          */
0564         if (TableDesc->ValidationCount >= ACPI_MAX_TABLE_VALIDATIONS)
0565         {
0566             ACPI_WARNING((AE_INFO,
0567                 "Table %p, Validation count overflows\n", TableDesc));
0568         }
0569     }
0570 
0571     *OutTable = TableDesc->Pointer;
0572     return_ACPI_STATUS (AE_OK);
0573 }
0574 
0575 
0576 /*******************************************************************************
0577  *
0578  * FUNCTION:    AcpiTbPutTable
0579  *
0580  * PARAMETERS:  TableDesc           - Table descriptor
0581  *
0582  * RETURN:      None
0583  *
0584  * DESCRIPTION: Decrease a reference to a table descriptor and release the
0585  *              validated table pointer if no references.
0586  *              If the table descriptor is an entry of the root table list,
0587  *              this API must be invoked with ACPI_MTX_TABLES acquired.
0588  *
0589  ******************************************************************************/
0590 
0591 void
0592 AcpiTbPutTable (
0593     ACPI_TABLE_DESC        *TableDesc)
0594 {
0595 
0596     ACPI_FUNCTION_TRACE (AcpiTbPutTable);
0597 
0598 
0599     if (TableDesc->ValidationCount < ACPI_MAX_TABLE_VALIDATIONS)
0600     {
0601         TableDesc->ValidationCount--;
0602 
0603         /*
0604          * Detect ValidationCount underflows to ensure that the warning
0605          * message will only be printed once.
0606          */
0607         if (TableDesc->ValidationCount >= ACPI_MAX_TABLE_VALIDATIONS)
0608         {
0609             ACPI_WARNING ((AE_INFO,
0610                 "Table %p, Validation count underflows\n", TableDesc));
0611             return_VOID;
0612         }
0613     }
0614 
0615     if (TableDesc->ValidationCount == 0)
0616     {
0617         /* Table need to be "INVALIDATED" */
0618 
0619         AcpiTbInvalidateTable (TableDesc);
0620     }
0621 
0622     return_VOID;
0623 }