From 3899a5379f4bfa067e73b4612a547a308a6634ec Mon Sep 17 00:00:00 2001 From: Chris Johns Date: Tue, 29 Jul 2008 02:21:15 +0000 Subject: 2008-07-29 Chris Johns * libblock/Makefile.am: Removed src/show_bdbuf.c. * libblock/src/show_bdbuf.c: Removed. * libblock/include/rtems/bdbuf.h, cpukit/libblock/src/bdbuf.c: Rewritten the bdbuf code. Remove pre-emption disable, score access, fixed many bugs and increased performance. * libblock/include/rtems/blkdev.h: Added RTEMS_BLKDEV_CAPABILITIES block device request. Cleaned up comments. Added block and user fields to the sg buffer request. Move to rtems_* namespace. * libblock/include/rtems/diskdevs.h, cpukit/libblock/src/diskdevs.c: Move to rtems_* namespace. Add a capabilities field for drivers. Change rtems_disk_lookup to rtems_disk_obtain to match the release call. You do not lookup and release a disk, you obtain and release a disk. * libblock/include/rtems/ide_part_table.h, libblock/include/rtems/ramdisk.h, libblock/src/ide_part_table.c: Move to rtems_* namespace. * libblock/include/rtems/nvdisk.h: Formatting change. * libblock/src/blkdev.c: Move to rtems_* namespace. Change rtems_disk_lookup to rtems_disk_obtain * libblock/src/flashdisk.c: Move to rtems_* namespace. Use the new support for the block number in the scatter/grather request struct. This allows non-continuous buffer requests for those drivers that can support increasing performance. * libblock/src/nvdisk.c: Move to rtems_* namespace. Removed warnings. Added better error checking. Fixed some comments. * libblock/src/ramdisk.c: Move to rtems_* namespace. Added some trace functions to help debugging upper layers. Use the new support for the block number in the scatter/grather request struct. This allows non-continuous buffer requests for those drivers that can support increasing performance. * libfs/src/dosfs/fat.c, libfs/src/dosfs/fat.h: Use new chains API. Removed temporary hack and changed set_errno_and_return_minus_one to rtems_set_errno_and_return_minus_one. Move fat_buf_access from header and stopped it being inlined. Updated to libblock changes. * libfs/src/dosfs/fat_fat_operations.c, libfs/src/dosfs/fat_file.c, libfs/src/dosfs/msdos_create.c, libfs/src/dosfs/msdos_dir.c, libfs/src/dosfs/msdos_eval.c, libfs/src/dosfs/msdos_file.c, libfs/src/dosfs/msdos_format.c, libfs/src/dosfs/msdos_free.c, libfs/src/dosfs/msdos_initsupp.c, libfs/src/dosfs/msdos_misc.c, libfs/src/dosfs/msdos_mknod.c: Use new chains API. Removed temporary hack and changed set_errno_and_return_minus_one to rtems_set_errno_and_return_minus_one. Updated to libblock changes. * libmisc/Makefile.am: Add new ls and rm command files. * libmisc/shell/cmp-ls.c, libmisc/shell/extern-ls.h, libmisc/shell/filemode.c, libmisc/shell/print-ls.c, libmisc/shell/pwcache.c, libmisc/shell/utils-ls.c, libmisc/shell/vis.c, shell/vis.h: New. * libmisc/shell/extern-cp.h, libmisc/shell/main_cp.c, libmisc/shell/utils-cp.c: Fixed the usage call bug. * libmisc/shell/main_blksync.c: Updated to the new block IO ioctl command. * libmisc/shell/main_ls.c, libmisc/shell/main_rm.c: Updated to BSD commands with more features. * score/src/coremutex.c: Fix the strick order mutex code. * libmisc/shell/shell.c: Change shell tasks mode to be timeslice and no ASR. * sapi/include/confdefs.h: Change ata_driver_task_priority to rtems_ata_driver_task_priority. Add the new BD buf cache parameters with defaults. * score/src/interr.c: Do not return if the CPU halt call returns. --- cpukit/libblock/src/ramdisk.c | 72 ++++++++++++++++++++++++++++++++++++------- 1 file changed, 61 insertions(+), 11 deletions(-) (limited to 'cpukit/libblock/src/ramdisk.c') diff --git a/cpukit/libblock/src/ramdisk.c b/cpukit/libblock/src/ramdisk.c index b72e3ae795..3b3f3f29b0 100644 --- a/cpukit/libblock/src/ramdisk.c +++ b/cpukit/libblock/src/ramdisk.c @@ -22,6 +22,14 @@ #include "rtems/diskdevs.h" #include "rtems/ramdisk.h" +/** + * Control tracing. It can be compiled out of the code for small + * footprint targets. Leave in by default. + */ +#if !defined (RTEMS_RAMDISK_TRACE) +#define RTEMS_RAMDISK_TRACE 0 +#endif + #define RAMDISK_DEVICE_BASE_NAME "/dev/ramdisk" /* Internal RAM disk descriptor */ @@ -32,11 +40,40 @@ struct ramdisk { rtems_boolean initialized;/* RAM disk is initialized */ rtems_boolean malloced; /* != 0, if memory allocated by malloc for this RAM disk */ +#if RTEMS_RAMDISK_TRACE + int info_level; /* Trace level */ +#endif }; static struct ramdisk *ramdisk; static int nramdisks; +#if RTEMS_RAMDISK_TRACE +/** + * Print a message to the ramdisk output and flush it. + * + * @param rd The ramdisk control structure. + * @param format The format string. See printf for details. + * @param ... The arguments for the format text. + * @return int The number of bytes written to the output. + */ +static int +rtems_ramdisk_printf (struct ramdisk *rd, const char *format, ...) +{ + int ret = 0; + if (rd->info_level >= 1) + { + va_list args; + va_start (args, format); + fprintf (stdout, "ramdisk:"); + ret = vfprintf (stdout, format, args); + fprintf (stdout, "\n"); + fflush (stdout); + } + return ret; +} +#endif + /* ramdisk_read -- * RAM disk READ request handler. This primitive copies data from RAM * disk to supplied buffer and invoke the callout function to inform @@ -49,19 +86,25 @@ static int nramdisks; * ioctl return value */ static int -ramdisk_read(struct ramdisk *rd, blkdev_request *req) +ramdisk_read(struct ramdisk *rd, rtems_blkdev_request *req) { char *from; uint32_t i; - blkdev_sg_buffer *sg; + rtems_blkdev_sg_buffer *sg; uint32_t remains; - from = (char *)rd->area + (req->start * rd->block_size); +#if RTEMS_RAMDISK_TRACE + rtems_ramdisk_printf (rd, "ramdisk read: start=%d, blocks=%d remains=%d", + req->bufs[0].block, req->bufnum, + rd->block_size * req->count); +#endif + remains = rd->block_size * req->count; sg = req->bufs; for (i = 0; (remains > 0) && (i < req->bufnum); i++, sg++) { int count = sg->length; + from = ((char *)rd->area + (sg->block * rd->block_size)); if (count > remains) count = remains; memcpy(sg->buffer, from, count); @@ -84,19 +127,24 @@ ramdisk_read(struct ramdisk *rd, blkdev_request *req) * ioctl return value */ static int -ramdisk_write(struct ramdisk *rd, blkdev_request *req) +ramdisk_write(struct ramdisk *rd, rtems_blkdev_request *req) { char *to; uint32_t i; - blkdev_sg_buffer *sg; + rtems_blkdev_sg_buffer *sg; uint32_t remains; - to = (char *)rd->area + (req->start * rd->block_size); +#if RTEMS_RAMDISK_TRACE + rtems_ramdisk_printf (rd, "ramdisk write: start=%d, blocks=%d remains=%d", + req->bufs[0].block, req->bufnum, + rd->block_size * req->count); +#endif remains = rd->block_size * req->count; sg = req->bufs; for (i = 0; (remains > 0) && (i < req->bufnum); i++, sg++) { int count = sg->length; + to = ((char *)rd->area + (sg->block * rd->block_size)); if (count > remains) count = remains; memcpy(to, sg->buffer, count); @@ -123,10 +171,10 @@ ramdisk_ioctl(dev_t dev, uint32_t req, void *argp) { switch (req) { - case BLKIO_REQUEST: + case RTEMS_BLKIO_REQUEST: { rtems_device_minor_number minor; - blkdev_request *r = argp; + rtems_blkdev_request *r = argp; struct ramdisk *rd; minor = rtems_filesystem_dev_minor_t(dev); @@ -140,10 +188,10 @@ ramdisk_ioctl(dev_t dev, uint32_t req, void *argp) switch (r->req) { - case BLKDEV_REQ_READ: + case RTEMS_BLKDEV_REQ_READ: return ramdisk_read(rd, r); - case BLKDEV_REQ_WRITE: + case RTEMS_BLKDEV_REQ_WRITE: return ramdisk_write(rd, r); default: @@ -188,7 +236,9 @@ ramdisk_initialize( r = ramdisk = calloc(rtems_ramdisk_configuration_size, sizeof(struct ramdisk)); - +#if RTEMS_RAMDISK_TRACE + r->info_level = 1; +#endif for (i = 0; i < rtems_ramdisk_configuration_size; i++, c++, r++) { dev_t dev = rtems_filesystem_make_dev_t(major, i); -- cgit v1.2.3