Changeset View
Changeset View
Standalone View
Standalone View
usr.sbin/bhyve/pci_xhci.c
Show First 20 Lines • Show All 44 Lines • ▼ Show 20 Lines | |||||
#include <stdint.h> | #include <stdint.h> | ||||
#include <string.h> | #include <string.h> | ||||
#include <errno.h> | #include <errno.h> | ||||
#include <pthread.h> | #include <pthread.h> | ||||
#include <unistd.h> | #include <unistd.h> | ||||
#include <machine/vmm_snapshot.h> | #include <machine/vmm_snapshot.h> | ||||
#ifdef BHYVE_SNAPSHOT | |||||
#include "snapshot.h" | |||||
#endif | |||||
#include <dev/usb/usbdi.h> | #include <dev/usb/usbdi.h> | ||||
#include <dev/usb/usb.h> | #include <dev/usb/usb.h> | ||||
#include <dev/usb/usb_freebsd.h> | #include <dev/usb/usb_freebsd.h> | ||||
#include <xhcireg.h> | #include <xhcireg.h> | ||||
#include "bhyverun.h" | #include "bhyverun.h" | ||||
#include "debug.h" | #include "debug.h" | ||||
#include "pci_emul.h" | #include "pci_emul.h" | ||||
▲ Show 20 Lines • Show All 2,710 Lines • ▼ Show 20 Lines | done: | ||||
return (sc->ndevices); | return (sc->ndevices); | ||||
} | } | ||||
static int | static int | ||||
pci_xhci_init(struct vmctx *ctx, struct pci_devinst *pi, char *opts) | pci_xhci_init(struct vmctx *ctx, struct pci_devinst *pi, char *opts) | ||||
{ | { | ||||
struct pci_xhci_softc *sc; | struct pci_xhci_softc *sc; | ||||
int error; | int error; | ||||
#ifdef BHYVE_SNAPSHOT | |||||
struct vm_snapshot_dev_info *dev_info; | |||||
#endif | |||||
if (xhci_in_use) { | if (xhci_in_use) { | ||||
WPRINTF(("pci_xhci controller already defined")); | WPRINTF(("pci_xhci controller already defined")); | ||||
return (-1); | return (-1); | ||||
} | } | ||||
xhci_in_use = 1; | xhci_in_use = 1; | ||||
sc = calloc(1, sizeof(struct pci_xhci_softc)); | sc = calloc(1, sizeof(struct pci_xhci_softc)); | ||||
▲ Show 20 Lines • Show All 64 Lines • ▼ Show 20 Lines | #endif | ||||
/* regsend + xecp registers */ | /* regsend + xecp registers */ | ||||
pci_emul_alloc_bar(pi, 0, PCIBAR_MEM32, sc->regsend + 4*32); | pci_emul_alloc_bar(pi, 0, PCIBAR_MEM32, sc->regsend + 4*32); | ||||
DPRINTF(("pci_xhci pci_emu_alloc: %d", sc->regsend + 4*32)); | DPRINTF(("pci_xhci pci_emu_alloc: %d", sc->regsend + 4*32)); | ||||
pci_lintr_request(pi); | pci_lintr_request(pi); | ||||
pthread_mutex_init(&sc->mtx, NULL); | pthread_mutex_init(&sc->mtx, NULL); | ||||
#ifdef BHYVE_SNAPSHOT | |||||
dev_info = calloc(1, sizeof(*dev_info)); | |||||
if (!dev_info) { | |||||
fprintf(stderr, "Error allocating space for snapshot struct"); | |||||
error = -1; | |||||
goto done; | |||||
} | |||||
dev_info->dev_name = pi->pi_d->pe_emu; | |||||
dev_info->was_restored = 0; | |||||
dev_info->snapshot_cb = pci_snapshot; | |||||
dev_info->meta_data = pi; | |||||
insert_registered_devs(dev_info); | |||||
#endif | |||||
done: | done: | ||||
if (error) { | if (error) { | ||||
free(sc); | free(sc); | ||||
} | } | ||||
return (error); | return (error); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 263 Lines • Show Last 20 Lines |