0001
0002
0003
0004
0005
0006
0007
0008
0009
0010 #include <acpi/acpi.h>
0011 #include "accommon.h"
0012 #include "actables.h"
0013
0014 #define _COMPONENT ACPI_TABLES
0015 ACPI_MODULE_NAME("tbfind")
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033 acpi_status
0034 acpi_tb_find_table(char *signature,
0035 char *oem_id, char *oem_table_id, u32 *table_index)
0036 {
0037 acpi_status status = AE_OK;
0038 struct acpi_table_header header;
0039 u32 i;
0040
0041 ACPI_FUNCTION_TRACE(tb_find_table);
0042
0043
0044
0045 if (!acpi_ut_valid_nameseg(signature)) {
0046 return_ACPI_STATUS(AE_BAD_SIGNATURE);
0047 }
0048
0049
0050
0051 if ((strlen(oem_id) > ACPI_OEM_ID_SIZE) ||
0052 (strlen(oem_table_id) > ACPI_OEM_TABLE_ID_SIZE)) {
0053 return_ACPI_STATUS(AE_AML_STRING_LIMIT);
0054 }
0055
0056
0057
0058 memset(&header, 0, sizeof(struct acpi_table_header));
0059 ACPI_COPY_NAMESEG(header.signature, signature);
0060 strncpy(header.oem_id, oem_id, ACPI_OEM_ID_SIZE);
0061 strncpy(header.oem_table_id, oem_table_id, ACPI_OEM_TABLE_ID_SIZE);
0062
0063
0064
0065 (void)acpi_ut_acquire_mutex(ACPI_MTX_TABLES);
0066 for (i = 0; i < acpi_gbl_root_table_list.current_table_count; ++i) {
0067 if (memcmp(&(acpi_gbl_root_table_list.tables[i].signature),
0068 header.signature, ACPI_NAMESEG_SIZE)) {
0069
0070
0071
0072 continue;
0073 }
0074
0075
0076
0077 if (!acpi_gbl_root_table_list.tables[i].pointer) {
0078
0079
0080
0081 status =
0082 acpi_tb_validate_table(&acpi_gbl_root_table_list.
0083 tables[i]);
0084 if (ACPI_FAILURE(status)) {
0085 goto unlock_and_exit;
0086 }
0087
0088 if (!acpi_gbl_root_table_list.tables[i].pointer) {
0089 continue;
0090 }
0091 }
0092
0093
0094
0095 if (!memcmp
0096 (acpi_gbl_root_table_list.tables[i].pointer->signature,
0097 header.signature, ACPI_NAMESEG_SIZE) && (!oem_id[0]
0098 ||
0099 !memcmp
0100 (acpi_gbl_root_table_list.
0101 tables[i].
0102 pointer->oem_id,
0103 header.oem_id,
0104 ACPI_OEM_ID_SIZE))
0105 && (!oem_table_id[0]
0106 || !memcmp(acpi_gbl_root_table_list.tables[i].pointer->
0107 oem_table_id, header.oem_table_id,
0108 ACPI_OEM_TABLE_ID_SIZE))) {
0109 *table_index = i;
0110
0111 ACPI_DEBUG_PRINT((ACPI_DB_TABLES,
0112 "Found table [%4.4s]\n",
0113 header.signature));
0114 goto unlock_and_exit;
0115 }
0116 }
0117 status = AE_NOT_FOUND;
0118
0119 unlock_and_exit:
0120 (void)acpi_ut_release_mutex(ACPI_MTX_TABLES);
0121 return_ACPI_STATUS(status);
0122 }