/* * Public interfaces */ ACPI_TABLE_RSDP * acpi_find_rsd_ptr(void) { ACPI_TABLE_RSDP *rsdp; char buf[20]; u_long addr; size_t len; acpi_user_init(); addr = 0; /* Attempt to use kenv or sysctl to find RSD PTR record. */ if (kenv(KENV_GET, hint_acpi_0_rsdp, buf, 20) == 0) addr = strtoul(buf, NULL, 0); if (addr == 0) { len = sizeof(addr); if (sysctlbyname(machdep_acpi_root, &addr, &len, NULL, 0) != 0) addr = 0; } if (addr != 0 && (rsdp = acpi_get_rsdp(addr)) != NULL) return (rsdp); return (acpi_scan_rsd_ptr()); }
/* * 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(); }