#include <sys/param.h>
#include <sys/mman.h>
#include <sys/uuid.h>
#include <assert.h>
#include <ctype.h>
#include <err.h>
#include <errno.h>
#include <pthread.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <strings.h>
#include <stdbool.h>
#include <unistd.h>
#include <machine/vmm.h>
#include <vmmapi.h>
#include "acpi.h"
#include "bootrom.h"
#include "vmgenc.h"
static uint64_t vmgen_gpa;
void
vmgenc_init(struct vmctx *ctx)
{
char *region;
int error;
error = bootrom_alloc(ctx, PAGE_SIZE, PROT_READ, 0, ®ion,
&vmgen_gpa);
if (error != 0)
errx(4, "%s: bootrom_alloc", __func__);
error = getentropy(region, sizeof(struct uuid));
if (error == -1)
err(4, "%s: getentropy", __func__);
#if 0
acpi_raise_gpe(ctx, GPE_VMGENC);
#endif
}
void
vmgenc_write_dsdt(void)
{
dsdt_line("");
dsdt_indent(1);
dsdt_line("Scope (_SB)");
dsdt_line("{");
dsdt_line(" Device (GENC)");
dsdt_line(" {");
dsdt_indent(2);
dsdt_line("Name (_CID, \"VM_Gen_Counter\")");
dsdt_line("Method (_HID, 0, NotSerialized)");
dsdt_line("{");
dsdt_line(" Return (\"Bhyve_V_Gen_Counter_V1\")");
dsdt_line("}");
dsdt_line("Name (_UID, 0)");
dsdt_line("Name (_DDN, \"VM_Gen_Counter\")");
dsdt_line("Name (ADDR, Package (0x02)");
dsdt_line("{");
dsdt_line(" 0x%08x,", (uint32_t)vmgen_gpa);
dsdt_line(" 0x%08x", (uint32_t)(vmgen_gpa >> 32));
dsdt_line("})");
dsdt_unindent(2);
dsdt_line(" }");
dsdt_line("}");
dsdt_line("");
dsdt_line("Scope (_GPE)");
dsdt_line("{");
dsdt_line(" Method (_E%02x, 0, NotSerialized)", GPE_VMGENC);
dsdt_line(" {");
dsdt_line(" Notify (\\_SB.GENC, 0x80)");
dsdt_line(" }");
dsdt_line("}");
dsdt_unindent(1);
}