summaryrefslogtreecommitdiff
path: root/nuttx/include/net
diff options
context:
space:
mode:
authorpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2011-03-15 20:26:34 +0000
committerpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2011-03-15 20:26:34 +0000
commit6353b7f4d277bc2145ad408e349f2a9a98c8c397 (patch)
treed4ccbfd8eaf3d042c0731d2ab970aea8dddeb768 /nuttx/include/net
parent69ed3e725f394bd249cb732945a0fc989b394746 (diff)
downloadpx4-nuttx-6353b7f4d277bc2145ad408e349f2a9a98c8c397.tar.gz
px4-nuttx-6353b7f4d277bc2145ad408e349f2a9a98c8c397.tar.bz2
px4-nuttx-6353b7f4d277bc2145ad408e349f2a9a98c8c397.zip
More SLIP integration
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@3384 42af7a65-404d-4744-a932-0658087f49c3
Diffstat (limited to 'nuttx/include/net')
-rw-r--r--nuttx/include/net/uip/uip.h52
1 files changed, 51 insertions, 1 deletions
diff --git a/nuttx/include/net/uip/uip.h b/nuttx/include/net/uip/uip.h
index a828d3f90..57407e632 100644
--- a/nuttx/include/net/uip/uip.h
+++ b/nuttx/include/net/uip/uip.h
@@ -5,7 +5,7 @@
* are used by uIP programs as well as internal uIP structures and function
* declarations.
*
- * Copyright (C) 2007-2010 Gregory Nutt. All rights reserved.
+ * Copyright (C) 2007-2011 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
*
* This logic was leveraged from uIP which also has a BSD-style license:
@@ -53,6 +53,11 @@
#include <stdint.h>
#include <stdbool.h>
#include <queue.h>
+
+#ifdef CONFIG_NET_NOINTS
+# include <semaphore.h>
+#endif
+
#include <arpa/inet.h>
#include <net/uip/uipopt.h>
@@ -309,6 +314,51 @@ extern void uip_initialize(void);
extern void uip_setipid(uint16_t id);
+/* Critical section management. The NuttX configuration setting
+ * CONFIG_NET_NOINT indicates that uIP not called from the interrupt level.
+ * If CONFIG_NET_NOINTS is defined, then these will map to semaphore
+ * controls. Otherwise, it assumed that uIP will be called from interrupt
+ * level handling and these will map to interrupt enable/disable controls.
+ */
+
+#ifdef CONFIG_NET_NOINTS
+
+/* Semaphore based locking for non-interrupt based logic.
+ *
+ * uip_lock_t -- Not used. Only for compatibility
+ * uip_lockinit() -- Initializes an underlying semaphore/mutex
+ * uip_lock() -- Takes the semaphore(). Implements a re-entrant mutex.
+ * uip_unlock() -- Gives the semaphore().
+ * uip_lockedwait() -- Like pthread_cond_wait(); releases the semaphore
+ * momemtarily to wait on another semaphore()
+ */
+
+typedef uint8_t uip_lock_t; /* Not really used */
+
+extern void uip_lockinit(void);
+extern uip_lock_t uip_lock(void);
+extern void uip_unlock(uip_lock_t flags);
+extern int uip_lockedwait(sem_t *sem);
+
+#else
+
+/* Enable/disable locking for interrupt based logic:
+ *
+ * uip_lock_t -- The processor specific representation of interrupt state.
+ * uip_lockinit() -- (Does not exist).
+ * uip_lock() -- Disables interrupts.
+ * uip_unlock() -- Conditionally restores interrupts.
+ * uip_lockedwait() -- Just wait for the semaphore.
+ */
+
+# define uip_lock_t irqstate_t
+# define uip_lockinit()
+# define uip_lock() irqsave()
+# define uip_unlock(f) irqrestore(f)
+# define uip_lockedwait(s) sem_wait(s)
+
+#endif
+
/* uIP application functions
*
* Functions used by an application running of top of uIP. This includes