From 53cc29bc8ca5083b9b6075f151824d65557af6f0 Mon Sep 17 00:00:00 2001 From: John Levon Date: Wed, 20 Jan 2021 10:44:49 +0000 Subject: support extended capabilities (#226) Provide initial support for extended capabilities, and implement handlers for the Device Serial Number and Vendor-Specific capabilities. Signed-off-by: John Levon Reviewed-by: Swapnil Ingle --- lib/pci.h | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'lib/pci.h') diff --git a/lib/pci.h b/lib/pci.h index faea75c..4b9f056 100644 --- a/lib/pci.h +++ b/lib/pci.h @@ -45,11 +45,17 @@ pci_config_space_access(vfu_ctx_t *vfu_ctx, char *buf, size_t count, loff_t pos, bool is_write); +static inline size_t +pci_config_space_size(vfu_ctx_t *vfu_ctx) +{ + return vfu_ctx->reg_info[VFU_PCI_DEV_CFG_REGION_IDX].size; +} + static inline uint8_t * pci_config_space_ptr(vfu_ctx_t *vfu_ctx, loff_t offset) { - assert(offset < vfu_ctx->reg_info[VFU_PCI_DEV_CFG_REGION_IDX].size); - return &vfu_ctx->pci.config_space->raw[offset]; + assert((size_t)offset < pci_config_space_size(vfu_ctx)); + return (uint8_t *)vfu_ctx->pci.config_space + offset; } #endif /* LIB_VFIO_USER_PCI_H */ -- cgit v1.1