aboutsummaryrefslogtreecommitdiff
path: root/usr.sbin/bhyve/pci_gvt-d.c
blob: 767b8ee3127f42916d8fcb7398f932b0384fe61a (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
/*-
 * SPDX-License-Identifier: BSD-2-Clause
 *
 * Copyright (c) 2020 Beckhoff Automation GmbH & Co. KG
 * Author: Corvin Köhne <c.koehne@beckhoff.com>
 */

#include <sys/types.h>

#include <dev/pci/pcireg.h>

#include <errno.h>

#include "pci_gvt-d-opregion.h"
#include "pci_passthru.h"

#define PCI_VENDOR_INTEL 0x8086

static int
gvt_d_probe(struct pci_devinst *const pi)
{
	struct passthru_softc *sc;
	uint16_t vendor;
	uint8_t class;

	sc = pi->pi_arg;

	vendor = read_config(passthru_get_sel(sc), PCIR_VENDOR, 0x02);
	if (vendor != PCI_VENDOR_INTEL)
		return (ENXIO);

	class = read_config(passthru_get_sel(sc), PCIR_CLASS, 0x01);
	if (class != PCIC_DISPLAY)
		return (ENXIO);

	return (0);
}

static int
gvt_d_init(struct pci_devinst *const pi __unused, nvlist_t *const nvl __unused)
{
	return (0);
}

static void
gvt_d_deinit(struct pci_devinst *const pi __unused)
{
}

static struct passthru_dev gvt_d_dev = {
	.probe = gvt_d_probe,
	.init = gvt_d_init,
	.deinit = gvt_d_deinit,
};
PASSTHRU_DEV_SET(gvt_d_dev);