/******************************************************************************* * * FUNCTION: acpi_get_table_with_size * * PARAMETERS: signature - ACPI signature of needed table * instance - Which instance (for SSDTs) * out_table - Where the pointer to the table is returned * * RETURN: Status and pointer to the requested table * * DESCRIPTION: Finds and verifies an ACPI table. Table must be in the * RSDT/XSDT. * ******************************************************************************/ acpi_status acpi_get_table_with_size(char *signature, u32 instance, struct acpi_table_header **out_table, acpi_size *tbl_size) { u32 i; u32 j; acpi_status status; /* Parameter validation */ if (!signature || !out_table) { return (AE_BAD_PARAMETER); } /* Walk the root table list */ for (i = 0, j = 0; i < acpi_gbl_root_table_list.current_table_count; i++) { if (!ACPI_COMPARE_NAME (&(acpi_gbl_root_table_list.tables[i].signature), signature)) { continue; } if (++j < instance) { continue; } status = acpi_tb_verify_table(&acpi_gbl_root_table_list.tables[i]); if (ACPI_SUCCESS(status)) { *out_table = acpi_gbl_root_table_list.tables[i].pointer; *tbl_size = acpi_gbl_root_table_list.tables[i].length; } if (!acpi_gbl_permanent_mmap) { acpi_gbl_root_table_list.tables[i].pointer = NULL; } return (status); } return (AE_NOT_FOUND); }
/******************************************************************************* * * FUNCTION: acpi_get_table_by_index * * PARAMETERS: table_index - Table index * Table - Where the pointer to the table is returned * * RETURN: Status and pointer to the table * * DESCRIPTION: Obtain a table by an index into the global table list. * ******************************************************************************/ acpi_status acpi_get_table_by_index(acpi_native_uint table_index, struct acpi_table_header ** table) { acpi_status status; ACPI_FUNCTION_TRACE(acpi_get_table_by_index); /* Parameter validation */ if (!table) { return_ACPI_STATUS(AE_BAD_PARAMETER); } (void)acpi_ut_acquire_mutex(ACPI_MTX_TABLES); /* Validate index */ if (table_index >= acpi_gbl_root_table_list.count) { (void)acpi_ut_release_mutex(ACPI_MTX_TABLES); return_ACPI_STATUS(AE_BAD_PARAMETER); } if (!acpi_gbl_root_table_list.tables[table_index].pointer) { /* Table is not mapped, map it */ status = acpi_tb_verify_table(&acpi_gbl_root_table_list. tables[table_index]); if (ACPI_FAILURE(status)) { (void)acpi_ut_release_mutex(ACPI_MTX_TABLES); return_ACPI_STATUS(status); } } *table = acpi_gbl_root_table_list.tables[table_index].pointer; (void)acpi_ut_release_mutex(ACPI_MTX_TABLES); return_ACPI_STATUS(AE_OK); }
acpi_status acpi_tb_add_table(struct acpi_table_desc *table_desc, u32 *table_index) { u32 i; acpi_status status = AE_OK; struct acpi_table_header *override_table = NULL; ACPI_FUNCTION_TRACE(tb_add_table); if (!table_desc->pointer) { status = acpi_tb_verify_table(table_desc); if (ACPI_FAILURE(status) || !table_desc->pointer) { return_ACPI_STATUS(status); } } /* * Originally, we checked the table signature for "SSDT" or "PSDT" here. * Next, we added support for OEMx tables, signature "OEM". * Valid tables were encountered with a null signature, so we've just * given up on validating the signature, since it seems to be a waste * of code. The original code was removed (05/2008). */ (void)acpi_ut_acquire_mutex(ACPI_MTX_TABLES); /* Check if table is already registered */ for (i = 0; i < acpi_gbl_root_table_list.current_table_count; ++i) { if (!acpi_gbl_root_table_list.tables[i].pointer) { status = acpi_tb_verify_table(&acpi_gbl_root_table_list. tables[i]); if (ACPI_FAILURE(status) || !acpi_gbl_root_table_list.tables[i].pointer) { continue; } } /* * Check for a table match on the entire table length, * not just the header. */ if (table_desc->length != acpi_gbl_root_table_list.tables[i].length) { continue; } if (ACPI_MEMCMP(table_desc->pointer, acpi_gbl_root_table_list.tables[i].pointer, acpi_gbl_root_table_list.tables[i].length)) { continue; } /* * Note: the current mechanism does not unregister a table if it is * dynamically unloaded. The related namespace entries are deleted, * but the table remains in the root table list. * * The assumption here is that the number of different tables that * will be loaded is actually small, and there is minimal overhead * in just keeping the table in case it is needed again. * * If this assumption changes in the future (perhaps on large * machines with many table load/unload operations), tables will * need to be unregistered when they are unloaded, and slots in the * root table list should be reused when empty. */ /* * Table is already registered. * We can delete the table that was passed as a parameter. */ acpi_tb_delete_table(table_desc); *table_index = i; if (acpi_gbl_root_table_list.tables[i]. flags & ACPI_TABLE_IS_LOADED) { /* Table is still loaded, this is an error */ status = AE_ALREADY_EXISTS; goto release; } else { /* Table was unloaded, allow it to be reloaded */ table_desc->pointer = acpi_gbl_root_table_list.tables[i].pointer; table_desc->address = acpi_gbl_root_table_list.tables[i].address; status = AE_OK; goto print_header; } } /* * ACPI Table Override: * Allow the host to override dynamically loaded tables. */ status = acpi_os_table_override(table_desc->pointer, &override_table); if (ACPI_SUCCESS(status) && override_table) { ACPI_INFO((AE_INFO, "%4.4s @ 0x%p Table override, replaced with:", table_desc->pointer->signature, ACPI_CAST_PTR(void, table_desc->address))); /* We can delete the table that was passed as a parameter */ acpi_tb_delete_table(table_desc); /* Setup descriptor for the new table */ table_desc->address = ACPI_PTR_TO_PHYSADDR(override_table); table_desc->pointer = override_table; table_desc->length = override_table->length; table_desc->flags = ACPI_TABLE_ORIGIN_OVERRIDE; }
acpi_status acpi_tb_find_table(char *signature, char *oem_id, char *oem_table_id, u32 *table_index) { u32 i; acpi_status status; struct acpi_table_header header; ACPI_FUNCTION_TRACE(tb_find_table); /* */ ACPI_MEMSET(&header, 0, sizeof(struct acpi_table_header)); ACPI_STRNCPY(header.signature, signature, ACPI_NAME_SIZE); ACPI_STRNCPY(header.oem_id, oem_id, ACPI_OEM_ID_SIZE); ACPI_STRNCPY(header.oem_table_id, oem_table_id, ACPI_OEM_TABLE_ID_SIZE); /* */ for (i = 0; i < acpi_gbl_root_table_list.current_table_count; ++i) { if (ACPI_MEMCMP(&(acpi_gbl_root_table_list.tables[i].signature), header.signature, ACPI_NAME_SIZE)) { /* */ continue; } /* */ if (!acpi_gbl_root_table_list.tables[i].pointer) { /* */ status = acpi_tb_verify_table(&acpi_gbl_root_table_list. tables[i]); if (ACPI_FAILURE(status)) { return_ACPI_STATUS(status); } if (!acpi_gbl_root_table_list.tables[i].pointer) { continue; } } /* */ if (!ACPI_MEMCMP (acpi_gbl_root_table_list.tables[i].pointer->signature, header.signature, ACPI_NAME_SIZE) && (!oem_id[0] || !ACPI_MEMCMP (acpi_gbl_root_table_list. tables[i].pointer-> oem_id, header.oem_id, ACPI_OEM_ID_SIZE)) && (!oem_table_id[0] || !ACPI_MEMCMP(acpi_gbl_root_table_list.tables[i]. pointer->oem_table_id, header.oem_table_id, ACPI_OEM_TABLE_ID_SIZE))) { *table_index = i; ACPI_DEBUG_PRINT((ACPI_DB_TABLES, "Found table [%4.4s]\n", header.signature)); return_ACPI_STATUS(AE_OK); } } return_ACPI_STATUS(AE_NOT_FOUND); }
/******************************************************************************* * * FUNCTION: acpi_tb_load_namespace * * PARAMETERS: None * * RETURN: Status * * DESCRIPTION: Load the namespace from the DSDT and all SSDTs/PSDTs found in * the RSDT/XSDT. * ******************************************************************************/ static acpi_status acpi_tb_load_namespace(void) { acpi_status status; u32 i; struct acpi_table_header *new_dsdt; ACPI_FUNCTION_TRACE(tb_load_namespace); (void)acpi_ut_acquire_mutex(ACPI_MTX_TABLES); /* * Load the namespace. The DSDT is required, but any SSDT and * PSDT tables are optional. Verify the DSDT. */ if (!acpi_gbl_root_table_list.current_table_count || !ACPI_COMPARE_NAME(& (acpi_gbl_root_table_list. tables[ACPI_TABLE_INDEX_DSDT].signature), ACPI_SIG_DSDT) || ACPI_FAILURE(acpi_tb_verify_table (&acpi_gbl_root_table_list. tables[ACPI_TABLE_INDEX_DSDT]))) { status = AE_NO_ACPI_TABLES; goto unlock_and_exit; } /* * Save the DSDT pointer for simple access. This is the mapped memory * address. We must take care here because the address of the .Tables * array can change dynamically as tables are loaded at run-time. Note: * .Pointer field is not validated until after call to acpi_tb_verify_table. */ acpi_gbl_DSDT = acpi_gbl_root_table_list.tables[ACPI_TABLE_INDEX_DSDT].pointer; /* * Optionally copy the entire DSDT to local memory (instead of simply * mapping it.) There are some BIOSs that corrupt or replace the original * DSDT, creating the need for this option. Default is FALSE, do not copy * the DSDT. */ if (acpi_gbl_copy_dsdt_locally) { new_dsdt = acpi_tb_copy_dsdt(ACPI_TABLE_INDEX_DSDT); if (new_dsdt) { acpi_gbl_DSDT = new_dsdt; } } /* * Save the original DSDT header for detection of table corruption * and/or replacement of the DSDT from outside the OS. */ ACPI_MEMCPY(&acpi_gbl_original_dsdt_header, acpi_gbl_DSDT, sizeof(struct acpi_table_header)); (void)acpi_ut_release_mutex(ACPI_MTX_TABLES); /* Load and parse tables */ status = acpi_ns_load_table(ACPI_TABLE_INDEX_DSDT, acpi_gbl_root_node); if (ACPI_FAILURE(status)) { return_ACPI_STATUS(status); } /* Load any SSDT or PSDT tables. Note: Loop leaves tables locked */ (void)acpi_ut_acquire_mutex(ACPI_MTX_TABLES); for (i = 0; i < acpi_gbl_root_table_list.current_table_count; ++i) { if ((!ACPI_COMPARE_NAME (&(acpi_gbl_root_table_list.tables[i].signature), ACPI_SIG_SSDT) && !ACPI_COMPARE_NAME(& (acpi_gbl_root_table_list.tables[i]. signature), ACPI_SIG_PSDT)) || ACPI_FAILURE(acpi_tb_verify_table (&acpi_gbl_root_table_list.tables[i]))) { continue; } if (no_auto_ssdt) { printk(KERN_WARNING "ACPI: SSDT ignored due to \"acpi_no_auto_ssdt\"\n"); continue; } /* Ignore errors while loading tables, get as many as possible */ (void)acpi_ut_release_mutex(ACPI_MTX_TABLES); (void)acpi_ns_load_table(i, acpi_gbl_root_node); (void)acpi_ut_acquire_mutex(ACPI_MTX_TABLES); } ACPI_DEBUG_PRINT((ACPI_DB_INIT, "ACPI Tables successfully acquired\n")); unlock_and_exit: (void)acpi_ut_release_mutex(ACPI_MTX_TABLES); return_ACPI_STATUS(status); }
acpi_status acpi_tb_add_table(struct acpi_table_desc *table_desc, u32 *table_index) { u32 i; acpi_status status = AE_OK; ACPI_FUNCTION_TRACE(tb_add_table); if (!table_desc->pointer) { status = acpi_tb_verify_table(table_desc); if (ACPI_FAILURE(status) || !table_desc->pointer) { return_ACPI_STATUS(status); } } /* * Validate the incoming table signature. * * 1) Originally, we checked the table signature for "SSDT" or "PSDT". * 2) We added support for OEMx tables, signature "OEM". * 3) Valid tables were encountered with a null signature, so we just * gave up on validating the signature, (05/2008). * 4) We encountered non-AML tables such as the MADT, which caused * interpreter errors and kernel faults. So now, we once again allow * only "SSDT", "OEMx", and now, also a null signature. (05/2011). */ if ((table_desc->pointer->signature[0] != 0x00) && (!ACPI_COMPARE_NAME(table_desc->pointer->signature, ACPI_SIG_SSDT)) && (ACPI_STRNCMP(table_desc->pointer->signature, "OEM", 3))) { ACPI_ERROR((AE_INFO, "Table has invalid signature [%4.4s] (0x%8.8X), must be SSDT or OEMx", acpi_ut_valid_acpi_name(*(u32 *)table_desc-> pointer-> signature) ? table_desc-> pointer->signature : "????", *(u32 *)table_desc->pointer->signature)); return_ACPI_STATUS(AE_BAD_SIGNATURE); } (void)acpi_ut_acquire_mutex(ACPI_MTX_TABLES); /* Check if table is already registered */ for (i = 0; i < acpi_gbl_root_table_list.current_table_count; ++i) { if (!acpi_gbl_root_table_list.tables[i].pointer) { status = acpi_tb_verify_table(&acpi_gbl_root_table_list. tables[i]); if (ACPI_FAILURE(status) || !acpi_gbl_root_table_list.tables[i].pointer) { continue; } } /* * Check for a table match on the entire table length, * not just the header. */ if (table_desc->length != acpi_gbl_root_table_list.tables[i].length) { continue; } if (ACPI_MEMCMP(table_desc->pointer, acpi_gbl_root_table_list.tables[i].pointer, acpi_gbl_root_table_list.tables[i].length)) { continue; } /* * Note: the current mechanism does not unregister a table if it is * dynamically unloaded. The related namespace entries are deleted, * but the table remains in the root table list. * * The assumption here is that the number of different tables that * will be loaded is actually small, and there is minimal overhead * in just keeping the table in case it is needed again. * * If this assumption changes in the future (perhaps on large * machines with many table load/unload operations), tables will * need to be unregistered when they are unloaded, and slots in the * root table list should be reused when empty. */ /* * Table is already registered. * We can delete the table that was passed as a parameter. */ acpi_tb_delete_table(table_desc); *table_index = i; if (acpi_gbl_root_table_list.tables[i]. flags & ACPI_TABLE_IS_LOADED) { /* Table is still loaded, this is an error */ status = AE_ALREADY_EXISTS; goto release; } else { /* Table was unloaded, allow it to be reloaded */ table_desc->pointer = acpi_gbl_root_table_list.tables[i].pointer; table_desc->address = acpi_gbl_root_table_list.tables[i].address; status = AE_OK; goto print_header; } } /* * ACPI Table Override: * Allow the host to override dynamically loaded tables. * NOTE: the table is fully mapped at this point, and the mapping will * be deleted by tb_table_override if the table is actually overridden. */ (void)acpi_tb_table_override(table_desc->pointer, table_desc); /* Add the table to the global root table list */ status = acpi_tb_store_table(table_desc->address, table_desc->pointer, table_desc->length, table_desc->flags, table_index); if (ACPI_FAILURE(status)) { goto release; } print_header: acpi_tb_print_table_header(table_desc->address, table_desc->pointer); release: (void)acpi_ut_release_mutex(ACPI_MTX_TABLES); return_ACPI_STATUS(status); }
/******************************************************************************* * * FUNCTION: acpi_tb_load_namespace * * PARAMETERS: None * * RETURN: Status * * DESCRIPTION: Load the namespace from the DSDT and all SSDTs/PSDTs found in * the RSDT/XSDT. * ******************************************************************************/ static acpi_status acpi_tb_load_namespace(void) { acpi_status status; u32 i; ACPI_FUNCTION_TRACE(tb_load_namespace); (void)acpi_ut_acquire_mutex(ACPI_MTX_TABLES); /* * Load the namespace. The DSDT is required, but any SSDT and PSDT tables * are optional. */ if (!acpi_gbl_root_table_list.count || !ACPI_COMPARE_NAME(& (acpi_gbl_root_table_list. tables[ACPI_TABLE_INDEX_DSDT].signature), ACPI_SIG_DSDT) || ACPI_FAILURE(acpi_tb_verify_table (&acpi_gbl_root_table_list. tables[ACPI_TABLE_INDEX_DSDT]))) { status = AE_NO_ACPI_TABLES; goto unlock_and_exit; } /* A valid DSDT is required */ status = acpi_tb_verify_table(&acpi_gbl_root_table_list. tables[ACPI_TABLE_INDEX_DSDT]); if (ACPI_FAILURE(status)) { status = AE_NO_ACPI_TABLES; goto unlock_and_exit; } (void)acpi_ut_release_mutex(ACPI_MTX_TABLES); /* Load and parse tables */ status = acpi_ns_load_table(ACPI_TABLE_INDEX_DSDT, acpi_gbl_root_node); if (ACPI_FAILURE(status)) { return_ACPI_STATUS(status); } /* Load any SSDT or PSDT tables. Note: Loop leaves tables locked */ (void)acpi_ut_acquire_mutex(ACPI_MTX_TABLES); for (i = 0; i < acpi_gbl_root_table_list.count; ++i) { if ((!ACPI_COMPARE_NAME (&(acpi_gbl_root_table_list.tables[i].signature), ACPI_SIG_SSDT) && !ACPI_COMPARE_NAME(& (acpi_gbl_root_table_list.tables[i]. signature), ACPI_SIG_PSDT)) || ACPI_FAILURE(acpi_tb_verify_table (&acpi_gbl_root_table_list.tables[i]))) { continue; } if (no_auto_ssdt) { printk(KERN_WARNING "ACPI: SSDT ignored due to \"acpi_no_auto_ssdt\"\n"); continue; } /* Ignore errors while loading tables, get as many as possible */ (void)acpi_ut_release_mutex(ACPI_MTX_TABLES); (void)acpi_ns_load_table(i, acpi_gbl_root_node); (void)acpi_ut_acquire_mutex(ACPI_MTX_TABLES); } ACPI_DEBUG_PRINT((ACPI_DB_INIT, "ACPI Tables successfully acquired\n")); unlock_and_exit: (void)acpi_ut_release_mutex(ACPI_MTX_TABLES); return_ACPI_STATUS(status); }
acpi_status acpi_tb_add_table(struct acpi_table_desc *table_desc, u32 *table_index) { u32 i; acpi_status status = AE_OK; struct acpi_table_header *override_table = NULL; ACPI_FUNCTION_TRACE(tb_add_table); if (!table_desc->pointer) { status = acpi_tb_verify_table(table_desc); if (ACPI_FAILURE(status) || !table_desc->pointer) { return_ACPI_STATUS(status); } } (void)acpi_ut_acquire_mutex(ACPI_MTX_TABLES); for (i = 0; i < acpi_gbl_root_table_list.count; ++i) { if (!acpi_gbl_root_table_list.tables[i].pointer) { status = acpi_tb_verify_table(&acpi_gbl_root_table_list. tables[i]); if (ACPI_FAILURE(status) || !acpi_gbl_root_table_list.tables[i].pointer) { continue; } } if (table_desc->length != acpi_gbl_root_table_list.tables[i].length) { continue; } if (ACPI_MEMCMP(table_desc->pointer, acpi_gbl_root_table_list.tables[i].pointer, acpi_gbl_root_table_list.tables[i].length)) { continue; } acpi_tb_delete_table(table_desc); *table_index = i; if (acpi_gbl_root_table_list.tables[i]. flags & ACPI_TABLE_IS_LOADED) { status = AE_ALREADY_EXISTS; goto release; } else { table_desc->pointer = acpi_gbl_root_table_list.tables[i].pointer; table_desc->address = acpi_gbl_root_table_list.tables[i].address; status = AE_OK; goto print_header; } } status = acpi_os_table_override(table_desc->pointer, &override_table); if (ACPI_SUCCESS(status) && override_table) { ACPI_INFO((AE_INFO, "%4.4s @ 0x%p Table override, replaced with:", table_desc->pointer->signature, ACPI_CAST_PTR(void, table_desc->address))); acpi_tb_delete_table(table_desc); table_desc->address = ACPI_PTR_TO_PHYSADDR(override_table); table_desc->pointer = override_table; table_desc->length = override_table->length; table_desc->flags = ACPI_TABLE_ORIGIN_OVERRIDE; }
acpi_status acpi_tb_find_table(char *signature, char *oem_id, char *oem_table_id, u32 *table_index) { u32 i; acpi_status status; struct acpi_table_header header; ACPI_FUNCTION_TRACE(tb_find_table); /* Normalize the input strings */ ACPI_MEMSET(&header, 0, sizeof(struct acpi_table_header)); ACPI_STRNCPY(header.signature, signature, ACPI_NAME_SIZE); ACPI_STRNCPY(header.oem_id, oem_id, ACPI_OEM_ID_SIZE); ACPI_STRNCPY(header.oem_table_id, oem_table_id, ACPI_OEM_TABLE_ID_SIZE); /* Search for the table */ for (i = 0; i < acpi_gbl_root_table_list.current_table_count; ++i) { if (ACPI_MEMCMP(&(acpi_gbl_root_table_list.tables[i].signature), header.signature, ACPI_NAME_SIZE)) { /* Not the requested table */ continue; } /* Table with matching signature has been found */ if (!acpi_gbl_root_table_list.tables[i].pointer) { /* Table is not currently mapped, map it */ status = acpi_tb_verify_table(&acpi_gbl_root_table_list. tables[i]); if (ACPI_FAILURE(status)) { return_ACPI_STATUS(status); } if (!acpi_gbl_root_table_list.tables[i].pointer) { continue; } } /* Check for table match on all IDs */ if (!ACPI_MEMCMP (acpi_gbl_root_table_list.tables[i].pointer->signature, header.signature, ACPI_NAME_SIZE) && (!oem_id[0] || !ACPI_MEMCMP (acpi_gbl_root_table_list. tables[i].pointer-> oem_id, header.oem_id, ACPI_OEM_ID_SIZE)) && (!oem_table_id[0] || !ACPI_MEMCMP(acpi_gbl_root_table_list.tables[i]. pointer->oem_table_id, header.oem_table_id, ACPI_OEM_TABLE_ID_SIZE))) { *table_index = i; ACPI_DEBUG_PRINT((ACPI_DB_TABLES, "Found table [%4.4s]\n", header.signature)); return_ACPI_STATUS(AE_OK); } } return_ACPI_STATUS(AE_NOT_FOUND); }
/******************************************************************************* * * FUNCTION: acpi_tb_load_namespace * * PARAMETERS: None * * RETURN: Status * * DESCRIPTION: Load the namespace from the DSDT and all SSDTs/PSDTs found in * the RSDT/XSDT. * ******************************************************************************/ static acpi_status acpi_tb_load_namespace(void) { acpi_status status; struct acpi_table_header *table; u32 i; ACPI_FUNCTION_TRACE(tb_load_namespace); (void)acpi_ut_acquire_mutex(ACPI_MTX_TABLES); /* * Load the namespace. The DSDT is required, but any SSDT and PSDT tables * are optional. */ if (!acpi_gbl_root_table_list.count || !ACPI_COMPARE_NAME(& (acpi_gbl_root_table_list. tables[ACPI_TABLE_INDEX_DSDT].signature), ACPI_SIG_DSDT) || ACPI_FAILURE(acpi_tb_verify_table (&acpi_gbl_root_table_list. tables[ACPI_TABLE_INDEX_DSDT]))) { status = AE_NO_ACPI_TABLES; goto unlock_and_exit; } /* * Find DSDT table */ status = acpi_os_table_override(acpi_gbl_root_table_list. tables[ACPI_TABLE_INDEX_DSDT].pointer, &table); if (ACPI_SUCCESS(status) && table) { /* * DSDT table has been found */ acpi_tb_delete_table(&acpi_gbl_root_table_list. tables[ACPI_TABLE_INDEX_DSDT]); acpi_gbl_root_table_list.tables[ACPI_TABLE_INDEX_DSDT].pointer = table; acpi_gbl_root_table_list.tables[ACPI_TABLE_INDEX_DSDT].length = table->length; acpi_gbl_root_table_list.tables[ACPI_TABLE_INDEX_DSDT].flags = ACPI_TABLE_ORIGIN_UNKNOWN; ACPI_INFO((AE_INFO, "Table DSDT replaced by host OS")); acpi_tb_print_table_header(0, table); if (no_auto_ssdt == 0) { printk(KERN_WARNING "ACPI: DSDT override uses original SSDTs unless \"acpi_no_auto_ssdt\"\n"); } } status = acpi_tb_verify_table(&acpi_gbl_root_table_list. tables[ACPI_TABLE_INDEX_DSDT]); if (ACPI_FAILURE(status)) { /* A valid DSDT is required */ status = AE_NO_ACPI_TABLES; goto unlock_and_exit; } (void)acpi_ut_release_mutex(ACPI_MTX_TABLES); /* * Load and parse tables. */ status = acpi_ns_load_table(ACPI_TABLE_INDEX_DSDT, acpi_gbl_root_node); if (ACPI_FAILURE(status)) { return_ACPI_STATUS(status); } /* * Load any SSDT or PSDT tables. Note: Loop leaves tables locked */ (void)acpi_ut_acquire_mutex(ACPI_MTX_TABLES); for (i = 0; i < acpi_gbl_root_table_list.count; ++i) { if ((!ACPI_COMPARE_NAME (&(acpi_gbl_root_table_list.tables[i].signature), ACPI_SIG_SSDT) && !ACPI_COMPARE_NAME(& (acpi_gbl_root_table_list.tables[i]. signature), ACPI_SIG_PSDT)) || ACPI_FAILURE(acpi_tb_verify_table (&acpi_gbl_root_table_list.tables[i]))) { continue; } if (no_auto_ssdt) { printk(KERN_WARNING "ACPI: SSDT ignored due to \"acpi_no_auto_ssdt\"\n"); continue; } /* Ignore errors while loading tables, get as many as possible */ (void)acpi_ut_release_mutex(ACPI_MTX_TABLES); (void)acpi_ns_load_table(i, acpi_gbl_root_node); (void)acpi_ut_acquire_mutex(ACPI_MTX_TABLES); } ACPI_DEBUG_PRINT((ACPI_DB_INIT, "ACPI Tables successfully acquired\n")); unlock_and_exit: (void)acpi_ut_release_mutex(ACPI_MTX_TABLES); return_ACPI_STATUS(status); }
acpi_status acpi_tb_add_table(struct acpi_table_desc *table_desc, u32 *table_index) { u32 i; acpi_status status = AE_OK; ACPI_FUNCTION_TRACE(tb_add_table); if (!table_desc->pointer) { status = acpi_tb_verify_table(table_desc); if (ACPI_FAILURE(status) || !table_desc->pointer) { return_ACPI_STATUS(status); } } if ((table_desc->pointer->signature[0] != 0x00) && (!ACPI_COMPARE_NAME(table_desc->pointer->signature, ACPI_SIG_SSDT)) && (ACPI_STRNCMP(table_desc->pointer->signature, "OEM", 3))) { ACPI_ERROR((AE_INFO, "Table has invalid signature [%4.4s] (0x%8.8X), must be SSDT or OEMx", acpi_ut_valid_acpi_name(*(u32 *)table_desc-> pointer-> signature) ? table_desc-> pointer->signature : "????", *(u32 *)table_desc->pointer->signature)); return_ACPI_STATUS(AE_BAD_SIGNATURE); } (void)acpi_ut_acquire_mutex(ACPI_MTX_TABLES); for (i = 0; i < acpi_gbl_root_table_list.current_table_count; ++i) { if (!acpi_gbl_root_table_list.tables[i].pointer) { status = acpi_tb_verify_table(&acpi_gbl_root_table_list. tables[i]); if (ACPI_FAILURE(status) || !acpi_gbl_root_table_list.tables[i].pointer) { continue; } } if (table_desc->length != acpi_gbl_root_table_list.tables[i].length) { continue; } if (ACPI_MEMCMP(table_desc->pointer, acpi_gbl_root_table_list.tables[i].pointer, acpi_gbl_root_table_list.tables[i].length)) { continue; } acpi_tb_delete_table(table_desc); *table_index = i; if (acpi_gbl_root_table_list.tables[i]. flags & ACPI_TABLE_IS_LOADED) { status = AE_ALREADY_EXISTS; goto release; } else { table_desc->pointer = acpi_gbl_root_table_list.tables[i].pointer; table_desc->address = acpi_gbl_root_table_list.tables[i].address; status = AE_OK; goto print_header; } } (void)acpi_tb_table_override(table_desc->pointer, table_desc); status = acpi_tb_store_table(table_desc->address, table_desc->pointer, table_desc->length, table_desc->flags, table_index); if (ACPI_FAILURE(status)) { goto release; } print_header: acpi_tb_print_table_header(table_desc->address, table_desc->pointer); release: (void)acpi_ut_release_mutex(ACPI_MTX_TABLES); return_ACPI_STATUS(status); }