/******************************************************************************* * * FUNCTION: acpi_tb_compare_tables * * PARAMETERS: table_desc - Table 1 descriptor to be compared * table_index - Index of table 2 to be compared * * RETURN: TRUE if both tables are identical. * * DESCRIPTION: This function compares a table with another table that has * already been installed in the root table list. *
******************************************************************************/
status =
acpi_tb_acquire_table(&acpi_gbl_root_table_list.tables[table_index],
&table, &table_length, &table_flags); if (ACPI_FAILURE(status)) { return (FALSE);
}
/* * Check for a table match on the entire table length, * not just the header.
*/
is_identical = (u8)((table_desc->length != table_length ||
memcmp(table_desc->pointer, table, table_length)) ? FALSE : TRUE);
/* * Initialize the table descriptor. Set the pointer to NULL for external * tables, since the table is not fully mapped at this time.
*/
memset(table_desc, 0, sizeof(struct acpi_table_desc));
table_desc->address = address;
table_desc->length = table->length;
table_desc->flags = flags;
ACPI_MOVE_32_TO_32(table_desc->signature.ascii, table->signature);
switch (table_desc->flags & ACPI_TABLE_ORIGIN_MASK) { case ACPI_TABLE_ORIGIN_INTERNAL_VIRTUAL: case ACPI_TABLE_ORIGIN_EXTERNAL_VIRTUAL:
table_desc->pointer = table; break;
case ACPI_TABLE_ORIGIN_INTERNAL_PHYSICAL: default:
break;
}
}
/******************************************************************************* * * FUNCTION: acpi_tb_acquire_table * * PARAMETERS: table_desc - Table descriptor * table_ptr - Where table is returned * table_length - Where table length is returned * table_flags - Where table allocation flags are returned * * RETURN: Status * * DESCRIPTION: Acquire an ACPI table. It can be used for tables not * maintained in the acpi_gbl_root_table_list. *
******************************************************************************/
/******************************************************************************* * * FUNCTION: acpi_tb_release_table * * PARAMETERS: table - Pointer for the table * table_length - Length for the table * table_flags - Allocation flags for the table * * RETURN: None * * DESCRIPTION: Release a table. The inverse of acpi_tb_acquire_table(). *
******************************************************************************/
switch (table_flags & ACPI_TABLE_ORIGIN_MASK) { case ACPI_TABLE_ORIGIN_INTERNAL_PHYSICAL:
acpi_os_unmap_memory(table, table_length); break;
case ACPI_TABLE_ORIGIN_INTERNAL_VIRTUAL: case ACPI_TABLE_ORIGIN_EXTERNAL_VIRTUAL: default:
break;
}
}
/******************************************************************************* * * FUNCTION: acpi_tb_acquire_temp_table * * PARAMETERS: table_desc - Table descriptor to be acquired * address - Address of the table * flags - Allocation flags of the table * table - Pointer to the table (required for virtual * origins, optional for physical) * * RETURN: Status * * DESCRIPTION: This function validates the table header to obtain the length * of a table and fills the table descriptor to make its state as * "INSTALLED". Such a table descriptor is only used for verified * installation. *
******************************************************************************/
/******************************************************************************* * * FUNCTION: acpi_tb_release_temp_table * * PARAMETERS: table_desc - Table descriptor to be released * * RETURN: Status * * DESCRIPTION: The inverse of acpi_tb_acquire_temp_table(). *
*****************************************************************************/
/* * Note that the .Address is maintained by the callers of * acpi_tb_acquire_temp_table(), thus do not invoke acpi_tb_uninstall_table() * where .Address will be freed.
*/
acpi_tb_invalidate_table(table_desc);
}
/****************************************************************************** * * FUNCTION: acpi_tb_validate_table * * PARAMETERS: table_desc - Table descriptor * * RETURN: Status * * DESCRIPTION: This function is called to validate the table, the returned * table descriptor is in "VALIDATED" state. *
*****************************************************************************/
acpi_status acpi_tb_validate_table(struct acpi_table_desc *table_desc)
{
acpi_status status = AE_OK;
ACPI_FUNCTION_TRACE(tb_validate_table);
/* Validate the table if necessary */
if (!table_desc->pointer) {
status = acpi_tb_acquire_table(table_desc, &table_desc->pointer,
&table_desc->length,
&table_desc->flags); if (!table_desc->pointer) {
status = AE_NO_MEMORY;
}
}
return_ACPI_STATUS(status);
}
/******************************************************************************* * * FUNCTION: acpi_tb_invalidate_table * * PARAMETERS: table_desc - Table descriptor * * RETURN: None * * DESCRIPTION: Invalidate one internal ACPI table, this is the inverse of * acpi_tb_validate_table(). *
******************************************************************************/
switch (table_desc->flags & ACPI_TABLE_ORIGIN_MASK) { case ACPI_TABLE_ORIGIN_INTERNAL_PHYSICAL:
table_desc->pointer = NULL; break;
case ACPI_TABLE_ORIGIN_INTERNAL_VIRTUAL: case ACPI_TABLE_ORIGIN_EXTERNAL_VIRTUAL: default:
break;
}
return_VOID;
}
/****************************************************************************** * * FUNCTION: acpi_tb_validate_temp_table * * PARAMETERS: table_desc - Table descriptor * * RETURN: Status * * DESCRIPTION: This function is called to validate the table, the returned * table descriptor is in "VALIDATED" state. *
*****************************************************************************/
if (!table_desc->pointer && !acpi_gbl_enable_table_validation) { /* * Only validates the header of the table. * Note that Length contains the size of the mapping after invoking * this work around, this value is required by * acpi_tb_release_temp_table(). * We can do this because in acpi_init_table_descriptor(), the Length * field of the installed descriptor is filled with the actual * table length obtaining from the table header.
*/
table_desc->length = sizeof(struct acpi_table_header);
}
return (acpi_tb_validate_table(table_desc));
}
/******************************************************************************* * * FUNCTION: acpi_tb_check_duplication * * PARAMETERS: table_desc - Table descriptor * table_index - Where the table index is returned * * RETURN: Status * * DESCRIPTION: Avoid installing duplicated tables. However table override and * user aided dynamic table load is allowed, thus comparing the * address of the table is not sufficient, and checking the entire * table content is required. *
******************************************************************************/
for (i = 0; i < acpi_gbl_root_table_list.current_table_count; ++i) {
/* Do not compare with unverified tables */
if (!
(acpi_gbl_root_table_list.tables[i].
flags & ACPI_TABLE_IS_VERIFIED)) { continue;
}
/* * Check for a table match on the entire table length, * not just the header.
*/ if (!acpi_tb_compare_tables(table_desc, i)) { 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.
*/ if (acpi_gbl_root_table_list.tables[i].flags &
ACPI_TABLE_IS_LOADED) {
/****************************************************************************** * * FUNCTION: acpi_tb_verify_temp_table * * PARAMETERS: table_desc - Table descriptor * signature - Table signature to verify * table_index - Where the table index is returned * * RETURN: Status * * DESCRIPTION: This function is called to validate and verify the table, the * returned table descriptor is in "VALIDATED" state. * Note that 'TableIndex' is required to be set to !NULL to * enable duplication check. *
*****************************************************************************/
/* allow_resize flag is a parameter to acpi_initialize_tables */
if (!(acpi_gbl_root_table_list.flags & ACPI_ROOT_ALLOW_RESIZE)) {
ACPI_ERROR((AE_INFO, "Resize of Root Table Array is not allowed"));
return_ACPI_STATUS(AE_SUPPORT);
}
max_table_count = table_count + ACPI_ROOT_TABLE_SIZE_INCREMENT;
tables = ACPI_ALLOCATE_ZEROED(((acpi_size)max_table_count) * sizeof(struct acpi_table_desc)); if (!tables) {
ACPI_ERROR((AE_INFO, "Could not allocate new root table array"));
return_ACPI_STATUS(AE_NO_MEMORY);
}
/* Copy and free the previous table array */
current_table_count = 0; if (acpi_gbl_root_table_list.tables) { for (i = 0; i < table_count; i++) { if (acpi_gbl_root_table_list.tables[i].address) {
memcpy(tables + current_table_count,
acpi_gbl_root_table_list.tables + i, sizeof(struct acpi_table_desc));
current_table_count++;
}
}
if (acpi_gbl_root_table_list.flags & ACPI_ROOT_ORIGIN_ALLOCATED) {
ACPI_FREE(acpi_gbl_root_table_list.tables);
}
}
/******************************************************************************* * * FUNCTION: acpi_tb_get_next_table_descriptor * * PARAMETERS: table_index - Where table index is returned * table_desc - Where table descriptor is returned * * RETURN: Status and table index/descriptor. * * DESCRIPTION: Allocate a new ACPI table entry to the global table list *
******************************************************************************/
/* Ensure that there is room for the table in the Root Table List */
if (acpi_gbl_root_table_list.current_table_count >=
acpi_gbl_root_table_list.max_table_count) {
status = acpi_tb_resize_root_table_list(); if (ACPI_FAILURE(status)) { return (status);
}
}
i = acpi_gbl_root_table_list.current_table_count;
acpi_gbl_root_table_list.current_table_count++;
if (table_index) {
*table_index = i;
} if (table_desc) {
*table_desc = &acpi_gbl_root_table_list.tables[i];
}
for (i = 0; i < acpi_gbl_root_table_list.current_table_count; i++) {
acpi_tb_uninstall_table(&acpi_gbl_root_table_list.tables[i]);
}
/* * Delete the root table array if allocated locally. Array cannot be * mapped, so we don't need to check for that flag.
*/ if (acpi_gbl_root_table_list.flags & ACPI_ROOT_ORIGIN_ALLOCATED) {
ACPI_FREE(acpi_gbl_root_table_list.tables);
}
/******************************************************************************* * * FUNCTION: acpi_tb_delete_namespace_by_owner * * PARAMETERS: table_index - Table index * * RETURN: Status * * DESCRIPTION: Delete all namespace objects created when this table was loaded. *
******************************************************************************/
/* * Need to acquire the namespace writer lock to prevent interference * with any concurrent namespace walks. The interpreter must be * released during the deletion since the acquisition of the deletion * lock may block, and also since the execution of a namespace walk * must be allowed to use the interpreter.
*/
status = acpi_ut_acquire_write_lock(&acpi_gbl_namespace_rw_lock); if (ACPI_FAILURE(status)) {
return_ACPI_STATUS(status);
}
/******************************************************************************* * * FUNCTION: acpi_tb_get_owner_id * * PARAMETERS: table_index - Table index * owner_id - Where the table owner_id is returned * * RETURN: Status * * DESCRIPTION: returns owner_id for the ACPI table *
******************************************************************************/
acpi_status acpi_tb_get_owner_id(u32 table_index, acpi_owner_id *owner_id)
{
acpi_status status = AE_BAD_PARAMETER;
ACPI_FUNCTION_TRACE(tb_get_owner_id);
(void)acpi_ut_acquire_mutex(ACPI_MTX_TABLES); if (table_index < acpi_gbl_root_table_list.current_table_count) {
*owner_id =
acpi_gbl_root_table_list.tables[table_index].owner_id;
status = AE_OK;
}
(void)acpi_ut_acquire_mutex(ACPI_MTX_TABLES); if (table_index < acpi_gbl_root_table_list.current_table_count) { if (is_loaded) {
acpi_gbl_root_table_list.tables[table_index].flags |=
ACPI_TABLE_IS_LOADED;
} else {
acpi_gbl_root_table_list.tables[table_index].flags &=
~ACPI_TABLE_IS_LOADED;
}
}
(void)acpi_ut_release_mutex(ACPI_MTX_TABLES);
}
/******************************************************************************* * * FUNCTION: acpi_tb_load_table * * PARAMETERS: table_index - Table index * parent_node - Where table index is returned * * RETURN: Status * * DESCRIPTION: Load an ACPI table *
******************************************************************************/
/* * Note: Now table is "INSTALLED", it must be validated before * using.
*/
status = acpi_get_table_by_index(table_index, &table); if (ACPI_FAILURE(status)) {
return_ACPI_STATUS(status);
}
status = acpi_ns_load_table(table_index, parent_node); if (ACPI_FAILURE(status)) {
return_ACPI_STATUS(status);
}
/* * Update GPEs for any new _Lxx/_Exx methods. Ignore errors. The host is * responsible for discovering any new wake GPEs by running _PRW methods * that may have been loaded by this table.
*/
status = acpi_tb_get_owner_id(table_index, &owner_id); if (ACPI_SUCCESS(status)) {
acpi_ev_update_gpes(owner_id);
}
/******************************************************************************* * * FUNCTION: acpi_tb_install_and_load_table * * PARAMETERS: address - Physical address of the table * flags - Allocation flags of the table * table - Pointer to the table (required for * virtual origins, optional for * physical) * override - Whether override should be performed * table_index - Where table index is returned * * RETURN: Status * * DESCRIPTION: Install and load an ACPI table *
******************************************************************************/
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.