Trivial changes in "registerfields.h"
cover Trivial changes in "registerfields.h"
Philippe Mathieu-Daudé (4):
MAINTAINERS: add "hw/registerfields.h" in Register API entry hw/registerfields: fix a typo in the FIELD() documentation hw/registerfields: add 64-bit extract/deposit macros hw/registerfields: add missing include
include/hw/registerfields.h | 15 ++++++++++++++- MAINTAINERS | 1 + 2 files changed, 15 insertions(+), 1 deletion(-)
Signature · 1 line
2.15.1
PATCH 1/4 MAINTAINERS: add "hw/registerfields.h" in Register API entry
Orphan since afb3141c660
--- MAINTAINERS | 1 + 1 file changed, 1 insertion(+)
MAINTAINERS +1 -0
@@ -1538,6 +1538,7 @@ M: Alistair Francis <[email protected]> S: Maintained F: hw/core/register.c F: include/hw/register.h +F: include/hw/registerfields.h SLIRP M: Samuel Thibault <[email protected]>
Signature · 1 line
2.15.1
PATCH 2/4 hw/registerfields: fix a typo in the FIELD() documentation
In reply to Philippe Mathieu-Daudé--- include/hw/registerfields.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
include/hw/registerfields.h +1 -1
@@ -22,7 +22,7 @@/* Define SHIFT, LENGTH and MASK constants for a field within a register */ -/* This macro will define FOO_BAR_MASK, FOO_BAR_SHIFT and FOO_BAR_LENGTH +/* This macro will define R_FOO_BAR_MASK, R_FOO_BAR_SHIFT and R_FOO_BAR_LENGTH * constants for field BAR in register FOO. */ #define FIELD (reg, field, shift, length) \
Signature · 1 line
2.15.1
PATCH 3/4 hw/registerfields: add 64-bit extract/deposit macros
In reply to Philippe Mathieu-Daudé--- include/hw/registerfields.h | 11 +++++++++++ 1 file changed, 11 insertions(+)
include/hw/registerfields.h +11 -0
@@ -35,6 +35,9 @@#define FIELD_EX32 (storage, reg, field) \ extract32((storage), R_ ## reg ## _ ## field ## _SHIFT, \ R_ ## reg ## _ ## field ## _LENGTH) +#define FIELD_EX64 (storage, reg, field) \ + extract64((storage), R_ ## reg ## _ ## field ## _SHIFT, \ + R_ ## reg ## _ ## field ## _LENGTH)/* Extract a field from an array of registers */ #define ARRAY_FIELD_EX32 (regs, reg, field) \
@@ -52,6 +55,14 @@ d = deposit32((storage), R_ ## reg ## _ ## field ## _SHIFT, \ R_ ## reg ## _ ## field ## _LENGTH, v.v); \ d; }) +#define FIELD_DP64 (storage, reg, field, val) ({ \ + struct { \ + unsigned int v:R_ ## reg ## _ ## field ## _LENGTH; \ + } v = { .v = val }; \ + uint64_t d; \ + d = deposit64((storage), R_ ## reg ## _ ## field ## _SHIFT, \ + R_ ## reg ## _ ## field ## _LENGTH, v.v); \ + d; })/* Deposit a field to array of registers. */ #define ARRAY_FIELD_DP32 (regs, reg, field, val) \
Signature · 1 line
2.15.1
Re: [Qemu-devel] [PATCH 3/4] hw/registerfields: add 64-bit extract/deposit macros
Quoted 33 lines · Philippe Mathieu-Daudé
Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- include/hw/registerfields.h | 11 +++++++++++ 1 file changed, 11 insertions(+)include/hw/registerfields.h +3
-0@@ -35,6 +35,9 @@#define FIELD_EX32 (storage, reg, field) \ extract32((storage), R_ ## reg ## _ ## field ## _SHIFT, \ R_ ## reg ## _ ## field ## _LENGTH) +#define FIELD_EX64 (storage, reg, field) \ + extract64((storage), R_ ## reg ## _ ## field ## _SHIFT, \ + R_ ## reg ## _ ## field ## _LENGTH) /* Extract a field from an array of registers */#define ARRAY_FIELD_EX32 (regs, reg, field)\
include/hw/registerfields.h +2
-0@@ -52,6 +55,14 @@ d = deposit32((storage), R_ ## reg ## _ ## field ## _SHIFT, \ R_ ## reg ## _ ## field ## _LENGTH, v.v); \ d; }) +#define FIELD_DP64 (storage, reg, field, val) ({ \ + struct {
Quoted 4 lines
\
+ unsigned int v:R_ ## reg ## _ ## field ##_LENGTH;
\
Hi Phiilppe,
I'm just wondering if 'v' above maybe should be uint64_t? The size of unsigned int seems to be 'implementation defined' but I would guess 32 bits is not unsual. Basically wouldn't a field length > 32 above be problematic?
Best regards,
Francisco
Quoted 18 lines
include/hw/registerfields.h +5
-1+ } v = { .v = val }; \ +uint64_t d; \ + d = deposit64((storage), R_ ## reg ## _ ## field ## _SHIFT, \ + R_ ## reg ## _ ## field ## _LENGTH, v.v); \ + d; })/* Deposit a field to array of registers. */ #define ARRAY_FIELD_DP32 (regs, reg, field, val) \ --2.15.1
Re: [Qemu-devel] [PATCH 3/4] hw/registerfields: add 64-bit extract/deposit macros
Hi Francisco,
Quoted 2 lines · francisco iglesias
On 13 December 2017 at 06:17, Philippe Mathieu-Daudé <[email protected]> wrote:
[...]
Quoted 1 line
Quoted 1 line
/* Extract a field from an array of registers */
[...]
Quoted 11 lines
Quoted 7 lines
(quoted diff) +2
-0+#define FIELD_DP64(storage, reg, field, val) ({ \ + struct {\
+ unsigned int v:R_ ## reg ## _ ## field ##_LENGTH;
\I'm just wondering if 'v' above maybe should be
uint64_t? The size of unsigned int seems to be 'implementation defined' but I would guess 32 bits is not unsual. Basically wouldn't a field length > 32 above be problematic?
Good remark...
As per the standard bitfields access must be per 'unsigned'. So with a LP64 data model we have sizeof(unsigned) = 32-bit, I wonder how the compiler behaves.
I added the debian-win32 docker image to tests this kind of regressions, but it seems the current toolchain used (mingw-w64) is now only a LLP64 model (I still need to verify).
I remember I somewhere have a Linux/X32 docker suite to test this series. I'll give it a try (I doubt before this week-end).
Regards,
Phil.
Quoted 15 lines
Quoted 15 lines
(quoted diff) +5
-1+ } v = { .v = val }; \ + uint64_t d; \ + d = deposit64((storage), R_ ## reg ## _ ## field ## _SHIFT, \ + R_ ## reg ## _ ## field ## _LENGTH, v.v); \ + d; }) /* Deposit a field to array of registers. */ #define ARRAY_FIELD_DP32(regs, reg, field, val) \ --2.15.1
PATCH 4/4 hw/registerfields: add missing include
In reply to Philippe Mathieu-DaudéThis allows to use this header in qtests.
This fixes:
CC tests/test.o
include/hw/registerfields.h:32:41: error: implicit declaration of function ‘MAKE_64BIT_MASK’ [-Werror=implicit-function-declaration]
MAKE_64BIT_MASK(shift, length)};
^
include/hw/registerfields.h:39:5: error: implicit declaration of function ‘extract64’; [-Werror=implicit-function-declaration]
extract64((storage), R_ ## reg ## _ ## field ## _SHIFT,
^--- include/hw/registerfields.h | 2 ++ 1 file changed, 2 insertions(+)
include/hw/registerfields.h +2 -0
@@ -11,6 +11,8 @@#ifndef REGISTERFIELDS_H #define REGISTERFIELDS_H +#include <qemu/bitops.h> +/* Define constants for a 32 bit register */ /* This macro will define A_FOO, for the byte address of a register
Signature · 1 line
2.15.1
Looks good to me, for all patches:
Thanks,
Darren.
Quoted 14 lines · Philippe Mathieu-Daudé
Philippe Mathieu-Daudé (4):
MAINTAINERS: add "hw/registerfields.h" in Register API entry hw/registerfields: fix a typo in theFIELD()documentation hw/registerfields: add 64-bit extract/deposit macros hw/registerfields: add missing include
include/hw/registerfields.h| 15 ++++++++++++++-MAINTAINERS| 1 +2 files changed, 15 insertions(+), 1 deletion(-)Signature · 1 line
2.15.1
Alistair Francis
Reviewed-byQuoted 3 lines · Darren Kenny
Looks good to me, for all patches:
Reviewed-by Darren Kenny <[email protected]>
Same, for all four patches.
Alistair
Quoted 23 lines
Thanks,
Darren.
Quoted 15 lines · Philippe Mathieu-Daudé
Philippe Mathieu-Daudé (4):
MAINTAINERS: add "hw/registerfields.h" in Register API entry hw/registerfields: fix a typo in theFIELD()documentation hw/registerfields: add 64-bit extract/deposit macros hw/registerfields: add missing include
include/hw/registerfields.h| 15 ++++++++++++++-MAINTAINERS| 1 +2 files changed, 15 insertions(+), 1 deletion(-)--
2.15.1
Quoted 9 lines · Philippe Mathieu-Daudé
Philippe Mathieu-Daudé (4):
MAINTAINERS: add "hw/registerfields.h" in Register API entry hw/registerfields: fix a typo in theFIELD()documentation hw/registerfields: add 64-bit extract/deposit macros hw/registerfields: add missing includeinclude/hw/registerfields.h | 15 ++++++++++++++- MAINTAINERS | 1 + 2 files changed, 15 insertions(+), 1 deletion(-)