X-Git-Url: https://git.ucc.asn.au/?a=blobdiff_plain;f=Kernel%2Finclude%2Ftpl_drv_disk.h;h=47efb0499cabccc3800c0317a62bc4ce4fa46aa1;hb=de2ae10743172075f2d527780bdfd890ccddb8e7;hp=d459aced249f975d6b522f7d0c4c2ea58c1b3188;hpb=1e7db40300bc594cf708bb6082a6e05a268da946;p=tpg%2Facess2.git diff --git a/Kernel/include/tpl_drv_disk.h b/Kernel/include/tpl_drv_disk.h index d459aced..47efb049 100644 --- a/Kernel/include/tpl_drv_disk.h +++ b/Kernel/include/tpl_drv_disk.h @@ -3,6 +3,10 @@ * \brief Disk Driver Interface Definitions * \author John Hodge (thePowersGang) * + * \section Nomeclature + * All addreses are 64-bit counts of bytes from the logical beginning of + * the disk unless explicitly stated. + * * \section dirs VFS Layout * Disk drivers have a flexible directory layout. The root directory can * contain subdirectories, with the only conditions being that all nodes @@ -33,13 +37,109 @@ enum eTplDisk_IOCtl { * \brief Get the block size * \return Size of a hardware block for this device */ - DISK_IOCTL_GETBLOCKSIZE = 4 + DISK_IOCTL_GETBLOCKSIZE = 4, + + /** + * ioctl(..., tTplDisk_CacheRegion *RegionInfo) + * \brief Sets the cache importantce and protocol for a section of + * memory. + * \param RegionInfo Pointer to a region information structure + * \return Boolean failure + */ + DISK_IOCTL_SETCACHEREGION, + + /** + * ioctl(..., Uint64 *Info[2]) + * \brief Asks the driver to precache a region of disk. + * \param Region 64-bit Address and Size pair describing the area to cache + * \return Number of blocks cached + */ + DISK_IOCTL_PRECACHE, + + /** + * ioclt(..., Uint64 *Region[2]) + * \brief Asks to driver to flush the region back to disk + * \param Region 64-bit Address and Size pair describing the area to flush + * \note If Region[0] == -1 then the entire disk's cache is flushed + * \return Number of blocks flushed (or 0 for entire disk) + */ + DISK_IOCTL_FLUSH +}; + +/** + * \brief Describes the cache parameters of a region on the disk + */ +typedef struct sTplDisk_CacheRegion +{ + Uint64 Base; //!< Base of cache region + Uint64 Length; //!< Size of cache region + /** + * \brief Cache Protocol & Flags + * + * The low 4 bits denot the cache protocol to be used by the + * region (see ::eTplDisk_CacheProtocols for a list). + * The high 4 bits denote flags to apply to the cache (see + * ::eTplDisk_CacheFlags) + */ + Uint8 Flags; + Uint8 Priority; //!< Lower is a higher proritory + /** + * \brief Maximum size of cache, in blocks + * \note If CacheSize is zero, the implemenation defined limit is used + */ + Uint16 CacheSize; +} tTplDisk_CacheRegion; + +/** + * \brief Cache protocols to use + */ +enum eTplDisk_CacheProtocols +{ + /** + * \brief Don't cache the region + */ + + DISK_CACHEPROTO_DONTCACHE, + /** + * \brief Most recently used blocks cached + * \note This is the default action for undefined regions + */ + DISK_CACHEPROTO_RECENTLYUSED, + /** + * \brief Cache the entire region in memory + * + * This is a faster version of setting Length to CacheSize*BlockSize + */ + DISK_CACHEPROTO_FULLCACHE, + + /** + * \brief Cache only on demand + * + * Only cache when the ::DISK_IOCTL_PRECACHE IOCtl is used + */ + DISK_CACHEPROTO_EXPLICIT +}; + +/** + * \brief Flags for the cache + */ +enum eTplDisk_CacheFlags +{ + /** + * \brief Write all changes to the region straight back to media + */ + DISK_CACHEFLAG_WRITETHROUGH = 0x10 }; /** * \brief IOCtl name strings */ -#define DRV_DISK_IOCTLNAMES "get_block_size" +#define DRV_DISK_IOCTLNAMES "get_block_size","set_cache_region","set_precache" + +/** + * \name Disk Driver Utilities + * \{ + */ /** * \brief Callback function type used by DrvUtil_ReadBlock and DrvUtil_WriteBlock @@ -77,4 +177,8 @@ extern Uint64 DrvUtil_WriteBlock(Uint64 Start, Uint64 Length, void *Buffer, tDrvUtil_Callback ReadBlocks, tDrvUtil_Callback WriteBlocks, Uint64 BlockSize, Uint Argument); +/** + * \} + */ + #endif