Back to home page

Quest Cross Reference

 
 

    


Warning, cross-references for /kernel/drivers/acpica/tbinstal.c need to be fixed.

0001 /******************************************************************************
0002  *
0003  * Module Name: tbinstal - ACPI table installation and removal
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 __TBINSTAL_C__
0118 
0119 #include "acpi.h"
0120 #include "accommon.h"
0121 #include "acnamesp.h"
0122 #include "actables.h"
0123 
0124 
0125 #define _COMPONENT          ACPI_TABLES
0126         ACPI_MODULE_NAME    ("tbinstal")
0127 
0128 
0129 /******************************************************************************
0130  *
0131  * FUNCTION:    AcpiTbVerifyTable
0132  *
0133  * PARAMETERS:  TableDesc           - table
0134  *
0135  * RETURN:      Status
0136  *
0137  * DESCRIPTION: this function is called to verify and map table
0138  *
0139  *****************************************************************************/
0140 
0141 ACPI_STATUS
0142 AcpiTbVerifyTable (
0143     ACPI_TABLE_DESC         *TableDesc)
0144 {
0145     ACPI_STATUS             Status = AE_OK;
0146 
0147 
0148     ACPI_FUNCTION_TRACE (TbVerifyTable);
0149 
0150 
0151     /* Map the table if necessary */
0152 
0153     if (!TableDesc->Pointer)
0154     {
0155         if ((TableDesc->Flags & ACPI_TABLE_ORIGIN_MASK) ==
0156             ACPI_TABLE_ORIGIN_MAPPED)
0157         {
0158             TableDesc->Pointer = AcpiOsMapMemory (
0159                 TableDesc->Address, TableDesc->Length);
0160         }
0161 
0162         if (!TableDesc->Pointer)
0163         {
0164             return_ACPI_STATUS (AE_NO_MEMORY);
0165         }
0166     }
0167 
0168     /* FACS is the odd table, has no standard ACPI header and no checksum */
0169 
0170     if (!ACPI_COMPARE_NAME (&TableDesc->Signature, ACPI_SIG_FACS))
0171     {
0172         /* Always calculate checksum, ignore bad checksum if requested */
0173 
0174         Status = AcpiTbVerifyChecksum (TableDesc->Pointer, TableDesc->Length);
0175     }
0176 
0177     return_ACPI_STATUS (Status);
0178 }
0179 
0180 
0181 /*******************************************************************************
0182  *
0183  * FUNCTION:    AcpiTbAddTable
0184  *
0185  * PARAMETERS:  TableDesc           - Table descriptor
0186  *              TableIndex          - Where the table index is returned
0187  *
0188  * RETURN:      Status
0189  *
0190  * DESCRIPTION: This function is called to add an ACPI table. It is used to
0191  *              dynamically load tables via the Load and LoadTable AML
0192  *              operators.
0193  *
0194  ******************************************************************************/
0195 
0196 ACPI_STATUS
0197 AcpiTbAddTable (
0198     ACPI_TABLE_DESC         *TableDesc,
0199     UINT32                  *TableIndex)
0200 {
0201     UINT32                  i;
0202     ACPI_STATUS             Status = AE_OK;
0203     ACPI_TABLE_HEADER       *OverrideTable = NULL;
0204 
0205 
0206     ACPI_FUNCTION_TRACE (TbAddTable);
0207 
0208 
0209     if (!TableDesc->Pointer)
0210     {
0211         Status = AcpiTbVerifyTable (TableDesc);
0212         if (ACPI_FAILURE (Status) || !TableDesc->Pointer)
0213         {
0214             return_ACPI_STATUS (Status);
0215         }
0216     }
0217 
0218     /*
0219      * Originally, we checked the table signature for "SSDT" or "PSDT" here.
0220      * Next, we added support for OEMx tables, signature "OEM".
0221      * Valid tables were encountered with a null signature, so we've just
0222      * given up on validating the signature, since it seems to be a waste
0223      * of code. The original code was removed (05/2008).
0224      */
0225 
0226     (void) AcpiUtAcquireMutex (ACPI_MTX_TABLES);
0227 
0228     /* Check if table is already registered */
0229 
0230     for (i = 0; i < AcpiGbl_RootTableList.Count; ++i)
0231     {
0232         if (!AcpiGbl_RootTableList.Tables[i].Pointer)
0233         {
0234             Status = AcpiTbVerifyTable (&AcpiGbl_RootTableList.Tables[i]);
0235             if (ACPI_FAILURE (Status) ||
0236                 !AcpiGbl_RootTableList.Tables[i].Pointer)
0237             {
0238                 continue;
0239             }
0240         }
0241 
0242         /*
0243          * Check for a table match on the entire table length,
0244          * not just the header.
0245          */
0246         if (TableDesc->Length != AcpiGbl_RootTableList.Tables[i].Length)
0247         {
0248             continue;
0249         }
0250 
0251         if (ACPI_MEMCMP (TableDesc->Pointer,
0252                 AcpiGbl_RootTableList.Tables[i].Pointer,
0253                 AcpiGbl_RootTableList.Tables[i].Length))
0254         {
0255             continue;
0256         }
0257 
0258         /*
0259          * Note: the current mechanism does not unregister a table if it is
0260          * dynamically unloaded. The related namespace entries are deleted,
0261          * but the table remains in the root table list.
0262          *
0263          * The assumption here is that the number of different tables that
0264          * will be loaded is actually small, and there is minimal overhead
0265          * in just keeping the table in case it is needed again.
0266          *
0267          * If this assumption changes in the future (perhaps on large
0268          * machines with many table load/unload operations), tables will
0269          * need to be unregistered when they are unloaded, and slots in the
0270          * root table list should be reused when empty.
0271          */
0272 
0273         /*
0274          * Table is already registered.
0275          * We can delete the table that was passed as a parameter.
0276          */
0277         AcpiTbDeleteTable (TableDesc);
0278         *TableIndex = i;
0279 
0280         if (AcpiGbl_RootTableList.Tables[i].Flags & ACPI_TABLE_IS_LOADED)
0281         {
0282             /* Table is still loaded, this is an error */
0283 
0284             Status = AE_ALREADY_EXISTS;
0285             goto Release;
0286         }
0287         else
0288         {
0289             /* Table was unloaded, allow it to be reloaded */
0290 
0291             TableDesc->Pointer = AcpiGbl_RootTableList.Tables[i].Pointer;
0292             TableDesc->Address = AcpiGbl_RootTableList.Tables[i].Address;
0293             Status = AE_OK;
0294             goto PrintHeader;
0295         }
0296     }
0297 
0298     /*
0299      * ACPI Table Override:
0300      * Allow the host to override dynamically loaded tables.
0301      */
0302     Status = AcpiOsTableOverride (TableDesc->Pointer, &OverrideTable);
0303     if (ACPI_SUCCESS (Status) && OverrideTable)
0304     {
0305         ACPI_INFO ((AE_INFO,
0306             "%4.4s @ 0x%p Table override, replaced with:",
0307             TableDesc->Pointer->Signature,
0308             ACPI_CAST_PTR (void, TableDesc->Address)));
0309 
0310         /* We can delete the table that was passed as a parameter */
0311 
0312         AcpiTbDeleteTable (TableDesc);
0313 
0314         /* Setup descriptor for the new table */
0315 
0316         TableDesc->Address = ACPI_PTR_TO_PHYSADDR (OverrideTable);
0317         TableDesc->Pointer = OverrideTable;
0318         TableDesc->Length = OverrideTable->Length;
0319         TableDesc->Flags = ACPI_TABLE_ORIGIN_OVERRIDE;
0320     }
0321 
0322     /* Add the table to the global root table list */
0323 
0324     Status = AcpiTbStoreTable (TableDesc->Address, TableDesc->Pointer,
0325                 TableDesc->Length, TableDesc->Flags, TableIndex);
0326     if (ACPI_FAILURE (Status))
0327     {
0328         goto Release;
0329     }
0330 
0331 PrintHeader:
0332     AcpiTbPrintTableHeader (TableDesc->Address, TableDesc->Pointer);
0333 
0334 Release:
0335     (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES);
0336     return_ACPI_STATUS (Status);
0337 }
0338 
0339 
0340 /*******************************************************************************
0341  *
0342  * FUNCTION:    AcpiTbResizeRootTableList
0343  *
0344  * PARAMETERS:  None
0345  *
0346  * RETURN:      Status
0347  *
0348  * DESCRIPTION: Expand the size of global table array
0349  *
0350  ******************************************************************************/
0351 
0352 ACPI_STATUS
0353 AcpiTbResizeRootTableList (
0354     void)
0355 {
0356     ACPI_TABLE_DESC         *Tables;
0357 
0358 
0359     ACPI_FUNCTION_TRACE (TbResizeRootTableList);
0360 
0361 
0362     /* AllowResize flag is a parameter to AcpiInitializeTables */
0363 
0364     if (!(AcpiGbl_RootTableList.Flags & ACPI_ROOT_ALLOW_RESIZE))
0365     {
0366         ACPI_ERROR ((AE_INFO, "Resize of Root Table Array is not allowed"));
0367         return_ACPI_STATUS (AE_SUPPORT);
0368     }
0369 
0370     /* Increase the Table Array size */
0371 
0372     Tables = ACPI_ALLOCATE_ZEROED (
0373         ((ACPI_SIZE) AcpiGbl_RootTableList.Size +
0374             ACPI_ROOT_TABLE_SIZE_INCREMENT) *
0375         sizeof (ACPI_TABLE_DESC));
0376     if (!Tables)
0377     {
0378         ACPI_ERROR ((AE_INFO, "Could not allocate new root table array"));
0379         return_ACPI_STATUS (AE_NO_MEMORY);
0380     }
0381 
0382     /* Copy and free the previous table array */
0383 
0384     if (AcpiGbl_RootTableList.Tables)
0385     {
0386         ACPI_MEMCPY (Tables, AcpiGbl_RootTableList.Tables,
0387             (ACPI_SIZE) AcpiGbl_RootTableList.Size * sizeof (ACPI_TABLE_DESC));
0388 
0389         if (AcpiGbl_RootTableList.Flags & ACPI_ROOT_ORIGIN_ALLOCATED)
0390         {
0391             ACPI_FREE (AcpiGbl_RootTableList.Tables);
0392         }
0393     }
0394 
0395     AcpiGbl_RootTableList.Tables = Tables;
0396     AcpiGbl_RootTableList.Size += ACPI_ROOT_TABLE_SIZE_INCREMENT;
0397     AcpiGbl_RootTableList.Flags |= (UINT8) ACPI_ROOT_ORIGIN_ALLOCATED;
0398 
0399     return_ACPI_STATUS (AE_OK);
0400 }
0401 
0402 
0403 /*******************************************************************************
0404  *
0405  * FUNCTION:    AcpiTbStoreTable
0406  *
0407  * PARAMETERS:  Address             - Table address
0408  *              Table               - Table header
0409  *              Length              - Table length
0410  *              Flags               - flags
0411  *
0412  * RETURN:      Status and table index.
0413  *
0414  * DESCRIPTION: Add an ACPI table to the global table list
0415  *
0416  ******************************************************************************/
0417 
0418 ACPI_STATUS
0419 AcpiTbStoreTable (
0420     ACPI_PHYSICAL_ADDRESS   Address,
0421     ACPI_TABLE_HEADER       *Table,
0422     UINT32                  Length,
0423     UINT8                   Flags,
0424     UINT32                  *TableIndex)
0425 {
0426     ACPI_STATUS             Status = AE_OK;
0427 
0428 
0429     /* Ensure that there is room for the table in the Root Table List */
0430 
0431     if (AcpiGbl_RootTableList.Count >= AcpiGbl_RootTableList.Size)
0432     {
0433         Status = AcpiTbResizeRootTableList();
0434         if (ACPI_FAILURE (Status))
0435         {
0436             return (Status);
0437         }
0438     }
0439 
0440     /* Initialize added table */
0441 
0442     AcpiGbl_RootTableList.Tables[AcpiGbl_RootTableList.Count].Address = Address;
0443     AcpiGbl_RootTableList.Tables[AcpiGbl_RootTableList.Count].Pointer = Table;
0444     AcpiGbl_RootTableList.Tables[AcpiGbl_RootTableList.Count].Length = Length;
0445     AcpiGbl_RootTableList.Tables[AcpiGbl_RootTableList.Count].OwnerId = 0;
0446     AcpiGbl_RootTableList.Tables[AcpiGbl_RootTableList.Count].Flags = Flags;
0447 
0448     ACPI_MOVE_32_TO_32 (
0449         &(AcpiGbl_RootTableList.Tables[AcpiGbl_RootTableList.Count].Signature),
0450         Table->Signature);
0451 
0452     *TableIndex = AcpiGbl_RootTableList.Count;
0453     AcpiGbl_RootTableList.Count++;
0454     return (Status);
0455 }
0456 
0457 
0458 /*******************************************************************************
0459  *
0460  * FUNCTION:    AcpiTbDeleteTable
0461  *
0462  * PARAMETERS:  TableIndex          - Table index
0463  *
0464  * RETURN:      None
0465  *
0466  * DESCRIPTION: Delete one internal ACPI table
0467  *
0468  ******************************************************************************/
0469 
0470 void
0471 AcpiTbDeleteTable (
0472     ACPI_TABLE_DESC         *TableDesc)
0473 {
0474 
0475     /* Table must be mapped or allocated */
0476 
0477     if (!TableDesc->Pointer)
0478     {
0479         return;
0480     }
0481 
0482     switch (TableDesc->Flags & ACPI_TABLE_ORIGIN_MASK)
0483     {
0484     case ACPI_TABLE_ORIGIN_MAPPED:
0485         AcpiOsUnmapMemory (TableDesc->Pointer, TableDesc->Length);
0486         break;
0487 
0488     case ACPI_TABLE_ORIGIN_ALLOCATED:
0489         ACPI_FREE (TableDesc->Pointer);
0490         break;
0491 
0492     default:
0493         break;
0494     }
0495 
0496     TableDesc->Pointer = NULL;
0497 }
0498 
0499 
0500 /*******************************************************************************
0501  *
0502  * FUNCTION:    AcpiTbTerminate
0503  *
0504  * PARAMETERS:  None
0505  *
0506  * RETURN:      None
0507  *
0508  * DESCRIPTION: Delete all internal ACPI tables
0509  *
0510  ******************************************************************************/
0511 
0512 void
0513 AcpiTbTerminate (
0514     void)
0515 {
0516     UINT32                  i;
0517 
0518 
0519     ACPI_FUNCTION_TRACE (TbTerminate);
0520 
0521 
0522     (void) AcpiUtAcquireMutex (ACPI_MTX_TABLES);
0523 
0524     /* Delete the individual tables */
0525 
0526     for (i = 0; i < AcpiGbl_RootTableList.Count; i++)
0527     {
0528         AcpiTbDeleteTable (&AcpiGbl_RootTableList.Tables[i]);
0529     }
0530 
0531     /*
0532      * Delete the root table array if allocated locally. Array cannot be
0533      * mapped, so we don't need to check for that flag.
0534      */
0535     if (AcpiGbl_RootTableList.Flags & ACPI_ROOT_ORIGIN_ALLOCATED)
0536     {
0537         ACPI_FREE (AcpiGbl_RootTableList.Tables);
0538     }
0539 
0540     AcpiGbl_RootTableList.Tables = NULL;
0541     AcpiGbl_RootTableList.Flags = 0;
0542     AcpiGbl_RootTableList.Count = 0;
0543 
0544     ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "ACPI Tables freed\n"));
0545     (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES);
0546 }
0547 
0548 
0549 /*******************************************************************************
0550  *
0551  * FUNCTION:    AcpiTbDeleteNamespaceByOwner
0552  *
0553  * PARAMETERS:  TableIndex          - Table index
0554  *
0555  * RETURN:      Status
0556  *
0557  * DESCRIPTION: Delete all namespace objects created when this table was loaded.
0558  *
0559  ******************************************************************************/
0560 
0561 ACPI_STATUS
0562 AcpiTbDeleteNamespaceByOwner (
0563     UINT32                  TableIndex)
0564 {
0565     ACPI_OWNER_ID           OwnerId;
0566     ACPI_STATUS             Status;
0567 
0568 
0569     ACPI_FUNCTION_TRACE (TbDeleteNamespaceByOwner);
0570 
0571 
0572     Status = AcpiUtAcquireMutex (ACPI_MTX_TABLES);
0573     if (ACPI_FAILURE (Status))
0574     {
0575         return_ACPI_STATUS (Status);
0576     }
0577 
0578     if (TableIndex >= AcpiGbl_RootTableList.Count)
0579     {
0580         /* The table index does not exist */
0581 
0582         (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES);
0583         return_ACPI_STATUS (AE_NOT_EXIST);
0584     }
0585 
0586     /* Get the owner ID for this table, used to delete namespace nodes */
0587 
0588     OwnerId = AcpiGbl_RootTableList.Tables[TableIndex].OwnerId;
0589     (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES);
0590 
0591     /*
0592      * Need to acquire the namespace writer lock to prevent interference
0593      * with any concurrent namespace walks. The interpreter must be
0594      * released during the deletion since the acquisition of the deletion
0595      * lock may block, and also since the execution of a namespace walk
0596      * must be allowed to use the interpreter.
0597      */
0598     (void) AcpiUtReleaseMutex (ACPI_MTX_INTERPRETER);
0599     Status = AcpiUtAcquireWriteLock (&AcpiGbl_NamespaceRwLock);
0600 
0601     AcpiNsDeleteNamespaceByOwner (OwnerId);
0602     if (ACPI_FAILURE (Status))
0603     {
0604         return_ACPI_STATUS (Status);
0605     }
0606 
0607     AcpiUtReleaseWriteLock (&AcpiGbl_NamespaceRwLock);
0608 
0609     Status = AcpiUtAcquireMutex (ACPI_MTX_INTERPRETER);
0610     return_ACPI_STATUS (Status);
0611 }
0612 
0613 
0614 /*******************************************************************************
0615  *
0616  * FUNCTION:    AcpiTbAllocateOwnerId
0617  *
0618  * PARAMETERS:  TableIndex          - Table index
0619  *
0620  * RETURN:      Status
0621  *
0622  * DESCRIPTION: Allocates OwnerId in TableDesc
0623  *
0624  ******************************************************************************/
0625 
0626 ACPI_STATUS
0627 AcpiTbAllocateOwnerId (
0628     UINT32                  TableIndex)
0629 {
0630     ACPI_STATUS             Status = AE_BAD_PARAMETER;
0631 
0632 
0633     ACPI_FUNCTION_TRACE (TbAllocateOwnerId);
0634 
0635 
0636     (void) AcpiUtAcquireMutex (ACPI_MTX_TABLES);
0637     if (TableIndex < AcpiGbl_RootTableList.Count)
0638     {
0639         Status = AcpiUtAllocateOwnerId
0640                     (&(AcpiGbl_RootTableList.Tables[TableIndex].OwnerId));
0641     }
0642 
0643     (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES);
0644     return_ACPI_STATUS (Status);
0645 }
0646 
0647 
0648 /*******************************************************************************
0649  *
0650  * FUNCTION:    AcpiTbReleaseOwnerId
0651  *
0652  * PARAMETERS:  TableIndex          - Table index
0653  *
0654  * RETURN:      Status
0655  *
0656  * DESCRIPTION: Releases OwnerId in TableDesc
0657  *
0658  ******************************************************************************/
0659 
0660 ACPI_STATUS
0661 AcpiTbReleaseOwnerId (
0662     UINT32                  TableIndex)
0663 {
0664     ACPI_STATUS             Status = AE_BAD_PARAMETER;
0665 
0666 
0667     ACPI_FUNCTION_TRACE (TbReleaseOwnerId);
0668 
0669 
0670     (void) AcpiUtAcquireMutex (ACPI_MTX_TABLES);
0671     if (TableIndex < AcpiGbl_RootTableList.Count)
0672     {
0673         AcpiUtReleaseOwnerId (
0674             &(AcpiGbl_RootTableList.Tables[TableIndex].OwnerId));
0675         Status = AE_OK;
0676     }
0677 
0678     (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES);
0679     return_ACPI_STATUS (Status);
0680 }
0681 
0682 
0683 /*******************************************************************************
0684  *
0685  * FUNCTION:    AcpiTbGetOwnerId
0686  *
0687  * PARAMETERS:  TableIndex          - Table index
0688  *              OwnerId             - Where the table OwnerId is returned
0689  *
0690  * RETURN:      Status
0691  *
0692  * DESCRIPTION: returns OwnerId for the ACPI table
0693  *
0694  ******************************************************************************/
0695 
0696 ACPI_STATUS
0697 AcpiTbGetOwnerId (
0698     UINT32                  TableIndex,
0699     ACPI_OWNER_ID           *OwnerId)
0700 {
0701     ACPI_STATUS             Status = AE_BAD_PARAMETER;
0702 
0703 
0704     ACPI_FUNCTION_TRACE (TbGetOwnerId);
0705 
0706 
0707     (void) AcpiUtAcquireMutex (ACPI_MTX_TABLES);
0708     if (TableIndex < AcpiGbl_RootTableList.Count)
0709     {
0710         *OwnerId = AcpiGbl_RootTableList.Tables[TableIndex].OwnerId;
0711         Status = AE_OK;
0712     }
0713 
0714     (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES);
0715     return_ACPI_STATUS (Status);
0716 }
0717 
0718 
0719 /*******************************************************************************
0720  *
0721  * FUNCTION:    AcpiTbIsTableLoaded
0722  *
0723  * PARAMETERS:  TableIndex          - Table index
0724  *
0725  * RETURN:      Table Loaded Flag
0726  *
0727  ******************************************************************************/
0728 
0729 BOOLEAN
0730 AcpiTbIsTableLoaded (
0731     UINT32                  TableIndex)
0732 {
0733     BOOLEAN                 IsLoaded = FALSE;
0734 
0735 
0736     (void) AcpiUtAcquireMutex (ACPI_MTX_TABLES);
0737     if (TableIndex < AcpiGbl_RootTableList.Count)
0738     {
0739         IsLoaded = (BOOLEAN)
0740             (AcpiGbl_RootTableList.Tables[TableIndex].Flags &
0741             ACPI_TABLE_IS_LOADED);
0742     }
0743 
0744     (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES);
0745     return (IsLoaded);
0746 }
0747 
0748 
0749 /*******************************************************************************
0750  *
0751  * FUNCTION:    AcpiTbSetTableLoadedFlag
0752  *
0753  * PARAMETERS:  TableIndex          - Table index
0754  *              IsLoaded            - TRUE if table is loaded, FALSE otherwise
0755  *
0756  * RETURN:      None
0757  *
0758  * DESCRIPTION: Sets the table loaded flag to either TRUE or FALSE.
0759  *
0760  ******************************************************************************/
0761 
0762 void
0763 AcpiTbSetTableLoadedFlag (
0764     UINT32                  TableIndex,
0765     BOOLEAN                 IsLoaded)
0766 {
0767 
0768     (void) AcpiUtAcquireMutex (ACPI_MTX_TABLES);
0769     if (TableIndex < AcpiGbl_RootTableList.Count)
0770     {
0771         if (IsLoaded)
0772         {
0773             AcpiGbl_RootTableList.Tables[TableIndex].Flags |=
0774                 ACPI_TABLE_IS_LOADED;
0775         }
0776         else
0777         {
0778             AcpiGbl_RootTableList.Tables[TableIndex].Flags &=
0779                 ~ACPI_TABLE_IS_LOADED;
0780         }
0781     }
0782 
0783     (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES);
0784 }
0785