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