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 @@ -108,6 +108,8 @@ #define BHYVE_ASL_SUFFIX ".aml" #define BHYVE_ASL_COMPILER "/usr/sbin/iasl" +#define BHYVE_ADDRESS_HPET 0xFED00000 + static int basl_keep_temps; static int basl_verbose_iasl; static int basl_ncpu; @@ -543,51 +545,6 @@ return (errno); } -static int -basl_fwrite_hpet(FILE *fp) -{ - EFPRINTF(fp, "/*\n"); - EFPRINTF(fp, " * bhyve HPET template\n"); - EFPRINTF(fp, " */\n"); - EFPRINTF(fp, "[0004]\t\tSignature : \"HPET\"\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 : \"BVHPET \"\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"); - - EFPRINTF(fp, "[0004]\t\tHardware Block ID : %08X\n", hpet_capabilities); - EFPRINTF(fp, - "[0012]\t\tTimer Block Register : [Generic Address Structure]\n"); - EFPRINTF(fp, "[0001]\t\tSpace ID : 00 [SystemMemory]\n"); - EFPRINTF(fp, "[0001]\t\tBit Width : 00\n"); - EFPRINTF(fp, "[0001]\t\tBit Offset : 00\n"); - EFPRINTF(fp, - "[0001]\t\tEncoded Access Width : 00 [Undefined/Legacy]\n"); - EFPRINTF(fp, "[0008]\t\tAddress : 00000000FED00000\n"); - EFPRINTF(fp, "\n"); - - EFPRINTF(fp, "[0001]\t\tSequence Number : 00\n"); - EFPRINTF(fp, "[0002]\t\tMinimum Clock Ticks : 0000\n"); - EFPRINTF(fp, "[0004]\t\tFlags (decoded below) : 00000001\n"); - EFPRINTF(fp, "\t\t\t4K Page Protect : 1\n"); - EFPRINTF(fp, "\t\t\t64K Page Protect : 0\n"); - EFPRINTF(fp, "\n"); - - EFFLUSH(fp); - - return (0); - -err_exit: - return (errno); -} - /* * Helper routines for writing to the DSDT from other modules. */ @@ -938,6 +895,33 @@ return (0); } +static int +build_hpet(struct vmctx *const ctx) +{ + struct basl_table *hpet; + + BASL_EXEC(basl_table_create(&hpet, ctx, ACPI_SIG_HPET, + BASL_TABLE_ALIGNMENT, HPET_OFFSET)); + + /* Header */ + BASL_EXEC( + basl_table_append_header(hpet, ACPI_SIG_HPET, BASL_REVISION_HPET, + BASL_OEM_ID, BASL_OEM_TABLE_ID_HPET, BASL_OEM_REVISION_HPET)); + /* Hardware Block ID */ + BASL_EXEC(basl_table_append_int(hpet, hpet_capabilities, 4)); + /* Timer Block Register */ + BASL_EXEC(basl_table_append_gas(hpet, ACPI_ADR_SPACE_SYSTEM_MEMORY, 0, + 0, 0, BHYVE_ADDRESS_HPET)); + /* Sequence Number */ + BASL_EXEC(basl_table_append_int(hpet, 0, 1)); + /* Minimum Clock Ticks */ + BASL_EXEC(basl_table_append_int(hpet, 0, 2)); + /* Flags */ + BASL_EXEC(basl_table_append_int(hpet, ACPI_HPET_PAGE_PROTECT4, 1)); + + return (0); +} + static int build_mcfg(struct vmctx *const ctx) { @@ -1004,7 +988,7 @@ BASL_EXEC(basl_compile(ctx, basl_fwrite_xsdt, XSDT_OFFSET)); 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(build_hpet(ctx)); 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,14 +19,17 @@ #define BHYVE_ACPI_BASE 0xf2400 #define BASL_REVISION_DSDT 2 +#define BASL_REVISION_HPET 1 #define BASL_REVISION_MCFG 1 #define BASL_OEM_ID "BHYVE " #define BASL_OEM_TABLE_ID_DSDT "BVDSDT " +#define BASL_OEM_TABLE_ID_HPET "BVHPET " #define BASL_OEM_TABLE_ID_MCFG "BVMCFG " #define BASL_OEM_REVISION_DSDT 1 +#define BASL_OEM_REVISION_HPET 1 #define BASL_OEM_REVISION_MCFG 1 #define BASL_COMPILER_ID "BASL"