source: network-demos/http/init.c @ 6bfe512

4.11network-demos-4-10-branchnetwork-demos-4-9-branch
Last change on this file since 6bfe512 was 6bfe512, checked in by Joel Sherrill <joel.sherrill@…>, on 12/06/07 at 15:16:53

2007-12-06 Joel Sherrill <joel.sherrill@…>

  • Makefile, init.c: Make sure POSIX threading is enabled if using GoAhead?.
  • Property mode set to 100644
File size: 4.4 KB
Line 
1/*  Init
2 *
3 *  This routine is the initialization task for this test program.
4 *
5 *  Don't forget to change the IP addresses
6 */
7
8#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
9#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
10#define CONFIGURE_RTEMS_INIT_TASKS_TABLE
11#define CONFIGURE_LIBIO_MAXIMUM_FILE_DESCRIPTORS        20
12#define CONFIGURE_USE_IMFS_AS_BASE_FILESYSTEM
13
14#define CONFIGURE_EXECUTIVE_RAM_SIZE    (512*1024)
15#define CONFIGURE_MAXIMUM_SEMAPHORES    20
16#define CONFIGURE_MAXIMUM_TASKS         20
17
18#define CONFIGURE_MICROSECONDS_PER_TICK 10000
19
20#define CONFIGURE_INIT_TASK_STACK_SIZE  (10*1024)
21#define CONFIGURE_INIT_TASK_PRIORITY    120
22#define CONFIGURE_INIT_TASK_INITIAL_MODES (RTEMS_PREEMPT | \
23                                           RTEMS_NO_TIMESLICE | \
24                                           RTEMS_NO_ASR | \
25                                           RTEMS_INTERRUPT_LEVEL(0))
26
27#define STACK_CHECKER_ON
28#define CONFIGURE_INIT
29
30#include "system.h"
31#include <bsp.h>
32
33#include <errno.h>
34#include <time.h>
35
36#include <rtems/confdefs.h>
37#include <stdio.h>
38#include <rtems/rtems_bsdnet.h>
39#include <rtems/ftpd.h>
40#include <rtems/untar.h>
41
42     
43#include <rtems/error.h>
44#include <rpc/rpc.h>
45#include <netinet/in.h>
46#include <time.h>
47
48#include <arpa/inet.h>
49#include <sys/socket.h>
50#include "../networkconfig.h"
51
52#include <rtems_webserver.h>
53
54#define ARGUMENT 0
55
56/*
57 *  The tarfile image is built automatically externally.
58 */
59#include "FilesystemImage.h"
60
61#if defined(USE_FTPD)
62  boolean FTPD_enabled = TRUE;
63  struct rtems_ftpd_configuration rtems_ftpd_configuration = {
64    10,                     /* FTPD task priority            */
65    1024,                   /* Maximum buffersize for hooks  */
66    21,                     /* Well-known port     */
67    NULL                    /* List of hooks       */
68 };
69#else
70 boolean FTPD_enabled = FALSE;
71#endif
72
73#if defined(USE_GOAHEAD_HTTPD) && !defined(RTEMS_POSIX_API)
74  #warning "GoAhead server requires POSIX API - switching to SHTTPD"
75  #undef USE_GOAHEAD_HTTPD
76  #undef USE_SIMPLE_HTTPD
77#endif
78
79#if defined(USE_GOAHEAD_HTTPD)
80  boolean GoAhead_HTTPD_enabled = TRUE;
81
82  /* GoAhead Trace Handler */
83  #include <goahead/uemf.h>
84  void quietTraceHandler(int level, char *buf)
85  {
86    /* do nothing */
87  }
88#else
89  boolean GoAhead_HTTPD_enabled = FALSE;
90#endif
91
92#if defined(USE_SIMPLE_HTTPD)
93  boolean Simple_HTTPD_enabled = TRUE;
94
95  #include <shttpd/shttpd.h>
96#else
97  boolean Simple_HTTPD_enabled = FALSE;
98#endif
99
100#define bool2string(_b) ((_b) ? "true" : "false")
101
102#if defined(USE_SIMPLE_HTTPD)
103extern void example_shttpd_addpages(struct shttpd_ctx *ctx);
104#endif
105
106rtems_task Init(
107  rtems_task_argument argument
108)
109{
110  rtems_status_code status;
111
112  printf("\n\n*** HTTP TEST ***\n\r" );
113  printf("GoAhead HTTPD Enabled: %s\n", bool2string(GoAhead_HTTPD_enabled) );
114  printf("Simple HTTPD Enabled: %s\n", bool2string(Simple_HTTPD_enabled) );
115  printf("FTPD Enabled: %s\n", bool2string(FTPD_enabled) );
116  printf("\n");
117
118  /*
119   * Load filesystem image
120   */
121  printf("Loading filesystem image\n");
122  status = Untar_FromMemory( (char *)FilesystemImage, FilesystemImage_size );
123   
124  printf("Initializing Network\n");
125  rtems_bsdnet_initialize_network ();
126
127  #if defined(USE_FTPD)
128    printf( "Initializing FTPD\n" );
129    rtems_initialize_ftpd();
130  #endif
131
132  #if defined(USE_GOAHEAD_HTTPD)
133    printf( "Initializing GoAhead HTTPD\n" );
134    status = rtems_initialize_webserver();
135    if ( status )
136      printf( "ERROR -- failed to initialize webserver\n" );
137
138    traceSetHandler( quietTraceHandler );
139  #endif
140
141  #if defined(USE_SIMPLE_HTTPD)
142    /*
143     *  SHTTPD uses about 37K of stack even in this test on a PowerPC.
144     *  There is no point in doing math for the stack size.  Bump it
145     *  until there isn't a problem.
146     */
147    printf( "Initializing Simple HTTPD\n" );
148    status = rtems_initialize_webserver(
149      100,                             /* initial priority */
150      (48 * 1024),                     /* stack size */
151      RTEMS_DEFAULT_MODES,             /* initial modes */
152      RTEMS_DEFAULT_ATTRIBUTES,        /* attributes */
153      NULL,                            /* init_callback */
154      example_shttpd_addpages,         /* addpages_callback */
155      "/",                             /* initial priority */
156      80                               /* port to listen on */
157    );
158    if ( status )
159      printf( "ERROR -- failed to initialize webserver\n" );
160
161  #endif
162
163  status = rtems_task_delete( RTEMS_SELF );
164}
165
166
167
168
Note: See TracBrowser for help on using the repository browser.