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

tbxface.c
Go to the documentation of this file.
00001 /******************************************************************************
00002  *
00003  * Module Name: tbxface - Public interfaces to the ACPI subsystem
00004  *                         ACPI table oriented interfaces
00005  *
00006  *****************************************************************************/
00007 
00008 /******************************************************************************
00009  *
00010  * 1. Copyright Notice
00011  *
00012  * Some or all of this work - Copyright (c) 1999 - 2011, Intel Corp.
00013  * All rights reserved.
00014  *
00015  * 2. License
00016  *
00017  * 2.1. This is your license from Intel Corp. under its intellectual property
00018  * rights.  You may have additional license terms from the party that provided
00019  * you this software, covering your right to use that party's intellectual
00020  * property rights.
00021  *
00022  * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
00023  * copy of the source code appearing in this file ("Covered Code") an
00024  * irrevocable, perpetual, worldwide license under Intel's copyrights in the
00025  * base code distributed originally by Intel ("Original Intel Code") to copy,
00026  * make derivatives, distribute, use and display any portion of the Covered
00027  * Code in any form, with the right to sublicense such rights; and
00028  *
00029  * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
00030  * license (with the right to sublicense), under only those claims of Intel
00031  * patents that are infringed by the Original Intel Code, to make, use, sell,
00032  * offer to sell, and import the Covered Code and derivative works thereof
00033  * solely to the minimum extent necessary to exercise the above copyright
00034  * license, and in no event shall the patent license extend to any additions
00035  * to or modifications of the Original Intel Code.  No other license or right
00036  * is granted directly or by implication, estoppel or otherwise;
00037  *
00038  * The above copyright and patent license is granted only if the following
00039  * conditions are met:
00040  *
00041  * 3. Conditions
00042  *
00043  * 3.1. Redistribution of Source with Rights to Further Distribute Source.
00044  * Redistribution of source code of any substantial portion of the Covered
00045  * Code or modification with rights to further distribute source must include
00046  * the above Copyright Notice, the above License, this list of Conditions,
00047  * and the following Disclaimer and Export Compliance provision.  In addition,
00048  * Licensee must cause all Covered Code to which Licensee contributes to
00049  * contain a file documenting the changes Licensee made to create that Covered
00050  * Code and the date of any change.  Licensee must include in that file the
00051  * documentation of any changes made by any predecessor Licensee.  Licensee
00052  * must include a prominent statement that the modification is derived,
00053  * directly or indirectly, from Original Intel Code.
00054  *
00055  * 3.2. Redistribution of Source with no Rights to Further Distribute Source.
00056  * Redistribution of source code of any substantial portion of the Covered
00057  * Code or modification without rights to further distribute source must
00058  * include the following Disclaimer and Export Compliance provision in the
00059  * documentation and/or other materials provided with distribution.  In
00060  * addition, Licensee may not authorize further sublicense of source of any
00061  * portion of the Covered Code, and must include terms to the effect that the
00062  * license from Licensee to its licensee is limited to the intellectual
00063  * property embodied in the software Licensee provides to its licensee, and
00064  * not to intellectual property embodied in modifications its licensee may
00065  * make.
00066  *
00067  * 3.3. Redistribution of Executable. Redistribution in executable form of any
00068  * substantial portion of the Covered Code or modification must reproduce the
00069  * above Copyright Notice, and the following Disclaimer and Export Compliance
00070  * provision in the documentation and/or other materials provided with the
00071  * distribution.
00072  *
00073  * 3.4. Intel retains all right, title, and interest in and to the Original
00074  * Intel Code.
00075  *
00076  * 3.5. Neither the name Intel nor any other trademark owned or controlled by
00077  * Intel shall be used in advertising or otherwise to promote the sale, use or
00078  * other dealings in products derived from or relating to the Covered Code
00079  * without prior written authorization from Intel.
00080  *
00081  * 4. Disclaimer and Export Compliance
00082  *
00083  * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
00084  * HERE.  ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
00085  * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT,  ASSISTANCE,
00086  * INSTALLATION, TRAINING OR OTHER SERVICES.  INTEL WILL NOT PROVIDE ANY
00087  * UPDATES, ENHANCEMENTS OR EXTENSIONS.  INTEL SPECIFICALLY DISCLAIMS ANY
00088  * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
00089  * PARTICULAR PURPOSE.
00090  *
00091  * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
00092  * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
00093  * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
00094  * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
00095  * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
00096  * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES.  THESE LIMITATIONS
00097  * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
00098  * LIMITED REMEDY.
00099  *
00100  * 4.3. Licensee shall not export, either directly or indirectly, any of this
00101  * software or system incorporating such software without first obtaining any
00102  * required license or other approval from the U. S. Department of Commerce or
00103  * any other agency or department of the United States Government.  In the
00104  * event Licensee exports any such software from the United States or
00105  * re-exports any such software from a foreign destination, Licensee shall
00106  * ensure that the distribution and export/re-export of the software is in
00107  * compliance with all laws, regulations, orders, or other restrictions of the
00108  * U.S. Export Administration Regulations. Licensee agrees that neither it nor
00109  * any of its subsidiaries will export/re-export any technical data, process,
00110  * software, or service, directly or indirectly, to any country for which the
00111  * United States government or any agency thereof requires an export license,
00112  * other governmental approval, or letter of assurance, without first obtaining
00113  * such license, approval or letter.
00114  *
00115  *****************************************************************************/
00116 
00117 #define __TBXFACE_C__
00118 
00119 #include "acpi.h"
00120 #include "accommon.h"
00121 #include "acnamesp.h"
00122 #include "actables.h"
00123 
00124 #define _COMPONENT          ACPI_TABLES
00125         ACPI_MODULE_NAME    ("tbxface")
00126 
00127 /* Local prototypes */
00128 
00129 static ACPI_STATUS
00130 AcpiTbLoadNamespace (
00131     void);
00132 
00133 
00134 /*******************************************************************************
00135  *
00136  * FUNCTION:    AcpiAllocateRootTable
00137  *
00138  * PARAMETERS:  InitialTableCount   - Size of InitialTableArray, in number of
00139  *                                    ACPI_TABLE_DESC structures
00140  *
00141  * RETURN:      Status
00142  *
00143  * DESCRIPTION: Allocate a root table array. Used by iASL compiler and
00144  *              AcpiInitializeTables.
00145  *
00146  ******************************************************************************/
00147 
00148 ACPI_STATUS
00149 AcpiAllocateRootTable (
00150     UINT32                  InitialTableCount)
00151 {
00152 
00153     AcpiGbl_RootTableList.MaxTableCount = InitialTableCount;
00154     AcpiGbl_RootTableList.Flags = ACPI_ROOT_ALLOW_RESIZE;
00155 
00156     return (AcpiTbResizeRootTableList ());
00157 }
00158 
00159 
00160 /*******************************************************************************
00161  *
00162  * FUNCTION:    AcpiInitializeTables
00163  *
00164  * PARAMETERS:  InitialTableArray   - Pointer to an array of pre-allocated
00165  *                                    ACPI_TABLE_DESC structures. If NULL, the
00166  *                                    array is dynamically allocated.
00167  *              InitialTableCount   - Size of InitialTableArray, in number of
00168  *                                    ACPI_TABLE_DESC structures
00169  *              AllowRealloc        - Flag to tell Table Manager if resize of
00170  *                                    pre-allocated array is allowed. Ignored
00171  *                                    if InitialTableArray is NULL.
00172  *
00173  * RETURN:      Status
00174  *
00175  * DESCRIPTION: Initialize the table manager, get the RSDP and RSDT/XSDT.
00176  *
00177  * NOTE:        Allows static allocation of the initial table array in order
00178  *              to avoid the use of dynamic memory in confined environments
00179  *              such as the kernel boot sequence where it may not be available.
00180  *
00181  *              If the host OS memory managers are initialized, use NULL for
00182  *              InitialTableArray, and the table will be dynamically allocated.
00183  *
00184  ******************************************************************************/
00185 
00186 ACPI_STATUS
00187 AcpiInitializeTables (
00188     ACPI_TABLE_DESC         *InitialTableArray,
00189     UINT32                  InitialTableCount,
00190     BOOLEAN                 AllowResize)
00191 {
00192     ACPI_PHYSICAL_ADDRESS   RsdpAddress;
00193     ACPI_STATUS             Status;
00194 
00195 
00196     ACPI_FUNCTION_TRACE (AcpiInitializeTables);
00197 
00198 
00199     /*
00200      * Set up the Root Table Array
00201      * Allocate the table array if requested
00202      */
00203     if (!InitialTableArray)
00204     {
00205         Status = AcpiAllocateRootTable (InitialTableCount);
00206         if (ACPI_FAILURE (Status))
00207         {
00208             return_ACPI_STATUS (Status);
00209         }
00210     }
00211     else
00212     {
00213         /* Root Table Array has been statically allocated by the host */
00214 
00215         ACPI_MEMSET (InitialTableArray, 0,
00216             (ACPI_SIZE) InitialTableCount * sizeof (ACPI_TABLE_DESC));
00217 
00218         AcpiGbl_RootTableList.Tables = InitialTableArray;
00219         AcpiGbl_RootTableList.MaxTableCount = InitialTableCount;
00220         AcpiGbl_RootTableList.Flags = ACPI_ROOT_ORIGIN_UNKNOWN;
00221         if (AllowResize)
00222         {
00223             AcpiGbl_RootTableList.Flags |= ACPI_ROOT_ALLOW_RESIZE;
00224         }
00225     }
00226 
00227     /* Get the address of the RSDP */
00228 
00229     RsdpAddress = AcpiOsGetRootPointer ();
00230     if (!RsdpAddress)
00231     {
00232         return_ACPI_STATUS (AE_NOT_FOUND);
00233     }
00234 
00235     /*
00236      * Get the root table (RSDT or XSDT) and extract all entries to the local
00237      * Root Table Array. This array contains the information of the RSDT/XSDT
00238      * in a common, more useable format.
00239      */
00240     Status = AcpiTbParseRootTable (RsdpAddress);
00241     return_ACPI_STATUS (Status);
00242 }
00243 
00244 ACPI_EXPORT_SYMBOL (AcpiInitializeTables)
00245 
00246 
00247 /*******************************************************************************
00248  *
00249  * FUNCTION:    AcpiReallocateRootTable
00250  *
00251  * PARAMETERS:  None
00252  *
00253  * RETURN:      Status
00254  *
00255  * DESCRIPTION: Reallocate Root Table List into dynamic memory. Copies the
00256  *              root list from the previously provided scratch area. Should
00257  *              be called once dynamic memory allocation is available in the
00258  *              kernel
00259  *
00260  ******************************************************************************/
00261 
00262 ACPI_STATUS
00263 AcpiReallocateRootTable (
00264     void)
00265 {
00266     ACPI_TABLE_DESC         *Tables;
00267     ACPI_SIZE               NewSize;
00268     ACPI_SIZE               CurrentSize;
00269 
00270 
00271     ACPI_FUNCTION_TRACE (AcpiReallocateRootTable);
00272 
00273 
00274     /*
00275      * Only reallocate the root table if the host provided a static buffer
00276      * for the table array in the call to AcpiInitializeTables.
00277      */
00278     if (AcpiGbl_RootTableList.Flags & ACPI_ROOT_ORIGIN_ALLOCATED)
00279     {
00280         return_ACPI_STATUS (AE_SUPPORT);
00281     }
00282 
00283     /*
00284      * Get the current size of the root table and add the default
00285      * increment to create the new table size.
00286      */
00287     CurrentSize = (ACPI_SIZE)
00288         AcpiGbl_RootTableList.CurrentTableCount * sizeof (ACPI_TABLE_DESC);
00289 
00290     NewSize = CurrentSize +
00291         (ACPI_ROOT_TABLE_SIZE_INCREMENT * sizeof (ACPI_TABLE_DESC));
00292 
00293     /* Create new array and copy the old array */
00294 
00295     Tables = ACPI_ALLOCATE_ZEROED (NewSize);
00296     if (!Tables)
00297     {
00298         return_ACPI_STATUS (AE_NO_MEMORY);
00299     }
00300 
00301     ACPI_MEMCPY (Tables, AcpiGbl_RootTableList.Tables, CurrentSize);
00302 
00303     /*
00304      * Update the root table descriptor. The new size will be the current
00305      * number of tables plus the increment, independent of the reserved
00306      * size of the original table list.
00307      */
00308     AcpiGbl_RootTableList.Tables = Tables;
00309     AcpiGbl_RootTableList.MaxTableCount =
00310         AcpiGbl_RootTableList.CurrentTableCount + ACPI_ROOT_TABLE_SIZE_INCREMENT;
00311     AcpiGbl_RootTableList.Flags =
00312         ACPI_ROOT_ORIGIN_ALLOCATED | ACPI_ROOT_ALLOW_RESIZE;
00313 
00314     return_ACPI_STATUS (AE_OK);
00315 }
00316 
00317 ACPI_EXPORT_SYMBOL (AcpiReallocateRootTable)
00318 
00319 
00320 /*******************************************************************************
00321  *
00322  * FUNCTION:    AcpiGetTableHeader
00323  *
00324  * PARAMETERS:  Signature           - ACPI signature of needed table
00325  *              Instance            - Which instance (for SSDTs)
00326  *              OutTableHeader      - The pointer to the table header to fill
00327  *
00328  * RETURN:      Status and pointer to mapped table header
00329  *
00330  * DESCRIPTION: Finds an ACPI table header.
00331  *
00332  * NOTE:        Caller is responsible in unmapping the header with
00333  *              AcpiOsUnmapMemory
00334  *
00335  ******************************************************************************/
00336 
00337 ACPI_STATUS
00338 AcpiGetTableHeader (
00339     char                    *Signature,
00340     UINT32                  Instance,
00341     ACPI_TABLE_HEADER       *OutTableHeader)
00342 {
00343     UINT32                  i;
00344     UINT32                  j;
00345     ACPI_TABLE_HEADER       *Header;
00346 
00347 
00348     /* Parameter validation */
00349 
00350     if (!Signature || !OutTableHeader)
00351     {
00352         return (AE_BAD_PARAMETER);
00353     }
00354 
00355     /* Walk the root table list */
00356 
00357     for (i = 0, j = 0; i < AcpiGbl_RootTableList.CurrentTableCount; i++)
00358     {
00359         if (!ACPI_COMPARE_NAME (&(AcpiGbl_RootTableList.Tables[i].Signature),
00360                     Signature))
00361         {
00362             continue;
00363         }
00364 
00365         if (++j < Instance)
00366         {
00367             continue;
00368         }
00369 
00370         if (!AcpiGbl_RootTableList.Tables[i].Pointer)
00371         {
00372             if ((AcpiGbl_RootTableList.Tables[i].Flags &
00373                     ACPI_TABLE_ORIGIN_MASK) ==
00374                 ACPI_TABLE_ORIGIN_MAPPED)
00375             {
00376                 Header = AcpiOsMapMemory (
00377                             AcpiGbl_RootTableList.Tables[i].Address,
00378                             sizeof (ACPI_TABLE_HEADER));
00379                 if (!Header)
00380                 {
00381                     return AE_NO_MEMORY;
00382                 }
00383 
00384                 ACPI_MEMCPY (OutTableHeader, Header, sizeof(ACPI_TABLE_HEADER));
00385                 AcpiOsUnmapMemory (Header, sizeof(ACPI_TABLE_HEADER));
00386             }
00387             else
00388             {
00389                 return AE_NOT_FOUND;
00390             }
00391         }
00392         else
00393         {
00394             ACPI_MEMCPY (OutTableHeader,
00395                 AcpiGbl_RootTableList.Tables[i].Pointer,
00396                 sizeof(ACPI_TABLE_HEADER));
00397         }
00398 
00399         return (AE_OK);
00400     }
00401 
00402     return (AE_NOT_FOUND);
00403 }
00404 
00405 ACPI_EXPORT_SYMBOL (AcpiGetTableHeader)
00406 
00407 
00408 /*******************************************************************************
00409  *
00410  * FUNCTION:    AcpiGetTable
00411  *
00412  * PARAMETERS:  Signature           - ACPI signature of needed table
00413  *              Instance            - Which instance (for SSDTs)
00414  *              OutTable            - Where the pointer to the table is returned
00415  *
00416  * RETURN:      Status and pointer to table
00417  *
00418  * DESCRIPTION: Finds and verifies an ACPI table.
00419  *
00420  ******************************************************************************/
00421 
00422 ACPI_STATUS
00423 AcpiGetTable (
00424     char                    *Signature,
00425     UINT32                  Instance,
00426     ACPI_TABLE_HEADER       **OutTable)
00427 {
00428     UINT32                  i;
00429     UINT32                  j;
00430     ACPI_STATUS             Status;
00431 
00432 
00433     /* Parameter validation */
00434 
00435     if (!Signature || !OutTable)
00436     {
00437         return (AE_BAD_PARAMETER);
00438     }
00439 
00440     /* Walk the root table list */
00441 
00442     for (i = 0, j = 0; i < AcpiGbl_RootTableList.CurrentTableCount; i++)
00443     {
00444         if (!ACPI_COMPARE_NAME (&(AcpiGbl_RootTableList.Tables[i].Signature),
00445                 Signature))
00446         {
00447             continue;
00448         }
00449 
00450         if (++j < Instance)
00451         {
00452             continue;
00453         }
00454 
00455         Status = AcpiTbVerifyTable (&AcpiGbl_RootTableList.Tables[i]);
00456         if (ACPI_SUCCESS (Status))
00457         {
00458             *OutTable = AcpiGbl_RootTableList.Tables[i].Pointer;
00459         }
00460 
00461         return (Status);
00462     }
00463 
00464     return (AE_NOT_FOUND);
00465 }
00466 
00467 ACPI_EXPORT_SYMBOL (AcpiGetTable)
00468 
00469 
00470 /*******************************************************************************
00471  *
00472  * FUNCTION:    AcpiGetTableByIndex
00473  *
00474  * PARAMETERS:  TableIndex          - Table index
00475  *              Table               - Where the pointer to the table is returned
00476  *
00477  * RETURN:      Status and pointer to the table
00478  *
00479  * DESCRIPTION: Obtain a table by an index into the global table list.
00480  *
00481  ******************************************************************************/
00482 
00483 ACPI_STATUS
00484 AcpiGetTableByIndex (
00485     UINT32                  TableIndex,
00486     ACPI_TABLE_HEADER       **Table)
00487 {
00488     ACPI_STATUS             Status;
00489 
00490 
00491     ACPI_FUNCTION_TRACE (AcpiGetTableByIndex);
00492 
00493 
00494     /* Parameter validation */
00495 
00496     if (!Table)
00497     {
00498         return_ACPI_STATUS (AE_BAD_PARAMETER);
00499     }
00500 
00501     (void) AcpiUtAcquireMutex (ACPI_MTX_TABLES);
00502 
00503     /* Validate index */
00504 
00505     if (TableIndex >= AcpiGbl_RootTableList.CurrentTableCount)
00506     {
00507         (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES);
00508         return_ACPI_STATUS (AE_BAD_PARAMETER);
00509     }
00510 
00511     if (!AcpiGbl_RootTableList.Tables[TableIndex].Pointer)
00512     {
00513         /* Table is not mapped, map it */
00514 
00515         Status = AcpiTbVerifyTable (&AcpiGbl_RootTableList.Tables[TableIndex]);
00516         if (ACPI_FAILURE (Status))
00517         {
00518             (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES);
00519             return_ACPI_STATUS (Status);
00520         }
00521     }
00522 
00523     *Table = AcpiGbl_RootTableList.Tables[TableIndex].Pointer;
00524     (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES);
00525     return_ACPI_STATUS (AE_OK);
00526 }
00527 
00528 ACPI_EXPORT_SYMBOL (AcpiGetTableByIndex)
00529 
00530 
00531 /*******************************************************************************
00532  *
00533  * FUNCTION:    AcpiTbLoadNamespace
00534  *
00535  * PARAMETERS:  None
00536  *
00537  * RETURN:      Status
00538  *
00539  * DESCRIPTION: Load the namespace from the DSDT and all SSDTs/PSDTs found in
00540  *              the RSDT/XSDT.
00541  *
00542  ******************************************************************************/
00543 
00544 static ACPI_STATUS
00545 AcpiTbLoadNamespace (
00546     void)
00547 {
00548     ACPI_STATUS             Status;
00549     UINT32                  i;
00550     ACPI_TABLE_HEADER       *NewDsdt;
00551 
00552 
00553     ACPI_FUNCTION_TRACE (TbLoadNamespace);
00554 
00555 
00556     (void) AcpiUtAcquireMutex (ACPI_MTX_TABLES);
00557 
00558     /*
00559      * Load the namespace. The DSDT is required, but any SSDT and
00560      * PSDT tables are optional. Verify the DSDT.
00561      */
00562     if (!AcpiGbl_RootTableList.CurrentTableCount ||
00563         !ACPI_COMPARE_NAME (
00564             &(AcpiGbl_RootTableList.Tables[ACPI_TABLE_INDEX_DSDT].Signature),
00565             ACPI_SIG_DSDT) ||
00566          ACPI_FAILURE (AcpiTbVerifyTable (
00567             &AcpiGbl_RootTableList.Tables[ACPI_TABLE_INDEX_DSDT])))
00568     {
00569         Status = AE_NO_ACPI_TABLES;
00570         goto UnlockAndExit;
00571     }
00572 
00573     /*
00574      * Save the DSDT pointer for simple access. This is the mapped memory
00575      * address. We must take care here because the address of the .Tables
00576      * array can change dynamically as tables are loaded at run-time. Note:
00577      * .Pointer field is not validated until after call to AcpiTbVerifyTable.
00578      */
00579     AcpiGbl_DSDT = AcpiGbl_RootTableList.Tables[ACPI_TABLE_INDEX_DSDT].Pointer;
00580 
00581     /*
00582      * Optionally copy the entire DSDT to local memory (instead of simply
00583      * mapping it.) There are some BIOSs that corrupt or replace the original
00584      * DSDT, creating the need for this option. Default is FALSE, do not copy
00585      * the DSDT.
00586      */
00587     if (AcpiGbl_CopyDsdtLocally)
00588     {
00589         NewDsdt = AcpiTbCopyDsdt (ACPI_TABLE_INDEX_DSDT);
00590         if (NewDsdt)
00591         {
00592             AcpiGbl_DSDT = NewDsdt;
00593         }
00594     }
00595 
00596     /*
00597      * Save the original DSDT header for detection of table corruption
00598      * and/or replacement of the DSDT from outside the OS.
00599      */
00600     ACPI_MEMCPY (&AcpiGbl_OriginalDsdtHeader, AcpiGbl_DSDT,
00601         sizeof (ACPI_TABLE_HEADER));
00602 
00603     (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES);
00604 
00605     /* Load and parse tables */
00606 
00607     Status = AcpiNsLoadTable (ACPI_TABLE_INDEX_DSDT, AcpiGbl_RootNode);
00608     if (ACPI_FAILURE (Status))
00609     {
00610         return_ACPI_STATUS (Status);
00611     }
00612 
00613     /* Load any SSDT or PSDT tables. Note: Loop leaves tables locked */
00614 
00615     (void) AcpiUtAcquireMutex (ACPI_MTX_TABLES);
00616     for (i = 0; i < AcpiGbl_RootTableList.CurrentTableCount; ++i)
00617     {
00618         if ((!ACPI_COMPARE_NAME (&(AcpiGbl_RootTableList.Tables[i].Signature),
00619                     ACPI_SIG_SSDT) &&
00620              !ACPI_COMPARE_NAME (&(AcpiGbl_RootTableList.Tables[i].Signature),
00621                     ACPI_SIG_PSDT)) ||
00622              ACPI_FAILURE (AcpiTbVerifyTable (
00623                 &AcpiGbl_RootTableList.Tables[i])))
00624         {
00625             continue;
00626         }
00627 
00628         /* Ignore errors while loading tables, get as many as possible */
00629 
00630         (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES);
00631         (void) AcpiNsLoadTable (i, AcpiGbl_RootNode);
00632         (void) AcpiUtAcquireMutex (ACPI_MTX_TABLES);
00633     }
00634 
00635     ACPI_DEBUG_PRINT ((ACPI_DB_INIT, "ACPI Tables successfully acquired\n"));
00636 
00637 UnlockAndExit:
00638     (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES);
00639     return_ACPI_STATUS (Status);
00640 }
00641 
00642 
00643 /*******************************************************************************
00644  *
00645  * FUNCTION:    AcpiLoadTables
00646  *
00647  * PARAMETERS:  None
00648  *
00649  * RETURN:      Status
00650  *
00651  * DESCRIPTION: Load the ACPI tables from the RSDT/XSDT
00652  *
00653  ******************************************************************************/
00654 
00655 ACPI_STATUS
00656 AcpiLoadTables (
00657     void)
00658 {
00659     ACPI_STATUS             Status;
00660 
00661 
00662     ACPI_FUNCTION_TRACE (AcpiLoadTables);
00663 
00664 
00665     /* Load the namespace from the tables */
00666 
00667     Status = AcpiTbLoadNamespace ();
00668     if (ACPI_FAILURE (Status))
00669     {
00670         ACPI_EXCEPTION ((AE_INFO, Status,
00671             "While loading namespace from ACPI tables"));
00672     }
00673 
00674     return_ACPI_STATUS (Status);
00675 }
00676 
00677 ACPI_EXPORT_SYMBOL (AcpiLoadTables)
00678 
00679 
00680 /*******************************************************************************
00681  *
00682  * FUNCTION:    AcpiInstallTableHandler
00683  *
00684  * PARAMETERS:  Handler         - Table event handler
00685  *              Context         - Value passed to the handler on each event
00686  *
00687  * RETURN:      Status
00688  *
00689  * DESCRIPTION: Install table event handler
00690  *
00691  ******************************************************************************/
00692 
00693 ACPI_STATUS
00694 AcpiInstallTableHandler (
00695     ACPI_TABLE_HANDLER      Handler,
00696     void                    *Context)
00697 {
00698     ACPI_STATUS             Status;
00699 
00700 
00701     ACPI_FUNCTION_TRACE (AcpiInstallTableHandler);
00702 
00703 
00704     if (!Handler)
00705     {
00706         return_ACPI_STATUS (AE_BAD_PARAMETER);
00707     }
00708 
00709     Status = AcpiUtAcquireMutex (ACPI_MTX_EVENTS);
00710     if (ACPI_FAILURE (Status))
00711     {
00712         return_ACPI_STATUS (Status);
00713     }
00714 
00715     /* Don't allow more than one handler */
00716 
00717     if (AcpiGbl_TableHandler)
00718     {
00719         Status = AE_ALREADY_EXISTS;
00720         goto Cleanup;
00721     }
00722 
00723     /* Install the handler */
00724 
00725     AcpiGbl_TableHandler = Handler;
00726     AcpiGbl_TableHandlerContext = Context;
00727 
00728 Cleanup:
00729     (void) AcpiUtReleaseMutex (ACPI_MTX_EVENTS);
00730     return_ACPI_STATUS (Status);
00731 }
00732 
00733 ACPI_EXPORT_SYMBOL (AcpiInstallTableHandler)
00734 
00735 
00736 /*******************************************************************************
00737  *
00738  * FUNCTION:    AcpiRemoveTableHandler
00739  *
00740  * PARAMETERS:  Handler         - Table event handler that was installed
00741  *                                previously.
00742  *
00743  * RETURN:      Status
00744  *
00745  * DESCRIPTION: Remove table event handler
00746  *
00747  ******************************************************************************/
00748 
00749 ACPI_STATUS
00750 AcpiRemoveTableHandler (
00751     ACPI_TABLE_HANDLER      Handler)
00752 {
00753     ACPI_STATUS             Status;
00754 
00755 
00756     ACPI_FUNCTION_TRACE (AcpiRemoveTableHandler);
00757 
00758 
00759     Status = AcpiUtAcquireMutex (ACPI_MTX_EVENTS);
00760     if (ACPI_FAILURE (Status))
00761     {
00762         return_ACPI_STATUS (Status);
00763     }
00764 
00765     /* Make sure that the installed handler is the same */
00766 
00767     if (!Handler ||
00768         Handler != AcpiGbl_TableHandler)
00769     {
00770         Status = AE_BAD_PARAMETER;
00771         goto Cleanup;
00772     }
00773 
00774     /* Remove the handler */
00775 
00776     AcpiGbl_TableHandler = NULL;
00777 
00778 Cleanup:
00779     (void) AcpiUtReleaseMutex (ACPI_MTX_EVENTS);
00780     return_ACPI_STATUS (Status);
00781 }
00782 
00783 ACPI_EXPORT_SYMBOL (AcpiRemoveTableHandler)
00784 

Generated on Sun May 27 2012 04:27:23 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.