Compare commits

..

46 Commits

Author SHA1 Message Date
patacongo
023de4390c Prep for 0.4.10 release
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@2016 42af7a65-404d-4744-a932-0658087f49c3
2009-08-08 18:12:10 +00:00
patacongo
a39e85d2ff Fix various errors in time manipulation routines
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@2015 42af7a65-404d-4744-a932-0658087f49c3
2009-08-08 16:54:36 +00:00
patacongo
f7483ab7b1 strftime fixes
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@2014 42af7a65-404d-4744-a932-0658087f49c3
2009-08-08 15:14:10 +00:00
patacongo
32716fbc25 Remove warning
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@2013 42af7a65-404d-4744-a932-0658087f49c3
2009-08-02 23:44:49 +00:00
patacongo
e832fd2a40 Bump up THTTPD main thread stack size
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@2012 42af7a65-404d-4744-a932-0658087f49c3
2009-08-02 23:40:47 +00:00
patacongo
3ec3bfdcc8 accept() now supports non-blocking operations
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@2011 42af7a65-404d-4744-a932-0658087f49c3
2009-08-02 23:35:27 +00:00
patacongo
09b640e844 Fix fdwatch problems; reduce fdwatch memory usage
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@2010 42af7a65-404d-4744-a932-0658087f49c3
2009-08-02 18:12:22 +00:00
patacongo
5e2d7c363b update
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@2009 42af7a65-404d-4744-a932-0658087f49c3
2009-08-02 16:40:49 +00:00
patacongo
7c2070bc83 Fix accept() -- it wanted parts of return address initialized
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@2008 42af7a65-404d-4744-a932-0658087f49c3
2009-08-02 16:31:50 +00:00
patacongo
7c8051a574 THTTPD now gets past initialization
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@2007 42af7a65-404d-4744-a932-0658087f49c3
2009-08-02 16:08:20 +00:00
patacongo
4322c23e43 Initialize THTTPD integration changes
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@2006 42af7a65-404d-4744-a932-0658087f49c3
2009-08-02 15:08:09 +00:00
patacongo
ea16dce2f3 Fix some ez80 compilation errors
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@2005 42af7a65-404d-4744-a932-0658087f49c3
2009-08-02 13:24:47 +00:00
patacongo
64777d8eaf Fix build problems with different configuratin options
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@2004 42af7a65-404d-4744-a932-0658087f49c3
2009-08-02 12:56:52 +00:00
patacongo
6afa5ccf72 Fix clean target error
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@2003 42af7a65-404d-4744-a932-0658087f49c3
2009-08-01 23:42:07 +00:00
patacongo
2ae1a0c1d6 Add THTTPD configuration
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@2002 42af7a65-404d-4744-a932-0658087f49c3
2009-08-01 23:17:52 +00:00
patacongo
c07e541644 Install .html files; install exe's in cgi-bin subdir
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@2000 42af7a65-404d-4744-a932-0658087f49c3
2009-08-01 21:48:57 +00:00
patacongo
d369294f8b Add infrastructure to add CGI binaries to THTTPD example
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@1999 42af7a65-404d-4744-a932-0658087f49c3
2009-08-01 21:29:56 +00:00
patacongo
0a4f4a805d Basic files for THTTPD test
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@1998 42af7a65-404d-4744-a932-0658087f49c3
2009-08-01 20:06:46 +00:00
patacongo
0051421e18 Finish fdwatch logic in cgi_child
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@1997 42af7a65-404d-4744-a932-0658087f49c3
2009-07-19 14:14:35 +00:00
patacongo
b63c500c14 Add non-blocking capability for TCP sockets
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@1996 42af7a65-404d-4744-a932-0658087f49c3
2009-07-19 13:50:08 +00:00
patacongo
297cb5e256 Add fcntl(F_DUPFD)
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@1995 42af7a65-404d-4744-a932-0658087f49c3
2009-07-19 00:14:46 +00:00
patacongo
e68c54fea0 Still fleshing out THTTPD example
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@1994 42af7a65-404d-4744-a932-0658087f49c3
2009-07-18 22:59:44 +00:00
patacongo
8c7634d4a2 Add skeleton for fcntl()
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@1993 42af7a65-404d-4744-a932-0658087f49c3
2009-07-18 21:39:59 +00:00
patacongo
5f7092fd27 Document string operations
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@1992 42af7a65-404d-4744-a932-0658087f49c3
2009-07-18 21:04:10 +00:00
patacongo
eefb20545f Add strpbrk()
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@1991 42af7a65-404d-4744-a932-0658087f49c3
2009-07-18 20:39:57 +00:00
patacongo
b9e21dbab5 Add strstr()
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@1990 42af7a65-404d-4744-a932-0658087f49c3
2009-07-18 20:11:11 +00:00
patacongo
22fa6bdfb3 Add framework for THTTPD example
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@1989 42af7a65-404d-4744-a932-0658087f49c3
2009-07-18 19:47:08 +00:00
patacongo
8c17e7f6d0 Fix CGI I/O redirection and interposer tasks
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@1988 42af7a65-404d-4744-a932-0658087f49c3
2009-07-18 18:04:05 +00:00
patacongo
59cf543804 Fix typo in vectored interrpt logic
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@1987 42af7a65-404d-4744-a932-0658087f49c3
2009-07-14 02:16:06 +00:00
patacongo
4b3d42c879 A big, hard-coded stack size was used in several places
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@1986 42af7a65-404d-4744-a932-0658087f49c3
2009-07-14 01:48:06 +00:00
patacongo
485c3066e1 Add fileno()
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@1985 42af7a65-404d-4744-a932-0658087f49c3
2009-07-13 01:35:15 +00:00
patacongo
470cba238e Add THTTPD configuration
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@1984 42af7a65-404d-4744-a932-0658087f49c3
2009-07-13 01:32:54 +00:00
patacongo
8f3d3641e5 Add NXFLAT CGI programs
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@1983 42af7a65-404d-4744-a932-0658087f49c3
2009-07-13 01:30:53 +00:00
patacongo
3975fc5bdf Add tdate_parse.c
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@1982 42af7a65-404d-4744-a932-0658087f49c3
2009-07-12 20:48:44 +00:00
patacongo
4020506590 Add fdwatch.c and timers.c
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@1981 42af7a65-404d-4744-a932-0658087f49c3
2009-07-12 20:27:56 +00:00
patacongo
1235ab92c5 libthttpd.c now longer used fork() and execve()
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@1980 42af7a65-404d-4744-a932-0658087f49c3
2009-07-12 18:46:11 +00:00
patacongo
29899e1069 Added exec()
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@1979 42af7a65-404d-4744-a932-0658087f49c3
2009-07-12 18:43:59 +00:00
patacongo
93e34db926 Add libhttpd.c
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@1978 42af7a65-404d-4744-a932-0658087f49c3
2009-07-12 16:45:27 +00:00
patacongo
49a834785b Add strftime
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@1977 42af7a65-404d-4744-a932-0658087f49c3
2009-07-12 15:16:00 +00:00
patacongo
b32b7cb4b2 Add gmtime and localtime
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@1976 42af7a65-404d-4744-a932-0658087f49c3
2009-07-12 00:41:06 +00:00
patacongo
de18e3272f Add framework for thttpd
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@1975 42af7a65-404d-4744-a932-0658087f49c3
2009-07-11 23:40:17 +00:00
patacongo
4f255b5fdf Add gettimeofday()
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@1974 42af7a65-404d-4744-a932-0658087f49c3
2009-07-11 23:39:33 +00:00
patacongo
631788ece1 mktime/gmtime_r moved and highly simplified
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@1973 42af7a65-404d-4744-a932-0658087f49c3
2009-07-11 17:24:14 +00:00
patacongo
bfd2dc6cd1 Added some pattern matching logic
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@1972 42af7a65-404d-4744-a932-0658087f49c3
2009-07-11 13:59:42 +00:00
patacongo
45659df160 Add reference to NXFLAT interface
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@1971 42af7a65-404d-4744-a932-0658087f49c3
2009-07-11 13:22:41 +00:00
patacongo
57283ed7cb Document binary loadr APIs
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@1970 42af7a65-404d-4744-a932-0658087f49c3
2009-06-27 00:56:39 +00:00
101 changed files with 15722 additions and 598 deletions

View File

@@ -802,7 +802,42 @@
This file has been around for a long time, but I don't think it has
every been used before (i.e., prior to the NXFLAT logic)
0.4.10 2009-xx-xx Gregory Nutt <spudmonkey@racsa.co.cr>
0.4.10 2009-08-08 Gregory Nutt <spudmonkey@racsa.co.cr>
* lib/: Added some basic regex-subset, pattern matching functions
* lib/: Greatly simplified mktime() and gmtime_r(). The Gregorian and
Julian time calculations were interesting, but not necessary in the
typical embeddd system.
* sched/: Added gettimeofday(). This implementation is simply a thin
wrapper around clock_gettimer().
* lib/: Add gmtime(), localtime(), and strftime()
* binfmt/: Add exec(). This is just a wrapper that executes both
load_ and exec_module() in a more familiar manner. It is not consistent
with more standard exec() functions, however, because (1) it returns
and (2) it requires symbol table arguments.
* lib/: Add fileno()
* examples/ostest: Several of the tests used a big, hard-coded stack size
when creating test threads (16Kb stacksize). The stack size should
be controlled by the .config file or the OSTest won't work on platforms
with memory constraints.
* netutils/thttpd: An initial port of Jeff Poskanzer's THTTPD HTTP server.
See http://acme.com/software/thttpd/.
* examples/thttpd: A basic test program for THTTPD
* configs/eagle100/thttpd: A build configuration for THTTPD on the Micromint
Eagle-100 LMS6918 (Cortex-M3) board.
* configs/ntosd-dm320/thttpd: A build configuration for THTTPD on the Neuros
DM320 platform.
* lib/: Added strstr() and strpbrk().
* net/recvfrom.c and net/accept(): Sockets now support some non-blocking
operations, specifically for (1) TCP/IP read operations when read-ahead
buffering is enabled, and (2) TCP/IP accept() operations when TCP/IP
connection backlog is enabled.
* fs/fs_fcntl.c and net/net_vfcntl.c: Minimal support provided for fcntl().
It can, at least, be used to mark sockets as blocking or non-blocking.
* net/net_close.c: Fix bug in close(). If reference count not set to zero
then uip_tcpfree() will assert when DEBUG is enabled.
* net/accept.c: Fix bug in accept(). The logic expected parts of the
return address structure to be initialized or it would return an error.
0.4.11 2009-xx-xx Gregory Nutt <spudmonkey@racsa.co.cr>

View File

@@ -8,7 +8,7 @@
<tr align="center" bgcolor="#e4e4e4">
<td>
<h1><big><font color="#3c34ec"><i>NuttX RTOS</i></font></big></h1>
<p>Last Updated: June 26, 2009</p>
<p>Last Updated: August 8, 2009</p>
</td>
</tr>
</table>
@@ -469,6 +469,16 @@
<li>Networking utilities (DHCP, SMTP, TELNET, TFTP, HTTP)</li>
</p>
</tr>
<tr>
<td><br></td>
<td>
<p>
<li>
A NuttX port of Jeff Poskanzer's <a href="http://acme.com/software/thttpd">THTTPD</a> HTTP server
integrated with <a href="NuttXNxFlat.html">NXFLAT</a> to provide true, embedded CGI.
</li>
</p>
</tr>
<tr>
<td valign="top" width="22"><img height="20" width="20" src="favicon.ico"></td>
@@ -696,8 +706,8 @@
</tr>
</table>
<p><b>nuttx-0.4.9</b>.
This 41<sup>st</sup> release of NuttX (nuttx-0.4.9) was made on June 26, 2009
<p><b>nuttx-0.4.10</b>.
This 42<sup>nd</sup> release of NuttX (nuttx-0.4.10) was made on August 8, 2009
and is available for download from the
<a href="http://sourceforge.net/project/showfiles.php?group_id=189573">SourceForge</a>
website.
@@ -705,18 +715,22 @@
Unreleased changes after this release are available in CVS.
These unreleased changes are listed <a href="#pendingchanges">here</a>.
</p>
This release adds:
The changes in thsi release focus on the port of Jeff Poskanzer's
<a href="http://acme.com/software/thttpd/">THTTPD</a> to NuttX.
Do to limited time to work on NuttX, that port is still not fully functional.
However, numerous related bug-fixes and functional additions for THTTPD were
added:
<ul>
<li>
Support for a new binary format call NXFLAT that can be used to
execute separately linked programs in place in a file system.
See <a href="NuttXNxFlat.html">NXFLAT Documentation</a>
for detailed information.
</li>
<li>
Several important bugs were files related to networking and ROMFS
(see the <a href="#currentrelease">ChangeLog</a> for a complete list).
</li>
<li>Several new standard C-library functions (<code>fileno</code>, <code>strstr</code>,
<code>strpbrk</code>, <code>fcntl</code>).</li>
<li>Improved and extended timing APIs (<code>mktime</code>, <code>gmtime</code>, <code>gmtime_r</code>,
<code>gettimeofday</code>, <code>localtime</code>, <code>localtime_r</code>, and
<code>strftime</code>)</li>
<li>Networking enhancements: <code>recvfrom</code> and <code>accept</code> now work with non-blocking
sockets.</li>
<li><a href="NuttXNxFlat.html">NXFLAT</a> extensions (<code>exec</code>)</li>
<li>Pattern matching logic.</li>
<li>And miscellaneous bug fixes (see the <a href="#currentrelease">ChangeLog</a> for a complete list).</li>
</ul>
</p>
@@ -1422,31 +1436,42 @@ Other memory:
</table>
<pre><ul>
nuttx-0.4.9 2009-06-26 Gregory Nutt &lt;spudmonkey@racsa.co.cr&gt;
nuttx-0.4.10 2009-08-08 Gregory Nutt &lt;spudmonkey@racsa.co.cr&gt;
* Add strtoll() and strtoull(); Add macros for atol() and atoll().
* dup() and dup2() will now clone socket descriptors
* All socket descriptors ar now cloned when when a new task is started
via task_create().
* Use of C++ reserved word 'private' in C header files causes problems
for C++ that include them.
* Added 'binfmt' support to allow execution of programs in a file system,
binding to NuttX symbols. A custom format call NXFLAT is used; this
derives from http://xflat.sourceforge.net. At present is supports on
XIP execution from ROMFS file systems. Initial check-in is untested
and probably breaks many builds.
* examples/lib: Added qsort()
* examples/nxflat: Added support for symbol tables
* Correct logic that creates compiler include paths. On Cygwin, the
include paths for Cygwin-based GCC were being converted to windows
native paths. That causes many problems -- breaking dependencies
for one.
* Fixed an important bug in ROMFS. The initial XIP offset was set
incorrectly so if sector zero was read first, there was a bad read.
I don't know how it worked before.
* arch/arm/src/common/up_use_stack.c. Fixed a fatal stack setup error.
This file has been around for a long time, but I don't think it has
every been used before (i.e., prior to the NXFLAT logic)
* lib/: Added some basic regex-subset, pattern matching functions
* lib/: Greatly simplified mktime() and gmtime_r(). The Gregorian and
Julian time calculations were interesting, but not necessary in the
typical embeddd system.
* sched/: Added gettimeofday(). This implementation is simply a thin
wrapper around clock_gettimer().
* lib/: Add gmtime(), localtime(), and strftime()
* binfmt/: Add exec(). This is just a wrapper that executes both
load_ and exec_module() in a more familiar manner. It is not consistent
with more standard exec() functions, however, because (1) it returns
and (2) it requires symbol table arguments.
* lib/: Add fileno()
* examples/ostest: Several of the tests used a big, hard-coded stack size
when creating test threads (16Kb stacksize). The stack size should
be controlled by the .config file or the OSTest won't work on platforms
with memory constraints.
* netutils/thttpd: An initial port of Jef Poskanzer's THTTPD HTTP server.
See http://acme.com/software/thttpd/.
* examples/thttpd: A basic test program for THTTPD
* configs/eagle100/thttpd: A build configuration for THTTPD on the Micromint
Eagle-100 LMS6918 (Cortex-M3) board.
* configs/ntosd-dm320/thttpd: A build configuration for THTTPD on the Neuros
DM320 platform.
* lib/: Added strstr() and strpbrk().
* net/recvfrom.c and net/accept(): Sockets now support some non-blocking
operations, specifically for (1) TCP/IP read operations when read-ahead
buffering is enabled, and (2) TCP/IP accept() operations when TCP/IP
connection backlog is enabled.
* fs/fs_fcntl.c and net/net_vfcntl.c: Minimal support provided for fcntl().
It can, at least, be used to mark sockets as blocking or non-blocking.
* net/net_close.c: Fix bug in close(). If reference count not set to zero
then uip_tcpfree() will assert when DEBUG is enabled.
* net/accept.c: Fix bug in accept(). The logic expected parts of the
return address structure to be initialized or it would return an error.
pascal-0.1.2 2008-02-10 Gregory Nutt &lt;spudmonkey@racsa.co.cr&gt;
@@ -1475,9 +1500,7 @@ buildroot-0.1.7 2009-06-26 &lt;spudmonkey@racsa.co.cr&gt;
</table>
<pre><ul>
nuttx-0.4.10 2009-xx-xx Gregory Nutt &lt;spudmonkey@racsa.co.cr&gt;
nuttx-0.4.10 2009-xx-xx Gregory Nutt &lt;spudmonkey@racsa.co.cr&gt;
nuttx-0.4.11 2009-xx-xx Gregory Nutt &lt;spudmonkey@racsa.co.cr&gt;
pascal-0.1.3 2009-xx-xx Gregory Nutt &lt;spudmonkey@racsa.co.cr&gt;

