/*-1* Copyright (c) 2014 Ed Maste <[email protected]>2* Copyright (c) 2025 Kayla Powell <[email protected]>3* All rights reserved.4*5* Redistribution and use in source and binary forms, with or without6* modification, are permitted provided that the following conditions7* are met:8* 1. Redistributions of source code must retain the above copyright9* notice, this list of conditions and the following disclaimer.10* 2. Redistributions in binary form must reproduce the above copyright11* notice, this list of conditions and the following disclaimer in the12* documentation and/or other materials provided with the distribution.13*14* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND15* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE16* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE17* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE18* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL19* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS20* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)21* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT22* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY23* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF24* SUCH DAMAGE.25*/2627#include <machine/_inttypes.h>28#include <efi.h>29#include <acpi.h>30#include "acpi_detect.h"3132/* For ACPI rsdp discovery. */33EFI_GUID acpi = ACPI_TABLE_GUID;34EFI_GUID acpi20 = ACPI_20_TABLE_GUID;35ACPI_TABLE_RSDP *rsdp;3637void38acpi_detect(void)39{40char buf[24];41int revision;4243feature_enable(FEATURE_EARLY_ACPI);44if ((rsdp = efi_get_table(&acpi20)) == NULL)45if ((rsdp = efi_get_table(&acpi)) == NULL)46return;4748sprintf(buf, "0x%016"PRIxPTR, (uintptr_t)rsdp);49setenv("acpi.rsdp", buf, 1);50revision = rsdp->Revision;51if (revision == 0)52revision = 1;53sprintf(buf, "%d", revision);54setenv("acpi.revision", buf, 1);55strncpy(buf, rsdp->OemId, sizeof(rsdp->OemId));56buf[sizeof(rsdp->OemId)] = '\0';57setenv("acpi.oem", buf, 1);58sprintf(buf, "0x%016x", rsdp->RsdtPhysicalAddress);59setenv("acpi.rsdt", buf, 1);60if (revision >= 2) {61/* XXX extended checksum? */62sprintf(buf, "0x%016llx",63(unsigned long long)rsdp->XsdtPhysicalAddress);64setenv("acpi.xsdt", buf, 1);65sprintf(buf, "%d", rsdp->Length);66setenv("acpi.xsdt_length", buf, 1);67}68}697071