2000-10-28 05:01:06 +00:00
|
|
|
/******************************************************************************
|
|
|
|
*
|
|
|
|
* Module Name: tbxface - Public interfaces to the ACPI subsystem
|
|
|
|
* ACPI table oriented interfaces
|
|
|
|
*
|
|
|
|
*****************************************************************************/
|
|
|
|
|
2011-01-13 16:12:34 +00:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2000 - 2011, Intel Corp.
|
2000-12-21 06:56:46 +00:00
|
|
|
* All rights reserved.
|
2000-10-28 05:01:06 +00:00
|
|
|
*
|
2011-01-13 16:12:34 +00:00
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions, and the following disclaimer,
|
|
|
|
* without modification.
|
|
|
|
* 2. Redistributions in binary form must reproduce at minimum a disclaimer
|
|
|
|
* substantially similar to the "NO WARRANTY" disclaimer below
|
|
|
|
* ("Disclaimer") and any redistribution must be conditioned upon
|
|
|
|
* including a substantially similar Disclaimer requirement for further
|
|
|
|
* binary redistribution.
|
|
|
|
* 3. Neither the names of the above-listed copyright holders nor the names
|
|
|
|
* of any contributors may be used to endorse or promote products derived
|
|
|
|
* from this software without specific prior written permission.
|
|
|
|
*
|
|
|
|
* Alternatively, this software may be distributed under the terms of the
|
|
|
|
* GNU General Public License ("GPL") version 2 as published by the Free
|
|
|
|
* Software Foundation.
|
|
|
|
*
|
|
|
|
* NO WARRANTY
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
|
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
|
|
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
|
|
|
|
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
|
|
* HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
|
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
|
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
|
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
|
|
|
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
|
|
|
|
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
|
|
* POSSIBILITY OF SUCH DAMAGES.
|
|
|
|
*/
|
2000-10-28 05:01:06 +00:00
|
|
|
|
|
|
|
#define __TBXFACE_C__
|
|
|
|
|
2009-06-01 19:24:26 +00:00
|
|
|
#include "acpi.h"
|
2009-06-01 21:02:40 +00:00
|
|
|
#include "accommon.h"
|
2009-06-01 19:24:26 +00:00
|
|
|
#include "acnamesp.h"
|
|
|
|
#include "actables.h"
|
2000-10-28 05:01:06 +00:00
|
|
|
|
2001-05-29 19:52:40 +00:00
|
|
|
#define _COMPONENT ACPI_TABLES
|
2002-02-23 05:10:40 +00:00
|
|
|
ACPI_MODULE_NAME ("tbxface")
|
2000-10-28 05:01:06 +00:00
|
|
|
|
2007-03-22 17:24:05 +00:00
|
|
|
/* Local prototypes */
|
|
|
|
|
|
|
|
static ACPI_STATUS
|
|
|
|
AcpiTbLoadNamespace (
|
|
|
|
void);
|
|
|
|
|
2000-10-28 05:01:06 +00:00
|
|
|
|
|
|
|
/*******************************************************************************
|
|
|
|
*
|
2007-03-22 17:24:05 +00:00
|
|
|
* FUNCTION: AcpiAllocateRootTable
|
2000-10-28 05:01:06 +00:00
|
|
|
*
|
2007-03-22 17:24:05 +00:00
|
|
|
* PARAMETERS: InitialTableCount - Size of InitialTableArray, in number of
|
|
|
|
* ACPI_TABLE_DESC structures
|
2000-10-28 05:01:06 +00:00
|
|
|
*
|
|
|
|
* RETURN: Status
|
|
|
|
*
|
2007-03-22 17:24:05 +00:00
|
|
|
* DESCRIPTION: Allocate a root table array. Used by iASL compiler and
|
|
|
|
* AcpiInitializeTables.
|
2000-10-28 05:01:06 +00:00
|
|
|
*
|
|
|
|
******************************************************************************/
|
|
|
|
|
|
|
|
ACPI_STATUS
|
2007-03-22 17:24:05 +00:00
|
|
|
AcpiAllocateRootTable (
|
|
|
|
UINT32 InitialTableCount)
|
2000-10-28 05:01:06 +00:00
|
|
|
{
|
|
|
|
|
2010-04-28 21:50:57 +00:00
|
|
|
AcpiGbl_RootTableList.MaxTableCount = InitialTableCount;
|
2007-03-22 17:24:05 +00:00
|
|
|
AcpiGbl_RootTableList.Flags = ACPI_ROOT_ALLOW_RESIZE;
|
2000-10-28 05:01:06 +00:00
|
|
|
|
2007-03-22 17:24:05 +00:00
|
|
|
return (AcpiTbResizeRootTableList ());
|
|
|
|
}
|
2000-10-28 05:01:06 +00:00
|
|
|
|
|
|
|
|
2007-03-22 17:24:05 +00:00
|
|
|
/*******************************************************************************
|
|
|
|
*
|
|
|
|
* FUNCTION: AcpiInitializeTables
|
|
|
|
*
|
|
|
|
* PARAMETERS: InitialTableArray - Pointer to an array of pre-allocated
|
|
|
|
* ACPI_TABLE_DESC structures. If NULL, the
|
|
|
|
* array is dynamically allocated.
|
|
|
|
* InitialTableCount - Size of InitialTableArray, in number of
|
|
|
|
* ACPI_TABLE_DESC structures
|
|
|
|
* AllowRealloc - Flag to tell Table Manager if resize of
|
|
|
|
* pre-allocated array is allowed. Ignored
|
|
|
|
* if InitialTableArray is NULL.
|
|
|
|
*
|
|
|
|
* RETURN: Status
|
|
|
|
*
|
|
|
|
* DESCRIPTION: Initialize the table manager, get the RSDP and RSDT/XSDT.
|
|
|
|
*
|
|
|
|
* NOTE: Allows static allocation of the initial table array in order
|
|
|
|
* to avoid the use of dynamic memory in confined environments
|
|
|
|
* such as the kernel boot sequence where it may not be available.
|
|
|
|
*
|
|
|
|
* If the host OS memory managers are initialized, use NULL for
|
|
|
|
* InitialTableArray, and the table will be dynamically allocated.
|
|
|
|
*
|
|
|
|
******************************************************************************/
|
2001-07-21 03:55:17 +00:00
|
|
|
|
2007-03-22 17:24:05 +00:00
|
|
|
ACPI_STATUS
|
|
|
|
AcpiInitializeTables (
|
|
|
|
ACPI_TABLE_DESC *InitialTableArray,
|
|
|
|
UINT32 InitialTableCount,
|
|
|
|
BOOLEAN AllowResize)
|
|
|
|
{
|
|
|
|
ACPI_PHYSICAL_ADDRESS RsdpAddress;
|
|
|
|
ACPI_STATUS Status;
|
2001-07-21 03:55:17 +00:00
|
|
|
|
2000-10-28 05:01:06 +00:00
|
|
|
|
2007-03-22 17:24:05 +00:00
|
|
|
ACPI_FUNCTION_TRACE (AcpiInitializeTables);
|
2002-06-30 17:50:46 +00:00
|
|
|
|
2000-10-28 05:01:06 +00:00
|
|
|
|
2007-03-22 17:24:05 +00:00
|
|
|
/*
|
|
|
|
* Set up the Root Table Array
|
|
|
|
* Allocate the table array if requested
|
|
|
|
*/
|
|
|
|
if (!InitialTableArray)
|
2000-10-28 05:01:06 +00:00
|
|
|
{
|
2007-03-22 17:24:05 +00:00
|
|
|
Status = AcpiAllocateRootTable (InitialTableCount);
|
|
|
|
if (ACPI_FAILURE (Status))
|
|
|
|
{
|
|
|
|
return_ACPI_STATUS (Status);
|
|
|
|
}
|
2000-10-28 05:01:06 +00:00
|
|
|
}
|
2007-03-22 17:24:05 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
/* Root Table Array has been statically allocated by the host */
|
2000-10-28 05:01:06 +00:00
|
|
|
|
2007-03-22 17:24:05 +00:00
|
|
|
ACPI_MEMSET (InitialTableArray, 0,
|
2009-06-01 21:02:40 +00:00
|
|
|
(ACPI_SIZE) InitialTableCount * sizeof (ACPI_TABLE_DESC));
|
2000-10-28 05:01:06 +00:00
|
|
|
|
2007-03-22 17:24:05 +00:00
|
|
|
AcpiGbl_RootTableList.Tables = InitialTableArray;
|
2010-04-28 21:50:57 +00:00
|
|
|
AcpiGbl_RootTableList.MaxTableCount = InitialTableCount;
|
2007-03-22 17:24:05 +00:00
|
|
|
AcpiGbl_RootTableList.Flags = ACPI_ROOT_ORIGIN_UNKNOWN;
|
|
|
|
if (AllowResize)
|
|
|
|
{
|
|
|
|
AcpiGbl_RootTableList.Flags |= ACPI_ROOT_ALLOW_RESIZE;
|
|
|
|
}
|
2000-10-28 05:01:06 +00:00
|
|
|
}
|
|
|
|
|
2007-03-22 17:24:05 +00:00
|
|
|
/* Get the address of the RSDP */
|
2000-10-28 05:01:06 +00:00
|
|
|
|
2007-03-22 17:24:05 +00:00
|
|
|
RsdpAddress = AcpiOsGetRootPointer ();
|
|
|
|
if (!RsdpAddress)
|
2000-10-28 05:01:06 +00:00
|
|
|
{
|
2007-03-22 17:24:05 +00:00
|
|
|
return_ACPI_STATUS (AE_NOT_FOUND);
|
2000-10-28 05:01:06 +00:00
|
|
|
}
|
|
|
|
|
2007-03-22 17:24:05 +00:00
|
|
|
/*
|
|
|
|
* Get the root table (RSDT or XSDT) and extract all entries to the local
|
|
|
|
* Root Table Array. This array contains the information of the RSDT/XSDT
|
|
|
|
* in a common, more useable format.
|
|
|
|
*/
|
2009-06-01 21:02:40 +00:00
|
|
|
Status = AcpiTbParseRootTable (RsdpAddress);
|
2000-10-28 05:01:06 +00:00
|
|
|
return_ACPI_STATUS (Status);
|
|
|
|
}
|
|
|
|
|
2007-03-22 17:24:05 +00:00
|
|
|
ACPI_EXPORT_SYMBOL (AcpiInitializeTables)
|
|
|
|
|
2000-10-28 05:01:06 +00:00
|
|
|
|
|
|
|
/*******************************************************************************
|
|
|
|
*
|
2007-03-22 17:24:05 +00:00
|
|
|
* FUNCTION: AcpiReallocateRootTable
|
2000-10-28 05:01:06 +00:00
|
|
|
*
|
2007-03-22 17:24:05 +00:00
|
|
|
* PARAMETERS: None
|
2000-10-28 05:01:06 +00:00
|
|
|
*
|
|
|
|
* RETURN: Status
|
|
|
|
*
|
2007-03-22 17:24:05 +00:00
|
|
|
* DESCRIPTION: Reallocate Root Table List into dynamic memory. Copies the
|
|
|
|
* root list from the previously provided scratch area. Should
|
|
|
|
* be called once dynamic memory allocation is available in the
|
|
|
|
* kernel
|
2000-10-28 05:01:06 +00:00
|
|
|
*
|
|
|
|
******************************************************************************/
|
|
|
|
|
|
|
|
ACPI_STATUS
|
2007-03-22 17:24:05 +00:00
|
|
|
AcpiReallocateRootTable (
|
|
|
|
void)
|
2000-10-28 05:01:06 +00:00
|
|
|
{
|
2007-03-22 17:24:05 +00:00
|
|
|
ACPI_TABLE_DESC *Tables;
|
|
|
|
ACPI_SIZE NewSize;
|
2010-04-02 16:48:51 +00:00
|
|
|
ACPI_SIZE CurrentSize;
|
2000-10-28 05:01:06 +00:00
|
|
|
|
|
|
|
|
2007-03-22 17:24:05 +00:00
|
|
|
ACPI_FUNCTION_TRACE (AcpiReallocateRootTable);
|
2000-10-28 05:01:06 +00:00
|
|
|
|
2001-05-29 19:52:40 +00:00
|
|
|
|
2007-03-22 17:24:05 +00:00
|
|
|
/*
|
|
|
|
* Only reallocate the root table if the host provided a static buffer
|
|
|
|
* for the table array in the call to AcpiInitializeTables.
|
|
|
|
*/
|
|
|
|
if (AcpiGbl_RootTableList.Flags & ACPI_ROOT_ORIGIN_ALLOCATED)
|
2000-10-28 05:01:06 +00:00
|
|
|
{
|
2007-03-22 17:24:05 +00:00
|
|
|
return_ACPI_STATUS (AE_SUPPORT);
|
2000-10-28 05:01:06 +00:00
|
|
|
}
|
|
|
|
|
2010-04-02 16:48:51 +00:00
|
|
|
/*
|
|
|
|
* Get the current size of the root table and add the default
|
|
|
|
* increment to create the new table size.
|
|
|
|
*/
|
|
|
|
CurrentSize = (ACPI_SIZE)
|
2010-04-28 21:50:57 +00:00
|
|
|
AcpiGbl_RootTableList.CurrentTableCount * sizeof (ACPI_TABLE_DESC);
|
2010-04-02 16:48:51 +00:00
|
|
|
|
|
|
|
NewSize = CurrentSize +
|
|
|
|
(ACPI_ROOT_TABLE_SIZE_INCREMENT * sizeof (ACPI_TABLE_DESC));
|
2000-10-28 05:01:06 +00:00
|
|
|
|
2007-03-22 17:24:05 +00:00
|
|
|
/* Create new array and copy the old array */
|
2002-06-30 17:50:46 +00:00
|
|
|
|
2007-03-22 17:24:05 +00:00
|
|
|
Tables = ACPI_ALLOCATE_ZEROED (NewSize);
|
|
|
|
if (!Tables)
|
2000-10-28 05:01:06 +00:00
|
|
|
{
|
2007-03-22 17:24:05 +00:00
|
|
|
return_ACPI_STATUS (AE_NO_MEMORY);
|
2000-10-28 05:01:06 +00:00
|
|
|
}
|
|
|
|
|
2010-04-02 16:48:51 +00:00
|
|
|
ACPI_MEMCPY (Tables, AcpiGbl_RootTableList.Tables, CurrentSize);
|
|
|
|
|
2010-04-02 21:05:28 +00:00
|
|
|
/*
|
|
|
|
* Update the root table descriptor. The new size will be the current
|
|
|
|
* number of tables plus the increment, independent of the reserved
|
|
|
|
* size of the original table list.
|
|
|
|
*/
|
2007-03-22 17:24:05 +00:00
|
|
|
AcpiGbl_RootTableList.Tables = Tables;
|
2010-04-28 21:50:57 +00:00
|
|
|
AcpiGbl_RootTableList.MaxTableCount =
|
|
|
|
AcpiGbl_RootTableList.CurrentTableCount + ACPI_ROOT_TABLE_SIZE_INCREMENT;
|
2007-03-22 17:24:05 +00:00
|
|
|
AcpiGbl_RootTableList.Flags =
|
|
|
|
ACPI_ROOT_ORIGIN_ALLOCATED | ACPI_ROOT_ALLOW_RESIZE;
|
2000-10-28 05:01:06 +00:00
|
|
|
|
2007-03-22 17:24:05 +00:00
|
|
|
return_ACPI_STATUS (AE_OK);
|
|
|
|
}
|
2005-11-01 22:11:18 +00:00
|
|
|
|
2007-03-22 17:24:05 +00:00
|
|
|
ACPI_EXPORT_SYMBOL (AcpiReallocateRootTable)
|
2005-11-01 22:11:18 +00:00
|
|
|
|
2000-10-28 05:01:06 +00:00
|
|
|
|
2009-06-01 21:02:40 +00:00
|
|
|
/*******************************************************************************
|
2007-03-22 17:24:05 +00:00
|
|
|
*
|
|
|
|
* FUNCTION: AcpiGetTableHeader
|
|
|
|
*
|
|
|
|
* PARAMETERS: Signature - ACPI signature of needed table
|
|
|
|
* Instance - Which instance (for SSDTs)
|
|
|
|
* OutTableHeader - The pointer to the table header to fill
|
|
|
|
*
|
|
|
|
* RETURN: Status and pointer to mapped table header
|
|
|
|
*
|
|
|
|
* DESCRIPTION: Finds an ACPI table header.
|
|
|
|
*
|
|
|
|
* NOTE: Caller is responsible in unmapping the header with
|
|
|
|
* AcpiOsUnmapMemory
|
|
|
|
*
|
2009-06-01 21:02:40 +00:00
|
|
|
******************************************************************************/
|
2000-10-28 05:01:06 +00:00
|
|
|
|
2007-03-22 17:24:05 +00:00
|
|
|
ACPI_STATUS
|
|
|
|
AcpiGetTableHeader (
|
|
|
|
char *Signature,
|
2009-06-01 21:02:40 +00:00
|
|
|
UINT32 Instance,
|
2007-03-22 17:24:05 +00:00
|
|
|
ACPI_TABLE_HEADER *OutTableHeader)
|
|
|
|
{
|
2009-06-01 21:02:40 +00:00
|
|
|
UINT32 i;
|
|
|
|
UINT32 j;
|
2007-03-22 17:24:05 +00:00
|
|
|
ACPI_TABLE_HEADER *Header;
|
2002-02-23 05:10:40 +00:00
|
|
|
|
|
|
|
|
2007-03-22 17:24:05 +00:00
|
|
|
/* Parameter validation */
|
2002-02-23 05:10:40 +00:00
|
|
|
|
2007-03-22 17:24:05 +00:00
|
|
|
if (!Signature || !OutTableHeader)
|
|
|
|
{
|
|
|
|
return (AE_BAD_PARAMETER);
|
|
|
|
}
|
2002-02-23 05:10:40 +00:00
|
|
|
|
2009-06-01 21:02:40 +00:00
|
|
|
/* Walk the root table list */
|
|
|
|
|
2010-04-28 21:50:57 +00:00
|
|
|
for (i = 0, j = 0; i < AcpiGbl_RootTableList.CurrentTableCount; i++)
|
2007-03-22 17:24:05 +00:00
|
|
|
{
|
|
|
|
if (!ACPI_COMPARE_NAME (&(AcpiGbl_RootTableList.Tables[i].Signature),
|
|
|
|
Signature))
|
|
|
|
{
|
|
|
|
continue;
|
|
|
|
}
|
2002-02-23 05:10:40 +00:00
|
|
|
|
2007-03-22 17:24:05 +00:00
|
|
|
if (++j < Instance)
|
|
|
|
{
|
|
|
|
continue;
|
|
|
|
}
|
2002-02-23 05:10:40 +00:00
|
|
|
|
2007-03-22 17:24:05 +00:00
|
|
|
if (!AcpiGbl_RootTableList.Tables[i].Pointer)
|
|
|
|
{
|
2009-06-01 21:02:40 +00:00
|
|
|
if ((AcpiGbl_RootTableList.Tables[i].Flags &
|
|
|
|
ACPI_TABLE_ORIGIN_MASK) ==
|
2007-03-22 17:24:05 +00:00
|
|
|
ACPI_TABLE_ORIGIN_MAPPED)
|
|
|
|
{
|
2009-06-01 21:02:40 +00:00
|
|
|
Header = AcpiOsMapMemory (
|
|
|
|
AcpiGbl_RootTableList.Tables[i].Address,
|
2007-03-22 17:24:05 +00:00
|
|
|
sizeof (ACPI_TABLE_HEADER));
|
|
|
|
if (!Header)
|
|
|
|
{
|
|
|
|
return AE_NO_MEMORY;
|
|
|
|
}
|
|
|
|
|
|
|
|
ACPI_MEMCPY (OutTableHeader, Header, sizeof(ACPI_TABLE_HEADER));
|
|
|
|
AcpiOsUnmapMemory (Header, sizeof(ACPI_TABLE_HEADER));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return AE_NOT_FOUND;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2009-06-01 21:02:40 +00:00
|
|
|
ACPI_MEMCPY (OutTableHeader,
|
|
|
|
AcpiGbl_RootTableList.Tables[i].Pointer,
|
2007-03-22 17:24:05 +00:00
|
|
|
sizeof(ACPI_TABLE_HEADER));
|
|
|
|
}
|
2000-10-28 05:01:06 +00:00
|
|
|
|
2007-03-22 17:24:05 +00:00
|
|
|
return (AE_OK);
|
2000-10-28 05:01:06 +00:00
|
|
|
}
|
|
|
|
|
2007-03-22 17:24:05 +00:00
|
|
|
return (AE_NOT_FOUND);
|
2000-10-28 05:01:06 +00:00
|
|
|
}
|
|
|
|
|
2007-03-22 17:24:05 +00:00
|
|
|
ACPI_EXPORT_SYMBOL (AcpiGetTableHeader)
|
2000-10-28 05:01:06 +00:00
|
|
|
|
2007-03-22 17:24:05 +00:00
|
|
|
|
2009-06-01 21:02:40 +00:00
|
|
|
/*******************************************************************************
|
2000-10-28 05:01:06 +00:00
|
|
|
*
|
2007-03-22 17:24:05 +00:00
|
|
|
* FUNCTION: AcpiGetTable
|
2000-10-28 05:01:06 +00:00
|
|
|
*
|
2007-03-22 17:24:05 +00:00
|
|
|
* PARAMETERS: Signature - ACPI signature of needed table
|
|
|
|
* Instance - Which instance (for SSDTs)
|
|
|
|
* OutTable - Where the pointer to the table is returned
|
2000-10-28 05:01:06 +00:00
|
|
|
*
|
2007-03-22 17:24:05 +00:00
|
|
|
* RETURN: Status and pointer to table
|
2000-10-28 05:01:06 +00:00
|
|
|
*
|
2007-03-22 17:24:05 +00:00
|
|
|
* DESCRIPTION: Finds and verifies an ACPI table.
|
2000-10-28 05:01:06 +00:00
|
|
|
*
|
2009-06-01 21:02:40 +00:00
|
|
|
******************************************************************************/
|
2000-10-28 05:01:06 +00:00
|
|
|
|
|
|
|
ACPI_STATUS
|
2007-03-22 17:24:05 +00:00
|
|
|
AcpiGetTable (
|
|
|
|
char *Signature,
|
2009-06-01 21:02:40 +00:00
|
|
|
UINT32 Instance,
|
2007-03-22 17:24:05 +00:00
|
|
|
ACPI_TABLE_HEADER **OutTable)
|
2000-10-28 05:01:06 +00:00
|
|
|
{
|
2009-06-01 21:02:40 +00:00
|
|
|
UINT32 i;
|
|
|
|
UINT32 j;
|
2007-03-22 17:24:05 +00:00
|
|
|
ACPI_STATUS Status;
|
2000-10-28 05:01:06 +00:00
|
|
|
|
|
|
|
|
|
|
|
/* Parameter validation */
|
|
|
|
|
2007-03-22 17:24:05 +00:00
|
|
|
if (!Signature || !OutTable)
|
2000-10-28 05:01:06 +00:00
|
|
|
{
|
2007-03-22 17:24:05 +00:00
|
|
|
return (AE_BAD_PARAMETER);
|
2000-10-28 05:01:06 +00:00
|
|
|
}
|
|
|
|
|
2009-06-01 21:02:40 +00:00
|
|
|
/* Walk the root table list */
|
|
|
|
|
2010-04-28 21:50:57 +00:00
|
|
|
for (i = 0, j = 0; i < AcpiGbl_RootTableList.CurrentTableCount; i++)
|
2000-10-28 05:01:06 +00:00
|
|
|
{
|
2007-03-22 17:24:05 +00:00
|
|
|
if (!ACPI_COMPARE_NAME (&(AcpiGbl_RootTableList.Tables[i].Signature),
|
|
|
|
Signature))
|
|
|
|
{
|
|
|
|
continue;
|
|
|
|
}
|
2000-10-28 05:01:06 +00:00
|
|
|
|
2007-03-22 17:24:05 +00:00
|
|
|
if (++j < Instance)
|
|
|
|
{
|
|
|
|
continue;
|
|
|
|
}
|
2000-10-28 05:01:06 +00:00
|
|
|
|
2007-03-22 17:24:05 +00:00
|
|
|
Status = AcpiTbVerifyTable (&AcpiGbl_RootTableList.Tables[i]);
|
|
|
|
if (ACPI_SUCCESS (Status))
|
|
|
|
{
|
|
|
|
*OutTable = AcpiGbl_RootTableList.Tables[i].Pointer;
|
|
|
|
}
|
|
|
|
|
|
|
|
return (Status);
|
|
|
|
}
|
|
|
|
|
|
|
|
return (AE_NOT_FOUND);
|
2000-10-28 05:01:06 +00:00
|
|
|
}
|
|
|
|
|
2007-03-22 17:24:05 +00:00
|
|
|
ACPI_EXPORT_SYMBOL (AcpiGetTable)
|
|
|
|
|
2000-10-28 05:01:06 +00:00
|
|
|
|
|
|
|
/*******************************************************************************
|
|
|
|
*
|
2007-03-22 17:24:05 +00:00
|
|
|
* FUNCTION: AcpiGetTableByIndex
|
2000-10-28 05:01:06 +00:00
|
|
|
*
|
2007-03-22 17:24:05 +00:00
|
|
|
* PARAMETERS: TableIndex - Table index
|
|
|
|
* Table - Where the pointer to the table is returned
|
2000-10-28 05:01:06 +00:00
|
|
|
*
|
2007-03-22 17:24:05 +00:00
|
|
|
* RETURN: Status and pointer to the table
|
2000-10-28 05:01:06 +00:00
|
|
|
*
|
2007-03-22 17:24:05 +00:00
|
|
|
* DESCRIPTION: Obtain a table by an index into the global table list.
|
2000-10-28 05:01:06 +00:00
|
|
|
*
|
|
|
|
******************************************************************************/
|
|
|
|
|
|
|
|
ACPI_STATUS
|
2007-03-22 17:24:05 +00:00
|
|
|
AcpiGetTableByIndex (
|
2009-06-01 21:02:40 +00:00
|
|
|
UINT32 TableIndex,
|
2007-03-22 17:24:05 +00:00
|
|
|
ACPI_TABLE_HEADER **Table)
|
2000-10-28 05:01:06 +00:00
|
|
|
{
|
|
|
|
ACPI_STATUS Status;
|
|
|
|
|
|
|
|
|
2007-03-22 17:24:05 +00:00
|
|
|
ACPI_FUNCTION_TRACE (AcpiGetTableByIndex);
|
2000-10-28 05:01:06 +00:00
|
|
|
|
2001-05-29 19:52:40 +00:00
|
|
|
|
2007-03-22 17:24:05 +00:00
|
|
|
/* Parameter validation */
|
|
|
|
|
|
|
|
if (!Table)
|
2000-10-28 05:01:06 +00:00
|
|
|
{
|
|
|
|
return_ACPI_STATUS (AE_BAD_PARAMETER);
|
|
|
|
}
|
|
|
|
|
2007-03-22 17:24:05 +00:00
|
|
|
(void) AcpiUtAcquireMutex (ACPI_MTX_TABLES);
|
|
|
|
|
|
|
|
/* Validate index */
|
2000-10-28 05:01:06 +00:00
|
|
|
|
2010-04-28 21:50:57 +00:00
|
|
|
if (TableIndex >= AcpiGbl_RootTableList.CurrentTableCount)
|
2000-10-28 05:01:06 +00:00
|
|
|
{
|
2007-03-22 17:24:05 +00:00
|
|
|
(void) AcpiUtReleaseMutex (ACPI_MTX_TABLES);
|
2000-10-28 05:01:06 +00:00
|
|
|
return_ACPI_STATUS (AE_BAD_PARAMETER);
|
|
|
|
}
|
|
|
|
|
2007-03-22 17:24:05 +00:00
|
|
|
if (!AcpiGbl_RootTableList.Tables[TableIndex].Pointer)
|
2000-10-28 05:01:06 +00:00
|
|
|
{
|
2007-03-22 17:24:05 +00:00
|
|
|
/* Table is not mapped, map it */
|
2000-10-28 05:01:06 +00:00
|
|
|
|
2007-03-22 17:24:05 +00:00
|
|
|
Status = AcpiTbVerifyTable (&AcpiGbl_RootTableList.Tables[TableIndex]);
|
|
|
|
if (ACPI_FAILURE (Status))
|
|
|
|
{
|
|
|
|
(void) AcpiUtReleaseMutex (ACPI_MTX_TABLES);
|
|
|
|
return_ACPI_STATUS (Status);
|
|
|
|
}
|
2000-10-28 05:01:06 +00:00
|
|
|
}
|
|
|
|
|
2007-03-22 17:24:05 +00:00
|
|
|
*Table = AcpiGbl_RootTableList.Tables[TableIndex].Pointer;
|
|
|
|
(void) AcpiUtReleaseMutex (ACPI_MTX_TABLES);
|
|
|
|
return_ACPI_STATUS (AE_OK);
|
2000-10-28 05:01:06 +00:00
|
|
|
}
|
|
|
|
|
2007-03-22 17:24:05 +00:00
|
|
|
ACPI_EXPORT_SYMBOL (AcpiGetTableByIndex)
|
|
|
|
|
2000-10-28 05:01:06 +00:00
|
|
|
|
|
|
|
/*******************************************************************************
|
|
|
|
*
|
2007-03-22 17:24:05 +00:00
|
|
|
* FUNCTION: AcpiTbLoadNamespace
|
2000-10-28 05:01:06 +00:00
|
|
|
*
|
2007-03-22 17:24:05 +00:00
|
|
|
* PARAMETERS: None
|
2000-10-28 05:01:06 +00:00
|
|
|
*
|
|
|
|
* RETURN: Status
|
|
|
|
*
|
2007-03-22 17:24:05 +00:00
|
|
|
* DESCRIPTION: Load the namespace from the DSDT and all SSDTs/PSDTs found in
|
|
|
|
* the RSDT/XSDT.
|
2000-10-28 05:01:06 +00:00
|
|
|
*
|
|
|
|
******************************************************************************/
|
|
|
|
|
2007-03-22 17:24:05 +00:00
|
|
|
static ACPI_STATUS
|
|
|
|
AcpiTbLoadNamespace (
|
|
|
|
void)
|
2000-10-28 05:01:06 +00:00
|
|
|
{
|
|
|
|
ACPI_STATUS Status;
|
2009-06-01 21:02:40 +00:00
|
|
|
UINT32 i;
|
2010-04-02 16:48:51 +00:00
|
|
|
ACPI_TABLE_HEADER *NewDsdt;
|
2000-10-28 05:01:06 +00:00
|
|
|
|
|
|
|
|
2007-03-22 17:24:05 +00:00
|
|
|
ACPI_FUNCTION_TRACE (TbLoadNamespace);
|
2000-10-28 05:01:06 +00:00
|
|
|
|
2001-05-29 19:52:40 +00:00
|
|
|
|
2007-03-22 17:24:05 +00:00
|
|
|
(void) AcpiUtAcquireMutex (ACPI_MTX_TABLES);
|
2002-02-23 05:10:40 +00:00
|
|
|
|
2010-04-02 16:48:51 +00:00
|
|
|
/*
|
|
|
|
* Load the namespace. The DSDT is required, but any SSDT and
|
|
|
|
* PSDT tables are optional. Verify the DSDT.
|
2007-03-22 17:24:05 +00:00
|
|
|
*/
|
2010-04-28 21:50:57 +00:00
|
|
|
if (!AcpiGbl_RootTableList.CurrentTableCount ||
|
2010-04-02 17:00:37 +00:00
|
|
|
!ACPI_COMPARE_NAME (
|
|
|
|
&(AcpiGbl_RootTableList.Tables[ACPI_TABLE_INDEX_DSDT].Signature),
|
|
|
|
ACPI_SIG_DSDT) ||
|
2010-04-02 16:48:51 +00:00
|
|
|
ACPI_FAILURE (AcpiTbVerifyTable (
|
2009-06-01 21:02:40 +00:00
|
|
|
&AcpiGbl_RootTableList.Tables[ACPI_TABLE_INDEX_DSDT])))
|
2000-10-28 05:01:06 +00:00
|
|
|
{
|
2007-03-22 17:24:05 +00:00
|
|
|
Status = AE_NO_ACPI_TABLES;
|
|
|
|
goto UnlockAndExit;
|
2000-10-28 05:01:06 +00:00
|
|
|
}
|
|
|
|
|
2010-04-02 17:00:37 +00:00
|
|
|
/*
|
|
|
|
* Save the DSDT pointer for simple access. This is the mapped memory
|
|
|
|
* address. We must take care here because the address of the .Tables
|
|
|
|
* array can change dynamically as tables are loaded at run-time. Note:
|
|
|
|
* .Pointer field is not validated until after call to AcpiTbVerifyTable.
|
|
|
|
*/
|
|
|
|
AcpiGbl_DSDT = AcpiGbl_RootTableList.Tables[ACPI_TABLE_INDEX_DSDT].Pointer;
|
|
|
|
|
2010-04-02 16:48:51 +00:00
|
|
|
/*
|
|
|
|
* Optionally copy the entire DSDT to local memory (instead of simply
|
|
|
|
* mapping it.) There are some BIOSs that corrupt or replace the original
|
|
|
|
* DSDT, creating the need for this option. Default is FALSE, do not copy
|
|
|
|
* the DSDT.
|
|
|
|
*/
|
|
|
|
if (AcpiGbl_CopyDsdtLocally)
|
2000-10-28 05:01:06 +00:00
|
|
|
{
|
2010-04-02 16:48:51 +00:00
|
|
|
NewDsdt = AcpiTbCopyDsdt (ACPI_TABLE_INDEX_DSDT);
|
|
|
|
if (NewDsdt)
|
|
|
|
{
|
|
|
|
AcpiGbl_DSDT = NewDsdt;
|
|
|
|
}
|
2000-10-28 05:01:06 +00:00
|
|
|
}
|
|
|
|
|
2010-04-02 16:48:51 +00:00
|
|
|
/*
|
|
|
|
* Save the original DSDT header for detection of table corruption
|
|
|
|
* and/or replacement of the DSDT from outside the OS.
|
|
|
|
*/
|
|
|
|
ACPI_MEMCPY (&AcpiGbl_OriginalDsdtHeader, AcpiGbl_DSDT,
|
|
|
|
sizeof (ACPI_TABLE_HEADER));
|
|
|
|
|
2007-03-22 17:24:05 +00:00
|
|
|
(void) AcpiUtReleaseMutex (ACPI_MTX_TABLES);
|
2000-10-28 05:01:06 +00:00
|
|
|
|
2009-06-01 21:02:40 +00:00
|
|
|
/* Load and parse tables */
|
|
|
|
|
2007-03-22 17:24:05 +00:00
|
|
|
Status = AcpiNsLoadTable (ACPI_TABLE_INDEX_DSDT, AcpiGbl_RootNode);
|
2000-10-28 05:01:06 +00:00
|
|
|
if (ACPI_FAILURE (Status))
|
|
|
|
{
|
|
|
|
return_ACPI_STATUS (Status);
|
|
|
|
}
|
|
|
|
|
2009-06-01 21:02:40 +00:00
|
|
|
/* Load any SSDT or PSDT tables. Note: Loop leaves tables locked */
|
|
|
|
|
2007-03-22 17:24:05 +00:00
|
|
|
(void) AcpiUtAcquireMutex (ACPI_MTX_TABLES);
|
2010-04-28 21:50:57 +00:00
|
|
|
for (i = 0; i < AcpiGbl_RootTableList.CurrentTableCount; ++i)
|
2000-10-28 05:01:06 +00:00
|
|
|
{
|
2007-03-22 17:24:05 +00:00
|
|
|
if ((!ACPI_COMPARE_NAME (&(AcpiGbl_RootTableList.Tables[i].Signature),
|
|
|
|
ACPI_SIG_SSDT) &&
|
|
|
|
!ACPI_COMPARE_NAME (&(AcpiGbl_RootTableList.Tables[i].Signature),
|
|
|
|
ACPI_SIG_PSDT)) ||
|
2009-06-01 21:02:40 +00:00
|
|
|
ACPI_FAILURE (AcpiTbVerifyTable (
|
|
|
|
&AcpiGbl_RootTableList.Tables[i])))
|
2007-03-22 17:24:05 +00:00
|
|
|
{
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Ignore errors while loading tables, get as many as possible */
|
|
|
|
|
|
|
|
(void) AcpiUtReleaseMutex (ACPI_MTX_TABLES);
|
|
|
|
(void) AcpiNsLoadTable (i, AcpiGbl_RootNode);
|
|
|
|
(void) AcpiUtAcquireMutex (ACPI_MTX_TABLES);
|
2000-10-28 05:01:06 +00:00
|
|
|
}
|
|
|
|
|
2007-03-22 17:24:05 +00:00
|
|
|
ACPI_DEBUG_PRINT ((ACPI_DB_INIT, "ACPI Tables successfully acquired\n"));
|
2002-02-23 05:10:40 +00:00
|
|
|
|
2007-03-22 17:24:05 +00:00
|
|
|
UnlockAndExit:
|
|
|
|
(void) AcpiUtReleaseMutex (ACPI_MTX_TABLES);
|
|
|
|
return_ACPI_STATUS (Status);
|
|
|
|
}
|
2005-11-01 22:11:18 +00:00
|
|
|
|
2000-10-28 05:01:06 +00:00
|
|
|
|
2007-03-22 17:24:05 +00:00
|
|
|
/*******************************************************************************
|
|
|
|
*
|
|
|
|
* FUNCTION: AcpiLoadTables
|
|
|
|
*
|
|
|
|
* PARAMETERS: None
|
|
|
|
*
|
|
|
|
* RETURN: Status
|
|
|
|
*
|
|
|
|
* DESCRIPTION: Load the ACPI tables from the RSDT/XSDT
|
|
|
|
*
|
|
|
|
******************************************************************************/
|
|
|
|
|
|
|
|
ACPI_STATUS
|
|
|
|
AcpiLoadTables (
|
|
|
|
void)
|
|
|
|
{
|
|
|
|
ACPI_STATUS Status;
|
|
|
|
|
|
|
|
|
|
|
|
ACPI_FUNCTION_TRACE (AcpiLoadTables);
|
|
|
|
|
2002-02-23 05:10:40 +00:00
|
|
|
|
2009-06-01 21:02:40 +00:00
|
|
|
/* Load the namespace from the tables */
|
|
|
|
|
2007-03-22 17:24:05 +00:00
|
|
|
Status = AcpiTbLoadNamespace ();
|
2002-02-23 05:10:40 +00:00
|
|
|
if (ACPI_FAILURE (Status))
|
2000-10-28 05:01:06 +00:00
|
|
|
{
|
2009-06-01 21:02:40 +00:00
|
|
|
ACPI_EXCEPTION ((AE_INFO, Status,
|
|
|
|
"While loading namespace from ACPI tables"));
|
2000-10-28 05:01:06 +00:00
|
|
|
}
|
|
|
|
|
2007-03-22 17:24:05 +00:00
|
|
|
return_ACPI_STATUS (Status);
|
2000-10-28 05:01:06 +00:00
|
|
|
}
|
|
|
|
|
2007-03-22 17:24:05 +00:00
|
|
|
ACPI_EXPORT_SYMBOL (AcpiLoadTables)
|
2001-06-29 20:11:04 +00:00
|
|
|
|
2009-06-01 21:02:40 +00:00
|
|
|
|
|
|
|
/*******************************************************************************
|
|
|
|
*
|
|
|
|
* FUNCTION: AcpiInstallTableHandler
|
|
|
|
*
|
|
|
|
* PARAMETERS: Handler - Table event handler
|
|
|
|
* Context - Value passed to the handler on each event
|
|
|
|
*
|
|
|
|
* RETURN: Status
|
|
|
|
*
|
|
|
|
* DESCRIPTION: Install table event handler
|
|
|
|
*
|
|
|
|
******************************************************************************/
|
|
|
|
|
|
|
|
ACPI_STATUS
|
|
|
|
AcpiInstallTableHandler (
|
|
|
|
ACPI_TABLE_HANDLER Handler,
|
|
|
|
void *Context)
|
|
|
|
{
|
|
|
|
ACPI_STATUS Status;
|
|
|
|
|
|
|
|
|
|
|
|
ACPI_FUNCTION_TRACE (AcpiInstallTableHandler);
|
|
|
|
|
|
|
|
|
|
|
|
if (!Handler)
|
|
|
|
{
|
|
|
|
return_ACPI_STATUS (AE_BAD_PARAMETER);
|
|
|
|
}
|
|
|
|
|
|
|
|
Status = AcpiUtAcquireMutex (ACPI_MTX_EVENTS);
|
|
|
|
if (ACPI_FAILURE (Status))
|
|
|
|
{
|
|
|
|
return_ACPI_STATUS (Status);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Don't allow more than one handler */
|
|
|
|
|
|
|
|
if (AcpiGbl_TableHandler)
|
|
|
|
{
|
|
|
|
Status = AE_ALREADY_EXISTS;
|
|
|
|
goto Cleanup;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Install the handler */
|
|
|
|
|
|
|
|
AcpiGbl_TableHandler = Handler;
|
|
|
|
AcpiGbl_TableHandlerContext = Context;
|
|
|
|
|
|
|
|
Cleanup:
|
|
|
|
(void) AcpiUtReleaseMutex (ACPI_MTX_EVENTS);
|
|
|
|
return_ACPI_STATUS (Status);
|
|
|
|
}
|
|
|
|
|
|
|
|
ACPI_EXPORT_SYMBOL (AcpiInstallTableHandler)
|
|
|
|
|
|
|
|
|
|
|
|
/*******************************************************************************
|
|
|
|
*
|
|
|
|
* FUNCTION: AcpiRemoveTableHandler
|
|
|
|
*
|
|
|
|
* PARAMETERS: Handler - Table event handler that was installed
|
|
|
|
* previously.
|
|
|
|
*
|
|
|
|
* RETURN: Status
|
|
|
|
*
|
|
|
|
* DESCRIPTION: Remove table event handler
|
|
|
|
*
|
|
|
|
******************************************************************************/
|
|
|
|
|
|
|
|
ACPI_STATUS
|
|
|
|
AcpiRemoveTableHandler (
|
|
|
|
ACPI_TABLE_HANDLER Handler)
|
|
|
|
{
|
|
|
|
ACPI_STATUS Status;
|
|
|
|
|
|
|
|
|
|
|
|
ACPI_FUNCTION_TRACE (AcpiRemoveTableHandler);
|
|
|
|
|
|
|
|
|
|
|
|
Status = AcpiUtAcquireMutex (ACPI_MTX_EVENTS);
|
|
|
|
if (ACPI_FAILURE (Status))
|
|
|
|
{
|
|
|
|
return_ACPI_STATUS (Status);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Make sure that the installed handler is the same */
|
|
|
|
|
|
|
|
if (!Handler ||
|
|
|
|
Handler != AcpiGbl_TableHandler)
|
|
|
|
{
|
|
|
|
Status = AE_BAD_PARAMETER;
|
|
|
|
goto Cleanup;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Remove the handler */
|
|
|
|
|
|
|
|
AcpiGbl_TableHandler = NULL;
|
|
|
|
|
|
|
|
Cleanup:
|
|
|
|
(void) AcpiUtReleaseMutex (ACPI_MTX_EVENTS);
|
|
|
|
return_ACPI_STATUS (Status);
|
|
|
|
}
|
|
|
|
|
|
|
|
ACPI_EXPORT_SYMBOL (AcpiRemoveTableHandler)
|
|
|
|
|