* [PATCH 0/2] hw/core/register: Add more 64-bit utilities
@ 2021-07-19 20:16 Joe Komlodi
2021-07-19 20:16 ` [PATCH 1/2] " Joe Komlodi
2021-07-19 20:16 ` [PATCH 2/2] hw/registerfields: Use 64-bit bitfield for FIELD_DP64 Joe Komlodi
0 siblings, 2 replies; 4+ messages in thread
From: Joe Komlodi @ 2021-07-19 20:16 UTC (permalink / raw)
To: qemu-devel; +Cc: alistair
Hi all,
This adds more utilities for 64-bit registers.
As part of it, it also fixes FIELD_DP64 to work with bit fields wider than
32-bits.
Thanks!
Joe
Joe Komlodi (2):
hw/core/register: Add more 64-bit utilities
hw/registerfields: Use 64-bit bitfield for FIELD_DP64
hw/core/register.c | 12 ++++++++++++
include/hw/register.h | 8 ++++++++
include/hw/registerfields.h | 10 +++++++++-
3 files changed, 29 insertions(+), 1 deletion(-)
--
2.7.4
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH 1/2] hw/core/register: Add more 64-bit utilities
2021-07-19 20:16 [PATCH 0/2] hw/core/register: Add more 64-bit utilities Joe Komlodi
@ 2021-07-19 20:16 ` Joe Komlodi
2021-07-19 20:16 ` [PATCH 2/2] hw/registerfields: Use 64-bit bitfield for FIELD_DP64 Joe Komlodi
1 sibling, 0 replies; 4+ messages in thread
From: Joe Komlodi @ 2021-07-19 20:16 UTC (permalink / raw)
To: qemu-devel; +Cc: alistair
We already have some utilities to handle 64-bit wide registers, so this just
adds some more for:
- Initializing 64-bit registers
- Extracting and depositing to an array of 64-bit registers
Signed-off-by: Joe Komlodi <joe.komlodi@xilinx.com>
---
hw/core/register.c | 12 ++++++++++++
include/hw/register.h | 8 ++++++++
include/hw/registerfields.h | 8 ++++++++
3 files changed, 28 insertions(+)
diff --git a/hw/core/register.c b/hw/core/register.c
index d6f8c20..ab20258 100644
--- a/hw/core/register.c
+++ b/hw/core/register.c
@@ -300,6 +300,18 @@ RegisterInfoArray *register_init_block32(DeviceState *owner,
data, ops, debug_enabled, memory_size, 32);
}
+RegisterInfoArray *register_init_block64(DeviceState *owner,
+ const RegisterAccessInfo *rae,
+ int num, RegisterInfo *ri,
+ uint32_t *data,
+ const MemoryRegionOps *ops,
+ bool debug_enabled,
+ uint64_t memory_size)
+{
+ return register_init_block(owner, rae, num, ri, (void *)
+ data, ops, debug_enabled, memory_size, 64);
+}
+
void register_finalize_block(RegisterInfoArray *r_array)
{
object_unparent(OBJECT(&r_array->mem));
diff --git a/include/hw/register.h b/include/hw/register.h
index b480e38..0197e45 100644
--- a/include/hw/register.h
+++ b/include/hw/register.h
@@ -204,6 +204,14 @@ RegisterInfoArray *register_init_block32(DeviceState *owner,
bool debug_enabled,
uint64_t memory_size);
+RegisterInfoArray *register_init_block64(DeviceState *owner,
+ const RegisterAccessInfo *rae,
+ int num, RegisterInfo *ri,
+ uint32_t *data,
+ const MemoryRegionOps *ops,
+ bool debug_enabled,
+ uint64_t memory_size);
+
/**
* This function should be called to cleanup the registers that were initialized
* when calling register_init_block32(). This function should only be called
diff --git a/include/hw/registerfields.h b/include/hw/registerfields.h
index 93fa4a8..9a03ac5 100644
--- a/include/hw/registerfields.h
+++ b/include/hw/registerfields.h
@@ -30,6 +30,10 @@
enum { A_ ## reg = (addr) }; \
enum { R_ ## reg = (addr) / 2 };
+#define REG64(reg, addr) \
+ enum { A_ ## reg = (addr) }; \
+ enum { R_ ## reg = (addr) / 8 };
+
/* Define SHIFT, LENGTH and MASK constants for a field within a register */
/* This macro will define R_FOO_BAR_MASK, R_FOO_BAR_SHIFT and R_FOO_BAR_LENGTH
@@ -58,6 +62,8 @@
/* Extract a field from an array of registers */
#define ARRAY_FIELD_EX32(regs, reg, field) \
FIELD_EX32((regs)[R_ ## reg], reg, field)
+#define ARRAY_FIELD_EX64(regs, reg, field) \
+ FIELD_EX64((regs)[R_ ## reg], reg, field)
/* Deposit a register field.
* Assigning values larger then the target field will result in
@@ -99,5 +105,7 @@
/* Deposit a field to array of registers. */
#define ARRAY_FIELD_DP32(regs, reg, field, val) \
(regs)[R_ ## reg] = FIELD_DP32((regs)[R_ ## reg], reg, field, val);
+#define ARRAY_FIELD_DP64(regs, reg, field, val) \
+ (regs)[R_ ## reg] = FIELD_DP64((regs)[R_ ## reg], reg, field, val);
#endif
--
2.7.4
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH 2/2] hw/registerfields: Use 64-bit bitfield for FIELD_DP64
2021-07-19 20:16 [PATCH 0/2] hw/core/register: Add more 64-bit utilities Joe Komlodi
2021-07-19 20:16 ` [PATCH 1/2] " Joe Komlodi
@ 2021-07-19 20:16 ` Joe Komlodi
2021-07-19 21:31 ` Richard Henderson
1 sibling, 1 reply; 4+ messages in thread
From: Joe Komlodi @ 2021-07-19 20:16 UTC (permalink / raw)
To: qemu-devel; +Cc: alistair
If we have a field that's wider than 32-bits, we need a data type wide enough to
be able to create the bitfield used to deposit the value.
Signed-off-by: Joe Komlodi <joe.komlodi@xilinx.com>
---
include/hw/registerfields.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/include/hw/registerfields.h b/include/hw/registerfields.h
index 9a03ac5..f7bfa1f 100644
--- a/include/hw/registerfields.h
+++ b/include/hw/registerfields.h
@@ -95,7 +95,7 @@
_d; })
#define FIELD_DP64(storage, reg, field, val) ({ \
struct { \
- unsigned int v:R_ ## reg ## _ ## field ## _LENGTH; \
+ unsigned long v:R_ ## reg ## _ ## field ## _LENGTH; \
} _v = { .v = val }; \
uint64_t _d; \
_d = deposit64((storage), R_ ## reg ## _ ## field ## _SHIFT, \
--
2.7.4
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH 2/2] hw/registerfields: Use 64-bit bitfield for FIELD_DP64
2021-07-19 20:16 ` [PATCH 2/2] hw/registerfields: Use 64-bit bitfield for FIELD_DP64 Joe Komlodi
@ 2021-07-19 21:31 ` Richard Henderson
0 siblings, 0 replies; 4+ messages in thread
From: Richard Henderson @ 2021-07-19 21:31 UTC (permalink / raw)
To: Joe Komlodi, qemu-devel; +Cc: alistair
On 7/19/21 10:16 AM, Joe Komlodi wrote:
> #define FIELD_DP64(storage, reg, field, val) ({ \
> struct { \
> - unsigned int v:R_ ## reg ## _ ## field ## _LENGTH; \
> + unsigned long v:R_ ## reg ## _ ## field ## _LENGTH; \
Won't work for a 32-bit host. Use uint64_t.
r~
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2021-07-19 21:33 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-19 20:16 [PATCH 0/2] hw/core/register: Add more 64-bit utilities Joe Komlodi
2021-07-19 20:16 ` [PATCH 1/2] " Joe Komlodi
2021-07-19 20:16 ` [PATCH 2/2] hw/registerfields: Use 64-bit bitfield for FIELD_DP64 Joe Komlodi
2021-07-19 21:31 ` Richard Henderson
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.