ReactOS  0.4.14-dev-606-g14ebc0b
wcache_lib.h File Reference
#include "platform.h"
Include dependency graph for wcache_lib.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  _WCACHE_ERROR_CONTEXT
 
struct  _W_CACHE_ENTRY
 
struct  _W_CACHE_FRAME
 
struct  _W_CACHE
 

Macros

#define WCACHE_BOUND_CHECKS
 
#define WCACHE_BLOCK_USED   0x01
 
#define WCACHE_BLOCK_ZERO   0x02
 
#define WCACHE_BLOCK_BAD   0x04
 
#define WCACHE_ERROR_READ   0x0001
 
#define WCACHE_ERROR_WRITE   0x0002
 
#define WCACHE_ERROR_INTERNAL   0x0003
 
#define WCACHE_W_OP   FALSE
 
#define WCACHE_R_OP   TRUE
 
#define CACHED_BLOCK_MEMORY_TYPE   PagedPool
 
#define MAX_TRIES_FOR_NA   3
 
#define WCACHE_ADDR_MASK   0xfffffff8
 
#define WCACHE_FLAG_MASK   0x00000007
 
#define WCACHE_FLAG_MODIFIED   0x00000001
 
#define WCACHE_FLAG_ZERO   0x00000002
 
#define WCACHE_FLAG_BAD   0x00000004
 
#define WCACHE_MODE_ROM   0x00000000
 
#define WCACHE_MODE_RW   0x00000001
 
#define WCACHE_MODE_R   0x00000002
 
#define WCACHE_MODE_RAM   0x00000003
 
#define WCACHE_MODE_EWR   0x00000004
 
#define WCACHE_MODE_MAX   WCACHE_MODE_RAM
 
#define PH_TMP_BUFFER   1
 
#define WCACHE_INVALID_LBA   ((lba_t)(-1))
 
#define WCACHE_CACHE_WHOLE_PACKET   0x01
 
#define WCACHE_DO_NOT_COMPARE   0x02
 
#define WCACHE_CHAINED_IO   0x04
 
#define WCACHE_MARK_BAD_BLOCKS   0x08
 
#define WCACHE_RO_BAD_BLOCKS   0x10
 
#define WCACHE_NO_WRITE_THROUGH   0x20
 
#define WCACHE_VALID_FLAGS
 
#define WCACHE_INVALID_FLAGS   (0xffffffff)
 

Typedefs

typedef OSSTATUS(* PWRITE_BLOCK) (IN PVOID Context, IN PVOID Buffer, IN SIZE_T Length, IN lba_t Lba, OUT PSIZE_T WrittenBytes, IN uint32 Flags)
 
typedef OSSTATUS(* PREAD_BLOCK) (IN PVOID Context, IN PVOID Buffer, IN SIZE_T Length, IN lba_t Lba, OUT PSIZE_T ReadBytes, IN uint32 Flags)
 
typedef OSSTATUS(* PWRITE_BLOCK_ASYNC) (IN PVOID Context, IN PVOID WContext, IN PVOID Buffer, IN SIZE_T Length, IN lba_t Lba, OUT PSIZE_T WrittenBytes, IN BOOLEAN FreeBuffer)
 
typedef OSSTATUS(* PREAD_BLOCK_ASYNC) (IN PVOID Context, IN PVOID WContext, IN PVOID Buffer, IN SIZE_T Length, IN lba_t Lba, OUT PSIZE_T ReadBytes)
 
typedef ULONG(* PCHECK_BLOCK) (IN PVOID Context, IN lba_t Lba)
 
typedef OSSTATUS(* PUPDATE_RELOC) (IN PVOID Context, IN lba_t Lba, IN PULONG RelocTab, IN ULONG BCount)
 
typedef struct _WCACHE_ERROR_CONTEXT WCACHE_ERROR_CONTEXT
 
typedef struct _WCACHE_ERROR_CONTEXTPWCACHE_ERROR_CONTEXT
 
typedef OSSTATUS(* PWC_ERROR_HANDLER) (IN PVOID Context, IN PWCACHE_ERROR_CONTEXT ErrorInfo)
 
typedef struct _W_CACHE_ENTRY W_CACHE_ENTRY
 
typedef struct _W_CACHE_ENTRYPW_CACHE_ENTRY
 
typedef struct _W_CACHE_FRAME W_CACHE_FRAME
 
typedef struct _W_CACHE_FRAMEPW_CACHE_FRAME
 
typedef struct _W_CACHE W_CACHE
 
typedef struct _W_CACHEPW_CACHE
 

Functions

OSSTATUS WCacheInit__ (IN PW_CACHE Cache, IN ULONG MaxFrames, IN ULONG MaxBlocks, IN SIZE_T MaxBytesToRead, IN ULONG PacketSizeSh, IN ULONG BlockSizeSh, IN ULONG BlocksPerFrameSh, IN lba_t FirstLba, IN lba_t LastLba, IN ULONG Mode, IN ULONG Flags, IN ULONG FramesToKeepFree, IN PWRITE_BLOCK WriteProc, IN PREAD_BLOCK ReadProc, IN PWRITE_BLOCK_ASYNC WriteProcAsync, IN PREAD_BLOCK_ASYNC ReadProcAsync, IN PCHECK_BLOCK CheckUsedProc, IN PUPDATE_RELOC UpdateRelocProc, IN PWC_ERROR_HANDLER ErrorHandlerProc)
 
OSSTATUS WCacheWriteBlocks__ (IN PW_CACHE Cache, IN PVOID Context, IN PCHAR Buffer, IN lba_t Lba, IN ULONG BCount, OUT PSIZE_T WrittenBytes, IN BOOLEAN CachedOnly)
 
OSSTATUS WCacheReadBlocks__ (IN PW_CACHE Cache, IN PVOID Context, IN PCHAR Buffer, IN lba_t Lba, IN ULONG BCount, OUT PSIZE_T ReadBytes, IN BOOLEAN CachedOnly)
 
OSSTATUS WCacheFlushBlocks__ (IN PW_CACHE Cache, IN PVOID Context, IN lba_t Lba, IN ULONG BCount)
 
VOID WCacheDiscardBlocks__ (IN PW_CACHE Cache, IN PVOID Context, IN lba_t Lba, IN ULONG BCount)
 
VOID WCacheFlushAll__ (IN PW_CACHE Cache, IN PVOID Context)
 
VOID WCachePurgeAll__ (IN PW_CACHE Cache, IN PVOID Context)
 
VOID WCacheRelease__ (IN PW_CACHE Cache)
 
BOOLEAN WCacheIsInitialized__ (IN PW_CACHE Cache)
 
OSSTATUS WCacheDirect__ (IN PW_CACHE Cache, IN PVOID Context, IN lba_t Lba, IN BOOLEAN Modified, OUT PCHAR *CachedBlock, IN BOOLEAN CachedOnly)
 
OSSTATUS WCacheEODirect__ (IN PW_CACHE Cache, IN PVOID Context)
 
OSSTATUS WCacheStartDirect__ (IN PW_CACHE Cache, IN PVOID Context, IN BOOLEAN Exclusive)
 
BOOLEAN WCacheIsCached__ (IN PW_CACHE Cache, IN lba_t Lba, IN ULONG BCount)
 
OSSTATUS WCacheSetMode__ (IN PW_CACHE Cache, IN ULONG Mode)
 
ULONG WCacheGetMode__ (IN PW_CACHE Cache)
 
ULONG WCacheGetWriteBlockCount__ (IN PW_CACHE Cache)
 
VOID WCacheSyncReloc__ (IN PW_CACHE Cache, IN PVOID Context)
 
ULONG WCacheChFlags__ (IN PW_CACHE Cache, IN ULONG SetFlags, IN ULONG ClrFlags)
 
OSSTATUS WCacheCompleteAsync__ (IN PVOID WContext, IN OSSTATUS Status)
 

Macro Definition Documentation

◆ CACHED_BLOCK_MEMORY_TYPE

#define CACHED_BLOCK_MEMORY_TYPE   PagedPool

Definition at line 115 of file wcache_lib.h.

◆ MAX_TRIES_FOR_NA

#define MAX_TRIES_FOR_NA   3

Definition at line 116 of file wcache_lib.h.

◆ PH_TMP_BUFFER

#define PH_TMP_BUFFER   1

Definition at line 131 of file wcache_lib.h.

◆ WCACHE_ADDR_MASK

#define WCACHE_ADDR_MASK   0xfffffff8

Definition at line 118 of file wcache_lib.h.

◆ WCACHE_BLOCK_BAD

#define WCACHE_BLOCK_BAD   0x04

Definition at line 56 of file wcache_lib.h.

◆ WCACHE_BLOCK_USED

#define WCACHE_BLOCK_USED   0x01

Definition at line 54 of file wcache_lib.h.

◆ WCACHE_BLOCK_ZERO

#define WCACHE_BLOCK_ZERO   0x02

Definition at line 55 of file wcache_lib.h.

◆ WCACHE_BOUND_CHECKS

#define WCACHE_BOUND_CHECKS

Definition at line 20 of file wcache_lib.h.

◆ WCACHE_CACHE_WHOLE_PACKET

#define WCACHE_CACHE_WHOLE_PACKET   0x01

Definition at line 191 of file wcache_lib.h.

◆ WCACHE_CHAINED_IO

#define WCACHE_CHAINED_IO   0x04

Definition at line 193 of file wcache_lib.h.

◆ WCACHE_DO_NOT_COMPARE

#define WCACHE_DO_NOT_COMPARE   0x02

Definition at line 192 of file wcache_lib.h.

◆ WCACHE_ERROR_INTERNAL

#define WCACHE_ERROR_INTERNAL   0x0003

Definition at line 68 of file wcache_lib.h.

◆ WCACHE_ERROR_READ

#define WCACHE_ERROR_READ   0x0001

Definition at line 66 of file wcache_lib.h.

◆ WCACHE_ERROR_WRITE

#define WCACHE_ERROR_WRITE   0x0002

Definition at line 67 of file wcache_lib.h.

◆ WCACHE_FLAG_BAD

#define WCACHE_FLAG_BAD   0x00000004

Definition at line 122 of file wcache_lib.h.

◆ WCACHE_FLAG_MASK

#define WCACHE_FLAG_MASK   0x00000007

Definition at line 119 of file wcache_lib.h.

◆ WCACHE_FLAG_MODIFIED

#define WCACHE_FLAG_MODIFIED   0x00000001

Definition at line 120 of file wcache_lib.h.

◆ WCACHE_FLAG_ZERO

#define WCACHE_FLAG_ZERO   0x00000002

Definition at line 121 of file wcache_lib.h.

◆ WCACHE_INVALID_FLAGS

#define WCACHE_INVALID_FLAGS   (0xffffffff)

Definition at line 205 of file wcache_lib.h.

◆ WCACHE_INVALID_LBA

#define WCACHE_INVALID_LBA   ((lba_t)(-1))

Definition at line 189 of file wcache_lib.h.

◆ WCACHE_MARK_BAD_BLOCKS

