lwip-users
[Top][All Lists]
Advanced

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

[lwip-users] [lwip] eZ80 port


From: Robert
Subject: [lwip-users] [lwip] eZ80 port
Date: Wed, 08 Jan 2003 23:46:33 -0000

I have had some success porting LwIP over to the eZ80.  Some of the issues
are related to the current Zilog compiler.  The changes so far related to
that are shown below.  I would appreciate any comments or suggestions.  
My current status is that the arp table on the eZ80 is being built, and
other hosts receive the arp of the eZ80.  So, I believe I am able to both
receive and send packets over Ethernet now.  I am not able to make a 
connection however, my callback "accept" function is never being called.  
Any suggestions as to where to look would be appreciated.  Additional 
information can be provided, of course...:)  Naturally I am continuing to 
work on debugging, and getting more familar with LwIP as I go.  If anyone 
spots somewhere in my changes that introducted a bug, I would *really* 
like to hear about it.


---------------------------------
I needed to make one change in tcp.c as follows:

u8_t
tcp_segs_free(struct tcp_seg *seg)
{
  u8_t count = 0;
  struct tcp_seg *next;

#ifndef EZ80    
 again:  
  if(seg != NULL) {
    next = seg->next;
    count += tcp_seg_free(seg);
    seg = next;
    goto again;
#else
  while(seg != NULL) {
    next = seg->next;
    count += tcp_seg_free(seg);
    seg = next;
#endif
  }

This change was needed because the "again" label occurs in another 
function in the same source file.  The Zilog compiler treats these as 
duplicate labels. It could be that my alternative coding could be 
accepted, since it would work in both cases.
---------------------------------


In the etharp.c file, I added an additional function.  This change is not 
strictly needed of course, but it's helpful to have a way to display the 
ARP table:

#ifdef EZ80
void etharp_dspl(void) {
  u8_t i;
  /* display ARP entries */
  printf("IP Address \t MAC Address \t\t ctime\n");
  for(i = 0; i < ARP_TABLE_SIZE; ++i) {
        if( arp_table[i].state == ETHARP_STATE_STABLE ) 
                printf("%u.%u.%u.%u \t %02X:%02X:%02X:%02X:%02X:%02X \t 
%d\n", 
                *(0 + (unsigned char*) &arp_table[i].ipaddr.addr), 
                *(1 + (unsigned char*) &arp_table[i].ipaddr.addr), 
                *(2 + (unsigned char*) &arp_table[i].ipaddr.addr), 
                *(3 + (unsigned char*) &arp_table[i].ipaddr.addr),
                arp_table[i].ethaddr.addr[0], 
                arp_table[i].ethaddr.addr[1], 
                arp_table[i].ethaddr.addr[2],
                arp_table[i].ethaddr.addr[3], 
                arp_table[i].ethaddr.addr[4], 
                arp_table[i].ethaddr.addr[5],
                arp_table[i].ctime);
  }
}
#endif
------------------------------
In mem.h, I needed to make the change below.  It seems the #define was 
just too complicate for the compiler to handle.  In the case of the eZ80, 
the alignment is on byte boundries, so alignment is not really an issue 
anyway.

#ifndef EZ80     // eZ80 compiler cannot handle this define
#define MEM_ALIGN_SIZE(size) (size + \
                             ((((size) % MEM_ALIGNMENT) == 0)? 0 : \
                             (MEM_ALIGNMENT - ((size) % MEM_ALIGNMENT))))
#else
#define MEM_ALIGN_SIZE(size) (size) 
#endif

--------------------------------
In sys.h, I needed to make the change below.  The Zilog compiler can't 
seem to handle having a #define and a structure with the same name.  I was 
not able to find anywhere the #define was used, perhaps it can be 
removed?

#ifndef EZ80    // can't have struct & #define with same name
#define sys_timeout(m,h,a)
#endif

-------------------------------

In tcp.h there is a #define that is too complicated for the Zilog compiler 
to handle, so I replaced it with a function call.


#ifndef EZ80     // too complicated for the eZ80 compiler
#define TCP_TCPLEN(seg) ((seg)->len + ((TCPH_FLAGS((seg)->tcphdr) & 
TCP_FIN || \
                                        TCPH_FLAGS((seg)->tcphdr) & 
TCP_SYN)? 1: 0))
#else
u16_t TCP_TCPLEN(struct tcp_seg *inseg);
#endif

there is the new file/function:

#include "lwip\tcp.h"
u16_t TCP_TCPLEN(struct tcp_seg *seg)
{
return ((seg)->len + ((TCPH_FLAGS((seg)->tcphdr) & TCP_FIN || 
        TCPH_FLAGS((seg)->tcphdr) & TCP_SYN)? 1: 0));
}

--------------------------------

In addition to these changes, the cs8900if.c file needed extensive changes 
because the interface to the chip is 8 bits wide rather than 16 bits as 
currently coded.  Once I get all this debugged, I will be posting my 
rewrite of the driver, in case there is interest.


-- 
Best Regards,
Robert Laughlin



[This message was sent through the lwip discussion list.]




reply via email to

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