On Thursday 21 May 2009, Zach Welch wrote:
> 
> > (NOTE that the armel build turned up *LOTS* of unrelated bugs, not fixed
> > here.  Biggest:  abusing "u8 *ptr" by "*((u32 *)ptr) = ..." loses badly,
> > since ARM doesn't guarantee unaligned reads work.  That idiom is used
> > all over the place in JTAG buffer conversions.)
> 
> Yeah.  My effort to add warnings pointed these out to me, and I just
> corrected those with calls to memcpy.  Clearly, this kind of work not
> only needs to be done, but it almost begs to be encapsulated in a new
> inline functions in src/helper/binarybuffer.[ch].... doesn't it?

Encapsulated, yes; and then there are all the byteswapping routines,
some of which are not needed at all.  Some <endian.h> checks like

 static __inline__ void arm_le_to_h_u32(u8 *in)
 {
-       *((u32 *)in)=le_to_h_u32(in);
+#if __BYTE_ORDER != __LITTLE_ENDIAN
+#error woe is me
+#endif
 }

could help ... that is, with a memcpy or something similar being
used *only* when host-order is big-endian.

I'd be more comfortable seeing something like the <asm/byteorder.h>
stack used ... it's got a full suite of cpu_to_{le,be}{16,32,64}()
calls, and vice versa; or for that case, le32_to_cpus() for the
in-situ conversions.  They morph to NOPs half the time.  :)



_______________________________________________
Openocd-development mailing list
[email protected]
https://lists.berlios.de/mailman/listinfo/openocd-development

Reply via email to