The Design and Implementation of the FreeBSD Operating System, Second Edition
Now available: The Design and Implementation of the FreeBSD Operating System (Second Edition)


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]

FreeBSD/Linux Kernel Cross Reference
sys/contrib/dev/acpica/components/tables/tbutils.c

Version: -  FREEBSD  -  FREEBSD-13-STABLE  -  FREEBSD-13-0  -  FREEBSD-12-STABLE  -  FREEBSD-12-0  -  FREEBSD-11-STABLE  -  FREEBSD-11-0  -  FREEBSD-10-STABLE  -  FREEBSD-10-0  -  FREEBSD-9-STABLE  -  FREEBSD-9-0  -  FREEBSD-8-STABLE  -  FREEBSD-8-0  -  FREEBSD-7-STABLE  -  FREEBSD-7-0  -  FREEBSD-6-STABLE  -  FREEBSD-6-0  -  FREEBSD-5-STABLE  -  FREEBSD-5-0  -  FREEBSD-4-STABLE  -  FREEBSD-3-STABLE  -  FREEBSD22  -  l41  -  OPENBSD  -  linux-2.6  -  MK84  -  PLAN9  -  xnu-8792 
SearchContext: -  none  -  3  -  10 

    1 /******************************************************************************
    2  *
    3  * Module Name: tbutils - ACPI Table utilities
    4  *
    5  *****************************************************************************/
    6 
    7 /******************************************************************************
    8  *
    9  * 1. Copyright Notice
   10  *
   11  * Some or all of this work - Copyright (c) 1999 - 2022, Intel Corp.
   12  * All rights reserved.
   13  *
   14  * 2. License
   15  *
   16  * 2.1. This is your license from Intel Corp. under its intellectual property
   17  * rights. You may have additional license terms from the party that provided
   18  * you this software, covering your right to use that party's intellectual
   19  * property rights.
   20  *
   21  * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
   22  * copy of the source code appearing in this file ("Covered Code") an
   23  * irrevocable, perpetual, worldwide license under Intel's copyrights in the
   24  * base code distributed originally by Intel ("Original Intel Code") to copy,
   25  * make derivatives, distribute, use and display any portion of the Covered
   26  * Code in any form, with the right to sublicense such rights; and
   27  *
   28  * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
   29  * license (with the right to sublicense), under only those claims of Intel
   30  * patents that are infringed by the Original Intel Code, to make, use, sell,
   31  * offer to sell, and import the Covered Code and derivative works thereof
   32  * solely to the minimum extent necessary to exercise the above copyright
   33  * license, and in no event shall the patent license extend to any additions
   34  * to or modifications of the Original Intel Code. No other license or right
   35  * is granted directly or by implication, estoppel or otherwise;
   36  *
   37  * The above copyright and patent license is granted only if the following
   38  * conditions are met:
   39  *
   40  * 3. Conditions
   41  *
   42  * 3.1. Redistribution of Source with Rights to Further Distribute Source.
   43  * Redistribution of source code of any substantial portion of the Covered
   44  * Code or modification with rights to further distribute source must include
   45  * the above Copyright Notice, the above License, this list of Conditions,
   46  * and the following Disclaimer and Export Compliance provision. In addition,
   47  * Licensee must cause all Covered Code to which Licensee contributes to
   48  * contain a file documenting the changes Licensee made to create that Covered
   49  * Code and the date of any change. Licensee must include in that file the
   50  * documentation of any changes made by any predecessor Licensee. Licensee
   51  * must include a prominent statement that the modification is derived,
   52  * directly or indirectly, from Original Intel Code.
   53  *
   54  * 3.2. Redistribution of Source with no Rights to Further Distribute Source.
   55  * Redistribution of source code of any substantial portion of the Covered
   56  * Code or modification without rights to further distribute source must
   57  * include the following Disclaimer and Export Compliance provision in the
   58  * documentation and/or other materials provided with distribution. In
   59  * addition, Licensee may not authorize further sublicense of source of any
   60  * portion of the Covered Code, and must include terms to the effect that the
   61  * license from Licensee to its licensee is limited to the intellectual
   62  * property embodied in the software Licensee provides to its licensee, and
   63  * not to intellectual property embodied in modifications its licensee may
   64  * make.
   65  *
   66  * 3.3. Redistribution of Executable. Redistribution in executable form of any
   67  * substantial portion of the Covered Code or modification must reproduce the
   68  * above Copyright Notice, and the following Disclaimer and Export Compliance
   69  * provision in the documentation and/or other materials provided with the
   70  * distribution.
   71  *
   72  * 3.4. Intel retains all right, title, and interest in and to the Original
   73  * Intel Code.
   74  *
   75  * 3.5. Neither the name Intel nor any other trademark owned or controlled by
   76  * Intel shall be used in advertising or otherwise to promote the sale, use or
   77  * other dealings in products derived from or relating to the Covered Code
   78  * without prior written authorization from Intel.
   79  *
   80  * 4. Disclaimer and Export Compliance
   81  *
   82  * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
   83  * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
   84  * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE,
   85  * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY
   86  * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY
   87  * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
   88  * PARTICULAR PURPOSE.
   89  *
   90  * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
   91  * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
   92  * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
   93  * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
   94  * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
   95  * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS
   96  * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
   97  * LIMITED REMEDY.
   98  *
   99  * 4.3. Licensee shall not export, either directly or indirectly, any of this
  100  * software or system incorporating such software without first obtaining any
  101  * required license or other approval from the U. S. Department of Commerce or
  102  * any other agency or department of the United States Government. In the
  103  * event Licensee exports any such software from the United States or
  104  * re-exports any such software from a foreign destination, Licensee shall
  105  * ensure that the distribution and export/re-export of the software is in
  106  * compliance with all laws, regulations, orders, or other restrictions of the
  107  * U.S. Export Administration Regulations. Licensee agrees that neither it nor
  108  * any of its subsidiaries will export/re-export any technical data, process,
  109  * software, or service, directly or indirectly, to any country for which the
  110  * United States government or any agency thereof requires an export license,
  111  * other governmental approval, or letter of assurance, without first obtaining
  112  * such license, approval or letter.
  113  *
  114  *****************************************************************************
  115  *
  116  * Alternatively, you may choose to be licensed under the terms of the
  117  * following license:
  118  *
  119  * Redistribution and use in source and binary forms, with or without
  120  * modification, are permitted provided that the following conditions
  121  * are met:
  122  * 1. Redistributions of source code must retain the above copyright
  123  *    notice, this list of conditions, and the following disclaimer,
  124  *    without modification.
  125  * 2. Redistributions in binary form must reproduce at minimum a disclaimer
  126  *    substantially similar to the "NO WARRANTY" disclaimer below
  127  *    ("Disclaimer") and any redistribution must be conditioned upon
  128  *    including a substantially similar Disclaimer requirement for further
  129  *    binary redistribution.
  130  * 3. Neither the names of the above-listed copyright holders nor the names
  131  *    of any contributors may be used to endorse or promote products derived
  132  *    from this software without specific prior written permission.
  133  *
  134  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  135  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  136  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  137  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  138  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  139  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  140  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  141  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  142  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  143  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  144  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  145  *
  146  * Alternatively, you may choose to be licensed under the terms of the
  147  * GNU General Public License ("GPL") version 2 as published by the Free
  148  * Software Foundation.
  149  *
  150  *****************************************************************************/
  151 
  152 #include <contrib/dev/acpica/include/acpi.h>
  153 #include <contrib/dev/acpica/include/accommon.h>
  154 #include <contrib/dev/acpica/include/actables.h>
  155 
  156 #define _COMPONENT          ACPI_TABLES
  157         ACPI_MODULE_NAME    ("tbutils")
  158 
  159 
  160 /* Local prototypes */
  161 
  162 static ACPI_PHYSICAL_ADDRESS
  163 AcpiTbGetRootTableEntry (
  164     UINT8                   *TableEntry,
  165     UINT32                  TableEntrySize);
  166 
  167 
  168 #if (!ACPI_REDUCED_HARDWARE)
  169 /*******************************************************************************
  170  *
  171  * FUNCTION:    AcpiTbInitializeFacs
  172  *
  173  * PARAMETERS:  None
  174  *
  175  * RETURN:      Status
  176  *
  177  * DESCRIPTION: Create a permanent mapping for the FADT and save it in a global
  178  *              for accessing the Global Lock and Firmware Waking Vector
  179  *
  180  ******************************************************************************/
  181 
  182 ACPI_STATUS
  183 AcpiTbInitializeFacs (
  184     void)
  185 {
  186     ACPI_TABLE_FACS         *Facs;
  187 
  188 
  189     /* If Hardware Reduced flag is set, there is no FACS */
  190 
  191     if (AcpiGbl_ReducedHardware)
  192     {
  193         AcpiGbl_FACS = NULL;
  194         return (AE_OK);
  195     }
  196     else if (AcpiGbl_FADT.XFacs &&
  197          (!AcpiGbl_FADT.Facs || !AcpiGbl_Use32BitFacsAddresses))
  198     {
  199         (void) AcpiGetTableByIndex (AcpiGbl_XFacsIndex,
  200             ACPI_CAST_INDIRECT_PTR (ACPI_TABLE_HEADER, &Facs));
  201         AcpiGbl_FACS = Facs;
  202     }
  203     else if (AcpiGbl_FADT.Facs)
  204     {
  205         (void) AcpiGetTableByIndex (AcpiGbl_FacsIndex,
  206             ACPI_CAST_INDIRECT_PTR (ACPI_TABLE_HEADER, &Facs));
  207         AcpiGbl_FACS = Facs;
  208     }
  209 
  210     /* If there is no FACS, just continue. There was already an error msg */
  211 
  212     return (AE_OK);
  213 }
  214 #endif /* !ACPI_REDUCED_HARDWARE */
  215 
  216 
  217 /*******************************************************************************
  218  *
  219  * FUNCTION:    AcpiTbCheckDsdtHeader
  220  *
  221  * PARAMETERS:  None
  222  *
  223  * RETURN:      None
  224  *
  225  * DESCRIPTION: Quick compare to check validity of the DSDT. This will detect
  226  *              if the DSDT has been replaced from outside the OS and/or if
  227  *              the DSDT header has been corrupted.
  228  *
  229  ******************************************************************************/
  230 
  231 void
  232 AcpiTbCheckDsdtHeader (
  233     void)
  234 {
  235 
  236     /* Compare original length and checksum to current values */
  237 
  238     if (AcpiGbl_OriginalDsdtHeader.Length != AcpiGbl_DSDT->Length ||
  239         AcpiGbl_OriginalDsdtHeader.Checksum != AcpiGbl_DSDT->Checksum)
  240     {
  241         ACPI_BIOS_ERROR ((AE_INFO,
  242             "The DSDT has been corrupted or replaced - "
  243             "old, new headers below"));
  244 
  245         AcpiTbPrintTableHeader (0, &AcpiGbl_OriginalDsdtHeader);
  246         AcpiTbPrintTableHeader (0, AcpiGbl_DSDT);
  247 
  248         /* Disable further error messages */
  249 
  250         AcpiGbl_OriginalDsdtHeader.Length = AcpiGbl_DSDT->Length;
  251         AcpiGbl_OriginalDsdtHeader.Checksum = AcpiGbl_DSDT->Checksum;
  252     }
  253 }
  254 
  255 
  256 /*******************************************************************************
  257  *
  258  * FUNCTION:    AcpiTbCopyDsdt
  259  *
  260  * PARAMETERS:  TableIndex          - Index of installed table to copy
  261  *
  262  * RETURN:      The copied DSDT
  263  *
  264  * DESCRIPTION: Implements a subsystem option to copy the DSDT to local memory.
  265  *              Some very bad BIOSs are known to either corrupt the DSDT or
  266  *              install a new, bad DSDT. This copy works around the problem.
  267  *
  268  ******************************************************************************/
  269 
  270 ACPI_TABLE_HEADER *
  271 AcpiTbCopyDsdt (
  272     UINT32                  TableIndex)
  273 {
  274     ACPI_TABLE_HEADER       *NewTable;
  275     ACPI_TABLE_DESC         *TableDesc;
  276 
  277 
  278     TableDesc = &AcpiGbl_RootTableList.Tables[TableIndex];
  279 
  280     NewTable = ACPI_ALLOCATE (TableDesc->Length);
  281     if (!NewTable)
  282     {
  283         ACPI_ERROR ((AE_INFO, "Could not copy DSDT of length 0x%X",
  284             TableDesc->Length));
  285         return (NULL);
  286     }
  287 
  288     memcpy (NewTable, TableDesc->Pointer, TableDesc->Length);
  289     AcpiTbUninstallTable (TableDesc);
  290 
  291     AcpiTbInitTableDescriptor (
  292         &AcpiGbl_RootTableList.Tables[AcpiGbl_DsdtIndex],
  293         ACPI_PTR_TO_PHYSADDR (NewTable),
  294         ACPI_TABLE_ORIGIN_INTERNAL_VIRTUAL, NewTable);
  295 
  296     ACPI_INFO ((
  297         "Forced DSDT copy: length 0x%05X copied locally, original unmapped",
  298         NewTable->Length));
  299 
  300     return (NewTable);
  301 }
  302 
  303 
  304 /*******************************************************************************
  305  *
  306  * FUNCTION:    AcpiTbGetRootTableEntry
  307  *
  308  * PARAMETERS:  TableEntry          - Pointer to the RSDT/XSDT table entry
  309  *              TableEntrySize      - sizeof 32 or 64 (RSDT or XSDT)
  310  *
  311  * RETURN:      Physical address extracted from the root table
  312  *
  313  * DESCRIPTION: Get one root table entry. Handles 32-bit and 64-bit cases on
  314  *              both 32-bit and 64-bit platforms
  315  *
  316  * NOTE:        ACPI_PHYSICAL_ADDRESS is 32-bit on 32-bit platforms, 64-bit on
  317  *              64-bit platforms.
  318  *
  319  ******************************************************************************/
  320 
  321 static ACPI_PHYSICAL_ADDRESS
  322 AcpiTbGetRootTableEntry (
  323     UINT8                   *TableEntry,
  324     UINT32                  TableEntrySize)
  325 {
  326     UINT64                  Address64;
  327 
  328 
  329     /*
  330      * Get the table physical address (32-bit for RSDT, 64-bit for XSDT):
  331      * Note: Addresses are 32-bit aligned (not 64) in both RSDT and XSDT
  332      */
  333     if (TableEntrySize == ACPI_RSDT_ENTRY_SIZE)
  334     {
  335         /*
  336          * 32-bit platform, RSDT: Return 32-bit table entry
  337          * 64-bit platform, RSDT: Expand 32-bit to 64-bit and return
  338          */
  339         return ((ACPI_PHYSICAL_ADDRESS) (*ACPI_CAST_PTR (
  340             UINT32, TableEntry)));
  341     }
  342     else
  343     {
  344         /*
  345          * 32-bit platform, XSDT: Truncate 64-bit to 32-bit and return
  346          * 64-bit platform, XSDT: Move (unaligned) 64-bit to local,
  347          *  return 64-bit
  348          */
  349         ACPI_MOVE_64_TO_64 (&Address64, TableEntry);
  350 
  351 #if ACPI_MACHINE_WIDTH == 32
  352         if (Address64 > ACPI_UINT32_MAX)
  353         {
  354             /* Will truncate 64-bit address to 32 bits, issue warning */
  355 
  356             ACPI_BIOS_WARNING ((AE_INFO,
  357                 "64-bit Physical Address in XSDT is too large (0x%8.8X%8.8X),"
  358                 " truncating",
  359                 ACPI_FORMAT_UINT64 (Address64)));
  360         }
  361 #endif
  362         return ((ACPI_PHYSICAL_ADDRESS) (Address64));
  363     }
  364 }
  365 
  366 
  367 /*******************************************************************************
  368  *
  369  * FUNCTION:    AcpiTbParseRootTable
  370  *
  371  * PARAMETERS:  RsdpAddress         - Pointer to the RSDP
  372  *
  373  * RETURN:      Status
  374  *
  375  * DESCRIPTION: This function is called to parse the Root System Description
  376  *              Table (RSDT or XSDT)
  377  *
  378  * NOTE:        Tables are mapped (not copied) for efficiency. The FACS must
  379  *              be mapped and cannot be copied because it contains the actual
  380  *              memory location of the ACPI Global Lock.
  381  *
  382  ******************************************************************************/
  383 
  384 ACPI_STATUS ACPI_INIT_FUNCTION
  385 AcpiTbParseRootTable (
  386     ACPI_PHYSICAL_ADDRESS   RsdpAddress)
  387 {
  388     ACPI_TABLE_RSDP         *Rsdp;
  389     UINT32                  TableEntrySize;
  390     UINT32                  i;
  391     UINT32                  TableCount;
  392     ACPI_TABLE_HEADER       *Table;
  393     ACPI_PHYSICAL_ADDRESS   Address;
  394     UINT32                  Length;
  395     UINT8                   *TableEntry;
  396     ACPI_STATUS             Status;
  397     UINT32                  TableIndex;
  398 
  399 
  400     ACPI_FUNCTION_TRACE (TbParseRootTable);
  401 
  402 
  403     /* Map the entire RSDP and extract the address of the RSDT or XSDT */
  404 
  405     Rsdp = AcpiOsMapMemory (RsdpAddress, sizeof (ACPI_TABLE_RSDP));
  406     if (!Rsdp)
  407     {
  408         return_ACPI_STATUS (AE_NO_MEMORY);
  409     }
  410 
  411     AcpiTbPrintTableHeader (RsdpAddress,
  412         ACPI_CAST_PTR (ACPI_TABLE_HEADER, Rsdp));
  413 
  414     /* Use XSDT if present and not overridden. Otherwise, use RSDT */
  415 
  416     if ((Rsdp->Revision > 1) &&
  417         Rsdp->XsdtPhysicalAddress &&
  418         !AcpiGbl_DoNotUseXsdt)
  419     {
  420         /*
  421          * RSDP contains an XSDT (64-bit physical addresses). We must use
  422          * the XSDT if the revision is > 1 and the XSDT pointer is present,
  423          * as per the ACPI specification.
  424          */
  425         Address = (ACPI_PHYSICAL_ADDRESS) Rsdp->XsdtPhysicalAddress;
  426         TableEntrySize = ACPI_XSDT_ENTRY_SIZE;
  427     }
  428     else
  429     {
  430         /* Root table is an RSDT (32-bit physical addresses) */
  431 
  432         Address = (ACPI_PHYSICAL_ADDRESS) Rsdp->RsdtPhysicalAddress;
  433         TableEntrySize = ACPI_RSDT_ENTRY_SIZE;
  434     }
  435 
  436     /*
  437      * It is not possible to map more than one entry in some environments,
  438      * so unmap the RSDP here before mapping other tables
  439      */
  440     AcpiOsUnmapMemory (Rsdp, sizeof (ACPI_TABLE_RSDP));
  441 
  442     /* Map the RSDT/XSDT table header to get the full table length */
  443 
  444     Table = AcpiOsMapMemory (Address, sizeof (ACPI_TABLE_HEADER));
  445     if (!Table)
  446     {
  447         return_ACPI_STATUS (AE_NO_MEMORY);
  448     }
  449 
  450     AcpiTbPrintTableHeader (Address, Table);
  451 
  452     /*
  453      * Validate length of the table, and map entire table.
  454      * Minimum length table must contain at least one entry.
  455      */
  456     Length = Table->Length;
  457     AcpiOsUnmapMemory (Table, sizeof (ACPI_TABLE_HEADER));
  458 
  459     if (Length < (sizeof (ACPI_TABLE_HEADER) + TableEntrySize))
  460     {
  461         ACPI_BIOS_ERROR ((AE_INFO,
  462             "Invalid table length 0x%X in RSDT/XSDT", Length));
  463         return_ACPI_STATUS (AE_INVALID_TABLE_LENGTH);
  464     }
  465 
  466     Table = AcpiOsMapMemory (Address, Length);
  467     if (!Table)
  468     {
  469         return_ACPI_STATUS (AE_NO_MEMORY);
  470     }
  471 
  472     /* Validate the root table checksum */
  473 
  474     Status = AcpiUtVerifyChecksum (Table, Length);
  475     if (ACPI_FAILURE (Status))
  476     {
  477         AcpiOsUnmapMemory (Table, Length);
  478         return_ACPI_STATUS (Status);
  479     }
  480 
  481     /* Get the number of entries and pointer to first entry */
  482 
  483     TableCount = (UINT32) ((Table->Length - sizeof (ACPI_TABLE_HEADER)) /
  484         TableEntrySize);
  485     TableEntry = ACPI_ADD_PTR (UINT8, Table, sizeof (ACPI_TABLE_HEADER));
  486 
  487     /* Initialize the root table array from the RSDT/XSDT */
  488 
  489     for (i = 0; i < TableCount; i++)
  490     {
  491         /* Get the table physical address (32-bit for RSDT, 64-bit for XSDT) */
  492 
  493         Address = AcpiTbGetRootTableEntry (TableEntry, TableEntrySize);
  494 
  495         /* Skip NULL entries in RSDT/XSDT */
  496 
  497         if (!Address)
  498         {
  499             goto NextTable;
  500         }
  501 
  502         Status = AcpiTbInstallStandardTable (Address,
  503             ACPI_TABLE_ORIGIN_INTERNAL_PHYSICAL, NULL, FALSE, TRUE,
  504             &TableIndex);
  505 
  506         if (ACPI_SUCCESS (Status) &&
  507             ACPI_COMPARE_NAMESEG (
  508                 &AcpiGbl_RootTableList.Tables[TableIndex].Signature,
  509                 ACPI_SIG_FADT))
  510         {
  511             AcpiGbl_FadtIndex = TableIndex;
  512             AcpiTbParseFadt ();
  513         }
  514 
  515 NextTable:
  516 
  517         TableEntry += TableEntrySize;
  518     }
  519 
  520     AcpiOsUnmapMemory (Table, Length);
  521     return_ACPI_STATUS (AE_OK);
  522 }
  523 
  524 
  525 /*******************************************************************************
  526  *
  527  * FUNCTION:    AcpiTbGetTable
  528  *
  529  * PARAMETERS:  TableDesc           - Table descriptor
  530  *              OutTable            - Where the pointer to the table is returned
  531  *
  532  * RETURN:      Status and pointer to the requested table
  533  *
  534  * DESCRIPTION: Increase a reference to a table descriptor and return the
  535  *              validated table pointer.
  536  *              If the table descriptor is an entry of the root table list,
  537  *              this API must be invoked with ACPI_MTX_TABLES acquired.
  538  *
  539  ******************************************************************************/
  540 
  541 ACPI_STATUS
  542 AcpiTbGetTable (
  543     ACPI_TABLE_DESC        *TableDesc,
  544     ACPI_TABLE_HEADER      **OutTable)
  545 {
  546     ACPI_STATUS            Status;
  547 
  548 
  549     ACPI_FUNCTION_TRACE (AcpiTbGetTable);
  550 
  551 
  552     if (TableDesc->ValidationCount == 0)
  553     {
  554         /* Table need to be "VALIDATED" */
  555 
  556         Status = AcpiTbValidateTable (TableDesc);
  557         if (ACPI_FAILURE (Status))
  558         {
  559             return_ACPI_STATUS (Status);
  560         }
  561     }
  562 
  563     if (TableDesc->ValidationCount < ACPI_MAX_TABLE_VALIDATIONS)
  564     {
  565         TableDesc->ValidationCount++;
  566 
  567         /*
  568          * Detect ValidationCount overflows to ensure that the warning
  569          * message will only be printed once.
  570          */
  571         if (TableDesc->ValidationCount >= ACPI_MAX_TABLE_VALIDATIONS)
  572         {
  573             ACPI_WARNING((AE_INFO,
  574                 "Table %p, Validation count overflows\n", TableDesc));
  575         }
  576     }
  577 
  578     *OutTable = TableDesc->Pointer;
  579     return_ACPI_STATUS (AE_OK);
  580 }
  581 
  582 
  583 /*******************************************************************************
  584  *
  585  * FUNCTION:    AcpiTbPutTable
  586  *
  587  * PARAMETERS:  TableDesc           - Table descriptor
  588  *
  589  * RETURN:      None
  590  *
  591  * DESCRIPTION: Decrease a reference to a table descriptor and release the
  592  *              validated table pointer if no references.
  593  *              If the table descriptor is an entry of the root table list,
  594  *              this API must be invoked with ACPI_MTX_TABLES acquired.
  595  *
  596  ******************************************************************************/
  597 
  598 void
  599 AcpiTbPutTable (
  600     ACPI_TABLE_DESC        *TableDesc)
  601 {
  602 
  603     ACPI_FUNCTION_TRACE (AcpiTbPutTable);
  604 
  605 
  606     if (TableDesc->ValidationCount < ACPI_MAX_TABLE_VALIDATIONS)
  607     {
  608         TableDesc->ValidationCount--;
  609 
  610         /*
  611          * Detect ValidationCount underflows to ensure that the warning
  612          * message will only be printed once.
  613          */
  614         if (TableDesc->ValidationCount >= ACPI_MAX_TABLE_VALIDATIONS)
  615         {
  616             ACPI_WARNING ((AE_INFO,
  617                 "Table %p, Validation count underflows\n", TableDesc));
  618             return_VOID;
  619         }
  620     }
  621 
  622     if (TableDesc->ValidationCount == 0)
  623     {
  624         /* Table need to be "INVALIDATED" */
  625 
  626         AcpiTbInvalidateTable (TableDesc);
  627     }
  628 
  629     return_VOID;
  630 }

Cache object: 5b2a166ce20f2cf576f316568bde19a0


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]


This page is part of the FreeBSD/Linux Linux Kernel Cross-Reference, and was automatically generated using a modified version of the LXR engine.