]> git.sur5r.net Git - freertos/blobdiff - FreeRTOS/Demo/lwIP_MCF5235_GCC/lwip/src/include/lwip/sys.h
Add FreeRTOS-Plus directory.
[freertos] / FreeRTOS / Demo / lwIP_MCF5235_GCC / lwip / src / include / lwip / sys.h
diff --git a/FreeRTOS/Demo/lwIP_MCF5235_GCC/lwip/src/include/lwip/sys.h b/FreeRTOS/Demo/lwIP_MCF5235_GCC/lwip/src/include/lwip/sys.h
new file mode 100644 (file)
index 0000000..d2328c4
--- /dev/null
@@ -0,0 +1,183 @@
+/*\r
+ * Copyright (c) 2001-2004 Swedish Institute of Computer Science.\r
+ * All rights reserved. \r
+ * \r
+ * Redistribution and use in source and binary forms, with or without modification, \r
+ * are permitted provided that the following conditions are met:\r
+ *\r
+ * 1. Redistributions of source code must retain the above copyright notice,\r
+ *    this list of conditions and the following disclaimer.\r
+ * 2. Redistributions in binary form must reproduce the above copyright notice,\r
+ *    this list of conditions and the following disclaimer in the documentation\r
+ *    and/or other materials provided with the distribution.\r
+ * 3. The name of the author may not be used to endorse or promote products\r
+ *    derived from this software without specific prior written permission. \r
+ *\r
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED \r
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF \r
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT \r
+ * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, \r
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT \r
+ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS \r
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN \r
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING \r
+ * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY \r
+ * OF SUCH DAMAGE.\r
+ *\r
+ * This file is part of the lwIP TCP/IP stack.\r
+ * \r
+ * Author: Adam Dunkels <adam@sics.se>\r
+ *\r
+ */\r
+#ifndef __LWIP_SYS_H__\r
+#define __LWIP_SYS_H__\r
+\r
+#include "arch/cc.h"\r
+\r
+#include "lwip/opt.h"\r
+\r
+\r
+#if NO_SYS\r
+\r
+/* For a totally minimal and standalone system, we provide null\r
+   definitions of the sys_ functions. */\r
+typedef u8_t sys_sem_t;\r
+typedef u8_t sys_mbox_t;\r
+struct sys_timeout {u8_t dummy;};\r
+\r
+#define sys_init()\r
+#define sys_timeout(m,h,a)\r
+#define sys_untimeout(m,a)\r
+#define sys_sem_new(c) c\r
+#define sys_sem_signal(s)\r
+#define sys_sem_wait(s)\r
+#define sys_sem_free(s)\r
+#define sys_mbox_new() 0\r
+#define sys_mbox_fetch(m,d)\r
+#define sys_mbox_post(m,d)\r
+#define sys_mbox_free(m)\r
+\r
+#define sys_thread_new(t,a,p)\r
+\r
+#else /* NO_SYS */\r
+\r
+#include "arch/sys_arch.h"\r
+\r
+/** Return code for timeouts from sys_arch_mbox_fetch and sys_arch_sem_wait */\r
+#define SYS_ARCH_TIMEOUT 0xffffffff\r
+\r
+typedef void (* sys_timeout_handler)(void *arg);\r
+\r
+struct sys_timeout {\r
+  struct sys_timeout *next;\r
+  u32_t time;\r
+  sys_timeout_handler h;\r
+  void *arg;\r
+};\r
+\r
+struct sys_timeouts {\r
+  struct sys_timeout *next;\r
+};\r
+\r
+/* sys_init() must be called before anthing else. */\r
+void sys_init(void);\r
+\r
+/*\r
+ * sys_timeout():\r
+ *\r
+ * Schedule a timeout a specified amount of milliseconds in the\r
+ * future. When the timeout occurs, the specified timeout handler will\r
+ * be called. The handler will be passed the "arg" argument when\r
+ * called.\r
+ *\r
+ */\r
+void sys_timeout(u32_t msecs, sys_timeout_handler h, void *arg);\r
+void sys_untimeout(sys_timeout_handler h, void *arg);\r
+struct sys_timeouts *sys_arch_timeouts(void);\r
+\r
+/* Semaphore functions. */\r
+sys_sem_t sys_sem_new(u8_t count);\r
+void sys_sem_signal(sys_sem_t sem);\r
+u32_t sys_arch_sem_wait(sys_sem_t sem, u32_t timeout);\r
+void sys_sem_free(sys_sem_t sem);\r
+void sys_sem_wait(sys_sem_t sem);\r
+int sys_sem_wait_timeout(sys_sem_t sem, u32_t timeout);\r
+\r
+/* Time functions. */\r
+#ifndef sys_msleep\r
+void sys_msleep(u32_t ms); /* only has a (close to) 1 jiffy resolution. */\r
+#endif\r
+#ifndef sys_jiffies\r
+u32_t sys_jiffies(void); /* since power up. */\r
+#endif\r
+\r
+/* Mailbox functions. */\r
+sys_mbox_t sys_mbox_new(void);\r
+void sys_mbox_post(sys_mbox_t mbox, void *msg);\r
+u32_t sys_arch_mbox_fetch(sys_mbox_t mbox, void **msg, u32_t timeout);\r
+void sys_mbox_free(sys_mbox_t mbox);\r
+void sys_mbox_fetch(sys_mbox_t mbox, void **msg);\r
+\r
+\r
+/* Thread functions. */\r
+sys_thread_t sys_thread_new(void (* thread)(void *arg), void *arg, int prio);\r
+\r
+/* The following functions are used only in Unix code, and\r
+   can be omitted when porting the stack. */\r
+/* Returns the current time in microseconds. */\r
+unsigned long sys_now(void);\r
+\r
+#endif /* NO_SYS */\r
+\r
+/* Critical Region Protection */\r
+/* These functions must be implemented in the sys_arch.c file.\r
+   In some implementations they can provide a more light-weight protection\r
+   mechanism than using semaphores. Otherwise semaphores can be used for\r
+   implementation */\r
+#ifndef SYS_ARCH_PROTECT\r
+/** SYS_LIGHTWEIGHT_PROT\r
+ * define SYS_LIGHTWEIGHT_PROT in lwipopts.h if you want inter-task protection\r
+ * for certain critical regions during buffer allocation, deallocation and memory\r
+ * allocation and deallocation.\r
+ */\r
+#if SYS_LIGHTWEIGHT_PROT\r
+\r
+/** SYS_ARCH_DECL_PROTECT\r
+ * declare a protection variable. This macro will default to defining a variable of\r
+ * type sys_prot_t. If a particular port needs a different implementation, then\r
+ * this macro may be defined in sys_arch.h.\r
+ */\r
+#define SYS_ARCH_DECL_PROTECT(lev) sys_prot_t lev\r
+/** SYS_ARCH_PROTECT\r
+ * Perform a "fast" protect. This could be implemented by\r
+ * disabling interrupts for an embedded system or by using a semaphore or\r
+ * mutex. The implementation should allow calling SYS_ARCH_PROTECT when\r
+ * already protected. The old protection level is returned in the variable\r
+ * "lev". This macro will default to calling the sys_arch_protect() function\r
+ * which should be implemented in sys_arch.c. If a particular port needs a\r
+ * different implementation, then this macro may be defined in sys_arch.h\r
+ */\r
+#define SYS_ARCH_PROTECT(lev) lev = sys_arch_protect()\r
+/** SYS_ARCH_UNPROTECT\r
+ * Perform a "fast" set of the protection level to "lev". This could be\r
+ * implemented by setting the interrupt level to "lev" within the MACRO or by\r
+ * using a semaphore or mutex.  This macro will default to calling the\r
+ * sys_arch_unprotect() function which should be implemented in\r
+ * sys_arch.c. If a particular port needs a different implementation, then\r
+ * this macro may be defined in sys_arch.h\r
+ */\r
+#define SYS_ARCH_UNPROTECT(lev) sys_arch_unprotect(lev)\r
+sys_prot_t sys_arch_protect(void);\r
+void sys_arch_unprotect(sys_prot_t pval);\r
+\r
+#else\r
+\r
+#define SYS_ARCH_DECL_PROTECT(lev)\r
+#define SYS_ARCH_PROTECT(lev)\r
+#define SYS_ARCH_UNPROTECT(lev)\r
+\r
+#endif /* SYS_LIGHTWEIGHT_PROT */\r
+\r
+#endif /* SYS_ARCH_PROTECT */\r
+\r
+#endif /* __LWIP_SYS_H__ */\r