xref: /illumos-gate/usr/src/cmd/bhyve/pci_passthru.h (revision 32640292)
1 /*-
2  * SPDX-License-Identifier: BSD-2-Clause
3  *
4  * Copyright (c) 2020 Beckhoff Automation GmbH & Co. KG
5  * Author: Corvin K<C3><B6>hne <c.koehne@beckhoff.com>
6  */
7 
8 #ifndef _PCI_PASSTHRU_H_
9 #define _PCI_PASSTHRU_H_
10 
11 #include <vmmapi.h>
12 
13 #include "pci_emul.h"
14 
15 struct passthru_softc;
16 
17 typedef int (*cfgread_handler)(struct passthru_softc *sc,
18     struct pci_devinst *pi, int coff, int bytes, uint32_t *rv);
19 typedef int (*cfgwrite_handler)(struct passthru_softc *sc,
20     struct pci_devinst *pi, int coff, int bytes, uint32_t val);
21 
22 uint32_t read_config(const struct pcisel *sel, long reg, int width);
23 void write_config(const struct pcisel *sel, long reg, int width, uint32_t data);
24 int passthru_cfgread_emulate(struct passthru_softc *sc, struct pci_devinst *pi,
25     int coff, int bytes, uint32_t *rv);
26 int passthru_cfgwrite_emulate(struct passthru_softc *sc, struct pci_devinst *pi,
27     int coff, int bytes, uint32_t val);
28 int set_pcir_handler(struct passthru_softc *sc, int reg, int len,
29     cfgread_handler rhandler, cfgwrite_handler whandler);
30 
31 #endif /* _PCI_PASSTHRU_H_ */
32