src/usr.sbin/acpi/acpidump/acpi.c
/* Write the DSDT to a file, concatenating any SSDTs (if present). */
Write the DSDT to a file, concatenating any SSDTs (if present).
Write the DSDT to a file concatenating any SSDTs ( if present ) .
static int
write_dsdt(int fd, ACPI_TABLE_HEADER *rsdt, ACPI_TABLE_HEADER *dsdt)
{
	ACPI_TABLE_HEADER sdt;
	ACPI_TABLE_HEADER *ssdt;
	uint8_t sum;
	sdt = *dsdt;
	if (rsdt != NULL) {
		sdt.Checksum = 0;
		sum = acpi_checksum(dsdt + 1, dsdt->Length -
		    sizeof(ACPI_TABLE_HEADER));
		ssdt = sdt_from_rsdt(rsdt, ACPI_SIG_SSDT, NULL);
		while (ssdt != NULL) {
			sdt.Length += ssdt->Length - sizeof(ACPI_TABLE_HEADER);
			sum += acpi_checksum(ssdt + 1,
			    ssdt->Length - sizeof(ACPI_TABLE_HEADER));
			ssdt = sdt_from_rsdt(rsdt, ACPI_SIG_SSDT, ssdt);
		}
		sum += acpi_checksum(&sdt, sizeof(ACPI_TABLE_HEADER));
		sdt.Checksum -= sum;
	}
	write(fd, &sdt, sizeof(ACPI_TABLE_HEADER));
	write(fd, dsdt + 1, dsdt->Length - sizeof(ACPI_TABLE_HEADER));
	if (rsdt != NULL) {
		ssdt = sdt_from_rsdt(rsdt, "SSDT", NULL);
		while (ssdt != NULL) {
			write(fd, ssdt + 1, ssdt->Length -
			    sizeof(ACPI_TABLE_HEADER));
			ssdt = sdt_from_rsdt(rsdt, "SSDT", ssdt);
		}
	}
	return (0);
}
static int write_dsdt ( int fd , ACPI_TABLE_HEADER * rsdt , ACPI_TABLE_HEADER * dsdt ) { ACPI_TABLE_HEADER sdt ; ACPI_TABLE_HEADER * ssdt ; uint8_t sum ; sdt = * dsdt ; if ( rsdt != NULL ) { sdt . Checksum = 0 ; sum = acpi_checksum ( dsdt + 1 , dsdt -> Length - sizeof ( ACPI_TABLE_HEADER ) ) ; ssdt = sdt_from_rsdt ( rsdt , ACPI_SIG_SSDT , NULL ) ; while ( ssdt != NULL ) { sdt . Length += ssdt -> Length - sizeof ( ACPI_TABLE_HEADER ) ; sum += acpi_checksum ( ssdt + 1 , ssdt -> Length - sizeof ( ACPI_TABLE_HEADER ) ) ; ssdt = sdt_from_rsdt ( rsdt , ACPI_SIG_SSDT , ssdt ) ; } sum += acpi_checksum ( & sdt , sizeof ( ACPI_TABLE_HEADER ) ) ; sdt . Checksum -= sum ; } write ( fd , & sdt , sizeof ( ACPI_TABLE_HEADER ) ) ; write ( fd , dsdt + 1 , dsdt -> Length - sizeof ( ACPI_TABLE_HEADER ) ) ; if ( rsdt != NULL ) { ssdt = sdt_from_rsdt ( rsdt , " " , NULL ) ; while ( ssdt != NULL ) { write ( fd , ssdt + 1 , ssdt -> Length - sizeof ( ACPI_TABLE_HEADER ) ) ; ssdt = sdt_from_rsdt ( rsdt , " " , ssdt ) ; } } return ( 0 ) ; }
Write the DSDT to a file, concatenating any SSDTs (if present).
Write the DSDT to a file concatenating any SSDTs ( if present ) .
/* Create a new checksum to account for the DSDT and any SSDTs. */ /* Write out the DSDT header and body. */ /* Write out any SSDTs (if present.) */