Skip to content

data-driven device registers

Alistair Francis qemu-devel 9 versions – Applied

Status from this message: Thanks, applied to target-arm.next. (You still had a typo

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v9 Latest8 patches 2 repliesApplied
  2. v88 patches 7 repliesSuperseded
  3. v711 of 12 patches 15 repliesSuperseded
Earlier versions · 6
VersionPostedPatchesRepliesStatus
v612 of 13 patches28 repliesSuperseded
v514 of 15 patches10 repliesSuperseded
v415 of 16 patches19 repliesSuperseded
v315 of 16 patches11 repliesSuperseded
v216 patches12 repliesSuperseded
v115 patches16 repliesSuperseded

Changes in v9 from the cover letter

- Fixup the finalise function

Patches in v9 Applied

#Subject and filesSizeRepliesApplied
1/8bitops: Add MAKE_64BIT_MASK macroinclude/qemu/bitops.h+3 -00 replies
2/8register: Add Register APIhw/core/Makefile.objs hw/core/register.c include/hw/register.h+273 -00 replies
3/8register: Add Memory API gluehw/core/register.c include/hw/register.h+102 -00 replies
4/8register: Define REG and FIELD macrosinclude/hw/register.h+46 -00 replies
5/8register: QOMifyhw/core/register.c include/hw/register.h+37 -00 replies
6/8register: Add block initialise helperhw/core/register.c include/hw/register.h+84 -00 replies
7/8dma: Add Xilinx Zynq devcfg device modeldefault-configs/arm-softmmu.mak hw/dma/Makefile.objs hw/dma/xlnx-zynq-devcfg.c +1 more+464 -00 replies
8/8xilinx_zynq: Connect devcfg to the Zynq machine modelhw/arm/xilinx_zynq.c+6 -00 replies

Reviews trailers per patch

6 of 8 patches have a Reviewed-by or Acked-by.

PatchAlex BennéePeter MaydellKONRAD Frederic
1/8R-b R-b
2/8R-b R-b
3/8
4/8R-b
5/8R-b R-b
6/8
7/8R-b
8/8R-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes. Scroll the table sideways for all 3 reviewers.

Read the v9 thread

Cover letter [Qemu-devel] [PATCH v9 0/8] data-driven device registers

This patch series is based on Peter C's original register API. His original cover letter is below.

Future work: Allow support for memory attributes.

V9:
- Fixup the finalise function
V8:
- Remove GPIO infrastructure from patch set
V7:
- Rebase
- Fixup the DecCFG model
- Fixes and corrections to the register API model and functions
V6:
- Small changes to the API based on Alex's comments
- Remove 'register: Add support for decoding information' patch
- Move prefix and debug into the RegisterInfoArray as it is the same for every register.
V5:
- Only create a single memory region instead of a memory region for each register
- General tidyups based on Alex's comments
V4:
- Rebase and fix build issue
- Simplify the register write logic
- Other small fixes suggested by Alex Bennee
V3:
- Small changes reported by Fred
V2:
- Rebase
- Fix up IOU SLCR connections
- Add the memory_region_add_subregion_no_print() function and use it for the registers
Changes since RFC:
- Connect the ZynqMP IOU SLCR device
- Rebase

Original cover letter From Peter:
Hi All. This is a new scheme I've come up with handling device registers in a data driven way. My motivation for this is to factor out a lot of the access checking that seems to be replicated in every device. See P1 commit message for further discussion.

P1 is the main patch, adds the register definition functionality P2-3,6 add helpers that glue the register API to the Memory API P4 Defines a set of macros that minimise register and field definitions P5 is QOMfication
P7 is a trivial
P10-13 Work up to GPIO support
P8,9,14 add new devices (the Xilinx Zynq devcfg & ZynqMP SLCR) that use this
scheme.
P15: Connect the ZynqMP SLCR device

This Zynq devcfg device was particularly finnicky with per-bit restrictions. I'm also looking for a higher-than-usual modelling fidelity
on the register space, with semantics defined for random reserved bits in-between otherwise consistent fields.

Here's an example of the qemu_log output for the devcfg device. This is produced by now generic sharable code:

/machine/unattached/device[44]:Addr 0x000008:CFG: write of value 00000508 /machine/unattached/device[44]:Addr 0x000080:MCTRL: write of value 00800010 /machine/unattached/device[44]:Addr 0x000010:INT_MASK: write of value ffffffff /machine/unattached/device[44]:Addr 00000000:CTRL: write of value 0c00607f

And an example of a rogue guest banging on a bad bit:

/machine/unattached/device[44]:Addr 0x000014:STATUS bits 0x000001 may not be \
written to 1

A future feature I am interested in is implementing TCG optimisation of side-effectless registers. The register API allows clear definition of what registers have txn side effects and which ones don't. You could even go a step further and translate such side-effectless accesses based on the data pointer for the register.

Alistair Francis (4):
bitops: Add MAKE_64BIT_MASK macro
register: Add Register API
register: Add Memory API glue
dma: Add Xilinx Zynq devcfg device model

Peter Crosthwaite (4):
register: Define REG and FIELD macros
register: QOMify
register: Add block initialise helper
xilinx_zynq: Connect devcfg to the Zynq machine model

 default-configs/arm-softmmu.mak   |   1 +
 hw/arm/xilinx_zynq.c              |   6 +
 hw/core/Makefile.objs             |   1 +
 hw/core/register.c                | 287 +++++++++++++++++++++++++++
 hw/dma/Makefile.objs              |   1 +
 hw/dma/xlnx-zynq-devcfg.c         | 400 ++++++++++++++++++++++++++++++++++++++
 include/hw/dma/xlnx-zynq-devcfg.h |  62 ++++++
 include/hw/register.h             | 254 ++++++++++++++++++++++++
 include/qemu/bitops.h             |   3 +
 9 files changed, 1015 insertions(+)
 create mode 100644 hw/core/register.c
 create mode 100644 hw/dma/xlnx-zynq-devcfg.c
 create mode 100644 include/hw/dma/xlnx-zynq-devcfg.h
 create mode 100644 include/hw/register.h
Signature · 1 line
2.7.4