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