9
0
Fork 0

Add Block-to-character device driver

git-svn-id: https://nuttx.svn.sourceforge.net/svnroot/nuttx/trunk@1237 7fd9a85b-ad96-42d3-883c-3090e2eb8679
This commit is contained in:
patacongo 2008-11-15 00:18:23 +00:00
parent a2201dae59
commit 1c77cd0c64
5 changed files with 58 additions and 9 deletions

View File

@ -550,4 +550,6 @@
* Each NSH command can not be disabled through a configuration setting. All of these
settings make the configuration of NSH potentially complex but also allow it to squeeze
into very small memory footprints.
* Added a block to character (BCH) driver. This is kind of the reverse of the loop
device; it allows you access a block device like a character device.

View File

@ -1193,6 +1193,8 @@ nuttx-0.3.18 2008-xx-xx Gregory Nutt <spudmonkey@racsa.co.cr>
* Each NSH command can not be disabled through a configuration setting. All of these
settings make the configuration of NSH potentially complex but also allow it to squeeze
into very small memory footprints.
* Added a block to character (BCH) driver. This is kind of the reverse of the loop
device; it allows you access a block device like a character device.
pascal-0.1.3 2008-xx-xx Gregory Nutt <spudmonkey@racsa.co.cr>

View File

@ -53,7 +53,16 @@ ROOTDEPPATH = --dep-path .
MMCSDDEPPATH = --dep-path mmcsd
CFLAGS += ${shell $(TOPDIR)/tools/incdir.sh "$(CC)" $(TOPDIR)/drivers/mmcsd}
ASRCS = $(NET_ASRCS) $(USBDEV_ASRCS) $(MMCSD_ASRCS)
ifneq ($(CONFIG_NFILE_DESCRIPTORS),0)
ifneq ($(CONFIG_DISABLE_MOUNTPOINT),y)
include bch/Make.defs
ROOTDEPPATH = --dep-path .
BCHDEPPATH = --dep-path bch
CFLAGS += ${shell $(TOPDIR)/tools/incdir.sh "$(CC)" $(TOPDIR)/drivers/bch}
endif
endif
ASRCS = $(NET_ASRCS) $(USBDEV_ASRCS) $(MMCSD_ASRCS) $(BCH_ASRCS)
AOBJS = $(ASRCS:.S=$(OBJEXT))
CSRCS =
@ -64,7 +73,7 @@ ifneq ($(CONFIG_DISABLE_MOUNTPOINT),y)
CSRCS += ramdisk.c
endif
endif
CSRCS += $(NET_CSRCS) $(USBDEV_CSRCS) $(MMCSD_CSRCS)
CSRCS += $(NET_CSRCS) $(USBDEV_CSRCS) $(MMCSD_CSRCS) $(BCH_CSRCS)
COBJS = $(CSRCS:.c=$(OBJEXT))
SRCS = $(ASRCS) $(CSRCS)
@ -72,7 +81,7 @@ OBJS = $(AOBJS) $(COBJS)
BIN = libdrivers$(LIBEXT)
VPATH = net:usbdev:mmcsd
VPATH = net:usbdev:mmcsd:bch
all: $(BIN)
@ -88,7 +97,7 @@ $(BIN): $(OBJS)
done ; )
.depend: Makefile $(SRCS)
@$(MKDEP) $(ROOTDEPPATH) $(NETDEPPATH) $(USBDEVDEPPATH) $(MMCSDDEPPATH) \
@$(MKDEP) $(ROOTDEPPATH) $(NETDEPPATH) $(USBDEVDEPPATH) $(MMCSDDEPPATH) $(BCHDEPPATH) \
$(CC) -- $(CFLAGS) -- $(SRCS) >Make.dep
@touch $@

View File

@ -370,8 +370,28 @@ EXTERN int lib_flushall(FAR struct streamlist *list);
* subdirectory
*/
/* Register /dev/null */
EXTERN void devnull_register(void);
EXTERN int losetup(const char *name, int minor, uint16 sectsize);
/* Setup the loop device so that it exports the file referenced by 'filename'
* as a block device.
*/
EXTERN int losetup(const char *devname, const char *filename, uint16 sectsize,
off_t offset, boolean readonly);
EXTERN int loteardown(const char *devname);
/* Setup so that the block driver referenced by 'blkdev' can be accessed
* similar to a character device.
*/
EXTERN int bchdev_register(const char *blkdev, const char *chardev, boolean readonly);
EXTERN int bchdev_unregister(const char *chardev);
EXTERN int bchlib_setup(const char *blkdev, boolean readonly, FAR void **handle);
EXTERN int bchlib_teardown(FAR void *handle);
EXTERN ssize_t bchlib_read(FAR void *handle, FAR char *buffer, size_t offset, size_t len);
EXTERN ssize_t bchlib_write(FAR void *handle, FAR const char *buffer, size_t offset, size_t len);
#undef EXTERN
#if defined(__cplusplus)

View File

@ -53,8 +53,9 @@
*/
#define _FIOCBASE (0x8700) /* File system ioctl commands */
#define _BIOCBASE (0x8800) /* Block driver ioctl commands */
#define _SIOCBASE (0x8900) /* Socket ioctl commandss */
#define _DIOCBASE (0x8800) /* Character driver ioctl commands */
#define _BIOCBASE (0x8900) /* Block driver ioctl commands */
#define _SIOCBASE (0x8a00) /* Socket ioctl commandss */
/* Macros used to manage ioctl commands */
@ -69,10 +70,25 @@
#define _FIOCVALID(c) (_IOC_TYPE(c)==_FIOCBASE)
#define _FIOC(nr) _IOC(_FIOCBASE,nr)
#define FIOC_MMAP _FIOC(0x0001) /* IN: None
#define FIOC_MMAP _FIOC(0x0001) /* IN: Location to return address (void **)
* OUT: If media is directly acccesible,
* return (void*) base address
* of file */
* of file
*/
/* NuttX file system ioctl definitions */
#define _DIOCVALID(c) (_IOC_TYPE(c)==_DIOCBASE)
#define _DIOC(nr) _IOC(_DIOCBASE,nr)
#define DIOC_GETPRIV _DIOC(0x0001) /* IN: Location to return handle (void **)
* OUT: Reference to internal data
* structure. May have a reference
* incremented.
*/
#define DIOC_RELPRIV _DIOC(0x0003) /* IN: None
* OUT: None, reference obtained by
* FIOC_GETPRIV released.
*/
/* NuttX block driver ioctl definitions */