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