[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[lwip-users] Re: [lwip] Port to uCOS-II
From: |
Konrad, Guido |
Subject: |
[lwip-users] Re: [lwip] Port to uCOS-II |
Date: |
Wed, 08 Jan 2003 22:18:09 -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_01C1BAEE.F1CD7040
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
Hi Mikael,
I recently finished the sys_arch.c module connecting lwIP to uC-OS-II. =
I
append two files to this mail containing the most important stuff. With =
my
ARM7TDMI it works. Perhaps you can give me feedback or improvements
concerning the code. One problem e.g. is that the sys_thread_new =
function
does not provide a parameter for the task priority, so the one and only =
task
I create with this function is the tcpip task.
Regards,
Guido Konrad
P.S.: This code is my contribution to lwIP. It's great to have such a =
code
for free. Thanks to Adam!
-----Urspr=FCngliche Nachricht-----
Von: Mikael Lundberg [mailto:address@hidden
Gesendet: Donnerstag, 21. Februar 2002 15:57
An: address@hidden
Betreff: [lwip] Port to uCOS-II
Hi all.
I'm going to port lwIP to uCOS-II, and i will ask before I go any =
further,
if=20
somebody already have a uCOS-port ready (or half-ready =3D) .
Regards
//Mikael Lundberg
[This message was sent through the lwip discussion list.]
------_=_NextPart_000_01C1BAEE.F1CD7040
Content-Type: application/octet-stream;
name="sys_arch.c"
Content-Transfer-Encoding: quoted-printable
Content-Disposition: attachment;
filename="sys_arch.c"
/*=0A=
* Copyright (c) 2001, Swedish Institute of Computer Science.=0A=
* All rights reserved. =0A=
*=0A=
* Redistribution and use in source and binary forms, with or without =
=0A=
* modification, are permitted provided that the following conditions =
=0A=
* are met: =0A=
* 1. Redistributions of source code must retain the above copyright =
=0A=
* notice, this list of conditions and the following disclaimer. =0A=
* 2. Redistributions in binary form must reproduce the above copyright =
=0A=
* notice, this list of conditions and the following disclaimer in =
the =0A=
* documentation and/or other materials provided with the =
distribution. =0A=
* 3. Neither the name of the Institute nor the names of its =
contributors =0A=
* may be used to endorse or promote products derived from this =
software =0A=
* without specific prior written permission. =0A=
*=0A=
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS =
IS'' AND =0A=
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, =
THE =0A=
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR =
PURPOSE =0A=
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE =
LIABLE =0A=
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR =
CONSEQUENTIAL =0A=
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE =
GOODS =0A=
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS =
INTERRUPTION) =0A=
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, =
STRICT =0A=
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN =
ANY WAY =0A=
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY =
OF =0A=
* SUCH DAMAGE. =0A=
*=0A=
* This file is part of the lwIP TCP/IP stack.=0A=
* =0A=
* Author: Adam Dunkels <address@hidden>=0A=
*=0A=
* $Id: sys_arch.c,v 1.1 2001/12/12 10:00:56 adam Exp $=0A=
*/=0A=
=0A=
#include <stdlib.h>=0A=
=0A=
#include "lwip/debug.h"=0A=
=0A=
#include "lwip/def.h"=0A=
#include "lwip/sys.h"=0A=
#include "lwip/mem.h"=0A=
=0A=
#include "sys_arch.h"=0A=
=0A=
struct timeoutlist {=0A=
struct sys_timeouts timeouts;=0A=
int pid;=0A=
};=0A=
=0A=
const void * const pvNullPointer;=0A=
=0A=
static OS_MEM *pQueueMem;=0A=
__align(8) static char pcQueueMemoryPool[MAX_QUEUES * sizeof(TQ_DESCR) =
];=0A=
=0A=
/*----------------------------------------------------------------------=
-------------*/=0A=
sys_mbox_t=0A=
sys_mbox_new(void)=0A=
{=0A=
INT8U ucErr;=0A=
PQ_DESCR pQDesc;=0A=
=0A=
pQDesc =3D OSMemGet( pQueueMem, &ucErr );=0A=
ASSERT( "OSMemGet ", ucErr =3D=3D OS_NO_ERR );=0A=
if( ucErr =3D=3D OS_NO_ERR ) { =0A=
pQDesc->pQ =3D OSQCreate( &(pQDesc->pvQEntries[0]), =
MAX_QUEUE_ENTRIES ); =0A=
ASSERT( "OSQCreate ", pQDesc->pQ !=3D NULL );=0A=
if( pQDesc->pQ !=3D NULL ) {=0A=
return pQDesc;=0A=
}=0A=
} =0A=
return SYS_MBOX_NULL;=0A=
}=0A=
=0A=
/*----------------------------------------------------------------------=
-------------*/=0A=
void=0A=
sys_mbox_free(sys_mbox_t mbox)=0A=
{=0A=
INT8U ucErr;=0A=
=0A=
ASSERT( "sys_mbox_free ", mbox !=3D SYS_MBOX_NULL ); =0A=
OSQFlush( mbox->pQ );=0A=
=0A=
(void)OSQDel( mbox->pQ, OS_DEL_NO_PEND, &ucErr);=0A=
ASSERT( "OSQDel ", ucErr =3D=3D OS_NO_ERR ); =0A=
=0A=
ucErr =3D OSMemPut( pQueueMem, mbox );=0A=
ASSERT( "OSMemPut ", ucErr =3D=3D OS_NO_ERR );=0A=
}=0A=
=0A=
/*----------------------------------------------------------------------=
-------------*/=0A=
void=0A=
sys_mbox_post(sys_mbox_t mbox, void *data)=0A=
{=0A=
if( !data ) data =3D (void*)&pvNullPointer;=0A=
(void)OSQPost( mbox->pQ, data);=0A=
}=0A=
=0A=
/*----------------------------------------------------------------------=
-------------*/=0A=
u16_t=0A=
sys_arch_mbox_fetch(sys_mbox_t mbox, void **data, u16_t timeout)=0A=
{=0A=
INT8U ucErr;=0A=
=0A=
*data =3D OSQPend( mbox->pQ, timeout, &ucErr ); =0A=
if( ucErr =3D=3D OS_TIMEOUT ) {=0A=
timeout =3D 0;=0A=
} else {=0A=
ASSERT( "OSQPend ", ucErr =3D=3D OS_NO_ERR );=0A=
if( *data =3D=3D (void*)&pvNullPointer ) *data =3D NULL;=0A=
/* Calculate time we waited for the message to arrive. */ =
=0A=
/* XXX: we cheat and just pretend that we waited for half the =
timeout value! */=0A=
timeout /=3D 2;=0A=
if( timeout =3D=3D 0 ) timeout =3D 1;=0A=
}=0A=
return timeout;=0A=
}=0A=
=0A=
/*----------------------------------------------------------------------=
-------------*/=0A=
sys_sem_t=0A=
sys_sem_new(u8_t count)=0A=
{=0A=
sys_sem_t pSem;=0A=
pSem =3D OSSemCreate( (INT16U)count );=0A=
ASSERT( "OSSemCreate ", pSem !=3D NULL );=0A=
return pSem;=0A=
}=0A=
/*----------------------------------------------------------------------=
-------------*/=0A=
u16_t=0A=
sys_arch_sem_wait(sys_sem_t sem, u16_t timeout)=0A=
{=0A=
INT8U ucErr;=0A=
=0A=
OSSemPend( sem, timeout, &ucErr ); =0A=
if( ucErr =3D=3D OS_TIMEOUT ) {=0A=
timeout =3D 0;=0A=
} else {=0A=
ASSERT( "OSSemPend ", ucErr =3D=3D OS_NO_ERR );=0A=
/* Calculate time we waited for the message to arrive. */ =
=0A=
/* XXX: we cheat and just pretend that we waited for half the =
timeout value! */=0A=
timeout /=3D 2;=0A=
if( timeout =3D=3D 0 ) timeout =3D 1;=0A=
}=0A=
return timeout;=0A=
}=0A=
/*----------------------------------------------------------------------=
-------------*/=0A=
void=0A=
sys_sem_signal(sys_sem_t sem)=0A=
{=0A=
INT8U ucErr;=0A=
ucErr =3D OSSemPost( sem );=0A=
=0A=
/* It may happen that a connection is already reset and the =
semaphore is deleted=0A=
if this function is called. Therefore ASSERTION should not be =
called */ =0A=
//ASSERT( "OSSemPost ", ucErr =3D=3D OS_NO_ERR );=0A=
=0A=
}=0A=
/*----------------------------------------------------------------------=
-------------*/=0A=
void=0A=
sys_sem_free(sys_sem_t sem)=0A=
{=0A=
INT8U ucErr;=0A=
=0A=
(void)OSSemDel( sem, OS_DEL_NO_PEND, &ucErr );=0A=
=0A=
ASSERT( "OSSemDel ", ucErr =3D=3D OS_NO_ERR );=0A=
}=0A=
=0A=
/*----------------------------------------------------------------------=
-------------*/=0A=
void=0A=
sys_init(void)=0A=
{=0A=
INT8U ucErr;=0A=
=0A=
pQueueMem =3D OSMemCreate( (void*)pcQueueMemoryPool, MAX_QUEUES, =
sizeof(TQ_DESCR), &ucErr );=0A=
=0A=
ASSERT( "OSMemCreate ", ucErr =3D=3D OS_NO_ERR ); =0A=
}=0A=
=0A=
struct sys_timeouts timeouts;=0A=
/*----------------------------------------------------------------------=
-------------*/=0A=
struct sys_timeouts *=0A=
sys_arch_timeouts(void)=0A=
{=0A=
/* Since we allow only one thread (TCP/IP) to be created by the =
systhread =0A=
function we do need only one timeout list */=0A=
return &timeouts;=0A=
}=0A=
=0A=
/*----------------------------------------------------------------------=
-------------*/=0A=
OS_STK tcp_stack[TCP_STACKSIZE];=0A=
void=0A=
sys_thread_new(void (* function)(void *arg), void *arg) =0A=
{=0A=
static int iTaskCreated =3D 0;=0A=
=0A=
/* Take care that only one task can be created with this function =
*/=0A=
if( iTaskCreated ) return;=0A=
=0A=
(void)OSTaskCreate( function, arg, (void *)&tcp_stack[TCP_STACKSIZE =
- 1], TCP_TASK_PRIO );=0A=
=0A=
iTaskCreated =3D 1;=0A=
}=0A=
------_=_NextPart_000_01C1BAEE.F1CD7040
Content-Type: application/octet-stream;
name="sys_arch.h"
Content-Transfer-Encoding: quoted-printable
Content-Disposition: attachment;
filename="sys_arch.h"
/*=0A=
* Copyright (c) 2001, Swedish Institute of Computer Science.=0A=
* All rights reserved. =0A=
*=0A=
* Redistribution and use in source and binary forms, with or without =
=0A=
* modification, are permitted provided that the following conditions =
=0A=
* are met: =0A=
* 1. Redistributions of source code must retain the above copyright =
=0A=
* notice, this list of conditions and the following disclaimer. =0A=
* 2. Redistributions in binary form must reproduce the above copyright =
=0A=
* notice, this list of conditions and the following disclaimer in =
the =0A=
* documentation and/or other materials provided with the =
distribution. =0A=
* 3. Neither the name of the Institute nor the names of its =
contributors =0A=
* may be used to endorse or promote products derived from this =
software =0A=
* without specific prior written permission. =0A=
*=0A=
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS =
IS'' AND =0A=
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, =
THE =0A=
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR =
PURPOSE =0A=
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE =
LIABLE =0A=
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR =
CONSEQUENTIAL =0A=
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE =
GOODS =0A=
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS =
INTERRUPTION) =0A=
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, =
STRICT =0A=
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN =
ANY WAY =0A=
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY =
OF =0A=
* SUCH DAMAGE. =0A=
*=0A=
* This file is part of the lwIP TCP/IP stack.=0A=
* =0A=
* Author: Adam Dunkels <address@hidden>=0A=
*=0A=
* $Id: sys_arch.h,v 1.1 2001/12/12 10:00:56 adam Exp $=0A=
*/=0A=
#ifndef __SYS_ARCH__H__=0A=
#define __SYS_ARCH__H__=0A=
=0A=
#include "sysopts.h"=0A=
=0A=
#define SYS_MBOX_NULL NULL=0A=
#define SYS_SEM_NULL NULL=0A=
=0A=
typedef struct {=0A=
OS_EVENT* pQ;=0A=
void* pvQEntries[MAX_QUEUE_ENTRIES];=0A=
} TQ_DESCR, *PQ_DESCR;=0A=
=0A=
typedef OS_EVENT* sys_sem_t;=0A=
typedef PQ_DESCR sys_mbox_t;=0A=
typedef INT8U sys_thread_t;=0A=
=0A=
#endif /* __SYS_RTXC_H__ */=0A=
=0A=
------_=_NextPart_000_01C1BAEE.F1CD7040--
[This message was sent through the lwip discussion list.]
- [lwip-users] Re: [lwip] Port to uCOS-II,
Konrad, Guido <=
- [lwip-users] RE: [lwip] Port to uCOS-II, DASILVA VINCENTE BIT, 2003/01/08
- [lwip-users] RE: [lwip] Port to uCOS-II, Mikael Lundberg, 2003/01/08
- [lwip-users] RE: [lwip] Port to uCOS-II, DASILVA VINCENTE BIT, 2003/01/08
- [lwip-users] Re: [lwip] Port to uCOS-II, Ganesh S, 2003/01/08
- [lwip-users] RE: [lwip] Port to uCOS-II, DASILVA VINCENTE BIT, 2003/01/08
- [lwip-users] Re: [lwip] Port to uCOS-II, Bill Knight, 2003/01/09
- [lwip-users] Re: [lwip] Port to uCOS-II, Taco Walstra, 2003/01/09
- [lwip-users] RE: [lwip] Port to uCOS-II, DASILVA VINCENTE BIT, 2003/01/09
- [lwip-users] Re: [lwip] Port to uCOS-II, Adam Dunkels, 2003/01/09