source: network-demos/http/init.c @ 5d2c26f

4.11network-demos-4-10-branch
Last change on this file since 5d2c26f was 5d2c26f, checked in by Joel Sherrill <joel.sherrill@…>, on 05/13/09 at 18:54:45

2009-05-13 Joel Sherrill <joel.sherrill@…>

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