[ECOS] network buffer alignment
Lars Poeschel
larsi@wh2.tu-dresden.de
Fri Sep 19 08:40:00 GMT 2008
Hello!
I am writing an ethernet driver for coldfire architecture and I am
using redboot for simple ping tests.
I had the problem of strange ethernet destination addresses on the
wire for outgoing packets. This was because the controller requires
the buffers for transmitting to be 4 byte aligned and the buffer in
question did not has this alignment. The buffer in question is in
redboot/current/src/net/enet.c in function __enet_send, the eth_hdr
stack variable. I now wonder if my ethernet controller is the only one
with this 4 byte aligning requirement or if other architectures had
luck in gcc aligning this buffer at a 4 byte boundary by random ?
I could make it work by forcing gcc with __attribute__((aligned(4)))
to the right alignment. This would make a little change in the redboot
sources neccessary, but I am not sure if this applies for all the
other architectures out there. If this were not the case, my only
other solution is: In the driver right before sending the packet I
would check for the right buffer alignment and if it is not correct, I
would have to allocate memory with the alignment in place and copy the
wrong buffer there. This would be a really ugly solution.
What are your opinions ?
Thanks,
Lars
-------------- next part --------------
A non-text attachment was scrubbed...
Name: PGP.sig
Type: application/pgp-signature
Size: 194 bytes
Desc: This is a digitally signed message part
URL: <http://sourceware.org/pipermail/ecos-discuss/attachments/20080919/f72a09fd/attachment.sig>
More information about the Ecos-discuss
mailing list