Update of /cvsroot/blob/blob/src/lib
In directory sc8-pr-cvs1:/tmp/cvs-serv25435
Modified Files:
generic_io.c
Log Message:
- put ram driver into a separate file
Index: generic_io.c
===================================================================
RCS file: /cvsroot/blob/blob/src/lib/generic_io.c,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- generic_io.c 13 May 2002 09:37:41 -0000 1.6
+++ generic_io.c 3 Apr 2003 14:21:23 -0000 1.7
@@ -45,7 +45,6 @@
* Defines / Makros
*/
-#define IO_MODULE_TEST 0
#define IO_DEBUG 1
#undef IO_QUIET
@@ -86,9 +85,6 @@
/**********************************************************************
* Prototypen
*/
-static int ram_io_conf( io_driver_t * io, void *conf );
-static int ram_io_read( unsigned char *dest, unsigned char *src, size_t amount, io_driver_t *io );
-static int ram_io_write( unsigned char *dest, unsigned char *src, size_t amount, io_driver_t *io );
/**********************************************************************
* Exported functions
@@ -284,7 +280,7 @@
/* read from source */
ret = io_read( buffer, adr, to_copy, src );
if ( ret ) {
- DBG( 1, "%s: read failed at block %d (adr %p).\n",
+ DBG( 1, "\n%s: read failed at block %d (adr %p).\n",
__FUNCTION__, block, adr );
return -EINVAL;
}
@@ -292,7 +288,7 @@
/* write to dest */
ret = io_write( adr, buffer, to_copy, dest );
if ( ret ) {
- DBG( 1, "%s: write failed at block %d (adr %p).\n",
+ DBG( 1, "\n%s: write failed at block %d (adr %p).\n",
__FUNCTION__, block, adr );
return -EINVAL;
}
@@ -301,111 +297,9 @@
adr += to_copy;
}
- return 0;
-}
-
-
-/**********************************************************************
- * A simple RAM driver
- * - io driver for RAM access
- */
-int ram_io_init( io_driver_t *io, ram_io_t *ram )
-{
- if ( !io || !ram )
- return -EINVAL;
-
- io->private_data = (void *)ram;
- io->io_size = ram->len - ram->pos;
- io->conf = ram_io_conf;
- io->read = ram_io_read;
- io->write = ram_io_write;
- io->child_io = NULL;
-
- return 0;
-}
-
-static int ram_io_conf( io_driver_t * io, void *conf )
-{
- ram_io_t *ram;
-
- if ( !io || !conf )
- return -EINVAL;
-
- ram = (ram_io_t*)io->private_data;
- if ( !ram )
- return -EINVAL;
-
- if ( (u32)conf >= ram->len )
- return -EINVAL;
-
- ram->pos = (u32)conf;
-
- io->io_size = ram->len - (u32)ram->pos;
-
- return 0;
-}
-
-static int ram_io_read( unsigned char *dest, unsigned char *src, size_t amount, io_driver_t *io )
-{
- u32 offset;
- ram_io_t *ram;
-
- DBG( 1, "%s: dest=%p, src=%p, amount=%d, io=%p\n", __FUNCTION__,
- dest, src, amount, io );
-
- if ( !io || !dest )
- return -EINVAL;
-
- ram = (ram_io_t*)io->private_data;
- if ( !ram )
- return -EINVAL;
-
- offset = ram->start + (u32)ram->pos;
-
- DBG( 1, "%s: dest=%p, src=%p(=%p), amount=%d, io=%p\n", __FUNCTION__,
- dest, src, (void*)(src +offset), amount, io );
-
- memcpy( dest, (void *)(offset + (u32)src), amount);
-
- return 0;
-}
-
-static int ram_io_write( unsigned char *dest, unsigned char *src, size_t amount, io_driver_t *io )
-{
- u32 offset;
- ram_io_t *ram;
-
-
- if ( !io || !src )
- return -EINVAL;
-
- ram = (ram_io_t*)io->private_data;
- if ( !ram )
- return -EINVAL;
-
- offset = ram->start + (u32)ram->pos;
-
- DBG( 1, "%s: dest=%p(=%p), src=%p, amount=%d, io=%p\n", __FUNCTION__,
- dest, (void*)(dest +offset), src, amount, io );
-
- memcpy((void *)(offset + (u32)dest), src, amount);
-
- return 0;
-}
-
-#if defined(IO_MODULE_TEST)
-/**********************************************************************
- * module test function
- */
-int io_test( void )
-{
- int ret = 0;
-
- DBG( 1, "%s: version %s\n", __FUNCTION__, module_version );
-
- ret = io_copy( "RAM1", "RAM0", 768 );
- if ( ret ) return -EINVAL;
+#if !defined(IO_QUIET)
+ printf("\n");
+#endif
return 0;
}
-#endif
|