IN ULONG BlocksPerFrameSh,// number of blocks in Frame (bit shift)
// Frame size = 2^BlocksPerFrameSh
IN lba_t FirstLba, // Logical Block Address (LBA) of the 1st block
- // in cacheable area
+ // in cacheable area
IN lba_t LastLba, // Logical Block Address (LBA) of the last block
- // in cacheable area
+ // in cacheable area
IN ULONG Mode, // media mode:
// WCACHE_MODE_ROM
// WCACHE_MODE_RW
IN ULONG Flags, // cache mode flags:
// WCACHE_CACHE_WHOLE_PACKET
// read long (Packet-sized) blocks of
- // data from media
+ // data from media
IN ULONG FramesToKeepFree,
// number of Frames to be flushed & purged from cache
// when Frame counter reaches top-limit and allocation
*/
#ifdef _MSC_VER
-#pragma warning(push)
+#pragma warning(push)
#pragma warning(disable:4035) // re-enable below
#endif
return;
ASSERT(!(BCount & 0x80000000));
-
+
ULONG firstPos = WCacheGetSortedListIndex(*BlockCount, List, Lba);
ULONG lastPos = WCacheGetSortedListIndex(*BlockCount, List, Lba+BCount);
ULONG offs = firstPos + BCount - lastPos;
VOID
__fastcall
WCacheRemoveRangeFromList(
- IN lba_t* List, // pointer to sorted (ASC) array of ULONGs
- IN PULONG BlockCount, // pointer to number of items in array (pointed by List)
+ IN lba_t* List, // pointer to sorted (ASC) array of ULONGs
+ IN PULONG BlockCount, // pointer to number of items in array (pointed by List)
IN lba_t Lba, // initial value for removal
IN ULONG BCount // number of sequentially incremented values to be removed
)
VOID
__fastcall
WCacheRemoveItemFromList(
- IN lba_t* List, // pointer to sorted (ASC) array of ULONGs
+ IN lba_t* List, // pointer to sorted (ASC) array of ULONGs
IN PULONG BlockCount, // pointer to number of items in array (pointed by List)
- IN lba_t Lba // value to be removed
+ IN lba_t Lba // value to be removed
)
{
if(!(*BlockCount)) return;
read = TRUE;
}
}
- }
+ }
// check if we are allowed to write to media
if(mod && !PrefereWrite) {
return STATUS_RETRY;
requested Blocks.
If there is not enough entries, WCache initiates flush & purge
process to satisfy request.
- This is dispatch routine, which calls
+ This is dispatch routine, which calls
WCacheCheckLimitsR() or WCacheCheckLimitsRW() depending on
media type.
Internal routine
}
}
}
-
+
if(!Cache->BlockCount) {
return STATUS_SUCCESS;
}
} // end WCacheCheckLimitsRAM()
/*
- WCachePurgeAllRAM()
+ WCachePurgeAllRAM()
Internal routine
*/
OSSTATUS
n=0;
while((n < BCount) &&
(n < Cache->BlocksPerFrame)) {
-
+
addr = (PCHAR)WCacheSectorAddr(block_array, i+n);
block_type = Cache->CheckUsedProc(Context, Lba+n);
if(/*WCacheGetBadFlag(block_array,i+n)*/
*/
OSSTATUS
WCacheReadBlocks__(
- IN PW_CACHE Cache, // pointer to the Cache Control structure
- IN PVOID Context, // user-supplied context for IO callbacks
+ IN PW_CACHE Cache, // pointer to the Cache Control structure
+ IN PVOID Context, // user-supplied context for IO callbacks
IN PCHAR Buffer, // user-supplied buffer for read blocks
IN lba_t Lba, // LBA to start read from
IN ULONG BCount, // number of blocks to be read
store_read_data_1:
// and now we'll copy them to cache
- //
+ //
Buffer -= (to_read - saved_to_read);
i = saved_i;
while(to_read - saved_to_read) {
WCacheWriteBlocks__(
IN PW_CACHE Cache, // pointer to the Cache Control structure
IN PVOID Context, // user-supplied context for IO callbacks
- IN PCHAR Buffer, // user-supplied buffer containing data to be written
+ IN PCHAR Buffer, // user-supplied buffer containing data to be written
IN lba_t Lba, // LBA to start write from
IN ULONG BCount, // number of blocks to be written
OUT PSIZE_T WrittenBytes, // user-supplied pointer to ULONG that will
// assume successful operation
block_array = Cache->FrameList[frame].Frame;
if(!block_array) {
-
+
if(BCount && !(BCount & (PS-1)) && !(Lba & (PS-1)) &&
(Cache->Mode != WCACHE_MODE_R) &&
(i+BCount <= Cache->BlocksPerFrame) &&
*/
VOID
WCacheFlushAll__(
- IN PW_CACHE Cache, // pointer to the Cache Control structure
- IN PVOID Context) // user-supplied context for IO callbacks
+ IN PW_CACHE Cache, // pointer to the Cache Control structure
+ IN PVOID Context) // user-supplied context for IO callbacks
{
if(!(Cache->ReadProc)) return;
ExAcquireResourceExclusiveLite(&(Cache->WCacheLock), TRUE);
*/
VOID
WCachePurgeAll__(
- IN PW_CACHE Cache, // pointer to the Cache Control structure
- IN PVOID Context) // user-supplied context for IO callbacks
+ IN PW_CACHE Cache, // pointer to the Cache Control structure
+ IN PVOID Context) // user-supplied context for IO callbacks
{
if(!(Cache->ReadProc)) return;
ExAcquireResourceExclusiveLite(&(Cache->WCacheLock), TRUE);
// lastPos = WCacheGetSortedListIndex(Cache->BlockCount, List, Lba+PSs);
block_array = Cache->FrameList[frame].Frame;
if(!block_array) {
- BrutePoint();
+ BrutePoint();
return;
}
// free memory
WCacheFreePacket(Cache, frame, block_array, Lba-firstLba, PSs);
-
+
WCacheRemoveRangeFromList(List, &(Cache->BlockCount), Lba, PSs);
WCacheRemoveRangeFromList(Cache->CachedModifiedBlocksList, &(Cache->WriteCount), Lba, PSs);
// check if frame is empty
// lastPos = WCacheGetSortedListIndex(Cache->WriteCount, List, Lba+PSs);
block_array = Cache->FrameList[frame].Frame;
if(!block_array) {
- BrutePoint();
+ BrutePoint();
continue;;
}
// queue modify request
WCacheFlushBlocksRW(
IN PW_CACHE Cache, // pointer to the Cache Control structure
IN PVOID Context, // user-supplied context for IO callbacks
- IN lba_t _Lba, // LBA to start flush from
+ IN lba_t _Lba, // LBA to start flush from
IN ULONG BCount // number of blocks to be flushed
)
{
if(Cache->Mode != WCACHE_MODE_RAM)
return STATUS_SUCCESS;
*/
-
+
return STATUS_SUCCESS;
} // end WCacheFlushBlocksRW()
WCacheFlushBlocks__(
IN PW_CACHE Cache, // pointer to the Cache Control structure
IN PVOID Context, // user-supplied context for IO callbacks
- IN lba_t Lba, // LBA to start flush from
+ IN lba_t Lba, // LBA to start flush from
IN ULONG BCount // number of blocks to be flushed
)
{
ExReleaseResourceForThreadLite(&(Cache->WCacheLock), ExGetCurrentResourceThread());
return status;
} // end WCacheFlushBlocks__()
-
+
/*
WCacheDirect__() returns pointer to memory block where
requested block is stored in.
WCacheCheckLimitsR(
IN PW_CACHE Cache, // pointer to the Cache Control structure
IN PVOID Context, // user-supplied context for IO callbacks
- IN lba_t ReqLba, // first LBA to access/cache
- IN ULONG BCount // number of Blocks to access/cache
+ IN lba_t ReqLba, // first LBA to access/cache
+ IN ULONG BCount // number of Blocks to access/cache
)
{
ULONG frame;
}
i = WCacheGetSortedListIndex(Cache->BlockCount, List, ReqLba);
- // enumerate requested blocks
+ // enumerate requested blocks
while((List[i] < (ReqLba+BCount)) && (i < Cache->BlockCount)) {
Lba = List[i];