diff --git a/usr.sbin/bhyve/acpi.c b/usr.sbin/bhyve/acpi.c --- a/usr.sbin/bhyve/acpi.c +++ b/usr.sbin/bhyve/acpi.c @@ -588,37 +588,6 @@ return (errno); } -static int -basl_fwrite_mcfg(FILE *fp) -{ - EFPRINTF(fp, "/*\n"); - EFPRINTF(fp, " * bhyve MCFG template\n"); - EFPRINTF(fp, " */\n"); - EFPRINTF(fp, "[0004]\t\tSignature : \"MCFG\"\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 : \"BVMCFG \"\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, "[0008]\t\tReserved : 0\n"); - EFPRINTF(fp, "\n"); - - EFPRINTF(fp, "[0008]\t\tBase Address : %016lX\n", pci_ecfg_base()); - EFPRINTF(fp, "[0002]\t\tSegment Group Number : 0000\n"); - EFPRINTF(fp, "[0001]\t\tStart Bus Number : 00\n"); - EFPRINTF(fp, "[0001]\t\tEnd Bus Number : FF\n"); - EFPRINTF(fp, "[0004]\t\tReserved : 0\n"); - EFFLUSH(fp); - return (0); -err_exit: - return (errno); -} - /* * Helper routines for writing to the DSDT from other modules. */ @@ -969,6 +938,34 @@ return (0); } +static int +build_mcfg(struct vmctx *const ctx) +{ + struct basl_table *mcfg; + + BASL_EXEC(basl_table_create(&mcfg, ctx, ACPI_SIG_MCFG, + BASL_TABLE_ALIGNMENT, MCFG_OFFSET)); + + /* Header */ + BASL_EXEC( + basl_table_append_header(mcfg, ACPI_SIG_MCFG, BASL_REVISION_MCFG, + BASL_OEM_ID, BASL_OEM_TABLE_ID_MCFG, BASL_OEM_REVISION_MCFG)); + /* Reserved */ + BASL_EXEC(basl_table_append_int(mcfg, 0, 8)); + /* Base Address */ + BASL_EXEC(basl_table_append_int(mcfg, pci_ecfg_base(), 8)); + /* Segment Group Number */ + BASL_EXEC(basl_table_append_int(mcfg, 0, 2)); + /* Start Bus Number */ + BASL_EXEC(basl_table_append_int(mcfg, 0, 1)); + /* End Bus Number */ + BASL_EXEC(basl_table_append_int(mcfg, 0xFF, 1)); + /* Reserved */ + BASL_EXEC(basl_table_append_int(mcfg, 0, 4)); + + return (0); +} + int acpi_build(struct vmctx *ctx, int ncpu) { @@ -1008,7 +1005,7 @@ BASL_EXEC(basl_compile(ctx, basl_fwrite_madt, MADT_OFFSET)); BASL_EXEC(basl_compile(ctx, basl_fwrite_fadt, FADT_OFFSET)); BASL_EXEC(basl_compile(ctx, basl_fwrite_hpet, HPET_OFFSET)); - BASL_EXEC(basl_compile(ctx, basl_fwrite_mcfg, MCFG_OFFSET)); + BASL_EXEC(build_mcfg(ctx)); BASL_EXEC(build_facs(ctx)); BASL_EXEC(build_dsdt(ctx)); diff --git a/usr.sbin/bhyve/basl.h b/usr.sbin/bhyve/basl.h --- a/usr.sbin/bhyve/basl.h +++ b/usr.sbin/bhyve/basl.h @@ -19,12 +19,15 @@ #define BHYVE_ACPI_BASE 0xf2400 #define BASL_REVISION_DSDT 2 +#define BASL_REVISION_MCFG 1 #define BASL_OEM_ID "BHYVE " #define BASL_OEM_TABLE_ID_DSDT "BVDSDT " +#define BASL_OEM_TABLE_ID_MCFG "BVMCFG " #define BASL_OEM_REVISION_DSDT 1 +#define BASL_OEM_REVISION_MCFG 1 #define BASL_COMPILER_ID "BASL"