tbxface.c revision 186507a7cf6e4b4155e9ef89631777a96633ac0e
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby/******************************************************************************
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby *
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby * Module Name: tbxface - Public interfaces to the ACPI subsystem
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby * ACPI table oriented interfaces
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby * $Revision: 1.70 $
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby *
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby *****************************************************************************/
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby/******************************************************************************
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby *
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby * 1. Copyright Notice
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby *
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp.
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby * All rights reserved.
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby *
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby * 2. License
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby *
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby * 2.1. This is your license from Intel Corp. under its intellectual property
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby * rights. You may have additional license terms from the party that provided
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby * you this software, covering your right to use that party's intellectual
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby * property rights.
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby *
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby * copy of the source code appearing in this file ("Covered Code") an
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby * irrevocable, perpetual, worldwide license under Intel's copyrights in the
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby * base code distributed originally by Intel ("Original Intel Code") to copy,
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby * make derivatives, distribute, use and display any portion of the Covered
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby * Code in any form, with the right to sublicense such rights; and
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby *
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby * license (with the right to sublicense), under only those claims of Intel
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby * patents that are infringed by the Original Intel Code, to make, use, sell,
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby * offer to sell, and import the Covered Code and derivative works thereof
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby * solely to the minimum extent necessary to exercise the above copyright
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby * license, and in no event shall the patent license extend to any additions
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby * to or modifications of the Original Intel Code. No other license or right
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby * is granted directly or by implication, estoppel or otherwise;
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby *
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby * The above copyright and patent license is granted only if the following
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby * conditions are met:
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby *
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby * 3. Conditions
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby *
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby * 3.1. Redistribution of Source with Rights to Further Distribute Source.
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby * Redistribution of source code of any substantial portion of the Covered
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby * Code or modification with rights to further distribute source must include
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby * the above Copyright Notice, the above License, this list of Conditions,
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby * and the following Disclaimer and Export Compliance provision. In addition,
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby * Licensee must cause all Covered Code to which Licensee contributes to
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby * contain a file documenting the changes Licensee made to create that Covered
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby * Code and the date of any change. Licensee must include in that file the
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby * documentation of any changes made by any predecessor Licensee. Licensee
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby * must include a prominent statement that the modification is derived,
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby * directly or indirectly, from Original Intel Code.
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby *
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby * 3.2. Redistribution of Source with no Rights to Further Distribute Source.
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby * Redistribution of source code of any substantial portion of the Covered
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby * Code or modification without rights to further distribute source must
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby * include the following Disclaimer and Export Compliance provision in the
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby * documentation and/or other materials provided with distribution. In
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby * addition, Licensee may not authorize further sublicense of source of any
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby * portion of the Covered Code, and must include terms to the effect that the
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby * license from Licensee to its licensee is limited to the intellectual
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby * property embodied in the software Licensee provides to its licensee, and
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby * not to intellectual property embodied in modifications its licensee may
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby * make.
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby *
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby * 3.3. Redistribution of Executable. Redistribution in executable form of any
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby * substantial portion of the Covered Code or modification must reproduce the
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby * above Copyright Notice, and the following Disclaimer and Export Compliance
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby * provision in the documentation and/or other materials provided with the
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby * distribution.
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby *
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby * 3.4. Intel retains all right, title, and interest in and to the Original
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby * Intel Code.
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby *
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby * 3.5. Neither the name Intel nor any other trademark owned or controlled by
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby * Intel shall be used in advertising or otherwise to promote the sale, use or
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby * other dealings in products derived from or relating to the Covered Code
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby * without prior written authorization from Intel.
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby *
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby * 4. Disclaimer and Export Compliance
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby *
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE,
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby * PARTICULAR PURPOSE.
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby *
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby * LIMITED REMEDY.
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby *
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby * 4.3. Licensee shall not export, either directly or indirectly, any of this
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby * software or system incorporating such software without first obtaining any
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby * required license or other approval from the U. S. Department of Commerce or
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby * any other agency or department of the United States Government. In the
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby * event Licensee exports any such software from the United States or
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby * re-exports any such software from a foreign destination, Licensee shall
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby * ensure that the distribution and export/re-export of the software is in
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby * compliance with all laws, regulations, orders, or other restrictions of the
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby * U.S. Export Administration Regulations. Licensee agrees that neither it nor
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby * any of its subsidiaries will export/re-export any technical data, process,
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby * software, or service, directly or indirectly, to any country for which the
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby * United States government or any agency thereof requires an export license,
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby * other governmental approval, or letter of assurance, without first obtaining
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby * such license, approval or letter.
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby *
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby *****************************************************************************/
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby#define __TBXFACE_C__
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby#include "acpi.h"
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby#include "acnamesp.h"
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby#include "actables.h"
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby#define _COMPONENT ACPI_TABLES
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby ACPI_MODULE_NAME ("tbxface")
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby/*******************************************************************************
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby *
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby * FUNCTION: AcpiLoadTables
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby *
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby * PARAMETERS: None
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby *
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby * RETURN: Status
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby *
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby * DESCRIPTION: This function is called to load the ACPI tables from the
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby * provided RSDT
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby *
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby ******************************************************************************/
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin MaltbyACPI_STATUS
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin MaltbyAcpiLoadTables (
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby void)
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby{
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby ACPI_POINTER RsdpAddress;
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby ACPI_STATUS Status;
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby ACPI_FUNCTION_TRACE ("AcpiLoadTables");
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby /* Get the RSDP */
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby Status = AcpiOsGetRootPointer (ACPI_LOGICAL_ADDRESSING,
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby &RsdpAddress);
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby if (ACPI_FAILURE (Status))
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby {
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby ACPI_REPORT_ERROR (("AcpiLoadTables: Could not get RSDP, %s\n",
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby AcpiFormatException (Status)));
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby goto ErrorExit;
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby }
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby /* Map and validate the RSDP */
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby AcpiGbl_TableFlags = RsdpAddress.PointerType;
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby Status = AcpiTbVerifyRsdp (&RsdpAddress);
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby if (ACPI_FAILURE (Status))
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby {
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby ACPI_REPORT_ERROR (("AcpiLoadTables: RSDP Failed validation: %s\n",
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby AcpiFormatException (Status)));
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby goto ErrorExit;
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby }
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby /* Get the RSDT via the RSDP */
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby Status = AcpiTbGetTableRsdt ();
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby if (ACPI_FAILURE (Status))
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby {
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby ACPI_REPORT_ERROR (("AcpiLoadTables: Could not load RSDT: %s\n",
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby AcpiFormatException (Status)));
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby goto ErrorExit;
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby }
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby /* Now get the tables needed by this subsystem (FADT, DSDT, etc.) */
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby Status = AcpiTbGetRequiredTables ();
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby if (ACPI_FAILURE (Status))
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby {
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby ACPI_REPORT_ERROR ((
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby "AcpiLoadTables: Error getting required tables (DSDT/FADT/FACS): %s\n",
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby AcpiFormatException (Status)));
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby goto ErrorExit;
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby }
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby ACPI_DEBUG_PRINT ((ACPI_DB_INIT, "ACPI Tables successfully acquired\n"));
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby /* Load the namespace from the tables */
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby Status = AcpiNsLoadNamespace ();
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby if (ACPI_FAILURE (Status))
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby {
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby ACPI_REPORT_ERROR (("AcpiLoadTables: Could not load namespace: %s\n",
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby AcpiFormatException (Status)));
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby goto ErrorExit;
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby }
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby return_ACPI_STATUS (AE_OK);
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin MaltbyErrorExit:
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby ACPI_REPORT_ERROR (("AcpiLoadTables: Could not load tables: %s\n",
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby AcpiFormatException (Status)));
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby return_ACPI_STATUS (Status);
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby}
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby/*******************************************************************************
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby *
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby * FUNCTION: AcpiLoadTable
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby *
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby * PARAMETERS: TablePtr - pointer to a buffer containing the entire
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby * table to be loaded
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby *
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby * RETURN: Status
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby *
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby * DESCRIPTION: This function is called to load a table from the caller's
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby * buffer. The buffer must contain an entire ACPI Table including
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby * a valid header. The header fields will be verified, and if it
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby * is determined that the table is invalid, the call will fail.
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby *
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby ******************************************************************************/
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin MaltbyACPI_STATUS
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin MaltbyAcpiLoadTable (
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby ACPI_TABLE_HEADER *TablePtr)
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby{
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby ACPI_STATUS Status;
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby ACPI_TABLE_DESC TableInfo;
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby ACPI_POINTER Address;
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby ACPI_FUNCTION_TRACE ("AcpiLoadTable");
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby if (!TablePtr)
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby {
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby return_ACPI_STATUS (AE_BAD_PARAMETER);
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby }
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby /* Copy the table to a local buffer */
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby Address.PointerType = ACPI_LOGICAL_POINTER | ACPI_LOGICAL_ADDRESSING;
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby Address.Pointer.Logical = TablePtr;
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby Status = AcpiTbGetTableBody (&Address, TablePtr, &TableInfo);
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby if (ACPI_FAILURE (Status))
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby {
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby return_ACPI_STATUS (Status);
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby }
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby /* Check signature for a valid table type */
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby Status = AcpiTbRecognizeTable (&TableInfo, ACPI_TABLE_ALL);
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby if (ACPI_FAILURE (Status))
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby {
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby return_ACPI_STATUS (Status);
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby }
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby /* Install the new table into the local data structures */
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby Status = AcpiTbInstallTable (&TableInfo);
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby if (ACPI_FAILURE (Status))
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby {
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby if (Status == AE_ALREADY_EXISTS)
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby {
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby /* Table already exists, no error */
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby Status = AE_OK;
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby }
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby /* Free table allocated by AcpiTbGetTableBody */
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby AcpiTbDeleteSingleTable (&TableInfo);
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby return_ACPI_STATUS (Status);
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby }
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby /* Convert the table to common format if necessary */
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby switch (TableInfo.Type)
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby {
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby case ACPI_TABLE_FADT:
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby Status = AcpiTbConvertTableFadt ();
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby break;
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby case ACPI_TABLE_FACS:
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby Status = AcpiTbBuildCommonFacs (&TableInfo);
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby break;
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby default:
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby /* Load table into namespace if it contains executable AML */
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby Status = AcpiNsLoadTable (TableInfo.InstalledDesc, AcpiGbl_RootNode);
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby break;
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby }
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby if (ACPI_FAILURE (Status))
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby {
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby /* Uninstall table and free the buffer */
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby (void) AcpiTbUninstallTable (TableInfo.InstalledDesc);
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby }
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby return_ACPI_STATUS (Status);
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby}
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby/*******************************************************************************
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby *
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby * FUNCTION: AcpiUnloadTable
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby *
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby * PARAMETERS: TableType - Type of table to be unloaded
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby *
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby * RETURN: Status
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby *
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby * DESCRIPTION: This routine is used to force the unload of a table
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby *
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby ******************************************************************************/
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin MaltbyACPI_STATUS
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin MaltbyAcpiUnloadTable (
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby ACPI_TABLE_TYPE TableType)
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby{
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby ACPI_TABLE_DESC *TableDesc;
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby ACPI_FUNCTION_TRACE ("AcpiUnloadTable");
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby /* Parameter validation */
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby if (TableType > ACPI_TABLE_MAX)
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby {
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby return_ACPI_STATUS (AE_BAD_PARAMETER);
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby }
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby /* Find all tables of the requested type */
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby TableDesc = AcpiGbl_TableLists[TableType].Next;
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby while (TableDesc)
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby {
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby /*
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby * Delete all namespace entries owned by this table. Note that these
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby * entries can appear anywhere in the namespace by virtue of the AML
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby * "Scope" operator. Thus, we need to track ownership by an ID, not
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby * simply a position within the hierarchy
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby */
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby AcpiNsDeleteNamespaceByOwner (TableDesc->OwnerId);
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby AcpiUtReleaseOwnerId (&TableDesc->OwnerId);
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby TableDesc = TableDesc->Next;
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby }
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby /* Delete (or unmap) all tables of this type */
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby AcpiTbDeleteTablesByType (TableType);
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby return_ACPI_STATUS (AE_OK);
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby}
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby/*******************************************************************************
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby *
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby * FUNCTION: AcpiGetTableHeader
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby *
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby * PARAMETERS: TableType - one of the defined table types
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby * Instance - the non zero instance of the table, allows
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby * support for multiple tables of the same type
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby * see AcpiGbl_AcpiTableFlag
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby * OutTableHeader - pointer to the ACPI_TABLE_HEADER if successful
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby *
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby * DESCRIPTION: This function is called to get an ACPI table header. The caller
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby * supplies an pointer to a data area sufficient to contain an ACPI
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby * ACPI_TABLE_HEADER structure.
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby *
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby * The header contains a length field that can be used to determine
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby * the size of the buffer needed to contain the entire table. This
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby * function is not valid for the RSD PTR table since it does not
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby * have a standard header and is fixed length.
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby *
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby ******************************************************************************/
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin MaltbyACPI_STATUS
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin MaltbyAcpiGetTableHeader (
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby ACPI_TABLE_TYPE TableType,
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby UINT32 Instance,
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby ACPI_TABLE_HEADER *OutTableHeader)
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby{
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby ACPI_TABLE_HEADER *TblPtr;
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby ACPI_STATUS Status;
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby ACPI_FUNCTION_TRACE ("AcpiGetTableHeader");
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby if ((Instance == 0) ||
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby (TableType == ACPI_TABLE_RSDP) ||
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby (!OutTableHeader))
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby {
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby return_ACPI_STATUS (AE_BAD_PARAMETER);
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby }
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby /* Check the table type and instance */
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby if ((TableType > ACPI_TABLE_MAX) ||
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby (ACPI_IS_SINGLE_TABLE (AcpiGbl_TableData[TableType].Flags) &&
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby Instance > 1))
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby {
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby return_ACPI_STATUS (AE_BAD_PARAMETER);
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby }
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby /* Get a pointer to the entire table */
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby Status = AcpiTbGetTablePtr (TableType, Instance, &TblPtr);
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby if (ACPI_FAILURE (Status))
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby {
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby return_ACPI_STATUS (Status);
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby }
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby /* The function will return a NULL pointer if the table is not loaded */
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby if (TblPtr == NULL)
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby {
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby return_ACPI_STATUS (AE_NOT_EXIST);
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby }
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby /* Copy the header to the caller's buffer */
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby ACPI_MEMCPY ((void *) OutTableHeader, (void *) TblPtr,
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby sizeof (ACPI_TABLE_HEADER));
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby return_ACPI_STATUS (Status);
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby}
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby/*******************************************************************************
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby *
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby * FUNCTION: AcpiGetTable
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby *
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby * PARAMETERS: TableType - one of the defined table types
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby * Instance - the non zero instance of the table, allows
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby * support for multiple tables of the same type
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby * see AcpiGbl_AcpiTableFlag
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby * RetBuffer - pointer to a structure containing a buffer to
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby * receive the table
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby *
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby * RETURN: Status
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby *
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby * DESCRIPTION: This function is called to get an ACPI table. The caller
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby * supplies an OutBuffer large enough to contain the entire ACPI
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby * table. The caller should call the AcpiGetTableHeader function
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby * first to determine the buffer size needed. Upon completion
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby * the OutBuffer->Length field will indicate the number of bytes
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby * copied into the OutBuffer->BufPtr buffer. This table will be
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby * a complete table including the header.
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby *
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby ******************************************************************************/
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin MaltbyACPI_STATUS
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin MaltbyAcpiGetTable (
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby ACPI_TABLE_TYPE TableType,
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby UINT32 Instance,
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby ACPI_BUFFER *RetBuffer)
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby{
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby ACPI_TABLE_HEADER *TblPtr;
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby ACPI_STATUS Status;
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby ACPI_SIZE TableLength;
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby ACPI_FUNCTION_TRACE ("AcpiGetTable");
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby /* Parameter validation */
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby if (Instance == 0)
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby {
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby return_ACPI_STATUS (AE_BAD_PARAMETER);
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby }
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby Status = AcpiUtValidateBuffer (RetBuffer);
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby if (ACPI_FAILURE (Status))
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby {
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby return_ACPI_STATUS (Status);
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby }
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby /* Check the table type and instance */
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby if ((TableType > ACPI_TABLE_MAX) ||
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby (ACPI_IS_SINGLE_TABLE (AcpiGbl_TableData[TableType].Flags) &&
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby Instance > 1))
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby {
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby return_ACPI_STATUS (AE_BAD_PARAMETER);
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby }
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby /* Get a pointer to the entire table */
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby Status = AcpiTbGetTablePtr (TableType, Instance, &TblPtr);
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby if (ACPI_FAILURE (Status))
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby {
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby return_ACPI_STATUS (Status);
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby }
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby /*
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby * AcpiTbGetTablePtr will return a NULL pointer if the
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby * table is not loaded.
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby */
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby if (TblPtr == NULL)
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby {
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby return_ACPI_STATUS (AE_NOT_EXIST);
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby }
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby /* Get the table length */
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby if (TableType == ACPI_TABLE_RSDP)
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby {
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby /* RSD PTR is the only "table" without a header */
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby TableLength = sizeof (RSDP_DESCRIPTOR);
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby }
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby else
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby {
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby TableLength = (ACPI_SIZE) TblPtr->Length;
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby }
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby /* Validate/Allocate/Clear caller buffer */
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby Status = AcpiUtInitializeBuffer (RetBuffer, TableLength);
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby if (ACPI_FAILURE (Status))
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby {
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby return_ACPI_STATUS (Status);
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby }
/* Copy the table to the buffer */
ACPI_MEMCPY ((void *) RetBuffer->Pointer, (void *) TblPtr, TableLength);
return_ACPI_STATUS (AE_OK);
}