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