2022-03-10 10:26:19 +00:00
|
|
|
/*-
|
2023-05-10 15:40:58 +00:00
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
2022-03-10 10:26:19 +00:00
|
|
|
*
|
|
|
|
* Copyright (c) 2020 Beckhoff Automation GmbH & Co. KG
|
|
|
|
* Author: Corvin Köhne <c.koehne@beckhoff.com>
|
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
2023-05-10 10:31:50 +00:00
|
|
|
#include <sys/linker_set.h>
|
|
|
|
|
2022-03-10 10:26:19 +00:00
|
|
|
#include <vmmapi.h>
|
|
|
|
|
2023-05-10 10:31:50 +00:00
|
|
|
#include "config.h"
|
2022-03-10 10:26:19 +00:00
|
|
|
#include "pci_emul.h"
|
|
|
|
|
2023-05-10 10:22:33 +00:00
|
|
|
struct passthru_mmio_mapping {
|
|
|
|
vm_paddr_t gpa; /* guest physical address */
|
|
|
|
void *gva; /* guest virtual address */
|
|
|
|
vm_paddr_t hpa; /* host physical address */
|
|
|
|
void *hva; /* guest virtual address */
|
|
|
|
vm_paddr_t len;
|
|
|
|
};
|
|
|
|
|
2021-03-19 12:48:34 +00:00
|
|
|
struct passthru_softc;
|
|
|
|
|
2023-05-10 10:31:50 +00:00
|
|
|
struct passthru_dev {
|
|
|
|
int (*probe)(struct pci_devinst *pi);
|
|
|
|
int (*init)(struct pci_devinst *pi, nvlist_t *nvl);
|
|
|
|
void (*deinit)(struct pci_devinst *pi);
|
|
|
|
};
|
|
|
|
#define PASSTHRU_DEV_SET(x) DATA_SET(passthru_dev_set, x)
|
|
|
|
|
2021-03-19 12:48:34 +00:00
|
|
|
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);
|
|
|
|
|
2022-03-10 10:26:19 +00:00
|
|
|
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);
|
2021-09-07 11:42:25 +00:00
|
|
|
int passthru_cfgread_emulate(struct passthru_softc *sc, struct pci_devinst *pi,
|
|
|
|
int coff, int bytes, uint32_t *rv);
|
|
|
|
int passthru_cfgwrite_emulate(struct passthru_softc *sc, struct pci_devinst *pi,
|
|
|
|
int coff, int bytes, uint32_t val);
|
2023-05-10 10:22:33 +00:00
|
|
|
struct passthru_mmio_mapping *passthru_get_mmio(struct passthru_softc *sc,
|
|
|
|
int num);
|
2023-05-10 10:19:49 +00:00
|
|
|
struct pcisel *passthru_get_sel(struct passthru_softc *sc);
|
2021-03-19 12:48:34 +00:00
|
|
|
int set_pcir_handler(struct passthru_softc *sc, int reg, int len,
|
|
|
|
cfgread_handler rhandler, cfgwrite_handler whandler);
|