drivers/acpi/acpica/utcksum.c

Source file repositories/reference/linux-study-clean/drivers/acpi/acpica/utcksum.c

File Facts

System
Linux kernel
Corpus path
drivers/acpi/acpica/utcksum.c
Extension
.c
Size
4733 bytes
Lines
171
Domain
Driver Families
Bucket
drivers/acpi
Inferred role
Driver Families: implementation source
Status
source implementation candidate

Why This File Exists

Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.

Dependency Surface

Detected Declarations

Annotated Snippet

ACPI_COMPARE_NAMESEG(table->signature, ACPI_SIG_FACS)) {
		return (AE_OK);
	}

	/* Compute the checksum on the table */

	length = table->length;
	checksum =
	    acpi_ut_generate_checksum(ACPI_CAST_PTR(u8, table), length,
				      table->checksum);

	/* Computed checksum matches table? */

	if (checksum != table->checksum) {
		ACPI_BIOS_WARNING((AE_INFO,
				   "Incorrect checksum in table [%4.4s] - 0x%2.2X, "
				   "should be 0x%2.2X",
				   table->signature, table->checksum,
				   table->checksum - checksum));

#if (ACPI_CHECKSUM_ABORT)
		return (AE_BAD_CHECKSUM);
#endif
	}

	return (AE_OK);
}

/*******************************************************************************
 *
 * FUNCTION:    acpi_ut_verify_cdat_checksum
 *
 * PARAMETERS:  table               - CDAT ACPI table to verify
 *              length              - Length of entire table
 *
 * RETURN:      Status
 *
 * DESCRIPTION: Verifies that the CDAT table checksums to zero. Optionally
 *              returns an exception on bad checksum.
 *
 ******************************************************************************/

acpi_status
acpi_ut_verify_cdat_checksum(struct acpi_table_cdat *cdat_table, u32 length)
{
	u8 checksum;

	/* Compute the checksum on the table */

	checksum = acpi_ut_generate_checksum(ACPI_CAST_PTR(u8, cdat_table),
					     cdat_table->length,
					     cdat_table->checksum);

	/* Computed checksum matches table? */

	if (checksum != cdat_table->checksum) {
		ACPI_BIOS_WARNING((AE_INFO,
				   "Incorrect checksum in table [%4.4s] - 0x%2.2X, "
				   "should be 0x%2.2X",
				   acpi_gbl_CDAT, cdat_table->checksum,
				   checksum));

#if (ACPI_CHECKSUM_ABORT)
		return (AE_BAD_CHECKSUM);
#endif
	}

	cdat_table->checksum = checksum;
	return (AE_OK);
}

/*******************************************************************************
 *
 * FUNCTION:    acpi_ut_generate_checksum
 *
 * PARAMETERS:  table               - Pointer to table to be checksummed
 *              length              - Length of the table
 *              original_checksum   - Value of the checksum field
 *
 * RETURN:      8 bit checksum of buffer
 *
 * DESCRIPTION: Computes an 8 bit checksum of the table.
 *
 ******************************************************************************/

u8 acpi_ut_generate_checksum(void *table, u32 length, u8 original_checksum)
{
	u8 checksum;

	/* Sum the entire table as-is */

Annotation

Implementation Notes