#define WCACHE_MARK_BAD_BLOCKS   0x08

Definition at line 194 of file wcache_lib.h.

◆ WCACHE_MODE_EWR

#define WCACHE_MODE_EWR   0x00000004

Definition at line 128 of file wcache_lib.h.

◆ WCACHE_MODE_MAX

#define WCACHE_MODE_MAX   WCACHE_MODE_RAM

Definition at line 129 of file wcache_lib.h.

◆ WCACHE_MODE_R

#define WCACHE_MODE_R   0x00000002

Definition at line 126 of file wcache_lib.h.

◆ WCACHE_MODE_RAM

#define WCACHE_MODE_RAM   0x00000003

Definition at line 127 of file wcache_lib.h.

◆ WCACHE_MODE_ROM

#define WCACHE_MODE_ROM   0x00000000

Definition at line 124 of file wcache_lib.h.

◆ WCACHE_MODE_RW

#define WCACHE_MODE_RW   0x00000001

Definition at line 125 of file wcache_lib.h.

◆ WCACHE_NO_WRITE_THROUGH

#define WCACHE_NO_WRITE_THROUGH   0x20

Definition at line 196 of file wcache_lib.h.

◆ WCACHE_R_OP

#define WCACHE_R_OP   TRUE

Definition at line 71 of file wcache_lib.h.

◆ WCACHE_RO_BAD_BLOCKS

#define WCACHE_RO_BAD_BLOCKS   0x10

Definition at line 195 of file wcache_lib.h.

◆ WCACHE_VALID_FLAGS

#define WCACHE_VALID_FLAGS
Value:
WCACHE_DO_NOT_COMPARE | \
WCACHE_CHAINED_IO | \
WCACHE_MARK_BAD_BLOCKS | \
WCACHE_RO_BAD_BLOCKS | \
WCACHE_NO_WRITE_THROUGH)
#define WCACHE_CACHE_WHOLE_PACKET
Definition: wcache_lib.h:191

Definition at line 198 of file wcache_lib.h.

◆ WCACHE_W_OP

#define WCACHE_W_OP   FALSE

Definition at line 70 of file wcache_lib.h.

Typedef Documentation

◆ PCHECK_BLOCK

typedef ULONG(* PCHECK_BLOCK) (IN PVOID Context, IN lba_t Lba)

Definition at line 58 of file wcache_lib.h.

◆ PREAD_BLOCK

Definition at line 29 of file wcache_lib.h.

◆ PREAD_BLOCK_ASYNC

typedef OSSTATUS(* PREAD_BLOCK_ASYNC) (IN PVOID Context, IN PVOID WContext, IN PVOID Buffer, IN SIZE_T Length, IN lba_t Lba, OUT PSIZE_T ReadBytes)

Definition at line 44 of file wcache_lib.h.

◆ PUPDATE_RELOC

typedef OSSTATUS(* PUPDATE_RELOC) (IN PVOID Context, IN lba_t Lba, IN PULONG RelocTab, IN ULONG BCount)

Definition at line 61 of file wcache_lib.h.

◆ PW_CACHE

◆ PW_CACHE_ENTRY

◆ PW_CACHE_FRAME

◆ PWC_ERROR_HANDLER

typedef OSSTATUS(* PWC_ERROR_HANDLER) (IN PVOID Context, IN PWCACHE_ERROR_CONTEXT ErrorInfo)

Definition at line 93 of file wcache_lib.h.

◆ PWCACHE_ERROR_CONTEXT

◆ PWRITE_BLOCK

typedef OSSTATUS(* PWRITE_BLOCK) (IN PVOID Context, IN PVOID Buffer, IN SIZE_T Length, IN lba_t Lba, OUT PSIZE_T WrittenBytes, IN uint32 Flags)

Definition at line 22 of file wcache_lib.h.

◆ PWRITE_BLOCK_ASYNC

typedef OSSTATUS(* PWRITE_BLOCK_ASYNC) (IN PVOID Context, IN PVOID WContext, IN PVOID Buffer, IN SIZE_T Length, IN lba_t Lba, OUT PSIZE_T WrittenBytes, IN BOOLEAN FreeBuffer)

Definition at line 36 of file wcache_lib.h.

◆ W_CACHE

◆ W_CACHE_ENTRY

◆ W_CACHE_FRAME

◆ WCACHE_ERROR_CONTEXT

Function Documentation

◆ WCacheChFlags__()

ULONG WCacheChFlags__ ( IN PW_CACHE  Cache,
IN ULONG  SetFlags,
IN ULONG  ClrFlags 
)

Definition at line 3634 of file wcache_lib.cpp.

3639 {
3640  ULONG Flags;
3641 
3642  if(SetFlags || ClrFlags) {
3643  Flags = (Cache->Flags & ~ClrFlags) | SetFlags;
3644 
3646  return -1;
3647  }
3648  } else {
3649  return Cache->Flags;
3650  }
3651  return Flags;
3652 } // end WCacheSetMode__()
Definition: fatfs.h:173
OSSTATUS __fastcall WCacheDecodeFlags(IN PW_CACHE Cache, IN ULONG Flags)
_Must_inspect_result_ _In_ ULONG Flags
Definition: wsk.h:170
#define OS_SUCCESS(a)
Definition: env_spec_w32.h:56
unsigned int ULONG
Definition: retypes.h:1

Referenced by UDFMountVolume(), and UDFVerifyVolume().

◆ WCacheCompleteAsync__()

OSSTATUS WCacheCompleteAsync__ ( IN PVOID  WContext,
IN OSSTATUS  Status 
)

Definition at line 3585 of file wcache_lib.cpp.

3589 {
3590  PW_CACHE_ASYNC AsyncCtx = (PW_CACHE_ASYNC)WContext;
3591 // PW_CACHE Cache = AsyncCtx->Cache;
3592 
3593  AsyncCtx->PhContext.IosbToUse.Status = Status;
3594  KeSetEvent(&(AsyncCtx->PhContext.event), 0, FALSE);
3595 
3596  return STATUS_SUCCESS;
3597 } // end WCacheSetMode__()
LONG NTAPI KeSetEvent(IN PKEVENT Event, IN KPRIORITY Increment, IN BOOLEAN Wait)
Definition: eventobj.c:159
struct _W_CACHE_ASYNC * PW_CACHE_ASYNC
IO_STATUS_BLOCK IosbToUse
Definition: Sys_spec_lib.h:24
UDF_PH_CALL_CONTEXT PhContext
Definition: wcache_lib.cpp:67
Status
Definition: gdiplustypes.h:24
return STATUS_SUCCESS
Definition: btrfs.c:2938

Referenced by WCacheUpdatePacket().

◆ WCacheDirect__()

OSSTATUS WCacheDirect__ ( IN PW_CACHE  Cache,
IN PVOID  Context,
IN lba_t  Lba,
IN BOOLEAN  Modified,
OUT PCHAR CachedBlock,
IN BOOLEAN  CachedOnly 
)

Definition at line 2948 of file wcache_lib.cpp.

2956 {
2957  ULONG frame;
2958  ULONG i;
2960  PW_CACHE_ENTRY block_array;
2961  ULONG BS = Cache->BlockSize;
2962  PCHAR addr;
2963  SIZE_T _ReadBytes;
2964  ULONG block_type;
2965 
2966  WcPrint(("WC:%sD %x (1)\n", Modified ? "W" : "R", Lba));
2967 
2968  // lock cache if nececcary
2969  if(!CachedOnly) {
2970  ExAcquireResourceExclusiveLite(&(Cache->WCacheLock), TRUE);
2971  }
2972  // check if we try to access beyond cached area
2973  if((Lba < Cache->FirstLba) ||
2974  (Lba > Cache->LastLba)) {
2975  UDFPrint(("LBA %#x is beyond cacheable area\n", Lba));
2976  BrutePoint();
2978  goto EO_WCache_D;
2979  }
2980 
2981  frame = Lba >> Cache->BlocksPerFrameSh;
2982  i = Lba - (frame << Cache->BlocksPerFrameSh);
2983  // check if we have enough space to store requested block
2984  if(!CachedOnly &&
2986  BrutePoint();
2987  goto EO_WCache_D;
2988  }
2989 
2990  // small updates are more important
2991  block_array = Cache->FrameList[frame].Frame;
2992  if(Modified) {
2993  Cache->FrameList[frame].UpdateCount+=8;
2994  } else {
2995  Cache->FrameList[frame].AccessCount+=8;
2996  }
2997  if(!block_array) {
2998  ASSERT(Cache->FrameCount < Cache->MaxFrames);
2999  block_array = WCacheInitFrame(Cache, Context, frame);
3000  if(!block_array) {
3002  goto EO_WCache_D;
3003  }
3004  }
3005  // check if requested block is already cached
3006  if( !(addr = (PCHAR)WCacheSectorAddr(block_array, i)) ) {
3007  // block is not cached
3008  // allocate memory and read block from media
3009  // do not set block_array[i].Sector here, because if media access fails and recursive access to cache
3010  // comes, this block should not be marked as 'cached'
3012  if(!addr) {
3014  goto EO_WCache_D;
3015  }
3016  block_type = Cache->CheckUsedProc(Context, Lba);
3017  if(block_type == WCACHE_BLOCK_USED) {
3018  status = Cache->ReadProc(Context, addr, BS, Lba, &_ReadBytes, PH_TMP_BUFFER);
3019  if(Cache->RememberBB) {
3020  if(!OS_SUCCESS(status)) {
3021  RtlZeroMemory(addr, BS);
3022  //WCacheSetBadFlag(block_array,i);
3023  }
3024  }
3025  } else {
3026  if(block_type & WCACHE_BLOCK_BAD) {
3027  DbgFreePool(addr);
3028  addr = NULL;
3030  goto EO_WCache_D;
3031  }
3032  if(!(block_type & WCACHE_BLOCK_ZERO)) {
3033  BrutePoint();
3034  }
3036  RtlZeroMemory(addr, BS);
3037  }
3038  // now add pointer to buffer to common storage
3039  block_array[i].Sector = addr;
3040  WCacheInsertItemToList(Cache->CachedBlocksList, &(Cache->BlockCount), Lba);
3041  if(Modified) {
3042  WCacheInsertItemToList(Cache->CachedModifiedBlocksList, &(Cache->WriteCount), Lba);
3043  WCacheSetModFlag(block_array, i);
3044  }
3045  Cache->FrameList[frame].BlockCount ++;
3046  } else {
3047  // block is not cached
3048  // just return pointer
3049  block_type = Cache->CheckUsedProc(Context, Lba);
3050  if(block_type & WCACHE_BLOCK_BAD) {
3051  //if(WCacheGetBadFlag(block_array,i)) {
3052  // bad packet. no pre-read
3054  goto EO_WCache_D;
3055  }
3056 #ifndef UDF_CHECK_UTIL
3057  ASSERT(block_type & WCACHE_BLOCK_USED);
3058 #else
3059  if(!(block_type & WCACHE_BLOCK_USED)) {
3060  UDFPrint(("LBA %#x is not marked as used\n", Lba));
3061  }
3062 #endif
3063  if(Modified &&
3064  !WCacheGetModFlag(block_array, i)) {
3065  WCacheInsertItemToList(Cache->CachedModifiedBlocksList, &(Cache->WriteCount), Lba);
3066  WCacheSetModFlag(block_array, i);
3067  }
3068  }
3069  (*CachedBlock) = addr;
3070 
3071 EO_WCache_D:
3072 
3073  return status;
3074 } // end WCacheDirect__()
signed char * PCHAR
Definition: retypes.h:7
#define UDFPrint(Args)
Definition: udffs.h:225
#define TRUE
Definition: types.h:120
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
#define DbgAllocatePoolWithTag(a, b, c)
Definition: env_spec_w32.h:333
Definition: fatfs.h:173
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
#define WCACHE_BLOCK_USED
Definition: wcache_lib.h:54
OSSTATUS __fastcall WCacheCheckLimits(IN PW_CACHE Cache, IN PVOID Context, IN lba_t ReqLba, IN ULONG BCount)
#define WCacheSetModFlag(block_array, i)
Definition: wcache_lib.cpp:811
BOOLEAN NTAPI ExAcquireResourceExclusiveLite(IN PERESOURCE Resource, IN BOOLEAN Wait)
Definition: resource.c:770
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define OSSTATUS
Definition: env_spec_w32.h:57
struct _ACPI_EFI_BOOT_SERVICES * BS
PCHAR Sector
Definition: wcache_lib.h:99
#define WCacheSectorAddr(block_array, i)
Definition: wcache_lib.cpp:864
smooth NULL
Definition: ftsmooth.c:416
#define WCACHE_BLOCK_BAD
Definition: wcache_lib.h:56
#define DbgFreePool
Definition: env_spec_w32.h:334
#define PCHAR
Definition: match.c:90
#define MEM_WCBUF_TAG
Definition: wcache_lib.cpp:56
#define WCACHE_BLOCK_ZERO
Definition: wcache_lib.h:55
PW_CACHE_ENTRY __fastcall WCacheInitFrame(IN PW_CACHE Cache, IN PVOID Context, IN ULONG frame)
Definition: wcache_lib.cpp:731
#define BrutePoint()
Definition: env_spec_w32.h:504
Definition: wcache_lib.h:97
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
VOID __fastcall WCacheInsertItemToList(IN lba_t *List, IN PULONG BlockCount, IN lba_t Lba)
Definition: wcache_lib.cpp:637
GLenum const GLvoid * addr
Definition: glext.h:9621
#define OS_SUCCESS(a)
Definition: env_spec_w32.h:56
#define WcPrint
Definition: wcache_lib.cpp:61
#define CACHED_BLOCK_MEMORY_TYPE
Definition: wcache_lib.h:115
ULONG_PTR SIZE_T
Definition: typedefs.h:78
#define PH_TMP_BUFFER
Definition: phys_lib.h:65
#define WCacheGetModFlag(block_array, i)
Definition: wcache_lib.cpp:828
unsigned int ULONG
Definition: retypes.h:1
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:261
return STATUS_SUCCESS
Definition: btrfs.c:2938
static SERVICE_STATUS status
Definition: service.c:31
#define STATUS_DEVICE_DATA_ERROR
Definition: udferr_usr.h:159
Definition: ps.c:97

