X-Git-Url: https://git.ucc.asn.au/?a=blobdiff_plain;ds=sidebyside;f=Kernel%2Fdrv%2Fiocache.c;h=8f735419f1d9f65d4a823d8a316ec0a8c9402917;hb=b719f4869750496484938a93f279cb28c6a6e37a;hp=774c497429dd0d8058df556491695b9e7a5507f4;hpb=952891ddb96a341c0e24ecb7dec6361c7bbeaece;p=tpg%2Facess2.git diff --git a/Kernel/drv/iocache.c b/Kernel/drv/iocache.c index 774c4974..8f735419 100644 --- a/Kernel/drv/iocache.c +++ b/Kernel/drv/iocache.c @@ -87,7 +87,6 @@ tIOCache *IOCache_Create( tIOCache_WriteCallback Write, Uint32 ID, int SectorSiz */ int IOCache_Read( tIOCache *Cache, Uint64 Sector, void *Buffer ) { - tIOCache_Ent *ent; ENTER("pCache XSector pBuffer", Cache, Sector, Buffer); @@ -104,7 +103,22 @@ int IOCache_Read( tIOCache *Cache, Uint64 Sector, void *Buffer ) LEAVE('i', -1); return -1; } - + + #if IOCACHE_USE_PAGES + tIOCache_PageInfo *page; + size_t offset = (Sector*Cache->SectorSize) % PAGE_SIZE; + Uint64 wanted_base = (Sector*Cache->SectorSize) & ~(PAGE_SIZE-1); + for( page = Cache->Pages; page; page = page->CacheNext ) + { + void *tmp; + if(page->BaseOffset < WantedBase) continue; + if(page->BaseOffset > WantedBase) break; + tmp = MM_MapTemp( page->BasePhys ); + memcpy( Buffer, tmp + offset, Cache->SectorSize ); + MM_FreeTemp( tmp ); + } + #else + tIOCache_Ent *ent; // Search the list for( ent = Cache->Entries; ent; ent = ent->Next ) { @@ -120,6 +134,7 @@ int IOCache_Read( tIOCache *Cache, Uint64 Sector, void *Buffer ) // it's not there if(ent->Num > Sector) break; } + #endif Mutex_Release( &Cache->Lock ); LEAVE('i', 0);