forked from Imagelibrary/rtems
LEON: added network device configuration helper function
This commit is contained in:
@@ -83,6 +83,10 @@ EXTRA_DIST += shared/include/b1553brm.h
|
||||
EXTRA_DIST += shared/i2c/i2cmst.c
|
||||
EXTRA_DIST += shared/include/i2cmst.h
|
||||
|
||||
# Network configuration
|
||||
EXTRA_DIST += shared/net/network_interface_add.c
|
||||
EXTRA_DIST += shared/include/network_interface_add.h
|
||||
|
||||
# Driver Manager
|
||||
EXTRA_DIST += shared/drvmgr/ambapp_bus.c
|
||||
EXTRA_DIST += shared/drvmgr/ambapp_bus_grlib.c
|
||||
|
||||
@@ -166,6 +166,11 @@ leon_open_eth_rel_CPPFLAGS += -D__INSIDE_RTEMS_BSD_TCPIP_STACK__
|
||||
leon_open_eth_rel_LDFLAGS = $(RTEMS_RELLDFLAGS)
|
||||
endif
|
||||
|
||||
# BSP Network configuration
|
||||
include_HEADERS += ../../sparc/shared/include/network_interface_add.h
|
||||
libbsp_a_SOURCES += ../../sparc/shared/net/network_interface_add.c
|
||||
endif
|
||||
|
||||
libbsp_a_LIBADD = \
|
||||
../../../libcpu/@RTEMS_CPU@/access.rel \
|
||||
../../../libcpu/@RTEMS_CPU@/cache.rel \
|
||||
|
||||
@@ -166,3 +166,7 @@ $(PROJECT_INCLUDE)/drvmgr/leon2_amba_bus.h: ../../sparc/shared/include/drvmgr/le
|
||||
$(INSTALL_DATA) $< $(PROJECT_INCLUDE)/drvmgr/leon2_amba_bus.h
|
||||
PREINSTALL_FILES += $(PROJECT_INCLUDE)/drvmgr/leon2_amba_bus.h
|
||||
|
||||
$(PROJECT_INCLUDE)/network_interface_add.h: ../../sparc/shared/include/network_interface_add.h $(PROJECT_INCLUDE)/$(dirstamp)
|
||||
$(INSTALL_DATA) $< $(PROJECT_INCLUDE)/network_interface_add.h
|
||||
PREINSTALL_FILES += $(PROJECT_INCLUDE)/network_interface_add.h
|
||||
endif
|
||||
|
||||
@@ -191,6 +191,12 @@ leon_greth_rel_CPPFLAGS += -D__INSIDE_RTEMS_BSD_TCPIP_STACK__
|
||||
leon_greth_rel_LDFLAGS = $(RTEMS_RELLDFLAGS)
|
||||
endif
|
||||
|
||||
# BSP Network configuration
|
||||
if HAS_NETWORKING
|
||||
include_HEADERS += ../../sparc/shared/include/network_interface_add.h
|
||||
libbsp_a_SOURCES += ../../sparc/shared/net/network_interface_add.c
|
||||
endif
|
||||
|
||||
EXTRA_DIST = shmsupp/README
|
||||
if HAS_MP
|
||||
# shmsupp
|
||||
|
||||
@@ -193,3 +193,9 @@ PREINSTALL_FILES += $(PROJECT_INCLUDE)/drvmgr/ambapp_bus_grlib.h
|
||||
$(PROJECT_INCLUDE)/drvmgr/ambapp_bus.h: ../../sparc/shared/include/drvmgr/ambapp_bus.h $(PROJECT_INCLUDE)/drvmgr/$(dirstamp)
|
||||
$(INSTALL_DATA) $< $(PROJECT_INCLUDE)/drvmgr/ambapp_bus.h
|
||||
PREINSTALL_FILES += $(PROJECT_INCLUDE)/drvmgr/ambapp_bus.h
|
||||
|
||||
if HAS_NETWORKING
|
||||
$(PROJECT_INCLUDE)/network_interface_add.h: ../../sparc/shared/include/network_interface_add.h $(PROJECT_INCLUDE)/$(dirstamp)
|
||||
$(INSTALL_DATA) $< $(PROJECT_INCLUDE)/network_interface_add.h
|
||||
PREINSTALL_FILES += $(PROJECT_INCLUDE)/network_interface_add.h
|
||||
endif
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
/* Network interface register help function
|
||||
*
|
||||
* COPYRIGHT (c) 2008.
|
||||
* Cobham Gaisler AB.
|
||||
*
|
||||
* This function adds a network interface to the
|
||||
* rtems_bsdnet_config.ifconfig linked list of interfaces.
|
||||
* The interface configuration is taken from the user defined
|
||||
* array interface_configs. This function is useful for PnP
|
||||
* systems when an unknown number of interfaces are available.
|
||||
*
|
||||
* The license and distribution terms for this file may be
|
||||
* found in found in the file LICENSE in this distribution or at
|
||||
* http://www.rtems.com/license/LICENSE.
|
||||
*/
|
||||
|
||||
#ifndef __NETWORK_INTERFACE_ADD_H__
|
||||
#define __NETWORK_INTERFACE_ADD_H__
|
||||
|
||||
#include <rtems/rtems_bsdnet.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Interface configuration description */
|
||||
struct ethernet_config {
|
||||
char *ip_addr; /* IP address */
|
||||
char *ip_netmask; /* IP Netmask */
|
||||
char eth_adr[6]; /* Ethernet hardware MAC address */
|
||||
};
|
||||
|
||||
/* Array with configurations for all interfaces in the system
|
||||
* Must be defined by the user.
|
||||
*/
|
||||
extern struct ethernet_config interface_configs[];
|
||||
|
||||
/* Routine adding interface to rtems_bsdnet_config.ifconfig linked
|
||||
* list of interfaces.
|
||||
*/
|
||||
int network_interface_add(struct rtems_bsdnet_ifconfig *interface);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _RTEMS_NETWORKCONFIG_H_ */
|
||||
62
c/src/lib/libbsp/sparc/shared/net/network_interface_add.c
Normal file
62
c/src/lib/libbsp/sparc/shared/net/network_interface_add.c
Normal file
@@ -0,0 +1,62 @@
|
||||
/* Network interface register help function
|
||||
*
|
||||
* COPYRIGHT (c) 2008.
|
||||
* Cobham Gaisler AB.
|
||||
*
|
||||
* This function adds a network interface to the
|
||||
* rtems_bsdnet_config.ifconfig linked list of interfaces.
|
||||
* The interface configuration is taken from the user defined
|
||||
* array interface_configs. This function is useful for PnP
|
||||
* systems when an unknown number of interfaces are available.
|
||||
*
|
||||
* The license and distribution terms for this file may be
|
||||
* found in found in the file LICENSE in this distribution or at
|
||||
* http://www.rtems.com/license/LICENSE.
|
||||
*/
|
||||
|
||||
#include <rtems/rtems_bsdnet.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include <network_interface_add.h>
|
||||
|
||||
extern struct rtems_bsdnet_config rtems_bsdnet_config;
|
||||
|
||||
/* Number of interfaces taken */
|
||||
int network_interface_cnt = 0;
|
||||
|
||||
int network_interface_add(struct rtems_bsdnet_ifconfig *interface)
|
||||
{
|
||||
struct ethernet_config *cfg = NULL;
|
||||
int i, last_entry = 1;
|
||||
|
||||
/* Init interface description */
|
||||
interface->next = NULL;
|
||||
|
||||
cfg = &interface_configs[network_interface_cnt];
|
||||
for(i=0; i<6; i++) {
|
||||
if ( cfg->eth_adr[i] != 0 ) {
|
||||
last_entry = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
/* Do we have a valid configuration? */
|
||||
if ( last_entry == 0 ) {
|
||||
cfg = &interface_configs[network_interface_cnt];
|
||||
|
||||
interface->ip_address = cfg->ip_addr;
|
||||
interface->ip_netmask = cfg->ip_netmask;
|
||||
interface->hardware_address = cfg->eth_adr;
|
||||
|
||||
network_interface_cnt++;
|
||||
} else {
|
||||
interface->ip_address = NULL;
|
||||
interface->ip_netmask = NULL;
|
||||
interface->hardware_address = NULL;
|
||||
}
|
||||
|
||||
/* Insert interface first into list */
|
||||
interface->next = rtems_bsdnet_config.ifconfig;
|
||||
rtems_bsdnet_config.ifconfig = interface;
|
||||
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user