]> rtime.felk.cvut.cz Git - pes-rpp/rpp-lwip.git/commitdiff
ports/posix: generic POSIX system port implemented.
authorPavel Pisa <pisa@cmp.felk.cvut.cz>
Sun, 18 Oct 2015 01:25:53 +0000 (03:25 +0200)
committerPavel Pisa <pisa@cmp.felk.cvut.cz>
Wed, 27 Jul 2016 18:55:44 +0000 (20:55 +0200)
The port is not tested yet. The main missing feature
is to use CLOCK_MONOTONIC instead of CLOCK_REALTIME.

Signed-off-by: Pavel Pisa <pisa@cmp.felk.cvut.cz>
ports/os/posix/Makefile [new file with mode: 0644]
ports/os/posix/Makefile.omk [new file with mode: 0644]
ports/os/posix/arch/cc.h [new file with mode: 0644]
ports/os/posix/arch/perf.h [new file with mode: 0644]
ports/os/posix/arch/sys_arch.c [new file with mode: 0644]
ports/os/posix/arch/sys_arch.h [new file with mode: 0644]

diff --git a/ports/os/posix/Makefile b/ports/os/posix/Makefile
new file mode 100644 (file)
index 0000000..cafc99f
--- /dev/null
@@ -0,0 +1,15 @@
+# Generic directory or leaf node makefile for OCERA make framework
+
+ifndef MAKERULES_DIR
+MAKERULES_DIR := $(shell ( old_pwd="" ;  while [ ! -e Makefile.rules ] ; do if [ "$$old_pwd" = `pwd`  ] ; then exit 1 ; else old_pwd=`pwd` ; cd -L .. 2>/dev/null ; fi ; done ; pwd ) )
+endif
+
+ifeq ($(MAKERULES_DIR),)
+all : default
+.DEFAULT::
+       @echo -e "\nThe Makefile.rules has not been found in this or partent directory\n"
+else
+include $(MAKERULES_DIR)/Makefile.rules
+endif
+
+# DO NOT DELETE
diff --git a/ports/os/posix/Makefile.omk b/ports/os/posix/Makefile.omk
new file mode 100644 (file)
index 0000000..7f4efc6
--- /dev/null
@@ -0,0 +1,6 @@
+# -*- makefile -*-
+
+nobase_include_HEADERS += arch/cc.h arch/perf.h arch/sys_arch.h
+
+lib_LIBRARIES += lwip
+lwip_SOURCES += arch/sys_arch.c
diff --git a/ports/os/posix/arch/cc.h b/ports/os/posix/arch/cc.h
new file mode 100644 (file)
index 0000000..d207cc7
--- /dev/null
@@ -0,0 +1,149 @@
+/*
+ * Copyright (c) 2001-2003 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. The name of the author may not be used to endorse or promote products
+ *    derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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 system adaptation of the lwIP TCP/IP stack
+ * by Adam Dunkels <adam@sics.se> for RTEMS system.
+ *
+ * Author: Premysl Houdek <houdepre@fel.cvut.cz>
+ * Mentor: Pavel Pisa <pisa@cmp.felk.cvut.cz>
+ * Industrial Informatics Group, FEE, Czech Technical University in Prague
+ *
+ */
+/*
+ * settings to adapt lwIP for compiler and machine architecture for RTEMS/GCC
+ * DETAILS: ./lwip/doc/sys_arch.txt
+ */
+#ifndef __CC_H__
+#define __CC_H__
+
+#include <stdio.h>
+#include <inttypes.h>
+#include <stdlib.h>
+#include <machine/endian.h>
+
+/* This file must either include a system-local <errno.h> which defines
+   the standard *nix error codes, or it should #define LWIP_PROVIDE_ERRNO
+   to make lwip/arch.h define the codes which are used throughout. */
+#undef LWIP_PROVIDE_ERRNO
+
+/* type definitions */
+typedef uint8_t             u8_t;
+typedef int8_t              s8_t;
+typedef uint16_t            u16_t;
+typedef int16_t             s16_t;
+typedef uint32_t            u32_t;
+typedef int32_t             s32_t;
+typedef u32_t               mem_ptr_t;
+
+/* Define (sn)printf formatters for these lwIP types */
+#define U16_F PRIu16
+#define S16_F PRId16
+#define X16_F PRIx16
+#define U32_F PRIu32
+#define S32_F PRId32
+#define X32_F PRIx32
+
+#if defined(__arm__) && defined(__ARMCC_VERSION)
+//
+// Setup PACKing macros for KEIL/RVMDK Tools
+//
+    #define PACK_STRUCT_BEGIN __packed
+    #define PACK_STRUCT_STRUCT
+    #define PACK_STRUCT_END
+    #define PACK_STRUCT_FIELD(x) x
+#elif defined (__IAR_SYSTEMS_ICC__)
+//
+// Setup PACKing macros for IAR Tools
+//
+    #define PACK_STRUCT_BEGIN
+    #define PACK_STRUCT_STRUCT
+    #define PACK_STRUCT_END
+    #define PACK_STRUCT_FIELD(x) x
+    #define PACK_STRUCT_USE_INCLUDES
+#elif defined (__TMS470__)
+    #define PACK_STRUCT_BEGIN
+    #define PACK_STRUCT_STRUCT
+    #define PACK_STRUCT_END
+    #define PACK_STRUCT_FIELD(x) x
+#else
+//
+// Setup PACKing macros for GCC Tools
+//
+    #define PACK_STRUCT_BEGIN
+    #define PACK_STRUCT_STRUCT __attribute__ ((__packed__))
+    #define PACK_STRUCT_END
+    #define PACK_STRUCT_FIELD(x) x
+#endif
+
+/*
+ *     1 - load byte by byte, construct 16 bits word and add: not efficient for most platforms
+ *     2 - load first byte if odd address, loop processing 16 bits words, add last byte.
+ *     3 - load first byte and word if not 4 byte aligned, loop processing 32 bits words, add last word/byte.
+ *
+ *     see inet_chksum.c
+ */
+#ifndef LWIP_CHKSUM_ALGORITHM
+#define LWIP_CHKSUM_ALGORITHM 2
+#endif
+
+/* this is used for 1) displaying statistics and 2) lwip debugging (set appropriate debugging level in lwipopts.h) */
+//#ifdef LWIP_DEBUG
+
+
+#define LWIP_PLATFORM_DIAG(expr)        printk expr
+
+//#else
+//#define LWIP_PLATFORM_DIAG(expr)
+//#endif
+
+//#define DEBUG
+#ifdef DEBUG
+
+/* for passing arguments to print function */
+#define CC_ASSERT(message, assertion) do { if (!(assertion)) \
+                                            LWIP_PLATFORM_DIAG(message); } while (0)
+
+//extern void __error__(char *pcFilename, unsigned long ulLine);
+#define LWIP_PLATFORM_ASSERT(expr)      printk((const char *)expr)
+/*
+{                                       \
+    if(!(expr))                         \
+    {                                   \
+        __error__(__FILE__, __LINE__);  \
+    }                                   \
+}
+*/
+#else
+#define LWIP_PLATFORM_ASSERT(expr)
+#define CC_ASSERT(message, assertion)
+#endif /* DEBUG */
+
+/* "lightweight" synchronization mechanisms */
+/* #define SYS_ARCH_DECL_PROTECT(x) */ /* declare a protection state variable */
+/* #define SYS_ARCH_PROTECT(x) */ /* enter protection mode */
+/* #define SYS_ARCH_UNPROTECT(x) */ /* leave protection mode */
+
+#endif /* __CC_H__ */
diff --git a/ports/os/posix/arch/perf.h b/ports/os/posix/arch/perf.h
new file mode 100644 (file)
index 0000000..1f799b3
--- /dev/null
@@ -0,0 +1,12 @@
+#ifndef _LWIP_ARCH_PERF_H_
+#define _LWIP_ARCH_PERF_H_
+
+//perf.h     - Architecture specific performance measurement.
+//Measurement calls made throughout lwip, these can be defined to nothing.
+
+#define PERF_START
+
+#define PERF_STOP(x)
+
+
+#endif /* _LWIP_ARCH_PERF_H_ */
diff --git a/ports/os/posix/arch/sys_arch.c b/ports/os/posix/arch/sys_arch.c
new file mode 100644 (file)
index 0000000..19b6ec2
--- /dev/null
@@ -0,0 +1,455 @@
+/*
+ * Copyright (c) 2001-2003 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. The name of the author may not be used to endorse or promote products
+ *    derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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 system adaptation of the lwIP TCP/IP stack
+ * by Adam Dunkels <adam@sics.se> for RTEMS system.
+ *
+ * Author: Premysl Houdek <houdepre@fel.cvut.cz>
+ * Author: Pavel Pisa <pisa@cmp.felk.cvut.cz>
+ * Industrial Informatics Group, FEE, Czech Technical University in Prague
+ *
+ */
+/*
+ * mapping of lwIP system dependencies to generic POSIX system services and types.
+ * DETAILS: ./lwip/doc/sys_arch.txt
+ */
+
+#include <stdint.h>
+#include <errno.h>
+#include <arch/cc.h>
+#include <time.h>
+#include <stdlib.h>
+#include <string.h>
+#include "sys_arch.h"
+#include "lwip/err.h"
+#include "lwip/tcpip.h"
+#include "lwipopts.h"
+
+#define SYS_LWIP_MBOX_SIZE (sizeof(void *))
+
+clockid_t sys_sem_clockid = CLOCK_REALTIME;
+
+static void
+sys_timespec_msec_add_to(struct timespec *y, uint32_t amsec)
+{
+  y->tv_sec += amsec / 1000;
+  amsec %= 1000;
+  y->tv_nsec += amsec * 1000000;
+  if (y->tv_nsec > 1000000000) {
+    y->tv_nsec -= 1000000000;
+    y->tv_sec++;
+  }
+}
+
+static uint32_t
+sys_timespec_diff_msec(const struct timespec *a, const struct timespec *b)
+{
+  uint32_t diffmsec;
+  uint32_t diffnsec;
+  struct timespec dummy;
+  typeof(dummy.tv_sec) sec;
+
+  sec = a->tv_sec - b->tv_sec;
+  if (sec >= 4294966)
+    sec = 4294966;
+
+  diffmsec = sec * 1000;
+
+  diffnsec = a->tv_nsec - b->tv_nsec;
+  if (diffnsec >= 1000000000) {
+    diffnsec += 1000000000;
+    diffmsec -= 1000;
+  }
+  diffmsec += diffnsec / 1000000;
+  return diffmsec;
+}
+
+uint32_t
+sys_now(void)
+{
+  uint32_t actmsec;
+  struct timespec act_time;
+
+  clock_gettime(sys_sem_clockid, &act_time);
+  actmsec = act_time.tv_sec;
+  actmsec *= 1000;
+  actmsec += act_time.tv_nsec / 1000000000;
+
+  return actmsec;
+}
+
+void
+sys_init(void)
+{
+  //  Is called to initialize the sys_arch layer.
+  return;
+}
+
+err_t
+sys_sem_new(sys_sem_t *sem, u8_t count)
+{
+  int res;
+  res = sem_init(sem, 0, count);
+  if (res != 0)
+    return ERR_MEM;
+
+  return ERR_OK;
+}
+
+
+void
+sys_sem_free(sys_sem_t *sem)
+{
+  sem_destroy(sem);
+}
+
+void
+sys_sem_signal(sys_sem_t *sem)
+{
+  sem_post(sem);
+}
+
+void
+sys_sem_signal_from_ISR(sys_sem_t *sem)
+{
+  sem_post(sem);
+}
+
+
+u32_t
+sys_arch_sem_wait(sys_sem_t *sem, u32_t timeout)
+{
+  int res;
+  struct timespec start_time;
+  struct timespec wait_time;
+
+  clock_gettime(sys_sem_clockid, &start_time);
+
+  if (timeout == 0) {
+    res = sem_wait(sem);
+  } else {
+    wait_time = start_time;
+    sys_timespec_msec_add_to(&wait_time, timeout);
+    res = sem_timedwait(sem, &wait_time);
+  }
+  if (res) {
+    return SYS_ARCH_TIMEOUT;
+  }
+  clock_gettime(sys_sem_clockid, &wait_time);
+
+  return sys_timespec_diff_msec(&wait_time, &start_time);
+}
+
+int
+sys_sem_valid(sys_sem_t *sem)
+{
+  return 1;
+}
+
+void
+sys_sem_set_invalid(sys_sem_t *sem)
+{
+  memset(sem, 0, sizeof(*sem));
+}
+
+err_t
+sys_mbox_new(sys_mbox_t *mbox, int size)
+{
+  int res;
+
+  res = sem_init(&mbox->free_slots, 0, size);
+  if (res != 0)
+    goto error_free_slots_sem;
+
+  res = sem_init(&mbox->full_slots, 0, 0);
+  if (res != 0)
+    goto error_full_slots_sem;
+
+  if (sys_mutex_new(&mbox->mutex) != ERR_OK)
+    goto error_mutex;
+
+  mbox->slots = (typeof(mbox->slots))malloc(sizeof(*mbox->slots) * size);
+  if (mbox->slots == NULL)
+    goto error_alloc_slots;
+
+  mbox->inidx = 0;
+  mbox->outidx = 0;
+  mbox->size = size;
+
+  return ERR_OK;
+
+error_alloc_slots:
+  sys_mutex_free(&mbox->mutex);
+error_mutex:
+  sem_destroy(&mbox->full_slots);
+error_full_slots_sem:
+  sem_destroy(&mbox->free_slots);
+error_free_slots_sem:
+  return ERR_MEM;
+}
+
+void
+sys_mbox_free(sys_mbox_t *mbox)
+{
+  sem_destroy(&mbox->full_slots);
+  sem_destroy(&mbox->free_slots);
+  free(mbox->slots);
+  sys_mutex_free(&mbox->mutex);
+  sys_mbox_set_invalid(mbox);
+}
+
+void
+sys_mbox_post(sys_mbox_t *mbox, void *msg)
+{
+  int res;
+
+  res = sem_wait(&mbox->free_slots);
+  if (res)
+    return;
+
+  pthread_mutex_lock(&mbox->mutex);
+  mbox->slots[mbox->inidx++] = msg;
+  if (mbox->inidx >= mbox->size)
+    mbox->inidx = 0;
+  pthread_mutex_unlock(&mbox->mutex);
+
+  sem_post(&mbox->full_slots);
+}
+
+err_t
+sys_mbox_trypost(sys_mbox_t *mbox, void *msg)
+{
+  int res;
+
+  res = sem_trywait(&mbox->free_slots);
+  if (res)
+    return ERR_MEM;
+
+  pthread_mutex_lock(&mbox->mutex);
+  mbox->slots[mbox->inidx++] = msg;
+  if (mbox->inidx >= mbox->size)
+    mbox->inidx = 0;
+  pthread_mutex_unlock(&mbox->mutex);
+
+  sem_post(&mbox->full_slots);
+
+  return ERR_OK;
+}
+
+u32_t
+sys_arch_mbox_fetch(sys_mbox_t *mbox, void **msg, u32_t timeout)
+{
+  int res;
+  struct timespec start_time;
+  struct timespec wait_time;
+
+  clock_gettime(sys_sem_clockid, &start_time);
+
+  if (timeout == 0) {
+    res = sem_wait(&mbox->full_slots);
+  } else {
+    wait_time = start_time;
+    sys_timespec_msec_add_to(&wait_time, timeout);
+    res = sem_timedwait(&mbox->full_slots, &wait_time);
+  }
+  if (res)
+    return SYS_ARCH_TIMEOUT;
+
+  clock_gettime(sys_sem_clockid, &wait_time);
+
+  pthread_mutex_lock(&mbox->mutex);
+  *msg = mbox->slots[mbox->outidx++];
+  if (mbox->outidx >= mbox->size)
+    mbox->outidx = 0;
+  pthread_mutex_unlock(&mbox->mutex);
+
+  sem_post(&mbox->free_slots);
+
+  return sys_timespec_diff_msec(&wait_time, &start_time);
+}
+
+u32_t
+sys_arch_mbox_tryfetch(sys_mbox_t *mbox, void **msg)
+{
+  int res;
+  struct timespec start_time;
+  struct timespec wait_time;
+
+  clock_gettime(sys_sem_clockid, &start_time);
+
+  res = sem_trywait(&mbox->full_slots);
+  if (res)
+    return SYS_MBOX_EMPTY;
+
+  clock_gettime(sys_sem_clockid, &wait_time);
+
+  pthread_mutex_lock(&mbox->mutex);
+  *msg = mbox->slots[mbox->outidx++];
+  if (mbox->outidx >= mbox->size)
+    mbox->outidx = 0;
+  pthread_mutex_unlock(&mbox->mutex);
+
+  sem_post(&mbox->free_slots);
+
+  return 0;
+}
+
+int
+sys_mbox_valid(sys_mbox_t *mbox)
+{
+  return mbox->size ? 1 : 0;
+}
+
+void
+sys_mbox_set_invalid(sys_mbox_t *mbox)
+{
+  memset(mbox, 0, sizeof(*mbox));
+}
+
+sys_thread_t
+sys_thread_new(const char *name, lwip_thread_fn function, void *arg, int stack_size, int prio)
+{
+  int res;
+  pthread_attr_t taskattr;
+  sys_thread_t thrid;
+  struct sched_param schedparam;
+
+  do {
+    res = pthread_attr_init(&taskattr);
+    if(res != 0)
+      break;
+    res = pthread_attr_setinheritsched(&taskattr, PTHREAD_EXPLICIT_SCHED);
+    if(res != 0)
+      break;
+    res = pthread_attr_setschedpolicy(&taskattr, SCHED_FIFO);
+    if(res != 0)
+      break;
+
+    schedparam.sched_priority = sched_get_priority_min(SCHED_FIFO) + prio;
+    res = pthread_attr_setschedparam(&taskattr, &schedparam);
+    if(res != 0)
+      break;
+
+    if (stack_size) {
+      res = pthread_attr_setstacksize(&taskattr, stack_size);
+      if(res != 0)
+        break;
+    }
+
+    res = pthread_create(&thrid, &taskattr,
+                         (void *(*)(void *))function, arg);
+    if(res != 0)
+      break;
+
+    pthread_detach(thrid);
+  } while(0);
+
+  pthread_attr_destroy(&taskattr);
+
+  if(res != 0)
+    return 0;
+
+  return thrid;
+}
+
+err_t
+sys_mutex_new(sys_mutex_t *mutex)
+{
+  pthread_mutexattr_t mutexattr;
+
+  if (pthread_mutexattr_init(&mutexattr)) {
+    return -1;
+  }
+
+ #ifdef _POSIX_THREAD_PRIO_INHERIT
+  #if _POSIX_THREAD_PRIO_INHERIT > 0
+  if (pthread_mutexattr_setprotocol(&mutexattr, PTHREAD_PRIO_INHERIT)) {
+    return -1;
+  }
+  #endif
+ #endif
+
+  if (pthread_mutex_init(mutex, &mutexattr)) {
+    return -1;
+  }
+
+  pthread_mutexattr_destroy(&mutexattr);
+
+  return ERR_OK;
+}
+
+/** Lock a mutex
+ * @param mutex the mutex to lock */
+void
+sys_mutex_lock(sys_mutex_t *mutex)
+{
+  pthread_mutex_lock(mutex);
+}
+/** Unlock a mutex
+ * @param mutex the mutex to unlock */
+void
+sys_mutex_unlock(sys_mutex_t *mutex)
+{
+  pthread_mutex_unlock(mutex);
+}
+/** Delete a semaphore
+ * @param mutex the mutex to delete */
+void
+sys_mutex_free(sys_mutex_t *mutex)
+{
+  pthread_mutex_destroy(mutex);
+}
+
+void
+sys_arch_delay(unsigned int timeout)
+{
+  struct timespec wait_time;
+
+  wait_time.tv_sec = timeout / 1000;
+  wait_time.tv_nsec = timeout * 1000000;
+
+  nanosleep(&wait_time, NULL);
+}
+
+/** Ticks/jiffies since power up. */
+uint32_t
+sys_jiffies(void)
+{
+  return sys_now();
+}
+
+/*
+int
+sys_request_irq(unsigned int irqnum, sys_irq_handler_t handler,
+               unsigned long flags, const char *name, void *context)
+{
+  rtems_status_code res;
+
+  res = rtems_interrupt_handler_install(irqnum,  name, flags,
+                                       handler, context);
+  return (res != RTEMS_SUCCESSFUL) ? -1 : 0;
+}
+*/
diff --git a/ports/os/posix/arch/sys_arch.h b/ports/os/posix/arch/sys_arch.h
new file mode 100644 (file)
index 0000000..55a1404
--- /dev/null
@@ -0,0 +1,120 @@
+/*
+ * Copyright (c) 2001-2003 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. The name of the author may not be used to endorse or promote products
+ *    derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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 system adaptation of the lwIP TCP/IP stack
+ * by Adam Dunkels <adam@sics.se> for generic POSIX system.
+ *
+ * Author: Premysl Houdek <houdepre@fel.cvut.cz>
+ * Author: Pavel Pisa <pisa@cmp.felk.cvut.cz>
+ * Industrial Informatics Group, FEE, Czech Technical University in Prague
+ *
+ */
+/*
+ * mapping of lwIP system dependencies to RTEMS system services and types.
+ * DETAILS: ./lwip/doc/sys_arch.txt
+ */
+#ifndef __ARCH_SYS_ARCH_H__
+#define __ARCH_SYS_ARCH_H__
+
+#include <semaphore.h>
+#include <pthread.h>
+
+
+/* Typedefs for the various port-specific types. */
+#if defined(NO_SYS) && NO_SYS
+  #error "POSIX SYS_ARCH cannot be compiled in NO_SYS variant"
+#endif
+
+#define sys_arch_printk printk
+
+typedef sem_t port_sem_t;
+
+typedef pthread_mutex_t port_mutex_t;
+
+typedef struct {
+  sem_t free_slots;
+  sem_t full_slots;
+  unsigned int inidx;
+  unsigned int outidx;
+  unsigned int size;
+  void **slots;
+  port_mutex_t mutex;
+} port_mailbox_t;
+
+typedef port_mailbox_t sys_mbox_t;
+typedef port_sem_t sys_sem_t;
+typedef pthread_t sys_thread_t;
+typedef port_mutex_t sys_mutex_t;
+typedef int sys_prot_t;
+
+void
+sys_arch_delay(unsigned int x);
+void
+sys_sem_signal_from_ISR(sys_sem_t *sem);
+
+/*
+typedef void sys_irqreturn_t;
+#define SYS_IRQ_NONE       ((void)0)
+#define SYS_IRQ_HANDLED    ((void)1)
+#define SYS_IRQ_RETVAL(x)  (IRQ_HANDLED)
+typedef rtems_interrupt_handler sys_irq_handler_t;
+#define SYS_IRQ_HANDLER_FNC(M_fnc_name)        \
+  sys_irqreturn_t M_fnc_name(void *__irq_handler_context)
+#define sys_irq_handler_get_context() (__irq_handler_context)
+
+int
+sys_request_irq(unsigned int irqnum, sys_irq_handler_t handler,
+               unsigned long flags, const char *name, void *context);
+
+static inline void
+sys_arch_mask_interrupt_source(unsigned int x)
+{
+  bsp_interrupt_vector_disable(x);
+}
+
+static inline void
+sys_arch_unmask_interrupt_source(unsigned int x)
+{
+  bsp_interrupt_vector_enable(x);
+}
+
+static inline sys_prot_t
+sys_arch_protect(void)
+{
+  sys_prot_t pval;
+
+  rtems_interrupt_disable(pval);
+  return pval;
+}
+
+static inline void
+sys_arch_unprotect(sys_prot_t pval)
+{
+  rtems_interrupt_enable(pval);
+}
+*/
+
+#endif /* __ARCH_SYS_ARCH_H__ */