mirror of
https://xff.cz/git/u-boot/
synced 2025-10-26 16:13:55 +01:00
x86: acpi: Move APIs unrelated to ACPI tables generation to a separate library
acpi_find_fadt(), acpi_find_wakeup_vector() and enter_acpi_mode() are something unrelated to ACPI tables generation. Move these to a separate library. This also fixes several style issues reported by checkpatch in the original codes. Signed-off-by: Bin Meng <bmeng.cn@gmail.com> Reviewed-by: Simon Glass <sjg@chromium.org> Tested-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
This commit is contained in:
@@ -12,8 +12,8 @@
|
||||
#include <dm/uclass-internal.h>
|
||||
#include <version.h>
|
||||
#include <asm/acpi/global_nvs.h>
|
||||
#include <asm/acpi.h>
|
||||
#include <asm/acpi_table.h>
|
||||
#include <asm/io.h>
|
||||
#include <asm/ioapic.h>
|
||||
#include <asm/lapic.h>
|
||||
#include <asm/mpspec.h>
|
||||
@@ -337,27 +337,6 @@ static void acpi_create_mcfg(struct acpi_mcfg *mcfg)
|
||||
header->checksum = table_compute_checksum((void *)mcfg, header->length);
|
||||
}
|
||||
|
||||
void enter_acpi_mode(int pm1_cnt)
|
||||
{
|
||||
u16 val = inw(pm1_cnt);
|
||||
|
||||
/*
|
||||
* PM1_CNT register bit0 selects the power management event to be
|
||||
* either an SCI or SMI interrupt. When this bit is set, then power
|
||||
* management events will generate an SCI interrupt. When this bit
|
||||
* is reset power management events will generate an SMI interrupt.
|
||||
*
|
||||
* Per ACPI spec, it is the responsibility of the hardware to set
|
||||
* or reset this bit. OSPM always preserves this bit position.
|
||||
*
|
||||
* U-Boot does not support SMI. And we don't have plan to support
|
||||
* anything running in SMM within U-Boot. To create a legacy-free
|
||||
* system, and expose ourselves to OSPM as working under ACPI mode
|
||||
* already, turn this bit on.
|
||||
*/
|
||||
outw(val | PM1_CNT_SCI_EN, pm1_cnt);
|
||||
}
|
||||
|
||||
/*
|
||||
* QEMU's version of write_acpi_tables is defined in drivers/misc/qfw.c
|
||||
*/
|
||||
@@ -482,81 +461,3 @@ ulong acpi_get_rsdp_addr(void)
|
||||
{
|
||||
return acpi_rsdp_addr;
|
||||
}
|
||||
|
||||
static struct acpi_rsdp *acpi_valid_rsdp(struct acpi_rsdp *rsdp)
|
||||
{
|
||||
if (strncmp((char *)rsdp, RSDP_SIG, sizeof(RSDP_SIG) - 1) != 0)
|
||||
return NULL;
|
||||
|
||||
debug("Looking on %p for valid checksum\n", rsdp);
|
||||
|
||||
if (table_compute_checksum((void *)rsdp, 20) != 0)
|
||||
return NULL;
|
||||
debug("acpi rsdp checksum 1 passed\n");
|
||||
|
||||
if ((rsdp->revision > 1) &&
|
||||
(table_compute_checksum((void *)rsdp, rsdp->length) != 0))
|
||||
return NULL;
|
||||
debug("acpi rsdp checksum 2 passed\n");
|
||||
|
||||
return rsdp;
|
||||
}
|
||||
|
||||
struct acpi_fadt *acpi_find_fadt(void)
|
||||
{
|
||||
char *p, *end;
|
||||
struct acpi_rsdp *rsdp = NULL;
|
||||
struct acpi_rsdt *rsdt;
|
||||
struct acpi_fadt *fadt = NULL;
|
||||
int i;
|
||||
|
||||
/* Find RSDP */
|
||||
for (p = (char *)ROM_TABLE_ADDR; p < (char *)ROM_TABLE_END; p += 16) {
|
||||
rsdp = acpi_valid_rsdp((struct acpi_rsdp *)p);
|
||||
if (rsdp)
|
||||
break;
|
||||
}
|
||||
|
||||
if (rsdp == NULL)
|
||||
return NULL;
|
||||
|
||||
debug("RSDP found at %p\n", rsdp);
|
||||
rsdt = (struct acpi_rsdt *)rsdp->rsdt_address;
|
||||
|
||||
end = (char *)rsdt + rsdt->header.length;
|
||||
debug("RSDT found at %p ends at %p\n", rsdt, end);
|
||||
|
||||
for (i = 0; ((char *)&rsdt->entry[i]) < end; i++) {
|
||||
fadt = (struct acpi_fadt *)rsdt->entry[i];
|
||||
if (strncmp((char *)fadt, "FACP", 4) == 0)
|
||||
break;
|
||||
fadt = NULL;
|
||||
}
|
||||
|
||||
if (fadt == NULL)
|
||||
return NULL;
|
||||
|
||||
debug("FADT found at %p\n", fadt);
|
||||
return fadt;
|
||||
}
|
||||
|
||||
void *acpi_find_wakeup_vector(struct acpi_fadt *fadt)
|
||||
{
|
||||
struct acpi_facs *facs;
|
||||
void *wake_vec;
|
||||
|
||||
debug("Trying to find the wakeup vector...\n");
|
||||
|
||||
facs = (struct acpi_facs *)fadt->firmware_ctrl;
|
||||
|
||||
if (facs == NULL) {
|
||||
debug("No FACS found, wake up from S3 not possible.\n");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
debug("FACS found at %p\n", facs);
|
||||
wake_vec = (void *)facs->firmware_waking_vector;
|
||||
debug("OS waking vector is %p\n", wake_vec);
|
||||
|
||||
return wake_vec;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user