lwip-users
[Top][All Lists]
Advanced

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

[lwip-users] RE: [lwip] New To LWIP : I Want to port LWIP on 8051 micro


From: DASILVA VINCENTE BIT
Subject: [lwip-users] RE: [lwip] New To LWIP : I Want to port LWIP on 8051 microcontrol ler
Date: Wed, 08 Jan 2003 23:09:13 -0000

This message is in MIME format. Since your mail reader does not understand
this format, some or all of this message may not be legible.

------_=_NextPart_000_01C1DCAB.A1AB4900
Content-Type: text/plain;
        charset="iso-8859-1"

You can run lwip on uCOS II for 8051.

I have ported lwip to 8051 (89C664 from Philips) on UCOS II with Keil
compiler 6.23.

The UCOS port is available on the UCOS site and the sysarch files are
attached.

We should do a cost analysis on the XA architecture 8051 from Philips. This
is a 8051 which allows much more memory than a standard 8051. If the cost of
this chip is not much higher than the standard 8051, then I think this would
be a much better choice since lwip is about 54K on my platform and this does
not include application code, an Ethernet driver, PPP, SLIP, Web Server
etc...

Vicente

-----Original Message-----
From: Mumtaz Ahmad [mailto:address@hidden
Sent: 05 April 2002 08:16 AM
To: address@hidden
Subject: Re: [lwip] New To LWIP : I Want to port LWIP on 8051
microcontroller


You better take the windows verison if u wanna run it in single threaded
environment


----- Original Message -----
From: Imran Mansuri <address@hidden>
To: <address@hidden>
Sent: Friday, April 05, 2002 10:53 AM
Subject: [lwip] New To LWIP : I Want to port LWIP on 8051 microcontroller


> Hello
>
> I myself Imran Mansuri studying in last year of
> engineering.
>
> I am new to LWIP and the group. I have gone through
> the code of LwIP, but still have some doubt about how
> to run it.
>
> Please anybody can help me what I need to implement to
> port LwIP over  Pentium/DOS or 8051 microcontroller.
>
> What files need to be changed for the above?
> I want to run the LWIP in a single thread. For 8051 I
> am not going to have any OS so Emulation layer will be
> implemented by me without any OS.
>
> Please help me out  for the above
> Thanks in advance
>
> Imran Mansuri
> Student
> BE Information Technology(IT)
> Nirma Institute Of Technology, Ahmedabad
> Gujarat, India.
>
>
> __________________________________________________
> Do You Yahoo!?
> Yahoo! Tax Center - online filing with TurboTax
> http://taxes.yahoo.com/
> [This message was sent through the lwip discussion list.]

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


    


------_=_NextPart_000_01C1DCAB.A1AB4900
Content-Type: application/octet-stream;
        name="sys_arch.c"
Content-Transfer-Encoding: quoted-printable
Content-Disposition: attachment;
        filename="sys_arch.c"

/*
 * Copyright (c) 2001, Swedish Institute of Computer Science.
 * All rights reserved.=20
 *
 * Redistribution and use in source and binary forms, with or without=20
 * modification, are permitted provided that the following conditions=20
 * are met:=20
 * 1. Redistributions of source code must retain the above copyright=20
 *    notice, this list of conditions and the following disclaimer.=20
 * 2. Redistributions in binary form must reproduce the above copyright =

 *    notice, this list of conditions and the following disclaimer in =
the=20
 *    documentation and/or other materials provided with the =
distribution.=20
 * 3. Neither the name of the Institute nor the names of its =
contributors=20
 *    may be used to endorse or promote products derived from this =
software=20
 *    without specific prior written permission.=20
 *
 * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS =
IS'' AND=20
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, =
THE=20
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR =
PURPOSE=20
 * ARE DISCLAIMED.  IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE =
LIABLE=20
 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR =
CONSEQUENTIAL=20
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE =
GOODS=20
 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS =
INTERRUPTION)=20
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, =
STRICT=20
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN =
ANY WAY=20
 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY =
OF=20
 * SUCH DAMAGE.=20
 *
 * This file is part of the lwIP TCP/IP stack.
 *=20
 * Author: Vicente Da Silva
 *
 * $Id:=20
 */

#include <stdlib.h>
#include "includes.h"
#include "lwip/sys.h"
#include "lwip/mem.h"
#include "init.h"

#define  TASK_STK_SIZE                  12288//8192//4096//64       // =
tcpip task stacks, need a larger stack
#define  TOTAL_TASKS                    4       //total number of tasks used =
by tcpip and the main application, not including the Main uCOS task
#define  SYS_MBOX_SIZE                  20 //total number of messages =
in the mbox

OS_STK           TaskStk[TOTAL_TASKS][TASK_STK_SIZE];     // tcpip task =
stacks, need a larger stack

static struct timeoutlist {
  struct sys_timeouts timeouts;
  u16_t pid;
};

static struct timeoutlist timeoutlist[OS_MAX_TASKS];
static u8_t nextthread =3D 0;
//----------------------------------------------------------------------=
-------------
void sys_thread_new(void (* function)(void *arg)KCREENTRANT, void =
*arg)KCREENTRANT
{
        if((nextthread + 1) <=3D OS_MAX_TASKS)
                if(OSTaskCreate(*function, arg, (void =
*)&TaskStk[nextthread][TASK_STK_SIZE - 1], nextthread + 1) !=3D =
OS_NO_ERR)
                        return;//do error stuff=09

  timeoutlist[nextthread].timeouts.next =3D NULL;
  timeoutlist[nextthread].pid =3D nextthread + 1;
        nextthread++;
}
//----------------------------------------------------------------------=
-------------
OS_EVENT* sys_mbox_new()KCREENTRANT
{
        void* mboxstore =3D 0;
        OS_EVENT* event =3D 0;

        mboxstore =3D (void *) mem_malloc(SYS_MBOX_SIZE * sizeof(void*));
        event =3D OSQCreate (mboxstore, SYS_MBOX_SIZE);
        if(event =3D=3D 0)
                return NULL;

        //check for invalid results

        #ifdef SYS_STATS
          stats.sys.mbox.used++;
          if(stats.sys.mbox.used > stats.sys.mbox.max) {
            stats.sys.mbox.max =3D stats.sys.mbox.used;
          }
        #endif /* SYS_STATS */

  return event;
}

//----------------------------------------------------------------------=
-------------
void sys_mbox_free(OS_EVENT* mbox)KCREENTRANT
{
        INT8U err;
  if(mbox !=3D SYS_MBOX_NULL)=20
        {
                #ifdef SYS_STATS
                    stats.sys.mbox.used--;
                #endif /* SYS_STATS */
   =20
                if(OSQDel (mbox, OS_DEL_ALWAYS, &err) !=3D 0)
                        ;//do error stuff=09
    mem_free(mbox);
  }
}

//----------------------------------------------------------------------=
-------------
void sys_mbox_post(OS_EVENT* mbox, void *msg)KCREENTRANT
{
        INT8U lret =3D 0;
        lret =3D OSQPost (mbox, msg);
        if(lret !=3D OS_NO_ERR)
                return;//do error stuff=09
}


//----------------------------------------------------------------------=
-------------
u16_t sys_arch_mbox_fetch(OS_EVENT* mbox, void **msg, u16_t =
timeout)KCREENTRANT
{
  INT8U err;
  u16_t wtime =3D 1;
 =20
  if(timeout =3D=3D 0)=20
        {
    *msg =3D OSQPend (mbox, 0, &err);
                if(err !=3D OS_NO_ERR)
                        return -1;//do error stuff=09
  }=20
        else=20
        {=20
    *msg =3D OSQPend (mbox, timeout, &err);
                if(err =3D=3D OS_TIMEOUT)
                {
      /* The call timed out, so we return 0. */
      wtime =3D 0;
    }=20
                else=20
                {
                        if(err !=3D OS_NO_ERR)
                                return -1;
      /* Calculate time we waited for the message to arrive. */
      /* XXX: we cheat and just pretend that we waited for half the =
timeout value! */
      wtime =3D timeout / 2;
      /* Make sure we don't return 0 here. */
      if(wtime =3D=3D 0)=20
                        {
                                wtime =3D 1;
      }
    }
  }
  return wtime;
}


//----------------------------------------------------------------------=
-------------
OS_EVENT* sys_sem_new(u8_t count)KCREENTRANT
{
        OS_EVENT* lret =3D 0;
        #ifdef SYS_STATS
          stats.sys.sem.used++;
          if(stats.sys.sem.used > stats.sys.sem.max) {
            stats.sys.sem.max =3D stats.sys.sem.used;
          }
        #endif /* SYS_STATS */
        lret =3D OSSemCreate (count);
        if (lret =3D=3D 0)
        {
                //do error stuff
                return lret;
        }
        else
        {
                return lret;
        }
}


//----------------------------------------------------------------------=
-------------
u16_t sys_arch_sem_wait(OS_EVENT* sem, u16_t timeout)KCREENTRANT
{
        INT8U err;
        u16_t wtime =3D 1;

  if(timeout =3D=3D 0)=20
        {
    OSSemPend (sem, 0, &err);
                if(err !=3D OS_NO_ERR)
                        return -1;//do error stuff=09
  }=20
        else=20
        {=20
                OSSemPend (sem, timeout, &err);
                if(err =3D=3D OS_TIMEOUT)
                        wtime =3D 0;
                else
                {
                        if(err !=3D OS_NO_ERR)
                                return -1;//do error stuff=09
                        /* Calculate time we waited for the message to arrive. 
*/
      /* XXX: we cheat and just pretend that we waited for half the =
timeout value! */
      wtime =3D timeout / 2;
      /* Make sure we don't return 0 here. */
      if(wtime =3D=3D 0)=20
                        {
                                wtime =3D 1;
      }
                }
        }
  return wtime;
}

//----------------------------------------------------------------------=
-------------
void sys_sem_signal(OS_EVENT* sem)KCREENTRANT
{
        if(OSSemPost (sem)!=3D OS_NO_ERR)
                return;//do error stuff=09
}

//----------------------------------------------------------------------=
-------------
void sys_sem_free(OS_EVENT* sem)KCREENTRANT
{
        INT8U err =3D 0;
        OSSemDel (sem, OS_DEL_ALWAYS, &err);
        if(err !=3D OS_NO_ERR)
                return;//do error stuff=09

        #ifdef SYS_STATS
            stats.sys.sem.used--;
        #endif /* SYS_STATS */
}

//----------------------------------------------------------------------=
-------------
struct sys_timeouts * sys_arch_timeouts(void)KCREENTRANT
{
        int i =3D 0;
  INT8U pid;
  struct timeoutlist *tl =3D 0; =20
        OS_TCB tcb;
 =20
        if(OSTaskQuery (OS_PRIO_SELF, &tcb) !=3D OS_NO_ERR)
                return NULL;

  pid =3D tcb.OSTCBPrio;
  for(i =3D 0; i < nextthread; i++)=20
        {
    tl =3D &timeoutlist[i];
    if(tl->pid =3D=3D pid)=20
                {
      return &(tl->timeouts);
    }
  }

  /* Error! */
  return NULL;
}

void tcpip_init_done(void * a)KCREENTRANT
{
  sys_sem_signal((OS_EVENT *)a);
}
//----------------------------------------------------------------------=
-------------
void sys_init()KCREENTRANT
{
}
//----------------------------------------------------------------------=
-------------

------_=_NextPart_000_01C1DCAB.A1AB4900
Content-Type: application/octet-stream;
        name="sys_arch.h"
Content-Disposition: attachment;
        filename="sys_arch.h"

/*
 * Copyright (c) 2001, Swedish Institute of Computer Science.
 * All rights reserved. 
 *
 * Redistribution and use in source and binary forms, with or without 
 * modification, are permitted provided that the following conditions 
 * are met: 
 * 1. Redistributions of source code must retain the above copyright 
 *    notice, this list of conditions and the following disclaimer. 
 * 2. Redistributions in binary form must reproduce the above copyright 
 *    notice, this list of conditions and the following disclaimer in the 
 *    documentation and/or other materials provided with the distribution. 
 * 3. Neither the name of the Institute nor the names of its contributors 
 *    may be used to endorse or promote products derived from this software 
 *    without specific prior written permission. 
 *
 * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND 
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 
 * ARE DISCLAIMED.  IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE 
 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 
 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 
 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 
 * SUCH DAMAGE. 
 *
 * This file is part of the lwIP TCP/IP stack.
 * 
 * Author: Adam Dunkels <address@hidden>
 *
 * $Id: sys_arch.h,v 1.1 2001/12/12 10:00:57 adam Exp $
 */
#ifndef __ARCH_SYS_ARCH_H__
#define __ARCH_SYS_ARCH_H__

#include "includes.h"

#define SYS_MBOX_NULL NULL
#define SYS_SEM_NULL  NULL

typedef OS_EVENT* sys_sem_t;
typedef OS_EVENT* sys_mbox_t;
typedef INT8U sys_thread_t;

//typedef OS_EVENT SEMA;
//typedef OS_EVENT QUEUE;
//typedef INT8U TASK;

#endif /* __ARCH_SYS_ARCH_H__ */


------_=_NextPart_000_01C1DCAB.A1AB4900--
[This message was sent through the lwip discussion list.]




reply via email to

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