source: network-demos/networkconfig-qemu.h @ 6ecabe8

4.11network-demos-4-10-branch
Last change on this file since 6ecabe8 was 0cd4d86, checked in by Joel Sherrill <joel.sherrill@…>, on 05/13/09 at 18:56:10

2009-05-13 Joel Sherrill <joel.sherrill@…>

  • 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.
  • Property mode set to 100644
File size: 10.0 KB
Line 
1/*
2 * Network configuration -- QEMU NOT using DHCP
3 *
4 ************************************************************
5 * EDIT THIS FILE TO REFLECT YOUR NETWORK CONFIGURATION     *
6 * BEFORE RUNNING ANY RTEMS PROGRAMS WHICH USE THE NETWORK! *
7 ************************************************************
8 *
9 *  The dynamic probing is based upon the EPICS network
10 *  configuration file written by:
11 *      W. Eric Norum
12 *      eric.norum@usask.ca
13 *      (306) 966-5394
14 *
15 *  networkconfig.h,v 1.8 2001/08/31 18:11:43 joel Exp
16 */
17
18#ifndef _RTEMS_NETWORKCONFIG_H_
19#define _RTEMS_NETWORKCONFIG_H_
20
21/* #define USE_LIBBSDPORT */
22
23#if defined(USE_LIBBSDPORT)
24  #include <bsp/libbsdport_api.h>
25  #define CONFIGURE_MAXIMUM_TIMERS 10
26#endif
27/*
28 * For TFTP test application
29 */
30#if (defined (RTEMS_USE_BOOTP))
31#define RTEMS_TFTP_TEST_HOST_NAME "BOOTP_HOST"
32#define RTEMS_TFTP_TEST_FILE_NAME "BOOTP_FILE"
33#else
34#define RTEMS_TFTP_TEST_HOST_NAME "XXX.YYY.ZZZ.XYZ"
35#define RTEMS_TFTP_TEST_FILE_NAME "tftptest"
36#endif
37
38/*
39 * For NFS test application
40 *
41 * NFS mount and a directory to ls once mounted
42 */
43#define RTEMS_NFS_SERVER      "192.168.1.210"
44#define RTEMS_NFS_SERVER_PATH "/home"
45#define RTEMS_NFS_LS_PATH     "/mnt/nfstest"
46
47
48
49/*
50 * This file can be copied to an application source dirctory
51 * and modified to override the values shown below.
52 *
53 * The following CPP symbols may be passed from the Makefile:
54 *
55 *   symbol                   default       description
56 *
57 *   NETWORK_TASK_PRIORITY    150           can be read by app from public
58 *                                          var 'gesysNetworkTaskPriority'
59 *   FIXED_IP_ADDR            <undefined>   hardcoded IP address (e.g.,
60 *                                          "192.168.0.10"); disables BOOTP;
61 *                                          must also define FIXED_NETMASK
62 *   FIXED_NETMASK            <undefined>   IP netmask string
63 *                                          (e.g. "255.255.255.0")
64 *   LO_IF_ONLY               <undefined>   If defined, do NOT configure
65 *                                          any ethernet driver but only the
66 *                                          loopback interface.
67 *   MULTI_NETDRIVER          <undefined>   ugly hack; if defined try to probe
68 *                                          a variety of PCI and ISA drivers
69 *                                          (i386 ONLY) use is discouraged!
70 *   NIC_NAME                 <undefined>   Ethernet driver name (e.g. "pcn1");
71 *                                          must also define NIC_ATTACH
72 *   NIC_ATTACH               <undefined>   Ethernet driver attach function
73 *                                          (e.g., rtems_fxp_attach).
74 *                                          If these are undefined then
75 *                                            a) MULTI_NETDRIVER is used
76 *                                               (if defined)
77 *                                            b) RTEMS_BSP_NETWORK_DRIVER_NAME/
78 *                                               RTEMS_BSP_NETWORK_DRIVER_ATTACH
79 *                                               are tried
80 *   MEMORY_CUSTOM            <undefined>   Allocate the defined amount of
81 *                                          memory for mbufs and mbuf clusters,
82 *                                          respectively. Define to a comma ','
83 *                                          separated pair of two numerical
84 *                                          values, e.g: 100*1024,200*1024
85 *   MEMORY_SCARCE            <undefined>   Allocate few memory for mbufs
86 *                                          (hint for how much memory the
87 *                                          board has)
88 *   MEMORY_HUGE              <undefined>   Allocate a lot of memory for mbufs
89 *                                          (hint for how much memory the
90 *                                          board has)
91 *                                          If none of MEMORY_CUSTOM/
92 *                                          MEMORY_SCARCE/MEMORY_HUGE are
93 *                                          defined then a medium amount of
94 *                                          memory is allocated for mbufs.
95 */
96
97#include <rtems/bspIo.h>
98#include <bsp.h>
99#include <rtems/rtems_bsdnet.h>
100
101#if 0
102#ifdef HAVE_CONFIG_H
103#include <config.h>
104#else
105#include "verscheck.h"
106#endif
107#endif
108
109#define MULTI_NETDRIVER
110
111/* Assume we are on qemu unless forced to lab hardware */
112#if !defined(ON_RTEMS_LAB_WINSYSTEMS)
113#undef ON_QEMU
114#define ON_QEMU
115#endif
116
117#if defined(ON_QEMU)
118#define FIXED_IP_ADDR "10.0.2.5"
119#endif
120
121#if defined(ON_RTEMS_LAB_WINSYSTEMS)
122#define FIXED_IP_ADDR "192.168.1.249"
123#endif
124
125#define FIXED_NETMASK "255.255.255.0"
126
127#ifndef NETWORK_TASK_PRIORITY
128#define NETWORK_TASK_PRIORITY   150  /* within EPICS' range */
129#endif
130
131/* make publicily available for startup scripts... */
132const int gesysNetworkTaskPriority = NETWORK_TASK_PRIORITY;
133
134#ifdef  FIXED_IP_ADDR
135#define RTEMS_DO_BOOTP 0
136#else
137#define RTEMS_DO_BOOTP rtems_bsdnet_do_bootp
138#define FIXED_IP_ADDR  0
139#undef  FIXED_NETMASK
140#define FIXED_NETMASK  0
141#endif
142
143#ifdef LO_IF_ONLY
144#undef NIC_NAME
145#elif !defined(NIC_NAME)
146
147#ifdef MULTI_NETDRIVER
148
149#if 0
150  #if RTEMS_VERSION_ATLEAST(4,6,99)
151  #define pcib_init pci_initialize
152  #endif
153#endif
154
155extern int rtems_3c509_driver_attach (struct rtems_bsdnet_ifconfig *, int);
156extern int rtems_fxp_attach (struct rtems_bsdnet_ifconfig *, int);
157extern int rtems_elnk_driver_attach (struct rtems_bsdnet_ifconfig *, int);
158extern int rtems_dec21140_driver_attach (struct rtems_bsdnet_ifconfig *, int);
159
160/* these don't probe and will be used even if there's no device :-( */
161extern int rtems_ne_driver_attach (struct rtems_bsdnet_ifconfig *, int);
162extern int rtems_wd_driver_attach (struct rtems_bsdnet_ifconfig *, int);
163
164static struct rtems_bsdnet_ifconfig isa_netdriver_config[] = {
165  {
166        "ep0", rtems_3c509_driver_attach, isa_netdriver_config + 1,
167  },
168  {
169        "ne1", rtems_ne_driver_attach, 0, irno: 9 /* qemu cannot configure irq-no :-(; has it hardwired to 9 */
170  },
171};
172
173static struct rtems_bsdnet_ifconfig pci_netdriver_config[]={
174  {
175  "dc1", rtems_dec21140_driver_attach, pci_netdriver_config+1,
176  },
177  #if !defined(USE_LIBBSDPORT)
178    {
179    "fxp1", rtems_fxp_attach, pci_netdriver_config+2,
180    },
181  #else
182    {
183      "", libbsdport_netdriver_attach, pci_netdriver_config+2,
184    },
185  #endif
186  {
187  "elnk1", rtems_elnk_driver_attach, isa_netdriver_config,
188  },
189};
190
191static int pci_check(struct rtems_bsdnet_ifconfig *ocfg, int attaching)
192{
193struct rtems_bsdnet_ifconfig *cfg;
194int if_index_pre;
195extern int if_index;
196  if ( attaching ) {
197        cfg = pci_initialize() ?
198                      isa_netdriver_config : pci_netdriver_config;
199  }
200  while ( cfg ) {
201        printk("Probing '%s'", cfg->name);
202        /* unfortunately, the return value is unreliable - some drivers report
203         * success even if they fail.
204         * Check if they chained an interface (ifnet) structure instead
205         */
206        if_index_pre = if_index;
207        cfg->attach(cfg, attaching);
208        if ( if_index > if_index_pre ) {
209                /* assume success */
210                printk(" .. seemed to work\n");
211                ocfg->name   = cfg->name;
212                ocfg->attach = cfg->attach;
213                return 0;
214        }
215        printk(" .. failed\n");
216        cfg = cfg->next;
217  }
218  return -1;
219}
220
221#define NIC_NAME   "dummy"
222#define NIC_ATTACH pci_check
223
224#else
225
226#if defined(RTEMS_BSP_NETWORK_DRIVER_NAME)  /* Use NIC provided by BSP */
227# define NIC_NAME   RTEMS_BSP_NETWORK_DRIVER_NAME
228# define NIC_ATTACH RTEMS_BSP_NETWORK_DRIVER_ATTACH
229#endif
230
231#endif /* ifdef MULTI_NETDRIVER */
232
233#endif /* ifdef LO_IF_ONLY */
234
235#ifdef NIC_NAME
236
237extern int NIC_ATTACH();
238
239
240static struct rtems_bsdnet_ifconfig netdriver_config[1] = {{
241  NIC_NAME,  /* name */
242  (int (*)(struct rtems_bsdnet_ifconfig*,int))NIC_ATTACH,  /* attach function */
243  0,            /* link to next interface */
244  FIXED_IP_ADDR,
245  FIXED_NETMASK
246}};
247#else
248#ifndef LO_IF_ONLY
249#warning "NO KNOWN NETWORK DRIVER FOR THIS BSP -- YOU MAY HAVE TO EDIT rtems_netconfig.c"
250#endif
251#endif
252
253extern void rtems_bsdnet_loopattach();
254static struct rtems_bsdnet_ifconfig loopback_config = {
255    "lo0",                          /* name */
256    (int (*)(struct rtems_bsdnet_ifconfig *, int))rtems_bsdnet_loopattach, /* attach function */
257#ifdef NIC_NAME
258    netdriver_config,               /* link to next interface */
259#else
260    0,                              /* link to next interface */
261#endif
262    "127.0.0.1",                    /* IP address */
263    "255.0.0.0",                    /* IP net mask */
264};
265
266struct rtems_bsdnet_config rtems_bsdnet_config = {
267    &loopback_config,         /* Network interface */
268#ifdef NIC_NAME
269    RTEMS_DO_BOOTP,           /* Use BOOTP to get network configuration */
270#else
271    0,                        /* Use BOOTP to get network configuration */
272#endif
273    NETWORK_TASK_PRIORITY,    /* Network task priority */
274#if   defined(MEMORY_CUSTOM)
275    MEMORY_CUSTOM,
276#elif defined(MEMORY_SCARCE)
277    100*1024,                 /* MBUF space */
278    200*1024,                 /* MBUF cluster space */
279#elif defined(MEMORY_HUGE)
280    2*1024*1024,              /* MBUF space */
281    5*1024*1024,              /* MBUF cluster space */
282#else
283    180*1024,                 /* MBUF space */
284    350*1024,                 /* MBUF cluster space */
285#endif
286#if (!defined (RTEMS_USE_BOOTP)) && defined(ON_RTEMS_LAB_WINSYSTEMS)
287    "rtems",                /* Host name */
288    "nodomain.com",         /* Domain name */
289    "192.168.1.14",         /* Gateway */
290    "192.168.1.1",          /* Log host */
291    {"192.168.1.1"  },      /* Name server(s) */
292    {"192.168.1.1"  },      /* NTP server(s) */
293#else
294    NULL,                   /* Host name */
295    NULL,                   /* Domain name */
296    NULL,                   /* Gateway */
297    NULL,                   /* Log host */
298    { NULL },               /* Name server(s) */
299    { NULL },               /* NTP server(s) */
300#endif /* !RTEMS_USE_BOOTP */
301    0,                      /* efficiency */
302    0,                      /* udp TX buffer */
303    0,                      /* udp RX buffer */
304    0,                      /* tcp TX buffer */
305    0,                      /* tcp RX buffer */
306};
307#endif /* _RTEMS_NETWORKCONFIG_H_ */
Note: See TracBrowser for help on using the repository browser.