hw/core/register: Add register_init_block8 helper.
There was no support for 8 bits block registers. Changed register_init_block32 to be generic and static, adding register size in bits as parameter. Created one helper for each size. Signed-off-by: Joaquin de Andres <me@xcancerberox.com.ar> Message-Id: <20200402162839.76636-1-me@xcancerberox.com.ar> Reviewed-by: Alistair Francis <alistair.francis@wdc.com> Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
This commit is contained in:
parent
f19d118bed
commit
f08085f49f
@ -246,16 +246,18 @@ uint64_t register_read_memory(void *opaque, hwaddr addr,
|
|||||||
return extract64(read_val, 0, size * 8);
|
return extract64(read_val, 0, size * 8);
|
||||||
}
|
}
|
||||||
|
|
||||||
RegisterInfoArray *register_init_block32(DeviceState *owner,
|
static RegisterInfoArray *register_init_block(DeviceState *owner,
|
||||||
const RegisterAccessInfo *rae,
|
const RegisterAccessInfo *rae,
|
||||||
int num, RegisterInfo *ri,
|
int num, RegisterInfo *ri,
|
||||||
uint32_t *data,
|
void *data,
|
||||||
const MemoryRegionOps *ops,
|
const MemoryRegionOps *ops,
|
||||||
bool debug_enabled,
|
bool debug_enabled,
|
||||||
uint64_t memory_size)
|
uint64_t memory_size,
|
||||||
|
size_t data_size_bits)
|
||||||
{
|
{
|
||||||
const char *device_prefix = object_get_typename(OBJECT(owner));
|
const char *device_prefix = object_get_typename(OBJECT(owner));
|
||||||
RegisterInfoArray *r_array = g_new0(RegisterInfoArray, 1);
|
RegisterInfoArray *r_array = g_new0(RegisterInfoArray, 1);
|
||||||
|
int data_size = data_size_bits >> 3;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
r_array->r = g_new0(RegisterInfo *, num);
|
r_array->r = g_new0(RegisterInfo *, num);
|
||||||
@ -264,12 +266,12 @@ RegisterInfoArray *register_init_block32(DeviceState *owner,
|
|||||||
r_array->prefix = device_prefix;
|
r_array->prefix = device_prefix;
|
||||||
|
|
||||||
for (i = 0; i < num; i++) {
|
for (i = 0; i < num; i++) {
|
||||||
int index = rae[i].addr / 4;
|
int index = rae[i].addr / data_size;
|
||||||
RegisterInfo *r = &ri[index];
|
RegisterInfo *r = &ri[index];
|
||||||
|
|
||||||
*r = (RegisterInfo) {
|
*r = (RegisterInfo) {
|
||||||
.data = &data[index],
|
.data = data + data_size * index,
|
||||||
.data_size = sizeof(uint32_t),
|
.data_size = data_size,
|
||||||
.access = &rae[i],
|
.access = &rae[i],
|
||||||
.opaque = owner,
|
.opaque = owner,
|
||||||
};
|
};
|
||||||
@ -284,6 +286,30 @@ RegisterInfoArray *register_init_block32(DeviceState *owner,
|
|||||||
return r_array;
|
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)
|
void register_finalize_block(RegisterInfoArray *r_array)
|
||||||
{
|
{
|
||||||
object_unparent(OBJECT(&r_array->mem));
|
object_unparent(OBJECT(&r_array->mem));
|
||||||
|
@ -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.
|
* 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,
|
RegisterInfoArray *register_init_block32(DeviceState *owner,
|
||||||
const RegisterAccessInfo *rae,
|
const RegisterAccessInfo *rae,
|
||||||
int num, RegisterInfo *ri,
|
int num, RegisterInfo *ri,
|
||||||
|
Loading…
Reference in New Issue
Block a user