diff options
Diffstat (limited to 'nuttx/net/iob/iob_initialize.c')
-rw-r--r-- | nuttx/net/iob/iob_initialize.c | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/nuttx/net/iob/iob_initialize.c b/nuttx/net/iob/iob_initialize.c index 5c4c122c3..319e75b8a 100644 --- a/nuttx/net/iob/iob_initialize.c +++ b/nuttx/net/iob/iob_initialize.c @@ -39,7 +39,15 @@ #include <nuttx/config.h> +#if defined(CONFIG_DEBUG) && defined(CONFIG_NET_IOB_DEBUG) +/* Force debug output (from this file only) */ + +# undef CONFIG_DEBUG_NET +# define CONFIG_DEBUG_NET 1 +#endif + #include <stdbool.h> +#include <semaphore.h> #include <nuttx/net/iob.h> @@ -60,7 +68,9 @@ /* This is a pool of pre-allocated I/O buffers */ static struct iob_s g_iob_pool[CONFIG_IOB_NBUFFERS]; +#if CONFIG_IOB_NCHAINS > 0 static struct iob_qentry_s g_iob_qpool[CONFIG_IOB_NCHAINS]; +#endif /**************************************************************************** * Public Data @@ -72,7 +82,16 @@ FAR struct iob_s *g_iob_freelist; /* A list of all free, unallocated I/O buffer queue containers */ +#if CONFIG_IOB_NCHAINS > 0 FAR struct iob_qentry_s *g_iob_freeqlist; +#endif + +/* Counting semaphores that tracks the number of free IOBs/qentries */ + +sem_t g_iob_sem; +#if CONFIG_IOB_NCHAINS > 0 +sem_t g_qentry_sem; +#endif /**************************************************************************** * Public Functions @@ -107,6 +126,9 @@ void iob_initialize(void) g_iob_freelist = iob; } + sem_init(&g_iob_sem, 0, CONFIG_IOB_NBUFFERS); + +#if CONFIG_IOB_NCHAINS > 0 /* Add each I/O buffer chain queue container to the free list */ for (i = 0; i < CONFIG_IOB_NCHAINS; i++) @@ -119,6 +141,8 @@ void iob_initialize(void) g_iob_freeqlist = iobq; } + sem_init(&g_qentry_sem, 0, CONFIG_IOB_NCHAINS); +#endif initialized = true; } } |