summaryrefslogtreecommitdiff
path: root/lwip/ports/os/rtems/arch
diff options
context:
space:
mode:
Diffstat (limited to 'lwip/ports/os/rtems/arch')
-rw-r--r--lwip/ports/os/rtems/arch/cc.h177
-rw-r--r--lwip/ports/os/rtems/arch/perf.h12
-rw-r--r--lwip/ports/os/rtems/arch/sys_arch.c378
-rw-r--r--lwip/ports/os/rtems/arch/sys_arch.h108
4 files changed, 675 insertions, 0 deletions
diff --git a/lwip/ports/os/rtems/arch/cc.h b/lwip/ports/os/rtems/arch/cc.h
new file mode 100644
index 0000000..84138ff
--- /dev/null
+++ b/lwip/ports/os/rtems/arch/cc.h
@@ -0,0 +1,177 @@
+/*
+ * 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 <rtems/malloc.h> /*printk*/
+#include <inttypes.h>
+#include <malloc.h>
+#include <sys/time.h>
+#include <rtems.h>
+#include <sys/errno.h>
+#include <endian.h>
+#include <stdlib.h>
+#include <stdint.h>
+
+#include <sys/uio.h> /*struct iovec*/
+
+#ifndef iovec
+#define iovec iovec
+#endif
+
+/* 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
+
+#if !defined(LWIP_NO_STDINT_H)
+#define LWIP_NO_STDINT_H 0
+#endif
+
+#if LWIP_NO_STDINT_H
+/* 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;
+
+#endif /*LWIP_NO_STDINT_H*/
+
+#if !defined(LWIP_NO_INTTYPES_H)
+#define LWIP_NO_INTTYPES_H 0
+#endif
+
+#if LWIP_NO_INTTYPES_H
+/* 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
+#endif /*LWIP_NO_INTTYPES_H*/
+
+#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 */
+
+/* 32-bit random value used by igmp and others */
+#define LWIP_RAND() ((uint32_t)random())
+
+#endif /* __CC_H__ */
diff --git a/lwip/ports/os/rtems/arch/perf.h b/lwip/ports/os/rtems/arch/perf.h
new file mode 100644
index 0000000..1f799b3
--- /dev/null
+++ b/lwip/ports/os/rtems/arch/perf.h
@@ -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/lwip/ports/os/rtems/arch/sys_arch.c b/lwip/ports/os/rtems/arch/sys_arch.c
new file mode 100644
index 0000000..ca7f8be
--- /dev/null
+++ b/lwip/ports/os/rtems/arch/sys_arch.c
@@ -0,0 +1,378 @@
+/*
+ * 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
+ *
+ */
+/*
+ * mapping of lwIP system dependencies to RTEMS system services and types.
+ * DETAILS: ./lwip/doc/sys_arch.txt
+ */
+
+#include <stdint.h>
+#include <arch/cc.h>
+#include <rtems/rtems/clock.h>
+#include <rtems/rtems/sem.h>
+#include <rtems.h>
+#include "sys_arch.h"
+#include "lwip/err.h"
+#include "lwip/tcpip.h"
+#include "lwipopts.h"
+
+#define SYS_LWIP_MBOX_SIZE (sizeof(void *))
+
+uint32_t
+sys_now()
+{
+ uint64_t temp = rtems_clock_get_uptime_nanoseconds() / (1000 * 1000);
+
+ return temp;
+}
+
+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)
+{
+ rtems_status_code ret = rtems_semaphore_create(
+ rtems_build_name('L', 'W', 'I', 'P'),
+ count,
+ RTEMS_COUNTING_SEMAPHORE,
+ 0,
+ &sem->semaphore
+ );
+
+ if (ret != RTEMS_SUCCESSFUL) {
+ sem->semaphore = RTEMS_ID_NONE;
+ return ret;
+ }
+ return ERR_OK;
+}
+
+
+void
+sys_sem_free(sys_sem_t *sem)
+{
+ rtems_semaphore_delete(
+ sem->semaphore
+ );
+ sem->semaphore = RTEMS_ID_NONE;
+}
+
+void
+sys_sem_signal(sys_sem_t *sem)
+{
+ rtems_semaphore_release(sem->semaphore);
+}
+
+void
+sys_sem_signal_from_ISR(sys_sem_t *sem)
+{
+ rtems_semaphore_release(sem->semaphore);
+}
+
+
+u32_t
+sys_arch_sem_wait(sys_sem_t *sem, u32_t timeout)
+{
+ rtems_status_code status;
+ rtems_interval tps = rtems_clock_get_ticks_per_second();
+ rtems_interval tick_timeout;
+ uint64_t start_time;
+ uint64_t wait_time;
+
+ start_time = rtems_clock_get_uptime_nanoseconds();
+ if (timeout == 0) {
+ tick_timeout = RTEMS_NO_TIMEOUT;
+ } else {
+ tick_timeout = (timeout * tps + 999) / 1000;
+ }
+ status = rtems_semaphore_obtain(sem->semaphore, RTEMS_WAIT, tick_timeout);
+ if (status == RTEMS_TIMEOUT) {
+ return SYS_ARCH_TIMEOUT;
+ }
+ if (status != RTEMS_SUCCESSFUL) {
+ return SYS_ARCH_TIMEOUT;
+ }
+ wait_time = rtems_clock_get_uptime_nanoseconds() - start_time;
+ return wait_time / (1000 * 1000);
+}
+
+int
+sys_sem_valid(sys_sem_t *sem)
+{
+ return sem->semaphore == RTEMS_ID_NONE ? 0 : 1;
+}
+
+void
+sys_sem_set_invalid(sys_sem_t *sem)
+{
+ sem->semaphore = RTEMS_ID_NONE;
+}
+
+err_t
+sys_mbox_new(sys_mbox_t *mbox, int size)
+{
+ rtems_status_code ret;
+
+ ret = rtems_message_queue_create(
+ rtems_build_name('L', 'W', 'I', 'P'),
+ size,
+ SYS_LWIP_MBOX_SIZE,
+ 0,
+ &mbox->mailbox
+ );
+ ret |= rtems_semaphore_create(
+ rtems_build_name('L', 'W', 'I', 'P'),
+ size,
+ RTEMS_COUNTING_SEMAPHORE,
+ 0,
+ &mbox->sem
+ );
+ if (ret != RTEMS_SUCCESSFUL) {
+ mbox->mailbox = RTEMS_ID_NONE;
+ mbox->sem = RTEMS_ID_NONE;
+ return ret;
+ }
+ return ERR_OK;
+}
+
+void
+sys_mbox_free(sys_mbox_t *mbox)
+{
+ rtems_message_queue_delete(mbox->mailbox);
+ rtems_semaphore_delete(mbox->sem);
+ sys_mbox_set_invalid(mbox);
+}
+
+void
+sys_mbox_post(sys_mbox_t *mbox, void *msg)
+{
+ rtems_semaphore_obtain(mbox->sem, RTEMS_WAIT, RTEMS_NO_TIMEOUT);
+ rtems_message_queue_send(mbox->mailbox, &msg, SYS_LWIP_MBOX_SIZE);
+}
+err_t
+sys_mbox_trypost(sys_mbox_t *mbox, void *msg)
+{
+ rtems_status_code status = rtems_semaphore_obtain(mbox->sem,
+ RTEMS_NO_WAIT, 0);
+
+ if (status != RTEMS_SUCCESSFUL) {
+ return ERR_MEM;
+ } else {
+ rtems_message_queue_send(mbox->mailbox, &msg, SYS_LWIP_MBOX_SIZE);
+ return ERR_OK;
+ }
+}
+
+u32_t
+sys_arch_mbox_fetch(sys_mbox_t *mbox, void **msg, u32_t timeout)
+{
+ rtems_status_code status;
+ rtems_interval tps = rtems_clock_get_ticks_per_second();
+ rtems_interval tick_timeout;
+ uint64_t start_time;
+ uint64_t wait_time;
+ size_t dummy;
+
+ start_time = rtems_clock_get_uptime_nanoseconds();
+ if (timeout == 0) {
+ tick_timeout = RTEMS_NO_TIMEOUT;
+ } else {
+ tick_timeout = (timeout * tps + 999) / 1000;
+ }
+ status = rtems_message_queue_receive(mbox->mailbox,
+ msg,
+ &dummy,
+ RTEMS_WAIT,
+ tick_timeout
+ );
+ if (status == RTEMS_TIMEOUT) {
+ return SYS_ARCH_TIMEOUT;
+ }
+ if (status != RTEMS_SUCCESSFUL) {
+ return SYS_ARCH_TIMEOUT;
+ }
+ wait_time = rtems_clock_get_uptime_nanoseconds() - start_time;
+ rtems_semaphore_release(mbox->sem);
+ return wait_time / (1000 * 1000);
+}
+
+u32_t
+sys_arch_mbox_tryfetch(sys_mbox_t *mbox, void **msg)
+{
+ rtems_status_code status;
+ size_t dummy;
+
+ status = rtems_message_queue_receive(mbox->mailbox, msg,
+ &dummy,
+ RTEMS_NO_WAIT,
+ 0
+ );
+
+ if (status != RTEMS_SUCCESSFUL) {
+ return SYS_MBOX_EMPTY;
+ } else {
+ rtems_semaphore_release(mbox->sem);
+ return 0;
+ }
+}
+int
+sys_mbox_valid(sys_mbox_t *mbox)
+{
+ return mbox->mailbox == RTEMS_ID_NONE ? 0 : 1;
+}
+void
+sys_mbox_set_invalid(sys_mbox_t *mbox)
+{
+ mbox->sem = RTEMS_ID_NONE;
+ mbox->mailbox = RTEMS_ID_NONE;
+}
+
+sys_thread_t
+sys_thread_new(const char *name, lwip_thread_fn function, void *arg, int stack_size, int prio)
+{
+ rtems_id id;
+ rtems_status_code res;
+
+ res = rtems_task_create(
+ rtems_build_name('L', 'W', 'I', 'P'),
+ prio,
+ stack_size,
+ RTEMS_PREEMPT,
+ 0,
+ &id
+ );
+
+ if (res != RTEMS_SUCCESSFUL) {
+ return 0;
+ }
+
+ res = rtems_task_start(id, (rtems_task_entry)function, (rtems_task_argument)arg);
+
+ if (res != RTEMS_SUCCESSFUL) {
+ rtems_task_delete(id);
+ return 0;
+ }
+ return id;
+}
+
+err_t
+sys_mutex_new(sys_mutex_t *mutex)
+{
+ rtems_status_code ret = rtems_semaphore_create(
+ rtems_build_name('L', 'W', 'I', 'P'),
+ 1,
+ RTEMS_PRIORITY|RTEMS_BINARY_SEMAPHORE|RTEMS_INHERIT_PRIORITY|RTEMS_LOCAL,
+ 0,
+ &mutex->mutex
+ );
+
+ if (ret != RTEMS_SUCCESSFUL) {
+ mutex->mutex = RTEMS_ID_NONE;
+ return ret;
+ }
+ return ERR_OK;
+}
+/** Lock a mutex
+ * @param mutex the mutex to lock */
+void
+sys_mutex_lock(sys_mutex_t *mutex)
+{
+ rtems_semaphore_obtain(mutex->mutex, RTEMS_WAIT, RTEMS_NO_TIMEOUT);
+}
+/** Unlock a mutex
+ * @param mutex the mutex to unlock */
+void
+sys_mutex_unlock(sys_mutex_t *mutex)
+{
+ rtems_semaphore_release(mutex->mutex);
+}
+/** Delete a semaphore
+ * @param mutex the mutex to delete */
+void
+sys_mutex_free(sys_mutex_t *mutex)
+{
+ rtems_semaphore_delete(mutex->mutex);
+}
+
+void
+sys_arch_delay(unsigned int timeout)
+{
+ rtems_interval tps = rtems_clock_get_ticks_per_second();
+ rtems_interval tick_timeout = (timeout * tps + 999) / 1000;
+
+ rtems_task_wake_after(tick_timeout);
+}
+
+/** Ticks/jiffies since power up. */
+uint32_t
+sys_jiffies(void)
+{
+ return rtems_clock_get_ticks_since_boot();
+}
+
+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;
+}
+
+sys_prot_t
+sys_arch_protect()
+{
+ sys_prot_t pval;
+
+ rtems_interrupt_disable(pval);
+ return pval;
+}
+
+void
+sys_arch_unprotect(sys_prot_t pval)
+{
+ rtems_interrupt_enable(pval);
+}
+err_t
+sys_mbox_trypost_fromisr(sys_mbox_t *q, void *msg)
+{
+ return sys_mbox_trypost(q, msg);
+}
+
diff --git a/lwip/ports/os/rtems/arch/sys_arch.h b/lwip/ports/os/rtems/arch/sys_arch.h
new file mode 100644
index 0000000..c89abd4
--- /dev/null
+++ b/lwip/ports/os/rtems/arch/sys_arch.h
@@ -0,0 +1,108 @@
+/*
+ * 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
+ *
+ */
+/*
+ * 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 <rtems/rtems/sem.h>
+#include <rtems/rtems/intr.h>
+#include <rtems/score/cpu.h>
+#include <bsp/irq-generic.h>
+//#include "eth_lwip_default.h"
+
+/* Typedefs for the various port-specific types. */
+#if defined(NO_SYS) && NO_SYS
+ #error "RTEMS SYS_ARCH cannot be compiled in NO_SYS variant"
+#endif
+
+#define sys_arch_printk printk
+
+typedef struct {
+ rtems_id mailbox;
+ rtems_id sem;
+} port_mailbox_t;
+
+typedef struct {
+ rtems_id semaphore;
+} port_sem_t;
+
+typedef struct {
+ rtems_id mutex;
+} port_mutex_t;
+
+typedef port_mailbox_t sys_mbox_t;
+typedef port_sem_t sys_sem_t;
+typedef rtems_id sys_thread_t;
+typedef port_mutex_t sys_mutex_t;
+typedef rtems_interrupt_level 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);
+}
+
+sys_prot_t sys_arch_protect();
+
+void sys_arch_unprotect(sys_prot_t pval);
+
+#endif /* __ARCH_SYS_ARCH_H__ */