summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoel Sherrill <joel.sherrill@OARcorp.com>2009-05-13 18:56:10 +0000
committerJoel Sherrill <joel.sherrill@OARcorp.com>2009-05-13 18:56:10 +0000
commit0cd4d86bdbe3293dfdefbe98a8c01e7472bdb641 (patch)
tree001d25ae23eacd42f730dfe942ad3e4692db2c70
parent2009-05-13 Joel Sherrill <joel.sherrill@oarcorp.com> (diff)
downloadnetwork-demos-0cd4d86bdbe3293dfdefbe98a8c01e7472bdb641.tar.bz2
2009-05-13 Joel Sherrill <joel.sherrill@oarcorp.com>
* networkconfig-qemu.h: Now works on qemu with fxp driver in RTEMS, the newer version in libbsdport, and on the real NIC in the Winsystems PC in RTEMS Lab.
-rw-r--r--ChangeLog6
-rw-r--r--networkconfig-qemu.h373
2 files changed, 265 insertions, 114 deletions
diff --git a/ChangeLog b/ChangeLog
index d7994d2..4b27141 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2009-05-13 Joel Sherrill <joel.sherrill@oarcorp.com>
+
+ * networkconfig-qemu.h: Now works on qemu with fxp driver in RTEMS, the
+ newer version in libbsdport, and on the real NIC in the Winsystems PC
+ in RTEMS Lab.
+
2009-05-05 Sebastian Huber <sebastian.huber@embedded-brains.de>
* telnetd/init.c: Enable shell login checks.
diff --git a/networkconfig-qemu.h b/networkconfig-qemu.h
index 9c02c61..426da4d 100644
--- a/networkconfig-qemu.h
+++ b/networkconfig-qemu.h
@@ -6,157 +6,302 @@
* BEFORE RUNNING ANY RTEMS PROGRAMS WHICH USE THE NETWORK! *
************************************************************
*
+ * The dynamic probing is based upon the EPICS network
+ * configuration file written by:
+ * W. Eric Norum
+ * eric.norum@usask.ca
+ * (306) 966-5394
+ *
* networkconfig.h,v 1.8 2001/08/31 18:11:43 joel Exp
*/
#ifndef _RTEMS_NETWORKCONFIG_H_
#define _RTEMS_NETWORKCONFIG_H_
+/* #define USE_LIBBSDPORT */
+
+#if defined(USE_LIBBSDPORT)
+ #include <bsp/libbsdport_api.h>
+ #define CONFIGURE_MAXIMUM_TIMERS 10
+#endif
/*
- * The following will normally be set by the BSP if it supports
- * a single network device driver. In the event, it supports
- * multiple network device drivers, then the user's default
- * network device driver will have to be selected by a BSP
- * specific mechanism.
+ * For TFTP test application
*/
-
-#undef RTEMS_BSP_NETWORK_DRIVER_NAME
-#undef RTEMS_BSP_NETWORK_DRIVER_ATTACH
-#if 0
-#define RTEMS_BSP_NETWORK_DRIVER_NAME "ne1"
-#define RTEMS_BSP_NETWORK_DRIVER_ATTACH rtems_ne_driver_attach
+#if (defined (RTEMS_USE_BOOTP))
+#define RTEMS_TFTP_TEST_HOST_NAME "BOOTP_HOST"
+#define RTEMS_TFTP_TEST_FILE_NAME "BOOTP_FILE"
#else
-int
-rtems_fxp_attach(struct rtems_bsdnet_ifconfig *config, int attaching);
-#define RTEMS_BSP_NETWORK_DRIVER_NAME "fxp1"
-#define RTEMS_BSP_NETWORK_DRIVER_ATTACH rtems_fxp_attach
+#define RTEMS_TFTP_TEST_HOST_NAME "XXX.YYY.ZZZ.XYZ"
+#define RTEMS_TFTP_TEST_FILE_NAME "tftptest"
#endif
+/*
+ * For NFS test application
+ *
+ * NFS mount and a directory to ls once mounted
+ */
+#define RTEMS_NFS_SERVER "192.168.1.210"
+#define RTEMS_NFS_SERVER_PATH "/home"
+#define RTEMS_NFS_LS_PATH "/mnt/nfstest"
+
-#ifdef RTEMS_USE_BOOTP
-#undef RTEMS_USE_BOOTP
-#endif
/*
- * If you use DHCP on the QEMU instance, there is less configuration
+ * This file can be copied to an application source dirctory
+ * and modified to override the values shown below.
+ *
+ * The following CPP symbols may be passed from the Makefile:
+ *
+ * symbol default description
+ *
+ * NETWORK_TASK_PRIORITY 150 can be read by app from public
+ * var 'gesysNetworkTaskPriority'
+ * FIXED_IP_ADDR <undefined> hardcoded IP address (e.g.,
+ * "192.168.0.10"); disables BOOTP;
+ * must also define FIXED_NETMASK
+ * FIXED_NETMASK <undefined> IP netmask string
+ * (e.g. "255.255.255.0")
+ * LO_IF_ONLY <undefined> If defined, do NOT configure
+ * any ethernet driver but only the
+ * loopback interface.
+ * MULTI_NETDRIVER <undefined> ugly hack; if defined try to probe
+ * a variety of PCI and ISA drivers
+ * (i386 ONLY) use is discouraged!
+ * NIC_NAME <undefined> Ethernet driver name (e.g. "pcn1");
+ * must also define NIC_ATTACH
+ * NIC_ATTACH <undefined> Ethernet driver attach function
+ * (e.g., rtems_fxp_attach).
+ * If these are undefined then
+ * a) MULTI_NETDRIVER is used
+ * (if defined)
+ * b) RTEMS_BSP_NETWORK_DRIVER_NAME/
+ * RTEMS_BSP_NETWORK_DRIVER_ATTACH
+ * are tried
+ * MEMORY_CUSTOM <undefined> Allocate the defined amount of
+ * memory for mbufs and mbuf clusters,
+ * respectively. Define to a comma ','
+ * separated pair of two numerical
+ * values, e.g: 100*1024,200*1024
+ * MEMORY_SCARCE <undefined> Allocate few memory for mbufs
+ * (hint for how much memory the
+ * board has)
+ * MEMORY_HUGE <undefined> Allocate a lot of memory for mbufs
+ * (hint for how much memory the
+ * board has)
+ * If none of MEMORY_CUSTOM/
+ * MEMORY_SCARCE/MEMORY_HUGE are
+ * defined then a medium amount of
+ * memory is allocated for mbufs.
*/
-// #define RTEMS_USE_BOOTP
+#include <rtems/bspIo.h>
#include <bsp.h>
+#include <rtems/rtems_bsdnet.h>
-/*
- * Define RTEMS_SET_ETHERNET_ADDRESS if you want to specify the
- * Ethernet address here. If RTEMS_SET_ETHERNET_ADDRESS is not
- * defined the driver will choose an address.
- */
-//#define RTEMS_SET_ETHERNET_ADDRESS
-#ifdef RTEMS_SET_ETHERNET_ADDRESS
-#undef RTEMS_SET_ETHERNET_ADDRESS
+#if 0
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#else
+#include "verscheck.h"
#endif
+#endif
+
+#define MULTI_NETDRIVER
-#if (defined (RTEMS_SET_ETHERNET_ADDRESS))
-/* static char ethernet_address[6] = { 0x08, 0x00, 0x3e, 0x12, 0x28, 0xb1 }; */
-static char ethernet_address[6] = { 0x00, 0x80, 0x7F, 0x22, 0x61, 0x77 };
+/* Assume we are on qemu unless forced to lab hardware */
+#if !defined(ON_RTEMS_LAB_WINSYSTEMS)
+#undef ON_QEMU
+#define ON_QEMU
#endif
-#ifdef RTEMS_USE_LOOPBACK
-/*
- * Loopback interface
- */
-extern void rtems_bsdnet_loopattach();
-static struct rtems_bsdnet_ifconfig loopback_config = {
- "lo0", /* name */
- rtems_bsdnet_loopattach, /* attach function */
- NULL, /* link to next interface */
- "127.0.0.1", /* IP address */
- "255.0.0.0", /* IP net mask */
-};
+#if defined(ON_QEMU)
+#define FIXED_IP_ADDR "10.0.2.5"
#endif
-/*
- * Default network interface
- */
-static struct rtems_bsdnet_ifconfig netdriver_config = {
- RTEMS_BSP_NETWORK_DRIVER_NAME, /* name */
- RTEMS_BSP_NETWORK_DRIVER_ATTACH, /* attach function */
+#if defined(ON_RTEMS_LAB_WINSYSTEMS)
+#define FIXED_IP_ADDR "192.168.1.249"
+#endif
-#ifdef RTEMS_USE_LOOPBACK
- &loopback_config, /* link to next interface */
-#else
- NULL, /* No more interfaces */
+#define FIXED_NETMASK "255.255.255.0"
+
+#ifndef NETWORK_TASK_PRIORITY
+#define NETWORK_TASK_PRIORITY 150 /* within EPICS' range */
#endif
-#if (defined (RTEMS_USE_BOOTP))
- NULL, /* BOOTP supplies IP address */
- NULL, /* BOOTP supplies IP net mask */
-#else
- "10.0.2.5", /* IP address */
- "255.255.255.0", /* IP net mask */
-#endif /* !RTEMS_USE_BOOTP */
+/* make publicily available for startup scripts... */
+const int gesysNetworkTaskPriority = NETWORK_TASK_PRIORITY;
-#if (defined (RTEMS_SET_ETHERNET_ADDRESS))
- ethernet_address, /* Ethernet hardware address */
+#ifdef FIXED_IP_ADDR
+#define RTEMS_DO_BOOTP 0
#else
- NULL, /* Driver supplies hardware address */
-#endif
- 0, /* Use default driver parameters */
- 0, /* mtu */
- 0, /* rbuf_count */
- 0, /* xbuf_count */
- 0, /* port */
- 9 /* irq */
+#define RTEMS_DO_BOOTP rtems_bsdnet_do_bootp
+#define FIXED_IP_ADDR 0
+#undef FIXED_NETMASK
+#define FIXED_NETMASK 0
+#endif
+
+#ifdef LO_IF_ONLY
+#undef NIC_NAME
+#elif !defined(NIC_NAME)
+
+#ifdef MULTI_NETDRIVER
+
+#if 0
+ #if RTEMS_VERSION_ATLEAST(4,6,99)
+ #define pcib_init pci_initialize
+ #endif
+#endif
+
+extern int rtems_3c509_driver_attach (struct rtems_bsdnet_ifconfig *, int);
+extern int rtems_fxp_attach (struct rtems_bsdnet_ifconfig *, int);
+extern int rtems_elnk_driver_attach (struct rtems_bsdnet_ifconfig *, int);
+extern int rtems_dec21140_driver_attach (struct rtems_bsdnet_ifconfig *, int);
+
+/* these don't probe and will be used even if there's no device :-( */
+extern int rtems_ne_driver_attach (struct rtems_bsdnet_ifconfig *, int);
+extern int rtems_wd_driver_attach (struct rtems_bsdnet_ifconfig *, int);
+
+static struct rtems_bsdnet_ifconfig isa_netdriver_config[] = {
+ {
+ "ep0", rtems_3c509_driver_attach, isa_netdriver_config + 1,
+ },
+ {
+ "ne1", rtems_ne_driver_attach, 0, irno: 9 /* qemu cannot configure irq-no :-(; has it hardwired to 9 */
+ },
};
-/*
- * Network configuration
- */
-struct rtems_bsdnet_config rtems_bsdnet_config = {
- &netdriver_config,
+static struct rtems_bsdnet_ifconfig pci_netdriver_config[]={
+ {
+ "dc1", rtems_dec21140_driver_attach, pci_netdriver_config+1,
+ },
+ #if !defined(USE_LIBBSDPORT)
+ {
+ "fxp1", rtems_fxp_attach, pci_netdriver_config+2,
+ },
+ #else
+ {
+ "", libbsdport_netdriver_attach, pci_netdriver_config+2,
+ },
+ #endif
+ {
+ "elnk1", rtems_elnk_driver_attach, isa_netdriver_config,
+ },
+};
+
+static int pci_check(struct rtems_bsdnet_ifconfig *ocfg, int attaching)
+{
+struct rtems_bsdnet_ifconfig *cfg;
+int if_index_pre;
+extern int if_index;
+ if ( attaching ) {
+ cfg = pci_initialize() ?
+ isa_netdriver_config : pci_netdriver_config;
+ }
+ while ( cfg ) {
+ printk("Probing '%s'", cfg->name);
+ /* unfortunately, the return value is unreliable - some drivers report
+ * success even if they fail.
+ * Check if they chained an interface (ifnet) structure instead
+ */
+ if_index_pre = if_index;
+ cfg->attach(cfg, attaching);
+ if ( if_index > if_index_pre ) {
+ /* assume success */
+ printk(" .. seemed to work\n");
+ ocfg->name = cfg->name;
+ ocfg->attach = cfg->attach;
+ return 0;
+ }
+ printk(" .. failed\n");
+ cfg = cfg->next;
+ }
+ return -1;
+}
+
+#define NIC_NAME "dummy"
+#define NIC_ATTACH pci_check
-#if (defined (RTEMS_USE_BOOTP))
- rtems_bsdnet_do_bootp,
-#else
- NULL,
-#endif
- 0, /* Default network task priority */
- 256 * 1024, /* 256K - not default mbuf capacity */
- 256 * 1024, /* 256K - not default mbuf cluster capacity */
-#if (!defined (RTEMS_USE_BOOTP))
- "rtems", /* Host name */
- "", /* Domain name */
- "10.0.2.1", /* Gateway */
- "10.0.0.1", /* Log host */
- {"10.0.2.3" }, /* Name server(s) */
- {"" }, /* NTP server(s) */
#else
- #error "Fill me in"
-#endif /* !RTEMS_USE_BOOTP */
- 1, /* sb_efficiency */
- 0, /* udp_tx_buf_size */
- 0, /* udp_rx_buf_size */
- 0, /* tcp_tx_buf_size */
- 0 /* tcp_rx_buf_size */
-};
+#if defined(RTEMS_BSP_NETWORK_DRIVER_NAME) /* Use NIC provided by BSP */
+# define NIC_NAME RTEMS_BSP_NETWORK_DRIVER_NAME
+# define NIC_ATTACH RTEMS_BSP_NETWORK_DRIVER_ATTACH
+#endif
-/*
- * For TFTP test application
- */
-#if (defined (RTEMS_USE_BOOTP))
-#define RTEMS_TFTP_TEST_HOST_NAME "BOOTP_HOST"
-#define RTEMS_TFTP_TEST_FILE_NAME "BOOTP_FILE"
+#endif /* ifdef MULTI_NETDRIVER */
+
+#endif /* ifdef LO_IF_ONLY */
+
+#ifdef NIC_NAME
+
+extern int NIC_ATTACH();
+
+
+static struct rtems_bsdnet_ifconfig netdriver_config[1] = {{
+ NIC_NAME, /* name */
+ (int (*)(struct rtems_bsdnet_ifconfig*,int))NIC_ATTACH, /* attach function */
+ 0, /* link to next interface */
+ FIXED_IP_ADDR,
+ FIXED_NETMASK
+}};
#else
-#define RTEMS_TFTP_TEST_HOST_NAME "XXX.YYY.ZZZ.XYZ"
-#define RTEMS_TFTP_TEST_FILE_NAME "tftptest"
+#ifndef LO_IF_ONLY
+#warning "NO KNOWN NETWORK DRIVER FOR THIS BSP -- YOU MAY HAVE TO EDIT rtems_netconfig.c"
+#endif
#endif
-/*
- * For NFS test application
- *
- * NFS mount and a directory to ls once mounted
- */
-#define RTEMS_NFS_SERVER "192.168.1.210"
-#define RTEMS_NFS_SERVER_PATH "/home"
-#define RTEMS_NFS_LS_PATH "/mnt/nfstest"
+extern void rtems_bsdnet_loopattach();
+static struct rtems_bsdnet_ifconfig loopback_config = {
+ "lo0", /* name */
+ (int (*)(struct rtems_bsdnet_ifconfig *, int))rtems_bsdnet_loopattach, /* attach function */
+#ifdef NIC_NAME
+ netdriver_config, /* link to next interface */
+#else
+ 0, /* link to next interface */
+#endif
+ "127.0.0.1", /* IP address */
+ "255.0.0.0", /* IP net mask */
+};
+struct rtems_bsdnet_config rtems_bsdnet_config = {
+ &loopback_config, /* Network interface */
+#ifdef NIC_NAME
+ RTEMS_DO_BOOTP, /* Use BOOTP to get network configuration */
+#else
+ 0, /* Use BOOTP to get network configuration */
+#endif
+ NETWORK_TASK_PRIORITY, /* Network task priority */
+#if defined(MEMORY_CUSTOM)
+ MEMORY_CUSTOM,
+#elif defined(MEMORY_SCARCE)
+ 100*1024, /* MBUF space */
+ 200*1024, /* MBUF cluster space */
+#elif defined(MEMORY_HUGE)
+ 2*1024*1024, /* MBUF space */
+ 5*1024*1024, /* MBUF cluster space */
+#else
+ 180*1024, /* MBUF space */
+ 350*1024, /* MBUF cluster space */
+#endif
+#if (!defined (RTEMS_USE_BOOTP)) && defined(ON_RTEMS_LAB_WINSYSTEMS)
+ "rtems", /* Host name */
+ "nodomain.com", /* Domain name */
+ "192.168.1.14", /* Gateway */
+ "192.168.1.1", /* Log host */
+ {"192.168.1.1" }, /* Name server(s) */
+ {"192.168.1.1" }, /* NTP server(s) */
+#else
+ NULL, /* Host name */
+ NULL, /* Domain name */
+ NULL, /* Gateway */
+ NULL, /* Log host */
+ { NULL }, /* Name server(s) */
+ { NULL }, /* NTP server(s) */
+#endif /* !RTEMS_USE_BOOTP */
+ 0, /* efficiency */
+ 0, /* udp TX buffer */
+ 0, /* udp RX buffer */
+ 0, /* tcp TX buffer */
+ 0, /* tcp RX buffer */
+};
#endif /* _RTEMS_NETWORKCONFIG_H_ */