View File

@@ -93,6 +93,12 @@
<a href="#making">1.4 Making an NXFLAT module</a>
</td>
</tr>
<tr>
<td valign="top" width="22"><img height="20" width="20" src="favicon.ico"></td>
<td>
<a href="#binfmt">3.0. Binary Loader APIs</a>
</td>
</tr>
<tr>
<td valign="top" width="22"><img height="20" width="20" src="favicon.ico"></td>
<td>
@@ -161,7 +167,7 @@
<p>
NXFLAT is derived from <a href="http://xflat.sourceforge.net/">XFLAT</a>.
XFLAT is a toolchain add that provides full shared library and XIP executable
support for processors that have no Memory Management Unit (MMU).
support for processors that have no Memory Management Unit (MMU<sup>1</sup>).
NXFLAT is greatly simplified for the deeply embedded environment targeted by Nuttx:
</p>
<ul>
@@ -170,13 +176,19 @@
</ul>
<p>
Rather, the NXFLAT module only <i>imports</i> symbol values.
In the NXFLAT model, the (PIC<sup>1</sup>) NXFLAT module resides in a FLASH file system and
In the NXFLAT model, the (PIC<sup>2</sup>) NXFLAT module resides in a FLASH file system and
when it is loaded at run time, it is dynamically linked only to the (non-PIC) base NuttX
code:
The base NuttX <i>exports</i> a symbol table; the NXFLAT module <i>imports</i> those symbol value
to dynamically bind the module to the base code.
</p>
<p><sup>1</sup><small>&quot;Position Independent Code&quot;</small></p>
<ul>
<p>
<sup>1</sup><small>MMU: &quot;Memory Management Unit&quot;</small><br>
<sup>2</sup><small>PIC: &quot;Position Independent Code&quot;</small>
</p>
</ul>
<a name="limitations"><h2>1.3 Limitations</h2></a>
@@ -220,8 +232,8 @@
</ul>
<ul><p>
<sup>1</sup><small>&quot;Memory Management Unit&quot;</small><br>
<sup>2</sup><small>&quot;Position Independent Code&quot;</small><br>
<sup>1</sup><small>MMU: &quot;Memory Management Unit&quot;</small><br>
<sup>2</sup><small>PIC: &quot;Position Independent Code&quot;</small><br>
<sup>3</sup><small>A work around is under consideration:
At run time, the <code>.rodata</code> offsets will be indexed by a RAM address.
If the dynamic loader were to offset those <code>.rodata</code> offsets properly, it
@@ -406,28 +418,187 @@ any following arguments.
</table></ul>
<p><b>Target 1</b>.
This target links all of the object files together into one relocation object.
In this case, there is only a single object file, <code>hello.o</code>, and it is linked to produce <code>hello.r1</code>.
This target links all of the module's object files together into one relocatable object.
Two relocatable objects will be generated; this is the first one (hence, the suffic <code>.r1</code>).
In this &quot;Hello, World!&quot; case, there is only a single object file, <code>hello.o</code>,
that is linked to produce the <code>hello.r1</code> object.
</p>
<p>
When the module's object files are compiled, some special compiler CFLAGS must be provided.
First, the option <code>-fpic</code> is required to tell the compiler to generate position independent code (other
GCC options, like <code>-fno-jump-tables</code> might also be desirable).
For ARM compilers, two additional compilation options are required: <code>-msingle-pic-base</code>
and <code>-mpic-register=r10</code>.
</p>
<p><b>Target 2</b>.
Given <code>hello.r1</code>, this target will invoke <a href="#mknxflat"><code>mknxflat</code></a>
Given the <code>hello.r1</code> relocatable object, this target will invoke
<a href="#mknxflat"><code>mknxflat</code></a>
to make the <i>thunk</i> file, <code>hello-thunk.S</code>.
This <i>thunk</i> contains all of the information needed to create the imported function list.
This <i>thunk</i> file contains all of the information needed to create the imported function list.
</p>
<p><b>Target 3</b>
This this target is similar to <b>Target 1</b>.
In this case, it will link together the object file, <code>hello.o</code> along with the assembled <i>thunk</i> file,
<code>hello-thunk.o</code> to create another, single relocatable object, <code>hello.r2</code>.
This target is similar to <b>Target 1</b>.
In this case, it will link together the module's object files (only <code>hello.o</code> here)
along with the assembled <i>thunk</i> file, <code>hello-thunk.o</code> to create the second relocatable object,
<code>hello.r2</code>.
The linker script, <code>gnu-nxflat.ld</code> is required at this point to correctly position the sections.
This linker script produces two segments:
An <i>I-Space</i> (Instruction Space) segment containing mostly <code>.text</code> and a <i>D-Space</i> (Data Space) segment
containing <code>.got</code>, <code>.data</code>, and <code>.bss</code> sections.
The I-Space section must be origined at address 0 (so that the segment's addresses are really offsets into
the I-Space segment)
and the D-Space section must also be origined at address 0 (so that segment's addresses are really offsets into
the I-Space segment).
The option <code>-no-check-sections</code> is required to prevent the linker from failing because these segments overlap.
</p>
<p><b>Target 4</b>.
Finally, this target will use the <code>hello.r2</code> relocatable object to create the final, NXFLAT module
<code>hello</code> by calling <a href="#ldnxflat"><code>ldnxflat</code></a>.
<code>hello</code> by executing <a href="#ldnxflat"><code>ldnxflat</code></a>.
</p>
<table width ="100%">
<tr bgcolor="#e4e4e4">
<td>
<a name="binfmt"><h1>3.0 Binary Loader APIs</h1></a>
</td>
</tr>
</table>
<p><b>Relevant Header Files:</b></p>
<ul>
<li>
The interface to the binary loader is described in the header file
<a href="http://nuttx.cvs.sourceforge.net/viewvc/nuttx/nuttx/include/nuttx/binfmt.h?revision=1.5&view=markup">
<code>include/nuttx/binfmt.h</code></a>.
A brief summary of the APIs prototyped in that header file are listed below.
</li>
<li>
NXFLAT APIs needed to register NXFLAT as a binary loader appear in the header file
<a href="http://nuttx.cvs.sourceforge.net/viewvc/*checkout*/nuttx/nuttx/include/nuttx/nxflat.h?revision=1.9">
<code>include/nuttx/nxflat.h</code></a>.
</li>
<li>
The format of an NXFLAT object itself is described in the header file:
<a href="http://nuttx.cvs.sourceforge.net/viewvc/*checkout*/nuttx/nuttx/include/nxflat.h?revision=1.12">
<code>include/nxflat.h</code></a>.
</li>
</ul>
<p><b>binfmt Registration</b>
These first interfaces are used only by a binary loader module, such as NXFLAT itself.
NXFLAT (or any future binary loader) calls <code>register_binfmt()</code> to incorporate
itself into the system.
In this way, the binary loader logic is dynamically extensible to support any kind of loader.
Normal application code should not be concerned with these interfaces.
</p>
<ul>
<p><b><code>int register_binfmt(FAR struct binfmt_s *binfmt)</code></b>
<ul>
<p><b>Description:</b>
Register a loader for a binary format
</p>
<p><b>Returned Value:</b>
This is a NuttX internal function so it follows the convention that
0 (<code>OK</code>) is returned on success and a negated errno is returned on
failure.
</p>
</ul>
<p><b><code>int unregister_binfmt(FAR struct binfmt_s *binfmt)</code></b>
<ul>
<p><b>Description:</b>
Register a loader for a binary format
</p>
<p><b>Returned Value:</b>
This is a NuttX internal function so it follows the convention that
0 (<code>OK</code>) is returned on success and a negated errno is returned on
failure.
</p>
</ul>
</ul>
<p><b>NXFLAT Initialization</b>
These interfaces are specific to NXFLAT.
Normally, an application needs only call <code>nxflat_initialize()</code> during its initialization
to have full NXFLAT support.
</p>
<ul>
<p><b><code>int nxflat_initialize(void)</code></b>
<ul>
<p><b>Description:</b>
NXFLAT support is built unconditionally. However, it order to
use this binary format, this function must be called during system
format in order to register the NXFLAT binary format.
This function calls <code>register_binfmt()</code> appropriately.
</p>
<p><b>Returned Value:</b>
This is a NuttX internal function so it follows the convention that
0 (OK) is returned on success and a negated errno is returned on
failure.
</p>
</ul>
<p><b><code>void nxflat_uninitialize(void)</code></b>
<ul>
<p><b>Description:</b>
Unregister the NXFLAT binary loader
</p>
<p><b>Returned Value:</b>
None
</p>
</ul>
</ul>
<p><b>Binary Loader Interfaces</b>.
The remaining APIs are called by user applications to maintain modules in the file system.
</p>
<ul>
<p><b><code>int load_module(FAR struct binary_s *bin)</code></b>
<ul>
<p><b>Description:</b>
Load a module into memory, bind it to an exported symbol take, and
prep the module for execution.
</p>
<p><b>Returned Value:</b>
This is an end-user function, so it follows the normal convention:
Returns 0 (<code>OK</code>) on success. On failure, it returns -1 (<code>ERROR</code>) with
errno set appropriately.
</p>
</ul>
<p><b><code>int unload_module(FAR const struct binary_s *bin)</code></b>
<ul>
<p><b>Description:</b>
Unload a (non-executing) module from memory. If the module has
been started (via <code>exec_module()</code>), calling this will be fatal.
</p>
<p><b>Returned Value:</b>
This is a NuttX internal function so it follows the convention that
0 (<code>OK</code>) is returned on success and a negated errno is returned on
failure.
</p>
</ul>
<p><b><code>int exec_module(FAR const struct binary_s *bin, int priority)</code></b>
<ul>
<p><b>Description:</b>
Execute a module that has been loaded into memory by load_module().
</p>
<p><b>Returned Value:</b>
This is an end-user function, so it follows the normal convention:
Returns the PID of the exec'ed module. On failure, it.returns
-1 (<code>ERROR</code>) and sets errno appropriately.
</p>
</ul>
</ul>
<table width ="100%">
<tr bgcolor="#e4e4e4">
<td>
@@ -438,7 +609,7 @@ any following arguments.
<p>
When GCC generate position independent code, new code sections will appear in your programs.
One of these the the GOT (Global Offset Table) and, in ELF environments, the PLT (Procedure
One of these is the GOT (Global Offset Table) and, in ELF environments, another is the PLT (Procedure
Lookup Table.
For example, if your C code generated (ARM) assembly language like this without PIC:
<p>

View File

@@ -12,7 +12,7 @@
<h1><big><font color="#3c34ec">
<i>NuttX RTOS Porting Guide</i>
</font></big></h1>
<p>Last Updated: June 18, 2009</p>
<p>Last Updated: July 18, 2009</p>
</td>
</tr>
</table>
@@ -2054,7 +2054,14 @@ extern void up_ledoff(int led);
Used to initialize the internal time logic.
</li>
<li>
<code>CONFIG_JULIAN_TIME</code>: Enables Julian time conversions
<code>CONFIG_GREGORIAN_TIME</code>: Enables Gregorian time conversions.
You would only need this if you are concerned about accurate time conversions in
the recent past or in the distant future.
</li>
<li>
<code>CONFIG_JULIAN_TIME</code>: Enables Julian time conversions.
You would only need this if you are concerned about accurate time conversion in the distand past.
You must also define <code>CONFIG_GREGORIAN_TIME</code> in order to use Julian time.
</li>
<li>
<code>CONFIG_DEV_CONSOLE</code>: Set if architecture-specific logic
@@ -2340,6 +2347,113 @@ extern void up_ledoff(int led);
</li>
</ul>
<h3>THTTPD</h3>
<ul>
<li>
<code>CONFIG_THTTPD_PORT</code>: THTTPD Server port number
</li>
<li>
<code>CONFIG_THTTPD_IPADDR</code>: Server IP address (no host name)
</li>
<li>
<code>CONFIG_THTTPD_SERVER_ADDRESS</code>: SERVER_ADDRESS: response
</li>
<li>
<code>CONFIG_THTTPD_SERVER_SOFTWARE</code>: SERVER_SOFTWARE: response
</li>
<li>
<code>CONFIG_THTTPD_CGI_PATH</code>:
</li>
<li>
<code>CONFIG_THTTPD_CGI_PATTERN</code>: Only CGI programs matching this
pattern will be executed. In fact, if this value is not defined
then no CGI logic will be built.
</li>
<li>
<code>CONFIG_THTTPD_CGI_PRIORITY</code>: Provides the priority of CGI child tasks
</li>
<li>
<code>CONFIG_THTTPD_CGI_STACKSIZE</code>: Provides the initial stack size of
CGI child task (will be overridden by the stack size in the NXFLAT
header)
</li>
<li>
<code>CONFIG_THTTPD_CGI_BYTECOUNT</code>: Byte output limit for CGI tasks.
</li>
<li>
<code>CONFIG_THTTPD_CGI_TIMELIMIT</code>: How many seconds to allow CGI programs
to run before killing them.
</li>
<li>
<code>CONFIG_THTTPD_CHARSET- The default character set name to use with
text MIME types.
</li>
<li>
<code>CONFIG_THTTPD_IOBUFFERSIZE</code>:
</li>
<li>
<code>CONFIG_THTTPD_INDEX_NAMES</code>: A list of index filenames to check. The
files are searched for in this order.
</li>
<li>
<code>CONFIG_AUTH_FILE</code>: The file to use for authentication. If this is
defined then thttpd checks for this file in the local directory
before every fetch. If the file exists then authentication is done,
otherwise the fetch proceeds as usual. If you leave this undefined
then thttpd will not implement authentication at all and will not
check for auth files, which saves a bit of CPU time. A typical
value is &quot;.htpasswd&quout;
</li>
<li>
<code>CONFIG_THTTPD_LISTEN_BACKLOG</code>: The listen() backlog queue length.
</li>
<li>
<code>CONFIG_THTTPD_LINGER_MSEC</code>: How many milliseconds to leave a connection
open while doing a lingering close.
</li>
<li>
<code>CONFIG_THTTPD_OCCASIONAL_MSEC</code>: How often to run the occasional
cleanup job.
</li>
<li>
<code>CONFIG_THTTPD_IDLE_READ_LIMIT_SEC</code>: How many seconds to allow for
reading the initial request on a new connection.
</li>
<li>
<code>CONFIG_THTTPD_IDLE_SEND_LIMIT_SEC</code>: How many seconds before an
idle connection gets closed.
</li>
<li>
<code>CONFIG_THTTPD_TILDE_MAP1 and CONFIG_THTTPD_TILDE_MAP2</code>: Tilde mapping.
Many URLs use ~username to indicate a user's home directory. thttpd
provides two options for mapping this construct to an actual filename.
<ol>
<li>
Map ~username to &lt;prefix&gt;/username. This is the recommended choice.
Each user gets a subdirectory in the main web tree, and the tilde
construct points there. The prefix could be something like "users",
or it could be empty.
</li>
<li>
Map ~username to &lt;user's homedir&gt;/&lt;postfix&gt;. The postfix would be
the name of a subdirectory off of the user's actual home dir,
something like &quot;public_html&quot;.
</li>
</ol>
You can also leave both options undefined, and thttpd will not do
anything special about tildes. Enabling both options is an error.
Typical values, if they're defined, are &quot;users&quot; for
CONFIG_THTTPD_TILDE_MAP1 and &quot;public_html&quot; forCONFIG_THTTPD_TILDE_MAP2.
</li>
<li>
<code>CONFIG_THTTPD_GENERATE_INDICES
</li>
<li>
<code>CONFIG_THTTPD_URLPATTERN</code>: If defined, then it will be used to match
and verify referrers.
</li>
</ul>
<h2>USB Device-Side Support</h2>
<h3>USB Device Controller Driver</h3>
<ul>

View File

@@ -183,7 +183,12 @@ paragraphs.
thread. In this case, file operations will have effect only all pthreads the
were started from the same parent thread.
</p>
<p>
<p><b>Executing Programs within a File System</b>.
NuttX also provides internal interfaces for the execution of separately built
programs that reside in a file system.
These internal interfaces are, however, non-standard and are documented
<a href="NuttXNxFlat.html#binfmt">elsewhere</a>.
<p><b>Task Control Interfaces</b>.
The following task control interfaces are provided by NuttX:
</p>
<ul>
@@ -2457,13 +2462,16 @@ VxWorks provides the following comparable interface:
<li><a href="#clockgettime">2.7.2 clock_gettime</a></li>
<li><a href="#clockgetres">2.7.3 clock_getres</a></li>
<li><a href="#mktime">2.7.4 mktime</a></li>
<li><a href="#gmtimer">2.7.5 gmtime_r</a></li>
<li><a href="#localtimer">2.7.6 localtime_r</a></li>
<li><a href="#timercreate">2.7.7 timer_create</a></li>
<li><a href="#timerdelete">2.7.8 timer_delete</a></li>
<li><a href="#timersettime">2.7.9 timer_settime</a></li>
<li><a href="#timergettime">2.7.10 timer_gettime</a></li>
<li><a href="#timergetoverrun">2.7.11 timer_getoverrun</a></li>
<li><a href="#gmtime">2.7.5 gmtime</a></li>
<li><a href="#localtime">2.7.6 localtime</a></li>
<li><a href="#gmtimer">2.7.7 gmtime_r</a></li>
<li><a href="#localtimer">2.7.8 localtime_r</a></li>
<li><a href="#timercreate">2.7.9 timer_create</a></li>
<li><a href="#timerdelete">2.7.10 timer_delete</a></li>
<li><a href="#timersettime">2.7.11 timer_settime</a></li>
<li><a href="#timergettime">2.7.12 timer_gettime</a></li>
<li><a href="#timergetoverrun">2.7.13 timer_getoverrun</a></li>
<li><a href="#gettimeofday">2.7.14 gettimeofday</a></li>
</ul>
<H3><a name="clocksettime">2.7.1 clock_settime</a></H3>
@@ -2578,7 +2586,46 @@ VxWorks provides the following comparable interface:
<li><code>To be provided</code>.</li>
</ul>
<H3><a name="gmtimer">2.7.5 gmtime_r</a></H3>
<H3><a name="gmtime">2.7.5 gmtime</a></H3>
<p>
<b>Function Prototype:</b>
</p>
<pre>
#include &lt;time.h&gt;
struct tm *gmtime(const time_t *clock);
</pre>
<p>
<b>Description:</b>
</p>
<p>
<b>Input Parameters:</b>
</p>
<ul>
<li><code>clock</code>.
Represents calendar time.
This is an absolute time value representing the number of seconds elapsed since 00:00:00
on January 1, 1970, Coordinated Universal Time (UTC).
</li>
</ul>
<p>
<b>Returned Values:</b>
</p>
<p>
If successful, the <I>gmtime()</I> function will return the pointer to a statically
defined instance of <code>struct tim</code>.
Otherwise, a NULL will be returned to indicate the error:
</p>
<ul>
<li><code>To be provided</code>.</li>
</ul>
<H3><a name="localtime">2.7.6 localtime</a></H3>
<pre>
#include &lt;time.h&gt;
#define localtime(c) gmtime(c)
</pre>
<H3><a name="gmtimer">2.7.7 gmtime_r</a></H3>
<p>
<b>Function Prototype:</b>
</p>
@@ -2593,26 +2640,32 @@ VxWorks provides the following comparable interface:
<b>Input Parameters:</b>
</p>
<ul>
<li><code>parm</code>. </li>
<li><code>clock</code>.
Represents calendar time.
This is an absolute time value representing the number of seconds elapsed since 00:00:00
on January 1, 1970, Coordinated Universal Time (UTC).
<li><code>result</code>.
A user-provided buffer to receive the converted time structure.
</ul>
<p>
<b>Returned Values:</b>
</p>
<p>
If successful, the <I>gmtime_r()</I> function will return zero (<I>OK</I>).
Otherwise, an non-zero error number will be returned to indicate the error:
If successful, the <I>gmtime_r()</I> function will return the pointer, <code>result</code>,
provided by the caller.
Otherwise, a NULL will be returned to indicate the error:
</p>
<ul>
<li><code>To be provided</code>.</li>
</ul>
<H3><a name="localtimer">2.7.6 localtime_r</a></H3>
<H3><a name="localtimer">2.7.8 localtime_r</a></H3>
<pre>
#include &lt;time.h&gt;
#define localtime_r(c,r) gmtime_r(c,r)
</pre>
<H3><a name="timercreate">2.7.7 timer_create</a></H3>
<H3><a name="timercreate">2.7.9 timer_create</a></H3>
<p>
<b>Function Prototype:</b>
</p>
@@ -2682,7 +2735,7 @@ VxWorks provides the following comparable interface:
<li>Only <code>CLOCK_REALTIME</code> is supported for the <code>clockid</code> argument.</li>
</ul>
<H3><a name="timerdelete">2.7.8 timer_delete</a></H3>
<H3><a name="timerdelete">2.7.10 timer_delete</a></H3>
<p>
<b>Function Prototype:</b>
</p>
@@ -2721,7 +2774,7 @@ VxWorks provides the following comparable interface:
Comparable to the POSIX interface of the same name.
</p>
<H3><a name="timersettime">2.7.9 timer_settime</a></H3>
<H3><a name="timersettime">2.7.11 timer_settime</a></H3>
<p>
<b>Function Prototype:</b>
</p>
@@ -2804,7 +2857,7 @@ VxWorks provides the following comparable interface:
<li>The <code>ovalue</code> argument is ignored.</li>
</ul>
<H3><a name="timergettime">2.7.10 timer_gettime</a></H3>
<H3><a name="timergettime">2.7.12 timer_gettime</a></H3>
<p>
<b>Function Prototype:</b>
</p>
@@ -2851,7 +2904,7 @@ VxWorks provides the following comparable interface:
Comparable to the POSIX interface of the same name.
</p>
<H3><a name="timergetoverrun">2.7.11 timer_getoverrun</a></H3>
<H3><a name="timergetoverrun">2.7.13 timer_getoverrun</a></H3>
<p>
<b>Function Prototype:</b>
</p>
@@ -2912,6 +2965,33 @@ VxWorks provides the following comparable interface:
interface of the same name.
</p>
<h3><a name="gettimeofday">2.7.14 gettimeofday</a></h3>
<p>
<b>Function Prototype:</b>
</p>
<pre>
#include &lt;sys/time.h&gt;
int gettimeofday(struct timeval *tp, void *tzp);
</pre>
<p>
<b>Description:</b>
This implementation of <code>gettimeofday()</code> is simply a thin wrapper around
<a href="#clockgettime"><code>clock_gettime()</code></a>.
It simply calls <code>clock_gettime()</code> using the <code>CLOCK_REALTIME</code> timer and
converts the result to the required <code>struct timeval</code>.
</p>
<p>
<b>Input Parameters:</b>
</p>
<ul>
<li><code>tp</code>. The current time will be returned to this user provided location.</li>
<li><code>tzp</code>. A reference to the timezone -- <i>IGNORED</i>.</li>
</ul>
<p>
<b>Returned Values:</b>
See <a href="#clockgettime"><code>clock_gettime()</code></a>.
</p>
<table width ="100%">
<tr bgcolor="#e4e4e4">
<td>
@@ -6008,10 +6088,12 @@ interface of the same name.
<li><a href="#FileSystemOverview">2.11.1 NuttX File System Overview</a></li>
<li><a href="#driveroperations">2.11.2 Driver Operations</a></li>
<li><a href="#directoryoperations">2.11.3 Directory Operations</a></li>
<li><a href="#standardio">2.11.4 Standard I/O</a></li>
<li><a href="#PipesNFifos">2.11.5 Pipes and FIFOs</a></li>
<li><a href="#fatsupport">2.11.6 FAT File System Support</a></li>
<li><a href="#mmapxip">2.11.7 <code>mmap()</code> and eXecute In Place (XIP)</a></li>
<li><a href="#dirunistdops">2.11.4 UNIX Standard Operations</a></li>
<li><a href="#standardio">2.11.5 Standard I/O</a></li>
<li><a href="#stdstrings">2.11.6 Standard String Operations</a></li>
<li><a href="#PipesNFifos">2.11.7 Pipes and FIFOs</a></li>
<li><a href="#fatsupport">2.11.8 FAT File System Support</a></li>
<li><a href="#mmapxip">2.11.9 <code>mmap()</code> and eXecute In Place (XIP)</a></li>
</ul>
<h3><a name="FileSystemOverview">2.11.1 NuttX File System Overview</a></h3>
@@ -6230,66 +6312,132 @@ interface of the same name.
<h3><a name="directoryoperations">2.11.3 Directory Operations</a></h3>
<a name="dirdirentops">
<ul><pre>
#include &lt;dirent.h&gt;
int closedir(DIR *dirp);
FAR DIR *opendir(const char *path);
FAR struct dirent *readdir(FAR DIR *dirp);
int readdir_r(FAR DIR *dirp, FAR struct dirent *entry, FAR struct dirent **result);
void rewinddir(FAR DIR *dirp);
void seekdir(FAR DIR *dirp, int loc);
int telldir(FAR DIR *dirp);
#include &lt;dirent.h&gt;
int closedir(DIR *dirp);
FAR DIR *opendir(const char *path);
FAR struct dirent *readdir(FAR DIR *dirp);
int readdir_r(FAR DIR *dirp, FAR struct dirent *entry, FAR struct dirent **result);
void rewinddir(FAR DIR *dirp);
void seekdir(FAR DIR *dirp, int loc);
int telldir(FAR DIR *dirp);
</pre></ul>
</a>
<a name="dirunistdops">
<h3><a name="dirunistdops">2.11.4 UNIX Standard Operations</a></h3>
<ul><pre>
#include &lt;unistd.h&gt;
int chdir(FAR const char *path);
FAR char *getcwd(FAR char *buf, size_t size);
#include &lt;unistd.h&gt;
pid_t getpid(void);
void _exit(int status) noreturn_function;
unsigned int sleep(unsigned int seconds);
void usleep(unsigned long usec);
int close(int fd);
int dup(int fd);
int dup2(int fd1, int fd2);
int fsync(int fd);
off_t lseek(int fd, off_t offset, int whence);
ssize_t read(int fd, FAR void *buf, size_t nbytes);
ssize_t write(int fd, FAR const void *buf, size_t nbytes);
int pipe(int filedes[2]);
int chdir(FAR const char *path);
FAR char *getcwd(FAR char *buf, size_t size);
int unlink(FAR const char *pathname);
int rmdir(FAR const char *pathname);
int getopt(int argc, FAR char *const argv[], FAR const char *optstring);
</pre></ul>
</a>
<h3><a name="standardio">2.11.4 Standard I/O</a></h3>
<h3><a name="standardio">2.11.5 Standard I/O</a></h3>
<ul><pre>
#include &lt;stdio.h&gt;
int fclose(FILE *stream);
int fflush(FILE *stream);
int feof(FILE *stream); /* Prototyped but not implemented */
int ferror(FILE *stream); /* Prototyped but not implemented */
int fgetc(FILE *stream);
int fgetpos(FILE *stream, fpos_t *pos);
char *fgets(char *s, int n, FILE *stream);
FILE *fopen(const char *path, const char *type);
int fprintf(FILE *stream, const char *format, ...);
int fputc(int c, FILE *stream);
int fputs(const char *s, FILE *stream);
size_t fread(void *ptr, size_t size, size_t n_items, FILE *stream);
int fseek(FILE *stream, long int offset, int whence);
int fsetpos(FILE *stream, fpos_t *pos);
long ftell(FILE *stream);
size_t fwrite(const void *ptr, size_t size, size_t n_items, FILE *stream);
char *gets(char *s);
#include &lt;stdio.h&gt;
int printf(const char *format, ...);
int puts(const char *s);
int rename(const char *source, const char *target);
int sprintf(char *dest, const char *format, ...);
int ungetc(int c, FILE *stream);
int vprintf(const char *s, va_list ap);
int vfprintf(FILE *stream, const char *s, va_list ap);
int vsprintf(char *buf, const char *s, va_list ap);
int fclose(FILE *stream);
int fflush(FILE *stream);
FILE *fdopen(int fd, const char *type);
int feof(FILE *stream); /* Prototyped but not implemented */
int ferror(FILE *stream); /* Prototyped but not implemented */
int fileno(FAR FILE *stream);
int fgetc(FILE *stream);
int fgetpos(FILE *stream, fpos_t *pos);
char *fgets(char *s, int n, FILE *stream);
FILE *fopen(const char *path, const char *type);
int fprintf(FILE *stream, const char *format, ...);
int fputc(int c, FILE *stream);
int fputs(const char *s, FILE *stream);
size_t fread(void *ptr, size_t size, size_t n_items, FILE *stream);
int fseek(FILE *stream, long int offset, int whence);
int fsetpos(FILE *stream, fpos_t *pos);
long ftell(FILE *stream);
size_t fwrite(const void *ptr, size_t size, size_t n_items, FILE *stream);
char *gets(char *s);
FILE *fdopen(int fd, const char *type);
int fstat(int fd, FAR struct stat *buf); /* Prototyped but not implemented */
int mkdir(const char *path, mode_t mode);
int rmdir(const char *path);
int stat(const char *path, FAR struct stat *buf);
int statfs(const char *path, FAR struct statfs *buf); /* Prototyped but not implemented */
int printf(const char *format, ...);
int puts(const char *s);
int rename(const char *source, const char *target);
int snprintf(FAR char *buf, size_t size, const char *format, ...);
int sprintf(char *dest, const char *format, ...);
int sscanf(const char *buf, const char *fmt, ...);
int ungetc(int c, FILE *stream);
int vprintf(const char *s, va_list ap);
int vfprintf(FILE *stream, const char *s, va_list ap);
int vsnprintf(FAR char *buf, size_t size, const char *format, va_list ap);
int vsscanf(char *buf, const char *s, va_list ap);
int vsprintf(char *buf, const char *s, va_list ap);
#include &lt;sys/stat.h&gt;
int mkdir(FAR const char *pathname, mode_t mode);
int mkfifo(FAR const char *pathname, mode_t mode);
int stat(const char *path, FAR struct stat *buf);
int fstat(int fd, FAR struct stat *buf);
#include &lt;sys/statfs.h&gt;
int statfs(const char *path, struct statfs *buf);
int fstatfs(int fd, struct statfs *buf);
</pre></ul>
<h3><a name="PipesNFifos">2.11.5 Pipes and FIFOs</a></h3>
<h3><a name="stdstrings">2.11.6 Standard String Operations</a></h3>
<ul><pre>
#include &lt;string.h&gt;
<h3>2.11.5.1 <a name="pipe"><code>pipe</code></a></h3>
char *strchr(const char *s, int c);
FAR char *strdup(const char *s);
const char *strerror(int);
size_t strlen(const char *);
char *strcat(char *, const char *);
char *strncat(char *, const char *, size_t);
int strcmp(const char *, const char *);
int strncmp(const char *, const char *, size_t);
int strcasecmp(const char *, const char *);
int strncasecmp(const char *, const char *, size_t);
char *strcpy(char *dest, const char *src);
char *strncpy(char *, const char *, size_t);
char *strpbrk(const char *, const char *);
char *strchr(const char *, int);
char *strrchr(const char *, int);
size_t strspn(const char *, const char *);
size_t strcspn(const char *, const char *);
char *strstr(const char *, const char *);
char *strtok(char *, const char *);
char *strtok_r(char *, const char *, char **);
void *memset(void *s, int c, size_t n);
void *memcpy(void *dest, const void *src, size_t n);
int memcmp(const void *s1, const void *s2, size_t n);
void *memmove(void *dest, const void *src, size_t count);
# define bzero(s,n) (void)memset(s,0,n)
</pre></ul>
<h3><a name="PipesNFifos">2.11.7 Pipes and FIFOs</a></h3>
<h3>2.11.7.1 <a name="pipe"><code>pipe</code></a></h3>
<p>
<b>Function Prototype:</b>
</p>
@@ -6323,7 +6471,7 @@ interface of the same name.
</ul>
</p>
<h3>2.11.5.2 <a name="mkfifo"><code>mkfifo</code></a></h3>
<h3>2.11.7.2 <a name="mkfifo"><code>mkfifo</code></a></h3>
<p>
<b>Function Prototype:</b>
</p>
@@ -6370,8 +6518,8 @@ interface of the same name.
</ul>
</p>
<h3><a name="fatsupport">2.11.6 FAT File System Support</a></h3>
<h3>2.11.6.1 <a name="mkfatfs"><code>mkfatfs</code></a></h3>
<h3><a name="fatsupport">2.11.8 FAT File System Support</a></h3>
<h3>2.11.8.1 <a name="mkfatfs"><code>mkfatfs</code></a></h3>
<p>
<b>Function Prototype:</b>
</p>
@@ -6448,7 +6596,7 @@ struct fat_format_s
</ul>
</p>
<h3><a name="mmapxip">2.11.7 <code>mmap()</code> and eXecute In Place (XIP)</a></h3>
<h3><a name="mmapxip">2.11.9 <code>mmap()</code> and eXecute In Place (XIP)</a></h3>
<p>
NuttX operates in a flat open address space.
Therefore, it generally does not require <code>mmap()</code> functionality.
@@ -6471,7 +6619,7 @@ struct fat_format_s
</ol>
</p>
<h3><a name="mmap">2.11.7.1 <code>mmap</code></a></h3>
<h3><a name="mmap">2.11.9.1 <code>mmap</code></a></h3>
<p>
<b>Function Prototype:</b>
</p>
@@ -7520,6 +7668,7 @@ notify a task when a message is available on a queue.
<li><a href="#getpid">getpid</a></li>
<li><a href="#standardio">gets</a></li>
<li><a href="#getsockopt">getsockopt</a></li>
<li><a href="#gmtime">gmtime</a></li>
<li><a href="#gmtimer">gmtime_r</a></li>
<li><a href="#Introduction">Introduction</a>
<li><a href="#drvrioctlops">ioctl</a></li>

View File

@@ -116,7 +116,7 @@ endif
# Add libraries for network support
ifeq ($(CONFIG_NET),y)
LINKLIBS += net/libnet$(LIBEXT) netutils/libnetutils$(LIBEXT)
LINKLIBS += net/libnet$(LIBEXT) netutils/libnetutils$(LIBEXT)
endif
# Add libraries for file system support

View File

@@ -937,3 +937,24 @@ This is the 41st release of NuttX. This release adds:
This tarball contains a complete CVS snapshot from June 26, 2009.
nuttx-0.4.10
^^^^^^^^^^^
This is the 42nd release of NuttX. This released focused on the port of Jeff
Poskanzer's THTTPD HTTP server (see http://acme.com/software/thttpd/.). As of
the 0.4.10 release, that port is still not fully complete and functional.
However, numerous related bug-fixes and functional additions for THTTPD were
added:
* Several new standard C-library functions (fileno, strstr, strpbrk, fcntl).
* Improved and extended timing APIs (mktime, gmtime, gmtime_r, gettimeofday,
localtime, localtime_r, and strftime)
* Networking enhancements: recvfrom and accept now work with non-blocking
sockets.
* NXFLAT extensions (exec)
* Pattern matching logic.
* And miscellaneous bug fixes (see the ChangeLog for details).
This tarball contains a complete CVS snapshot from August 8, 2009.

22
TODO
View File

@@ -1,4 +1,4 @@
NuttX TODO List (Last updated June 26, 2009)
NuttX TODO List (Last updated August 8, 2009)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
(5) Task/Scheduler (sched/)
@@ -7,13 +7,13 @@ NuttX TODO List (Last updated June 26, 2009)
(1) pthreads (sched/)
(1) C++ Support
(5) Binary loaders (binfmt/)
(12) Network (net/, netutils/)
(15) Network (net/, netutils/)
(1) USB (drivers/usbdev)
(4) Libraries (lib/)
(8) File system/Generic drivers (fs/, drivers/)
(2) Graphics subystem (graphics/)
(1) Pascal add-on (pcode/)
(2) Documentation (Documentation/)
(1) Documentation (Documentation/)
(6) Build system / Toolchains
(3) NuttShell (NSH) (examples/nsh)
(3) Other Applications & Tests (examples/)
@@ -234,6 +234,18 @@ o Network (net/, netutils/)
Status: Open, depends on UDP read-ahead support
Priority: Medium
Description: sockets do not support all modes except for O_NONBLOCK. Sockets
support only (1) TCP/IP non-blocking read operations when read-ahead
buffering is enabled, and (2) TCP/IP accept() operations when TCP/IP
connection backlog is enabled.
Status: Open
Priority: Low.
Description: THTTPD is included in the source tree, but has not yet been fully
integrated.
Status: Open
Priority: High
o USB (drivers/usbdev)
^^^^^^^^^^^^^^^^^^^^
@@ -359,10 +371,6 @@ o Documentation (Documentation/)
Status: Open
Priority: Low
Description: Need to document binary loader APIs
Status: Open
Priority: Low
o Build system
^^^^^^^^^^^^

View File

@@ -1,7 +1,7 @@
/********************************************************************************
* arch/arm/src/lpc214x/lpc214x_decodeirq.c
*
* Copyright (C) 2007, 2008 Gregory Nutt. All rights reserved.
* Copyright (C) 2007-2009 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
*
* Redistribution and use in source and binary forms, with or without
@@ -162,7 +162,7 @@ static void lpc214x_decodeirq( uint32 *regs)
#ifdef CONFIG_VECTORED_INTERRUPTS
void up_decodeirq(uint32 *regs)
{
vic_vector_t vector = (vic_vector)vic_getreg(LPC214X_VIC_VECTADDR_OFFSET);
vic_vector_t vector = (vic_vector_t)vic_getreg(LPC214X_VIC_VECTADDR_OFFSET);
vector(regs);
}
#endif

View File

@@ -48,11 +48,11 @@ endif
BINFMT_ASRCS =
BINFMT_CSRCS = binfmt_globals.c binfmt_register.c binfmt_unregister.c \
binfmt_loadmodule.c binfmt_unloadmodule.c binfmt_execmodule.c \
binfmt_dumpmodule.c
binfmt_exec.c binfmt_dumpmodule.c
SYMTAB_ASRCS =
SYMTAB_CSRCS = symtab_findbyname.c symtab_findbyvalue.c \
symtab_findorderedbyname.c symtab_findorderedbyvalue.c
symtab_findorderedbyname.c symtab_findorderedbyvalue.c
SUBDIRS = libnxflat

124
binfmt/binfmt_exec.c Normal file
View File

@@ -0,0 +1,124 @@
/****************************************************************************
* binfmt/binfmt_exec.c
*
* Copyright (C) 2009 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
* 3. Neither the name NuttX nor the names of its contributors may be
* used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
****************************************************************************/
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include <sys/types.h>
#include <string.h>
#include <sched.h>
#include <debug.h>
#include <errno.h>
#include <nuttx/binfmt.h>
#include "binfmt_internal.h"
#ifndef CONFIG_BINFMT_DISABLE
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
/****************************************************************************
* Private Function Prototypes
****************************************************************************/
/****************************************************************************
* Private Data
****************************************************************************/
/****************************************************************************
* Private Functions
****************************************************************************/
/****************************************************************************
* Public Functions
****************************************************************************/
/****************************************************************************
* Name: exec
*
* Description:
* This is a convenience function that wraps load_ and exec_module into
* one call.
*
* Input Parameter:
* filename - Fulll path to the binary to be loaded
* argv - Argument list
* exports - Table of exported symbols
* nexports - The number of symbols in exports
*
* Returned Value:
* This is an end-user function, so it follows the normal convention:
* Returns the PID of the exec'ed module. On failure, it.returns
* -1 (ERROR) and sets errno appropriately.
*
****************************************************************************/
int exec(FAR const char *filename, FAR const char **argv,
FAR const struct symtab_s *exports, int nexports)
{
struct binary_s bin;
int ret;
memset(&bin, 0, sizeof(struct binary_s));
bin.filename = filename;
bin.exports = exports;
bin.nexports = nexports;
ret = load_module(&bin);
if (ret < 0)
{
bdbg("ERROR: Failed to load program '%s'\n", filename);
return ERROR;
}
ret = exec_module(&bin, 50);
if (ret < 0)
{
bdbg("ERROR: Failed to execute program '%s'\n", filename);
unload_module(&bin);
return ERROR;
}
return ret;
}
#endif /* CONFIG_BINFMT_DISABLE */

View File

@@ -194,7 +194,13 @@ defconfig -- This is a configuration file similar to the Linux
instrumentation is selected. Set to zero to disable.
CONFIG_START_YEAR, CONFIG_START_MONTH, CONFIG_START_DAY -
Used to initialize the internal time logic.
CONFIG_JULIAN_TIME - Enables Julian time conversions
CONFIG_GREGORIAN_TIME - Enables Gregorian time conversions.
You would only need this if you are concerned about accurate
time conversions in the past or in the distant future.
CONFIG_JULIAN_TIME - Enables Julian time conversions. You
would only need this if you are concerned about accurate
time conversion in the distand past. You must also define
CONFIG_GREGORIAN_TIME in order to use Julian time.
CONFIG_DEV_CONSOLE - Set if architecture-specific logic
provides /dev/console. Enables stdout, stderr, stdin.
CONFIG_MUTEX_TYPES - Set to enable support for recursive and
@@ -347,6 +353,61 @@ defconfig -- This is a configuration file similar to the Linux
CONFIG_NET_DHCP_LIGHT - Reduces size of DHCP
CONFIG_NET_RESOLV_ENTRIES - Number of resolver entries
THTTPD:
CONFIG_THTTPD_PORT - THTTPD Server port number
CONFIG_THTTPD_IPADDR - Server IP address (no host name)
CONFIG_THTTPD_SERVER_ADDRESS - SERVER_ADDRESS: response
CONFIG_THTTPD_SERVER_SOFTWARE - SERVER_SOFTWARE: response
CONFIG_THTTPD_CGI_PATH -
CONFIG_THTTPD_CGI_PATTERN - Only CGI programs matching this
pattern will be executed. In fact, if this value is not defined
then no CGI logic will be built.
CONFIG_THTTPD_CGI_PRIORITY - Provides the priority of CGI child tasks
CONFIG_THTTPD_CGI_STACKSIZE - Provides the initial stack size of
CGI child task (will be overridden by the stack size in the NXFLAT
header)
CONFIG_THTTPD_CGI_BYTECOUNT - Byte output limit for CGI tasks.
CONFIG_THTTPD_CGI_TIMELIMIT - How many seconds to allow CGI programs
to run before killing them.
CONFIG_THTTPD_CHARSET- The default character set name to use with
text MIME types.
CONFIG_THTTPD_IOBUFFERSIZE -
CONFIG_THTTPD_INDEX_NAMES - A list of index filenames to check. The
files are searched for in this order.
CONFIG_AUTH_FILE - The file to use for authentication. If this is
defined then thttpd checks for this file in the local directory
before every fetch. If the file exists then authentication is done,
otherwise the fetch proceeds as usual. If you leave this undefined
then thttpd will not implement authentication at all and will not
check for auth files, which saves a bit of CPU time. A typical
value is ".htpasswd"
CONFIG_THTTPD_LISTEN_BACKLOG - The listen() backlog queue length.
CONFIG_THTTPD_LINGER_MSEC - How many milliseconds to leave a connection
open while doing a lingering close.
CONFIG_THTTPD_OCCASIONAL_MSEC - How often to run the occasional
cleanup job.
CONFIG_THTTPD_IDLE_READ_LIMIT_SEC - How many seconds to allow for
reading the initial request on a new connection.
CONFIG_THTTPD_IDLE_SEND_LIMIT_SEC - How many seconds before an
idle connection gets closed.
CONFIG_THTTPD_TILDE_MAP1 and CONFIG_THTTPD_TILDE_MAP2 - Tilde mapping.
Many URLs use ~username to indicate a user's home directory. thttpd
provides two options for mapping this construct to an actual filename.
1) Map ~username to <prefix>/username. This is the recommended choice.
Each user gets a subdirectory in the main web tree, and the tilde
construct points there. The prefix could be something like "users",
or it could be empty.
2) Map ~username to <user's homedir>/<postfix>. The postfix would be
the name of a subdirectory off of the user's actual home dir,
something like "public_html".
You can also leave both options undefined, and thttpd will not do
anything special about tildes. Enabling both options is an error.
Typical values, if they're defined, are "users" for
CONFIG_THTTPD_TILDE_MAP1 and "public_html"forCONFIG_THTTPD_TILDE_MAP2.
CONFIG_THTTPD_GENERATE_INDICES
CONFIG_THTTPD_URLPATTERN - If defined, then it will be used to match
and verify referrers.
USB device controller driver
CONFIG_USBDEV - Enables USB device support
CONFIG_USBDEV_ISOCHRONOUS - Build in extra support for isochronous

View File

@@ -0,0 +1,151 @@
############################################################################
# configs/eagle100/thttpd/Make.defs
#
# Copyright (C) 2009 Gregory Nutt. All rights reserved.
# Author: Gregory Nutt <spudmonkey@racsa.co.cr>
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
#
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in
# the documentation and/or other materials provided with the
# distribution.
# 3. Neither the name NuttX nor the names of its contributors may be
# used to endorse or promote products derived from this software
# without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
#
############################################################################
include ${TOPDIR}/.config
# The default value for CROSSDEV can be overridden from the make command line:
# make -- Will build for the devkitARM toolchain
# make CROSSDEV=arm-eabi- -- Will build for the devkitARM toolchain
# make CROSSDEV=arm-none-eabi- -- Will build for the CodeSourcery toolchain
# make CROSSDEV=arm-elf- -- Will build for the NuttX buildroot toolchain
CROSSDEV = arm-eabi-
CC = $(CROSSDEV)gcc
CXX = $(CROSSDEV)g++
CPP = $(CROSSDEV)gcc -E
LD = $(CROSSDEV)ld
AR = $(CROSSDEV)ar rcs
NM = $(CROSSDEV)nm
OBJCOPY = $(CROSSDEV)objcopy
OBJDUMP = $(CROSSDEV)objdump
MKNXFLAT = mknxflat
LDNXFLAT = ldnxflat
ARCHCCVERSION = ${shell $(CC) -v 2>&1 | sed -n '/^gcc version/p' | sed -e 's/^gcc version \([0-9\.]\)/\1/g' -e 's/[-\ ].*//g' -e '1q'}
ARCHCCMAJOR = ${shell echo $(ARCHCCVERSION) | cut -d'.' -f1}
ifeq ($(CROSSDEV),arm-elf-)
MKDEP = $(TOPDIR)/tools/mkdeps.sh
ARCHCPUFLAGS = -mtune=cortex-m3 -march=armv7-m -mfloat-abi=soft
ARCHINCLUDES = -I. -isystem $(TOPDIR)/include
ARCHXXINCLUDES = -I. -isystem $(TOPDIR)/include -isystem $(TOPDIR)/include/cxx
ARCHSCRIPT = -T$(TOPDIR)/configs/$(CONFIG_ARCH_BOARD)/thttpd/ld.script
MAXOPTIMIZATION = -Os
else
WINTOOL = y
DIRLINK = $(TOPDIR)/tools/winlink.sh
DIRUNLINK = $(TOPDIR)/tools/unlink.sh
MKDEP = $(TOPDIR)/tools/mknulldeps.sh
ARCHCPUFLAGS = -mcpu=cortex-m3 -mthumb -mfloat-abi=soft
ARCHINCLUDES = -I. -isystem "${shell cygpath -w $(TOPDIR)/include}"
ARCHXXINCLUDES = -I. -isystem "${shell cygpath -w $(TOPDIR)/include}" -isystem "${shell cygpath -w $(TOPDIR)/include/cxx}"
ARCHSCRIPT = -T "${shell cygpath -w $(TOPDIR)/configs/$(CONFIG_ARCH_BOARD)/thttpd/ld.script}"
MAXOPTIMIZATION = -O2
endif
ifeq ("${CONFIG_DEBUG}","y")
ARCHOPTIMIZATION = -g
else
ARCHOPTIMIZATION = $(MAXOPTIMIZATION) -fno-strict-aliasing -fno-strength-reduce -fomit-frame-pointer
endif
ARCHCFLAGS = -fno-builtin
ARCHCXXFLAGS = -fno-builtin -fno-exceptions
ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow
ARCHWARNINGSXX = -Wall -Wshadow
ARCHDEFINES =
ARCHPICFLAGS = -fpic -msingle-pic-base -mpic-register=r10
CFLAGS = $(ARCHCFLAGS) $(ARCHWARNINGS) $(ARCHOPTIMIZATION) \
$(ARCHCPUFLAGS) $(ARCHINCLUDES) $(ARCHDEFINES) -pipe
CPICFLAGS = $(ARCHPICFLAGS) $(CFLAGS)
CXXFLAGS = $(ARCHCXXFLAGS) $(ARCHWARNINGSXX) $(ARCHOPTIMIZATION) \
$(ARCHCPUFLAGS) $(ARCHXXINCLUDES) $(ARCHDEFINES) -pipe
CXXPICFLAGS = $(ARCHPICFLAGS) $(CXXFLAGS)
CPPFLAGS = $(ARCHINCLUDES) $(ARCHDEFINES)
AFLAGS = $(CFLAGS) -D__ASSEMBLY__
NXFLATLDFLAGS1 = -r -d -warn-common
NXFLATLDFLAGS2 = $(NXFLATLDFLAGS1) \
-T$(TOPDIR)/binfmt/libnxflat/gnu-nxflat.ld \
-no-check-sections
LDNXFLATFLAGS = -e main -s 2048
OBJEXT = .o
LIBEXT = .a
EXEEXT =
ifneq ($(CROSSDEV),arm-elf-)
LDFLAGS += -nostartfiles -nodefaultlibs
endif
ifeq ($(CONFIG_DEBUG),y)
LDFLAGS += -g
endif
define PREPROCESS
@echo "CPP: $1->$2"
@$(CPP) $(CPPFLAGS) $1 -o $2
endef
define COMPILE
@echo "CC: $1"
@$(CC) -c $(CFLAGS) $1 -o $2
endef
define COMPILEXX
@echo "CXX: $1"
@$(CXX) -c $(CXXFLAGS) $1 -o $2
endef
define ASSEMBLE
@echo "AS: $1"
@$(CC) -c $(AFLAGS) $1 -o $2
endef
define ARCHIVE
echo "AR: $2"; \
$(AR) $1 $2 || { echo "$(AR) $1 $2 FAILED!" ; exit 1 ; }
endef
define CLEAN
@rm -f *.o *.a
endef
HOSTCC = gcc
HOSTINCLUDES = -I.
HOSTCFLAGS = -Wall -Wstrict-prototypes -Wshadow -g -pipe
HOSTLDFLAGS =

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,111 @@
/****************************************************************************
* configs/eagle100/thttpd/ld.script
*
* Copyright (C) 2009 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
* 3. Neither the name NuttX nor the names of its contributors may be
* used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
****************************************************************************/
/* The LM3S6918 has 256Kb of FLASH beginning at address 0x0000:0000. However,
* if the Eagle100 Ethernet bootloader is used, then the entry point must
* be at the following offset in FLASH (and the size of the FLASH must be
* reduced to 248Kb):
*/
MEMORY
{
/* flash (rx) : ORIGIN = 0x00000000, LENGTH = 256K */
flash (rx) : ORIGIN = 0x00002000, LENGTH = 248K
sram (rwx) : ORIGIN = 0x20000000, LENGTH = 64K
}
OUTPUT_ARCH(arm)
ENTRY(_stext)
SECTIONS
{
.text : {
_stext = ABSOLUTE(.);
*(.vectors)
*(.text .text.*)
*(.fixup)
*(.gnu.warning)
*(.rodata .rodata.*)
*(.gnu.linkonce.t.*)
*(.glue_7)
*(.glue_7t)
*(.got)
*(.gcc_except_table)
*(.gnu.linkonce.r.*)
_etext = ABSOLUTE(.);
} > flash
_eronly = ABSOLUTE(.); /* See below */
/* The LM3S6918 has 64Kb of SRAM beginning at the following address */
.data : {
_sdata = ABSOLUTE(.);
*(.data .data.*)
*(.gnu.linkonce.d.*)
CONSTRUCTORS
_edata = ABSOLUTE(.);
} > sram AT > flash
.ARM.extab : {
*(.ARM.extab*)
} >sram
.ARM.exidx : {
__exidx_start = ABSOLUTE(.);
*(.ARM.exidx*)
__exidx_end = ABSOLUTE(.);
} >sram
.bss : { /* BSS */
_sbss = ABSOLUTE(.);
*(.bss .bss.*)
*(.gnu.linkonce.b.*)
*(COMMON)
_ebss = ABSOLUTE(.);
} > sram
/* Stabs debugging sections. */
.stab 0 : { *(.stab) }
.stabstr 0 : { *(.stabstr) }
.stab.excl 0 : { *(.stab.excl) }
.stab.exclstr 0 : { *(.stab.exclstr) }
.stab.index 0 : { *(.stab.index) }
.stab.indexstr 0 : { *(.stab.indexstr) }
.comment 0 : { *(.comment) }
.debug_abbrev 0 : { *(.debug_abbrev) }
.debug_info 0 : { *(.debug_info) }
.debug_line 0 : { *(.debug_line) }
.debug_pubnames 0 : { *(.debug_pubnames) }
.debug_aranges 0 : { *(.debug_aranges) }
}

View File

@@ -0,0 +1,46 @@
#!/bin/bash
# configs/eagle100/thttpd/setenv.sh
#
# Copyright (C) 2009 Gregory Nutt. All rights reserved.
# Author: Gregory Nutt <spudmonkey@racsa.co.cr>
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
#
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in
# the documentation and/or other materials provided with the
# distribution.
# 3. Neither the name NuttX nor the names of its contributors may be
# used to endorse or promote products derived from this software
# without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
#
if [ "$(basename $0)" = "setenv.sh" ] ; then
echo "You must source this script, not run it!" 1>&2
exit 1
fi
if [ -z "${PATH_ORIG}" ]; then export PATH_ORIG="${PATH}"; fi
WD=`pwd`
export BUILDROOT_BIN="${WD}/../buildroot/build_arm_nofpu/staging_dir/bin"
export PATH="${BUILDROOT_BIN}:/sbin:/usr/sbin:${PATH_ORIG}"
echo "PATH : ${PATH}"

View File

@@ -1,7 +1,7 @@
/****************************************************************************
* board/up_network.c
*
* Copyright (C) 2007 Gregory Nutt. All rights reserved.
* Copyright (C) 2007, 2009 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
*
* Redistribution and use in source and binary forms, with or without

View File

@@ -0,0 +1,134 @@
############################################################################
# configs/ntosd-dm320/thttpd/Make.defs
#
# Copyright (C) 2009 Gregory Nutt. All rights reserved.
# Author: Gregory Nutt <spudmonkey@racsa.co.cr>
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
#
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in
# the documentation and/or other materials provided with the
# distribution.
# 3. Neither the name NuttX nor the names of its contributors may be
# used to endorse or promote products derived from this software
# without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
#
############################################################################
include ${TOPDIR}/.config
CROSSDEV = arm-elf-
CC = $(CROSSDEV)gcc
CXX = $(CROSSDEV)g++
CPP = $(CROSSDEV)gcc -E
LD = $(CROSSDEV)ld
AR = $(CROSSDEV)ar rcs
NM = $(CROSSDEV)nm
OBJCOPY = $(CROSSDEV)objcopy
OBJDUMP = $(CROSSDEV)objdump
MKNXFLAT = mknxflat
LDNXFLAT = ldnxflat
ARCHCCVERSION = ${shell $(CC) -v 2>&1 | sed -n '/^gcc version/p' | sed -e 's/^gcc version \([0-9\.]\)/\1/g' -e 's/[-\ ].*//g' -e '1q'}
ARCHCCMAJOR = ${shell echo $(ARCHCCVERSION) | cut -d'.' -f1}
ifeq ("${CONFIG_DEBUG}","y")
ARCHOPTIMIZATION = -g
else
ARCHOPTIMIZATION = -Os -fno-strict-aliasing -fno-strength-reduce \
-fomit-frame-pointer
endif
ifeq ($(ARCHCCMAJOR),4)
ARCHCPUFLAGS = -mtune=arm9tdmi -march=armv5te -mfloat-abi=soft -fno-builtin
else
ARCHCPUFLAGS = -mapcs-32 -mtune=arm9tdmi -march=armv5te -msoft-float -fno-builtin
endif
ARCHCFLAGS = -fno-builtin
ARCHCXXFLAGS = -fno-builtin -fno-exceptions
ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow
ARCHWARNINGSXX = -Wall -Wshadow
ARCHDEFINES =
ARCHINCLUDES = -I. -isystem $(TOPDIR)/include
ARCHSCRIPT = -T$(TOPDIR)/configs/$(CONFIG_ARCH_BOARD)/thttpd/ld.script
ARCHPICFLAGS = -fpic -msingle-pic-base -mpic-register=r10
CFLAGS = $(ARCHCFLAGS) $(ARCHWARNINGS) $(ARCHOPTIMIZATION) \
$(ARCHCPUFLAGS) $(ARCHINCLUDES) $(ARCHDEFINES) -pipe
CPICFLAGS = $(ARCHPICFLAGS) $(CFLAGS)
CXXFLAGS = $(ARCHCXXFLAGS) $(ARCHWARNINGSXX) $(ARCHOPTIMIZATION) \
$(ARCHCPUFLAGS) $(ARCHXXINCLUDES) $(ARCHDEFINES) -pipe
CXXPICFLAGS = $(ARCHPICFLAGS) $(CXXFLAGS)
CPPFLAGS = $(ARCHINCLUDES) $(ARCHDEFINES)
AFLAGS = $(CFLAGS) -D__ASSEMBLY__
NXFLATLDFLAGS1 = -r -d -warn-common
NXFLATLDFLAGS2 = $(NXFLATLDFLAGS1) \
-T$(TOPDIR)/binfmt/libnxflat/gnu-nxflat.ld \
-no-check-sections
LDNXFLATFLAGS = -e main -s 2048
OBJEXT = .o
LIBEXT = .a
EXEEXT =
ifeq ("${CONFIG_DEBUG}","y")
LDFLAGS += -g
endif
define PREPROCESS
@echo "CPP: $1->$2"
@$(CPP) $(CPPFLAGS) $1 -o $2
endef
define COMPILE
@echo "CC: $1"
@$(CC) -c $(CFLAGS) $1 -o $2
endef
define COMPILEXX
@echo "CXX: $1"
@$(CXX) -c $(CXXFLAGS) $1 -o $2
endef
define ASSEMBLE
@echo "AS: $1"
@$(CC) -c $(AFLAGS) $1 -o $2
endef
define ARCHIVE
echo "AR: $2"; \
$(AR) $1 $2 || { echo "$(AR) $1 $2 FAILED!" ; exit 1 ; }
endef
define CLEAN
@rm -f *.o *.a
endef
MKDEP = $(TOPDIR)/tools/mkdeps.sh
HOSTCC = gcc
HOSTINCLUDES = -I.
HOSTCFLAGS = -Wall -Wstrict-prototypes -Wshadow -g -pipe
HOSTLDFLAGS =

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,84 @@
/****************************************************************************
* configs/ntosd-dm320/thttpd/ld.script
*
* Copyright (C) 2009 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
* 3. Neither the name NuttX nor the names of its contributors may be
* used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
****************************************************************************/
OUTPUT_ARCH(arm)
ENTRY(_stext)
SECTIONS
{
/* The OS entry point is here */
. = 0x00008000;
.text : {
_stext = ABSOLUTE(.);
*(.text)
*(.fixup)
*(.gnu.warning)
*(.rodata)
*(.glue_7)
*(.glue_7t)
*(.got) /* Global offset table */
_etext = ABSOLUTE(.);
}
_eronly = ABSOLUTE(.); /* See below */
. = ALIGN(4096);
.data : {
_sdata = ABSOLUTE(.);
*(.data)
CONSTRUCTORS
_edata = ABSOLUTE(.);
}
.bss : { /* BSS */
_sbss = ABSOLUTE(.);
*(.bss)
*(COMMON)
_ebss = ABSOLUTE(.);
}
/* Stabs debugging sections. */
.stab 0 : { *(.stab) }
.stabstr 0 : { *(.stabstr) }
.stab.excl 0 : { *(.stab.excl) }
.stab.exclstr 0 : { *(.stab.exclstr) }
.stab.index 0 : { *(.stab.index) }
.stab.indexstr 0 : { *(.stab.indexstr) }
.comment 0 : { *(.comment) }
.debug_abbrev 0 : { *(.debug_abbrev) }
.debug_info 0 : { *(.debug_info) }
.debug_line 0 : { *(.debug_line) }
.debug_pubnames 0 : { *(.debug_pubnames) }
.debug_aranges 0 : { *(.debug_aranges) }
}

View File

@@ -0,0 +1,46 @@
#!/bin/bash
# configs/ntosd-dm320/thttpd/setenv.sh
#
# Copyright (C) 2009 Gregory Nutt. All rights reserved.
# Author: Gregory Nutt <spudmonkey@racsa.co.cr>
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
#
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in
# the documentation and/or other materials provided with the
# distribution.
# 3. Neither the name NuttX nor the names of its contributors may be
# used to endorse or promote products derived from this software
# without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
#
if [ "$(basename $0)" = "setenv.sh" ] ; then
echo "You must source this script, not run it!" 1>&2
exit 1
fi
if [ -z ${PATH_ORIG} ]; then export PATH_ORIG=${PATH}; fi
WD=`pwd`
export BUILDROOT_BIN=${WD}/../buildroot/build_arm_nofpu/staging_dir/bin
export PATH=${BUILDROOT_BIN}:/sbin:/usr/sbin:${PATH_ORIG}
echo "PATH : ${PATH}"

View File

@@ -293,6 +293,17 @@ examples/serloop
Use C buffered I/O (getchar/putchar) vs. raw console I/O
(read/read).
examples/thttpd
^^^^^^^^^^^^^^^
An example that builds netutils/thttpd with some simple NXFLAT
CGI programs. see configs/README.txt for most THTTPD settings.
In addition to those, this example accepts:
CONFIG_EXAMPLE_THTTPD_NOMAC - (May be defined to use software assigned MAC)
CONFIG_EXAMPLE_THTTPD_DRIPADDR - Default router IP addess
CONFIG_EXAMPLE_THTTPD_NETMASK - Network mask
examples/udp
^^^^^^^^^^^^

