ReactOS Fundraising Campaign 2012
 
€ 4,410 / € 30,000

Information | Donate

Home | Info | Community | Development | myReactOS | Contact Us

  1. Home
  2. Community
  3. Development
  4. myReactOS
  5. Fundraiser 2012

  1. Main Page
  2. Alphabetical List
  3. Data Structures
  4. Directories
  5. File List
  6. Data Fields
  7. Globals
  8. Related Pages

ReactOS Development > Doxygen

tbinstal.c
Go to the documentation of this file.
00001 /******************************************************************************
00002  *
00003  * Module Name: tbinstal - ACPI table installation and removal
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 __TBINSTAL_C__
00118 
00119 #include "acpi.h"
00120 #include "accommon.h"
00121 #include "acnamesp.h"
00122 #include "actables.h"
00123 
00124 
00125 #define _COMPONENT          ACPI_TABLES
00126         ACPI_MODULE_NAME    ("tbinstal")
00127 
00128 
00129 /******************************************************************************
00130  *
00131  * FUNCTION:    AcpiTbVerifyTable
00132  *
00133  * PARAMETERS:  TableDesc           - table
00134  *
00135  * RETURN:      Status
00136  *
00137  * DESCRIPTION: this function is called to verify and map table
00138  *
00139  *****************************************************************************/
00140 
00141 ACPI_STATUS
00142 AcpiTbVerifyTable (
00143     ACPI_TABLE_DESC         *TableDesc)
00144 {
00145     ACPI_STATUS             Status = AE_OK;
00146 
00147 
00148     ACPI_FUNCTION_TRACE (TbVerifyTable);
00149 
00150 
00151     /* Map the table if necessary */
00152 
00153     if (!TableDesc->Pointer)
00154     {
00155         if ((TableDesc->Flags & ACPI_TABLE_ORIGIN_MASK) ==
00156             ACPI_TABLE_ORIGIN_MAPPED)
00157         {
00158             TableDesc->Pointer = AcpiOsMapMemory (
00159                 TableDesc->Address, TableDesc->Length);
00160         }
00161 
00162         if (!TableDesc->Pointer)
00163         {
00164             return_ACPI_STATUS (AE_NO_MEMORY);
00165         }
00166     }
00167 
00168     /* FACS is the odd table, has no standard ACPI header and no checksum */
00169 
00170     if (!ACPI_COMPARE_NAME (&TableDesc->Signature, ACPI_SIG_FACS))
00171     {
00172         /* Always calculate checksum, ignore bad checksum if requested */
00173 
00174         Status = AcpiTbVerifyChecksum (TableDesc->Pointer, TableDesc->Length);
00175     }
00176 
00177     return_ACPI_STATUS (Status);
00178 }
00179 
00180 
00181 /*******************************************************************************
00182  *
00183  * FUNCTION:    AcpiTbAddTable
00184  *
00185  * PARAMETERS:  TableDesc           - Table descriptor
00186  *              TableIndex          - Where the table index is returned
00187  *
00188  * RETURN:      Status
00189  *
00190  * DESCRIPTION: This function is called to add an ACPI table. It is used to
00191  *              dynamically load tables via the Load and LoadTable AML
00192  *              operators.
00193  *
00194  ******************************************************************************/
00195 
00196 ACPI_STATUS
00197 AcpiTbAddTable (
00198     ACPI_TABLE_DESC         *TableDesc,
00199     UINT32                  *TableIndex)
00200 {
00201     UINT32                  i;
00202     ACPI_STATUS             Status = AE_OK;
00203     ACPI_TABLE_HEADER       *OverrideTable = NULL;
00204 
00205 
00206     ACPI_FUNCTION_TRACE (TbAddTable);
00207 
00208 
00209     if (!TableDesc->Pointer)
00210     {
00211         Status = AcpiTbVerifyTable (TableDesc);
00212         if (ACPI_FAILURE (Status) || !TableDesc->Pointer)
00213         {
00214             return_ACPI_STATUS (Status);
00215         }
00216     }
00217 
00218     /*
00219      * Validate the incoming table signature.
00220      *
00221      * 1) Originally, we checked the table signature for "SSDT" or "PSDT".
00222      * 2) We added support for OEMx tables, signature "OEM".
00223      * 3) Valid tables were encountered with a null signature, so we just
00224      *    gave up on validating the signature, (05/2008).
00225      * 4) We encountered non-AML tables such as the MADT, which caused
00226      *    interpreter errors and kernel faults. So now, we once again allow
00227      *    only "SSDT", "OEMx", and now, also a null signature. (05/2011).
00228      */
00229     if ((TableDesc->Pointer->Signature[0] != 0x00) &&
00230        (!ACPI_COMPARE_NAME (TableDesc->Pointer->Signature, ACPI_SIG_SSDT)) &&
00231        (ACPI_STRNCMP (TableDesc->Pointer->Signature, "OEM", 3)))
00232     {
00233         ACPI_ERROR ((AE_INFO,
00234             "Table has invalid signature [%4.4s] (0x%8.8X), must be SSDT or OEMx",
00235             AcpiUtValidAcpiName (*(UINT32 *) TableDesc->Pointer->Signature) ?
00236                 TableDesc->Pointer->Signature : "????",
00237             *(UINT32 *) TableDesc->Pointer->Signature));
00238 
00239         return_ACPI_STATUS (AE_BAD_SIGNATURE);
00240     }
00241 
00242     (void) AcpiUtAcquireMutex (ACPI_MTX_TABLES);
00243 
00244     /* Check if table is already registered */
00245 
00246     for (i = 0; i < AcpiGbl_RootTableList.CurrentTableCount; ++i)
00247     {
00248         if (!AcpiGbl_RootTableList.Tables[i].Pointer)
00249         {
00250             Status = AcpiTbVerifyTable (&AcpiGbl_RootTableList.Tables[i]);
00251             if (ACPI_FAILURE (Status) ||
00252                 !AcpiGbl_RootTableList.Tables[i].Pointer)
00253             {
00254                 continue;
00255             }
00256         }
00257 
00258         /*
00259          * Check for a table match on the entire table length,
00260          * not just the header.
00261          */
00262         if (TableDesc->Length != AcpiGbl_RootTableList.Tables[i].Length)
00263         {
00264             continue;
00265         }
00266 
00267         if (ACPI_MEMCMP (TableDesc->Pointer,
00268                 AcpiGbl_RootTableList.Tables[i].Pointer,
00269                 AcpiGbl_RootTableList.Tables[i].Length))
00270         {
00271             continue;
00272         }
00273 
00274         /*
00275          * Note: the current mechanism does not unregister a table if it is
00276          * dynamically unloaded. The related namespace entries are deleted,
00277          * but the table remains in the root table list.
00278          *
00279          * The assumption here is that the number of different tables that
00280          * will be loaded is actually small, and there is minimal overhead
00281          * in just keeping the table in case it is needed again.
00282          *
00283          * If this assumption changes in the future (perhaps on large
00284          * machines with many table load/unload operations), tables will
00285          * need to be unregistered when they are unloaded, and slots in the
00286          * root table list should be reused when empty.
00287          */
00288 
00289         /*
00290          * Table is already registered.
00291          * We can delete the table that was passed as a parameter.
00292          */
00293         AcpiTbDeleteTable (TableDesc);
00294         *TableIndex = i;
00295 
00296         if (AcpiGbl_RootTableList.Tables[i].Flags & ACPI_TABLE_IS_LOADED)
00297         {
00298             /* Table is still loaded, this is an error */
00299 
00300             Status = AE_ALREADY_EXISTS;
00301             goto Release;
00302         }
00303         else
00304         {
00305             /* Table was unloaded, allow it to be reloaded */
00306 
00307             TableDesc->Pointer = AcpiGbl_RootTableList.Tables[i].Pointer;
00308             TableDesc->Address = AcpiGbl_RootTableList.Tables[i].Address;
00309             Status = AE_OK;
00310             goto PrintHeader;
00311         }
00312     }
00313 
00314     /*
00315      * ACPI Table Override:
00316      * Allow the host to override dynamically loaded tables.
00317      */
00318     Status = AcpiOsTableOverride (TableDesc->Pointer, &OverrideTable);
00319     if (ACPI_SUCCESS (Status) && OverrideTable)
00320     {
00321         ACPI_INFO ((AE_INFO,
00322             "%4.4s @ 0x%p Table override, replaced with:",
00323             TableDesc->Pointer->Signature,
00324             ACPI_CAST_PTR (void, TableDesc->Address)));
00325 
00326         /* We can delete the table that was passed as a parameter */
00327 
00328         AcpiTbDeleteTable (TableDesc);
00329 
00330         /* Setup descriptor for the new table */
00331 
00332         TableDesc->Address = ACPI_PTR_TO_PHYSADDR (OverrideTable);
00333         TableDesc->Pointer = OverrideTable;
00334         TableDesc->Length = OverrideTable->Length;
00335         TableDesc->Flags = ACPI_TABLE_ORIGIN_OVERRIDE;
00336     }
00337 
00338     /* Add the table to the global root table list */
00339 
00340     Status = AcpiTbStoreTable (TableDesc->Address, TableDesc->Pointer,
00341                 TableDesc->Length, TableDesc->Flags, TableIndex);
00342     if (ACPI_FAILURE (Status))
00343     {
00344         goto Release;
00345     }
00346 
00347 PrintHeader:
00348     AcpiTbPrintTableHeader (TableDesc->Address, TableDesc->Pointer);
00349 
00350 Release:
00351     (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES);
00352     return_ACPI_STATUS (Status);
00353 }
00354 
00355 
00356 /*******************************************************************************
00357  *
00358  * FUNCTION:    AcpiTbResizeRootTableList
00359  *
00360  * PARAMETERS:  None
00361  *
00362  * RETURN:      Status
00363  *
00364  * DESCRIPTION: Expand the size of global table array
00365  *
00366  ******************************************************************************/
00367 
00368 ACPI_STATUS
00369 AcpiTbResizeRootTableList (
00370     void)
00371 {
00372     ACPI_TABLE_DESC         *Tables;
00373 
00374 
00375     ACPI_FUNCTION_TRACE (TbResizeRootTableList);
00376 
00377 
00378     /* AllowResize flag is a parameter to AcpiInitializeTables */
00379 
00380     if (!(AcpiGbl_RootTableList.Flags & ACPI_ROOT_ALLOW_RESIZE))
00381     {
00382         ACPI_ERROR ((AE_INFO, "Resize of Root Table Array is not allowed"));
00383         return_ACPI_STATUS (AE_SUPPORT);
00384     }
00385 
00386     /* Increase the Table Array size */
00387 
00388     Tables = ACPI_ALLOCATE_ZEROED (
00389         ((ACPI_SIZE) AcpiGbl_RootTableList.MaxTableCount +
00390             ACPI_ROOT_TABLE_SIZE_INCREMENT) *
00391         sizeof (ACPI_TABLE_DESC));
00392     if (!Tables)
00393     {
00394         ACPI_ERROR ((AE_INFO, "Could not allocate new root table array"));
00395         return_ACPI_STATUS (AE_NO_MEMORY);
00396     }
00397 
00398     /* Copy and free the previous table array */
00399 
00400     if (AcpiGbl_RootTableList.Tables)
00401     {
00402         ACPI_MEMCPY (Tables, AcpiGbl_RootTableList.Tables,
00403             (ACPI_SIZE) AcpiGbl_RootTableList.MaxTableCount * sizeof (ACPI_TABLE_DESC));
00404 
00405         if (AcpiGbl_RootTableList.Flags & ACPI_ROOT_ORIGIN_ALLOCATED)
00406         {
00407             ACPI_FREE (AcpiGbl_RootTableList.Tables);
00408         }
00409     }
00410 
00411     AcpiGbl_RootTableList.Tables = Tables;
00412     AcpiGbl_RootTableList.MaxTableCount += ACPI_ROOT_TABLE_SIZE_INCREMENT;
00413     AcpiGbl_RootTableList.Flags |= (UINT8) ACPI_ROOT_ORIGIN_ALLOCATED;
00414 
00415     return_ACPI_STATUS (AE_OK);
00416 }
00417 
00418 
00419 /*******************************************************************************
00420  *
00421  * FUNCTION:    AcpiTbStoreTable
00422  *
00423  * PARAMETERS:  Address             - Table address
00424  *              Table               - Table header
00425  *              Length              - Table length
00426  *              Flags               - flags
00427  *
00428  * RETURN:      Status and table index.
00429  *
00430  * DESCRIPTION: Add an ACPI table to the global table list
00431  *
00432  ******************************************************************************/
00433 
00434 ACPI_STATUS
00435 AcpiTbStoreTable (
00436     ACPI_PHYSICAL_ADDRESS   Address,
00437     ACPI_TABLE_HEADER       *Table,
00438     UINT32                  Length,
00439     UINT8                   Flags,
00440     UINT32                  *TableIndex)
00441 {
00442     ACPI_STATUS             Status;
00443     ACPI_TABLE_DESC         *NewTable;
00444 
00445 
00446     /* Ensure that there is room for the table in the Root Table List */
00447 
00448     if (AcpiGbl_RootTableList.CurrentTableCount >=
00449         AcpiGbl_RootTableList.MaxTableCount)
00450     {
00451         Status = AcpiTbResizeRootTableList();
00452         if (ACPI_FAILURE (Status))
00453         {
00454             return (Status);
00455         }
00456     }
00457 
00458     NewTable = &AcpiGbl_RootTableList.Tables[AcpiGbl_RootTableList.CurrentTableCount];
00459 
00460     /* Initialize added table */
00461 
00462     NewTable->Address = Address;
00463     NewTable->Pointer = Table;
00464     NewTable->Length = Length;
00465     NewTable->OwnerId = 0;
00466     NewTable->Flags = Flags;
00467 
00468     ACPI_MOVE_32_TO_32 (&NewTable->Signature, Table->Signature);
00469 
00470     *TableIndex = AcpiGbl_RootTableList.CurrentTableCount;
00471     AcpiGbl_RootTableList.CurrentTableCount++;
00472     return (AE_OK);
00473 }
00474 
00475 
00476 /*******************************************************************************
00477  *
00478  * FUNCTION:    AcpiTbDeleteTable
00479  *
00480  * PARAMETERS:  TableIndex          - Table index
00481  *
00482  * RETURN:      None
00483  *
00484  * DESCRIPTION: Delete one internal ACPI table
00485  *
00486  ******************************************************************************/
00487 
00488 void
00489 AcpiTbDeleteTable (
00490     ACPI_TABLE_DESC         *TableDesc)
00491 {
00492 
00493     /* Table must be mapped or allocated */
00494 
00495     if (!TableDesc->Pointer)
00496     {
00497         return;
00498     }
00499 
00500     switch (TableDesc->Flags & ACPI_TABLE_ORIGIN_MASK)
00501     {
00502     case ACPI_TABLE_ORIGIN_MAPPED:
00503         AcpiOsUnmapMemory (TableDesc->Pointer, TableDesc->Length);
00504         break;
00505 
00506     case ACPI_TABLE_ORIGIN_ALLOCATED:
00507         ACPI_FREE (TableDesc->Pointer);
00508         break;
00509 
00510     default:
00511         break;
00512     }
00513 
00514     TableDesc->Pointer = NULL;
00515 }
00516 
00517 
00518 /*******************************************************************************
00519  *
00520  * FUNCTION:    AcpiTbTerminate
00521  *
00522  * PARAMETERS:  None
00523  *
00524  * RETURN:      None
00525  *
00526  * DESCRIPTION: Delete all internal ACPI tables
00527  *
00528  ******************************************************************************/
00529 
00530 void
00531 AcpiTbTerminate (
00532     void)
00533 {
00534     UINT32                  i;
00535 
00536 
00537     ACPI_FUNCTION_TRACE (TbTerminate);
00538 
00539 
00540     (void) AcpiUtAcquireMutex (ACPI_MTX_TABLES);
00541 
00542     /* Delete the individual tables */
00543 
00544     for (i = 0; i < AcpiGbl_RootTableList.CurrentTableCount; i++)
00545     {
00546         AcpiTbDeleteTable (&AcpiGbl_RootTableList.Tables[i]);
00547     }
00548 
00549     /*
00550      * Delete the root table array if allocated locally. Array cannot be
00551      * mapped, so we don't need to check for that flag.
00552      */
00553     if (AcpiGbl_RootTableList.Flags & ACPI_ROOT_ORIGIN_ALLOCATED)
00554     {
00555         ACPI_FREE (AcpiGbl_RootTableList.Tables);
00556     }
00557 
00558     AcpiGbl_RootTableList.Tables = NULL;
00559     AcpiGbl_RootTableList.Flags = 0;
00560     AcpiGbl_RootTableList.CurrentTableCount = 0;
00561 
00562     ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "ACPI Tables freed\n"));
00563     (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES);
00564 }
00565 
00566 
00567 /*******************************************************************************
00568  *
00569  * FUNCTION:    AcpiTbDeleteNamespaceByOwner
00570  *
00571  * PARAMETERS:  TableIndex          - Table index
00572  *
00573  * RETURN:      Status
00574  *
00575  * DESCRIPTION: Delete all namespace objects created when this table was loaded.
00576  *
00577  ******************************************************************************/
00578 
00579 ACPI_STATUS
00580 AcpiTbDeleteNamespaceByOwner (
00581     UINT32                  TableIndex)
00582 {
00583     ACPI_OWNER_ID           OwnerId;
00584     ACPI_STATUS             Status;
00585 
00586 
00587     ACPI_FUNCTION_TRACE (TbDeleteNamespaceByOwner);
00588 
00589 
00590     Status = AcpiUtAcquireMutex (ACPI_MTX_TABLES);
00591     if (ACPI_FAILURE (Status))
00592     {
00593         return_ACPI_STATUS (Status);
00594     }
00595 
00596     if (TableIndex >= AcpiGbl_RootTableList.CurrentTableCount)
00597     {
00598         /* The table index does not exist */
00599 
00600         (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES);
00601         return_ACPI_STATUS (AE_NOT_EXIST);
00602     }
00603 
00604     /* Get the owner ID for this table, used to delete namespace nodes */
00605 
00606     OwnerId = AcpiGbl_RootTableList.Tables[TableIndex].OwnerId;
00607     (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES);
00608 
00609     /*
00610      * Need to acquire the namespace writer lock to prevent interference
00611      * with any concurrent namespace walks. The interpreter must be
00612      * released during the deletion since the acquisition of the deletion
00613      * lock may block, and also since the execution of a namespace walk
00614      * must be allowed to use the interpreter.
00615      */
00616     (void) AcpiUtReleaseMutex (ACPI_MTX_INTERPRETER);
00617     Status = AcpiUtAcquireWriteLock (&AcpiGbl_NamespaceRwLock);
00618 
00619     AcpiNsDeleteNamespaceByOwner (OwnerId);
00620     if (ACPI_FAILURE (Status))
00621     {
00622         return_ACPI_STATUS (Status);
00623     }
00624 
00625     AcpiUtReleaseWriteLock (&AcpiGbl_NamespaceRwLock);
00626 
00627     Status = AcpiUtAcquireMutex (ACPI_MTX_INTERPRETER);
00628     return_ACPI_STATUS (Status);
00629 }
00630 
00631 
00632 /*******************************************************************************
00633  *
00634  * FUNCTION:    AcpiTbAllocateOwnerId
00635  *
00636  * PARAMETERS:  TableIndex          - Table index
00637  *
00638  * RETURN:      Status
00639  *
00640  * DESCRIPTION: Allocates OwnerId in TableDesc
00641  *
00642  ******************************************************************************/
00643 
00644 ACPI_STATUS
00645 AcpiTbAllocateOwnerId (
00646     UINT32                  TableIndex)
00647 {
00648     ACPI_STATUS             Status = AE_BAD_PARAMETER;
00649 
00650 
00651     ACPI_FUNCTION_TRACE (TbAllocateOwnerId);
00652 
00653 
00654     (void) AcpiUtAcquireMutex (ACPI_MTX_TABLES);
00655     if (TableIndex < AcpiGbl_RootTableList.CurrentTableCount)
00656     {
00657         Status = AcpiUtAllocateOwnerId
00658                     (&(AcpiGbl_RootTableList.Tables[TableIndex].OwnerId));
00659     }
00660 
00661     (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES);
00662     return_ACPI_STATUS (Status);
00663 }
00664 
00665 
00666 /*******************************************************************************
00667  *
00668  * FUNCTION:    AcpiTbReleaseOwnerId
00669  *
00670  * PARAMETERS:  TableIndex          - Table index
00671  *
00672  * RETURN:      Status
00673  *
00674  * DESCRIPTION: Releases OwnerId in TableDesc
00675  *
00676  ******************************************************************************/
00677 
00678 ACPI_STATUS
00679 AcpiTbReleaseOwnerId (
00680     UINT32                  TableIndex)
00681 {
00682     ACPI_STATUS             Status = AE_BAD_PARAMETER;
00683 
00684 
00685     ACPI_FUNCTION_TRACE (TbReleaseOwnerId);
00686 
00687 
00688     (void) AcpiUtAcquireMutex (ACPI_MTX_TABLES);
00689     if (TableIndex < AcpiGbl_RootTableList.CurrentTableCount)
00690     {
00691         AcpiUtReleaseOwnerId (
00692             &(AcpiGbl_RootTableList.Tables[TableIndex].OwnerId));
00693         Status = AE_OK;
00694     }
00695 
00696     (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES);
00697     return_ACPI_STATUS (Status);
00698 }
00699 
00700 
00701 /*******************************************************************************
00702  *
00703  * FUNCTION:    AcpiTbGetOwnerId
00704  *
00705  * PARAMETERS:  TableIndex          - Table index
00706  *              OwnerId             - Where the table OwnerId is returned
00707  *
00708  * RETURN:      Status
00709  *
00710  * DESCRIPTION: returns OwnerId for the ACPI table
00711  *
00712  ******************************************************************************/
00713 
00714 ACPI_STATUS
00715 AcpiTbGetOwnerId (
00716     UINT32                  TableIndex,
00717     ACPI_OWNER_ID           *OwnerId)
00718 {
00719     ACPI_STATUS             Status = AE_BAD_PARAMETER;
00720 
00721 
00722     ACPI_FUNCTION_TRACE (TbGetOwnerId);
00723 
00724 
00725     (void) AcpiUtAcquireMutex (ACPI_MTX_TABLES);
00726     if (TableIndex < AcpiGbl_RootTableList.CurrentTableCount)
00727     {
00728         *OwnerId = AcpiGbl_RootTableList.Tables[TableIndex].OwnerId;
00729         Status = AE_OK;
00730     }
00731 
00732     (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES);
00733     return_ACPI_STATUS (Status);
00734 }
00735 
00736 
00737 /*******************************************************************************
00738  *
00739  * FUNCTION:    AcpiTbIsTableLoaded
00740  *
00741  * PARAMETERS:  TableIndex          - Table index
00742  *
00743  * RETURN:      Table Loaded Flag
00744  *
00745  ******************************************************************************/
00746 
00747 BOOLEAN
00748 AcpiTbIsTableLoaded (
00749     UINT32                  TableIndex)
00750 {
00751     BOOLEAN                 IsLoaded = FALSE;
00752 
00753 
00754     (void) AcpiUtAcquireMutex (ACPI_MTX_TABLES);
00755     if (TableIndex < AcpiGbl_RootTableList.CurrentTableCount)
00756     {
00757         IsLoaded = (BOOLEAN)
00758             (AcpiGbl_RootTableList.Tables[TableIndex].Flags &
00759             ACPI_TABLE_IS_LOADED);
00760     }
00761 
00762     (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES);
00763     return (IsLoaded);
00764 }
00765 
00766 
00767 /*******************************************************************************
00768  *
00769  * FUNCTION:    AcpiTbSetTableLoadedFlag
00770  *
00771  * PARAMETERS:  TableIndex          - Table index
00772  *              IsLoaded            - TRUE if table is loaded, FALSE otherwise
00773  *
00774  * RETURN:      None
00775  *
00776  * DESCRIPTION: Sets the table loaded flag to either TRUE or FALSE.
00777  *
00778  ******************************************************************************/
00779 
00780 void
00781 AcpiTbSetTableLoadedFlag (
00782     UINT32                  TableIndex,
00783     BOOLEAN                 IsLoaded)
00784 {
00785 
00786     (void) AcpiUtAcquireMutex (ACPI_MTX_TABLES);
00787     if (TableIndex < AcpiGbl_RootTableList.CurrentTableCount)
00788     {
00789         if (IsLoaded)
00790         {
00791             AcpiGbl_RootTableList.Tables[TableIndex].Flags |=
00792                 ACPI_TABLE_IS_LOADED;
00793         }
00794         else
00795         {
00796             AcpiGbl_RootTableList.Tables[TableIndex].Flags &=
00797                 ~ACPI_TABLE_IS_LOADED;
00798         }
00799     }
00800 
00801     (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES);
00802 }
00803 

Generated on Fri May 25 2012 04:25:39 for ReactOS by doxygen 1.7.6.1

ReactOS is a registered trademark or a trademark of ReactOS Foundation in the United States and other countries.