From 8c6b0338426c1d56d35cef6c2f94fa3667c75bc9 Mon Sep 17 00:00:00 2001 From: Joel Sherrill Date: Thu, 6 Sep 2007 22:01:37 +0000 Subject: 2007-09-06 Joel Sherrill * Makefile, init.c, rootfs/.cvsignore: Add some dynamic content. Can now look at cpu usage, reset cpu usage and print a stack usage report. * goahead_index.html, shttpd.png, shttpd_ext.c, shttpd_index.html: New files. * index.html.in: Removed. --- http/ChangeLog | 9 +++++++ http/Makefile | 22 +++++++++++------ http/goahead_index.html | 12 +++++++++ http/index.html.in | 12 --------- http/init.c | 13 +++++++--- http/rootfs/.cvsignore | 1 + http/shttpd.png | Bin 0 -> 73563 bytes http/shttpd_ext.c | 64 ++++++++++++++++++++++++++++++++++++++++++++++++ http/shttpd_index.html | 34 +++++++++++++++++++++++++ 9 files changed, 144 insertions(+), 23 deletions(-) create mode 100644 http/goahead_index.html delete mode 100644 http/index.html.in create mode 100644 http/shttpd.png create mode 100644 http/shttpd_ext.c create mode 100644 http/shttpd_index.html diff --git a/http/ChangeLog b/http/ChangeLog index ea6bbe7..d98feaa 100644 --- a/http/ChangeLog +++ b/http/ChangeLog @@ -1,3 +1,12 @@ +2007-09-06 Joel Sherrill + + * Makefile, init.c, rootfs/.cvsignore: Add some dynamic content. + Can now look at cpu usage, reset cpu usage and print a stack + usage report. + * goahead_index.html, shttpd.png, shttpd_ext.c, shttpd_index.html: + New files. + * index.html.in: Removed. + 2007-09-04 Joel Sherrill * init.c: Remove TARFILE_XXX macros. diff --git a/http/Makefile b/http/Makefile index 2d20a33..7c64dc4 100644 --- a/http/Makefile +++ b/http/Makefile @@ -8,7 +8,7 @@ PGM=${ARCH}/$(SAMPLE).exe MANAGERS=all # C source names, if any, go here -- minus the .c -C_PIECES=init FilesystemImage +C_PIECES=init FilesystemImage shttpd_ext C_FILES=$(C_PIECES:%=%.c) C_O_FILES=$(C_PIECES:%=${ARCH}/%.o) @@ -73,7 +73,7 @@ LD_LIBS += # CLEAN_ADDITIONS += FilesystemImage FilesystemImage.c FilesystemImage.h -CLEAN_ADDIRIONS += stamp-index-html rootfs/index.html +CLEAN_ADDITIONS += stamp-index-html rootfs/index.html rootfs/shttpd.png CLOBBER_ADDITIONS += # strip out flags gcc knows but LD doesn't like -- add as needed @@ -86,19 +86,27 @@ all: ${ARCH} $(SRCS) $(PGM) ${PGM}: $(OBJS) $(LINK_FILES) $(make-exe) - $(ARCH)/init.c: init.c FilesystemImage.c -FilesystemImage: $(ARCH) stamp-index-html +FilesystemImage: $(ARCH) stamp-index-html \ + rootfs/etc/host.conf rootfs/etc/hosts rootfs/rtems_logo.jpg cd rootfs ; \ tar cf ../FilesystemImage --exclude CVS --exclude .cvsignore . FilesystemImage.c: $(ARCH) FilesystemImage $(PROJECT_ROOT)/bin/bin2c FilesystemImage FilesystemImage -stamp-index-html: index.html.in -ifneq ($(HTTPD),) - sed -e 's/@SERVER@/$(HTTPD)/' rootfs/index.html +rootfs/index.html: shttpd_index.html goahead_index.html +ifeq ($(USE_SIMPLE),yes) + cp shttpd_index.html rootfs/index.html +endif +ifeq ($(USE_GOHEAD),yes) + cp goahead_index.html rootfs/index.html +endif + +stamp-index-html: rootfs/index.html +ifeq ($(USE_SIMPLE),yes) + cp shttpd.png rootfs endif touch stamp-index-html diff --git a/http/goahead_index.html b/http/goahead_index.html new file mode 100644 index 0000000..cdfcf58 --- /dev/null +++ b/http/goahead_index.html @@ -0,0 +1,12 @@ + +RTEMS @SERVER@ Test Page + +
+

RTEMS @SERVER@ Test Page

+ + RTEMS + +

Congratulations, you have successfully loaded your first page +from the GoAhead webserver running on RTEMS.

+
+ diff --git a/http/index.html.in b/http/index.html.in deleted file mode 100644 index 9c14022..0000000 --- a/http/index.html.in +++ /dev/null @@ -1,12 +0,0 @@ - -RTEMS @SERVER@ Test Page - -
-

