Changeset View
Changeset View
Standalone View
Standalone View
usr.sbin/bhyve/pci_passthru.c
Show First 20 Lines • Show All 954 Lines • ▼ Show 20 Lines | if (bytes <= 2) | ||||
return (-1); | return (-1); | ||||
*rv = read_config(&sc->psc_sel, PCIR_STATUS, 2) << 16 | | *rv = read_config(&sc->psc_sel, PCIR_STATUS, 2) << 16 | | ||||
pci_get_cfgdata16(pi, PCIR_COMMAND); | pci_get_cfgdata16(pi, PCIR_COMMAND); | ||||
return (0); | return (0); | ||||
} | } | ||||
static int | |||||
passthru_cfgread_default(struct passthru_softc *sc, | |||||
struct pci_devinst *pi __unused, int coff, int bytes, uint32_t *rv) | |||||
{ | |||||
*rv = read_config(&sc->psc_sel, coff, bytes); | |||||
return (0); | |||||
} | |||||
int | int | ||||
passthru_cfgread_emulate(struct passthru_softc *sc __unused, | passthru_cfgread_emulate(struct passthru_softc *sc __unused, | ||||
struct pci_devinst *pi __unused, int coff __unused, int bytes __unused, | struct pci_devinst *pi __unused, int coff __unused, int bytes __unused, | ||||
uint32_t *rv __unused) | uint32_t *rv __unused) | ||||
{ | { | ||||
return (-1); | return (-1); | ||||
} | } | ||||
static int | static int | ||||
passthru_cfgread(struct pci_devinst *pi, int coff, int bytes, uint32_t *rv) | passthru_cfgread(struct pci_devinst *pi, int coff, int bytes, uint32_t *rv) | ||||
{ | { | ||||
struct passthru_softc *sc; | struct passthru_softc *sc; | ||||
sc = pi->pi_arg; | sc = pi->pi_arg; | ||||
if (sc->psc_pcir_rhandler[coff] != NULL) | if (sc->psc_pcir_rhandler[coff] != NULL) | ||||
return (sc->psc_pcir_rhandler[coff](sc, pi, coff, bytes, rv)); | return (sc->psc_pcir_rhandler[coff](sc, pi, coff, bytes, rv)); | ||||
return (passthru_cfgread_default(sc, pi, coff, bytes, rv)); | *rv = read_config(&sc->psc_sel, coff, bytes); | ||||
return (0); | |||||
} | } | ||||
static int | static int | ||||
passthru_cfgwrite_command(struct passthru_softc *sc, struct pci_devinst *pi, | passthru_cfgwrite_command(struct passthru_softc *sc, struct pci_devinst *pi, | ||||
int coff, int bytes, uint32_t val) | int coff, int bytes, uint32_t val) | ||||
{ | { | ||||
uint16_t cmd_old; | uint16_t cmd_old; | ||||
Show All 16 Lines | if (bytes == 1) | ||||
pci_set_cfgdata8(pi, coff, val); | pci_set_cfgdata8(pi, coff, val); | ||||
else if (bytes == 2) | else if (bytes == 2) | ||||
pci_set_cfgdata16(pi, coff, val); | pci_set_cfgdata16(pi, coff, val); | ||||
pci_emul_cmd_changed(pi, cmd_old); | pci_emul_cmd_changed(pi, cmd_old); | ||||
return (0); | return (0); | ||||
} | } | ||||
static int | |||||
passthru_cfgwrite_default(struct passthru_softc *sc, struct pci_devinst *pi, | |||||
int coff, int bytes, uint32_t val) | |||||
{ | |||||
write_config(&sc->psc_sel, coff, bytes, val); | |||||
return (0); | |||||
} | |||||
int | int | ||||
passthru_cfgwrite_emulate(struct passthru_softc *sc __unused, | passthru_cfgwrite_emulate(struct passthru_softc *sc __unused, | ||||
struct pci_devinst *pi __unused, int coff __unused, int bytes __unused, | struct pci_devinst *pi __unused, int coff __unused, int bytes __unused, | ||||
uint32_t val __unused) | uint32_t val __unused) | ||||
{ | { | ||||
return (-1); | return (-1); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 48 Lines • ▼ Show 20 Lines | |||||
{ | { | ||||
struct passthru_softc *sc; | struct passthru_softc *sc; | ||||
sc = pi->pi_arg; | sc = pi->pi_arg; | ||||
if (sc->psc_pcir_whandler[coff] != NULL) | if (sc->psc_pcir_whandler[coff] != NULL) | ||||
return (sc->psc_pcir_whandler[coff](sc, pi, coff, bytes, val)); | return (sc->psc_pcir_whandler[coff](sc, pi, coff, bytes, val)); | ||||
return (passthru_cfgwrite_default(sc, pi, coff, bytes, val)); | write_config(&sc->psc_sel, coff, bytes, val); | ||||
return (0); | |||||
} | } | ||||
static void | static void | ||||
passthru_write(struct pci_devinst *pi, int baridx, uint64_t offset, int size, | passthru_write(struct pci_devinst *pi, int baridx, uint64_t offset, int size, | ||||
uint64_t value) | uint64_t value) | ||||
{ | { | ||||
struct passthru_softc *sc; | struct passthru_softc *sc; | ||||
struct pci_bar_ioreq pio; | struct pci_bar_ioreq pio; | ||||
▲ Show 20 Lines • Show All 184 Lines • Show Last 20 Lines |