1
2
3
4
5
6
7
8
9
10#include <acpi/acpi.h>
11#include "accommon.h"
12#include "actables.h"
13
14#define _COMPONENT ACPI_TABLES
15ACPI_MODULE_NAME("tbfind")
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33acpi_status
34acpi_tb_find_table(char *signature,
35 char *oem_id, char *oem_table_id, u32 *table_index)
36{
37 acpi_status status = AE_OK;
38 struct acpi_table_header header;
39 u32 i;
40
41 ACPI_FUNCTION_TRACE(tb_find_table);
42
43
44
45 if (!acpi_ut_valid_nameseg(signature)) {
46 return_ACPI_STATUS(AE_BAD_SIGNATURE);
47 }
48
49
50
51 if ((strlen(oem_id) > ACPI_OEM_ID_SIZE) ||
52 (strlen(oem_table_id) > ACPI_OEM_TABLE_ID_SIZE)) {
53 return_ACPI_STATUS(AE_AML_STRING_LIMIT);
54 }
55
56
57
58 memset(&header, 0, sizeof(struct acpi_table_header));
59 ACPI_COPY_NAMESEG(header.signature, signature);
60 strncpy(header.oem_id, oem_id, ACPI_OEM_ID_SIZE);
61 strncpy(header.oem_table_id, oem_table_id, ACPI_OEM_TABLE_ID_SIZE);
62
63
64
65 (void)acpi_ut_acquire_mutex(ACPI_MTX_TABLES);
66 for (i = 0; i < acpi_gbl_root_table_list.current_table_count; ++i) {
67 if (memcmp(&(acpi_gbl_root_table_list.tables[i].signature),
68 header.signature, ACPI_NAMESEG_SIZE)) {
69
70
71
72 continue;
73 }
74
75
76
77 if (!acpi_gbl_root_table_list.tables[i].pointer) {
78
79
80
81 status =
82 acpi_tb_validate_table(&acpi_gbl_root_table_list.
83 tables[i]);
84 if (ACPI_FAILURE(status)) {
85 goto unlock_and_exit;
86 }
87
88 if (!acpi_gbl_root_table_list.tables[i].pointer) {
89 continue;
90 }
91 }
92
93
94
95 if (!memcmp
96 (acpi_gbl_root_table_list.tables[i].pointer->signature,
97 header.signature, ACPI_NAMESEG_SIZE) && (!oem_id[0]
98 ||
99 !memcmp
100 (acpi_gbl_root_table_list.
101 tables[i].
102 pointer->oem_id,
103 header.oem_id,
104 ACPI_OEM_ID_SIZE))
105 && (!oem_table_id[0]
106 || !memcmp(acpi_gbl_root_table_list.tables[i].pointer->
107 oem_table_id, header.oem_table_id,
108 ACPI_OEM_TABLE_ID_SIZE))) {
109 *table_index = i;
110
111 ACPI_DEBUG_PRINT((ACPI_DB_TABLES,
112 "Found table [%4.4s]\n",
113 header.signature));
114 goto unlock_and_exit;
115 }
116 }
117 status = AE_NOT_FOUND;
118
119unlock_and_exit:
120 (void)acpi_ut_release_mutex(ACPI_MTX_TABLES);
121 return_ACPI_STATUS(status);
122}
123