dmi_scan() allocate bytes depending on abits value (#307)
* dmi_scan() allocate bytes depending on abits value Fixes #303. Change-Id: Iac45959cf342180c60cd0b5462f864ad81beddd2 * Incorporate review feedback. Change-Id: I1cc7d20fed6f2d891bec0e858fca53ece450720c
This commit is contained in:
parent
b986d29bc9
commit
60c37e1679
|
@ -458,14 +458,18 @@ static dmi_status_t dmi_scan(struct target *target, uint32_t *address_in,
|
|||
bool exec)
|
||||
{
|
||||
riscv013_info_t *info = get_info(target);
|
||||
uint8_t in[8] = {0};
|
||||
uint8_t out[8];
|
||||
unsigned num_bits = info->abits + DTM_DMI_OP_LENGTH + DTM_DMI_DATA_LENGTH;
|
||||
size_t num_bytes = (num_bits + 7) / 8;
|
||||
uint8_t in[num_bytes];
|
||||
uint8_t out[num_bytes];
|
||||
struct scan_field field = {
|
||||
.num_bits = info->abits + DTM_DMI_OP_LENGTH + DTM_DMI_DATA_LENGTH,
|
||||
.num_bits = num_bits,
|
||||
.out_value = out,
|
||||
.in_value = in
|
||||
};
|
||||
|
||||
memset(in, 0, num_bytes);
|
||||
|
||||
assert(info->abits != 0);
|
||||
|
||||
buf_set_u32(out, DTM_DMI_OP_OFFSET, DTM_DMI_OP_LENGTH, op);
|
||||
|
|
Loading…
Reference in New Issue