Changeset View
Changeset View
Standalone View
Standalone View
usr.sbin/bhyve/pci_e82545.c
Show First 20 Lines • Show All 42 Lines • ▼ Show 20 Lines | |||||
#include <netinet/in.h> | #include <netinet/in.h> | ||||
#include <netinet/tcp.h> | #include <netinet/tcp.h> | ||||
#ifndef WITHOUT_CAPSICUM | #ifndef WITHOUT_CAPSICUM | ||||
#include <capsicum_helpers.h> | #include <capsicum_helpers.h> | ||||
#endif | #endif | ||||
#include <machine/vmm_snapshot.h> | #include <machine/vmm_snapshot.h> | ||||
#ifdef BHYVE_SNAPSHOT | |||||
#include "snapshot.h" | |||||
#endif | |||||
#include <err.h> | #include <err.h> | ||||
#include <errno.h> | #include <errno.h> | ||||
#include <fcntl.h> | #include <fcntl.h> | ||||
#include <md5.h> | #include <md5.h> | ||||
#include <stdio.h> | #include <stdio.h> | ||||
#include <stdlib.h> | #include <stdlib.h> | ||||
#include <string.h> | #include <string.h> | ||||
#include <sysexits.h> | #include <sysexits.h> | ||||
▲ Show 20 Lines • Show All 2,220 Lines • ▼ Show 20 Lines | |||||
static int | static int | ||||
e82545_init(struct vmctx *ctx, struct pci_devinst *pi, char *opts) | e82545_init(struct vmctx *ctx, struct pci_devinst *pi, char *opts) | ||||
{ | { | ||||
char nstr[80]; | char nstr[80]; | ||||
struct e82545_softc *sc; | struct e82545_softc *sc; | ||||
char *optscopy; | char *optscopy; | ||||
char *vtopts; | char *vtopts; | ||||
int mac_provided; | int mac_provided; | ||||
#ifdef BHYVE_SNAPSHOT | |||||
struct vm_snapshot_dev_info *dev_info; | |||||
#endif | |||||
DPRINTF("Loading with options: %s", opts); | DPRINTF("Loading with options: %s", opts); | ||||
/* Setup our softc */ | /* Setup our softc */ | ||||
sc = calloc(1, sizeof(*sc)); | sc = calloc(1, sizeof(*sc)); | ||||
pi->pi_arg = sc; | pi->pi_arg = sc; | ||||
sc->esc_pi = pi; | sc->esc_pi = pi; | ||||
sc->esc_ctx = ctx; | sc->esc_ctx = ctx; | ||||
▲ Show 20 Lines • Show All 78 Lines • ▼ Show 20 Lines | #endif | ||||
if (!mac_provided) { | if (!mac_provided) { | ||||
net_genmac(pi, sc->esc_mac.octet); | net_genmac(pi, sc->esc_mac.octet); | ||||
} | } | ||||
netbe_rx_enable(sc->esc_be); | netbe_rx_enable(sc->esc_be); | ||||
/* H/w initiated reset */ | /* H/w initiated reset */ | ||||
e82545_reset(sc, 0); | e82545_reset(sc, 0); | ||||
#ifdef BHYVE_SNAPSHOT | |||||
dev_info = calloc(1, sizeof(*dev_info)); | |||||
if (!dev_info) { | |||||
fprintf(stderr, "Error allocating space for snapshot struct"); | |||||
return (-1); | |||||
} | |||||
dev_info->dev_name = pi->pi_d->pe_emu; | |||||
dev_info->snapshot_cb = pci_snapshot; | |||||
dev_info->meta_data = pi; | |||||
insert_registered_devs(dev_info); | |||||
#endif | |||||
return (0); | return (0); | ||||
} | } | ||||
#ifdef BHYVE_SNAPSHOT | #ifdef BHYVE_SNAPSHOT | ||||
static int | static int | ||||
e82545_snapshot(struct vm_snapshot_meta *meta) | e82545_snapshot(struct vm_snapshot_meta *meta) | ||||
{ | { | ||||
▲ Show 20 Lines • Show All 161 Lines • Show Last 20 Lines |