static struct ACPIsdt * acpi_map_sdt(vm_offset_t pa) { struct ACPIsdt *sp; sp = acpi_map_physical(pa, sizeof(struct ACPIsdt)); sp = acpi_map_physical(pa, sp->len); return (sp); }
static struct ACPIrsdp * acpi_get_rsdp(u_long addr) { struct ACPIrsdp rsdp; size_t len; /* Read in the table signature and check it. */ pread(acpi_mem_fd, &rsdp, 8, addr); if (memcmp(rsdp.signature, "RSD PTR ", 8)) return (NULL); /* Read the entire table. */ pread(acpi_mem_fd, &rsdp, sizeof(rsdp), addr); /* Run the checksum only over the version 1 header. */ if (acpi_checksum(&rsdp, 20)) return (NULL); /* If the revision is 0, assume a version 1 length. */ if (rsdp.revision == 0) len = 20; else len = rsdp.length; /* XXX Should handle ACPI 2.0 RSDP extended checksum here. */ return (acpi_map_physical(addr, len)); }
static ACPI_TABLE_RSDP * acpi_get_rsdp(u_long addr) { ACPI_TABLE_RSDP rsdp; size_t len; /* Read in the table signature and check it. */ pread(acpi_mem_fd, &rsdp, 8, addr); if (memcmp(rsdp.Signature, "RSD PTR ", 8)) return (NULL); /* Read the entire table. */ pread(acpi_mem_fd, &rsdp, sizeof(rsdp), addr); /* Check the standard checksum. */ if (acpi_checksum(&rsdp, ACPI_RSDP_CHECKSUM_LENGTH) != 0) return (NULL); /* Check extended checksum if table version >= 2. */ if (rsdp.Revision >= 2 && acpi_checksum(&rsdp, ACPI_RSDP_XCHECKSUM_LENGTH) != 0) return (NULL); /* If the revision is 0, assume a version 1 length. */ if (rsdp.Revision == 0) len = ACPI_RSDP_REV0_SIZE; else len = rsdp.Length; return (acpi_map_physical(addr, len)); }
/* * Public interfaces */ ACPI_TABLE_RSDP * acpi_find_rsd_ptr(void) { int i; uint8_t buf[sizeof(ACPI_TABLE_RSDP)]; acpi_user_init(); for (i = 0; i < 1024 * 1024; i += 16) { read(acpi_mem_fd, buf, 16); if (!memcmp(buf, "RSD PTR ", 8)) { /* Read the rest of the structure */ read(acpi_mem_fd, buf + 16, sizeof(ACPI_TABLE_RSDP) - 16); /* Verify checksum before accepting it. */ if (acpi_checksum(buf, sizeof(ACPI_TABLE_RSDP))) continue; return (acpi_map_physical(i, sizeof(ACPI_TABLE_RSDP))); } } return acpi_scan_rsd_ptr(); }