tools/power/acpi/tools/acpidump/apdump.c

Source file repositories/reference/linux-study-clean/tools/power/acpi/tools/acpidump/apdump.c

File Facts

System
Linux kernel
Corpus path
tools/power/acpi/tools/acpidump/apdump.c
Extension
.c
Size
10539 bytes
Lines
406
Domain
Support Tooling And Documentation
Bucket
tools
Inferred role
Support Tooling And Documentation: implementation source
Status
source implementation candidate

Why This File Exists

Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.

Dependency Surface

Detected Declarations

Annotated Snippet

if (!acpi_ut_valid_nameseg(table->signature)) {
			fprintf(stderr,
				"Table signature (0x%8.8X) is invalid\n",
				*(u32 *)table->signature);
			return (FALSE);
		}

		/* Check for minimum table length */

		if (table->length < sizeof(struct acpi_table_header)) {
			fprintf(stderr, "Table length (0x%8.8X) is invalid\n",
				table->length);
			return (FALSE);
		}
	}

	return (TRUE);
}

/******************************************************************************
 *
 * FUNCTION:    ap_is_valid_checksum
 *
 * PARAMETERS:  table               - Pointer to table to be validated
 *
 * RETURN:      TRUE if the checksum appears to be valid. FALSE otherwise.
 *
 * DESCRIPTION: Check for a valid ACPI table checksum.
 *
 ******************************************************************************/

u8 ap_is_valid_checksum(struct acpi_table_header *table)
{
	acpi_status status;
	struct acpi_table_rsdp *rsdp;

	if (ACPI_VALIDATE_RSDP_SIG(table->signature)) {
		/*
		 * Checksum for RSDP.
		 * Note: Other checksums are computed during the table dump.
		 */
		rsdp = ACPI_CAST_PTR(struct acpi_table_rsdp, table);
		status = acpi_tb_validate_rsdp(rsdp);
	} else {
		/* We don't have to check for a CDAT here, since CDAT is not in the RSDT/XSDT */

		status = acpi_ut_verify_checksum(table, table->length);
	}

	if (ACPI_FAILURE(status)) {
		fprintf(stderr, "%4.4s: Warning: wrong checksum in table\n",
			table->signature);
		return (FALSE);
	}

	return (TRUE);
}

/******************************************************************************
 *
 * FUNCTION:    ap_get_table_length
 *
 * PARAMETERS:  table               - Pointer to the table
 *
 * RETURN:      Table length
 *
 * DESCRIPTION: Obtain table length according to table signature.
 *
 ******************************************************************************/

u32 ap_get_table_length(struct acpi_table_header *table)
{
	struct acpi_table_rsdp *rsdp;

	/* Check if table is valid */

	if (!ap_is_valid_header(table)) {
		return (0);
	}

	if (ACPI_VALIDATE_RSDP_SIG(table->signature)) {
		rsdp = ACPI_CAST_PTR(struct acpi_table_rsdp, table);
		return (acpi_tb_get_rsdp_length(rsdp));
	}

	/* Normal ACPI table */

	return (table->length);
}

Annotation

Implementation Notes