RTEMS @SERVER@ Test Page

- - RTEMS - -

Congratulations, you have successfully loaded your first page -from the @SERVER@ running on RTEMS.

-
- diff --git a/http/init.c b/http/init.c index f6f64d3..9ea0a58 100644 --- a/http/init.c +++ b/http/init.c @@ -24,6 +24,7 @@ RTEMS_NO_ASR | \ RTEMS_INTERRUPT_LEVEL(0)) +#define STACK_CHECKER_ON #define CONFIGURE_INIT #include "system.h" @@ -92,6 +93,10 @@ #define bool2string(_b) ((_b) ? "true" : "false") +#if defined(USE_SIMPLE_HTTPD) +extern void example_shttpd_addpages(struct shttpd_ctx *ctx); +#endif + rtems_task Init( rtems_task_argument argument ) @@ -107,10 +112,10 @@ rtems_task Init( /* * Load filesystem image */ - printf("Loading filesystem image"); + printf("Loading filesystem image\n"); status = Untar_FromMemory( (char *)FilesystemImage, FilesystemImage_size ); - printf("Initializing Network"); + printf("Initializing Network\n"); rtems_bsdnet_initialize_network (); #if defined(USE_FTPD) @@ -131,11 +136,11 @@ rtems_task Init( printf( "Initializing Simple HTTPD\n" ); status = rtems_initialize_webserver( 100, /* initial priority */ - RTEMS_MINIMUM_STACK_SIZE * 2, /* stack size */ + RTEMS_MINIMUM_STACK_SIZE * 4, /* stack size */ RTEMS_DEFAULT_MODES, /* initial modes */ RTEMS_DEFAULT_ATTRIBUTES, /* attributes */ NULL, /* init_callback */ - NULL, /* addpages_callback */ + example_shttpd_addpages, /* addpages_callback */ "/", /* initial priority */ 80 /* port to listen on */ ); diff --git a/http/rootfs/.cvsignore b/http/rootfs/.cvsignore index dcaf716..ea0613a 100644 --- a/http/rootfs/.cvsignore +++ b/http/rootfs/.cvsignore @@ -1 +1,2 @@ index.html +shttpd.png diff --git a/http/shttpd.png b/http/shttpd.png new file mode 100644 index 0000000..59033ee Binary files /dev/null and b/http/shttpd.png differ diff --git a/http/shttpd_ext.c b/http/shttpd_ext.c new file mode 100644 index 0000000..901f3f1 --- /dev/null +++ b/http/shttpd_ext.c @@ -0,0 +1,64 @@ +/* SHTTPD Extensions + * + * $Id$ + */ + + +#if defined(USE_SIMPLE_HTTPD) + +#include +#include +#include +#include + +#include + +#define START_HTML_BODY \ + "HTTP/1.1 200 OK\r\n" \ + "Content-Type: text/html\r\n\r\n" \ + "\r\n" + +#define END_HTML_BODY \ + +void example_shttpd_callback(struct shttpd_arg *arg) +{ + const char *query; + + query = shttpd_get_env(arg, "QUERY_STRING" ); + if ( !query ) + query = ""; + /* fprintf( stderr, "RTEMS Request -%s-\n", query ); */ + + if ( !strcmp( query, "cpuuse_report" ) ) { + rtems_cpu_usage_report_with_handler( arg, shttpd_printf ); + } else if ( !strcmp( query, "cpuuse_reset" ) ) { + rtems_cpu_usage_reset(); + shttpd_printf( + arg, + START_HTML_BODY + "

CPU Usage data reset -- return to the previous page

" + END_HTML_BODY + ); + } else if ( !strcmp( query, "stackuse_report" ) ) { + rtems_stack_checker_report_usage_with_handler( arg, shttpd_printf ); + } else { + shttpd_printf( + arg, + START_HTML_BODY + "

Unknown Request

" + "

URI: %s
" + " Arguments: %s

" + END_HTML_BODY, + shttpd_get_env(arg, "REQUEST_URI"), + query + ); + } + arg->flags |= SHTTPD_END_OF_OUTPUT; +} + +void example_shttpd_addpages(struct shttpd_ctx *ctx) +{ + shttpd_register_uri( ctx, "/queries*", example_shttpd_callback, NULL ); +} + +#endif diff --git a/http/shttpd_index.html b/http/shttpd_index.html new file mode 100644 index 0000000..0132df6 --- /dev/null +++ b/http/shttpd_index.html @@ -0,0 +1,34 @@ + +RTEMS Simple HTTPD Web Server Test Page + + + + + + +
+ + RTEMS + + + + Simple HTTPD + +
+ +

Congratulations, you have successfully loaded your first page +from the Simple HTTPD Web Server running on RTEMS. +

+ +

+This RTEMS program includes some dynamic web pages. Check +out the following links for examples: +

+ +
+ + -- cgit v1.2.3