I have never build the documentation for eCos so I don't know if I've
added the example correctly.

-- 
Øyvind Harboe
http://www.zylin.com - eCos ARM & FPGA  developer kit
### Eclipse Workspace Patch 1.0
#P ecos
Index: hal/arm/at91/var/current/src/timer_pit.c
===================================================================
RCS file: /cvs/ecos/ecos/packages/hal/arm/at91/var/current/src/timer_pit.c,v
retrieving revision 1.4
diff -u -r1.4 timer_pit.c
--- hal/arm/at91/var/current/src/timer_pit.c    20 Feb 2007 21:33:03 -0000      
1.4
+++ hal/arm/at91/var/current/src/timer_pit.c    12 Nov 2007 15:16:33 -0000
@@ -116,36 +116,5 @@
   *pvalue = ir & AT91_PITC_VALUE_MASK;
 }
 
-// -------------------------------------------------------------------------
-//
-// Delay for some number of micro-seconds
-// PIT is clocked at MCLK / 16
-//
-void hal_delay_us(cyg_int32 usecs)
-{
-  cyg_int64 ticks;
-  cyg_uint32 val1, val2;
-  cyg_uint32 piv;
-  
-  // Calculate how many PIT ticks the required number of microseconds
-  // equate to. We do this calculation in 64 bit arithmetic to avoid
-  // overflow.
-  ticks = (((cyg_uint64)usecs) * 
-           ((cyg_uint64)CYGNUM_HAL_ARM_AT91_CLOCK_SPEED))/16/1000000LL;
-  
-  // Calculate the wrap around period. 
-  HAL_READ_UINT32(AT91_PITC + AT91_PITC_PIMR, piv);
-  piv = (piv & AT91_PITC_VALUE_MASK) - 1; 
-  
-  hal_clock_read(&val1);
-  while (ticks > 0) {
-    hal_clock_read(&val2);
-    if (val2 < val1)
-      ticks -= ((piv + val2) - val1); //overflow occurred
-    else 
-      ticks -= (val2 - val1);
-    val1 = val2;
-  }
-}
 
 // timer_pit.c
Index: hal/arm/at91/var/current/src/timer_tc.c
===================================================================
RCS file: /cvs/ecos/ecos/packages/hal/arm/at91/var/current/src/timer_tc.c,v
retrieving revision 1.2
diff -u -r1.2 timer_tc.c
--- hal/arm/at91/var/current/src/timer_tc.c     25 Feb 2006 20:12:32 -0000      
1.2
+++ hal/arm/at91/var/current/src/timer_tc.c     12 Nov 2007 15:16:33 -0000
@@ -108,53 +108,5 @@
     *pvalue = val;
 }
 
-// -------------------------------------------------------------------------
-//
-// Delay for some number of micro-seconds
-//   Use timer #2 in MCLOCK/32 mode.
-//
-void hal_delay_us(cyg_int32 usecs)
-{
-    cyg_uint32 stat;
-    cyg_uint64 ticks;
-#if defined(CYGHWR_HAL_ARM_AT91_JTST)
-    // TC2 is reserved for AD/DA. Use TC1 instead. 
-    CYG_ADDRESS timer = AT91_TC+AT91_TC_TC1;
-#else
-    CYG_ADDRESS timer = AT91_TC+AT91_TC_TC2;
-#endif
-    // Calculate how many timer ticks the required number of
-    // microseconds equate to. We do this calculation in 64 bit
-    // arithmetic to avoid overflow.
-    ticks = (((cyg_uint64)usecs) * 
-             ((cyg_uint64)CYGNUM_HAL_ARM_AT91_CLOCK_SPEED))/32000000LL;
-    
-    //    CYG_ASSERT(ticks < (1 << 16), "Timer overflow");
-    
-    if (ticks > (1 << 16))
-      ticks = (1 << 16) - 1;
-    
-    if (ticks == 0)
-      return;
-    
-    // Disable counter
-    HAL_WRITE_UINT32(timer+AT91_TC_CCR, AT91_TC_CCR_CLKDIS);
-
-    // Set registers
-    HAL_WRITE_UINT32(timer+AT91_TC_CMR, AT91_TC_CMR_CLKS_MCK32);  // 1MHz
-    HAL_WRITE_UINT32(timer+AT91_TC_RA, 0);
-    HAL_WRITE_UINT32(timer+AT91_TC_RC, ticks);
-
-    // Clear status flags
-    HAL_READ_UINT32(timer+AT91_TC_SR, stat);
-    
-    // Start timer
-    HAL_WRITE_UINT32(timer+AT91_TC_CCR, AT91_TC_CCR_TRIG | AT91_TC_CCR_CLKEN);
-    
-    // Wait for the compare
-    do {
-      HAL_READ_UINT32(timer+AT91_TC_SR, stat);
-    } while ((stat & AT91_TC_SR_CPC) == 0);
-}
 
 // timer_tc.c
