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.
This commit is contained in:
parent
a1d3faaa8a
commit
8840102554
@ -170,6 +170,50 @@ extern "C"
|
||||
* Public Function Prototypes
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* 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.
|
||||
@ -294,23 +338,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:
|
||||
*
|
||||
|
@ -106,11 +106,34 @@ extern uint32_t g_neighbor_polltime;
|
||||
* Public Function Prototypes
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* 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
|
||||
|
@ -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();
|
||||
|
@ -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 */
|
||||
|
||||
|
@ -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 */
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user