-
Notifications
You must be signed in to change notification settings - Fork 0
/
init.c
232 lines (192 loc) · 6.42 KB
/
init.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
/**
* Configure the RTEMS initialisation.
*/
#define CONFIGURE_MAXIMUM_POSIX_KEYS 16
#define CONFIGURE_MAXIMUM_POSIX_KEY_VALUE_PAIRS 16
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <stdlib.h>
#include <rtems.h>
#if !RTEMS_APP_NETWORKING
#undef RTEMS_NETWORKING
#endif
#ifdef RTEMS_NETWORKING
#include <rtems/rtems_bsdnet.h>
#include <rtems/dhcp.h>
#endif
/**
* Configure base RTEMS resources.
*/
#define CONFIGURE_RTEMS_INIT_TASKS_TABLE
/*
* v850sim bsp only has 1M ram
*/
#if defined(__v850__)
#define CONFIGURE_MEMORY_OVERHEAD 210
#else
#define CONFIGURE_MEMORY_OVERHEAD 512
#endif
#define CONFIGURE_MAXIMUM_TASKS rtems_resource_unlimited (10)
#define CONFIGURE_MAXIMUM_SEMAPHORES rtems_resource_unlimited (10)
#define CONFIGURE_MAXIMUM_MESSAGE_QUEUES rtems_resource_unlimited (5)
#define CONFIGURE_MAXIMUM_PARTITIONS rtems_resource_unlimited (2)
#define CONFIGURE_MAXIMUM_TIMERS 10
/**
* Configure drivers.
*/
#define CONFIGURE_MAXIMUM_DRIVERS 10
#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
/**
* Configure file system and libblock.
*/
#define CONFIGURE_USE_IMFS_AS_BASE_FILESYSTEM
#define CONFIGURE_LIBIO_MAXIMUM_FILE_DESCRIPTORS 20
#define CONFIGURE_APPLICATION_NEEDS_LIBBLOCK
#define CONFIGURE_SWAPOUT_TASK_PRIORITY 15
#if RTEMS_APP_IDEDISK
#define CONFIGURE_BDBUF_CACHE_MEMORY_SIZE (16 * 1024 * 1024)
#define CONFIGURE_BDBUF_MAX_READ_AHEAD_BLOCKS 2
#define CONFIGURE_BDBUF_MAX_WRITE_BLOCKS 32
#define CONFIGURE_APPLICATION_NEEDS_IDE_DRIVER
#define CONFIGURE_APPLICATION_NEEDS_ATA_DRIVER
#define CONFIGURE_ATA_DRIVER_TASK_PRIORITY 14
#endif
#if !defined(__v850__)
#define CONFIGURE_FILESYSTEM_ALL
#endif
/**
* Tell confdefs.h to provide the configuration.
*/
#define CONFIGURE_INIT
#include <rtems/confdefs.h>
#ifdef RTEMS_NETWORKING
#define CONFIGURE_NETWORK_PRIORITY 10
#if pc586
#define LIBBSDPORT 1
#define MULTI_NETDRIVER 0
#define NEK 0
#include <rtems/pci.h>
#if LIBBSDPORT
#include <bsp/libbsdport_api.h>
driver_t* libbsdport_netdriver_table[] =
{
&libbsdport_rl_driver,
&libbsdport_re_driver,
&libbsdport_fxp_driver,
NULL
};
static int libbsdport_net_attach (struct rtems_bsdnet_ifconfig* ocfg, int attaching);
static struct rtems_bsdnet_ifconfig libbsdport_config[] =
{
{ "", libbsdport_net_attach, NULL }
};
static int libbsdport_net_attach (struct rtems_bsdnet_ifconfig* ocfg, int attaching)
{
int result;
result = pci_initialize ();
if (result)
{
printk ("PCI initialise failed\n");
return result;
}
printk ("Initialising libbsdport...\n");
result = libbsdport_netdriver_attach (&libbsdport_config[0], attaching);
if (result)
printk ("libbsdport failed: %d: %s\n", result, strerror (result));
return result;
}
#define CONFIGURE_NETWORK_DRIVER_NAME ""
#define CONFIGURE_NETWORK_DRIVER_ATTACH libbsdport_net_attach
#elif MULTI_NETDRIVER
int rtems_fxp_attach(struct rtems_bsdnet_ifconfig *config, int attaching);
int rtems_3c509_driver_attach (struct rtems_bsdnet_ifconfig *, int);
int rtems_fxp_attach (struct rtems_bsdnet_ifconfig *, int);
int rtems_elnk_driver_attach (struct rtems_bsdnet_ifconfig *, int);
int rtems_dec21140_driver_attach (struct rtems_bsdnet_ifconfig *, int);
/* these don't probe and will be used even if there's no device :-( */
int rtems_ne_driver_attach (struct rtems_bsdnet_ifconfig *, int);
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 },
/* qemu cannot configure irq-no :-(; has it hardwired to 9 */
{ "ne1", rtems_ne_driver_attach, 0, irno: 9 },
};
static struct rtems_bsdnet_ifconfig pci_netdriver_config[]=
{
{ "dc1", rtems_dec21140_driver_attach, pci_netdriver_config + 1 },
{ "fxp1", rtems_fxp_attach, pci_netdriver_config + 2 },
{ "elnk1", rtems_elnk_driver_attach, isa_netdriver_config },
};
extern int if_index;
static int net_prober (struct rtems_bsdnet_ifconfig* ocfg, int attaching)
{
struct rtems_bsdnet_ifconfig* cfg = NULL;
int if_index_pre;
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("attached\n");
ocfg->name = cfg->name;
ocfg->attach = cfg->attach;
return 0;
}
printk ("Probing %s : failed\n", cfg->name);
cfg = cfg->next;
}
return -1;
}
#define CONFIGURE_NETWORK_DRIVER_NAME "probing"
#define CONFIGURE_NETWORK_DRIVER_ATTACH net_prober
#define CONFIGURE_ETHERNET_ADDRESS 0x00, 0x08, 0xc7, 0x21, 0x01, 0xf9
#elif NEK
int rtems_ne_driver_attach (struct rtems_bsdnet_ifconfig *, int);
#define CONFIGURE_NETWORK_DRIVER_NAME "ne1"
#define CONFIGURE_NETWORK_DRIVER_ATTACH rtems_ne_driver_attach
#define CONFIGURE_ETHERNET_ADDRESS 0x00, 0x08, 0xc7, 0x21, 0x01, 0xf9
#else
int rtems_fxp_attach(struct rtems_bsdnet_ifconfig *config, int attaching);
#define CONFIGURE_NETWORK_DRIVER_NAME "fxp1"
#define CONFIGURE_NETWORK_DRIVER_ATTACH rtems_fxp_attach
#define CONFIGURE_ETHERNET_ADDRESS 0x00, 0x08, 0xc7, 0x21, 0x01, 0xf9
#endif
#else
#define CONFIGURE_NETWORK_DRIVER_NAME "fec0"
#define CONFIGURE_NETWORK_DRIVER_ATTACH rtems_fec_driver_attach
#define CONFIGURE_ETHERNET_ADDRESS 0x00, 0x20, 0xDD, 0xFF, 0x00, 0x01
#endif
#if RTEMS_APP_NETWORKING_DHCP
#define CONFIGURE_NETWORK_DHCP
#endif
#if RTEMS_APP_NETWORKING_STATIC
#define CONFIGURE_NETWORK_IPADDR "172.16.100.50"
#define CONFIGURE_NETWORK_NETMASK "255.255.255.0"
#define CONFIGURE_NETWORK_GATEWAY "172.16.100.1"
#endif
#define CONFIGURE_NETWORK_MBUFS (180*1024)
#define CONFIGURE_NETWORK_MCLUSTERS (350*1024)
#include "networkconfig.h"
#endif
#define CONFIGURE_SHELL_COMMANDS_INIT
#define CONFIGURE_SHELL_COMMANDS_ALL
#define CONFIGURE_SHELL_DEBUGRFS
#ifdef RTEMS_NETWORKING
#define CONFIGURE_SHELL_COMMANDS_ALL_NETWORKING
#endif
#include <rtems/shellconfig.h>