[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [SeaBIOS] [PATCH 07/18] virtio: add version 1.0 read/wr
From: |
Gerd Hoffmann |
Subject: |
Re: [Qemu-devel] [SeaBIOS] [PATCH 07/18] virtio: add version 1.0 read/write macros |
Date: |
Mon, 29 Jun 2015 15:46:54 +0200 |
On Mo, 2015-06-29 at 09:02 -0400, Kevin O'Connor wrote:
> On Mon, Jun 29, 2015 at 10:53:29AM +0200, Gerd Hoffmann wrote:
> > Add macros to read/write registers of virtio-1.0 regions.
> >
> > Signed-off-by: Gerd Hoffmann <address@hidden>
> > ---
> > src/hw/virtio-pci.h | 76
> > +++++++++++++++++++++++++++++++++++++++++++++++++++++
> > 1 file changed, 76 insertions(+)
> >
> > diff --git a/src/hw/virtio-pci.h b/src/hw/virtio-pci.h
> > index 893a7dd..e1d8b3e 100644
> > --- a/src/hw/virtio-pci.h
> > +++ b/src/hw/virtio-pci.h
> > @@ -111,6 +111,82 @@ struct vp_device {
> > struct vp_cap common, notify, isr, device;
> > };
> >
> > +#define vp_modern_read(_cap, _struct, _field, _var) { \
> > + u32 addr = _cap.addr; \
> > + addr += offsetof(_struct, _field); \
>
> Wouldn't this make more sense if the bulk of the code was in a
> function?
The idea is that 'sizeof((_struct *)0)->_field)' evaluates to a
compile-time constant, so gcc can optimize away the bulk of the #define.
Also we don't have to use u64 for _var then (except when it actually is
a 64bit value).
But having 'vp_modern_read(..., var)' in the code instead of 'var =
vp_modern_read(...)' isn't that nice indeed.
> > + if (_cap.is_io) { \
> > + switch (sizeof(((_struct *)0)->_field)) { \
> > + case 8: \
> > + _var = inl(addr); \
> > + _var |= (u64)inl(addr+4) << 32; \
> > + break; \
>
> It didn't look like there were any 64bit fields defined, but maybe I
> missed something.
The is a single one (number of sectors for virtio-blk disks).
cheers,
Gerd
[Qemu-devel] [PATCH 08/18] virtio: make features 64bit, support version 1.0 features, Gerd Hoffmann, 2015/06/29
[Qemu-devel] [PATCH 09/18] virtio: add version 1.0 support to vp_{get, set}_status, Gerd Hoffmann, 2015/06/29
[Qemu-devel] [PATCH 10/18] virtio: add version 1.0 support to vp_get_isr, Gerd Hoffmann, 2015/06/29
[Qemu-devel] [PATCH 11/18] virtio: add version 1.0 support to vp_reset, Gerd Hoffmann, 2015/06/29
[Qemu-devel] [PATCH 13/18] virtio: remove unused vp_del_vq, Gerd Hoffmann, 2015/06/29
[Qemu-devel] [PATCH 12/18] virtio: add version 1.0 support to vp_notify, Gerd Hoffmann, 2015/06/29