summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGregory Nutt <gnutt@nuttx.org>2015-02-14 06:36:53 -0600
committerGregory Nutt <gnutt@nuttx.org>2015-02-14 06:36:53 -0600
commit45cd51e3fccab3239bfe7693d3b8ac5c85bf794a (patch)
tree4843b2a77f8a5d15f6fb192201cdd44d17a7db85
parent0faee4135ba8bec677d0bcab8d5f86682df45aa2 (diff)
downloadnuttx-45cd51e3fccab3239bfe7693d3b8ac5c85bf794a.tar.gz
nuttx-45cd51e3fccab3239bfe7693d3b8ac5c85bf794a.tar.bz2
nuttx-45cd51e3fccab3239bfe7693d3b8ac5c85bf794a.zip
Networking: Divide net_intiialize() into net_setup() and net_initialize() to solve a chicken-and-egg problem. net_setup() must be caleld before up_initialize() is called so that networking data structures are ready to register new network devices.
net_initialize() now does only timer related operations and is called AFTER up_initialize() where the timers are configured. This is really.
-rw-r--r--nuttx/include/nuttx/net/net.h61
-rw-r--r--nuttx/net/neighbor/neighbor.h25
-rw-r--r--nuttx/net/neighbor/neighbor_initialize.c30
-rw-r--r--nuttx/net/net_initialize.c46
-rw-r--r--nuttx/sched/init/os_start.c18
5 files changed, 150 insertions, 30 deletions
diff --git a/nuttx/include/nuttx/net/net.h b/nuttx/include/nuttx/net/net.h
index 4b35f35d5..49e9f6022 100644
--- a/nuttx/include/nuttx/net/net.h
+++ b/nuttx/include/nuttx/net/net.h
@@ -171,6 +171,50 @@ extern "C"
****************************************************************************/
/****************************************************************************
+ * Name: net_setup
+ *
+ * Description:
+ * This is called from the OS initialization logic at power-up reset in
+ * order to configure networking data structures. This is called prior
+ * to platform-specific driver initialization so that the networking
+ * subsystem is prepared to deal with network driver initialization
+ * actions.
+ *
+ * Actions performed in this initialization phase assume that base OS
+ * facilities such as semaphores are available but this logic cannot
+ * depend upon OS resources such as interrupts or timers which are not
+ * yet available.
+ *
+ * Input Parameters:
+ * None
+ *
+ * Returned Value:
+ * None
+ *
+ ****************************************************************************/
+
+void net_setup(void);
+
+/****************************************************************************
+ * Name: net_initialize
+ *
+ * Description:
+ * This function is called from the OS initialization logic at power-up
+ * reset AFTER initialization of hardware facilities such as timers and
+ * interrupts. This logic completes the initialization started by
+ * net_setup().
+ *
+ * Input Parameters:
+ * None
+ *
+ * Returned Value:
+ * None
+ *
+ ****************************************************************************/
+
+void net_initialize(void);
+
+/****************************************************************************
* 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
@@ -295,23 +339,6 @@ void net_setipid(uint16_t id);
int net_checksd(int fd, int oflags);
/****************************************************************************
- * Name: net_initialize
- *
- * Description:
- * This is called from the OS initialization logic at power-up reset in
- * order to configure the networking subsystem.
- *
- * Input Parameters:
- * None
- *
- * Returned Value:
- * None
- *
- ****************************************************************************/
-
-void net_initialize(void);
-
-/****************************************************************************
* Name:
*
* Description:
diff --git a/nuttx/net/neighbor/neighbor.h b/nuttx/net/neighbor/neighbor.h
index 98b90a8e1..087f1a414 100644
--- a/nuttx/net/neighbor/neighbor.h
+++ b/nuttx/net/neighbor/neighbor.h
@@ -107,10 +107,33 @@ extern uint32_t g_neighbor_polltime;
****************************************************************************/
/****************************************************************************
+ * Name: neighbor_setup
+ *
+ * Description:
+ * Initialize Neighbor table data structures. This function is called
+ * prior to platform-specific driver initialization so that the networking
+ * subsystem is prepared to deal with network driver initialization
+ * actions.
+ *
+ * Input Parameters:
+ * None
+ *
+ * Returned Value:
+ * None
+ *
+ ****************************************************************************/
+
+void neighbor_setup(void);
+
+/****************************************************************************
* Name: neighbor_initialize
*
* Description:
- * Initialize Neighbor table support
+ * Initialize Neighbor ageing. This function is called from the OS
+ * initialization logic at power-up reset AFTER initialization of hardware
+ * facilities such as timers and interrupts. This logic completes the
+ * initialization started by neighbor_setup.
+ *
*
* Input Parameters:
* None
diff --git a/nuttx/net/neighbor/neighbor_initialize.c b/nuttx/net/neighbor/neighbor_initialize.c
index fd8b36d36..34f6191f5 100644
--- a/nuttx/net/neighbor/neighbor_initialize.c
+++ b/nuttx/net/neighbor/neighbor_initialize.c
@@ -65,10 +65,13 @@ uint32_t g_neighbor_polltime;
****************************************************************************/
/****************************************************************************
- * Name: neighbor_initialize
+ * Name: neighbor_setup
*
* Description:
- * Initialize Neighbor table support
+ * Initialize Neighbor table data structures. This function is called
+ * prior to platform-specific driver initialization so that the networking
+ * subsystem is prepared to deal with network driver initialization
+ * actions.
*
* Input Parameters:
* None
@@ -78,7 +81,7 @@ uint32_t g_neighbor_polltime;
*
****************************************************************************/
-void neighbor_initialize(void)
+void neighbor_setup(void)
{
int i;
@@ -86,7 +89,28 @@ void neighbor_initialize(void)
{
g_neighbors[i].ne_time = NEIGHBOR_MAXTIME;
}
+}
+/****************************************************************************
+ * Name: neighbor_initialize
+ *
+ * Description:
+ * Initialize Neighbor ageing. This function is called from the OS
+ * initialization logic at power-up reset AFTER initialization of hardware
+ * facilities such as timers and interrupts. This logic completes the
+ * initialization started by neighbor_setup.
+ *
+ *
+ * Input Parameters:
+ * None
+ *
+ * Returned Value:
+ * None
+ *
+ ****************************************************************************/
+
+void neighbor_initialize(void);
+{
/* Initialize the time of the last poll */
g_neighbor_polltime = clock_systimer();
diff --git a/nuttx/net/net_initialize.c b/nuttx/net/net_initialize.c
index 3fee0f4a1..af0e8651f 100644
--- a/nuttx/net/net_initialize.c
+++ b/nuttx/net/net_initialize.c
@@ -1,7 +1,7 @@
/****************************************************************************
* net/net_sockets.c
*
- * Copyright (C) 2007-2009, 2011-2014 Gregory Nutt. All rights reserved.
+ * Copyright (C) 2007-2009, 2011-2015 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
@@ -83,11 +83,19 @@
****************************************************************************/
/****************************************************************************
- * Name: net_initialize
+ * Name: net_setup
*
* Description:
* This is called from the OS initialization logic at power-up reset in
- * order to configure the networking subsystem.
+ * order to configure networking data structures. This is called prior
+ * to platform-specific driver initialization so that the networking
+ * subsystem is prepared to deal with network driver initialization
+ * actions.
+ *
+ * Actions performed in this initialization phase assume that base OS
+ * facilities such as semaphores are available but this logic cannot
+ * depend upon OS resources such as interrupts or timers which are not
+ * yet available.
*
* Input Parameters:
* None
@@ -97,7 +105,7 @@
*
****************************************************************************/
-void net_initialize(void)
+void net_setup(void)
{
/* Initialize the locking facility */
@@ -108,9 +116,9 @@ void net_initialize(void)
arp_reset();
#ifdef CONFIG_NET_IPv6
- /* Initialize the Neighbor Table */
+ /* Initialize the Neighbor Table data structures */
- neighbor_initialize();
+ neighbor_setup();
#endif
#ifdef CONFIG_NET_IOB
@@ -174,6 +182,32 @@ void net_initialize(void)
netdev_seminit();
#endif
+}
+
+/****************************************************************************
+ * Name: net_initialize
+ *
+ * Description:
+ * This function is called from the OS initialization logic at power-up
+ * reset AFTER initialization of hardware facilities such as timers and
+ * interrupts. This logic completes the initialization started by
+ * net_setup().
+ *
+ * Input Parameters:
+ * None
+ *
+ * Returned Value:
+ * None
+ *
+ ****************************************************************************/
+
+void net_initialize(void)
+{
+#ifdef CONFIG_NET_IPv6
+ /* Configure Neighbor Table ageing */
+
+ neighbor_initialize();
+#endif
/* Initialize the periodic ARP timer */
diff --git a/nuttx/sched/init/os_start.c b/nuttx/sched/init/os_start.c
index 63055142d..511e5870c 100644
--- a/nuttx/sched/init/os_start.c
+++ b/nuttx/sched/init/os_start.c
@@ -466,11 +466,15 @@ void os_start(void)
#endif
#ifdef CONFIG_NET
- /* Initialize the networking systeming. This must be done prior to
- * registering network drivers.
+ /* Initialize the networking system. Network initialization is
+ * performed in two steps: (1) net_setup() initializes static
+ * configuration of the network support. This must be done prior
+ * to registering network drivers by up_initialize(). This step
+ * cannot require upon any hardware-depending features such as
+ * timers or interrupts.
*/
- net_initialize();
+ net_setup();
#endif
/* The processor specific details of running the operating system
@@ -481,6 +485,14 @@ void os_start(void)
up_initialize();
+#ifdef CONFIG_NET
+ /* Complete initialization the networking system now that interrupts
+ * and timers have been configured by up_initialize().
+ */
+
+ net_initialize();
+#endif
+
#ifdef CONFIG_MM_SHM
/* Initialize shared memory support */