[Dibbler-devel] Linux Port of SA-1110 StrongARM 32 bit alignment problems.
Jim Rayno
Jim.Rayno at jdsu.com
Fri May 11 17:18:20 CEST 2007
I have built the dibbler client to run on the SA1110 processor. The
platform is configured to strictly align addresses to 32 bits. Because
of this, there are problems with message encoding/decoding, specifically
in the storeSelf( char* buf) method of the TOptIA_NA option class.
Since the StrongARM does not allow the non-32 bit aligned memory writes,
the option is malformed. Upon entry into this method, the address of
buf is not 32 bit aligned because of prior fields in the message
specifically the Link Local Address (6 bytes). I was able to use the
kernel to help debug the problem
http://lecs.cs.ucla.edu/wiki/index.php/XScale_alignment#Identifying_alig
nment_problems and even corrected it using "echo 2 >
/proc/cpu/alignment" as a quick check.
I prefer to fix the code and have created simple cheesy macros to work
around the situation... such a change would increase its portability...
Thank you for such a great product!... overall, it was very easy to get
built and running on my target.
Jim Rayno
Sr. Software Engineer
// Existing method...
char * TOptIA_NA::storeSelf( char* buf) {
*(uint16_t*)buf = htons(OptType);
buf+=2;
*(uint16_t*)buf = htons( getSize()-4 );
buf+=2;
*(uint32_t*)buf = htonl(IAID);
buf+=4;
*(uint32_t*)buf = htonl(T1);
buf+=4;
*(uint32_t*)buf = htonl(T2);
buf+=4;
buf=this->storeSubOpt(buf);
return buf;
}
#define STORE_LONG(f,t) { \
t[0] =((char *)&f)[0]; \
t[1] =((char *)&f)[1]; \
t[2] =((char *)&f)[2]; \
t[3] =((char *)&f)[3]; \
}
#define STORE_SHORT(f,t) { \
t[0] =((char *)&f)[0]; \
t[1] =((char *)&f)[1]; \
}
char * TOptIA_NA::storeSelf( char* buf) {
short opttype = (short)htons(OptType);
short size = htons((short)getSize()-4);
long iaid = htonl(IAID);
long t1 = htonl(T1);
long t2 = htonl(T2);
STORE_SHORT(opttype,buf);
buf += 2;
STORE_SHORT(size,buf);
buf += 2;
STORE_LONG(iaid, buf );
buf+=4;
STORE_LONG(t1, buf );
buf+=4;
STORE_LONG(t2, buf );
buf+=4;
buf=this->storeSubOpt(buf);
return buf;
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://klub.com.pl/pipermail/dibbler-devel/attachments/20070511/d8b63902/attachment.htm
More information about the Dibbler-devel
mailing list