- Fri Sep 01, 2006 2:42 am
#18228
Here is an attempt to describe the idea a bit more structured:
- JTAG
All JTAG operations take pointers to little-endian buffers (u8*). The in_handler member of the scan_field_t structure can be used to put captured data directly in a host-endian variable, or a target-endian buffer.
- TARGET
The target interface (target_type_t, target_t, registers, algorithms) use little-endian buffers for values, to potentially allow the OpenOCD to be extended beyond 32 (64, 128) bit targets, for example in case of multi-media extensions. buf_get/set_u32 should be used to read/write these buffers.
Those interfaces currently using u32 for addresses would still have to be changed.
Target-internal functions can use whatever datatype fits the architecture, for example u32 in case of ARMv4/5. These values are stored in normal u32 variables, therefor in host-endianness. As target->type->read/write_memory operates on buffers in target-endianness, the convenience functions target_read/write_u8/6/32 have been added to directly read/write u8, u16 and u32 values in host endianness.
- FLASH
Flash functions only make use of the external target interface, and therefor operate on buffers in target endianness. If flash code has to read/write memory mapped registers, it should use the target_read/write_u8/16/32 functions. Alternatively, it can call target->type->read/write memory directly, and use target_buffer_get/set_u8/16/32 on the memory buffer (that's what I did when I started working on the at91sam7.c code. I completely forgot about these changes, and committed them together with the other changes. This is incomplete, and target_read_u32 would be more appropriate).
If code is to be executed on the target (flash write algorithms, for example), the opcodes are stored in u32[] arrays (therefor in host endianness). Before writing these opcodes to the target, target_buffer_set_u32 has to be used to convert the opcodes to target endianness. See arm7_9_bulk_write_memory for an example.
Regards,
Dominic