Hi,

I'm not seriously contemplating porting lwIP stack to PIC, 
but out of curiosity I did some experiments.
In about two hours I was able to get it to compile with SDCC.

First I used gcc to check that the code was conforming
and spotted a few places that needed some little editing.

Compiling with SDCC required some modifications,
mainly because memset() is not compatible with
generic pointers (about four instances) and 
because SDCC does not support struct
assignment (about two instances) and
insist on passing struct through pointer (one
instance).

Of course getting the code to compile is just
the first step. Next the necessary network
interface and operating system layers would 
have to be created and the configuration
(number and size of buffers, and various
data types) would need to be tinkered to suit PIC.
And I expect some non trivial  testing and debugging
would be necessary to get it to work.

But like I said, I'm not really doing this.

For serious porting effort I would start by
immediately convert all generic pointers to 
__data pointers for much better performance.

This I would require quite a few edits to add
the __data definitions to each pointer def.
There are several hundred of these so I would
be tempted to do this with search/replace or sed.

The downside of this is that this would require
touching the 'base' lwIP code which fork the
lwIP development unless the lwIP community
could be persuaded to include to use
#define NEAR __DATA 
or some such approach in their code to define
pointers. Which brings to my mind a question:

Has it ever been considered that SDCC could have
a commandline switch that would cause all
generic pointers to be short or data/ram pointers,
as most of the time this is what they are.?

I can see
a few places, such as string constants in ROM
that could be problematic but for things like lwIP
this would be really handy. IIRC there is nothing
in lwIP pointer usage would require pointers to ROM.
(Not counting that someone would like send some
 data or static ip addresses in ROM.

Another question is why SDCC does not support
assigning structs? Not a big deal (not having it),
trivially converted to memcpy's but on the face 
of it this seems also rather simple to implement
so I'm curious why it has not been. After all
for small structs the compiler would be able 
to generate considerably more efficient code
that calling memcpu with generic pointers 
all that it implies.

But back to lwIP porting.

All in all it looked like something that would
start to resemble a working TCP/IP stack could
be hacked together in a few weeks.

lwIP is BSD licensed so for all but open source
purist the licencing is quite nice. Before I would
start porting I would try to assess the status
of the project: don't know if it is the licence
(people not giving back their code) or what
but there was surprisingly small number of
ports included with the source code I downloaded.

Just thought I'd share these thoughts.


br Kusti









------------------------------------------------------------------------------
This SF.net email is sponsored by:
SourcForge Community
SourceForge wants to tell your story.
http://p.sf.net/sfu/sf-spreadtheword
_______________________________________________
Sdcc-user mailing list
Sdcc-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sdcc-user

Reply via email to