register: Add Register API
commit1599121b57d9bcfff868ad589bb87cf6e0e2c4ac
authorAlistair Francis <alistair.francis@xilinx.com>
Mon, 4 Jul 2016 12:06:36 +0000 (4 13:06 +0100)
committerPeter Maydell <peter.maydell@linaro.org>
Mon, 4 Jul 2016 12:15:22 +0000 (4 13:15 +0100)
treecd8786ee55a5a5a5298b583ca5ad1bae436dd0e7
parentae2923b5c20a21c6457680330506a9c13873485c
register: Add Register API

This API provides some encapsulation of registers and factors out some
common functionality to common code. Bits of device state (usually MMIO
registers) often have all sorts of access restrictions and semantics
associated with them. This API allows you to define what those
restrictions are on a bit-by-bit basis.

Helper functions are then used to access the register which observe the
semantics defined by the RegisterAccessInfo struct.

Some features:
Bits can be marked as read_only (ro field)
Bits can be marked as write-1-clear (w1c field)
Bits can be marked as reserved (rsvd field)
Reset values can be defined (reset)
Bits can be marked clear on read (cor)
Pre and post action callbacks can be added to read and write ops
Verbose debugging info can be enabled/disabled

Useful for defining device register spaces in a data driven way. Cuts
down on a lot of the verbosity and repetition in the switch-case blocks
in the standard foo_mmio_read/write functions.

Also useful for automated generation of device models from hardware
design sources.

Signed-off-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
Signed-off-by: Alistair Francis <alistair.francis@xilinx.com>
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Message-id: 40d62c7e1bf6e63bb4193ec46b15092a7d981e59.1467053537.git.alistair.francis@xilinx.com
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
hw/core/Makefile.objs
hw/core/register.c [new file with mode: 0644]
include/hw/register.h [new file with mode: 0644]