> Take for example:
>
> fields[0].tap = etm_reg->jtag_info->tap;
> fields[0].num_bits = 32;
> fields[0].out_value = reg->value;
> fields[0].in_value = NULL;
> fields[0].check_value = NULL;
> fields[0].check_mask = NULL;
>
> fields[1].tap = etm_reg->jtag_info->tap;
> fields[1].num_bits = 7;
> fields[1].out_value = malloc(1);

:-) That malloc() is just a silly anachronism in OpenOCD. We should
be mostly rid of them now...

> buf_set_u32(fields[1].out_value, 0, 7, reg_addr);
> fields[1].in_value = NULL;
> fields[1].check_value = NULL;
> fields[1].check_mask = NULL;
>
> fields[2].tap = etm_reg->jtag_info->tap;
> fields[2].num_bits = 1;
> fields[2].out_value = malloc(1);
> buf_set_u32(fields[2].out_value, 0, 0, 0);
> fields[2].in_value = NULL;
> fields[2].check_value = NULL;
> fields[2].check_mask = NULL;

I think everybody will agree that this is one of the least
elegant parts of OpenOCD.

I've worked on improving this part of OpenOCD.

The check_value/mask no longer have to be set.
Also, I believe that switching to 32 bit instead of 8 bit word
size would help(get rid of lots of buf_set_u32()'s).

> OUT_FIELD(fields[0], 32, reg->value);
> OUT_FIELD(fields[1], 7, reg_addr);
> OUT_FIELD(fields[2], 1, 0);
>
> it would be macros you might have to look up once when you deal with
> openocd for the first time, but that is a tiny price to pay for
> immediately seeing the relevant parts of the action.

Macros/helper fn's could improve things, but for this particular
case, I believe the root cause of the problem should
be attacked. Currently the worst part of the fields.xxx mess
is that 8 bit instead of 32 bit words are used...

-- 
Øyvind Harboe
http://www.zylin.com/zy1000.html
ARM7 ARM9 ARM11 XScale Cortex
JTAG debugger and flash programmer
_______________________________________________
Openocd-development mailing list
Openocd-development@lists.berlios.de
https://lists.berlios.de/mailman/listinfo/openocd-development

Reply via email to