Block device driver definitions. More...
Go to the source code of this file.
Data Structures | |
struct | _BLKPAR_SEEK |
Block seek parameter structure. More... | |
struct | _BLKPAR_INFO |
Device information parameter structure. More... | |
struct | _NUTBLOCKIO |
Generic block I/O device interface structure. More... | |
Typedefs | |
typedef struct _BLKPAR_SEEK | BLKPAR_SEEK |
Block seek parameter structure. | |
typedef struct _BLKPAR_INFO | BLKPAR_INFO |
Device information parameter structure. | |
typedef struct _NUTBLOCKIO | NUTBLOCKIO |
Generic block I/O device interface structure type. | |
Functions | |
int | NutBlockDeviceInit (NUTDEVICE *dev) |
Initialize the block I/O device. | |
NUTFILE * | NutBlockDeviceOpen (NUTDEVICE *dev, CONST char *name, int mode, int acc) |
Mount a volume. | |
int | NutBlockDeviceClose (NUTFILE *nfp) |
Unmount a currently mounted volume. | |
int | NutBlockDeviceIOCtl (NUTDEVICE *dev, int req, void *conf) |
Perform block I/O device control functions. | |
int | NutBlockDeviceRead (NUTFILE *nfp, void *buffer, int num) |
Read data blocks from a mounted volume. | |
int | NutBlockDeviceWrite (NUTFILE *nfp, CONST void *buffer, int num) |
Write data blocks to a mounted volume. | |
long | NutBlockDeviceSize (NUTFILE *nfp) |
Return the size of a mounted volume. | |
int | NutBlockDeviceWrite_P (NUTFILE *nfp, PGM_P buffer, int num) |
Write data blocks from program space to a mounted volume. | |
Control Codes | |
#define | NUTBLKDEV_MEDIAAVAIL 0x1200 |
Query for media change. | |
#define | NUTBLKDEV_MEDIACHANGE 0x1201 |
Query for media change. | |
#define | NUTBLKDEV_INFO 0x1202 |
Retrieve device information. | |
#define | NUTBLKDEV_SEEK 0x1203 |
Block seek request. |
Block device driver definitions.
* * $Log$ * Revision 1.4 2009/01/09 17:59:05 haraldkipp * Added target independent AT45D block device drivers and non-volatile * memory support based on the new bus controllers. * * Revision 1.3 2008/08/11 06:59:59 haraldkipp * BSD types replaced by stdint types (feature request #1282721). * * Revision 1.2 2006/04/07 12:57:48 haraldkipp * Added ioctl(NUTBLKDEV_MEDIAAVAIL). * * Revision 1.1 2006/01/05 16:32:05 haraldkipp * First check-in. * * *
Definition in file blockdev.h.
int NutBlockDeviceInit | ( | NUTDEVICE * | dev | ) |
Initialize the block I/O device.
This dummy routine may be used by drivers, which do not need any specific initialization.
dev | Specifies the device. |
Definition at line 131 of file blockdev.c.
References NUTASSERT.
Mount a volume.
Nut/OS doesn't provide specific routines for mounting. Instead routines for opening files are used.
Applications should not directly call this function, but use the high level stdio routines for opening a file.
dev | Specifies the block I/O device. |
name | Partition number followed by a slash followed by a name of the file system device. Both items are optional. If no file system driver name is given, the first file system driver found in the list of registered devices will be used. If no partition number is specified or if partition zero is given, the first active primary partition will be used. |
mode | Opening mode. Currently ignored, but should be used for compatibility with future enhancements. |
acc | File attributes, ignored. |
Definition at line 163 of file blockdev.c.
References _NUTBLOCKIO::blkio_blk_cnt, _NUTBLOCKIO::blkio_blk_siz, _NUTBLOCKIO::blkio_vol_bot, _NUTBLOCKIO::blkio_vol_top, _NUTDEVICE::dev_dcb, _NUTDEVICE::dev_ioctl, ENODEV, errno, free(), FS_VOL_MOUNT, _FSCP_VOL_MOUNT::fscp_bmnt, _FSCP_VOL_MOUNT::fscp_part_type, IFTYP_FS, malloc(), _NUTFILE::nf_dev, _NUTFILE::nf_fcb, _NUTFILE::nf_next, NUTASSERT, NutDeviceLookup(), NUTFILE_EOF, _BLOCKVOLUME::vol_blk_buf, _BLOCKVOLUME::vol_blk_cnt, _BLOCKVOLUME::vol_blk_len, _BLOCKVOLUME::vol_blk_num, _BLOCKVOLUME::vol_blk_off, and _BLOCKVOLUME::vol_fsdev.
int NutBlockDeviceClose | ( | NUTFILE * | nfp | ) |
Unmount a currently mounted volume.
nfp | File pointer to a previously mounted volume. |
Definition at line 241 of file blockdev.c.
References _NUTDEVICE::dev_ioctl, free(), FS_VOL_UNMOUNT, _NUTFILE::nf_fcb, NUTASSERT, and _BLOCKVOLUME::vol_fsdev.
int NutBlockDeviceIOCtl | ( | NUTDEVICE * | dev, |
int | req, | ||
void * | conf | ||
) |
Perform block I/O device control functions.
This function is called by the ioctl() function of the C runtime library. Applications should not directly call this function.
Unkown requests are passed to the block I/O device.
dev | Identifies the device that receives the device-control function. |
req | Requested control function. May be set to one of the following constants:
|
conf | Points to a buffer that contains any data required for the given control function or receives data from that function. |
Definition at line 280 of file blockdev.c.
References _NUTBLOCKIO::blkio_ioctl, _NUTDEVICE::dev_dcb, _NUTFILE::nf_fcb, NUTASSERT, NUTBLKDEV_INFO, NUTBLKDEV_SEEK, _BLKPAR_INFO::par_blkbp, _BLKPAR_SEEK::par_blknum, _BLKPAR_INFO::par_blksz, _BLKPAR_INFO::par_nblks, _BLKPAR_SEEK::par_nfp, _BLKPAR_INFO::par_nfp, _BLOCKVOLUME::vol_blk_buf, _BLOCKVOLUME::vol_blk_cnt, _BLOCKVOLUME::vol_blk_len, and _BLOCKVOLUME::vol_blk_num.
int NutBlockDeviceRead | ( | NUTFILE * | nfp, |
void * | buffer, | ||
int | num | ||
) |
Read data blocks from a mounted volume.
The current position may have been set by a previous I/O control NUTBLKDEV_SEEK.
Applications should not call this function directly, but use the stdio interface.
nfp | File pointer to a previously mounted volume. |
buffer | Pointer to the data buffer to fill. |
num | Number of blocks to read. |
Definition at line 348 of file blockdev.c.
References _NUTBLOCKIO::blkio_read, _NUTDEVICE::dev_dcb, _NUTFILE::nf_dev, _NUTFILE::nf_fcb, NUTASSERT, _BLOCKVOLUME::vol_blk_cnt, _BLOCKVOLUME::vol_blk_len, _BLOCKVOLUME::vol_blk_num, and _BLOCKVOLUME::vol_blk_off.
int NutBlockDeviceWrite | ( | NUTFILE * | nfp, |
CONST void * | buffer, | ||
int | num | ||
) |
Write data blocks to a mounted volume.
The current position may have been set by a previous I/O control NUTBLKDEV_SEEK.
Applications should not call this function directly, but use the stdio interface.
nfp | File pointer to a previously mounted volume. |
buffer | Pointer to the data to be written. |
num | Number of blocks to write. |
Definition at line 400 of file blockdev.c.
References _NUTBLOCKIO::blkio_write, CONST, _NUTDEVICE::dev_dcb, _NUTFILE::nf_dev, _NUTFILE::nf_fcb, NUTASSERT, _BLOCKVOLUME::vol_blk_cnt, _BLOCKVOLUME::vol_blk_len, _BLOCKVOLUME::vol_blk_num, and _BLOCKVOLUME::vol_blk_off.
long NutBlockDeviceSize | ( | NUTFILE * | nfp | ) |
Return the size of a mounted volume.
nfp | File pointer to a previously mounted volume. |
Definition at line 495 of file blockdev.c.
References _NUTFILE::nf_fcb, NUTASSERT, _BLOCKVOLUME::vol_blk_cnt, and _BLOCKVOLUME::vol_blk_len.
int NutBlockDeviceWrite_P | ( | NUTFILE * | nfp, |
PGM_P | buffer, | ||
int | num | ||
) |
Write data blocks from program space to a mounted volume.
Similar to NutBlockDeviceWrite() except that the data is located in program memory.
Applications should not call this function directly, but use the stdio interface.
nfp | File pointer to a previously mounted volume. |
buffer | Pointer to the data bytes in program space to be written. |
num | Number of blocks to write. |
Definition at line 452 of file blockdev.c.
References _NUTBLOCKIO::blkio_write, _NUTBLOCKIO::blkio_write_P, _NUTDEVICE::dev_dcb, _NUTFILE::nf_dev, _NUTFILE::nf_fcb, NUTASSERT, PGM_P, _BLOCKVOLUME::vol_blk_cnt, _BLOCKVOLUME::vol_blk_len, _BLOCKVOLUME::vol_blk_num, and _BLOCKVOLUME::vol_blk_off.