summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoel Sherrill <joel.sherrill@OARcorp.com>2007-09-06 22:01:37 +0000
committerJoel Sherrill <joel.sherrill@OARcorp.com>2007-09-06 22:01:37 +0000
commit8c6b0338426c1d56d35cef6c2f94fa3667c75bc9 (patch)
treed4353391aa3e5f3e8a4d3769987eb40c27b92d57
parenta0273651341bae53f841583ca90413bb5e155113 (diff)
2007-09-06 Joel Sherrill <joel.sherrill@oarcorp.com>
* 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.
-rw-r--r--http/ChangeLog9
-rw-r--r--http/Makefile22
-rw-r--r--http/goahead_index.html (renamed from http/index.html.in)2
-rw-r--r--http/init.c13
-rw-r--r--http/rootfs/.cvsignore1
-rw-r--r--http/shttpd.pngbin0 -> 73563 bytes
-rw-r--r--http/shttpd_ext.c64
-rw-r--r--http/shttpd_index.html34
8 files changed, 133 insertions, 12 deletions
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 <joel.sherrill@oarcorp.com>
+
+ * 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 <joel.sherrill@oarcorp.com>
* 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)/' <index.html.in >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/index.html.in b/http/goahead_index.html
index 9c14022..cdfcf58 100644
--- a/http/index.html.in
+++ b/http/goahead_index.html
@@ -7,6 +7,6 @@
<IMG align=center BORDER=0 SRC="rtems_logo.jpg" ALT="RTEMS"> </A>
<P><big>Congratulations, you have successfully loaded your first page
-from the @SERVER@ running on RTEMS.</big></P>
+from the GoAhead webserver running on RTEMS.</big></P>
</center>
</BODY></HTML>
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
--- /dev/null
+++ b/http/shttpd.png
Binary files 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 <rtems.h>
+#include <shttpd/shttpd.h>
+#include <rtems/cpuuse.h>
+#include <rtems/stackchk.h>
+
+#include <stdio.h>
+
+#define START_HTML_BODY \
+ "HTTP/1.1 200 OK\r\n" \
+ "Content-Type: text/html\r\n\r\n" \
+ "<html><body>\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
+ " <p><big>CPU Usage data reset -- return to the previous page</big></p>"
+ 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
+ " <h2>Unknown Request</h2>"
+ " <h3>URI: %s</br>"
+ " Arguments: %s</h3>"
+ 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 @@
+<HTML>
+<HEAD><TITLE>RTEMS Simple HTTPD Web Server Test Page</TITLE></HEAD>
+<BODY BGCOLOR="FFFFFF">
+<table>
+<tr>
+ <td width="40%">
+ <A HREF="http://www.rtems.org">
+ <IMG align=right BORDER=0 SRC="rtems_logo.jpg" ALT="RTEMS"> </A>
+ <td>
+ <td width="20%"></td>
+ <td width="40%">
+ <A HREF="http://http://shttpd.sourceforge.net/">
+ <IMG align=left BORDER=0 SRC="shttpd.png" ALT="Simple HTTPD"> </A>
+ <td>
+ <td width="10%"></td>
+</tr>
+</table>
+<BIG>
+<P>Congratulations, you have successfully loaded your first page
+from the Simple HTTPD Web Server running on RTEMS.
+</P>
+
+</P>
+This RTEMS program includes some dynamic web pages. Check
+out the following links for examples:
+</P>
+<UL>
+ <LI><A HREF="queries?cpuuse_report">CPU Usage -- Report</LI>
+ <LI><A HREF="queries?cpuuse_reset">CPU Usage -- Reset</LI>
+ <LI><A HREF="queries?stackuse_report">Stack Usage -- Report</LI>
+</UL>
+</big>
+
+</BODY></HTML>