PageRenderTime 15ms CodeModel.GetById 7ms app.highlight 5ms RepoModel.GetById 1ms app.codeStats 0ms

/testbed/init.c

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