Skip to content

Commit bdf5f91

Browse files
Dan Mileaarnopo
authored andcommitted
Refactor VRING macros for AMP VIRTIO
Renamed AMP VIRTIO macros to avoid conflicts. Signed-off-by: Dan Milea <dan.milea@windriver.com>
1 parent 937ba1d commit bdf5f91

2 files changed

Lines changed: 2 additions & 24 deletions

File tree

lib/include/openamp/virtio.h

Lines changed: 1 addition & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -136,29 +136,7 @@ struct virtio_device_id {
136136
#define VIRTIO_ASSERT(_exp, _msg) metal_assert(_exp)
137137
#endif /* VIRTIO_DEBUG */
138138

139-
#define VRING_ALIGNMENT 4096
140-
141-
#define VIRTIO_RING_SIZE(n, align) \
142-
(( \
143-
( \
144-
sizeof(struct vring_desc) * n + \
145-
sizeof(struct vring_avail) + \
146-
sizeof(uint16_t) * (n + 1) + \
147-
align - 1 \
148-
) \
149-
& ~(align - 1) \
150-
) + \
151-
sizeof(struct vring_used) + \
152-
sizeof(struct vring_used_elem) * n + sizeof(uint16_t))
153-
154-
#define VRING_DECLARE(name, n, align) \
155-
static char __vrbuf_##name[VIRTIO_RING_SIZE(n, align)] __aligned(VRING_ALIGNMENT); \
156-
static struct vring __vring_##name = { \
157-
.desc = (void *)__vrbuf_##name, \
158-
.avail = (void *)((unsigned long)__vrbuf_##name + n * sizeof(struct vring_desc)), \
159-
.used = (void *)((unsigned long)__vrbuf_##name + ((n * sizeof(struct vring_desc) + \
160-
(n + 1) * sizeof(uint16_t) + align - 1) & ~(align - 1))), \
161-
}
139+
#define VIRTIO_MMIO_VRING_ALIGNMENT 4096
162140

163141
typedef void (*virtio_dev_reset_cb)(struct virtio_device *vdev);
164142

lib/virtio_mmio/virtio_mmio_drv.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,7 @@ struct virtqueue *virtio_mmio_setup_virtqueue(struct virtio_device *vdev,
286286

287287
vring_info->io = vmdev->shm_io;
288288
vring_info->info.num_descs = virtio_mmio_get_max_elem(vdev, idx);
289-
vring_info->info.align = VRING_ALIGNMENT;
289+
vring_info->info.align = VIRTIO_MMIO_VRING_ALIGNMENT;
290290

291291
/* Check if vrings are already configured */
292292
if (vq->vq_nentries != 0 && vq->vq_nentries == vq->vq_free_cnt &&

0 commit comments

Comments
 (0)