Changeset View
Changeset View
Standalone View
Standalone View
usr.sbin/bhyve/pci_fbuf.c
Show First 20 Lines • Show All 210 Lines • ▼ Show 20 Lines | pci_fbuf_read(struct vmctx *ctx, int vcpu, struct pci_devinst *pi, | ||||
DPRINTF(DEBUG_VERBOSE, | DPRINTF(DEBUG_VERBOSE, | ||||
("fbuf rd: offset 0x%lx, size: %d, value: 0x%lx", | ("fbuf rd: offset 0x%lx, size: %d, value: 0x%lx", | ||||
offset, size, value)); | offset, size, value)); | ||||
return (value); | return (value); | ||||
} | } | ||||
static void | |||||
pci_fbuf_baraddr(struct vmctx *ctx, struct pci_devinst *pi, int baridx, | |||||
int enabled, uint64_t address) | |||||
{ | |||||
struct pci_fbuf_softc *sc; | |||||
int prot; | |||||
if (baridx != 1) | |||||
return; | |||||
sc = pi->pi_arg; | |||||
if (!enabled && sc->fbaddr != 0) { | |||||
if (vm_munmap_memseg(ctx, sc->fbaddr, FB_SIZE) != 0) | |||||
EPRINTLN("pci_fbuf: munmap_memseg failed"); | |||||
sc->fbaddr = 0; | |||||
} else if (sc->fb_base != NULL && sc->fbaddr == 0) { | |||||
prot = PROT_READ | PROT_WRITE; | |||||
if (vm_mmap_memseg(ctx, address, VM_FRAMEBUFFER, 0, FB_SIZE, prot) != 0) | |||||
EPRINTLN("pci_fbuf: mmap_memseg failed"); | |||||
sc->fbaddr = address; | |||||
} | |||||
} | |||||
static int | static int | ||||
pci_fbuf_parse_config(struct pci_fbuf_softc *sc, nvlist_t *nvl) | pci_fbuf_parse_config(struct pci_fbuf_softc *sc, nvlist_t *nvl) | ||||
{ | { | ||||
const char *value; | const char *value; | ||||
char *cp; | char *cp; | ||||
sc->rfb_wait = get_config_bool_node_default(nvl, "wait", false); | sc->rfb_wait = get_config_bool_node_default(nvl, "wait", false); | ||||
▲ Show 20 Lines • Show All 225 Lines • ▼ Show 20 Lines | |||||
} | } | ||||
#endif | #endif | ||||
struct pci_devemu pci_fbuf = { | struct pci_devemu pci_fbuf = { | ||||
.pe_emu = "fbuf", | .pe_emu = "fbuf", | ||||
.pe_init = pci_fbuf_init, | .pe_init = pci_fbuf_init, | ||||
.pe_barwrite = pci_fbuf_write, | .pe_barwrite = pci_fbuf_write, | ||||
.pe_barread = pci_fbuf_read, | .pe_barread = pci_fbuf_read, | ||||
.pe_baraddr = pci_fbuf_baraddr, | |||||
#ifdef BHYVE_SNAPSHOT | #ifdef BHYVE_SNAPSHOT | ||||
.pe_snapshot = pci_fbuf_snapshot, | .pe_snapshot = pci_fbuf_snapshot, | ||||
#endif | #endif | ||||
}; | }; | ||||
PCI_EMUL_SET(pci_fbuf); | PCI_EMUL_SET(pci_fbuf); |