bhyve: build RSDT table by basl
Building the RSDT table by basl will allow it to be loaded by qemu's ACPI table loader in the future. Reviewed by: jhb, markj (older version) Approved by: manu (mentor) MFC after: 2 weeks Sponsored by: Beckhoff Automation GmbH & Co. KG Differential Revision: https://reviews.freebsd.org/D37000
This commit is contained in:
parent
4a60470f05
commit
f3dcdf8be4
@ -134,6 +134,7 @@ static FILE *dsdt_fp;
|
||||
static int dsdt_indent_level;
|
||||
static int dsdt_error;
|
||||
|
||||
static struct basl_table *rsdt;
|
||||
static struct basl_table *xsdt;
|
||||
|
||||
struct basl_fio {
|
||||
@ -174,42 +175,6 @@ basl_fwrite_rsdp(FILE *fp)
|
||||
return (errno);
|
||||
}
|
||||
|
||||
static int
|
||||
basl_fwrite_rsdt(FILE *fp)
|
||||
{
|
||||
EFPRINTF(fp, "/*\n");
|
||||
EFPRINTF(fp, " * bhyve RSDT template\n");
|
||||
EFPRINTF(fp, " */\n");
|
||||
EFPRINTF(fp, "[0004]\t\tSignature : \"RSDT\"\n");
|
||||
EFPRINTF(fp, "[0004]\t\tTable Length : 00000000\n");
|
||||
EFPRINTF(fp, "[0001]\t\tRevision : 01\n");
|
||||
EFPRINTF(fp, "[0001]\t\tChecksum : 00\n");
|
||||
EFPRINTF(fp, "[0006]\t\tOem ID : \"BHYVE \"\n");
|
||||
EFPRINTF(fp, "[0008]\t\tOem Table ID : \"BVRSDT \"\n");
|
||||
EFPRINTF(fp, "[0004]\t\tOem Revision : 00000001\n");
|
||||
/* iasl will fill in the compiler ID/revision fields */
|
||||
EFPRINTF(fp, "[0004]\t\tAsl Compiler ID : \"xxxx\"\n");
|
||||
EFPRINTF(fp, "[0004]\t\tAsl Compiler Revision : 00000000\n");
|
||||
EFPRINTF(fp, "\n");
|
||||
|
||||
/* Add in pointers to the MADT, FADT and HPET */
|
||||
EFPRINTF(fp, "[0004]\t\tACPI Table Address 0 : %08X\n",
|
||||
basl_acpi_base + MADT_OFFSET);
|
||||
EFPRINTF(fp, "[0004]\t\tACPI Table Address 1 : %08X\n",
|
||||
basl_acpi_base + FADT_OFFSET);
|
||||
EFPRINTF(fp, "[0004]\t\tACPI Table Address 2 : %08X\n",
|
||||
basl_acpi_base + HPET_OFFSET);
|
||||
EFPRINTF(fp, "[0004]\t\tACPI Table Address 3 : %08X\n",
|
||||
basl_acpi_base + MCFG_OFFSET);
|
||||
|
||||
EFFLUSH(fp);
|
||||
|
||||
return (0);
|
||||
|
||||
err_exit:
|
||||
return (errno);
|
||||
}
|
||||
|
||||
/*
|
||||
* Helper routines for writing to the DSDT from other modules.
|
||||
*/
|
||||
@ -608,6 +573,8 @@ build_fadt(struct vmctx *const ctx)
|
||||
BASL_EXEC(basl_table_add_pointer(table, ACPI_SIG_DSDT,
|
||||
offsetof(ACPI_TABLE_FADT, XDsdt), sizeof(fadt.XDsdt)));
|
||||
|
||||
BASL_EXEC(basl_table_append_pointer(rsdt, ACPI_SIG_FADT,
|
||||
ACPI_RSDT_ENTRY_SIZE));
|
||||
BASL_EXEC(basl_table_append_pointer(xsdt, ACPI_SIG_FADT,
|
||||
ACPI_XSDT_ENTRY_SIZE));
|
||||
|
||||
@ -631,6 +598,8 @@ build_hpet(struct vmctx *const ctx)
|
||||
hpet.Flags = ACPI_HPET_PAGE_PROTECT4;
|
||||
BASL_EXEC(basl_table_append_content(table, &hpet, sizeof(hpet)));
|
||||
|
||||
BASL_EXEC(basl_table_append_pointer(rsdt, ACPI_SIG_HPET,
|
||||
ACPI_RSDT_ENTRY_SIZE));
|
||||
BASL_EXEC(basl_table_append_pointer(xsdt, ACPI_SIG_HPET,
|
||||
ACPI_XSDT_ENTRY_SIZE));
|
||||
|
||||
@ -707,6 +676,8 @@ build_madt(struct vmctx *const ctx)
|
||||
BASL_EXEC(basl_table_append_bytes(table, &madt_lapic_nmi,
|
||||
sizeof(madt_lapic_nmi)));
|
||||
|
||||
BASL_EXEC(basl_table_append_pointer(rsdt, ACPI_SIG_MADT,
|
||||
ACPI_RSDT_ENTRY_SIZE));
|
||||
BASL_EXEC(basl_table_append_pointer(xsdt, ACPI_SIG_MADT,
|
||||
ACPI_XSDT_ENTRY_SIZE));
|
||||
|
||||
@ -733,12 +704,27 @@ build_mcfg(struct vmctx *const ctx)
|
||||
BASL_EXEC(basl_table_append_bytes(table, &mcfg_allocation,
|
||||
sizeof(mcfg_allocation)));
|
||||
|
||||
BASL_EXEC(basl_table_append_pointer(rsdt, ACPI_SIG_MCFG,
|
||||
ACPI_RSDT_ENTRY_SIZE));
|
||||
BASL_EXEC(basl_table_append_pointer(xsdt, ACPI_SIG_MCFG,
|
||||
ACPI_XSDT_ENTRY_SIZE));
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
||||
static int
|
||||
build_rsdt(struct vmctx *const ctx)
|
||||
{
|
||||
BASL_EXEC(basl_table_create(&rsdt, ctx, ACPI_SIG_RSDT,
|
||||
BASL_TABLE_ALIGNMENT, RSDT_OFFSET));
|
||||
|
||||
/* Header */
|
||||
BASL_EXEC(basl_table_append_header(rsdt, ACPI_SIG_RSDT, 1, 1));
|
||||
/* Pointers (added by other build_XXX funcs) */
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
||||
static int
|
||||
build_xsdt(struct vmctx *const ctx)
|
||||
{
|
||||
@ -790,7 +776,7 @@ acpi_build(struct vmctx *ctx, int ncpu)
|
||||
* first table after XSDT.
|
||||
*/
|
||||
BASL_EXEC(basl_compile(ctx, basl_fwrite_rsdp, 0));
|
||||
BASL_EXEC(basl_compile(ctx, basl_fwrite_rsdt, RSDT_OFFSET));
|
||||
BASL_EXEC(build_rsdt(ctx));
|
||||
BASL_EXEC(build_xsdt(ctx));
|
||||
BASL_EXEC(build_fadt(ctx));
|
||||
BASL_EXEC(build_madt(ctx));
|
||||
|
Loading…
Reference in New Issue
Block a user