2 * \file tpl_drv_disk.h
\r
3 * \brief Disk Driver Interface Definitions
\r
4 * \author John Hodge (thePowersGang)
\r
6 * \section dirs VFS Layout
\r
7 * Disk drivers have a flexible directory layout. The root directory can
\r
8 * contain subdirectories, with the only conditions being that all nodes
\r
9 * must support ::eTplDrv_IOCtl with DRV_IOCTL_TYPE returning DRV_TYPE_DISK.
\r
10 * And all file nodes representing disk devices (or partitions) and implemeting
\r
11 * ::eTplDisk_IOCtl fully
\r
13 * \section files Files
\r
14 * When a read or write occurs on a normal file in the disk driver it will
\r
15 * read/write the represented device. The accesses need not be aligned to
\r
16 * the block size, however aligned reads/writes should be handled specially
\r
17 * to improve speed (this can be aided by using ::DrvUtil_ReadBlock and
\r
18 * ::DrvUtil_WriteBlock)
\r
20 #ifndef _TPL_DRV_DISK_H
\r
21 #define _TPL_DRV_DISK_H
\r
23 #include <tpl_drv_common.h>
\r
26 * \enum eTplDisk_IOCtl
\r
27 * \brief Common Disk IOCtl Calls
\r
28 * \extends eTplDrv_IOCtl
\r
30 enum eTplDisk_IOCtl {
\r
33 * \brief Get the block size
\r
34 * \return Size of a hardware block for this device
\r
36 DISK_IOCTL_GETBLOCKSIZE = 4
\r
40 * \brief IOCtl name strings
\r
42 #define DRV_DISK_IOCTLNAMES "get_block_size"
\r
45 * \brief Callback function type used by DrvUtil_ReadBlock and DrvUtil_WriteBlock
\r
46 * \param Address Zero based block number to read
\r
47 * \param Count Number of blocks to read
\r
48 * \param Buffer Destination for read blocks
\r
49 * \param Argument Argument provided in ::DrvUtil_ReadBlock and ::DrvUtil_WriteBlock
\r
51 typedef Uint (*tDrvUtil_Callback)(Uint64 Address, Uint Count, void *Buffer, Uint Argument);
\r
54 * \brief Reads a range from a block device using aligned reads
\r
55 * \param Start Base byte offset
\r
56 * \param Length Number of bytes to read
\r
57 * \param Buffer Destination for read data
\r
58 * \param ReadBlocks Callback function to read a sequence of blocks
\r
59 * \param BlockSize Size of an individual block
\r
60 * \param Argument An argument to pass to \a ReadBlocks
\r
61 * \return Number of bytes read
\r
63 extern Uint64 DrvUtil_ReadBlock(Uint64 Start, Uint64 Length, void *Buffer,
\r
64 tDrvUtil_Callback ReadBlocks, Uint64 BlockSize, Uint Argument);
\r
66 * \brief Writes a range to a block device using aligned writes
\r
67 * \param Start Base byte offset
\r
68 * \param Length Number of bytes to write
\r
69 * \param Buffer Destination for read data
\r
70 * \param ReadBlocks Callback function to read a sequence of blocks
\r
71 * \param WriteBlocks Callback function to write a sequence of blocks
\r
72 * \param BlockSize Size of an individual block
\r
73 * \param Argument An argument to pass to \a ReadBlocks and \a WriteBlocks
\r
74 * \return Number of bytes written
\r
76 extern Uint64 DrvUtil_WriteBlock(Uint64 Start, Uint64 Length, void *Buffer,
\r
77 tDrvUtil_Callback ReadBlocks, tDrvUtil_Callback WriteBlocks,
\r
78 Uint64 BlockSize, Uint Argument);
\r