master
h 47 lines 1.29 KB
Raw
1 /*
2 * VFIO region
3 *
4 * Copyright Red Hat, Inc. 2025
5 *
6 * SPDX-License-Identifier: GPL-2.0-or-later
7 */
8
9 #ifndef HW_VFIO_REGION_H
10 #define HW_VFIO_REGION_H
11
12 #include "system/memory.h"
13
14 typedef struct VFIOMmap {
15 MemoryRegion mem;
16 void *mmap;
17 off_t offset;
18 size_t size;
19 } VFIOMmap;
20
21 typedef struct VFIODevice VFIODevice;
22
23 typedef struct VFIORegion {
24 struct VFIODevice *vbasedev;
25 off_t fd_offset; /* offset of region within device fd */
26 MemoryRegion *mem; /* slow, read/write access */
27 size_t size;
28 uint32_t flags; /* VFIO region flags (rd/wr/mmap) */
29 uint32_t nr_mmaps;
30 VFIOMmap *mmaps;
31 uint8_t nr; /* cache the region number for debug */
32 bool post_wr; /* writes can be posted */
33 } VFIORegion;
34
35
36 void vfio_region_write(void *opaque, hwaddr addr,
37 uint64_t data, unsigned size);
38 uint64_t vfio_region_read(void *opaque,
39 hwaddr addr, unsigned size);
40 int vfio_region_setup(Object *obj, VFIODevice *vbasedev, VFIORegion *region,
41 int index, const char *name, Error **errp);
42 int vfio_region_mmap(VFIORegion *region);
43 void vfio_region_mmaps_set_enabled(VFIORegion *region, bool enabled);
44 void vfio_region_exit(VFIORegion *region);
45 void vfio_region_finalize(VFIORegion *region);
46
47 #endif /* HW_VFIO_REGION_H */