tbfind.c revision 193251
113685Swosch/******************************************************************************
213685Swosch *
313685Swosch * Module Name: tbfind   - find table
450477Speter *              $Revision: 1.3 $
513685Swosch *
613685Swosch *****************************************************************************/
713685Swosch
813685Swosch/******************************************************************************
913685Swosch *
101590Srgrimes * 1. Copyright Notice
1113792Smpp *
121590Srgrimes * Some or all of this work - Copyright (c) 1999 - 2007, Intel Corp.
131590Srgrimes * All rights reserved.
141590Srgrimes *
151590Srgrimes * 2. License
161590Srgrimes *
171590Srgrimes * 2.1. This is your license from Intel Corp. under its intellectual property
181590Srgrimes * rights.  You may have additional license terms from the party that provided
191590Srgrimes * you this software, covering your right to use that party's intellectual
201590Srgrimes * property rights.
211590Srgrimes *
221590Srgrimes * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
231590Srgrimes * copy of the source code appearing in this file ("Covered Code") an
241590Srgrimes * irrevocable, perpetual, worldwide license under Intel's copyrights in the
251590Srgrimes * base code distributed originally by Intel ("Original Intel Code") to copy,
261590Srgrimes * make derivatives, distribute, use and display any portion of the Covered
271590Srgrimes * Code in any form, with the right to sublicense such rights; and
281590Srgrimes *
291590Srgrimes * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
301590Srgrimes * license (with the right to sublicense), under only those claims of Intel
311590Srgrimes * patents that are infringed by the Original Intel Code, to make, use, sell,
321590Srgrimes * offer to sell, and import the Covered Code and derivative works thereof
331590Srgrimes * solely to the minimum extent necessary to exercise the above copyright
341590Srgrimes * license, and in no event shall the patent license extend to any additions
35113543Sgrog * to or modifications of the Original Intel Code.  No other license or right
361590Srgrimes * is granted directly or by implication, estoppel or otherwise;
371590Srgrimes *
381590Srgrimes * The above copyright and patent license is granted only if the following
391590Srgrimes * conditions are met:
401590Srgrimes *
411590Srgrimes * 3. Conditions
421590Srgrimes *
431590Srgrimes * 3.1. Redistribution of Source with Rights to Further Distribute Source.
441590Srgrimes * Redistribution of source code of any substantial portion of the Covered
451590Srgrimes * Code or modification with rights to further distribute source must include
461590Srgrimes * the above Copyright Notice, the above License, this list of Conditions,
471590Srgrimes * and the following Disclaimer and Export Compliance provision.  In addition,
4854758Scpiazza * Licensee must cause all Covered Code to which Licensee contributes to
49110933Sseanc * contain a file documenting the changes Licensee made to create that Covered
50110933Sseanc * Code and the date of any change.  Licensee must include in that file the
511590Srgrimes * documentation of any changes made by any predecessor Licensee.  Licensee
52110933Sseanc * must include a prominent statement that the modification is derived,
531590Srgrimes * directly or indirectly, from Original Intel Code.
541590Srgrimes *
55113543Sgrog * 3.2. Redistribution of Source with no Rights to Further Distribute Source.
561590Srgrimes * Redistribution of source code of any substantial portion of the Covered
571590Srgrimes * Code or modification without rights to further distribute source must
581590Srgrimes * include the following Disclaimer and Export Compliance provision in the
591590Srgrimes * documentation and/or other materials provided with distribution.  In
601590Srgrimes * addition, Licensee may not authorize further sublicense of source of any
611590Srgrimes * portion of the Covered Code, and must include terms to the effect that the
621590Srgrimes * license from Licensee to its licensee is limited to the intellectual
631590Srgrimes * property embodied in the software Licensee provides to its licensee, and
641590Srgrimes * not to intellectual property embodied in modifications its licensee may
651590Srgrimes * make.
661590Srgrimes *
671590Srgrimes * 3.3. Redistribution of Executable. Redistribution in executable form of any
681590Srgrimes * substantial portion of the Covered Code or modification must reproduce the
691590Srgrimes * above Copyright Notice, and the following Disclaimer and Export Compliance
701590Srgrimes * provision in the documentation and/or other materials provided with the
711590Srgrimes * distribution.
721590Srgrimes *
731590Srgrimes * 3.4. Intel retains all right, title, and interest in and to the Original
741590Srgrimes * Intel Code.
751590Srgrimes *
761590Srgrimes * 3.5. Neither the name Intel nor any other trademark owned or controlled by
7723094Smpp * Intel shall be used in advertising or otherwise to promote the sale, use or
781590Srgrimes * other dealings in products derived from or relating to the Covered Code
791590Srgrimes * without prior written authorization from Intel.
801590Srgrimes *
81165616Sru * 4. Disclaimer and Export Compliance
82112249Sgrog *
83102501Sgrog * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
841590Srgrimes * HERE.  ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
851590Srgrimes * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT,  ASSISTANCE,
861590Srgrimes * INSTALLATION, TRAINING OR OTHER SERVICES.  INTEL WILL NOT PROVIDE ANY
871590Srgrimes * UPDATES, ENHANCEMENTS OR EXTENSIONS.  INTEL SPECIFICALLY DISCLAIMS ANY
881590Srgrimes * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
891590Srgrimes * PARTICULAR PURPOSE.
901590Srgrimes *
911590Srgrimes * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
921590Srgrimes * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
931590Srgrimes * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
941590Srgrimes * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
951590Srgrimes * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
961590Srgrimes * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES.  THESE LIMITATIONS
971590Srgrimes * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
981590Srgrimes * LIMITED REMEDY.
991590Srgrimes *
1001590Srgrimes * 4.3. Licensee shall not export, either directly or indirectly, any of this
1011590Srgrimes * software or system incorporating such software without first obtaining any
1021590Srgrimes * required license or other approval from the U. S. Department of Commerce or
10392217Sgrog * any other agency or department of the United States Government.  In the
1041590Srgrimes * event Licensee exports any such software from the United States or
1051590Srgrimes * re-exports any such software from a foreign destination, Licensee shall
1061590Srgrimes * ensure that the distribution and export/re-export of the software is in
1071590Srgrimes * compliance with all laws, regulations, orders, or other restrictions of the
1081590Srgrimes * U.S. Export Administration Regulations. Licensee agrees that neither it nor
109113543Sgrog * any of its subsidiaries will export/re-export any technical data, process,
1101590Srgrimes * software, or service, directly or indirectly, to any country for which the
111113543Sgrog * United States government or any agency thereof requires an export license,
1121590Srgrimes * other governmental approval, or letter of assurance, without first obtaining
1131590Srgrimes * such license, approval or letter.
1141590Srgrimes *
1151590Srgrimes *****************************************************************************/
1161590Srgrimes
1171590Srgrimes#define __TBFIND_C__
1181590Srgrimes
1191590Srgrimes#include "acpi.h"
1201590Srgrimes#include "actables.h"
121113850Sgrog
1221590Srgrimes#define _COMPONENT          ACPI_TABLES
12313792Smpp        ACPI_MODULE_NAME    ("tbfind")
1241590Srgrimes
12513792Smpp
1261590Srgrimes/*******************************************************************************
1271590Srgrimes *
1281590Srgrimes * FUNCTION:    AcpiTbFindTable
1291590Srgrimes *
1301590Srgrimes * PARAMETERS:  Signature           - String with ACPI table signature
131161355Smaxim *              OemId               - String with the table OEM ID
1321590Srgrimes *              OemTableId          - String with the OEM Table ID
1331590Srgrimes *              TableIndex          - Where the table index is returned
1341590Srgrimes *
1351590Srgrimes * RETURN:      Status and table index
1361590Srgrimes *
1371590Srgrimes * DESCRIPTION: Find an ACPI table (in the RSDT/XSDT) that matches the
1381590Srgrimes *              Signature, OEM ID and OEM Table ID. Returns an index that can
1391590Srgrimes *              be used to get the table header or entire table.
1401590Srgrimes *
1411590Srgrimes ******************************************************************************/
1421590Srgrimes
1431590SrgrimesACPI_STATUS
1441590SrgrimesAcpiTbFindTable (
1451590Srgrimes    char                    *Signature,
1461590Srgrimes    char                    *OemId,
1471590Srgrimes    char                    *OemTableId,
1481590Srgrimes    ACPI_NATIVE_UINT        *TableIndex)
1491590Srgrimes{
150102545Sgrog    ACPI_NATIVE_UINT        i;
1511590Srgrimes    ACPI_STATUS             Status;
1521590Srgrimes
1531590Srgrimes
1541590Srgrimes    ACPI_FUNCTION_TRACE (TbFindTable);
1551590Srgrimes
1561590Srgrimes
1571590Srgrimes    for (i = 0; i < AcpiGbl_RootTableList.Count; ++i)
1581590Srgrimes    {
1591590Srgrimes        if (ACPI_MEMCMP (&(AcpiGbl_RootTableList.Tables[i].Signature),
1601590Srgrimes            Signature, ACPI_NAME_SIZE))
16113792Smpp        {
1621590Srgrimes            /* Not the requested table */
1631590Srgrimes
1641590Srgrimes            continue;
1651590Srgrimes        }
1661590Srgrimes
1671590Srgrimes        /* Table with matching signature has been found */
1681590Srgrimes
1691590Srgrimes        if (!AcpiGbl_RootTableList.Tables[i].Pointer)
1701590Srgrimes        {
1711590Srgrimes            /* Table is not currently mapped, map it */
1721590Srgrimes
1731590Srgrimes            Status = AcpiTbVerifyTable (&AcpiGbl_RootTableList.Tables[i]);
1741590Srgrimes            if (ACPI_FAILURE (Status))
1751590Srgrimes            {
1761590Srgrimes                return_ACPI_STATUS (Status);
1771590Srgrimes            }
1781590Srgrimes
1791590Srgrimes            if (!AcpiGbl_RootTableList.Tables[i].Pointer)
1801590Srgrimes            {
1811590Srgrimes                continue;
1821590Srgrimes            }
1831590Srgrimes        }
1841590Srgrimes
1851590Srgrimes        /* Check for table match on all IDs */
1861590Srgrimes
1871590Srgrimes        if (!ACPI_MEMCMP (AcpiGbl_RootTableList.Tables[i].Pointer->Signature,
1881590Srgrimes                Signature, ACPI_NAME_SIZE) &&
1891590Srgrimes            (!OemId[0] ||
1901590Srgrimes             !ACPI_MEMCMP (AcpiGbl_RootTableList.Tables[i].Pointer->OemId,
1911590Srgrimes                             OemId, ACPI_OEM_ID_SIZE)) &&
1921590Srgrimes            (!OemTableId[0] ||
1931590Srgrimes             !ACPI_MEMCMP (AcpiGbl_RootTableList.Tables[i].Pointer->OemTableId,
1941590Srgrimes                             OemTableId, ACPI_OEM_TABLE_ID_SIZE)))
1951590Srgrimes        {
1961590Srgrimes            *TableIndex = i;
1971590Srgrimes
1981590Srgrimes            ACPI_DEBUG_PRINT ((ACPI_DB_TABLES, "Found table [%4.4s]\n",
1991590Srgrimes                Signature));
2001590Srgrimes            return_ACPI_STATUS (AE_OK);
2011590Srgrimes        }
2021590Srgrimes    }
2031590Srgrimes
2041590Srgrimes    return_ACPI_STATUS (AE_NOT_FOUND);
205148069Sceri}
2061590Srgrimes