Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

149 lines
3.0 KiB

  1. /*++
  2. Copyright (c) 1992-2000 Microsoft Corporation
  3. Module Name:
  4. rwcache.hxx
  5. Abstract:
  6. This class implements a read write cache.
  7. Author:
  8. Norbert Kusters (norbertk) 23-Apr-92
  9. --*/
  10. #if !defined(_READ_WRITE_CACHE_DEFN_)
  11. #define _READ_WRITE_CACHE_DEFN_
  12. #include "dcache.hxx"
  13. #include "hmem.hxx"
  14. #include "numset.hxx"
  15. #if defined ( _AUTOCHECK_ )
  16. #define IFSUTIL_EXPORT
  17. #elif defined ( _IFSUTIL_MEMBER_ )
  18. #define IFSUTIL_EXPORT __declspec(dllexport)
  19. #else
  20. #define IFSUTIL_EXPORT __declspec(dllimport)
  21. #endif
  22. //#define RWCACHE_PERF_COUNTERS 1
  23. struct RW_CACHE_BLOCK {
  24. BOOLEAN InUse;
  25. BOOLEAN IsDirty;
  26. ULONG Age;
  27. BIG_INT SectorNumber;
  28. HMEM SectorBuffer;
  29. };
  30. DEFINE_POINTER_TYPES(RW_CACHE_BLOCK);
  31. DECLARE_CLASS(READ_WRITE_CACHE);
  32. class READ_WRITE_CACHE : public DRIVE_CACHE {
  33. public:
  34. IFSUTIL_EXPORT
  35. DECLARE_CONSTRUCTOR( READ_WRITE_CACHE );
  36. VIRTUAL
  37. ~READ_WRITE_CACHE(
  38. );
  39. NONVIRTUAL
  40. IFSUTIL_EXPORT
  41. BOOLEAN
  42. Initialize(
  43. IN OUT PIO_DP_DRIVE Drive,
  44. IN ULONG NumberOfCacheBlocks
  45. );
  46. VIRTUAL
  47. BOOLEAN
  48. Read(
  49. IN BIG_INT StartingSector,
  50. IN SECTORCOUNT NumberOfSectors,
  51. OUT PVOID Buffer
  52. );
  53. VIRTUAL
  54. BOOLEAN
  55. Write(
  56. IN BIG_INT StartingSector,
  57. IN SECTORCOUNT NumberOfSectors,
  58. IN PVOID Buffer
  59. );
  60. VIRTUAL
  61. BOOLEAN
  62. Flush(
  63. );
  64. #if defined(RWCACHE_PERF_COUNTERS)
  65. NONVIRTUAL
  66. IFSUTIL_EXPORT
  67. VOID
  68. QueryPerformanceCounters(
  69. PULONG RMiss,
  70. PULONG RHit,
  71. PULONG ROverHead,
  72. PULONG WMiss,
  73. PULONG WHit,
  74. PULONG Usage
  75. );
  76. #endif
  77. private:
  78. NONVIRTUAL
  79. PRW_CACHE_BLOCK
  80. GetSectorCacheBlock(
  81. IN BIG_INT SectorNumber
  82. );
  83. NONVIRTUAL
  84. PRW_CACHE_BLOCK
  85. GetNextAvailbleCacheBlock(
  86. IN BIG_INT SectorNumber
  87. );
  88. NONVIRTUAL
  89. VOID
  90. FlushThisCacheBlock(
  91. IN OUT PRW_CACHE_BLOCK Block
  92. );
  93. NONVIRTUAL
  94. VOID
  95. Construct(
  96. );
  97. NONVIRTUAL
  98. VOID
  99. Destroy(
  100. );
  101. NUMBER_SET _sectors_cached;
  102. PRW_CACHE_BLOCK* _cache_blocks;
  103. ULONG _num_blocks;
  104. HMEM _write_buffer;
  105. ULONG _sector_size;
  106. BOOLEAN _error_occurred;
  107. ULONG _sectors_per_buffer;
  108. #if defined(RWCACHE_PERF_COUNTERS)
  109. ULONG _RMiss, _RHit, _ROverHead, _WMiss, _WHit, _Usage;
  110. #endif
  111. };
  112. #endif