FreeRTOS port
---
.../{old/rtxc => freertos/port}/include/arch/cc.h | 72 ++--
.../rtxc => freertos/port}/include/arch/init.h | 0
.../{old/rtxc => freertos/port}/include/arch/lib.h | 0
.../rtxc => freertos/port}/include/arch/sys_arch.h | 19 +-
.../include/arch => freertos/port/include}/perf.h | 0
ports/freertos/port/sys_arch.c | 480 +++++++++++++++++++++
6 files changed, 540 insertions(+), 31 deletions(-)
copy ports/{old/rtxc => freertos/port}/include/arch/cc.h (64%)
copy ports/{old/rtxc => freertos/port}/include/arch/init.h (100%)
copy ports/{old/rtxc => freertos/port}/include/arch/lib.h (100%)
copy ports/{old/rtxc => freertos/port}/include/arch/sys_arch.h (81%)
copy ports/{old/rtxc/include/arch => freertos/port/include}/perf.h (100%)
create mode 100644 ports/freertos/port/sys_arch.c
diff --git a/ports/old/rtxc/include/arch/cc.h b/ports/freertos/port/include/arch/cc.h
similarity index 64%
copy from ports/old/rtxc/include/arch/cc.h
copy to ports/freertos/port/include/arch/cc.h
index ac55609..05b4e62 100644
--- a/ports/old/rtxc/include/arch/cc.h
+++ b/ports/freertos/port/include/arch/cc.h
@@ -1,8 +1,8 @@
/*
* Copyright (c) 2001-2003 Swedish Institute of Computer Science.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without modification,
+ * 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,
@@ -11,27 +11,37 @@
* 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.
+ * 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
+ * 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 part of the lwIP TCP/IP stack.
- *
+ *
* Author: Adam Dunkels
*
*/
#ifndef __CC_H__
#define __CC_H__
+#include
+#include
+
+#define U16_F "hu"
+#define X16_F "hX"
+#define U32_F "u"
+#define X32_F "X"
+#define S16_F "hd"
+#define S32_F "d"
+
typedef unsigned char u8_t;
typedef signed char s8_t;
typedef unsigned short u16_t;
@@ -39,16 +49,28 @@ typedef signed short s16_t;
typedef unsigned long u32_t;
typedef signed long s32_t;
-#define U16_F "hu"
-#define S16_F "hd"
-#define X16_F "hx"
-#define U32_F "lu"
-#define S32_F "ld"
-#define X32_F "lx"
-
-#define PACK_STRUCT_BEGIN
-#define PACK_STRUCT_STRUCT
-#define PACK_STRUCT_END
-#define PACK_STRUCT_FIELD(x) x
+/* typedef u32_t mem_ptr_t; */
+typedef int sys_prot_t;
+
+#define LWIP_TIMEVAL_PRIVATE 0
+
+/* Define platform endianness */
+#ifndef BYTE_ORDER
+#define BYTE_ORDER LITTLE_ENDIAN
+#endif /* BYTE_ORDER */
+
+/* Compiler hints for packing structures */
+#define PACK_STRUCT_STRUCT __attribute__((packed))
+
+
+/* Plaform specific diagnostic output */
+#define LWIP_PLATFORM_DIAG(x) do {printf x;} while(0)
+
+#define LWIP_PLATFORM_ASSERT(x) do {printf("Assertion \"%s\" failed at line %d
+in %s\n", \
+ x, __LINE__, __FILE__); fflush(NULL);
+abort();} while(0)
+
+#define LWIP_RAND() ((u32_t)rand())
#endif /* __CC_H__ */
diff --git a/ports/old/rtxc/include/arch/init.h b/ports/freertos/port/include/arch/init.h
similarity index 100%
copy from ports/old/rtxc/include/arch/init.h
copy to ports/freertos/port/include/arch/init.h
diff --git a/ports/old/rtxc/include/arch/lib.h b/ports/freertos/port/include/arch/lib.h
similarity index 100%
copy from ports/old/rtxc/include/arch/lib.h
copy to ports/freertos/port/include/arch/lib.h
diff --git a/ports/old/rtxc/include/arch/sys_arch.h b/ports/freertos/port/include/arch/sys_arch.h
similarity index 81%
copy from ports/old/rtxc/include/arch/sys_arch.h
copy to ports/freertos/port/include/arch/sys_arch.h
index f423fb6..cdf4c29 100644
--- a/ports/old/rtxc/include/arch/sys_arch.h
+++ b/ports/freertos/port/include/arch/sys_arch.h
@@ -32,14 +32,21 @@
#ifndef __SYS_RTXC_H__
#define __SYS_RTXC_H__
-#include "rtxcapi.h"
+#include "FreeRTOS.h"
+#include "task.h"
+#include "queue.h"
+#include "semphr.h"
-#define SYS_MBOX_NULL (QUEUE)0
-#define SYS_SEM_NULL (SEMA)0
+#define SYS_MBOX_NULL (xQueueHandle)0
+#define SYS_SEM_NULL (xSemaphoreHandle)0
-typedef SEMA sys_sem_t;
-typedef QUEUE sys_mbox_t;
-typedef TASK sys_thread_t;
+typedef xSemaphoreHandle sys_sem_t;
+typedef xQueueHandle sys_mbox_t;
+typedef xTaskHandle sys_thread_t;
+
+/* Message queue constants. */
+#define archMESG_QUEUE_LENGTH ( 32 )
+#define archPOST_BLOCK_TIME_MS ( ( unsigned portLONG ) 10000 )
#endif /* __SYS_RTXC_H__ */
diff --git a/ports/old/rtxc/include/arch/perf.h b/ports/freertos/port/include/perf.h
similarity index 100%
copy from ports/old/rtxc/include/arch/perf.h
copy to ports/freertos/port/include/perf.h
diff --git a/ports/freertos/port/sys_arch.c b/ports/freertos/port/sys_arch.c
new file mode 100644
index 0000000..2d04047
--- /dev/null
+++ b/ports/freertos/port/sys_arch.c
@@ -0,0 +1,480 @@
+/*
+ * 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 part of the lwIP TCP/IP stack.
+ *
+ * Author: Adam Dunkels
+ * Author: Stefano Oliveri
+ *
+ * This file was modified by Stefano Oliveri to implement the system emulation layer for STR91x.
+ *
+ */
+
+/* lwIP includes. */
+#include "lwip/debug.h"
+#include "lwip/def.h"
+#include "lwip/sys.h"
+#include "lwip/mem.h"
+#include "lwip/stats.h"
+
+#define SYS_MAX_Q 20
+static xQueueHandle sys_mbox_table[SYS_MAX_Q];
+#define SYS_MAX_SEM 20
+static xQueueHandle sys_sem_table[SYS_MAX_SEM];
+
+/* This is the number of threads that can be started with sys_thread_new() */
+#define SYS_THREAD_MAX 4
+
+static u16_t s_nextthread = 0;
+
+/*-----------------------------------------------------------------------------------*/
+/* Creates an empty mailbox. */
+err_t sys_mbox_new(sys_mbox_t *mbox, int size)
+{
+ int i;
+ err_t ret = ERR_OK;
+ *mbox = xQueueCreate( archMESG_QUEUE_LENGTH, sizeof( void * ) );
+
+#if SYS_STATS
+ ++lwip_stats.sys.mbox.used;
+ if (lwip_stats.sys.mbox.max < lwip_stats.sys.mbox.used) {
+ lwip_stats.sys.mbox.max = lwip_stats.sys.mbox.used;
+ }
+#endif /* SYS_STATS */
+ vTaskSuspendAll();
+ for(i=0;i