From: John Hodge Date: Mon, 24 Jun 2013 16:46:38 +0000 (+0800) Subject: Kernel/IOCache - Constness fixes and pointer callback handle X-Git-Tag: rel0.15~410 X-Git-Url: https://git.ucc.asn.au/?a=commitdiff_plain;h=5178e8cb3113d9207c55b9042b6506de05624724;p=tpg%2Facess2.git Kernel/IOCache - Constness fixes and pointer callback handle --- diff --git a/KernelLand/Kernel/drv/iocache.c b/KernelLand/Kernel/drv/iocache.c index 8f735419..446f9b6b 100644 --- a/KernelLand/Kernel/drv/iocache.c +++ b/KernelLand/Kernel/drv/iocache.c @@ -39,7 +39,7 @@ struct sIOCache int SectorSize; tMutex Lock; int Mode; - Uint32 ID; + void *ID; tIOCache_WriteCallback Write; int CacheSize; int CacheUsed; @@ -57,7 +57,7 @@ tIOCache_PageInfo *gIOCache_GlobalPages; * \fn tIOCache *IOCache_Create( tIOCache_WriteCallback Write, Uint32 ID, int SectorSize, int CacheSize ) * \brief Creates a new IO Cache */ -tIOCache *IOCache_Create( tIOCache_WriteCallback Write, Uint32 ID, int SectorSize, int CacheSize ) +tIOCache *IOCache_Create( tIOCache_WriteCallback Write, void *ID, int SectorSize, int CacheSize ) { tIOCache *ret = calloc( 1, sizeof(tIOCache) ); @@ -145,7 +145,7 @@ int IOCache_Read( tIOCache *Cache, Uint64 Sector, void *Buffer ) * \fn int IOCache_Add( tIOCache *Cache, Uint64 Sector, void *Buffer ) * \brief Cache a sector */ -int IOCache_Add( tIOCache *Cache, Uint64 Sector, void *Buffer ) +int IOCache_Add( tIOCache *Cache, Uint64 Sector, const void *Buffer ) { tIOCache_Ent *ent, *prev; tIOCache_Ent *new; @@ -237,7 +237,7 @@ int IOCache_Add( tIOCache *Cache, Uint64 Sector, void *Buffer ) * \fn int IOCache_Write( tIOCache *Cache, Uint64 Sector, void *Buffer ) * \brief Read from a cached sector */ -int IOCache_Write( tIOCache *Cache, Uint64 Sector, void *Buffer ) +int IOCache_Write( tIOCache *Cache, Uint64 Sector, const void *Buffer ) { tIOCache_Ent *ent; diff --git a/KernelLand/Kernel/include/iocache.h b/KernelLand/Kernel/include/iocache.h index f008a2d0..b6d9ffee 100644 --- a/KernelLand/Kernel/include/iocache.h +++ b/KernelLand/Kernel/include/iocache.h @@ -26,7 +26,7 @@ typedef struct sIOCache tIOCache; * * Called to write a sector back to the device */ -typedef int (*tIOCache_WriteCallback)(Uint32 ID, Uint64 Sector, void *Buffer); +typedef int (*tIOCache_WriteCallback)(void *ID, Uint64 Sector, const void *Buffer); // === CONSTANTS === /** @@ -65,7 +65,7 @@ enum eIOCache_Modess { * \param SectorSize Size of a cached sector * \param CacheSize Maximum number of objects that can be in the cache at one time */ -tIOCache *IOCache_Create( tIOCache_WriteCallback Write, Uint32 ID, int SectorSize, int CacheSize ); +extern tIOCache *IOCache_Create( tIOCache_WriteCallback Write, void *ID, int SectorSize, int CacheSize ); /** * \brief Reads from a cached sector @@ -74,7 +74,7 @@ tIOCache *IOCache_Create( tIOCache_WriteCallback Write, Uint32 ID, int SectorSiz * \param Buffer Destination for the data read * \return 1 if the data was read, 0 if the sector is not cached, -1 on error */ - int IOCache_Read( tIOCache *Cache, Uint64 Sector, void *Buffer ); +extern int IOCache_Read( tIOCache *Cache, Uint64 Sector, void *Buffer ); /** * \brief Adds a sector to the cache @@ -83,7 +83,7 @@ tIOCache *IOCache_Create( tIOCache_WriteCallback Write, Uint32 ID, int SectorSiz * \param Buffer Data to cache * \return 1 on success, 0 if the sector is already cached, -1 on error */ - int IOCache_Add( tIOCache *Cache, Uint64 Sector, void *Buffer ); +extern int IOCache_Add( tIOCache *Cache, Uint64 Sector, const void *Buffer ); /** * \brief Writes to a cached sector @@ -96,7 +96,7 @@ tIOCache *IOCache_Create( tIOCache_WriteCallback Write, Uint32 ID, int SectorSiz * Wether the Write callback is called depends on the selected caching * behaviour. */ - int IOCache_Write( tIOCache *Cache, Uint64 Sector, void *Buffer ); +extern int IOCache_Write( tIOCache *Cache, Uint64 Sector, const void *Buffer ); /** * \brief Flush altered sectors out to the device @@ -105,7 +105,7 @@ tIOCache *IOCache_Create( tIOCache_WriteCallback Write, Uint32 ID, int SectorSiz * This will call the cache's write callback on each altered sector * to flush the write cache. */ -void IOCache_Flush( tIOCache *Cache ); +extern void IOCache_Flush( tIOCache *Cache ); /** * \brief Flushes the cache and then removes it @@ -115,6 +115,6 @@ void IOCache_Flush( tIOCache *Cache ); * IOCache_Destroy writes all changed sectors to the device and then * deallocates the cache for other systems to use. */ -void IOCache_Destroy( tIOCache *Cache ); +extern void IOCache_Destroy( tIOCache *Cache ); #endif