199767f8919635c4928607450d9e0abb932109ceToomas Soome * Copyright (c) 2001 Michael Smith <msmith@freebsd.org>
199767f8919635c4928607450d9e0abb932109ceToomas Soome * All rights reserved.
199767f8919635c4928607450d9e0abb932109ceToomas Soome * Redistribution and use in source and binary forms, with or without
199767f8919635c4928607450d9e0abb932109ceToomas Soome * modification, are permitted provided that the following conditions
199767f8919635c4928607450d9e0abb932109ceToomas Soome * 1. Redistributions of source code must retain the above copyright
199767f8919635c4928607450d9e0abb932109ceToomas Soome * notice, this list of conditions and the following disclaimer.
199767f8919635c4928607450d9e0abb932109ceToomas Soome * 2. Redistributions in binary form must reproduce the above copyright
199767f8919635c4928607450d9e0abb932109ceToomas Soome * notice, this list of conditions and the following disclaimer in the
199767f8919635c4928607450d9e0abb932109ceToomas Soome * documentation and/or other materials provided with the distribution.
199767f8919635c4928607450d9e0abb932109ceToomas Soome * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
199767f8919635c4928607450d9e0abb932109ceToomas Soome * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
199767f8919635c4928607450d9e0abb932109ceToomas Soome * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
199767f8919635c4928607450d9e0abb932109ceToomas Soome * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
199767f8919635c4928607450d9e0abb932109ceToomas Soome * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
199767f8919635c4928607450d9e0abb932109ceToomas Soome * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
199767f8919635c4928607450d9e0abb932109ceToomas Soome * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
199767f8919635c4928607450d9e0abb932109ceToomas Soome * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
199767f8919635c4928607450d9e0abb932109ceToomas Soome * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
199767f8919635c4928607450d9e0abb932109ceToomas Soome * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
199767f8919635c4928607450d9e0abb932109ceToomas Soome * SUCH DAMAGE.
199767f8919635c4928607450d9e0abb932109ceToomas Soome * Detect ACPI and export information about the ACPI BIOS into the
199767f8919635c4928607450d9e0abb932109ceToomas Soome * environment.
199767f8919635c4928607450d9e0abb932109ceToomas Soomestatic ACPI_TABLE_RSDP *biosacpi_find_rsdp(void);
199767f8919635c4928607450d9e0abb932109ceToomas Soomestatic ACPI_TABLE_RSDP *biosacpi_search_rsdp(char *base, int length);
199767f8919635c4928607450d9e0abb932109ceToomas Soome /* locate and validate the RSDP */
199767f8919635c4928607450d9e0abb932109ceToomas Soome /* export values from the RSDP */
199767f8919635c4928607450d9e0abb932109ceToomas Soome sprintf(buf, "0x%08x", (unsigned int)VTOP(rsdp));
199767f8919635c4928607450d9e0abb932109ceToomas Soome strncpy(buf, rsdp->OemId, sizeof(rsdp->OemId));
199767f8919635c4928607450d9e0abb932109ceToomas Soome sprintf(buf, "0x%08x", rsdp->RsdtPhysicalAddress);
199767f8919635c4928607450d9e0abb932109ceToomas Soome /* XXX extended checksum? */
199767f8919635c4928607450d9e0abb932109ceToomas Soome (unsigned long long)rsdp->XsdtPhysicalAddress);
199767f8919635c4928607450d9e0abb932109ceToomas Soome * Find the RSDP in low memory. See section 5.2.2 of the ACPI spec.
199767f8919635c4928607450d9e0abb932109ceToomas Soome /* EBDA is the 1 KB addressed by the 16 bit pointer at 0x40E. */
199767f8919635c4928607450d9e0abb932109ceToomas Soome rsdp = biosacpi_search_rsdp((char *)(intptr_t)(*addr << 4), 0x400);
199767f8919635c4928607450d9e0abb932109ceToomas Soome /* Check the upper memory BIOS space, 0xe0000 - 0xfffff. */
199767f8919635c4928607450d9e0abb932109ceToomas Soome if ((rsdp = biosacpi_search_rsdp((char *)0xe0000, 0x20000)) != NULL)
199767f8919635c4928607450d9e0abb932109ceToomas Soome /* search on 16-byte boundaries */
199767f8919635c4928607450d9e0abb932109ceToomas Soome /* compare signature, validate checksum */
199767f8919635c4928607450d9e0abb932109ceToomas Soome if (!strncmp(rsdp->Signature, ACPI_SIG_RSDP, strlen(ACPI_SIG_RSDP))) {