aboutsummaryrefslogtreecommitdiff
path: root/samples/gpio-pci-idio-16.c
diff options
context:
space:
mode:
authorJohn Levon <john.levon@nutanix.com>2021-01-04 17:53:10 +0000
committerGitHub <noreply@github.com>2021-01-04 17:53:10 +0000
commit1fa90d5abecd896362e551b2bd2ec987d8f60a6b (patch)
tree6bcb22c92d2bf52c1baf6786a644d4abbbd09604 /samples/gpio-pci-idio-16.c
parent715b7963312002980b9eea5a695719cfdf2bf6e4 (diff)
downloadlibvfio-user-1fa90d5abecd896362e551b2bd2ec987d8f60a6b.zip
libvfio-user-1fa90d5abecd896362e551b2bd2ec987d8f60a6b.tar.gz
libvfio-user-1fa90d5abecd896362e551b2bd2ec987d8f60a6b.tar.bz2
re-work PCI config setup API (#198)
Split up vfu_pci_setup_config_hdr(): individual "helpers" like vfu_pci_set_id() are much simpler to use than making the user specify the values in header-formatted structs; and this way if we want to add additional helpers, we won't need to modify the existing functions. Signed-off-by: John Levon <john.levon@nutanix.com> Reviewed-by: Thanos Makatos <thanos.makatos@nutanix.com>
Diffstat (limited to 'samples/gpio-pci-idio-16.c')
-rw-r--r--samples/gpio-pci-idio-16.c12
1 files changed, 5 insertions, 7 deletions
diff --git a/samples/gpio-pci-idio-16.c b/samples/gpio-pci-idio-16.c
index 08f2cca..350d11f 100644
--- a/samples/gpio-pci-idio-16.c
+++ b/samples/gpio-pci-idio-16.c
@@ -75,9 +75,6 @@ main(int argc, char *argv[])
char opt;
struct sigaction act = { .sa_handler = _sa_handler };
vfu_ctx_t *vfu_ctx;
- vfu_pci_hdr_id_t id = { .vid = 0x494F, .did = 0x0DC8 };
- vfu_pci_hdr_ss_t ss = { .vid = 0x0, .sid = 0x0 };
- vfu_pci_hdr_cc_t cc = { { 0 } };
while ((opt = getopt(argc, argv, "v")) != -1) {
switch (opt) {
@@ -114,13 +111,14 @@ main(int argc, char *argv[])
err(EXIT_FAILURE, "failed to setup log");
}
- ret = vfu_pci_setup_config_hdr(vfu_ctx, id, ss, cc,
- VFU_PCI_TYPE_CONVENTIONAL, 0);
+ ret = vfu_pci_init(vfu_ctx, VFU_PCI_TYPE_CONVENTIONAL,
+ PCI_HEADER_TYPE_NORMAL, 0);
if (ret < 0) {
- fprintf(stderr, "failed to setup pci header\n");
- goto out;
+ err(EXIT_FAILURE, "vfu_pci_init() failed");
}
+ vfu_pci_set_id(vfu_ctx, 0x494f, 0x0dc8, 0x0, 0x0);
+
ret = vfu_setup_region(vfu_ctx, VFU_PCI_DEV_BAR2_REGION_IDX, 0x100,
&bar2_access, VFU_REGION_FLAG_RW, NULL, 0, -1);
if (ret < 0) {