Leaked source code of windows server 2003
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.

141 lines
3.3 KiB

  1. // Copyright (C) 1997 Microsoft Corporation. All rights reserved.
  2. #if _MSC_VER > 1000
  3. #pragma once
  4. #endif
  5. #ifndef __SUBFILE_H__
  6. #define __SUBFILE_H__
  7. #include "hhtypes.h"
  8. // we have three possible caching schemes:
  9. // HH_FAST_CACHE - fast but its a hog!
  10. //
  11. // We store a small number of pages (2-3) for each unique
  12. // title and subfile combination. This results is quite of bit
  13. // of memory being used per collection but oh boy is it fast!
  14. //
  15. //#define HH_FAST_CACHE
  16. // HH_EFFICIENT_CACHE - slow but it saves memory!
  17. //
  18. // We store a small number of moderate pages (2-3) for each unique
  19. // subfile regardless of the title it came from. This results in an
  20. // efficient use of memory since like subfiles, such as #TOCIDX, share
  21. // the same group of cache pages instead of having their own uniqe group
  22. // per title. However, this method slows things down since multiple reads
  23. // from the same named subfile accross several titles results in many
  24. // cache misses.
  25. //
  26. //#define HH_EFFICIENT_CACHE
  27. // HH_SHARED_CACHE - nice balance of speed and size!
  28. //
  29. // We store a large number of pages (16+) for the entire collection.
  30. // This result is a fixed quantity of cache pages regardless of number
  31. // and type of subfiles we have. It utilizes memory well since we can
  32. // access multiple subfiles of the same name accross several titles
  33. // effectively yielding a larger pool of cache pages.
  34. //
  35. // [paulti] - We want to use this method exclusively. Please see me
  36. // if you want to change this for any reason.
  37. //
  38. #define HH_SHARED_CACHE
  39. #if defined ( HH_FAST_CACHE )
  40. #define CACHE_PAGE_COUNT 3
  41. #elif defined ( HH_EFFICIENT_CACHE )
  42. #define CACHE_PAGE_COUNT 5
  43. #else // HH_SHARED_CACHE
  44. #define CACHE_PAGE_COUNT 32
  45. #endif
  46. class CSubFileSystem;
  47. class CTitleInfo;
  48. typedef struct page {
  49. CTitleInfo* pTitle;
  50. DWORD dwPage;
  51. HASH hashPathname;
  52. DWORD dwLRU;
  53. BYTE rgb[PAGE_SIZE];
  54. } PAGE;
  55. //////////////////////////////////////////////
  56. //
  57. // CPagesList
  58. //
  59. //////////////////////////////////////////////
  60. class CPagesList
  61. {
  62. friend class CPagedSubfile;
  63. friend class CPages;
  64. public:
  65. CPagesList() { m_pFirst = 0; }
  66. ~CPagesList();
  67. private:
  68. CPages* m_pFirst;
  69. CPages* GetPages( HASH );
  70. };
  71. ////////////////////////////////////////
  72. //
  73. // CPages
  74. //
  75. ////////////////////////////////////////
  76. class CPages
  77. {
  78. public:
  79. void Flush( CTitleInfo* pTitle );
  80. private:
  81. CPages( HASH );
  82. void* Find( const CTitleInfo *, HASH, DWORD );
  83. void* Alloc( CTitleInfo *, HASH, DWORD );
  84. void Flush( void );
  85. CPages* m_pNext;
  86. HASH m_hash;
  87. DWORD m_dwLRUPage;
  88. DWORD m_dwLRUCount;
  89. PAGE m_pages[CACHE_PAGE_COUNT];
  90. friend class CPagedSubfile;
  91. friend class CPagesList;
  92. };
  93. //////////////////////////////////////////////
  94. //
  95. // CPagedSubfile
  96. //
  97. //////////////////////////////////////////////
  98. class CPagedSubfile
  99. {
  100. public:
  101. CPagedSubfile();
  102. ~CPagedSubfile();
  103. HRESULT Open(CTitleInfo *, LPCSTR);
  104. void* Offset(DWORD dwOffs);
  105. void* Page(DWORD iPage);
  106. private:
  107. CSubFileSystem* m_pCSubFileSystem;
  108. CTitleInfo* m_pTitle;
  109. HASH m_hashPathname;
  110. HASH m_hash;
  111. DWORD m_cbSize;
  112. CPages* m_pPages;
  113. };
  114. #endif