This is the mail archive of the
ecos-discuss@sourceware.org
mailing list for the eCos project.
Re: network buffer alignment
- From: Andrew Lunn <andrew at lunn dot ch>
- To: Lars Poeschel <larsi at wh2 dot tu-dresden dot de>
- Cc: ecos-discuss at ecos dot sourceware dot org
- Date: Fri, 19 Sep 2008 19:19:10 +0200
- Subject: Re: [ECOS] network buffer alignment
- References: <22F8772E-1D93-4C8C-9CBD-9D8D4D3271EB@wh2.tu-dresden.de>
On Fri, Sep 19, 2008 at 09:44:05AM +0200, Lars Poeschel wrote:
> 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 ?
This sounds like a toolchain issue.
[Goes away and googles]
http://gcc.gnu.org/onlinedocs/gcc/M680x0-Options.html
-malign-int
-mno-align-int
Control whether GCC aligns int, long, long long, float, double,
and long double variables on a 32-bit boundary (-malign-int) or a
16-bit boundary (-mno-align-int). Aligning variables on 32-bit
boundaries produces code that runs somewhat faster on processors
with 32-bit busses at the expense of more memory.
Warning: if you use the -malign-int switch, GCC will align
structures containing the above types differently than most
published application binary interface specifications for the
m68k.
Does this help?
Andrew
--
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss