fileio w/o kernel
Andrew Lunn
andrew@lunn.ch
Sun Nov 14 14:03:00 GMT 2004
On Fri, Nov 12, 2004 at 05:10:13PM +0200, Jani Monoses wrote:
> Hello
>
> this patch makes fileio (more exactly devfs ) compile without the kernel.
> It did not have an actual dependency on it but some kernel headers were
> included nonetheless. Also make the fileio tests build w/o kernel.
Committed.
> Was there a reason for using a thread in fat/tests/fileio instead of
> regular main startup?
Not that i can see. It works OK your way, which is the same as for
romfs, ramfs & jffs2. However, main() is only called by the kernel. If
you don't have a kernel you need to use cyg_start() or
cyg_user_start(). Since you are trying to make this work without the
kernel it makes sense to change this to cyg_start() not main. You
might want to change the tests in fat, ram, rom & jffs2 as well.
> With the other tests in fileio which need the kernel (socket and testfs) I
> am not sure which patch to take: make their building conditional in the CDL
> or put ifdefs in them so they build but print NOT_AVALAIBLE at runtime.
> Which is the preferred method?
Well it looks like testfs just needs cyg_current_time() for setting
the time in the file inodes. I did a quick test of using 0 if there is
no kernel which seems to work OK. Given how fast these tests run, its
unlikely cyg_current_time() is returning anything other than 0 anyway!
For socket its best to make use of CYG_TEST_NA().
Andrew
-------------- next part --------------
Index: io/fileio/current/ChangeLog
===================================================================
RCS file: /cvs/ecos/ecos/packages/io/fileio/current/ChangeLog,v
retrieving revision 1.49
diff -u -r1.49 ChangeLog
--- io/fileio/current/ChangeLog 22 Oct 2004 14:07:49 -0000 1.49
+++ io/fileio/current/ChangeLog 14 Nov 2004 14:01:29 -0000
@@ -1,3 +1,15 @@
+2004-11-14 Andrew Lunn <andrew.lunn@ascom.ch>
+
+ * tests/fileio1.c: Start the test using cyg_user_start so that
+ it can be used without the kernel.
+ * tests/testfs.c (testfs_time): If we don't have a kernel return 0
+ as the time rather than the current time.
+
+2004-11-14 Jani Monoses <jani@iv.ro>
+
+ * src/devfs.cxx: Removed unneeded header files so the package can
+ be compiled without the kernel.
+
2004-10-13 David Brennan <eCos@brennanhome.com>
* include/fileio.h:
Index: io/fileio/current/src/devfs.cxx
===================================================================
RCS file: /cvs/ecos/ecos/packages/io/fileio/current/src/devfs.cxx,v
retrieving revision 1.7
diff -u -r1.7 devfs.cxx
--- io/fileio/current/src/devfs.cxx 6 Oct 2003 18:45:23 -0000 1.7
+++ io/fileio/current/src/devfs.cxx 14 Nov 2004 14:01:30 -0000
@@ -56,10 +56,8 @@
//==========================================================================
#include <pkgconf/hal.h>
-#include <pkgconf/kernel.h>
#include <pkgconf/io_fileio.h>
-#include <cyg/kernel/ktypes.h> // base kernel types
#include <cyg/infra/cyg_trac.h> // tracing macros
#include <cyg/infra/cyg_ass.h> // assertion macros
Index: io/fileio/current/tests/fileio1.c
===================================================================
RCS file: /cvs/ecos/ecos/packages/io/fileio/current/tests/fileio1.c,v
retrieving revision 1.5
diff -u -r1.5 fileio1.c
--- io/fileio/current/tests/fileio1.c 16 Apr 2004 03:33:18 -0000 1.5
+++ io/fileio/current/tests/fileio1.c 14 Nov 2004 14:01:30 -0000
@@ -58,10 +58,8 @@
//==========================================================================
#include <pkgconf/hal.h>
-#include <pkgconf/kernel.h>
#include <pkgconf/io_fileio.h>
-#include <cyg/kernel/ktypes.h> // base kernel types
#include <cyg/infra/cyg_trac.h> // tracing macros
#include <cyg/infra/cyg_ass.h> // assertion macros
@@ -357,7 +355,7 @@
//==========================================================================
// main
-int main( int argc, char **argv )
+int cyg_user_start(void)
{
int err;
Index: io/fileio/current/tests/testfs.c
===================================================================
RCS file: /cvs/ecos/ecos/packages/io/fileio/current/tests/testfs.c,v
retrieving revision 1.3
diff -u -r1.3 testfs.c
--- io/fileio/current/tests/testfs.c 23 May 2002 23:06:13 -0000 1.3
+++ io/fileio/current/tests/testfs.c 14 Nov 2004 14:01:32 -0000
@@ -58,10 +58,8 @@
//==========================================================================
#include <pkgconf/hal.h>
-#include <pkgconf/kernel.h>
#include <pkgconf/io_fileio.h>
-#include <cyg/kernel/ktypes.h> // base kernel types
#include <cyg/infra/cyg_trac.h> // tracing macros
#include <cyg/infra/cyg_ass.h> // assertion macros
@@ -73,7 +71,6 @@
#include <cyg/fileio/fileio.h>
-#include <cyg/kernel/kapi.h>
#include <cyg/infra/diag.h>
//==========================================================================
@@ -351,8 +348,11 @@
static time_t testfs_time(void)
{
- // FIXME: !!!!Temporary!!!!
+#ifdef CYGPKG_KERNEL
return cyg_current_time();
+#else
+ return 0;
+#endif
}
// -------------------------------------------------------------------------
Index: fs/fat/current/ChangeLog
===================================================================
RCS file: /cvs/ecos/ecos/packages/fs/fat/current/ChangeLog,v
retrieving revision 1.6
diff -u -r1.6 ChangeLog
--- fs/fat/current/ChangeLog 11 Nov 2004 19:33:29 -0000 1.6
+++ fs/fat/current/ChangeLog 14 Nov 2004 14:01:33 -0000
@@ -1,3 +1,8 @@
+2004-11-14 Jani Monoses <jani@iv.ro>
+
+ * test/fileio1.c: Start the test using main, not via a
+ thread. This makes is more uniform with the other fileio1 tests.
+
2004-11-11 David Brennan <eCos@brennanhome.com>
* src/fatfs.c: fixed typos in TRACE statements
Index: fs/fat/current/tests/fileio1.c
===================================================================
RCS file: /cvs/ecos/ecos/packages/fs/fat/current/tests/fileio1.c,v
retrieving revision 1.4
diff -u -r1.4 fileio1.c
--- fs/fat/current/tests/fileio1.c 26 Oct 2004 08:00:09 -0000 1.4
+++ fs/fat/current/tests/fileio1.c 14 Nov 2004 14:01:33 -0000
@@ -58,11 +58,9 @@
//==========================================================================
#include <pkgconf/hal.h>
-#include <pkgconf/kernel.h>
#include <pkgconf/io_fileio.h>
#include <pkgconf/fs_fat.h>
-#include <cyg/kernel/ktypes.h> // base kernel types
#include <cyg/infra/cyg_trac.h> // tracing macros
#include <cyg/infra/cyg_ass.h> // assertion macros
@@ -429,7 +427,7 @@
//==========================================================================
// main
-void fileio1_main( CYG_ADDRESS id )
+int main( int argc, char **argv )
{
int err;
int existingdirents=-1;
@@ -744,29 +742,4 @@
}
// -------------------------------------------------------------------------
-
-#include <cyg/kernel/kapi.h>
-
-static char stack[CYGNUM_HAL_STACK_SIZE_TYPICAL];
-static cyg_handle_t thread_handle;
-static cyg_thread thread;
-
-externC void
-cyg_start( void )
-{
- cyg_thread_create(3, // Priority - just a number
- fileio1_main, // entry
- 0, // index
- 0, // no name
- &stack[0], // Stack
- sizeof(stack), // Size
- &thread_handle, // Handle
- &thread // Thread data structure
- );
- cyg_thread_resume(thread_handle);
-
- cyg_scheduler_start();
-}
-
-// -------------------------------------------------------------------------
// EOF fileio1.c
More information about the Ecos-patches
mailing list