View File

@@ -1,7 +1,7 @@
/***********************************************************************
* examples/ostest/cancel.c
*
* Copyright (C) 2007, 2008 Gregory Nutt. All rights reserved.
* Copyright (C) 2007-2009 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
*
* Redistribution and use in source and binary forms, with or without
@@ -131,7 +131,7 @@ static void start_thread(pthread_t *waiter, int cancelable)
printf("start_thread: pthread_attr_init failed, status=%d\n", status);
}
status = pthread_attr_setstacksize(&attr, 16384);
status = pthread_attr_setstacksize(&attr, STACKSIZE);
if (status != 0)
{
printf("start_thread: pthread_attr_setstacksize failed, status=%d\n", status);

View File

@@ -1,7 +1,7 @@
/**************************************************************************
* mqueue.c
*
* Copyright (C) 2007, 2008 Gregory Nutt. All rights reserved.
* Copyright (C) 2007-2009 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
*
* Redistribution and use in source and binary forms, with or without
@@ -296,7 +296,7 @@ void mqueue_test(void)
printf("mqueue_test: pthread_attr_init failed, status=%d\n", status);
}
status = pthread_attr_setstacksize(&attr, 16384);
status = pthread_attr_setstacksize(&attr, STACKSIZE);
if (status != 0)
{
printf("mqueue_test: pthread_attr_setstacksize failed, status=%d\n", status);
@@ -332,7 +332,7 @@ void mqueue_test(void)
printf("mqueue_test: pthread_attr_init failed, status=%d\n", status);
}
status = pthread_attr_setstacksize(&attr, 16384);
status = pthread_attr_setstacksize(&attr, STACKSIZE);
if (status != 0)
{
printf("mqueue_test: pthread_attr_setstacksize failed, status=%d\n", status);

View File

@@ -1,7 +1,7 @@
/**************************************************************************
* examples/ostest/mqueue.c
*
* Copyright (C) 2007, 2008 Gregory Nutt. All rights reserved.
* Copyright (C) 2007-2009 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
*
* Redistribution and use in source and binary forms, with or without
@@ -336,7 +336,7 @@ void timedmqueue_test(void)
printf("timedmqueue_test: pthread_attr_init failed, status=%d\n", status);
}
status = pthread_attr_setstacksize(&attr, 16384);
status = pthread_attr_setstacksize(&attr, STACKSIZE);
if (status != 0)
{
printf("timedmqueue_test: pthread_attr_setstacksize failed, status=%d\n", status);
@@ -366,7 +366,7 @@ void timedmqueue_test(void)
printf("timedmqueue_test: pthread_attr_init failed, status=%d\n", status);
}
status = pthread_attr_setstacksize(&attr, 16384);
status = pthread_attr_setstacksize(&attr, STACKSIZE);
if (status != 0)
{
printf("timedmqueue_test: pthread_attr_setstacksize failed, status=%d\n", status);

80
examples/thttpd/Makefile Normal file
View File

@@ -0,0 +1,80 @@
############################################################################
# examples/thttpd/Makefile
#
# Copyright (C) 2009 Gregory Nutt. All rights reserved.
# Author: Gregory Nutt <spudmonkey@racsa.co.cr>
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
#
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in
# the documentation and/or other materials provided with the
# distribution.
# 3. Neither the name NuttX nor the names of its contributors may be
# used to endorse or promote products derived from this software
# without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
#
############################################################################
-include $(TOPDIR)/.config
-include $(TOPDIR)/Make.defs
ASRCS =
AOBJS = $(ASRCS:.S=$(OBJEXT))
CSRCS = main.c
COBJS = $(CSRCS:.c=$(OBJEXT))
SRCS = $(ASRCS) $(CSRCS)
OBJS = $(AOBJS) $(COBJS)
BIN = lib$(CONFIG_EXAMPLE)$(LIBEXT)
all: $(BIN)
.PHONY: clean headers
$(AOBJS): %$(OBJEXT): %.S
$(call ASSEMBLE, $<, $@)
$(COBJS): %$(OBJEXT): %.c
$(call COMPILE, $<, $@)
headers:
@$(MAKE) -C content TOPDIR=$(TOPDIR) CROSSDEV=$(CROSSDEV)
$(BIN): headers $(OBJS)
@( for obj in $(OBJS) ; do \
$(call ARCHIVE, $@, $${obj}); \
done ; )
.depend: Makefile $(SRCS)
@$(MKDEP) $(CC) -- $(CFLAGS) -- $(SRCS) >Make.dep
@touch $@
depend: .depend
clean:
@rm -f $(BIN) *~ .*.swp
@make -C content clean TOPDIR=$(TOPDIR) CROSSDEV=$(CROSSDEV)
$(call CLEAN)
distclean: clean
@rm -f Make.dep .depend
-include Make.dep

View File

@@ -0,0 +1,104 @@
############################################################################
# examples/thttpd/content/Makefile
#
# Copyright (C) 2009 Gregory Nutt. All rights reserved.
# Author: Gregory Nutt <spudmonkey@racsa.co.cr>
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
#
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in
# the documentation and/or other materials provided with the
# distribution.
# 3. Neither the name NuttX nor the names of its contributors may be
# used to endorse or promote products derived from this software
# without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
#
############################################################################
SUBDIRS = hello
INSTALL_FILES = index.html style.css
THTTPD_DIR = $(TOPDIR)/examples/thttpd
CONTENT_DIR = $(THTTPD_DIR)/content
ROMFS_DIR = $(CONTENT_DIR)/romfs
ROMFS_IMG = $(CONTENT_DIR)/romfs.img
ROMFS_HDR = $(CONTENT_DIR)/romfs.h
ROMFSCGI_DIR = $(ROMFS_DIR)/cgi-bin
SYMTAB = $(CONTENT_DIR)/symtab.h
define DIR_template
$(1)_$(2):
@$(MAKE) -C $(1) $(3) TOPDIR=$(TOPDIR) CROSSDEV=$(CROSSDEV) CGI_DIR=$(ROMFSCGI_DIR)
endef
all: $(ROMFS_HDR) $(SYMTAB)
.PHONY: all build clean install populate
$(foreach DIR, $(SUBDIRS), $(eval $(call DIR_template,$(DIR),build, all)))
$(foreach DIR, $(SUBDIRS), $(eval $(call DIR_template,$(DIR),clean,clean)))
$(foreach DIR, $(SUBDIRS), $(eval $(call DIR_template,$(DIR),install,install)))
# Build program(s) in each sud-directory
build: $(foreach DIR, $(SUBDIRS), $(DIR)_build)
# Install each program in the romfs directory
install: $(foreach DIR, $(SUBDIRS), $(DIR)_install)
@( for file in $(INSTALL_FILES); do\
install -m 0644 -D $${file} $(ROMFS_DIR)/$${file}; \
done; )
# Create the romfs directory
$(ROMFS_DIR):
@mkdir -p $(ROMFS_DIR)
$(ROMFSCGI_DIR): $(ROMFS_DIR)
@mkdir -p $(ROMFSCGI_DIR)
# Populate the romfs directory
populate: $(ROMFSCGI_DIR) build install
# Create the romfs.img file from the populated romfs directory
$(ROMFS_IMG): populate
@genromfs -f $@ -d $(ROMFS_DIR) -V "THTTPDTEST"
# Create the romfs.h header file from the romfs.img file
$(ROMFS_HDR) : $(ROMFS_IMG)
@(cd $(CONTENT_DIR); xxd -i romfs.img | sed -e "s/^unsigned/static const unsigned/g" >$@)
# Create the exported symbol table list from the derived *-thunk.S files
$(SYMTAB): build
@$(CONTENT_DIR)/mksymtab.sh $(CONTENT_DIR) >$@
# Clean each subdirectory
clean: $(foreach DIR, $(SUBDIRS), $(DIR)_clean)
@rm -f $(ROMFS_HDR) $(ROMFS_IMG) $(SYMTAB)
@rm -rf $(ROMFS_DIR)
@rm -f *~ .*.swp

View File

@@ -0,0 +1,78 @@
############################################################################
# examples/thttpd/content/hello/Makefile
#
# Copyright (C) 2009 Gregory Nutt. All rights reserved.
# Author: Gregory Nutt <spudmonkey@racsa.co.cr>
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
#
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in
# the documentation and/or other materials provided with the
# distribution.
# 3. Neither the name NuttX nor the names of its contributors may be
# used to endorse or promote products derived from this software
# without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
#
############################################################################
-include $(TOPDIR)/.config # Current configuration
-include $(TOPDIR)/Make.defs # Basic make info
BIN = hello
R1SRCS = $(BIN).c
R1OBJS = $(R1SRCS:.c=.o)
R2SRC = $(BIN)-thunk.S
R2OBJ = $(R2SRC:.S=.o)
all: $(BIN)
$(R1OBJS): %.o: %.c
@echo "CC: $<"
@$(CC) -c $(CPICFLAGS) $< -o $@
$(R2OBJ): %.o: %.S
@echo "AS: $<"
@$(CC) -c $(CPICFLAGS) $< -o $@
$(BIN).r1: $(R1OBJS)
@echo "LD: $<"
@$(LD) $(NXFLATLDFLAGS1) -o $@ $^
$(R2SRC): $(BIN).r1
@echo "MK: $<"
@$(MKNXFLAT) -o $@ $^
$(BIN).r2: $(R2OBJ)
@echo "LD: $<"
@$(LD) $(NXFLATLDFLAGS2) -o $@ $(R1OBJS) $(R2OBJ)
$(BIN): $(BIN).r2
@echo "LD: $<"
@$(LDNXFLAT) $(LDNXFLATFLAGS) -o $@ $^
clean:
@rm -f $(BIN) $(R2SRC) *.o *.r1 *.r2 *~ .*.swp core
install:
@install -m 0755 -D $(BIN) $(CGI_DIR)/$(BIN)

View File

@@ -0,0 +1,69 @@
/****************************************************************************
* examples/thttpd/content/hello.c
* Manatory "Hello, World!" Example
*
* Copyright (C) 2009 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
* 3. Neither the name Gregory Nutt nor the names of its contributors may be
* used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
****************************************************************************/
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include <sys/types.h>
#include <stdio.h>
#include <stdlib.h>
/****************************************************************************
* Public Functions
****************************************************************************/
int main(int argc, char *argv[])
{
fprintf(stderr, "Hello requested from: %s\n", getenv("REMOTE_ADDR"));
(void)printf(
"Content-type: text/html\r\n"
"Status: 200/html\r\n"
"\r\n"
"<HTML>"
"<HEAD>"
"<TITLE>Hello</TITLE>"
"</HEAD>\r\n"
"<BODY>"
"<H2>Hello, World!</H2>"
"<P>Requested by: %s</P>"
"</BODY></HTML>\r\n",
getenv("REMOTE_ADDR"));
return 0;
}

View File

@@ -0,0 +1,30 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>NuttX examples/thttpd!</title>
<link rel="stylesheet" type="text/css" href="style.css">
</head>
<body bgcolor="#fffeec" text="black">
<div class="menu">
<div class="menubox"><a href="index.html">Front page</a></div>
<div class="menubox"><a href="cgi-bin/hello">Say Hello</a></div>
<div class="menubox"><a href="cgi-bin/test1">Test1</a></div>
<div class="menubox"><a href="cgi-bin/test2">Test2</a></div>
<br>
</div>
<div class="contentblock">
<p>
These web pages are served by a port of <a href="http://acme.com/software/thttpd/">THTTPD</a>
running on top of <a href="http://www.nuttx.org">NuttX</a>.
NuttX includes a port of the <a href="http://www.sics.se/~adam/uip/">uIP</a> embedded TCP/IP stack.
</p>
<p>
Click on the links above to exercise THTTPD's CGI capability under NuttX.
Clicking the links will execute the CGI program from an
<a href="http://nuttx.sourceforge.net/NuttXNxFlat.html">NXFLAT</a> program residing
in a ROMFS file system.
</p>
</body>
</html>

View File

@@ -0,0 +1,39 @@
#!/bin/bash
usage="Usage: %0 <test-dir-path>"
dir=$1
if [ -z "$dir" ]; then
echo "ERROR: Missing <test-dir-path>"
echo ""
echo $usage
exit 1
fi
if [ ! -d "$dir" ]; then
echo "ERROR: Directory $dir does not exist"
echo ""
echo $usage
exit 1
fi
varlist=`find $dir -name "*-thunk.S"| xargs grep -h asciz | cut -f3 | sort | uniq`
echo "#ifndef __EXAMPLES_NXFLAT_TESTS_SYMTAB_H"
echo "#define __EXAMPLES_NXFLAT_TESTS_SYMTAB_H"
echo ""
echo "#include <nuttx/symtab.h>"
echo ""
echo "static const struct symtab_s exports[] = "
echo "{"
for string in $varlist; do
var=`echo $string | sed -e "s/\"//g"`
echo " {$string, $var},"
done
echo "};"
echo "#define NEXPORTS (sizeof(exports)/sizeof(struct symtab_s))"
echo ""
echo "#endif /* __EXAMPLES_NXFLAT_TESTS_SYMTAB_H */"

View File

@@ -0,0 +1,80 @@
h1
{
text-align: center;
font-size:14pt;
font-family:arial,helvetica;
font-weight:bold;
padding:10px;
}
body
{
background-color: #fffeec;
color:black;
font-size:8pt;
font-family:arial,helvetica;
}
.menu
{
margin: 4px;
width:60%;
padding:2px;
border: solid 1px;
background-color: #fffcd2;
text-align:left;
font-size:9pt;
font-family:arial,helvetica;
}
div.menubox
{
width: 25%;
border: 0;
float: left;
text-align: center;
}
.contentblock
{
margin: 4px;
width:60%;
padding:2px;
border: 1px dotted;
background-color: white;
font-size:8pt;
font-family:arial,helvetica;
}
p.intro
{
margin-left:20px;
margin-right:20px;
font-size:10pt;
font-family:arial,helvetica;
}
p.clink
{
font-size:12pt;
font-family:courier,monospace;
text-align:center;
}
p.clink9
{
font-size:9pt;
font-family:courier,monospace;
text-align:center;
}
p
{
padding-left:10px;
}
p.right
{
text-align:right;
}

