tbxface.c revision 193529
1254721Semaste/****************************************************************************** 2254721Semaste * 3254721Semaste * Module Name: tbxface - Public interfaces to the ACPI subsystem 4254721Semaste * ACPI table oriented interfaces 5254721Semaste * 6254721Semaste *****************************************************************************/ 7254721Semaste 8254721Semaste/****************************************************************************** 9254721Semaste * 10254721Semaste * 1. Copyright Notice 11254721Semaste * 12254721Semaste * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. 13296417Sdim * All rights reserved. 14296417Sdim * 15254721Semaste * 2. License 16254721Semaste * 17254721Semaste * 2.1. This is your license from Intel Corp. under its intellectual property 18258054Semaste * rights. You may have additional license terms from the party that provided 19258054Semaste * you this software, covering your right to use that party's intellectual 20276479Sdim * property rights. 21258054Semaste * 22258054Semaste * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a 23258054Semaste * copy of the source code appearing in this file ("Covered Code") an 24258054Semaste * irrevocable, perpetual, worldwide license under Intel's copyrights in the 25258054Semaste * base code distributed originally by Intel ("Original Intel Code") to copy, 26258054Semaste * make derivatives, distribute, use and display any portion of the Covered 27296417Sdim * Code in any form, with the right to sublicense such rights; and 28296417Sdim * 29296417Sdim * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent 30254721Semaste * license (with the right to sublicense), under only those claims of Intel 31254721Semaste * patents that are infringed by the Original Intel Code, to make, use, sell, 32254721Semaste * offer to sell, and import the Covered Code and derivative works thereof 33254721Semaste * solely to the minimum extent necessary to exercise the above copyright 34254721Semaste * license, and in no event shall the patent license extend to any additions 35254721Semaste * to or modifications of the Original Intel Code. No other license or right 36254721Semaste * is granted directly or by implication, estoppel or otherwise; 37254721Semaste * 38254721Semaste * The above copyright and patent license is granted only if the following 39254721Semaste * conditions are met: 40254721Semaste * 41254721Semaste * 3. Conditions 42254721Semaste * 43254721Semaste * 3.1. Redistribution of Source with Rights to Further Distribute Source. 44254721Semaste * Redistribution of source code of any substantial portion of the Covered 45254721Semaste * Code or modification with rights to further distribute source must include 46296417Sdim * the above Copyright Notice, the above License, this list of Conditions, 47296417Sdim * and the following Disclaimer and Export Compliance provision. In addition, 48296417Sdim * Licensee must cause all Covered Code to which Licensee contributes to 49296417Sdim * contain a file documenting the changes Licensee made to create that Covered 50296417Sdim * Code and the date of any change. Licensee must include in that file the 51296417Sdim * documentation of any changes made by any predecessor Licensee. Licensee 52296417Sdim * must include a prominent statement that the modification is derived, 53254721Semaste * directly or indirectly, from Original Intel Code. 54258054Semaste * 55254721Semaste * 3.2. Redistribution of Source with no Rights to Further Distribute Source. 56258054Semaste * Redistribution of source code of any substantial portion of the Covered 57258054Semaste * Code or modification without rights to further distribute source must 58258054Semaste * include the following Disclaimer and Export Compliance provision in the 59254721Semaste * documentation and/or other materials provided with distribution. In 60296417Sdim * addition, Licensee may not authorize further sublicense of source of any 61254721Semaste * portion of the Covered Code, and must include terms to the effect that the 62254721Semaste * license from Licensee to its licensee is limited to the intellectual 63254721Semaste * property embodied in the software Licensee provides to its licensee, and 64254721Semaste * not to intellectual property embodied in modifications its licensee may 65254721Semaste * make. 66254721Semaste * 67254721Semaste * 3.3. Redistribution of Executable. Redistribution in executable form of any 68254721Semaste * substantial portion of the Covered Code or modification must reproduce the 69254721Semaste * above Copyright Notice, and the following Disclaimer and Export Compliance 70254721Semaste * provision in the documentation and/or other materials provided with the 71254721Semaste * distribution. 72254721Semaste * 73254721Semaste * 3.4. Intel retains all right, title, and interest in and to the Original 74254721Semaste * Intel Code. 75296417Sdim * 76254721Semaste * 3.5. Neither the name Intel nor any other trademark owned or controlled by 77276479Sdim * Intel shall be used in advertising or otherwise to promote the sale, use or 78276479Sdim * other dealings in products derived from or relating to the Covered Code 79254721Semaste * without prior written authorization from Intel. 80254721Semaste * 81254721Semaste * 4. Disclaimer and Export Compliance 82254721Semaste * 83254721Semaste * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED 84254721Semaste * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE 85254721Semaste * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, 86254721Semaste * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY 87254721Semaste * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY 88254721Semaste * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A 89254721Semaste * PARTICULAR PURPOSE. 90254721Semaste * 91254721Semaste * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES 92254721Semaste * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR 93254721Semaste * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, 94254721Semaste * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY 95254721Semaste * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL 96254721Semaste * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS 97254721Semaste * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY 98254721Semaste * LIMITED REMEDY. 99254721Semaste * 100254721Semaste * 4.3. Licensee shall not export, either directly or indirectly, any of this 101254721Semaste * software or system incorporating such software without first obtaining any 102254721Semaste * required license or other approval from the U. S. Department of Commerce or 103254721Semaste * any other agency or department of the United States Government. In the 104254721Semaste * event Licensee exports any such software from the United States or 105254721Semaste * re-exports any such software from a foreign destination, Licensee shall 106254721Semaste * ensure that the distribution and export/re-export of the software is in 107254721Semaste * compliance with all laws, regulations, orders, or other restrictions of the 108254721Semaste * U.S. Export Administration Regulations. Licensee agrees that neither it nor 109254721Semaste * any of its subsidiaries will export/re-export any technical data, process, 110254721Semaste * software, or service, directly or indirectly, to any country for which the 111254721Semaste * United States government or any agency thereof requires an export license, 112254721Semaste * other governmental approval, or letter of assurance, without first obtaining 113254721Semaste * such license, approval or letter. 114254721Semaste * 115254721Semaste *****************************************************************************/ 116254721Semaste 117254721Semaste#define __TBXFACE_C__ 118254721Semaste 119254721Semaste#include <contrib/dev/acpica/include/acpi.h> 120254721Semaste#include <contrib/dev/acpica/include/accommon.h> 121296417Sdim#include <contrib/dev/acpica/include/acnamesp.h> 122296417Sdim#include <contrib/dev/acpica/include/actables.h> 123254721Semaste 124254721Semaste#define _COMPONENT ACPI_TABLES 125254721Semaste ACPI_MODULE_NAME ("tbxface") 126254721Semaste 127254721Semaste/* Local prototypes */ 128254721Semaste 129254721Semastestatic ACPI_STATUS 130254721SemasteAcpiTbLoadNamespace ( 131254721Semaste void); 132254721Semaste 133296417Sdim 134254721Semaste/******************************************************************************* 135254721Semaste * 136254721Semaste * FUNCTION: AcpiAllocateRootTable 137254721Semaste * 138254721Semaste * PARAMETERS: InitialTableCount - Size of InitialTableArray, in number of 139254721Semaste * ACPI_TABLE_DESC structures 140296417Sdim * 141254721Semaste * RETURN: Status 142254721Semaste * 143254721Semaste * DESCRIPTION: Allocate a root table array. Used by iASL compiler and 144254721Semaste * AcpiInitializeTables. 145254721Semaste * 146296417Sdim ******************************************************************************/ 147254721Semaste 148254721SemasteACPI_STATUS 149276479SdimAcpiAllocateRootTable ( 150254721Semaste UINT32 InitialTableCount) 151254721Semaste{ 152254721Semaste 153254721Semaste AcpiGbl_RootTableList.Size = InitialTableCount; 154254721Semaste AcpiGbl_RootTableList.Flags = ACPI_ROOT_ALLOW_RESIZE; 155254721Semaste 156254721Semaste return (AcpiTbResizeRootTableList ()); 157254721Semaste} 158254721Semaste 159254721Semaste 160254721Semaste/******************************************************************************* 161254721Semaste * 162254721Semaste * FUNCTION: AcpiInitializeTables 163254721Semaste * 164254721Semaste * PARAMETERS: InitialTableArray - Pointer to an array of pre-allocated 165288943Sdim * ACPI_TABLE_DESC structures. If NULL, the 166254721Semaste * array is dynamically allocated. 167254721Semaste * InitialTableCount - Size of InitialTableArray, in number of 168254721Semaste * ACPI_TABLE_DESC structures 169254721Semaste * AllowRealloc - Flag to tell Table Manager if resize of 170254721Semaste * pre-allocated array is allowed. Ignored 171254721Semaste * if InitialTableArray is NULL. 172296417Sdim * 173254721Semaste * RETURN: Status 174254721Semaste * 175254721Semaste * DESCRIPTION: Initialize the table manager, get the RSDP and RSDT/XSDT. 176254721Semaste * 177254721Semaste * NOTE: Allows static allocation of the initial table array in order 178254721Semaste * to avoid the use of dynamic memory in confined environments 179254721Semaste * such as the kernel boot sequence where it may not be available. 180254721Semaste * 181254721Semaste * If the host OS memory managers are initialized, use NULL for 182254721Semaste * InitialTableArray, and the table will be dynamically allocated. 183254721Semaste * 184254721Semaste ******************************************************************************/ 185254721Semaste 186254721SemasteACPI_STATUS 187254721SemasteAcpiInitializeTables ( 188254721Semaste ACPI_TABLE_DESC *InitialTableArray, 189254721Semaste UINT32 InitialTableCount, 190254721Semaste BOOLEAN AllowResize) 191254721Semaste{ 192254721Semaste ACPI_PHYSICAL_ADDRESS RsdpAddress; 193254721Semaste ACPI_STATUS Status; 194254721Semaste 195254721Semaste 196254721Semaste ACPI_FUNCTION_TRACE (AcpiInitializeTables); 197254721Semaste 198254721Semaste 199296417Sdim /* 200296417Sdim * Set up the Root Table Array 201254721Semaste * Allocate the table array if requested 202254721Semaste */ 203276479Sdim if (!InitialTableArray) 204276479Sdim { 205276479Sdim Status = AcpiAllocateRootTable (InitialTableCount); 206276479Sdim if (ACPI_FAILURE (Status)) 207296417Sdim { 208296417Sdim return_ACPI_STATUS (Status); 209276479Sdim } 210276479Sdim } 211254721Semaste else 212254721Semaste { 213254721Semaste /* Root Table Array has been statically allocated by the host */ 214254721Semaste 215296417Sdim ACPI_MEMSET (InitialTableArray, 0, 216254721Semaste (ACPI_SIZE) InitialTableCount * sizeof (ACPI_TABLE_DESC)); 217254721Semaste 218254721Semaste AcpiGbl_RootTableList.Tables = InitialTableArray; 219254721Semaste AcpiGbl_RootTableList.Size = InitialTableCount; 220254721Semaste AcpiGbl_RootTableList.Flags = ACPI_ROOT_ORIGIN_UNKNOWN; 221254721Semaste if (AllowResize) 222254721Semaste { 223254721Semaste AcpiGbl_RootTableList.Flags |= ACPI_ROOT_ALLOW_RESIZE; 224254721Semaste } 225254721Semaste } 226254721Semaste 227254721Semaste /* Get the address of the RSDP */ 228254721Semaste 229254721Semaste RsdpAddress = AcpiOsGetRootPointer (); 230254721Semaste if (!RsdpAddress) 231254721Semaste { 232254721Semaste return_ACPI_STATUS (AE_NOT_FOUND); 233254721Semaste } 234254721Semaste 235254721Semaste /* 236254721Semaste * Get the root table (RSDT or XSDT) and extract all entries to the local 237254721Semaste * Root Table Array. This array contains the information of the RSDT/XSDT 238254721Semaste * in a common, more useable format. 239254721Semaste */ 240254721Semaste Status = AcpiTbParseRootTable (RsdpAddress); 241254721Semaste return_ACPI_STATUS (Status); 242254721Semaste} 243254721Semaste 244254721SemasteACPI_EXPORT_SYMBOL (AcpiInitializeTables) 245254721Semaste 246254721Semaste 247254721Semaste/******************************************************************************* 248254721Semaste * 249254721Semaste * FUNCTION: AcpiReallocateRootTable 250254721Semaste * 251254721Semaste * PARAMETERS: None 252254721Semaste * 253254721Semaste * RETURN: Status 254254721Semaste * 255254721Semaste * DESCRIPTION: Reallocate Root Table List into dynamic memory. Copies the 256254721Semaste * root list from the previously provided scratch area. Should 257254721Semaste * be called once dynamic memory allocation is available in the 258254721Semaste * kernel 259254721Semaste * 260254721Semaste ******************************************************************************/ 261254721Semaste 262254721SemasteACPI_STATUS 263254721SemasteAcpiReallocateRootTable ( 264254721Semaste void) 265254721Semaste{ 266254721Semaste ACPI_TABLE_DESC *Tables; 267254721Semaste ACPI_SIZE NewSize; 268254721Semaste 269254721Semaste 270254721Semaste ACPI_FUNCTION_TRACE (AcpiReallocateRootTable); 271254721Semaste 272254721Semaste 273254721Semaste /* 274254721Semaste * Only reallocate the root table if the host provided a static buffer 275254721Semaste * for the table array in the call to AcpiInitializeTables. 276254721Semaste */ 277254721Semaste if (AcpiGbl_RootTableList.Flags & ACPI_ROOT_ORIGIN_ALLOCATED) 278254721Semaste { 279254721Semaste return_ACPI_STATUS (AE_SUPPORT); 280254721Semaste } 281254721Semaste 282254721Semaste NewSize = ((ACPI_SIZE) AcpiGbl_RootTableList.Count + 283254721Semaste ACPI_ROOT_TABLE_SIZE_INCREMENT) * 284254721Semaste sizeof (ACPI_TABLE_DESC); 285254721Semaste 286254721Semaste /* Create new array and copy the old array */ 287254721Semaste 288254721Semaste Tables = ACPI_ALLOCATE_ZEROED (NewSize); 289254721Semaste if (!Tables) 290254721Semaste { 291254721Semaste return_ACPI_STATUS (AE_NO_MEMORY); 292254721Semaste } 293254721Semaste 294254721Semaste ACPI_MEMCPY (Tables, AcpiGbl_RootTableList.Tables, NewSize); 295254721Semaste 296254721Semaste AcpiGbl_RootTableList.Size = AcpiGbl_RootTableList.Count; 297254721Semaste AcpiGbl_RootTableList.Tables = Tables; 298254721Semaste AcpiGbl_RootTableList.Flags = 299254721Semaste ACPI_ROOT_ORIGIN_ALLOCATED | ACPI_ROOT_ALLOW_RESIZE; 300254721Semaste 301254721Semaste return_ACPI_STATUS (AE_OK); 302254721Semaste} 303254721Semaste 304254721SemasteACPI_EXPORT_SYMBOL (AcpiReallocateRootTable) 305254721Semaste 306288943Sdim 307288943Sdim/******************************************************************************* 308288943Sdim * 309288943Sdim * FUNCTION: AcpiGetTableHeader 310288943Sdim * 311288943Sdim * PARAMETERS: Signature - ACPI signature of needed table 312288943Sdim * Instance - Which instance (for SSDTs) 313288943Sdim * OutTableHeader - The pointer to the table header to fill 314254721Semaste * 315254721Semaste * RETURN: Status and pointer to mapped table header 316254721Semaste * 317254721Semaste * DESCRIPTION: Finds an ACPI table header. 318254721Semaste * 319254721Semaste * NOTE: Caller is responsible in unmapping the header with 320254721Semaste * AcpiOsUnmapMemory 321254721Semaste * 322254721Semaste ******************************************************************************/ 323254721Semaste 324254721SemasteACPI_STATUS 325254721SemasteAcpiGetTableHeader ( 326254721Semaste char *Signature, 327254721Semaste UINT32 Instance, 328254721Semaste ACPI_TABLE_HEADER *OutTableHeader) 329254721Semaste{ 330254721Semaste UINT32 i; 331254721Semaste UINT32 j; 332254721Semaste ACPI_TABLE_HEADER *Header; 333254721Semaste 334254721Semaste 335254721Semaste /* Parameter validation */ 336254721Semaste 337254721Semaste if (!Signature || !OutTableHeader) 338254721Semaste { 339254721Semaste return (AE_BAD_PARAMETER); 340254721Semaste } 341254721Semaste 342254721Semaste /* Walk the root table list */ 343254721Semaste 344254721Semaste for (i = 0, j = 0; i < AcpiGbl_RootTableList.Count; i++) 345254721Semaste { 346254721Semaste if (!ACPI_COMPARE_NAME (&(AcpiGbl_RootTableList.Tables[i].Signature), 347254721Semaste Signature)) 348254721Semaste { 349254721Semaste continue; 350254721Semaste } 351254721Semaste 352254721Semaste if (++j < Instance) 353254721Semaste { 354254721Semaste continue; 355254721Semaste } 356254721Semaste 357254721Semaste if (!AcpiGbl_RootTableList.Tables[i].Pointer) 358254721Semaste { 359254721Semaste if ((AcpiGbl_RootTableList.Tables[i].Flags & 360254721Semaste ACPI_TABLE_ORIGIN_MASK) == 361254721Semaste ACPI_TABLE_ORIGIN_MAPPED) 362254721Semaste { 363254721Semaste Header = AcpiOsMapMemory ( 364254721Semaste AcpiGbl_RootTableList.Tables[i].Address, 365254721Semaste sizeof (ACPI_TABLE_HEADER)); 366254721Semaste if (!Header) 367254721Semaste { 368254721Semaste return AE_NO_MEMORY; 369254721Semaste } 370254721Semaste 371254721Semaste ACPI_MEMCPY (OutTableHeader, Header, sizeof(ACPI_TABLE_HEADER)); 372254721Semaste AcpiOsUnmapMemory (Header, sizeof(ACPI_TABLE_HEADER)); 373254721Semaste } 374254721Semaste else 375254721Semaste { 376254721Semaste return AE_NOT_FOUND; 377254721Semaste } 378254721Semaste } 379254721Semaste else 380254721Semaste { 381254721Semaste ACPI_MEMCPY (OutTableHeader, 382254721Semaste AcpiGbl_RootTableList.Tables[i].Pointer, 383254721Semaste sizeof(ACPI_TABLE_HEADER)); 384254721Semaste } 385254721Semaste 386254721Semaste return (AE_OK); 387254721Semaste } 388254721Semaste 389254721Semaste return (AE_NOT_FOUND); 390254721Semaste} 391254721Semaste 392254721SemasteACPI_EXPORT_SYMBOL (AcpiGetTableHeader) 393254721Semaste 394254721Semaste 395254721Semaste/******************************************************************************* 396254721Semaste * 397254721Semaste * FUNCTION: AcpiGetTable 398254721Semaste * 399254721Semaste * PARAMETERS: Signature - ACPI signature of needed table 400254721Semaste * Instance - Which instance (for SSDTs) 401254721Semaste * OutTable - Where the pointer to the table is returned 402254721Semaste * 403254721Semaste * RETURN: Status and pointer to table 404254721Semaste * 405254721Semaste * DESCRIPTION: Finds and verifies an ACPI table. 406254721Semaste * 407254721Semaste ******************************************************************************/ 408254721Semaste 409254721SemasteACPI_STATUS 410254721SemasteAcpiGetTable ( 411254721Semaste char *Signature, 412254721Semaste UINT32 Instance, 413254721Semaste ACPI_TABLE_HEADER **OutTable) 414254721Semaste{ 415254721Semaste UINT32 i; 416254721Semaste UINT32 j; 417254721Semaste ACPI_STATUS Status; 418254721Semaste 419254721Semaste 420254721Semaste /* Parameter validation */ 421254721Semaste 422254721Semaste if (!Signature || !OutTable) 423254721Semaste { 424254721Semaste return (AE_BAD_PARAMETER); 425254721Semaste } 426254721Semaste 427254721Semaste /* Walk the root table list */ 428254721Semaste 429254721Semaste for (i = 0, j = 0; i < AcpiGbl_RootTableList.Count; i++) 430254721Semaste { 431254721Semaste if (!ACPI_COMPARE_NAME (&(AcpiGbl_RootTableList.Tables[i].Signature), 432254721Semaste Signature)) 433254721Semaste { 434254721Semaste continue; 435254721Semaste } 436254721Semaste 437254721Semaste if (++j < Instance) 438254721Semaste { 439254721Semaste continue; 440254721Semaste } 441254721Semaste 442254721Semaste Status = AcpiTbVerifyTable (&AcpiGbl_RootTableList.Tables[i]); 443254721Semaste if (ACPI_SUCCESS (Status)) 444254721Semaste { 445254721Semaste *OutTable = AcpiGbl_RootTableList.Tables[i].Pointer; 446254721Semaste } 447254721Semaste 448254721Semaste return (Status); 449254721Semaste } 450254721Semaste 451254721Semaste return (AE_NOT_FOUND); 452254721Semaste} 453254721Semaste 454254721SemasteACPI_EXPORT_SYMBOL (AcpiGetTable) 455254721Semaste 456254721Semaste 457254721Semaste/******************************************************************************* 458254721Semaste * 459254721Semaste * FUNCTION: AcpiGetTableByIndex 460254721Semaste * 461254721Semaste * PARAMETERS: TableIndex - Table index 462254721Semaste * Table - Where the pointer to the table is returned 463254721Semaste * 464254721Semaste * RETURN: Status and pointer to the table 465254721Semaste * 466254721Semaste * DESCRIPTION: Obtain a table by an index into the global table list. 467254721Semaste * 468254721Semaste ******************************************************************************/ 469254721Semaste 470254721SemasteACPI_STATUS 471254721SemasteAcpiGetTableByIndex ( 472254721Semaste UINT32 TableIndex, 473254721Semaste ACPI_TABLE_HEADER **Table) 474254721Semaste{ 475254721Semaste ACPI_STATUS Status; 476254721Semaste 477254721Semaste 478254721Semaste ACPI_FUNCTION_TRACE (AcpiGetTableByIndex); 479254721Semaste 480254721Semaste 481254721Semaste /* Parameter validation */ 482254721Semaste 483254721Semaste if (!Table) 484254721Semaste { 485254721Semaste return_ACPI_STATUS (AE_BAD_PARAMETER); 486254721Semaste } 487254721Semaste 488254721Semaste (void) AcpiUtAcquireMutex (ACPI_MTX_TABLES); 489254721Semaste 490254721Semaste /* Validate index */ 491254721Semaste 492254721Semaste if (TableIndex >= AcpiGbl_RootTableList.Count) 493254721Semaste { 494254721Semaste (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES); 495254721Semaste return_ACPI_STATUS (AE_BAD_PARAMETER); 496254721Semaste } 497254721Semaste 498254721Semaste if (!AcpiGbl_RootTableList.Tables[TableIndex].Pointer) 499296417Sdim { 500254721Semaste /* Table is not mapped, map it */ 501254721Semaste 502254721Semaste Status = AcpiTbVerifyTable (&AcpiGbl_RootTableList.Tables[TableIndex]); 503254721Semaste if (ACPI_FAILURE (Status)) 504254721Semaste { 505254721Semaste (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES); 506254721Semaste return_ACPI_STATUS (Status); 507254721Semaste } 508254721Semaste } 509254721Semaste 510296417Sdim *Table = AcpiGbl_RootTableList.Tables[TableIndex].Pointer; 511254721Semaste (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES); 512254721Semaste return_ACPI_STATUS (AE_OK); 513254721Semaste} 514254721Semaste 515254721SemasteACPI_EXPORT_SYMBOL (AcpiGetTableByIndex) 516254721Semaste 517254721Semaste 518254721Semaste/******************************************************************************* 519254721Semaste * 520254721Semaste * FUNCTION: AcpiTbLoadNamespace 521254721Semaste * 522254721Semaste * PARAMETERS: None 523254721Semaste * 524254721Semaste * RETURN: Status 525254721Semaste * 526254721Semaste * DESCRIPTION: Load the namespace from the DSDT and all SSDTs/PSDTs found in 527254721Semaste * the RSDT/XSDT. 528254721Semaste * 529254721Semaste ******************************************************************************/ 530254721Semaste 531254721Semastestatic ACPI_STATUS 532254721SemasteAcpiTbLoadNamespace ( 533254721Semaste void) 534254721Semaste{ 535254721Semaste ACPI_STATUS Status; 536254721Semaste UINT32 i; 537254721Semaste 538254721Semaste 539254721Semaste ACPI_FUNCTION_TRACE (TbLoadNamespace); 540254721Semaste 541254721Semaste 542254721Semaste (void) AcpiUtAcquireMutex (ACPI_MTX_TABLES); 543254721Semaste 544254721Semaste /* 545254721Semaste * Load the namespace. The DSDT is required, but any SSDT and PSDT tables 546254721Semaste * are optional. 547254721Semaste */ 548254721Semaste if (!AcpiGbl_RootTableList.Count || 549254721Semaste !ACPI_COMPARE_NAME ( 550254721Semaste &(AcpiGbl_RootTableList.Tables[ACPI_TABLE_INDEX_DSDT].Signature), 551254721Semaste ACPI_SIG_DSDT) || 552254721Semaste ACPI_FAILURE (AcpiTbVerifyTable ( 553254721Semaste &AcpiGbl_RootTableList.Tables[ACPI_TABLE_INDEX_DSDT]))) 554254721Semaste { 555254721Semaste Status = AE_NO_ACPI_TABLES; 556254721Semaste goto UnlockAndExit; 557254721Semaste } 558254721Semaste 559254721Semaste /* A valid DSDT is required */ 560254721Semaste 561288943Sdim Status = AcpiTbVerifyTable ( 562254721Semaste &AcpiGbl_RootTableList.Tables[ACPI_TABLE_INDEX_DSDT]); 563254721Semaste if (ACPI_FAILURE (Status)) 564254721Semaste { 565254721Semaste Status = AE_NO_ACPI_TABLES; 566254721Semaste goto UnlockAndExit; 567254721Semaste } 568254721Semaste 569254721Semaste (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES); 570254721Semaste 571254721Semaste /* Load and parse tables */ 572254721Semaste 573296417Sdim Status = AcpiNsLoadTable (ACPI_TABLE_INDEX_DSDT, AcpiGbl_RootNode); 574296417Sdim if (ACPI_FAILURE (Status)) 575296417Sdim { 576296417Sdim return_ACPI_STATUS (Status); 577254721Semaste } 578296417Sdim 579254721Semaste /* Load any SSDT or PSDT tables. Note: Loop leaves tables locked */ 580254721Semaste 581254721Semaste (void) AcpiUtAcquireMutex (ACPI_MTX_TABLES); 582254721Semaste for (i = 2; i < AcpiGbl_RootTableList.Count; ++i) 583254721Semaste { 584254721Semaste if ((!ACPI_COMPARE_NAME (&(AcpiGbl_RootTableList.Tables[i].Signature), 585254721Semaste ACPI_SIG_SSDT) && 586254721Semaste !ACPI_COMPARE_NAME (&(AcpiGbl_RootTableList.Tables[i].Signature), 587254721Semaste ACPI_SIG_PSDT)) || 588254721Semaste ACPI_FAILURE (AcpiTbVerifyTable ( 589254721Semaste &AcpiGbl_RootTableList.Tables[i]))) 590254721Semaste { 591254721Semaste continue; 592254721Semaste } 593254721Semaste 594254721Semaste /* Skip SSDT when DSDT is overriden */ 595254721Semaste 596254721Semaste if (ACPI_COMPARE_NAME (&(AcpiGbl_RootTableList.Tables[i].Signature), 597254721Semaste ACPI_SIG_SSDT) && 598254721Semaste (AcpiGbl_RootTableList.Tables[ACPI_TABLE_INDEX_DSDT].Flags & 599254721Semaste ACPI_TABLE_ORIGIN_OVERRIDE)) 600254721Semaste { 601254721Semaste continue; 602254721Semaste } 603254721Semaste 604254721Semaste /* Ignore errors while loading tables, get as many as possible */ 605254721Semaste 606254721Semaste (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES); 607254721Semaste (void) AcpiNsLoadTable (i, AcpiGbl_RootNode); 608254721Semaste (void) AcpiUtAcquireMutex (ACPI_MTX_TABLES); 609254721Semaste } 610254721Semaste 611254721Semaste ACPI_DEBUG_PRINT ((ACPI_DB_INIT, "ACPI Tables successfully acquired\n")); 612254721Semaste 613254721SemasteUnlockAndExit: 614254721Semaste (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES); 615254721Semaste return_ACPI_STATUS (Status); 616254721Semaste} 617258054Semaste 618258054Semaste 619258054Semaste/******************************************************************************* 620258054Semaste * 621258054Semaste * FUNCTION: AcpiLoadTables 622254721Semaste * 623254721Semaste * PARAMETERS: None 624254721Semaste * 625254721Semaste * RETURN: Status 626254721Semaste * 627254721Semaste * DESCRIPTION: Load the ACPI tables from the RSDT/XSDT 628258054Semaste * 629258054Semaste ******************************************************************************/ 630258054Semaste 631258054SemasteACPI_STATUS 632258054SemasteAcpiLoadTables ( 633254721Semaste void) 634254721Semaste{ 635254721Semaste ACPI_STATUS Status; 636254721Semaste 637254721Semaste 638254721Semaste ACPI_FUNCTION_TRACE (AcpiLoadTables); 639254721Semaste 640254721Semaste 641254721Semaste /* Load the namespace from the tables */ 642254721Semaste 643254721Semaste Status = AcpiTbLoadNamespace (); 644254721Semaste if (ACPI_FAILURE (Status)) 645296417Sdim { 646296417Sdim ACPI_EXCEPTION ((AE_INFO, Status, 647296417Sdim "While loading namespace from ACPI tables")); 648296417Sdim } 649254721Semaste 650254721Semaste return_ACPI_STATUS (Status); 651254721Semaste} 652254721Semaste 653254721SemasteACPI_EXPORT_SYMBOL (AcpiLoadTables) 654254721Semaste 655254721Semaste 656254721Semaste/******************************************************************************* 657254721Semaste * 658254721Semaste * FUNCTION: AcpiInstallTableHandler 659254721Semaste * 660254721Semaste * PARAMETERS: Handler - Table event handler 661254721Semaste * Context - Value passed to the handler on each event 662254721Semaste * 663254721Semaste * RETURN: Status 664254721Semaste * 665254721Semaste * DESCRIPTION: Install table event handler 666254721Semaste * 667254721Semaste ******************************************************************************/ 668254721Semaste 669254721SemasteACPI_STATUS 670254721SemasteAcpiInstallTableHandler ( 671254721Semaste ACPI_TABLE_HANDLER Handler, 672254721Semaste void *Context) 673254721Semaste{ 674254721Semaste ACPI_STATUS Status; 675254721Semaste 676254721Semaste 677254721Semaste ACPI_FUNCTION_TRACE (AcpiInstallTableHandler); 678254721Semaste 679254721Semaste 680254721Semaste if (!Handler) 681254721Semaste { 682254721Semaste return_ACPI_STATUS (AE_BAD_PARAMETER); 683254721Semaste } 684254721Semaste 685254721Semaste Status = AcpiUtAcquireMutex (ACPI_MTX_EVENTS); 686254721Semaste if (ACPI_FAILURE (Status)) 687254721Semaste { 688254721Semaste return_ACPI_STATUS (Status); 689254721Semaste } 690254721Semaste 691254721Semaste /* Don't allow more than one handler */ 692254721Semaste 693254721Semaste if (AcpiGbl_TableHandler) 694254721Semaste { 695254721Semaste Status = AE_ALREADY_EXISTS; 696254721Semaste goto Cleanup; 697254721Semaste } 698254721Semaste 699254721Semaste /* Install the handler */ 700254721Semaste 701254721Semaste AcpiGbl_TableHandler = Handler; 702254721Semaste AcpiGbl_TableHandlerContext = Context; 703254721Semaste 704254721SemasteCleanup: 705254721Semaste (void) AcpiUtReleaseMutex (ACPI_MTX_EVENTS); 706254721Semaste return_ACPI_STATUS (Status); 707254721Semaste} 708254721Semaste 709254721SemasteACPI_EXPORT_SYMBOL (AcpiInstallTableHandler) 710254721Semaste 711254721Semaste 712254721Semaste/******************************************************************************* 713254721Semaste * 714254721Semaste * FUNCTION: AcpiRemoveTableHandler 715254721Semaste * 716254721Semaste * PARAMETERS: Handler - Table event handler that was installed 717254721Semaste * previously. 718254721Semaste * 719254721Semaste * RETURN: Status 720296417Sdim * 721254721Semaste * DESCRIPTION: Remove table event handler 722254721Semaste * 723254721Semaste ******************************************************************************/ 724254721Semaste 725254721SemasteACPI_STATUS 726254721SemasteAcpiRemoveTableHandler ( 727254721Semaste ACPI_TABLE_HANDLER Handler) 728254721Semaste{ 729254721Semaste ACPI_STATUS Status; 730254721Semaste 731254721Semaste 732254721Semaste ACPI_FUNCTION_TRACE (AcpiRemoveTableHandler); 733254721Semaste 734254721Semaste 735254721Semaste Status = AcpiUtAcquireMutex (ACPI_MTX_EVENTS); 736254721Semaste if (ACPI_FAILURE (Status)) 737254721Semaste { 738254721Semaste return_ACPI_STATUS (Status); 739254721Semaste } 740254721Semaste 741254721Semaste /* Make sure that the installed handler is the same */ 742258054Semaste 743254721Semaste if (!Handler || 744254721Semaste Handler != AcpiGbl_TableHandler) 745254721Semaste { 746254721Semaste Status = AE_BAD_PARAMETER; 747254721Semaste goto Cleanup; 748254721Semaste } 749254721Semaste 750254721Semaste /* Remove the handler */ 751254721Semaste 752254721Semaste AcpiGbl_TableHandler = NULL; 753254721Semaste 754254721SemasteCleanup: 755254721Semaste (void) AcpiUtReleaseMutex (ACPI_MTX_EVENTS); 756254721Semaste return_ACPI_STATUS (Status); 757254721Semaste} 758296417Sdim 759254721SemasteACPI_EXPORT_SYMBOL (AcpiRemoveTableHandler) 760254721Semaste 761254721Semaste