Index: ecos.db
===================================================================
RCS file: /cvs/ecos/ecos/packages/ecos.db,v
retrieving revision 1.167
diff -u -r1.167 ecos.db
--- ecos.db     3 Jul 2007 14:42:18 -0000       1.167
+++ ecos.db     12 Nov 2007 15:16:33 -0000
@@ -1816,15 +1816,6 @@
        description     "Ethernet driver for XSEngine board."
 }
 
-package CYGPKG_DEVS_ETH_ARM_GRG_I82559 {
-       alias           { "GRG / Intel 82559 ethernet driver"
-                          devs_eth_arm_grg_i82559 }
-       hardware
-       directory       devs/eth/arm/grg/i82559
-       script          grg_i82559_eth_driver.cdl
-        description     "Ethernet driver for GRG with Intel 82559 PCI NIC."
-}
-
 package CYGPKG_DEVS_ETH_I386_PC_I82559 {
        alias           { "Standard PC with EtherPro 10/100 ethernet device"
                           devs_eth_i386_pc_i82559 pc_etherpro }
Index: net/athttpd/current/doc/athttpd.sgml
===================================================================
RCS file: /cvs/ecos/ecos-opt/net/net/athttpd/current/doc/athttpd.sgml,v
retrieving revision 1.5
diff -u -r1.5 athttpd.sgml
--- net/athttpd/current/doc/athttpd.sgml        12 Nov 2007 11:32:02 -0000      
1.5
+++ net/athttpd/current/doc/athttpd.sgml        12 Nov 2007 15:16:34 -0000
@@ -365,6 +365,40 @@
 </sect2>
 </sect1>
 
+
+<title>tcl hello world</title>
+<sect3 id="athttpd-tcl-hello-world">
+<title>end_chunked</title>
+<programlisting width=72>
+#This will replace print /ram/log as a valid html file w/replacing \n 
w/&lt;br&gt;
+#log.tcl
+start_chunked "html";
+
+set fp [aio.open "/ram/log" r];
+$fp seek 0 end;
+set fsize [$fp tell];
+$fp seek 0 start;
+set data "abcxxx";
+set data [$fp read $fsize];
+$fp close;
+set data [string map {\n <br>} $data];
+
+set datax "";
+append datax "<html><body>" $data "</body></html>";
+
+write_chunked $datax;
+end_chunked;
+</programlisting>
+<para>
+The above is an example of how to convert a log file in /ram/log to
+HTML code. Copy the log.tcl above to a file system on your embedded 
+target and navigate to http://10.0.0.66/cgi-bin/hello.tcl. The tcl script 
+is then executed, where 10.0.0.66 is the IP and "cgi-bin" is the cgi-bin
+directory.
+</para>
+</sect3>
+
+
 <sect1 id="athttpd-authentication">
 <title>Authentication</title>
 <para>
Index: net/athttpd/current/src/forms.c
===================================================================
RCS file: /cvs/ecos/ecos-opt/net/net/athttpd/current/src/forms.c,v
retrieving revision 1.3
diff -u -r1.3 forms.c
--- net/athttpd/current/src/forms.c     27 Nov 2006 15:41:56 -0000      1.3
+++ net/athttpd/current/src/forms.c     12 Nov 2007 15:16:35 -0000
@@ -252,16 +252,6 @@
     if (httpstate.mode & CYG_HTTPD_MODE_FORM_DATA)
         cyg_httpd_store_form_data(httpstate.post_data);
 
-    handler h = cyg_httpd_find_handler();
-    if (h != 0)
-    {
-        // A handler was found. We'll call the function associated to it.
-        h(&httpstate);
-        free(httpstate.post_data);
-        httpstate.post_data = NULL;
-        return;
-    }
-
 #if defined(CYGOPT_NET_ATHTTPD_USE_CGIBIN_OBJLOADER) || \
                            defined(CYGOPT_NET_ATHTTPD_USE_CGIBIN_TCL)
     // See if we are trying to execute a CGI via one of the supported methods.
@@ -282,6 +272,17 @@
         return;
     }
 #endif    
+    
+    handler h = cyg_httpd_find_handler();
+    if (h != 0)
+    {
+        // A handler was found. We'll call the function associated to it.
+        h(&httpstate);
+        free(httpstate.post_data);
+        httpstate.post_data = NULL;
+        return;
+    }
+
 
     // No handler of any kind for a post request. Must send 404.
     cyg_httpd_send_error(CYG_HTTPD_STATUS_NOT_FOUND);