235
examples/thttpd/main.c Normal file
View File

@@ -0,0 +1,235 @@
/****************************************************************************
* examples/thttpd/main.c
*
* Copyright (C) 2009 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
* 3. Neither the name Gregory Nutt nor the names of its contributors may be
* used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
****************************************************************************/
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include <sys/types.h>
#include <sys/ioctl.h>
#include <sys/mount.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <errno.h>
#include <debug.h>
#include <net/if.h>
#include <net/uip/thttpd.h>
#include <net/uip/uip-arp.h>
#include <net/uip/uip-lib.h>
#include <nuttx/ramdisk.h>
#include <nuttx/binfmt.h>
#include <nuttx/nxflat.h>
#include "content/romfs.h"
#include "content/symtab.h"
/****************************************************************************
* Definitions
****************************************************************************/
/* Check configuration. This is not all of the configuration settings that
* are required -- only the more obvious.
*/
#if CONFIG_NFILE_DESCRIPTORS < 1
# error "You must provide file descriptors via CONFIG_NFILE_DESCRIPTORS in your configuration file"
#endif
#ifndef CONFIG_NXFLAT
# error "You must select CONFIG_NXFLAT in your configuration file"
#endif
#ifndef CONFIG_FS_ROMFS
# error "You must select CONFIG_FS_ROMFS in your configuration file"
#endif
#ifdef CONFIG_DISABLE_MOUNTPOINT
# error "You must not disable mountpoints via CONFIG_DISABLE_MOUNTPOINT in your configuration file"
#endif
#ifdef CONFIG_BINFMT_DISABLE
# error "You must not disable loadable modules via CONFIG_BINFMT_DISABLE in your configuration file"
#endif
/* Describe the ROMFS file system */
#define SECTORSIZE 512
#define NSECTORS(b) (((b)+SECTORSIZE-1)/SECTORSIZE)
#define ROMFSDEV "/dev/ram0"
#define MOUNTPT "/mnt/www"
#ifdef CONFIG_CPP_HAVE_VARARGS
# ifdef CONFIG_DEBUG
# define message(...) lib_lowprintf(__VA_ARGS__)
# else
# define message(...) printf(__VA_ARGS__)
# endif
#else
# ifdef CONFIG_DEBUG
# define message lib_lowprintf
# else
# define message (void)
# endif
#endif
/****************************************************************************
* Private Data
****************************************************************************/
/****************************************************************************
* Public Data
****************************************************************************/
/* These values must be provided by the user before the THTTPD task daemon
* is started:
*
* g_thttpdsymtab: A symbol table describing all of the symbols exported
* from the base system. These symbols are used to bind address references
* in CGI programs to NuttX.
* g_nsymbols: The number of symbols in g_thttpdsymtab[].
*/
FAR const struct symtab_s *g_thttpdsymtab;
int g_thttpdnsymbols;
/****************************************************************************
* Public Functions
****************************************************************************/
/****************************************************************************
* user_initialize
****************************************************************************/
#ifndef CONFIG_HAVE_WEAKFUNCTIONS
void user_initialize(void)
{
/* Stub that must be provided only if the toolchain does not support weak
* functions.
*/
}
#endif
/****************************************************************************
* user_start
****************************************************************************/
int user_start(int argc, char *argv[])
{
struct in_addr addr;
#ifdef CONFIG_EXAMPLE_UIP_NOMAC
uint8 mac[IFHWADDRLEN];
#endif
char *thttpd_argv = "thttpd";
int ret;
/* Many embedded network interfaces must have a software assigned MAC */
#ifdef CONFIG_EXAMPLE_UIP_NOMAC
message("Assigning MAC\n");
mac[0] = 0x00;
mac[1] = 0xe0;
mac[2] = 0xb0;
mac[3] = 0x0b;
mac[4] = 0xba;
mac[5] = 0xbe;
uip_setmacaddr("eth0", mac);
#endif
/* Set up our host address */
message("Setup network addresses\n");
addr.s_addr = HTONL(CONFIG_THTTPD_IPADDR);
uip_sethostaddr("eth0", &addr);
/* Set up the default router address */
addr.s_addr = HTONL(CONFIG_EXAMPLE_THTTPD_DRIPADDR);
uip_setdraddr("eth0", &addr);
/* Setup the subnet mask */
addr.s_addr = HTONL(CONFIG_EXAMPLE_THTTPD_NETMASK);
uip_setnetmask("eth0", &addr);
/* Initialize the NXFLAT binary loader */
message("Initializing the NXFLAT binary loader\n");
ret = nxflat_initialize();
if (ret < 0)
{
message("ERROR: Initialization of the NXFLAT loader failed: %d\n", ret);
exit(1);
}
/* Create a ROM disk for the ROMFS filesystem */
message("Registering romdisk\n");
ret = romdisk_register(0, (ubyte*)romfs_img, NSECTORS(romfs_img_len), SECTORSIZE);
if (ret < 0)
{
message("ERROR: romdisk_register failed: %d\n", ret);
nxflat_uninitialize();
exit(1);
}
/* Mount the file system */
message("Mounting ROMFS filesystem at target=%s with source=%s\n",
MOUNTPT, ROMFSDEV);
ret = mount(ROMFSDEV, MOUNTPT, "romfs", MS_RDONLY, NULL);
if (ret < 0)
{
message("ERROR: mount(%s,%s,romfs) failed: %s\n",
ROMFSDEV, MOUNTPT, errno);
nxflat_uninitialize();
}
/* Start THTTPD. At present, symbol table info is passed via global variables */
g_thttpdsymtab = exports;
g_thttpdnsymbols = NEXPORTS;
message("Starting THTTPD\n");
thttpd_main(1, &thttpd_argv);
message("THTTPD terminated\n");
return 0;
}

View File

@@ -44,9 +44,10 @@ ifneq ($(CONFIG_NSOCKET_DESCRIPTORS),0)
CSRCS += fs_close.c fs_write.c fs_ioctl.c fs_poll.c fs_select.c
endif
else
CSRCS += fs_open.c fs_close.c fs_read.c fs_write.c fs_ioctl.c fs_poll.c \
fs_select.c fs_lseek.c fs_dup.c fs_filedup.c fs_dup2.c fs_filedup2.c \
fs_mmap.c fs_opendir.c fs_closedir.c fs_stat.c fs_readdir.c fs_readdirr.c \
CSRCS += fs_open.c fs_close.c fs_read.c fs_write.c fs_ioctl.c \
fs_poll.c fs_select.c fs_lseek.c fs_dup.c fs_filedup.c \
fs_dup2.c fs_fcntl.c fs_filedup2.c fs_mmap.c fs_opendir.c \
fs_closedir.c fs_stat.c fs_readdir.c fs_readdirr.c \
fs_seekdir.c fs_telldir.c fs_rewinddir.c fs_files.c fs_inode.c \
fs_inodefind.c fs_inodereserve.c fs_statfs.c fs_inoderemove.c \
fs_registerdriver.c fs_unregisterdriver.c fs_inodeaddref.c \

View File

@@ -47,15 +47,8 @@
#include <nuttx/fs.h>
#include "fs_internal.h"
/* This logic in this applies only when both socket and file descriptors are
* in that case, this function descriminates which type of dup is being
* performed.
*/
#if CONFIG_NFILE_DESCRIPTORS > 0 && defined(CONFIG_NET) && CONFIG_NSOCKET_DESCRIPTORS > 0
/****************************************************************************
* Definitions
* Pre-processor Definitions
****************************************************************************/
/****************************************************************************
@@ -76,34 +69,40 @@
int dup(int fildes)
{
int ret = OK;
/* Check the range of the descriptor to see if we got a file or a socket
* descriptor. */
if ((unsigned int)fildes >= CONFIG_NFILE_DESCRIPTORS)
#if CONFIG_NFILE_DESCRIPTORS > 0
if ((unsigned int)fildes < CONFIG_NFILE_DESCRIPTORS)
{
/* Its a valid file descriptor.. dup the file descriptor using any
* other file descriptor*/
ret = file_dup(fildes, 0);
}
else
#endif
{
/* Not a vailid file descriptor. Did we get a valid socket descriptor? */
#if defined(CONFIG_NET) && CONFIG_NSOCKET_DESCRIPTORS > 0
if ((unsigned int)fildes < (CONFIG_NFILE_DESCRIPTORS+CONFIG_NSOCKET_DESCRIPTORS))
{
/* Yes.. dup the socket descriptor */
return net_dup(fildes);
ret = net_dup(fildes, CONFIG_NFILE_DESCRIPTORS);
}
else
#endif
{
/* No.. then it is a bad descriptor number */
errno = EBADF;
return ERROR;
ret = ERROR;
}
}
else
{
/* Its a valid file descriptor.. dup the file descriptor */
return file_dup(fildes);
}
return ret;
}
#endif /* CONFIG_NFILE_DESCRIPTORS > 0 ... */

256
fs/fs_fcntl.c Normal file
View File

@@ -0,0 +1,256 @@
/****************************************************************************
* fs/fs_fcntl.c
*
* Copyright (C) 2009 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
* 3. Neither the name NuttX nor the names of its contributors may be
* used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
****************************************************************************/
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include <sys/types.h>
#include <stdarg.h>
#include <fcntl.h>
#include <errno.h>
#include <nuttx/fs.h>
#include <nuttx/net.h>
#include <nuttx/sched.h>
#include "fs_internal.h"
/****************************************************************************
* Private Functions
****************************************************************************/
#if CONFIG_NFILE_DESCRIPTORS > 0
static inline int file_vfcntl(int fildes, int cmd, va_list ap)
{
FAR struct filelist *list;
FAR struct file *this_file;
int err = 0;
int ret = 0;
/* Get the thread-specific file list */
list = sched_getfiles();
if (!list)
{
err = EMFILE;
goto errout;
}
/* Was this file opened ? */
this_file = &list->fl_files[fildes];
if (!this_file->f_inode)
{
err = EBADF;
goto errout;
}
switch (cmd)
{
case F_DUPFD:
/* Return a new file descriptor which shall be the lowest numbered
* available (that is, not already open) file descriptor greater than
* or equal to the third argument, arg, taken as an integer of type
* int. The new file descriptor shall refer to the same open file
* description as the original file descriptor, and shall share any
* locks. The FD_CLOEXEC flag associated with the new file descriptor
* shall be cleared to keep the file open across calls to one of the
* exec functions.
*/
{
ret = file_dup(fildes, va_arg(ap, int));
}
break;
case F_GETFD:
/* Get the file descriptor flags defined in <fcntl.h> that are associated
* with the file descriptor fildes. File descriptor flags are associated
* with a single file descriptor and do not affect other file descriptors
* that refer to the same file.
*/
case F_SETFD:
/* Set the file descriptor flags defined in <fcntl.h>, that are associated
* with fildes, to the third argument, arg, taken as type int. If the
* FD_CLOEXEC flag in the third argument is 0, the file shall remain open
* across the exec functions; otherwise, the file shall be closed upon
* successful execution of one of the exec functions.
*/
err = ENOSYS;
break;
case F_GETFL:
/* Get the file status flags and file access modes, defined in <fcntl.h>,
* for the file description associated with fildes. The file access modes
* can be extracted from the return value using the mask O_ACCMODE, which is
* defined in <fcntl.h>. File status flags and file access modes are associated
* with the file description and do not affect other file descriptors that
* refer to the same file with different open file descriptions.
*/
{
ret = this_file->f_oflags;
}
break;
case F_SETFL:
/* Set the file status flags, defined in <fcntl.h>, for the file description
* associated with fildes from the corresponding bits in the third argument,
* arg, taken as type int. Bits corresponding to the file access mode and
* the file creation flags, as defined in <fcntl.h>, that are set in arg shall
* be ignored. If any bits in arg other than those mentioned here are changed
* by the application, the result is unspecified.
*/
{
this_file->f_oflags = va_arg(ap, int);
}
break;
case F_GETOWN:
/* If fildes refers to a socket, get the process or process group ID specified
* to receive SIGURG signals when out-of-band data is available. Positive values
* indicate a process ID; negative values, other than -1, indicate a process group
* ID. If fildes does not refer to a socket, the results are unspecified.
*/
case F_SETOWN:
/* If fildes refers to a socket, set the process or process group ID specified
* to receive SIGURG signals when out-of-band data is available, using the value
* of the third argument, arg, taken as type int. Positive values indicate a
* process ID; negative values, other than -1, indicate a process group ID. If
* fildes does not refer to a socket, the results are unspecified.
*/
err = EBADF; /* Only valid on socket descriptors */
break;
case F_GETLK:
/* Get the first lock which blocks the lock description pointed to by the third
* argument, arg, taken as a pointer to type struct flock, defined in <fcntl.h>.
* The information retrieved shall overwrite the information passed to fcntl() in
* the structure flock. If no lock is found that would prevent this lock from being
* created, then the structure shall be left unchanged except for the lock type
* which shall be set to F_UNLCK.
*/
case F_SETLK:
/* Set or clear a file segment lock according to the lock description pointed to
* by the third argument, arg, taken as a pointer to type struct flock, defined in
* <fcntl.h>. F_SETLK can establish shared (or read) locks (F_RDLCK) or exclusive
* (or write) locks (F_WRLCK), as well as to remove either type of lock (F_UNLCK).
* F_RDLCK, F_WRLCK, and F_UNLCK are defined in <fcntl.h>. If a shared or exclusive
* lock cannot be set, fcntl() shall return immediately with a return value of -1.
*/
case F_SETLKW:
/* This command shall be equivalent to F_SETLK except that if a shared or exclusive
* lock is blocked by other locks, the thread shall wait until the request can be
* satisfied. If a signal that is to be caught is received while fcntl() is waiting
* for a region, fcntl() shall be interrupted. Upon return from the signal handler,
* fcntl() shall return -1 with errno set to [EINTR], and the lock operation shall
* not be done.
*/
err = ENOSYS; /* Not implemented */
break;
default:
err = EINVAL;
break;
}
errout:
if (err != 0)
{
errno = err;
return ERROR;
}
return OK;
}
#endif /* CONFIG_NFILE_DESCRIPTORS > 0 */
/****************************************************************************
* Global Functions
****************************************************************************/
int fcntl(int fildes, int cmd, ...)
{
va_list ap;
int ret;
/* Setup to access the variable argument list */
va_start(ap, cmd);
/* Did we get a valid file descriptor? */
#if CONFIG_NFILE_DESCRIPTORS > 0
if ((unsigned int)fildes < CONFIG_NFILE_DESCRIPTORS)
{
/* Yes.. defer file operations to file_vfcntl() */
ret = file_vfcntl(fildes, cmd, ap);
}
else
#endif
{
/* No... check for operations on a socket descriptor */
#if defined(CONFIG_NET) && CONFIG_NSOCKET_DESCRIPTORS > 0
if ((unsigned int)fildes < (CONFIG_NFILE_DESCRIPTORS+CONFIG_NSOCKET_DESCRIPTORS))
{
/* Yes.. defer socket descriptor operations to net_vfcntl() */
ret = net_vfcntl(fildes, cmd, ap);
}
else
#endif
{
/* No.. this descriptor number is out of range */
ret = EBADF;
}
}
va_end(ap);
return ret;
}

View File

