tbfind.c revision 1.1.1.2.2.2 1 1.1.1.2.2.2 bouyer /******************************************************************************
2 1.1.1.2.2.2 bouyer *
3 1.1.1.2.2.2 bouyer * Module Name: tbfind - find table
4 1.1.1.2.2.2 bouyer *
5 1.1.1.2.2.2 bouyer *****************************************************************************/
6 1.1.1.2.2.2 bouyer
7 1.1.1.2.2.2 bouyer /*
8 1.1.1.2.2.2 bouyer * Copyright (C) 2000 - 2011, Intel Corp.
9 1.1.1.2.2.2 bouyer * All rights reserved.
10 1.1.1.2.2.2 bouyer *
11 1.1.1.2.2.2 bouyer * Redistribution and use in source and binary forms, with or without
12 1.1.1.2.2.2 bouyer * modification, are permitted provided that the following conditions
13 1.1.1.2.2.2 bouyer * are met:
14 1.1.1.2.2.2 bouyer * 1. Redistributions of source code must retain the above copyright
15 1.1.1.2.2.2 bouyer * notice, this list of conditions, and the following disclaimer,
16 1.1.1.2.2.2 bouyer * without modification.
17 1.1.1.2.2.2 bouyer * 2. Redistributions in binary form must reproduce at minimum a disclaimer
18 1.1.1.2.2.2 bouyer * substantially similar to the "NO WARRANTY" disclaimer below
19 1.1.1.2.2.2 bouyer * ("Disclaimer") and any redistribution must be conditioned upon
20 1.1.1.2.2.2 bouyer * including a substantially similar Disclaimer requirement for further
21 1.1.1.2.2.2 bouyer * binary redistribution.
22 1.1.1.2.2.2 bouyer * 3. Neither the names of the above-listed copyright holders nor the names
23 1.1.1.2.2.2 bouyer * of any contributors may be used to endorse or promote products derived
24 1.1.1.2.2.2 bouyer * from this software without specific prior written permission.
25 1.1.1.2.2.2 bouyer *
26 1.1.1.2.2.2 bouyer * Alternatively, this software may be distributed under the terms of the
27 1.1.1.2.2.2 bouyer * GNU General Public License ("GPL") version 2 as published by the Free
28 1.1.1.2.2.2 bouyer * Software Foundation.
29 1.1.1.2.2.2 bouyer *
30 1.1.1.2.2.2 bouyer * NO WARRANTY
31 1.1.1.2.2.2 bouyer * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
32 1.1.1.2.2.2 bouyer * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
33 1.1.1.2.2.2 bouyer * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
34 1.1.1.2.2.2 bouyer * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
35 1.1.1.2.2.2 bouyer * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
36 1.1.1.2.2.2 bouyer * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
37 1.1.1.2.2.2 bouyer * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
38 1.1.1.2.2.2 bouyer * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
39 1.1.1.2.2.2 bouyer * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
40 1.1.1.2.2.2 bouyer * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
41 1.1.1.2.2.2 bouyer * POSSIBILITY OF SUCH DAMAGES.
42 1.1.1.2.2.2 bouyer */
43 1.1.1.2.2.2 bouyer
44 1.1.1.2.2.2 bouyer #define __TBFIND_C__
45 1.1.1.2.2.2 bouyer
46 1.1.1.2.2.2 bouyer #include "acpi.h"
47 1.1.1.2.2.2 bouyer #include "accommon.h"
48 1.1.1.2.2.2 bouyer #include "actables.h"
49 1.1.1.2.2.2 bouyer
50 1.1.1.2.2.2 bouyer #define _COMPONENT ACPI_TABLES
51 1.1.1.2.2.2 bouyer ACPI_MODULE_NAME ("tbfind")
52 1.1.1.2.2.2 bouyer
53 1.1.1.2.2.2 bouyer
54 1.1.1.2.2.2 bouyer /*******************************************************************************
55 1.1.1.2.2.2 bouyer *
56 1.1.1.2.2.2 bouyer * FUNCTION: AcpiTbFindTable
57 1.1.1.2.2.2 bouyer *
58 1.1.1.2.2.2 bouyer * PARAMETERS: Signature - String with ACPI table signature
59 1.1.1.2.2.2 bouyer * OemId - String with the table OEM ID
60 1.1.1.2.2.2 bouyer * OemTableId - String with the OEM Table ID
61 1.1.1.2.2.2 bouyer * TableIndex - Where the table index is returned
62 1.1.1.2.2.2 bouyer *
63 1.1.1.2.2.2 bouyer * RETURN: Status and table index
64 1.1.1.2.2.2 bouyer *
65 1.1.1.2.2.2 bouyer * DESCRIPTION: Find an ACPI table (in the RSDT/XSDT) that matches the
66 1.1.1.2.2.2 bouyer * Signature, OEM ID and OEM Table ID. Returns an index that can
67 1.1.1.2.2.2 bouyer * be used to get the table header or entire table.
68 1.1.1.2.2.2 bouyer *
69 1.1.1.2.2.2 bouyer ******************************************************************************/
70 1.1.1.2.2.2 bouyer
71 1.1.1.2.2.2 bouyer ACPI_STATUS
72 1.1.1.2.2.2 bouyer AcpiTbFindTable (
73 1.1.1.2.2.2 bouyer char *Signature,
74 1.1.1.2.2.2 bouyer char *OemId,
75 1.1.1.2.2.2 bouyer char *OemTableId,
76 1.1.1.2.2.2 bouyer UINT32 *TableIndex)
77 1.1.1.2.2.2 bouyer {
78 1.1.1.2.2.2 bouyer UINT32 i;
79 1.1.1.2.2.2 bouyer ACPI_STATUS Status;
80 1.1.1.2.2.2 bouyer ACPI_TABLE_HEADER Header;
81 1.1.1.2.2.2 bouyer
82 1.1.1.2.2.2 bouyer
83 1.1.1.2.2.2 bouyer ACPI_FUNCTION_TRACE (TbFindTable);
84 1.1.1.2.2.2 bouyer
85 1.1.1.2.2.2 bouyer
86 1.1.1.2.2.2 bouyer /* Normalize the input strings */
87 1.1.1.2.2.2 bouyer
88 1.1.1.2.2.2 bouyer ACPI_MEMSET (&Header, 0, sizeof (ACPI_TABLE_HEADER));
89 1.1.1.2.2.2 bouyer ACPI_STRNCPY (Header.Signature, Signature, ACPI_NAME_SIZE);
90 1.1.1.2.2.2 bouyer ACPI_STRNCPY (Header.OemId, OemId, ACPI_OEM_ID_SIZE);
91 1.1.1.2.2.2 bouyer ACPI_STRNCPY (Header.OemTableId, OemTableId, ACPI_OEM_TABLE_ID_SIZE);
92 1.1.1.2.2.2 bouyer
93 1.1.1.2.2.2 bouyer /* Search for the table */
94 1.1.1.2.2.2 bouyer
95 1.1.1.2.2.2 bouyer for (i = 0; i < AcpiGbl_RootTableList.CurrentTableCount; ++i)
96 1.1.1.2.2.2 bouyer {
97 1.1.1.2.2.2 bouyer if (ACPI_MEMCMP (&(AcpiGbl_RootTableList.Tables[i].Signature),
98 1.1.1.2.2.2 bouyer Header.Signature, ACPI_NAME_SIZE))
99 1.1.1.2.2.2 bouyer {
100 1.1.1.2.2.2 bouyer /* Not the requested table */
101 1.1.1.2.2.2 bouyer
102 1.1.1.2.2.2 bouyer continue;
103 1.1.1.2.2.2 bouyer }
104 1.1.1.2.2.2 bouyer
105 1.1.1.2.2.2 bouyer /* Table with matching signature has been found */
106 1.1.1.2.2.2 bouyer
107 1.1.1.2.2.2 bouyer if (!AcpiGbl_RootTableList.Tables[i].Pointer)
108 1.1.1.2.2.2 bouyer {
109 1.1.1.2.2.2 bouyer /* Table is not currently mapped, map it */
110 1.1.1.2.2.2 bouyer
111 1.1.1.2.2.2 bouyer Status = AcpiTbVerifyTable (&AcpiGbl_RootTableList.Tables[i]);
112 1.1.1.2.2.2 bouyer if (ACPI_FAILURE (Status))
113 1.1.1.2.2.2 bouyer {
114 1.1.1.2.2.2 bouyer return_ACPI_STATUS (Status);
115 1.1.1.2.2.2 bouyer }
116 1.1.1.2.2.2 bouyer
117 1.1.1.2.2.2 bouyer if (!AcpiGbl_RootTableList.Tables[i].Pointer)
118 1.1.1.2.2.2 bouyer {
119 1.1.1.2.2.2 bouyer continue;
120 1.1.1.2.2.2 bouyer }
121 1.1.1.2.2.2 bouyer }
122 1.1.1.2.2.2 bouyer
123 1.1.1.2.2.2 bouyer /* Check for table match on all IDs */
124 1.1.1.2.2.2 bouyer
125 1.1.1.2.2.2 bouyer if (!ACPI_MEMCMP (AcpiGbl_RootTableList.Tables[i].Pointer->Signature,
126 1.1.1.2.2.2 bouyer Header.Signature, ACPI_NAME_SIZE) &&
127 1.1.1.2.2.2 bouyer (!OemId[0] ||
128 1.1.1.2.2.2 bouyer !ACPI_MEMCMP (AcpiGbl_RootTableList.Tables[i].Pointer->OemId,
129 1.1.1.2.2.2 bouyer Header.OemId, ACPI_OEM_ID_SIZE)) &&
130 1.1.1.2.2.2 bouyer (!OemTableId[0] ||
131 1.1.1.2.2.2 bouyer !ACPI_MEMCMP (AcpiGbl_RootTableList.Tables[i].Pointer->OemTableId,
132 1.1.1.2.2.2 bouyer Header.OemTableId, ACPI_OEM_TABLE_ID_SIZE)))
133 1.1.1.2.2.2 bouyer {
134 1.1.1.2.2.2 bouyer *TableIndex = i;
135 1.1.1.2.2.2 bouyer
136 1.1.1.2.2.2 bouyer ACPI_DEBUG_PRINT ((ACPI_DB_TABLES, "Found table [%4.4s]\n",
137 1.1.1.2.2.2 bouyer Header.Signature));
138 1.1.1.2.2.2 bouyer return_ACPI_STATUS (AE_OK);
139 1.1.1.2.2.2 bouyer }
140 1.1.1.2.2.2 bouyer }
141 1.1.1.2.2.2 bouyer
142 1.1.1.2.2.2 bouyer return_ACPI_STATUS (AE_NOT_FOUND);
143 1.1.1.2.2.2 bouyer }
144