/****************************************************************************** * * FUNCTION: osl_get_last_status * * PARAMETERS: default_status - Default error status to return * * RETURN: Status; Converted from errno. * * DESCRIPTION: Get last errno and convert it to acpi_status. *
*****************************************************************************/
/****************************************************************************** * * FUNCTION: acpi_os_get_table_by_address * * PARAMETERS: address - Physical address of the ACPI table * table - Where a pointer to the table is returned * * RETURN: Status; Table buffer is returned if AE_OK. * AE_NOT_FOUND: A valid table was not found at the address * * DESCRIPTION: Get an ACPI table via a physical memory address. *
*****************************************************************************/
/****************************************************************************** * * FUNCTION: acpi_os_get_table_by_name * * PARAMETERS: signature - ACPI Signature for desired table. Must be * a null terminated 4-character string. * instance - Multiple table support for SSDT/UEFI (0...n) * Must be 0 for other tables. * table - Where a pointer to the table is returned * address - Where the table physical address is returned * * RETURN: Status; Table buffer and physical address returned if AE_OK. * AE_LIMIT: Instance is beyond valid limit * AE_NOT_FOUND: A table with the signature was not found * * NOTE: Assumes the input signature is uppercase. *
*****************************************************************************/
/****************************************************************************** * * FUNCTION: acpi_os_get_table_by_index * * PARAMETERS: index - Which table to get * table - Where a pointer to the table is returned * instance - Where a pointer to the table instance no. is * returned * address - Where the table physical address is returned * * RETURN: Status; Table buffer and physical address returned if AE_OK. * AE_LIMIT: Index is beyond valid limit * * DESCRIPTION: Get an ACPI table via an index value (0 through n). Returns * AE_LIMIT when an invalid index is reached. Index is not * necessarily an index into the RSDT/XSDT. *
*****************************************************************************/
/****************************************************************************** * * FUNCTION: osl_can_use_xsdt * * PARAMETERS: None * * RETURN: TRUE if XSDT is allowed to be used. * * DESCRIPTION: This function collects logic that can be used to determine if * XSDT should be used instead of RSDT. *
*****************************************************************************/
/****************************************************************************** * * FUNCTION: osl_table_initialize * * PARAMETERS: None * * RETURN: Status * * DESCRIPTION: Initialize ACPI table data. Get and store main ACPI tables to * local variables. Main ACPI tables include RSDT, FADT, RSDT, * and/or XSDT. *
*****************************************************************************/
/****************************************************************************** * * FUNCTION: osl_list_bios_tables * * PARAMETERS: None * * RETURN: Status; Table list is initialized if AE_OK. * * DESCRIPTION: Add ACPI tables to the table list from memory. * * NOTE: This works on Linux as table customization does not modify the * addresses stored in RSDP/RSDT/XSDT/FADT. *
*****************************************************************************/
/****************************************************************************** * * FUNCTION: osl_get_bios_table * * PARAMETERS: signature - ACPI Signature for common table. Must be * a null terminated 4-character string. * instance - Multiple table support for SSDT/UEFI (0...n) * Must be 0 for other tables. * table - Where a pointer to the table is returned * address - Where the table physical address is returned * * RETURN: Status; Table buffer and physical address returned if AE_OK. * AE_LIMIT: Instance is beyond valid limit * AE_NOT_FOUND: A table with the signature was not found * * DESCRIPTION: Get a BIOS provided ACPI table * * NOTE: Assumes the input signature is uppercase. *
*****************************************************************************/
if (current_instance != instance) {
osl_unmap_table(mapped_table);
mapped_table = NULL;
current_instance++; goto find_next_instance;
}
} else { /* Case for a normal ACPI table */
if (osl_can_use_xsdt()) {
item_size = sizeof(u64);
table_data =
ACPI_CAST8(gbl_xsdt) + sizeof(struct acpi_table_header);
number_of_tables =
(u8)((gbl_xsdt->header.length - sizeof(struct acpi_table_header))
/ item_size);
} else { /* Use RSDT if XSDT is not available */
/****************************************************************************** * * FUNCTION: osl_list_customized_tables * * PARAMETERS: directory - Directory that contains the tables * * RETURN: Status; Table list is initialized if AE_OK. * * DESCRIPTION: Add ACPI tables to the table list from a directory. *
*****************************************************************************/
/****************************************************************************** * * FUNCTION: osl_map_table * * PARAMETERS: address - Address of the table in memory * signature - Optional ACPI Signature for desired table. * Null terminated 4-character string. * table - Where a pointer to the mapped table is * returned * * RETURN: Status; Mapped table is returned if AE_OK. * AE_NOT_FOUND: A valid table was not found at the address * * DESCRIPTION: Map entire ACPI table into caller's address space. *
*****************************************************************************/
/* * Map the header so we can get the table length. * Use sizeof (struct acpi_table_header) as: * 1. it is bigger than 24 to include RSDP->Length * 2. it is smaller than sizeof (struct acpi_table_rsdp)
*/
mapped_table =
acpi_os_map_memory(address, sizeof(struct acpi_table_header)); if (!mapped_table) {
fprintf(stderr, "Could not map table header at 0x%8.8X%8.8X\n",
ACPI_FORMAT_UINT64(address)); return (osl_get_last_status(AE_BAD_ADDRESS));
}
/* If specified, signature must match */
if (signature) { if (ACPI_VALIDATE_RSDP_SIG(signature)) { if (!ACPI_VALIDATE_RSDP_SIG(mapped_table->signature)) {
acpi_os_unmap_memory(mapped_table, sizeof(struct
acpi_table_header)); return (AE_BAD_SIGNATURE);
}
} else if (!ACPI_COMPARE_NAMESEG
(signature, mapped_table->signature)) {
acpi_os_unmap_memory(mapped_table, sizeof(struct acpi_table_header)); return (AE_BAD_SIGNATURE);
}
}
/****************************************************************************** * * FUNCTION: osl_table_name_from_file * * PARAMETERS: filename - File that contains the desired table * signature - Pointer to 4-character buffer to store * extracted table signature. * instance - Pointer to integer to store extracted * table instance number. * * RETURN: Status; Table name is extracted if AE_OK. * * DESCRIPTION: Extract table signature and instance number from a table file * name. *
*****************************************************************************/
/****************************************************************************** * * FUNCTION: osl_read_table_from_file * * PARAMETERS: filename - File that contains the desired table * file_offset - Offset of the table in file * table - Where a pointer to the table is returned * * RETURN: Status; Table buffer is returned if AE_OK. * * DESCRIPTION: Read a ACPI table from a file. *
*****************************************************************************/
table_file = fopen(filename, "rb"); if (table_file == NULL) {
fprintf(stderr, "Could not open table file: %s\n", filename); return (osl_get_last_status(AE_NOT_FOUND));
}
fseek(table_file, file_offset, SEEK_SET);
/* Read the Table header to get the table length */
count = fread(&header, 1, sizeof(struct acpi_table_header), table_file); if (count != sizeof(struct acpi_table_header)) {
fprintf(stderr, "Could not read table header: %s\n", filename);
status = AE_BAD_HEADER; gotoexit;
}
#ifdef ACPI_OBSOLETE_FUNCTIONS
/* If signature is specified, it must match the table */
if (signature) { if (ACPI_VALIDATE_RSDP_SIG(signature)) { if (!ACPI_VALIDATE_RSDP_SIG(header.signature)) {
fprintf(stderr, "Incorrect RSDP signature: found %8.8s\n",
header.signature);
status = AE_BAD_SIGNATURE; gotoexit;
}
} elseif (!ACPI_COMPARE_NAMESEG(signature, header.signature)) {
fprintf(stderr, "Incorrect signature: Expecting %4.4s, found %4.4s\n",
signature, header.signature);
status = AE_BAD_SIGNATURE; gotoexit;
}
} #endif
table_length = ap_get_table_length(&header); if (table_length == 0) {
status = AE_BAD_HEADER; gotoexit;
}
/* Read the entire table into a local buffer */
local_table = calloc(1, table_length); if (!local_table) {
fprintf(stderr, "%4.4s: Could not allocate buffer for table of length %X\n",
header.signature, table_length);
status = AE_NO_MEMORY; gotoexit;
}
fseek(table_file, file_offset, SEEK_SET);
count = fread(local_table, 1, table_length, table_file); if (count != table_length) {
fprintf(stderr, "%4.4s: Could not read table content\n",
header.signature);
status = AE_INVALID_TABLE_LENGTH; gotoexit;
}
/****************************************************************************** * * FUNCTION: osl_get_customized_table * * PARAMETERS: pathname - Directory to find Linux customized table * signature - ACPI Signature for desired table. Must be * a null terminated 4-character string. * instance - Multiple table support for SSDT/UEFI (0...n) * Must be 0 for other tables. * table - Where a pointer to the table is returned * address - Where the table physical address is returned * * RETURN: Status; Table buffer is returned if AE_OK. * AE_LIMIT: Instance is beyond valid limit * AE_NOT_FOUND: A table with the signature was not found * * DESCRIPTION: Get an OS customized 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.