src/usr.sbin/acpi/acpidump/acpi.c
/* Fetch a table matching the given signature via the RSDT. */
Fetch a table matching the given signature via the RSDT.
Fetch a table matching the given signature via the RSDT .
ACPI_TABLE_HEADER *
sdt_from_rsdt(ACPI_TABLE_HEADER *rsdp, const char *sig, ACPI_TABLE_HEADER *last)
{
	ACPI_TABLE_HEADER *sdt;
	ACPI_TABLE_RSDT *rsdt;
	ACPI_TABLE_XSDT *xsdt;
	vm_offset_t addr;
	int entries, i;
	rsdt = (ACPI_TABLE_RSDT *)rsdp;
	xsdt = (ACPI_TABLE_XSDT *)rsdp;
	entries = (rsdp->Length - sizeof(ACPI_TABLE_HEADER)) / addr_size;
	for (i = 0; i < entries; i++) {
		if (addr_size == 4)
			addr = le32toh(rsdt->TableOffsetEntry[i]);
		else
			addr = le64toh(xsdt->TableOffsetEntry[i]);
		if (addr == 0)
			continue;
		sdt = (ACPI_TABLE_HEADER *)acpi_map_sdt(addr);
		if (last != NULL) {
			if (sdt == last)
				last = NULL;
			continue;
		}
		if (memcmp(sdt->Signature, sig, strlen(sig)))
			continue;
		if (acpi_checksum(sdt, sdt->Length))
			errx(1, "RSDT entry %d is corrupt", i);
		return (sdt);
	}
	return (NULL);
}
ACPI_TABLE_HEADER * sdt_from_rsdt ( ACPI_TABLE_HEADER * rsdp , const char * sig , ACPI_TABLE_HEADER * last ) { ACPI_TABLE_HEADER * sdt ; ACPI_TABLE_RSDT * rsdt ; ACPI_TABLE_XSDT * xsdt ; vm_offset_t addr ; int entries , i ; rsdt = ( ACPI_TABLE_RSDT * ) rsdp ; xsdt = ( ACPI_TABLE_XSDT * ) rsdp ; entries = ( rsdp -> Length - sizeof ( ACPI_TABLE_HEADER ) ) / addr_size ; for ( i = 0 ; i < entries ; i ++ ) { if ( addr_size == 4 ) addr = le32toh ( rsdt -> TableOffsetEntry [ i ] ) ; else addr = le64toh ( xsdt -> TableOffsetEntry [ i ] ) ; if ( addr == 0 ) continue ; sdt = ( ACPI_TABLE_HEADER * ) acpi_map_sdt ( addr ) ; if ( last != NULL ) { if ( sdt == last ) last = NULL ; continue ; } if ( memcmp ( sdt -> Signature , sig , strlen ( sig ) ) ) continue ; if ( acpi_checksum ( sdt , sdt -> Length ) ) errx ( 1 , " " , i ) ; return ( sdt ) ; } return ( NULL ) ; }
Fetch a table matching the given signature via the RSDT.
Fetch a table matching the given signature via the RSDT .