Changeset View
Changeset View
Standalone View
Standalone View
usr.sbin/bhyve/pci_passthru.h
/*- | /*- | ||||
* SPDX-License-Identifier: BSD-2-Clause-FreeBSD | * SPDX-License-Identifier: BSD-2-Clause-FreeBSD | ||||
* | * | ||||
* Copyright (c) 2020 Beckhoff Automation GmbH & Co. KG | * Copyright (c) 2020 Beckhoff Automation GmbH & Co. KG | ||||
* Author: Corvin Köhne <c.koehne@beckhoff.com> | * Author: Corvin Köhne <c.koehne@beckhoff.com> | ||||
*/ | */ | ||||
#pragma once | #pragma once | ||||
#include <vmmapi.h> | #include <vmmapi.h> | ||||
#include "pci_emul.h" | #include "pci_emul.h" | ||||
struct passthru_softc; | |||||
typedef int (*cfgread_handler)(struct passthru_softc *sc, | |||||
struct pci_devinst *pi, int coff, int bytes, uint32_t *rv); | |||||
typedef int (*cfgwrite_handler)(struct passthru_softc *sc, | |||||
struct pci_devinst *pi, int coff, int bytes, uint32_t val); | |||||
struct passthru_softc { | struct passthru_softc { | ||||
struct pci_devinst *psc_pi; | struct pci_devinst *psc_pi; | ||||
/* ROM is handled like a BAR */ | /* ROM is handled like a BAR */ | ||||
struct pcibar psc_bar[PCI_BARMAX_WITH_ROM + 1]; | struct pcibar psc_bar[PCI_BARMAX_WITH_ROM + 1]; | ||||
struct { | struct { | ||||
int capoff; | int capoff; | ||||
int msgctrl; | int msgctrl; | ||||
int emulated; | int emulated; | ||||
} psc_msi; | } psc_msi; | ||||
struct { | struct { | ||||
int capoff; | int capoff; | ||||
} psc_msix; | } psc_msix; | ||||
struct pcisel psc_sel; | struct pcisel psc_sel; | ||||
cfgread_handler psc_pcir_rhandler[PCI_REGMAX + 1]; | |||||
cfgwrite_handler psc_pcir_whandler[PCI_REGMAX + 1]; | |||||
}; | }; | ||||
uint32_t read_config(const struct pcisel *sel, long reg, int width); | uint32_t read_config(const struct pcisel *sel, long reg, int width); | ||||
void write_config(const struct pcisel *sel, long reg, int width, uint32_t data); | void write_config(const struct pcisel *sel, long reg, int width, uint32_t data); | ||||
int passthru_cfgread_default(struct passthru_softc *sc, struct pci_devinst *pi, | |||||
int coff, int bytes, uint32_t *rv); | |||||
int passthru_cfgwrite_default(struct passthru_softc *sc, struct pci_devinst *pi, | |||||
int coff, int bytes, uint32_t val); | |||||
int set_pcir_handler(struct passthru_softc *sc, int reg, int len, | |||||
cfgread_handler rhandler, cfgwrite_handler whandler); |