lwip-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [lwip-users] alignment problems


From: Jonathan Larmour
Subject: Re: [lwip-users] alignment problems
Date: Thu, 08 Nov 2007 11:08:23 +0000
User-agent: Thunderbird 1.5.0.12 (X11/20070530)

Bartlomiej Wicher wrote:
> Hello
> 
> I am a newbie in LWIP and it's my first post to this list. I'm trying to
> use LWIP with Freescale DSP568366. I have some problems with value of
> MEM_ALIGNMENT. Normally microprocessor are 8-bit addressable,  but the
> DSP568366 is word-addressable (16-bits). It means that each address of
> memory stores dwo bytes. Moreover:
> 
> + Size of char is 1 byte - it is stored in one word (one address used)
> + Size of int is 2 bytes - it is also stored in one word
> + Size of long is 4 bytes - it is stored in two words (two addresses
> involved)
> + An array of chars is "packed" automatically by the microcontroller, so
> that 2 consecutive chars are stored in one word.
> 
> What value of MEM_ALIGNMENT should I use?

Probably 2. Although it would be 4 if your longs must be aligned on a
2-word boundary. Or it might need to more if there are any other
fundamental types that have stronger alignment requirements.

> Can I use LWIP memory
> functinos (mem_malloc() etc) without any changes in their original
> source code, or should I use the stdio mem functions (malloc() etc)?

You can always choose to use the standard malloc() etc. if you want to
anyway, although if you weren't going to use it otherwise, it might result
in smaller code not to, because some malloc()s are quite heavyweight. I
don't think the mem_alloc() etc. code is likely to more of a problem than
any other part of lwIP....

> Finally - do I have to make any changes in the original LWIP source code
> due to my my architecture?

I'm concerned that you say that "two addresses" are only used with long,
and one for both char and int. Does this mean that for:
char foo[4];
that: &foo[0] == &foo[1] ?

If that is the case, I think you may have an uphill struggle.

Jifl
-- 
eCosCentric Limited      http://www.eCosCentric.com/     The eCos experts
Barnwell House, Barnwell Drive, Cambridge, UK.       Tel: +44 1223 245571
Registered in England and Wales: Reg No 4422071.
------["Si fractum non sit, noli id reficere"]------       Opinions==mine




reply via email to

[Prev in Thread] Current Thread [Next in Thread]