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