Referenced by UDFWriteInSector().

◆ WCacheDiscardBlocks__()

VOID WCacheDiscardBlocks__ ( IN PW_CACHE  Cache,
IN PVOID  Context,
IN lba_t  Lba,
IN ULONG  BCount 
)

Definition at line 3519 of file wcache_lib.cpp.

3525 {
3526  ULONG frame;
3527  lba_t firstLba;
3528  lba_t* List;
3529  lba_t Lba;
3530  PW_CACHE_ENTRY block_array;
3531  BOOLEAN mod;
3532  ULONG i;
3533 
3534  ExAcquireResourceExclusiveLite(&(Cache->WCacheLock), TRUE);
3535 
3536  UDFPrint((" Discard req: %x@%x\n",BCount, ReqLba));
3537 
3538  List = Cache->CachedBlocksList;
3539  if(!List) {
3541  return;
3542  }
3543  i = WCacheGetSortedListIndex(Cache->BlockCount, List, ReqLba);
3544 
3545  // enumerate requested blocks
3546  while((List[i] < (ReqLba+BCount)) && (i < Cache->BlockCount)) {
3547 
3548  Lba = List[i];
3549  frame = Lba >> Cache->BlocksPerFrameSh;
3550  firstLba = frame << Cache->BlocksPerFrameSh;
3551  block_array = Cache->FrameList[frame].Frame;
3552  if(!block_array) {
3554  BrutePoint();
3555  return;
3556  }
3557  // check if modified
3558  mod = WCacheGetModFlag(block_array, Lba - firstLba);
3559  // just discard
3560 
3561  // mark as non-cached & free pool
3562  if(WCacheSectorAddr(block_array,Lba-firstLba)) {
3563  WCacheRemoveItemFromList(List, &(Cache->BlockCount), Lba);
3564  if(mod)
3565  WCacheRemoveItemFromList(Cache->CachedModifiedBlocksList, &(Cache->WriteCount), Lba);
3566  // mark as non-cached & free pool
3567  WCacheFreeSector(frame, Lba-firstLba);
3568  // check if frame is empty
3569  if(!Cache->FrameList[frame].BlockCount) {
3570  WCacheRemoveFrame(Cache, Context, frame);
3571  } else {
3572  ASSERT(Cache->FrameList[frame].Frame);
3573  }
3574  } else {
3575  // we should never get here !!!
3576  // getting this part of code means that we have
3577  // placed non-cached block in CachedBlocksList
3578  BrutePoint();
3579  }
3580  }
3582 } // end WCacheDiscardBlocks__()
#define ExGetCurrentResourceThread()
Definition: env_spec_w32.h:633
#define UDFPrint(Args)
Definition: udffs.h:225
#define TRUE
Definition: types.h:120
Definition: fatfs.h:173
#define WCacheFreeSector(frame, offs)
Definition: wcache_lib.cpp:873
BOOLEAN NTAPI ExAcquireResourceExclusiveLite(IN PERESOURCE Resource, IN BOOLEAN Wait)
Definition: resource.c:770
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
ULONG WCacheGetSortedListIndex(IN ULONG BlockCount, IN lba_t *List, IN lba_t Lba)
Definition: wcache_lib.cpp:449
unsigned char BOOLEAN
#define WCacheSectorAddr(block_array, i)
Definition: wcache_lib.cpp:864
VOID __fastcall WCacheRemoveItemFromList(IN lba_t *List, IN PULONG BlockCount, IN lba_t Lba)
Definition: wcache_lib.cpp:704
LIST_ENTRY List
Definition: psmgr.c:57
VOID __fastcall WCacheRemoveFrame(IN PW_CACHE Cache, IN PVOID Context, IN ULONG frame)
Definition: wcache_lib.cpp:780
#define BrutePoint()
Definition: env_spec_w32.h:504
Definition: wcache_lib.h:97
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
#define WCacheGetModFlag(block_array, i)
Definition: wcache_lib.cpp:828
unsigned int ULONG
Definition: retypes.h:1
VOID NTAPI ExReleaseResourceForThreadLite(IN PERESOURCE Resource, IN ERESOURCE_THREAD Thread)
Definition: resource.c:1844
uint32 lba_t
Definition: platform.h:20
static int mod
Definition: i386-dis.c:1273

Referenced by UDFMarkSpaceAsXXXNoProtect_().

◆ WCacheEODirect__()

OSSTATUS WCacheEODirect__ ( IN PW_CACHE  Cache,
IN PVOID  Context 
)

Definition at line 3082 of file wcache_lib.cpp.

3086 {
3088  return STATUS_SUCCESS;
3089 } // end WCacheEODirect__()
#define ExGetCurrentResourceThread()
Definition: env_spec_w32.h:633
Definition: fatfs.h:173
VOID NTAPI ExReleaseResourceForThreadLite(IN PERESOURCE Resource, IN ERESOURCE_THREAD Thread)
Definition: resource.c:1844
return STATUS_SUCCESS
Definition: btrfs.c:2938

Referenced by UDFCommonRead(), UDFCommonWrite(), UDFIsExtentCached(), UDFVWorkItem(), and UDFWriteInSector().

◆ WCacheFlushAll__()

VOID WCacheFlushAll__ ( IN PW_CACHE  Cache,
IN PVOID  Context 
)

Definition at line 2559 of file wcache_lib.cpp.

2562 {
2563  if(!(Cache->ReadProc)) return;
2564  ExAcquireResourceExclusiveLite(&(Cache->WCacheLock), TRUE);
2565 
2566  switch(Cache->Mode) {
2567  case WCACHE_MODE_RAM:
2569  break;
2570  case WCACHE_MODE_ROM:
2571  case WCACHE_MODE_RW:
2573  break;
2574  case WCACHE_MODE_R:
2576  break;
2577  }
2578 
2580  return;
2581 } // end WCacheFlushAll__()
#define ExGetCurrentResourceThread()
Definition: env_spec_w32.h:633
#define TRUE
Definition: types.h:120
Definition: fatfs.h:173
VOID __fastcall WCachePurgeAllR(IN PW_CACHE Cache, IN PVOID Context)
BOOLEAN NTAPI ExAcquireResourceExclusiveLite(IN PERESOURCE Resource, IN BOOLEAN Wait)
Definition: resource.c:770
OSSTATUS __fastcall WCacheFlushAllRAM(IN PW_CACHE Cache, IN PVOID Context)
VOID __fastcall WCacheFlushAllRW(IN PW_CACHE Cache, IN PVOID Context)
#define WCACHE_MODE_RAM
Definition: wcache_lib.h:127
#define WCACHE_MODE_R
Definition: wcache_lib.h:126
#define WCACHE_MODE_ROM
Definition: wcache_lib.h:124
VOID NTAPI ExReleaseResourceForThreadLite(IN PERESOURCE Resource, IN ERESOURCE_THREAD Thread)
Definition: resource.c:1844
#define WCACHE_MODE_RW
Definition: wcache_lib.h:125

Referenced by UDFEjectReqWaiter(), UDFFlushLogicalVolume(), UDFLoadPartDesc(), UDFRecordVAT(), UDFReleaseVCB(), UDFUmount__(), and UDFVerifyVolume().

◆ WCacheFlushBlocks__()

OSSTATUS WCacheFlushBlocks__ ( IN PW_CACHE  Cache,
IN PVOID  Context,
IN lba_t  Lba,
IN ULONG  BCount 
)

Definition at line 2898 of file wcache_lib.cpp.