@@ -40,7 +40,6 @@
#include <nuttx/config.h>
#include <sys/types.h>
#include <unistd.h>
#include <sched.h>
#include <errno.h>
@@ -76,11 +75,7 @@
*
****************************************************************************/
#if defined(CONFIG_NET) && CONFIG_NSOCKET_DESCRIPTORS > 0
int file_dup(int fildes)
#else
int dup(int fildes)
#endif
int file_dup(int fildes, int minfd)
{
FAR struct filelist *list;
int fildes2;
@@ -110,7 +105,8 @@ int dup(int fildes)
fildes2 = files_allocate(list->fl_files[fildes].f_inode,
list->fl_files[fildes].f_oflags,
list->fl_files[fildes].f_pos);
list->fl_files[fildes].f_pos,
minfd);
if (fildes2 < 0)
{
errno = EMFILE;

View File

@@ -1,7 +1,7 @@
/****************************************************************************
* fs/fs_files.c
*
* Copyright (C) 2007, 2008 Gregory Nutt. All rights reserved.
* Copyright (C) 2007-2009 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
*
* Redistribution and use in source and binary forms, with or without
@@ -361,7 +361,8 @@ errout:
* Returns the file descriptor == index into the files array.
*
****************************************************************************/
int files_allocate(FAR struct inode *inode, int oflags, off_t pos)
int files_allocate(FAR struct inode *inode, int oflags, off_t pos, int minfd)
{
FAR struct filelist *list;
int i;
@@ -370,7 +371,7 @@ int files_allocate(FAR struct inode *inode, int oflags, off_t pos)
if (list)
{
_files_semtake(list);
for (i = 0; i < CONFIG_NFILE_DESCRIPTORS; i++)
for (i = minfd; i < CONFIG_NFILE_DESCRIPTORS; i++)
{
if (!list->fl_files[i].f_inode)
{

View File

@@ -225,7 +225,7 @@ EXTERN void inode_release(FAR struct inode *inode);
/* fs_files.c ****************************************************************/
EXTERN void weak_function files_initialize(void);
EXTERN int files_allocate(FAR struct inode *inode, int oflags, off_t pos);
EXTERN int files_allocate(FAR struct inode *inode, int oflags, off_t pos, int minfd);
EXTERN int files_close(int filedes);
EXTERN void files_release(int filedes);

View File

@@ -140,7 +140,7 @@ int open(const char *path, int oflags, ...)
/* Associate the inode with a file structure */
fd = files_allocate(inode, oflags, 0);
fd = files_allocate(inode, oflags, 0, 0);
if (fd < 0)
{
ret = EMFILE;

View File

@@ -1,7 +1,7 @@
/********************************************************************************
* include/fcntl.h
*
* Copyright (C) 2007, 2008 Gregory Nutt. All rights reserved.
* Copyright (C) 2007-2009 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
*
* Redistribution and use in source and binary forms, with or without
@@ -57,8 +57,9 @@
#define O_APPEND 0x10 /* Keep contents, append to end */
#define O_TRUNC 0x20 /* Delete contents */
#define O_NONBLOCK 0x40 /* Don't wait for data */
#define O_NDELAY O_NONBLOCK
#define O_SYNC 0x80 /* Synchronize output on write */
#define O_DSYNC OSYNC
#define O_DSYNC O_SYNC
#define O_RSYNC 0x00 /* Sychronize input on read */
#define O_ACCMODE 0x00 /* Required by POSIX */
@@ -85,16 +86,16 @@
#define F_SETOWN 13 /* Set pid that will receive SIGIO and SIGURG signals for fd */
#define F_SETSIG 14 /* Set the signal to be sent */
/* For posix fcntl() and lockf() */
#define F_RDLCK 0 /* Take out a read lease */
#define F_WRLCK 1 /* Take out a write lease */
#define F_UNLCK 2 /* Remove a lease */
/* close-on-exec flag for F_GETRL and F_SETFL */
#define FD_CLOEXEC 1
/* Arguments to F_SETLEASE */
#define F_RDLCK 0 /* Take out a read lease */
#define F_WRLCK 2 /* Take out a write lease */
#define F_UNLCK 3 /* Remove a lease */
/* These are the notifications that can be received from F_NOTIFY (linux) */
#define DN_ACCESS 0 /* A file was accessed */

101
include/net/uip/thttpd.h Normal file
View File

@@ -0,0 +1,101 @@
/****************************************************************************
* net/uip/thttpd.h
*
* Copyright (C) 2009 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
* 3. Neither the name NuttX nor the names of its contributors may be
* used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
****************************************************************************/
#ifndef __NET_UIP_THTTPD_H
#define __NET_UIP_THTTPD_H
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include <sys/types.h>
#include <nuttx/symtab.h>
/****************************************************************************
* Public Data
****************************************************************************/
#undef EXTERN
#if defined(__cplusplus)
#define EXTERN extern "C"
extern "C" {
#else
#define EXTERN extern
#endif
/* These values must be provided by the user before the THTTPD task daemon
* is started:
*
* g_thttpdsymtab: A symbol table describing all of the symbols exported
* from the base system. These symbols are used to bind address references
* in CGI programs to NuttX.
* g_nsymbols: The number of symbols in g_thttpdsymtab[].
*
* (See examples/nxflat and examples/thttpd for examples of how such a symbol
* table may be created.)
*/
EXTERN FAR const struct symtab_s *g_thttpdsymtab;
EXTERN int g_thttpdnsymbols;
/****************************************************************************
* Public Function Prototypes
****************************************************************************/
/****************************************************************************
* Function: thttpd_main
*
* Description:
* This function is the entrypoint into the THTTPD server. It does not
* return. It may be called, the normal mechanism for starting the server
* is:
*
* 1) Set is g_thttpdsymtab and g_thttpdnsymbols. The user is required
* to provide a symbol table to use for binding CGI programs (if CGI
* is enabled. See examples/nxflat and examples/thttpd for examples of
* how such a symbol table may be created.)
* 2) Call task_create() to start thttpd_main()
*
****************************************************************************/
EXTERN int thttpd_main(int argc, char **argv);
#undef EXTERN
#if defined(__cplusplus)
}
#endif
#endif /* __NET_UIP_THTTPD_H */

View File

@@ -87,9 +87,9 @@ struct in_addr
struct sockaddr_in
{
sa_family_t sin_family; /* address family: AF_INET */
uint16 sin_port; /* port in network byte order */
struct in_addr sin_addr; /* internet address */
sa_family_t sin_family; /* Address family: AF_INET */
uint16 sin_port; /* Port in network byte order */
struct in_addr sin_addr; /* Internet address */
};
/* IPv6 Internet address */
@@ -106,9 +106,9 @@ struct in6_addr
struct sockaddr_in6
{
sa_family_t sin_family; /* Address family: AF_INET */
uint16 sin_port; /* Port in network byte order */
struct in6_addr sin6_addr; /* IPv6 internet address */
sa_family_t sin_family; /* Address family: AF_INET */
uint16 sin_port; /* Port in network byte order */
struct in6_addr sin6_addr; /* IPv6 internet address */
};
/****************************************************************************

View File

@@ -85,7 +85,7 @@ struct binfmt_s
};
/****************************************************************************
* Public Functions
* Public Data
****************************************************************************/
#undef EXTERN
@@ -96,6 +96,10 @@ extern "C" {
#define EXTERN extern
#endif
/****************************************************************************
* Public Function Prototypes
****************************************************************************/
/****************************************************************************
* Name: register_binfmt
*
@@ -173,6 +177,29 @@ EXTERN int unload_module(FAR const struct binary_s *bin);
EXTERN int exec_module(FAR const struct binary_s *bin, int priority);
/****************************************************************************
* Name: exec
*
* Description:
* This is a convenience function that wraps load_ and exec_module into
* one call.
*
* Input Parameter:
* filename - Fulll path to the binary to be loaded
* argv - Argument list
* exports - Table of exported symbols
* nexports - The number of symbols in exports
*
* Returned Value:
* This is an end-user function, so it follows the normal convention:
* Returns the PID of the exec'ed module. On failure, it.returns
* -1 (ERROR) and sets errno appropriately.
*
****************************************************************************/
EXTERN int exec(FAR const char *filename, FAR const char **argv,
FAR const struct symtab_s *exports, int nexports);
#undef EXTERN
#if defined(__cplusplus)
}

View File

@@ -344,15 +344,9 @@ EXTERN int files_dup(FAR struct file *filep1, FAR struct file *filep2);
/* fs_filedup.c **************************************************************/
/* This alternative naming is used when dup could operate on both file and
* socket descritors to avoid drawing unused socket support into the link.
*/
/* Dupicate a file descriptor using any value greater than or equal to minfd */
#if defined(CONFIG_NET) && CONFIG_NSOCKET_DESCRIPTORS > 0
EXTERN int file_dup(int fd);
#else
# define file_dup(fd) dup(fd)
#endif
EXTERN int file_dup(int fd, int minfd);
/* fs_filedup2.c *************************************************************/

View File

@@ -1,7 +1,8 @@
/****************************************************************************
* include/nuttx/lib.h
* Non-standard, internal APIs available in lib/.
*
* Copyright (C) 2007, 2008 Gregory Nutt. All rights reserved.
* Copyright (C) 2007-2009 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
*
* Redistribution and use in source and binary forms, with or without

View File

@@ -43,6 +43,7 @@
#include <nuttx/config.h>
#ifdef CONFIG_NET
#include <stdarg.h>
#include <semaphore.h>
#include <net/uip/uip.h>
@@ -165,14 +166,10 @@ EXTERN int net_poll(int sockfd, struct pollfd *fds, boolean setup);
/* net_dup.c *****************************************************************/
/* The standard dup() operation redirects operations on socket descriptors to
* this function (when both file and socket descriptors are supported)
* this function
*/
#if CONFIG_NFILE_DESCRIPTOR > 0
EXTERN int net_dup(int sockfd);
#else
# define net_dup(sockfd) dup(sockfd)
#endif
EXTERN int net_dup(int sockfd, int minsd);
/* net_dup2.c ****************************************************************/
/* The standard dup2() operation redirects operations on socket descriptors to
@@ -190,6 +187,11 @@ EXTERN int net_dup2(int sockfd1, int sockfd2);
EXTERN int net_clone(FAR struct socket *psock1, FAR struct socket *psock2);
/* net_vfcntl.c **************************************************************/
/* Performs fcntl operations on socket */
EXTERN int net_vfcntl(int sockfd, int cmd, va_list ap);
/* netdev-register.c *********************************************************/
/* This function is called by network interface device drivers to inform the
* socket layer of their existence. This registration is necesary to support

82
include/nuttx/regex.h Normal file
View File

@@ -0,0 +1,82 @@
/****************************************************************************
* include/nuttx/regex.h
* Non-standard, pattern-matching APIs available in lib/.
*
* Copyright (C) 2009 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
* 3. Neither the name NuttX nor the names of its contributors may be
* used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
****************************************************************************/
#ifndef __INCLUDE_NUTTX_REGEX_H
#define __INCLUDE_NUTTX_REGEX_H
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include <nuttx/fs.h>
/****************************************************************************
* Pre-Processor Definitions
****************************************************************************/
/****************************************************************************
* Public Function Prototypes
****************************************************************************/
#ifdef __cplusplus
#define EXTERN extern "C"
extern "C" {
#else
#define EXTERN extern
#endif
/****************************************************************************
* Name: match
*
* Description:
* Simple shell-style filename pattern matcher written by Jef Poskanzer
* (See copyright notice in lib/lib_match.c). This pattern matcher only
* handles '?', '*' and '**', and multiple patterns separated by '|'.
*
* Returned Value:
* Returns 1 (match) or 0 (no-match).
*
****************************************************************************/
EXTERN int match(const char *pattern, const char *string);
#undef EXTERN
#ifdef __cplusplus
}
#endif
#endif /* __INCLUDE_NUTTX_REGEX_H */

119
include/nuttx/time.h Normal file
View File

@@ -0,0 +1,119 @@
/****************************************************************************
* include/nuttx/time.h
*
* Copyright (C) 2009 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
* 3. Neither the name NuttX nor the names of its contributors may be
* used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
****************************************************************************/
#ifndef __INCLUDE_NUTTX_TIME_H
#define __INCLUDE_NUTTX_TIME_H
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include <sys/types.h>
#include <time.h>
/****************************************************************************
* Pre-Processor Definitions
****************************************************************************/
/* If Gregorian time is not supported, then neither is Julian */
#ifndef CONFIG_GREGORIAN_TIME
# undef CONFIG_JULIAN_TIME
#else
# define JD_OF_EPOCH 2440588 /* Julian Date of noon, J1970 */
# ifdef CONFIG_JULIAN_TIME
# define GREG_DUTC -141427 /* Default is October 15, 1582 */
# define GREG_YEAR 1582
# define GREG_MONTH 10
# define GREG_DAY 15
# endif /* CONFIG_JULIAN_TIME */
#endif /* !CONFIG_GREGORIAN_TIME */
/****************************************************************************
* Public Data
****************************************************************************/
/****************************************************************************
* Public Function Prototypes
****************************************************************************/
#ifdef __cplusplus
#define EXTERN extern "C"
extern "C" {
#else
#define EXTERN extern
#endif
/****************************************************************************
* Function: clock_isleapyear
*
* Description:
* Return true if the specified year is a leap year
*
****************************************************************************/
EXTERN int clock_isleapyear(int year);
/****************************************************************************
* Function: clock_daysbeforemonth
*
* Description:
* Get the number of days that occurred before the beginning of the month.
*
****************************************************************************/
EXTERN int clock_daysbeforemonth(int month, boolean leapyear);
/****************************************************************************
* Function: clock_calendar2utc
*
* Description:
* Calendar/UTC conversion based on algorithms from p. 604
* of Seidelman, P. K. 1992. Explanatory Supplement to
* the Astronomical Almanac. University Science Books,
* Mill Valley.
*
****************************************************************************/
EXTERN time_t clock_calendar2utc(int year, int month, int day);
#undef EXTERN
#ifdef __cplusplus
}
#endif
#endif /* __INCLUDE_NUTTX_TIME_H */

View File

@@ -33,8 +33,8 @@
*
****************************************************************************/
#ifndef __STDIO_H
#define __STDIO_H
#ifndef __INCLUDE_STDIO_H
#define __INCLUDE_STDIO_H
/****************************************************************************
* Included Files
@@ -106,6 +106,7 @@ EXTERN int fclose(FAR FILE *stream);
EXTERN int fflush(FAR FILE *stream);
EXTERN int feof(FAR FILE *stream);
EXTERN int ferror(FAR FILE *stream);
EXTERN int fileno(FAR FILE *stream);
EXTERN int fgetc(FAR FILE *stream);
EXTERN int fgetpos(FAR FILE *stream, FAR fpos_t *pos);
EXTERN char *fgets(FAR char *s, int n, FAR FILE *stream);
@@ -125,12 +126,14 @@ EXTERN int puts(FAR const char *s);
EXTERN int rename(FAR const char *oldpath, FAR const char *newpath);
EXTERN int sprintf(FAR char *buf, const char *format, ...);
EXTERN int snprintf(FAR char *buf, size_t size, const char *format, ...);
EXTERN int sscanf(const char *buf, const char *fmt, ...);
EXTERN int ungetc(int c, FAR FILE *stream);
EXTERN int vprintf(FAR const char *format, va_list ap);
EXTERN int vfprintf(FAR FILE *stream, const char *format, va_list ap);
EXTERN int vsprintf(FAR char *buf, const char *format, va_list ap);
EXTERN int vsnprintf(FAR char *buf, size_t size, const char *format, va_list ap);
EXTERN int vsscanf(char *buf, const char *s, va_list ap);
/* POSIX-like File System Interfaces */
@@ -142,4 +145,4 @@ EXTERN int statfs(FAR const char *path, FAR struct statfs *buf);
}
#endif
#endif /* __STDIO_H */
#endif /* __INCLUDE_STDIO_H */

Some files were not shown because too many files have changed in this diff Show More