Index: net/athttpd/current/src/http.c
===================================================================
RCS file: /cvs/ecos/ecos-opt/net/net/athttpd/current/src/http.c,v
retrieving revision 1.3
diff -u -r1.3 http.c
--- net/athttpd/current/src/http.c      27 Nov 2006 15:41:56 -0000      1.3
+++ net/athttpd/current/src/http.c      12 Nov 2007 15:16:36 -0000
@@ -708,15 +708,7 @@
 void
 cyg_httpd_handle_method_GET(void)
 {
-    // Use defined handlers take precedence over other forms of response.
-    handler h = cyg_httpd_find_handler();
-    if (h != 0)
-    {
-        h(&httpstate);
-        return;
-    }
-    
-#ifdef CYGOPT_NET_ATHTTPD_USE_CGIBIN_OBJLOADER
+#if defined(CYGOPT_NET_ATHTTPD_USE_CGIBIN_OBJLOADER) || 
defined(CYGOPT_NET_ATHTTPD_USE_CGIBIN_TCL)
     // If the URL is a CGI script, there is a different directory...
     if (httpstate.url[0] == '/' &&
                     !strncmp(httpstate.url + 1, 
@@ -730,6 +722,15 @@
     //  will likely generate a 404.
 #endif    
 
+    // Use defined handlers take precedence over other forms of response.
+    handler h = cyg_httpd_find_handler();
+    if (h != 0)
+    {
+        h(&httpstate);
+        return;
+    }
+    
+
 #ifdef CYGOPT_NET_ATHTTPD_USE_FS
     // No handler, we'll redirect to the file system.
     cyg_httpd_send_file(httpstate.url);
@@ -940,28 +941,28 @@
             }
             else if (strncasecmp(p, "Digest", 6) == 0)
             {
-                p += 6;
-                while (*p == ' ')
-                   p++;
+                p += 6;
+                while (*p == ' ')
+                   p++;
                 while ((*p != '\r') && (*p != '\n'))
-                {
-                    if (strncasecmp(p, "realm=", 6) == 0)
+                {
+                    if (strncasecmp(p, "realm=", 6) == 0)
                         p = cyg_httpd_digest_skip(p + 6);
-                    else if (strncasecmp(p, "username=", 9) == 0)
+                    else if (strncasecmp(p, "username=", 9) == 0)
                         p = cyg_httpd_digest_skip(p + 9);
                     else if (strncasecmp(p, "nonce=", 6) == 0)
                         p = cyg_httpd_digest_skip(p + 6);
-                    else if (strncasecmp(p, "response=", 9) == 0)
+                    else if (strncasecmp(p, "response=", 9) == 0)
                         p = cyg_httpd_digest_data(cyg_httpd_md5_response, 
                                                   p + 9);
-                    else if (strncasecmp(p, "cnonce=", 7) == 0)
+                    else if (strncasecmp(p, "cnonce=", 7) == 0)
                         p = cyg_httpd_digest_data(cyg_httpd_md5_cnonce, p + 7);
-                    else if (strncasecmp(p, "qop=", 4) == 0)
+                    else if (strncasecmp(p, "qop=", 4) == 0)
                         p = cyg_httpd_digest_skip(p + 4);
-                    else if (strncasecmp(p, "nc=", 3) == 0)
+                    else if (strncasecmp(p, "nc=", 3) == 0)
                         p = cyg_httpd_digest_data(cyg_httpd_md5_noncecount, 
                                                   p + 3);
-                    else if (strncasecmp(p, "algorithm=", 10) == 0)
+                    else if (strncasecmp(p, "algorithm=", 10) == 0)
                         p = cyg_httpd_digest_skip(p + 10);
                     else if (strncasecmp(p, "opaque=", 7) == 0)
                         p = cyg_httpd_digest_skip(p + 7);
Index: net/athttpd/current/ChangeLog
===================================================================
RCS file: /cvs/ecos/ecos-opt/net/net/athttpd/current/ChangeLog,v
retrieving revision 1.8
diff -u -r1.8 ChangeLog
--- net/athttpd/current/ChangeLog       12 Nov 2007 13:33:12 -0000      1.8
+++ net/athttpd/current/ChangeLog       12 Nov 2007 15:16:34 -0000
@@ -1,7 +1,12 @@
 2007-11-12  Oyvind Harboe  <[EMAIL PROTECTED]>
 
+       * doc/athttpd.sgml: added an example of a tcl script.
+       * src/http.c, forms.c: serve cgi requests before file system requests, 
that 
+       way it isn't possible to download the actual cgi/.o script and cgi works
+       even if the http root directory is above the cgi directory.   
+       * src/http.c: if only tcl cgi is enabled, cgi requests are now 
forwarded to tcl
        * include/jim.h: include file order fix; now compiles again.
-       * doc/athttpd.cdl: Fixed typos in doc. Return value from handler is not 
+       * doc/athttpd.sgml: Fixed typos in doc. Return value from handler is 
not 
        used, recommend returning 0 in doc.
 
 2006-12-03  Anthony Tonizzo  <[EMAIL PROTECTED]>
Index: .project
===================================================================
RCS file: .project
diff -N .project
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ .project    1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+       <name>ecos</name>
+       <comment></comment>
+       <projects>
+       </projects>
+       <buildSpec>
+       </buildSpec>
+       <natures>
+       </natures>
+</projectDescription>

Reply via email to