2904 {
2905  OSSTATUS status;
2906 
2907  if(!(Cache->ReadProc)) return STATUS_INVALID_PARAMETER;
2908  ExAcquireResourceExclusiveLite(&(Cache->WCacheLock), TRUE);
2909 
2910  // check if we try to access beyond cached area
2911  if((Lba < Cache->FirstLba) ||
2912  (Lba+BCount-1 > Cache->LastLba)) {
2913  UDFPrint(("LBA %#x (%x) is beyond cacheable area\n", Lba, BCount));
2914  BrutePoint();
2916  goto EO_WCache_F;
2917  }
2918 
2919  switch(Cache->Mode) {
2920  case WCACHE_MODE_RAM:
2921 // WCacheFlushBlocksRW(Cache, Context);
2922 // break;
2923  case WCACHE_MODE_ROM:
2924  case WCACHE_MODE_RW:
2925  status = WCacheFlushBlocksRW(Cache, Context, Lba, BCount);
2926  break;
2927  case WCACHE_MODE_R:
2929  break;
2930  }
2931 EO_WCache_F:
2933  return status;
2934 } // end WCacheFlushBlocks__()
#define ExGetCurrentResourceThread()
Definition: env_spec_w32.h:633
#define UDFPrint(Args)
Definition: udffs.h:225
#define TRUE
Definition: types.h:120
Definition: fatfs.h:173
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
OSSTATUS WCacheFlushBlocksRW(IN PW_CACHE Cache, IN PVOID Context, IN lba_t _Lba, IN ULONG BCount)
BOOLEAN NTAPI ExAcquireResourceExclusiveLite(IN PERESOURCE Resource, IN BOOLEAN Wait)
Definition: resource.c:770
#define OSSTATUS
Definition: env_spec_w32.h:57
#define BrutePoint()
Definition: env_spec_w32.h:504
#define WCACHE_MODE_RAM
Definition: wcache_lib.h:127
#define WCACHE_MODE_R
Definition: wcache_lib.h:126
#define WCACHE_MODE_ROM
Definition: wcache_lib.h:124
VOID NTAPI ExReleaseResourceForThreadLite(IN PERESOURCE Resource, IN ERESOURCE_THREAD Thread)
Definition: resource.c:1844
return STATUS_SUCCESS
Definition: btrfs.c:2938
static SERVICE_STATUS status
Definition: service.c:31
#define WCACHE_MODE_RW
Definition: wcache_lib.h:125
Definition: ps.c:97

Referenced by UDFCommonDeviceControl(), UDFEjectReqWaiter(), UDFFlushLogicalVolume(), UDFUmount__(), and UDFUpdateLogicalVolInt().

◆ WCacheGetMode__()

ULONG WCacheGetMode__ ( IN PW_CACHE  Cache)

Definition at line 3440 of file wcache_lib.cpp.

3443 {
3444  return Cache->Mode;
3445 } // end WCacheGetMode__()
Definition: fatfs.h:173

◆ WCacheGetWriteBlockCount__()

ULONG WCacheGetWriteBlockCount__ ( IN PW_CACHE  Cache)

Definition at line 3454 of file wcache_lib.cpp.

3457 {
3458  return Cache->WriteCount;
3459 } // end WCacheGetWriteBlockCount__()
Definition: fatfs.h:173

Referenced by UDFRecordVAT(), and UDFUmount__().

◆ WCacheInit__()

OSSTATUS WCacheInit__ ( IN PW_CACHE  Cache,
IN ULONG  MaxFrames,
IN ULONG  MaxBlocks,
IN SIZE_T  MaxBytesToRead,
IN ULONG  PacketSizeSh,
IN ULONG  BlockSizeSh,
IN ULONG  BlocksPerFrameSh,
IN lba_t  FirstLba,
IN lba_t  LastLba,
IN ULONG  Mode,
IN ULONG  Flags,
IN ULONG  FramesToKeepFree,
IN PWRITE_BLOCK  WriteProc,
IN PREAD_BLOCK  ReadProc,
IN PWRITE_BLOCK_ASYNC  WriteProcAsync,
IN PREAD_BLOCK_ASYNC  ReadProcAsync,
IN PCHECK_BLOCK  CheckUsedProc,
IN PUPDATE_RELOC  UpdateRelocProc,
IN PWC_ERROR_HANDLER  ErrorHandlerProc 
)

Definition at line 116 of file wcache_lib.cpp.

