Pull request for RegisterAPI

This is a single patch to add support to the RegisterAPI for different
 data sizes.
 -----BEGIN PGP SIGNATURE-----
 
 iQEzBAABCAAdFiEE9sSsRtSTSGjTuM6PIeENKd+XcFQFAl6x8d8ACgkQIeENKd+X
 cFT3egf/cmwdK7/ICSY8axlQKQpaAxtkIvtTTdAmPYVWxyIuiEB9UCfU4xKzST7s
 5gIPT3g0r1xixTUy4jueadDi9cieU0w5RsIt016w+riwSOSg+XJVg4pscswWBuTT
 LRnAXMwua056NtJXJgd28X6Ul4oqVwUeUnOihrvDGzgnge862AKeGl+r6Bdwo0Wh
 d7N2Ih+gG2+Nez+A5iHWmT1+Hk0yS0FB0cgPkHokDSTQdMQMcLLktF9j82Y50fZh
 Ezy4vAr4Ng28urzkHPZ+qXiVwx8qqYb3YR1NPYMfnf63Wgj2eIlqIr2OvU5nm2A9
 dqmddy7JxkJ4XttG3j2Y+WiN40q6TA==
 =VSMG
 -----END PGP SIGNATURE-----

Merge remote-tracking branch 'remotes/alistair/tags/pull-reg-to-apply-20200505' into staging

Pull request for RegisterAPI

This is a single patch to add support to the RegisterAPI for different
data sizes.

# gpg: Signature made Wed 06 May 2020 00:08:15 BST
# gpg:                using RSA key F6C4AC46D4934868D3B8CE8F21E10D29DF977054
# gpg: Good signature from "Alistair Francis <alistair@alistair23.me>" [full]
# Primary key fingerprint: F6C4 AC46 D493 4868 D3B8  CE8F 21E1 0D29 DF97 7054

* remotes/alistair/tags/pull-reg-to-apply-20200505:
  hw/core/register: Add register_init_block8 helper.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
This commit is contained in:
Peter Maydell 2020-05-06 15:38:02 +01:00
commit 570a921482
2 changed files with 44 additions and 10 deletions

View File

@ -246,16 +246,18 @@ uint64_t register_read_memory(void *opaque, hwaddr addr,
return extract64(read_val, 0, size * 8);
}
RegisterInfoArray *register_init_block32(DeviceState *owner,
const RegisterAccessInfo *rae,
int num, RegisterInfo *ri,
uint32_t *data,
const MemoryRegionOps *ops,
bool debug_enabled,
uint64_t memory_size)
static RegisterInfoArray *register_init_block(DeviceState *owner,
const RegisterAccessInfo *rae,
int num, RegisterInfo *ri,
void *data,
const MemoryRegionOps *ops,
bool debug_enabled,
uint64_t memory_size,
size_t data_size_bits)
{
const char *device_prefix = object_get_typename(OBJECT(owner));
RegisterInfoArray *r_array = g_new0(RegisterInfoArray, 1);
int data_size = data_size_bits >> 3;
int i;
r_array->r = g_new0(RegisterInfo *, num);
@ -264,12 +266,12 @@ RegisterInfoArray *register_init_block32(DeviceState *owner,
r_array->prefix = device_prefix;
for (i = 0; i < num; i++) {
int index = rae[i].addr / 4;
int index = rae[i].addr / data_size;
RegisterInfo *r = &ri[index];
*r = (RegisterInfo) {
.data = &data[index],
.data_size = sizeof(uint32_t),
.data = data + data_size * index,
.data_size = data_size,
.access = &rae[i],
.opaque = owner,
};
@ -284,6 +286,30 @@ RegisterInfoArray *register_init_block32(DeviceState *owner,
return r_array;
}
RegisterInfoArray *register_init_block8(DeviceState *owner,
const RegisterAccessInfo *rae,
int num, RegisterInfo *ri,
uint8_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, 8);
}
RegisterInfoArray *register_init_block32(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, 32);
}
void register_finalize_block(RegisterInfoArray *r_array)
{
object_unparent(OBJECT(&r_array->mem));

View File

@ -185,6 +185,14 @@ uint64_t register_read_memory(void *opaque, hwaddr addr, unsigned size);
* memory region (r_array->mem) the caller should add to a container.
*/
RegisterInfoArray *register_init_block8(DeviceState *owner,
const RegisterAccessInfo *rae,
int num, RegisterInfo *ri,
uint8_t *data,
const MemoryRegionOps *ops,
bool debug_enabled,
uint64_t memory_size);
RegisterInfoArray *register_init_block32(DeviceState *owner,
const RegisterAccessInfo *rae,
int num, RegisterInfo *ri,