171 {
172  ULONG l1, l2, l3;
173  ULONG PacketSize = (1) << PacketSizeSh;
174  ULONG BlockSize = (1) << BlockSizeSh;
175  ULONG BlocksPerFrame = (1) << BlocksPerFrameSh;
177  LARGE_INTEGER rseed;
178  ULONG res_init_flags = 0;
179 
180 #define WCLOCK_RES 1
181 
182  _SEH2_TRY {
183  // check input parameters
184  if(Mode == WCACHE_MODE_R) {
185  UDFPrint(("Disable Async-Write for WORM media\n"));
186  WriteProcAsync = NULL;
187  }
188  if((MaxBlocks % PacketSize) || !MaxBlocks) {
189  UDFPrint(("Total number of sectors must be packet-size-aligned\n"));
191  }
192  if(BlocksPerFrame % PacketSize) {
193  UDFPrint(("Number of sectors per Frame must be packet-size-aligned\n"));
195  }
196  if(!ReadProc) {
197  UDFPrint(("Read routine pointer must be valid\n"));
199  }
200  if(FirstLba >= LastLba) {
201  UDFPrint(("Invalid cached area parameters: (%x - %x)\n",FirstLba, LastLba));
203  }
204  if(!MaxFrames) {
205  UDFPrint(("Total frame number must be non-zero\n",FirstLba, LastLba));
207  }
208  if(Mode > WCACHE_MODE_MAX) {
209  UDFPrint(("Invalid media mode. Should be 0-%x\n",WCACHE_MODE_MAX));
211  }
212  if(FramesToKeepFree >= MaxFrames/2) {
213  UDFPrint(("Invalid FramesToKeepFree (%x). Should be Less or equal to MaxFrames/2 (%x)\n", FramesToKeepFree, MaxFrames/2));
215  }
216  // check 'features'
217  if(!WriteProc) {
218  UDFPrint(("Write routine not specified\n"));
219  UDFPrint(("Read-only mode enabled\n"));
220  }
221  MaxBlocks = max(MaxBlocks, BlocksPerFrame*3);
222  // initialize required structures
223  // we'll align structure size on system page size to
224  // avoid system crashes caused by pool fragmentation
225  if(!(Cache->FrameList =
226  (PW_CACHE_FRAME)MyAllocatePoolTag__(NonPagedPool, l1 = (((LastLba >> BlocksPerFrameSh)+1)*sizeof(W_CACHE_FRAME)), MEM_WCFRM_TAG) )) {
227  UDFPrint(("Cache init err 1\n"));
229  }
230  if(!(Cache->CachedBlocksList =
231  (PULONG)MyAllocatePoolTag__(NonPagedPool, l2 = ((MaxBlocks+2)*sizeof(lba_t)), MEM_WCFRM_TAG) )) {
232  UDFPrint(("Cache init err 2\n"));
234  }
235  if(!(Cache->CachedModifiedBlocksList =
237  UDFPrint(("Cache init err 3\n"));
239  }
240  if(!(Cache->CachedFramesList =
241  (PULONG)MyAllocatePoolTag__(NonPagedPool, l3 = ((MaxFrames+2)*sizeof(lba_t)), MEM_WCFRM_TAG) )) {
242  UDFPrint(("Cache init err 4\n"));
244  }
245  RtlZeroMemory(Cache->FrameList, l1);
246  RtlZeroMemory(Cache->CachedBlocksList, l2);
247  RtlZeroMemory(Cache->CachedModifiedBlocksList, l2);
248  RtlZeroMemory(Cache->CachedFramesList, l3);
249  // remember all useful parameters
250  Cache->BlocksPerFrame = BlocksPerFrame;
251  Cache->BlocksPerFrameSh = BlocksPerFrameSh;
252  Cache->BlockCount = 0;
253  Cache->MaxBlocks = MaxBlocks;
254  Cache->MaxBytesToRead = MaxBytesToRead;
255  Cache->FrameCount = 0;
256  Cache->MaxFrames = MaxFrames;
257  Cache->PacketSize = PacketSize;
258  Cache->PacketSizeSh = PacketSizeSh;
259  Cache->BlockSize = BlockSize;
260  Cache->BlockSizeSh = BlockSizeSh;
261  Cache->WriteCount = 0;
262  Cache->FirstLba = FirstLba;
263  Cache->LastLba = LastLba;
264  Cache->Mode = Mode;
265 
266  if(!OS_SUCCESS(RC = WCacheDecodeFlags(Cache, Flags))) {
267  return RC;
268  }
269 
270  Cache->FramesToKeepFree = FramesToKeepFree;
271  Cache->WriteProc = WriteProc;
272  Cache->ReadProc = ReadProc;
273  Cache->WriteProcAsync = WriteProcAsync;
274  Cache->ReadProcAsync = ReadProcAsync;
275  Cache->CheckUsedProc = CheckUsedProc;
276  Cache->UpdateRelocProc = UpdateRelocProc;
277  Cache->ErrorHandlerProc = ErrorHandlerProc;
278  // init permanent tmp buffers
279  if(!(Cache->tmp_buff =
281  UDFPrint(("Cache init err 5.W\n"));
283  }
284  if(!(Cache->tmp_buff_r =
286  UDFPrint(("Cache init err 5.R\n"));
288  }
289  if(!(Cache->reloc_tab =
290  (PULONG)MyAllocatePoolTag__(NonPagedPool, Cache->PacketSize*sizeof(ULONG), MEM_WCFRM_TAG))) {
291  UDFPrint(("Cache init err 6\n"));
293  }
294  if(!OS_SUCCESS(RC = ExInitializeResourceLite(&(Cache->WCacheLock)))) {
295  UDFPrint(("Cache init err (res)\n"));
296  try_return(RC);
297  }
298  res_init_flags |= WCLOCK_RES;
300  WCache_random = rseed.LowPart;
301 
302 try_exit: NOTHING;
303 
304  } _SEH2_FINALLY {
305 
306  if(!OS_SUCCESS(RC)) {
307  if(res_init_flags & WCLOCK_RES)
308  ExDeleteResourceLite(&(Cache->WCacheLock));
309  if(Cache->FrameList)
310  MyFreePool__(Cache->FrameList);
311  if(Cache->CachedBlocksList)
312  MyFreePool__(Cache->CachedBlocksList);
313  if(Cache->CachedModifiedBlocksList)
314  MyFreePool__(Cache->CachedModifiedBlocksList);
315  if(Cache->CachedFramesList)
316  MyFreePool__(Cache->CachedFramesList);
317  if(Cache->tmp_buff_r)
318  MyFreePool__(Cache->tmp_buff_r);
319  if(Cache->tmp_buff)
320  MyFreePool__(Cache->tmp_buff);
321  if(Cache->reloc_tab)
322  MyFreePool__(Cache->reloc_tab);
323  RtlZeroMemory(Cache, sizeof(W_CACHE));
324  } else {
325  Cache->Tag = 0xCAC11E00;
326  }
327 
328  } _SEH2_END;
329 
330  return RC;
331 } // end WCacheInit__()
#define KeQuerySystemTime(t)
Definition: env_spec_w32.h:570
signed char * PCHAR
Definition: retypes.h:7
#define max(a, b)
Definition: svc.c:63
#define UDFPrint(Args)
Definition: udffs.h:225
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
ULONG WCache_random
Definition: wcache_lib.cpp:90
_In_ ULONG Mode
Definition: hubbusif.h:303
Definition: fatfs.h:173
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
OSSTATUS __fastcall WCacheDecodeFlags(IN PW_CACHE Cache, IN ULONG Flags)
NTSTATUS ExInitializeResourceLite(PULONG res)
Definition: env_spec_w32.h:641
NTSTATUS NTAPI ExDeleteResourceLite(IN PERESOURCE Resource)
Definition: resource.c:1456
#define MEM_WCFRM_TAG
Definition: wcache_lib.cpp:55
_SEH2_TRY
Definition: create.c:4250
_Must_inspect_result_ _In_ ULONG Flags
Definition: wsk.h:170
#define WCLOCK_RES
#define OSSTATUS
Definition: env_spec_w32.h:57
#define WCACHE_MODE_MAX
Definition: wcache_lib.h:129
smooth NULL
Definition: ftsmooth.c:416
#define try_return(S)
Definition: cdprocs.h:2189
#define MyFreePool__(addr)
Definition: mem_tools.h:152
#define OS_SUCCESS(a)
Definition: env_spec_w32.h:56
ULONG LowPart
Definition: typedefs.h:104
#define NOTHING
Definition: env_spec_w32.h:461
#define MyAllocatePoolTag__(type, size, tag)
Definition: mem_tools.h:150
_SEH2_END
Definition: create.c:4424
_In_ USHORT PacketSize
Definition: iofuncs.h:1056
_SEH2_FINALLY
Definition: create.c:4395
unsigned int * PULONG
Definition: retypes.h:1
#define WCACHE_MODE_R
Definition: wcache_lib.h:126
unsigned int ULONG
Definition: retypes.h:1
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:261
uint32 lba_t
Definition: platform.h:20
return STATUS_SUCCESS
Definition: btrfs.c:2938

Referenced by UDFMountVolume(), and UDFVerifyVolume().

◆ WCacheIsCached__()

BOOLEAN WCacheIsCached__ ( IN PW_CACHE  Cache,
IN lba_t  Lba,
IN ULONG  BCount 
)

WCacheGetBadFlag(block_array, i)

(Cache->CheckUsedProc(Context, Lba) & WCACHE_BLOCK_BAD)

Definition at line 3126 of file wcache_lib.cpp.

3131 {
3132  ULONG frame;
3133  ULONG i;
3134  PW_CACHE_ENTRY block_array;
3135 
3136  // check if we try to access beyond cached area
3137  if((Lba < Cache->FirstLba) ||
3138  (Lba + BCount - 1 > Cache->LastLba)) {
3139  return FALSE;
3140  }
3141 
3142  frame = Lba >> Cache->BlocksPerFrameSh;
3143  i = Lba - (frame << Cache->BlocksPerFrameSh);
3144 
3145  block_array = Cache->FrameList[frame].Frame;
3146  if(!block_array) {
3147  return FALSE;
3148  }
3149 
3150  while(BCount) {
3151  if(i >= Cache->BlocksPerFrame) {
3152  frame++;
3153  block_array = Cache->FrameList[frame].Frame;
3154  i -= Cache->BlocksPerFrame;
3155  }
3156  if(!block_array) {
3157  return FALSE;
3158  }
3159  // 'read' cached extent (if any)
3160  while(BCount &&
3161  (i < Cache->BlocksPerFrame) &&
3162  WCacheSectorAddr(block_array, i) &&
3165  TRUE ) {
3166  i++;
3167  BCount--;
3168  Lba++;
3169  }
3170  if(BCount &&
3171  (i < Cache->BlocksPerFrame) /*&&
3172  (!WCacheSectorAddr(block_array, i))*/ ) {
3173  return FALSE;
3174  }
3175  }
3176  return TRUE;
3177 } // end WCacheIsCached__()
#define TRUE
Definition: types.h:120
Definition: fatfs.h:173
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define WCacheSectorAddr(block_array, i)
Definition: wcache_lib.cpp:864
Definition: wcache_lib.h:97
unsigned int ULONG
Definition: retypes.h:1

◆ WCacheIsInitialized__()

BOOLEAN WCacheIsInitialized__ ( IN PW_CACHE  Cache)

Definition at line 2816 of file wcache_lib.cpp.

2819 {
2820  return (Cache->ReadProc != NULL);
2821 } // end WCacheIsInitialized__()
Definition: fatfs.h:173
smooth NULL
Definition: ftsmooth.c:416

Referenced by UDFVerifyVolume(), and UDFWriteInSector().

◆ WCachePurgeAll__()

VOID WCachePurgeAll__ ( IN PW_CACHE  Cache,
IN PVOID  Context 
)

Definition at line 2589 of file wcache_lib.cpp.

2592 {
2593  if(!(Cache->ReadProc)) return;
2594  ExAcquireResourceExclusiveLite(&(Cache->WCacheLock), TRUE);
2595 
2596  switch(Cache->Mode) {
2597  case WCACHE_MODE_RAM:
2599  break;
2600  case WCACHE_MODE_ROM:
2601  case WCACHE_MODE_RW:
2603  break;
2604  case WCACHE_MODE_R:
2606  break;
2607  }
2608 
2610  return;
2611 } // end WCachePurgeAll__()
VOID __fastcall WCachePurgeAllRW(IN PW_CACHE Cache, IN PVOID Context)
#define ExGetCurrentResourceThread()
Definition: env_spec_w32.h:633
#define TRUE
Definition: types.h:120
Definition: fatfs.h:173
VOID __fastcall WCachePurgeAllR(IN PW_CACHE Cache, IN PVOID Context)
BOOLEAN NTAPI ExAcquireResourceExclusiveLite(IN PERESOURCE Resource, IN BOOLEAN Wait)
Definition: resource.c:770
OSSTATUS __fastcall WCachePurgeAllRAM(IN PW_CACHE Cache, IN PVOID Context)
#define WCACHE_MODE_RAM
Definition: wcache_lib.h:127
#define WCACHE_MODE_R
Definition: wcache_lib.h:126
#define WCACHE_MODE_ROM
Definition: wcache_lib.h:124
VOID NTAPI ExReleaseResourceForThreadLite(IN PERESOURCE Resource, IN ERESOURCE_THREAD Thread)
Definition: resource.c:1844
#define WCACHE_MODE_RW
Definition: wcache_lib.h:125

Referenced by UDFFindAnchor().

◆ WCacheReadBlocks__()

OSSTATUS WCacheReadBlocks__ ( IN PW_CACHE  Cache,
IN PVOID  Context,
IN PCHAR  Buffer,
IN lba_t  Lba,
IN ULONG  BCount,
OUT PSIZE_T  ReadBytes,
IN BOOLEAN  CachedOnly 
)

Definition at line 2011 of file wcache_lib.cpp.

2021 {
2022  ULONG frame;
2023  ULONG i, saved_i, saved_BC = BCount, n;
2025  PW_CACHE_ENTRY block_array;
2026  ULONG BSh = Cache->BlockSizeSh;
2027  SIZE_T BS = Cache->BlockSize;
2028  PCHAR addr;
2029  ULONG to_read, saved_to_read;
2030 // PCHAR saved_buff = Buffer;
2031  SIZE_T _ReadBytes;
2032  ULONG PS = Cache->PacketSize;
2033  ULONG MaxR = Cache->MaxBytesToRead;
2034  ULONG PacketMask = PS-1; // here we assume that Packet Size value is 2^n
2035  ULONG d;
2036  ULONG block_type;
2037 
2038  WcPrint(("WC:R %x (%x)\n", Lba, BCount));
2039 
2040  (*ReadBytes) = 0;
2041  // check if we try to read too much data
2042  if(BCount >= Cache->MaxBlocks) {
2043  i = 0;
2044  if(CachedOnly) {
2046  goto EO_WCache_R2;
2047  }
2048  while(TRUE) {
2049  status = WCacheReadBlocks__(Cache, Context, Buffer + (i<<BSh), Lba, PS, &_ReadBytes, FALSE);
2050  (*ReadBytes) += _ReadBytes;
2051  if(!OS_SUCCESS(status) || (BCount <= PS)) break;
2052  BCount -= PS;
2053  Lba += PS;
2054  i += PS;
2055  }
2056  return status;
2057  }
2058  // check if we try to access beyond cached area
2059  if((Lba < Cache->FirstLba) ||
2060  (Lba + BCount - 1 > Cache->LastLba)) {
2061  status = Cache->ReadProc(Context, Buffer, BCount, Lba, ReadBytes, 0);
2062  if(!OS_SUCCESS(status)) {
2064  }
2065  return status;
2066  }
2067  if(!CachedOnly) {
2068  ExAcquireResourceExclusiveLite(&(Cache->WCacheLock), TRUE);
2069  }
2070 
2071  frame = Lba >> Cache->BlocksPerFrameSh;
2072  i = Lba - (frame << Cache->BlocksPerFrameSh);
2073 
2074  if(Cache->CacheWholePacket && (BCount < PS)) {
2075  if(!CachedOnly &&
2076  !OS_SUCCESS(status = WCacheCheckLimits(Cache, Context, Lba & ~(PS-1), PS*2)) ) {
2078  return status;
2079  }
2080  } else {
2081  if(!CachedOnly &&
2082  !OS_SUCCESS(status = WCacheCheckLimits(Cache, Context, Lba, BCount))) {
2084  return status;
2085  }
2086  }
2087  if(!CachedOnly) {
2088  // convert to shared
2089 // ExConvertExclusiveToSharedLite(&(Cache->WCacheLock));
2090  }
2091 
2092  // pre-read packet. It is very useful for
2093  // highly fragmented files
2094  if(Cache->CacheWholePacket && (BCount < PS)) {
2095 // status = WCacheReadBlocks__(Cache, Context, Cache->tmp_buff_r, Lba & (~PacketMask), PS, &_ReadBytes, TRUE);
2096  // we should not perform IO if user requested CachedOnly data
2097  if(!CachedOnly) {
2099  }
2101  }
2102 
2103  // assume successful operation
2104  block_array = Cache->FrameList[frame].Frame;
2105  if(!block_array) {
2106  ASSERT(!CachedOnly);
2107  ASSERT(Cache->FrameCount < Cache->MaxFrames);
2108  block_array = WCacheInitFrame(Cache, Context, frame);
2109  if(!block_array) {
2111  goto EO_WCache_R;
2112  }
2113  }
2114 
2115  Cache->FrameList[frame].AccessCount++;
2116  while(BCount) {
2117  if(i >= Cache->BlocksPerFrame) {
2118  frame++;
2119  block_array = Cache->FrameList[frame].Frame;
2120  i -= Cache->BlocksPerFrame;
2121  }
2122  if(!block_array) {
2123  ASSERT(Cache->FrameCount < Cache->MaxFrames);
2124  block_array = WCacheInitFrame(Cache, Context, frame);
2125  if(!block_array) {
2127  goto EO_WCache_R;
2128  }
2129  }
2130  // 'read' cached extent (if any)
2131  // it is just copying
2132  while(BCount &&
2133  (i < Cache->BlocksPerFrame) &&
2134  (addr = (PCHAR)WCacheSectorAddr(block_array, i)) ) {
2135  block_type = Cache->CheckUsedProc(Context, Lba+saved_BC-BCount);
2136  if(block_type & WCACHE_BLOCK_BAD) {
2137  //if(WCacheGetBadFlag(block_array,i)) {
2139  goto EO_WCache_R;
2140  }
2142  Buffer += BS;
2143  *ReadBytes += BS;
2144  i++;
2145  BCount--;
2146  }
2147  // read non-cached packet-size-aligned extent (if any)
2148  // now we'll calculate total length & decide if it has enough size
2149  if(!((d = Lba+saved_BC-BCount) & PacketMask) && d ) {
2150  n = 0;
2151  while(BCount &&
2152  (i < Cache->BlocksPerFrame) &&
2153  (!WCacheSectorAddr(block_array, i)) ) {
2154  n++;
2155  BCount--;
2156  }
2157  BCount += n;
2158  n &= ~PacketMask;
2159  if(n>PS) {
2160  if(!OS_SUCCESS(status = Cache->ReadProc(Context, Buffer, BS*n, Lba+saved_BC-BCount, &_ReadBytes, 0))) {
2161  status = WCacheRaiseIoError(Cache, Context, status, Lba+saved_BC-BCount, n, Buffer, WCACHE_R_OP, NULL);
2162  if(!OS_SUCCESS(status)) {
2163  goto EO_WCache_R;
2164  }
2165  }
2166 // WCacheInsertRangeToList(Cache->CachedBlocksList, &(Cache->BlockCount), Lba, saved_BC - BCount);
2167  BCount -= n;
2168  Lba += saved_BC - BCount;
2169  saved_BC = BCount;
2170  i += n;
2171  Buffer += BS*n;
2172  *ReadBytes += BS*n;
2173  }
2174 // } else {
2175 // UDFPrint(("Unaligned\n"));
2176  }
2177  // read non-cached extent (if any)
2178  // firstable, we'll get total number of sectors to read
2179  to_read = 0;
2180  saved_i = i;
2181  d = BCount;
2182  while(d &&
2183  (i < Cache->BlocksPerFrame) &&
2184  (!WCacheSectorAddr(block_array, i)) ) {
2185  i++;
2186  to_read += BS;
2187  d--;
2188  }
2189  // read some not cached sectors
2190  if(to_read) {
2191  i = saved_i;
2192  saved_to_read = to_read;
2193  d = BCount - d;
2194  // split request if necessary
2195  if(saved_to_read > MaxR) {
2196  WCacheInsertRangeToList(Cache->CachedBlocksList, &(Cache->BlockCount), Lba, saved_BC - BCount);
2197  n = MaxR >> BSh;
2198  do {
2199  status = Cache->ReadProc(Context, Buffer, MaxR, i + (frame << Cache->BlocksPerFrameSh), &_ReadBytes, 0);
2200  *ReadBytes += _ReadBytes;
2201  if(!OS_SUCCESS(status)) {
2202  _ReadBytes &= ~(BS-1);
2203  BCount -= _ReadBytes >> BSh;
2204  saved_to_read -= _ReadBytes;
2205  Buffer += _ReadBytes;
2206  saved_BC = BCount;
2207  goto store_read_data_1;
2208  }
2209  Buffer += MaxR;
2210  saved_to_read -= MaxR;
2211  i += n;
2212  BCount -= n;
2213  d -= n;
2214  } while(saved_to_read > MaxR);
2215  saved_BC = BCount;
2216  }
2217  if(saved_to_read) {
2218  status = Cache->ReadProc(Context, Buffer, saved_to_read, i + (frame << Cache->BlocksPerFrameSh), &_ReadBytes, 0);
2219  *ReadBytes += _ReadBytes;
2220  if(!OS_SUCCESS(status)) {
2221  _ReadBytes &= ~(BS-1);
2222  BCount -= _ReadBytes >> BSh;
2223  saved_to_read -= _ReadBytes;
2224  Buffer += _ReadBytes;
2225  goto store_read_data_1;
2226  }
2227  Buffer += saved_to_read;
2228  saved_to_read = 0;
2229  BCount -= d;
2230  }
2231 
2232 store_read_data_1:
2233  // and now we'll copy them to cache
2234 
2235  //
2236  Buffer -= (to_read - saved_to_read);
2237  i = saved_i;
2238  while(to_read - saved_to_read) {
2240  if(!block_array[i].Sector) {
2241  BCount += to_read >> BSh;
2243  goto EO_WCache_R;
2244  }
2245  DbgCopyMemory(block_array[i].Sector, Buffer, BS);
2246  Cache->FrameList[frame].BlockCount++;
2247  i++;
2248  Buffer += BS;
2249  to_read -= BS;
2250  }
2251  if(!OS_SUCCESS(status))
2252  goto EO_WCache_R;
2253  to_read = 0;
2254  }
2255  }
2256 
2257 EO_WCache_R:
2258 
2259  // we know the number of unread sectors if an error occured
2260  // so we can need to update BlockCount
2261  // return number of read bytes
2262  WCacheInsertRangeToList(Cache->CachedBlocksList, &(Cache->BlockCount), Lba, saved_BC - BCount);
2263 // Cache->FrameList[frame].BlockCount -= BCount;
2264 EO_WCache_R2:
2265  if(!CachedOnly) {
2267  }
2268 
2269  return status;
2270 } // end WCacheReadBlocks__()
signed char * PCHAR
Definition: retypes.h:7
#define ExGetCurrentResourceThread()
Definition: env_spec_w32.h:633
VOID __fastcall WCacheInsertRangeToList(IN lba_t *List, IN PULONG BlockCount, IN lba_t Lba, IN ULONG BCount)
Definition: wcache_lib.cpp:588
#define TRUE
Definition: types.h:120
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
#define DbgAllocatePoolWithTag(a, b, c)
Definition: env_spec_w32.h:333
#define WCACHE_R_OP
Definition: wcache_lib.h:71
Definition: fatfs.h:173
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
GLdouble n
Definition: glext.h:7729
OSSTATUS WCacheRaiseIoError(IN PW_CACHE Cache, IN PVOID Context, IN OSSTATUS Status, IN ULONG Lba, IN ULONG BCount, IN PVOID Buffer, IN BOOLEAN ReadOp, IN PBOOLEAN Retry)
Definition: wcache_lib.cpp:946
OSSTATUS __fastcall WCacheCheckLimits(IN PW_CACHE Cache, IN PVOID Context, IN lba_t ReqLba, IN ULONG BCount)
BOOLEAN NTAPI ExAcquireResourceExclusiveLite(IN PERESOURCE Resource, IN BOOLEAN Wait)
Definition: resource.c:770
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define OSSTATUS
Definition: env_spec_w32.h:57
struct _ACPI_EFI_BOOT_SERVICES * BS
PCHAR Sector
Definition: wcache_lib.h:99
#define WCacheSectorAddr(block_array, i)
Definition: wcache_lib.cpp:864
smooth NULL
Definition: ftsmooth.c:416
Definition: bufpool.h:45
#define WCACHE_BLOCK_BAD
Definition: wcache_lib.h:56
static NTSTATUS ReadBytes(IN PDEVICE_OBJECT LowerDevice, OUT PUCHAR Buffer, IN ULONG BufferSize, OUT PULONG_PTR FilledBytes)
Definition: detect.c:67
#define PCHAR
Definition: match.c:90
#define d
Definition: ke_i.h:81
#define MEM_WCBUF_TAG
Definition: wcache_lib.cpp:56
ULONG to_read
Definition: btrfs.c:4136
PW_CACHE_ENTRY __fastcall WCacheInitFrame(IN PW_CACHE Cache, IN PVOID Context, IN ULONG frame)
Definition: wcache_lib.cpp:731
OSSTATUS WCacheReadBlocks__(IN PW_CACHE Cache, IN PVOID Context, IN PCHAR Buffer, IN lba_t Lba, IN ULONG BCount, OUT PSIZE_T ReadBytes, IN BOOLEAN CachedOnly)
Definition: wcache_lib.h:97
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
OSSTATUS WCachePreReadPacket__(IN PW_CACHE Cache, IN PVOID Context, IN lba_t Lba)
GLenum const GLvoid * addr
Definition: glext.h:9621
#define OS_SUCCESS(a)
Definition: env_spec_w32.h:56
#define WcPrint
Definition: wcache_lib.cpp:61
#define CACHED_BLOCK_MEMORY_TYPE
Definition: wcache_lib.h:115
ULONG_PTR SIZE_T
Definition: typedefs.h:78
#define DbgCopyMemory
Definition: env_spec_w32.h:331
unsigned int ULONG
Definition: retypes.h:1
VOID NTAPI ExReleaseResourceForThreadLite(IN PERESOURCE Resource, IN ERESOURCE_THREAD Thread)
Definition: resource.c:1844
return STATUS_SUCCESS
Definition: btrfs.c:2938
static SERVICE_STATUS status
Definition: service.c:31
#define STATUS_DEVICE_DATA_ERROR
Definition: udferr_usr.h:159
Definition: ps.c:97

Referenced by WCacheReadBlocks__().

◆ WCacheRelease__()

VOID WCacheRelease__ ( IN PW_CACHE  Cache)

Definition at line 2767 of file wcache_lib.cpp.

2770 {
2771  ULONG i, j, k;
2772  PW_CACHE_ENTRY block_array;
2773 
2774  Cache->Tag = 0xDEADCACE;
2775  if(!(Cache->ReadProc)) return;
2776 // ASSERT(Cache->Tag == 0xCAC11E00);
2777  ExAcquireResourceExclusiveLite(&(Cache->WCacheLock), TRUE);
2778  for(i=0; i<Cache->FrameCount; i++) {
2779  j = Cache->CachedFramesList[i];
2780  block_array = Cache->FrameList[j].Frame;
2781  if(block_array) {
2782  for(k=0; k<Cache->BlocksPerFrame; k++) {
2783  if(WCacheSectorAddr(block_array, k)) {
2784  WCacheFreeSector(j, k);
2785  }
2786  }
2787  MyFreePool__(block_array);
2788  }
2789  }
2790  if(Cache->FrameList)
2791  MyFreePool__(Cache->FrameList);
2792  if(Cache->CachedBlocksList)
2793  MyFreePool__(Cache->CachedBlocksList);
2794  if(Cache->CachedModifiedBlocksList)
2795  MyFreePool__(Cache->CachedModifiedBlocksList);
2796  if(Cache->CachedFramesList)
2797  MyFreePool__(Cache->CachedFramesList);
2798  if(Cache->tmp_buff_r)
2799  MyFreePool__(Cache->tmp_buff_r);
2800  if(Cache->CachedFramesList)
2801  MyFreePool__(Cache->tmp_buff);
2802  if(Cache->CachedFramesList)
2803  MyFreePool__(Cache->reloc_tab);
2805  ExDeleteResourceLite(&(Cache->WCacheLock));
2806  RtlZeroMemory(Cache, sizeof(W_CACHE));
2807  return;
2808 } // end WCacheRelease__()
#define ExGetCurrentResourceThread()
Definition: env_spec_w32.h:633
#define TRUE
Definition: types.h:120
Definition: fatfs.h:173
NTSTATUS NTAPI ExDeleteResourceLite(IN PERESOURCE Resource)
Definition: resource.c:1456
#define WCacheFreeSector(frame, offs)
Definition: wcache_lib.cpp:873
BOOLEAN NTAPI ExAcquireResourceExclusiveLite(IN PERESOURCE Resource, IN BOOLEAN Wait)
Definition: resource.c:770
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define WCacheSectorAddr(block_array, i)
Definition: wcache_lib.cpp:864
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint GLint GLint j
Definition: glfuncs.h:250
#define MyFreePool__(addr)
Definition: mem_tools.h:152
Definition: wcache_lib.h:97
unsigned int ULONG
Definition: retypes.h:1
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:261
VOID NTAPI ExReleaseResourceForThreadLite(IN PERESOURCE Resource, IN ERESOURCE_THREAD Thread)
Definition: resource.c:1844
int k
Definition: mpi.c:3369

Referenced by UDFDoDismountSequence(), UDFReleaseVCB(), and UDFVerifyVolume().

◆ WCacheSetMode__()

OSSTATUS WCacheSetMode__ ( IN PW_CACHE  Cache,
IN ULONG  Mode 
)

Definition at line 3425 of file wcache_lib.cpp.

3429 {
3431  Cache->Mode = Mode;
3432  return STATUS_SUCCESS;
3433 } // end WCacheSetMode__()
_In_ ULONG Mode
Definition: hubbusif.h:303
Definition: fatfs.h:173
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
#define WCACHE_MODE_MAX
Definition: wcache_lib.h:129
return STATUS_SUCCESS
Definition: btrfs.c:2938

Referenced by UDFLoadPartDesc(), UDFMountVolume(), and UDFVerifyVolume().

◆ WCacheStartDirect__()

OSSTATUS WCacheStartDirect__ ( IN PW_CACHE  Cache,
IN PVOID  Context,
IN BOOLEAN  Exclusive 
)

Definition at line 3100 of file wcache_lib.cpp.

3106 {
3107  if(Exclusive) {
3108  ExAcquireResourceExclusiveLite(&(Cache->WCacheLock), TRUE);
3109  } else {
3110  BrutePoint();
3111  ExAcquireResourceSharedLite(&(Cache->WCacheLock), TRUE);
3112  }
3113  return STATUS_SUCCESS;
3114 } // end WCacheStartDirect__()
#define TRUE
Definition: types.h:120
Definition: fatfs.h:173
BOOLEAN NTAPI ExAcquireResourceExclusiveLite(IN PERESOURCE Resource, IN BOOLEAN Wait)
Definition: resource.c:770
#define BrutePoint()
Definition: env_spec_w32.h:504
BOOLEAN NTAPI ExAcquireResourceSharedLite(IN PERESOURCE Resource, IN BOOLEAN Wait)
Definition: resource.c:885
return STATUS_SUCCESS
Definition: btrfs.c:2938

Referenced by UDFIsExtentCached(), and UDFVWorkItem().

◆ WCacheSyncReloc__()

VOID WCacheSyncReloc__ ( IN PW_CACHE  Cache,
IN PVOID  Context 
)

Definition at line 3469 of file wcache_lib.cpp.

3472 {
3473  ULONG frame;
3474  lba_t firstLba;
3475  lba_t* List = Cache->CachedBlocksList;
3476  lba_t Lba;
3477 // ULONG BSh = Cache->BlockSizeSh;
3478 // ULONG BS = Cache->BlockSize;
3479 // ULONG PS = BS << Cache->PacketSizeSh; // packet size (bytes)
3480 // ULONG PSs = Cache->PacketSize;
3481  PW_CACHE_ENTRY block_array;
3482  BOOLEAN mod;
3483  ULONG MaxReloc = Cache->PacketSize;
3484  PULONG reloc_tab = Cache->reloc_tab;
3485  ULONG RelocCount = 0;
3486  BOOLEAN IncompletePacket;
3487 
3488  IncompletePacket = (Cache->WriteCount >= MaxReloc) ? FALSE : TRUE;
3489  // enumerate modified blocks
3490  for(ULONG i=0; IncompletePacket && (i<Cache->BlockCount); i++) {
3491 
3492  Lba = List[i];
3493  frame = Lba >> Cache->BlocksPerFrameSh;
3494  firstLba = frame << Cache->BlocksPerFrameSh;
3495  block_array = Cache->FrameList[frame].Frame;
3496  if(!block_array) {
3497  return;
3498  }
3499  // check if modified
3500  mod = WCacheGetModFlag(block_array, Lba - firstLba);
3501  // update relocation table for modified sectors
3502  if(mod && (Cache->CheckUsedProc(Context, Lba) & WCACHE_BLOCK_USED)) {
3503  reloc_tab[RelocCount] = Lba;
3504  RelocCount++;
3505  if(RelocCount >= Cache->WriteCount) {
3506  Cache->UpdateRelocProc(Context, NULL, reloc_tab, RelocCount);
3507  break;
3508  }
3509  }
3510  }
3511 } // end WCacheSyncReloc__()
#define TRUE
Definition: types.h:120
Definition: fatfs.h:173
#define WCACHE_BLOCK_USED
Definition: wcache_lib.h:54
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
unsigned char BOOLEAN
smooth NULL
Definition: ftsmooth.c:416
LIST_ENTRY List
Definition: psmgr.c:57
Definition: wcache_lib.h:97
unsigned int * PULONG
Definition: retypes.h:1
#define WCacheGetModFlag(block_array, i)
Definition: wcache_lib.cpp:828
unsigned int ULONG
Definition: retypes.h:1
uint32 lba_t
Definition: platform.h:20
static int mod
Definition: i386-dis.c:1273

Referenced by UDFRecordVAT().

◆ WCacheWriteBlocks__()

OSSTATUS WCacheWriteBlocks__ ( IN PW_CACHE  Cache,
IN PVOID  Context,
IN PCHAR  Buffer,
IN lba_t  Lba,
IN ULONG  BCount,
OUT PSIZE_T  WrittenBytes,
IN BOOLEAN  CachedOnly 
)

Definition at line 2280 of file wcache_lib.cpp.

2290 {
2291  ULONG frame;
2292  ULONG i, saved_BC = BCount, n, d;
2294  PW_CACHE_ENTRY block_array;
2295  ULONG BSh = Cache->BlockSizeSh;
2296  ULONG BS = Cache->BlockSize;
2297  PCHAR addr;
2298 // PCHAR saved_buff = Buffer;
2299  SIZE_T _WrittenBytes;
2300  ULONG PS = Cache->PacketSize;
2301  ULONG PacketMask = PS-1; // here we assume that Packet Size value is 2^n
2302  ULONG block_type;
2303 // BOOLEAN Aligned = FALSE;
2304 
2305  BOOLEAN WriteThrough = FALSE;
2306  lba_t WTh_Lba;
2307  ULONG WTh_BCount;
2308 
2309  WcPrint(("WC:W %x (%x)\n", Lba, BCount));
2310 
2311  *WrittenBytes = 0;
2312 // UDFPrint(("BCount:%x\n",BCount));
2313  // check if we try to read too much data
2314  if(BCount >= Cache->MaxBlocks) {
2315  i = 0;
2316  if(CachedOnly) {
2318  goto EO_WCache_W2;
2319  }
2320  while(TRUE) {
2321 // UDFPrint((" BCount:%x\n",BCount));
2322  status = WCacheWriteBlocks__(Cache, Context, Buffer + (i<<BSh), Lba, min(PS,BCount), &_WrittenBytes, FALSE);
2323  (*WrittenBytes) += _WrittenBytes;
2324  BCount -= PS;
2325  Lba += PS;
2326  i += PS;
2327  if(!OS_SUCCESS(status) || (BCount < PS))
2328  return status;
2329  }
2330  }
2331  // check if we try to access beyond cached area
2332  if((Lba < Cache->FirstLba) ||
2333  (Lba + BCount - 1 > Cache->LastLba)) {
2334  return STATUS_INVALID_PARAMETER;
2335  }
2336  if(!CachedOnly) {
2337  ExAcquireResourceExclusiveLite(&(Cache->WCacheLock), TRUE);
2338  }
2339 
2340  frame = Lba >> Cache->BlocksPerFrameSh;
2341  i = Lba - (frame << Cache->BlocksPerFrameSh);
2342 
2343  if(!CachedOnly &&
2344  !OS_SUCCESS(status = WCacheCheckLimits(Cache, Context, Lba, BCount))) {
2346  return status;
2347  }
2348 
2349  // assume successful operation
2350  block_array = Cache->FrameList[frame].Frame;
2351  if(!block_array) {
2352 
2353  if(BCount && !(BCount & (PS-1)) && !(Lba & (PS-1)) &&
2354  (Cache->Mode != WCACHE_MODE_R) &&
2355  (i+BCount <= Cache->BlocksPerFrame) &&
2356  !Cache->NoWriteThrough) {
2357  status = Cache->WriteProc(Context, Buffer, BCount<<BSh, Lba, WrittenBytes, 0);
2358  if(!OS_SUCCESS(status)) {
2360  }
2361  goto EO_WCache_W2;
2362  }
2363 
2364  ASSERT(!CachedOnly);
2365  ASSERT(Cache->FrameCount < Cache->MaxFrames);
2366  block_array = WCacheInitFrame(Cache, Context, frame);
2367  if(!block_array) {
2369  goto EO_WCache_W;
2370  }
2371  }
2372 
2373  if(Cache->Mode == WCACHE_MODE_RAM &&
2374  BCount &&
2375 // !(Lba & (PS-1)) &&
2376  (!(BCount & (PS-1)) || (BCount > PS)) ) {
2377  WriteThrough = TRUE;
2378  WTh_Lba = Lba;
2379  WTh_BCount = BCount;
2380  } else
2381  if(Cache->Mode == WCACHE_MODE_RAM &&
2382  ((Lba & ~PacketMask) != ((Lba+BCount-1) & ~PacketMask))
2383  ) {
2384  WriteThrough = TRUE;
2385  WTh_Lba = Lba & ~PacketMask;
2386  WTh_BCount = PS;
2387  }
2388 
2389  Cache->FrameList[frame].UpdateCount++;
2390 // UDFPrint((" BCount:%x\n",BCount));
2391  while(BCount) {
2392  if(i >= Cache->BlocksPerFrame) {
2393  frame++;
2394  block_array = Cache->FrameList[frame].Frame;
2395  i -= Cache->BlocksPerFrame;
2396  }
2397  if(!block_array) {
2398  ASSERT(Cache->FrameCount < Cache->MaxFrames);
2399  block_array = WCacheInitFrame(Cache, Context, frame);
2400  if(!block_array) {
2402  goto EO_WCache_W;
2403  }
2404  }
2405  // 'write' cached extent (if any)
2406  // it is just copying
2407  while(BCount &&
2408  (i < Cache->BlocksPerFrame) &&
2409  (addr = (PCHAR)WCacheSectorAddr(block_array, i)) ) {
2410 // UDFPrint(("addr:%x:Buffer:%x:BS:%x:BCount:%x\n",addr, Buffer, BS, BCount));
2411  block_type = Cache->CheckUsedProc(Context, Lba+saved_BC-BCount);
2412  if(Cache->NoWriteBB &&
2413  /*WCacheGetBadFlag(block_array,i)*/
2414  (block_type & WCACHE_BLOCK_BAD)) {
2415  // bad packet. no cached write
2417  goto EO_WCache_W;
2418  }
2420  WCacheSetModFlag(block_array, i);
2421  Buffer += BS;
2422  *WrittenBytes += BS;
2423  i++;
2424  BCount--;
2425  }
2426  // write non-cached not-aligned extent (if any) till aligned one
2427  while(BCount &&
2428  (i & PacketMask) &&
2429  (Cache->Mode != WCACHE_MODE_R) &&
2430  (i < Cache->BlocksPerFrame) &&
2431  (!WCacheSectorAddr(block_array, i)) ) {
2433  if(!block_array[i].Sector) {
2435  goto EO_WCache_W;
2436  }
2437 // UDFPrint(("addr:%x:Buffer:%x:BS:%x:BCount:%x\n",block_array[i].Sector, Buffer, BS, BCount));
2438  DbgCopyMemory(block_array[i].Sector, Buffer, BS);
2439  WCacheSetModFlag(block_array, i);
2440  i++;
2441  Buffer += BS;
2442  *WrittenBytes += BS;
2443  BCount--;
2444  Cache->FrameList[frame].BlockCount ++;
2445  }
2446  // write non-cached packet-size-aligned extent (if any)
2447  // now we'll calculate total length & decide if has enough size
2448  if(!Cache->NoWriteThrough
2449  &&
2450  ( !(i & PacketMask) ||
2451  ((Cache->Mode == WCACHE_MODE_R) && (BCount >= PS)) )) {
2452  n = 0;
2453  while(BCount &&
2454  (i < Cache->BlocksPerFrame) &&
2455  (!WCacheSectorAddr(block_array, i)) ) {
2456  n++;
2457  BCount--;
2458  }
2459  BCount += n;
2460  n &= ~PacketMask;
2461 // if(!OS_SUCCESS(status = Cache->WriteProcAsync(Context, Buffer, BS*n, Lba+saved_BC-BCount, &_WrittenBytes, FALSE)))
2462  if(n) {
2463  // add previously written data to list
2464  d = saved_BC - BCount;
2465  WCacheInsertRangeToList(Cache->CachedBlocksList, &(Cache->BlockCount), Lba, d);
2466  WCacheInsertRangeToList(Cache->CachedModifiedBlocksList, &(Cache->WriteCount), Lba, d);
2467  Lba += d;
2468  saved_BC = BCount;
2469 
2470  while(n) {
2471  if(Cache->Mode == WCACHE_MODE_R)
2472  Cache->UpdateRelocProc(Context, Lba, NULL, PS);
2473  if(!OS_SUCCESS(status = Cache->WriteProc(Context, Buffer, PS<<BSh, Lba, &_WrittenBytes, 0))) {
2475  if(!OS_SUCCESS(status)) {
2476  goto EO_WCache_W;
2477  }
2478  }
2479  BCount -= PS;
2480  Lba += PS;
2481  saved_BC = BCount;
2482  i += PS;
2483  Buffer += PS<<BSh;
2484  *WrittenBytes += PS<<BSh;
2485  n-=PS;
2486  }
2487  }
2488  }
2489  // write non-cached not-aligned extent (if any)
2490  while(BCount &&
2491  (i < Cache->BlocksPerFrame) &&
2492  (!WCacheSectorAddr(block_array, i)) ) {
2494  if(!block_array[i].Sector) {
2496  goto EO_WCache_W;
2497  }
2498 // UDFPrint(("addr:%x:Buffer:%x:BS:%x:BCount:%x\n",block_array[i].Sector, Buffer, BS, BCount));
2499  DbgCopyMemory(block_array[i].Sector, Buffer, BS);
2500  WCacheSetModFlag(block_array, i);
2501  i++;
2502  Buffer += BS;
2503  *WrittenBytes += BS;
2504  BCount--;
2505  Cache->FrameList[frame].BlockCount ++;
2506  }
2507  }
2508 
2509 EO_WCache_W:
2510 
2511  // we know the number of unread sectors if an error occured
2512  // so we can need to update BlockCount
2513  // return number of read bytes
2514  WCacheInsertRangeToList(Cache->CachedBlocksList, &(Cache->BlockCount), Lba, saved_BC - BCount);
2515  WCacheInsertRangeToList(Cache->CachedModifiedBlocksList, &(Cache->WriteCount), Lba, saved_BC - BCount);
2516 
2517  if(WriteThrough && !BCount) {
2518  ULONG d;
2519 // lba_t lastLba;
2520  ULONG firstPos;
2521  ULONG lastPos;
2522 
2523  BCount = WTh_BCount;
2524  Lba = WTh_Lba;
2525  while(BCount) {
2526  frame = Lba >> Cache->BlocksPerFrameSh;
2527 // firstLba = frame << Cache->BlocksPerFrameSh;
2528  firstPos = WCacheGetSortedListIndex(Cache->BlockCount, Cache->CachedBlocksList, Lba);
2529  d = min(Lba+BCount, (frame+1) << Cache->BlocksPerFrameSh) - Lba;
2530  lastPos = WCacheGetSortedListIndex(Cache->BlockCount, Cache->CachedBlocksList, Lba+d);
2531  block_array = Cache->FrameList[frame].Frame;
2532  if(!block_array) {
2533  ASSERT(FALSE);
2534  BCount -= d;
2535  Lba += d;
2536  continue;
2537  }
2538  status = WCacheFlushBlocksRAM(Cache, Context, block_array, Cache->CachedBlocksList, firstPos, lastPos, FALSE);
2539  WCacheRemoveRangeFromList(Cache->CachedModifiedBlocksList, &(Cache->WriteCount), Lba, d);
2540  BCount -= d;
2541  Lba += d;
2542  }
2543  }
2544 
2545 EO_WCache_W2:
2546 
2547  if(!CachedOnly) {
2549  }
2550  return status;
2551 } // end WCacheWriteBlocks__()
signed char * PCHAR
Definition: retypes.h:7
#define ExGetCurrentResourceThread()
Definition: env_spec_w32.h:633
VOID __fastcall WCacheInsertRangeToList(IN lba_t *List, IN PULONG BlockCount, IN lba_t Lba, IN ULONG BCount)
Definition: wcache_lib.cpp:588
#define TRUE
Definition: types.h:120
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
#define DbgAllocatePoolWithTag(a, b, c)
Definition: env_spec_w32.h:333
Definition: fatfs.h:173
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
GLdouble n
Definition: glext.h:7729
OSSTATUS WCacheRaiseIoError(IN PW_CACHE Cache, IN PVOID Context, IN OSSTATUS Status, IN ULONG Lba, IN ULONG BCount, IN PVOID Buffer, IN BOOLEAN ReadOp, IN PBOOLEAN Retry)
Definition: wcache_lib.cpp:946
OSSTATUS __fastcall WCacheCheckLimits(IN PW_CACHE Cache, IN PVOID Context, IN lba_t ReqLba, IN ULONG BCount)
#define WCacheSetModFlag(block_array, i)
Definition: wcache_lib.cpp:811
BOOLEAN NTAPI ExAcquireResourceExclusiveLite(IN PERESOURCE Resource, IN BOOLEAN Wait)
Definition: resource.c:770
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
ULONG WCacheGetSortedListIndex(IN ULONG BlockCount, IN lba_t *List, IN lba_t Lba)
Definition: wcache_lib.cpp:449
#define OSSTATUS
Definition: env_spec_w32.h:57
struct _ACPI_EFI_BOOT_SERVICES * BS
PCHAR Sector
Definition: wcache_lib.h:99
unsigned char BOOLEAN
#define WCacheSectorAddr(block_array, i)
Definition: wcache_lib.cpp:864
smooth NULL
Definition: ftsmooth.c:416
Definition: bufpool.h:45
#define WCACHE_BLOCK_BAD
Definition: wcache_lib.h:56
#define WCACHE_W_OP
Definition: wcache_lib.h:70
#define PCHAR
Definition: match.c:90
#define d
Definition: ke_i.h:81
#define MEM_WCBUF_TAG
Definition: wcache_lib.cpp:56
PW_CACHE_ENTRY __fastcall WCacheInitFrame(IN PW_CACHE Cache, IN PVOID Context, IN ULONG frame)
Definition: wcache_lib.cpp:731
Definition: wcache_lib.h:97
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
GLenum const GLvoid * addr
Definition: glext.h:9621
#define OS_SUCCESS(a)
Definition: env_spec_w32.h:56
VOID __fastcall WCacheRemoveRangeFromList(IN lba_t *List, IN PULONG BlockCount, IN lba_t Lba, IN ULONG BCount)
Definition: wcache_lib.cpp:675
#define WcPrint
Definition: wcache_lib.cpp:61
#define WCACHE_MODE_RAM
Definition: wcache_lib.h:127
#define CACHED_BLOCK_MEMORY_TYPE
Definition: wcache_lib.h:115
ULONG_PTR SIZE_T
Definition: typedefs.h:78
#define DbgCopyMemory
Definition: env_spec_w32.h:331
#define min(a, b)
Definition: monoChain.cc:55
OSSTATUS __fastcall WCacheFlushBlocksRAM(IN PW_CACHE Cache, IN PVOID Context, PW_CACHE_ENTRY block_array, lba_t *List, ULONG firstPos, ULONG lastPos, BOOLEAN Purge)
#define WCACHE_MODE_R
Definition: wcache_lib.h:126
unsigned int ULONG
Definition: retypes.h:1
VOID NTAPI ExReleaseResourceForThreadLite(IN PERESOURCE Resource, IN ERESOURCE_THREAD Thread)
Definition: resource.c:1844
uint32 lba_t
Definition: platform.h:20
return STATUS_SUCCESS
Definition: btrfs.c:2938
static SERVICE_STATUS status
Definition: service.c:31
OSSTATUS WCacheWriteBlocks__(IN PW_CACHE Cache, IN PVOID Context, IN PCHAR Buffer, IN lba_t Lba, IN ULONG BCount, OUT PSIZE_T WrittenBytes, IN BOOLEAN CachedOnly)
#define STATUS_DEVICE_DATA_ERROR
Definition: udferr_usr.h:159
Definition: ps.c:97

Referenced by UDFWriteSectors(), and WCacheWriteBlocks__().