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.

250 lines
6.4 KiB

  1. //+---------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1992 - 1992.
  5. //
  6. // File: vectfunc.hxx
  7. //
  8. // Contents: CPagedVector inline functions
  9. //
  10. // Classes:
  11. //
  12. // Functions:
  13. //
  14. // History: 28-Oct-92 PhilipLa Created
  15. //
  16. //----------------------------------------------------------------------------
  17. #ifndef __VECTFUNC_HXX__
  18. #define __VECTFUNC_HXX__
  19. #define STG_S_FOUND MAKE_SCODE(SEVERITY_SUCCESS, FACILITY_STORAGE, 0x400)
  20. //+-------------------------------------------------------------------------
  21. //
  22. // Method: CPagedVector::ReleaseTable, public
  23. //
  24. // Synopsis: Release a table that is no longer needed.
  25. //
  26. // Arguments: [iTable] -- index into vector
  27. //
  28. // Returns: S_OK if call completed OK.
  29. //
  30. // History: 27-Oct-92 PhilipLa Created.
  31. //
  32. // Notes:
  33. //
  34. //--------------------------------------------------------------------------
  35. inline void CPagedVector::ReleaseTable(const FSINDEX iTable)
  36. {
  37. if ((_amp == NULL) || (_amp[iTable] == NULL))
  38. {
  39. _pmpt->ReleasePage(this, _sid, iTable);
  40. }
  41. else
  42. {
  43. _amp[iTable]->Release();
  44. }
  45. }
  46. //+-------------------------------------------------------------------------
  47. //
  48. // Method: CPagedVector::GetBits, public
  49. //
  50. // Synopsis: Return CVectBits for a given table
  51. //
  52. // Arguments: [iTable] -- Index of table to get bits for
  53. //
  54. // Returns: Pointer to CVectBits associated with table
  55. //
  56. // History: 27-Oct-92 PhilipLa Created.
  57. //
  58. //--------------------------------------------------------------------------
  59. inline CVectBits * CPagedVector::GetBits(const ULONG iTable)
  60. {
  61. msfAssert(iTable < _ulSize);
  62. if (_avb == NULL)
  63. return NULL;
  64. else
  65. return (&_avb[iTable]);
  66. }
  67. //+---------------------------------------------------------------------------
  68. //
  69. // Member: CPagedVector::ResetDirty, public
  70. //
  71. // Synopsis: Reset the dirty bit on the specified page
  72. //
  73. // Arguments: [iTable] -- Table to reset bit on
  74. //
  75. // History: 28-Oct-92 PhilipLa Created
  76. //
  77. // Notes: This function is always called on a page with an
  78. // open reference. Therefore, the page is
  79. // guaranteed to be in the page table, and that
  80. // FindPage call should never return an error.
  81. //
  82. //----------------------------------------------------------------------------
  83. inline void CPagedVector::ResetDirty(ULONG iTable)
  84. {
  85. SCODE sc;
  86. if (_amp == NULL)
  87. {
  88. CMSFPage *pmp;
  89. msfChk(_pmpt->FindPage(this, _sid, iTable, &pmp));
  90. msfAssert(sc == STG_S_FOUND);
  91. msfAssert(pmp->IsInUse() &&
  92. aMsg("Called ResetDirty on page not in use."));
  93. pmp->ResetDirty();
  94. }
  95. else
  96. {
  97. msfAssert(_amp != NULL);
  98. msfAssert(_amp[iTable] != NULL);
  99. _amp[iTable]->ResetDirty();
  100. }
  101. Err:
  102. return;
  103. }
  104. //+---------------------------------------------------------------------------
  105. //
  106. // Member: CPagedVector::SetSect, public
  107. //
  108. // Synopsis: Set the sector location of a page
  109. //
  110. // Arguments: [iTable] -- Table to set page for
  111. // [sect] -- Sector location of page
  112. //
  113. // History: 02-Nov-92 PhilipLa Created
  114. //
  115. // Notes: This function is always called on a page with an
  116. // open reference. Therefore, the page is
  117. // guaranteed to be in the page table, and that
  118. // FindPage call should never return an error.
  119. //
  120. //----------------------------------------------------------------------------
  121. inline void CPagedVector::SetSect(const ULONG iTable, const SECT sect)
  122. {
  123. SCODE sc;
  124. if (_amp == NULL)
  125. {
  126. CMSFPage *pmp;
  127. msfChk(_pmpt->FindPage(this, _sid, iTable, &pmp));
  128. msfAssert(sc == STG_S_FOUND);
  129. msfAssert(pmp->IsInUse() &&
  130. aMsg("Called SetSect on page not in use."));
  131. #ifdef SORTPAGETABLE
  132. _pmpt->SetSect(pmp, sect);
  133. #else
  134. pmp->SetSect(sect);
  135. #endif
  136. }
  137. else
  138. {
  139. msfAssert(_amp != NULL);
  140. msfAssert(_amp[iTable] != NULL);
  141. #ifdef SORTPAGETABLE
  142. _pmpt->SetSect(BP_TO_P(CMSFPage *, _amp[iTable]), sect);
  143. #else
  144. _amp[iTable]->SetSect(sect);
  145. #endif
  146. }
  147. Err:
  148. return;
  149. }
  150. //+---------------------------------------------------------------------------
  151. //
  152. // Member: CPagedVector::FreeTable, public
  153. //
  154. // Synopsis: Free a given table (NULL its pointer)
  155. //
  156. // Arguments: [iTable] -- Table to free
  157. //
  158. // History: 04-Nov-92 PhilipLa Created
  159. //
  160. //----------------------------------------------------------------------------
  161. inline void CPagedVector::FreeTable(ULONG iTable)
  162. {
  163. if ((_amp != NULL) && (_amp[iTable] != NULL))
  164. {
  165. msfAssert(_amp[iTable]->GetVector() == this);
  166. _amp[iTable] = NULL;
  167. }
  168. }
  169. //+---------------------------------------------------------------------------
  170. //
  171. // Member: CPagedVector::SetParent, public
  172. //
  173. // Synopsis: Set the parent of this page table
  174. //
  175. // Arguments: [pms] -- Pointer to new parent
  176. //
  177. // History: 05-Nov-92 PhilipLa Created
  178. //
  179. //----------------------------------------------------------------------------
  180. inline void CPagedVector::SetParent(CMStream *pms)
  181. {
  182. _pmsParent = P_TO_BP(CBasedMStreamPtr, pms);
  183. }
  184. //+---------------------------------------------------------------------------
  185. //
  186. // Member: CPagedVector::GetParent, public
  187. //
  188. // Synopsis: Return the parent MS pointer of a vector
  189. //
  190. // History: 05-Nov-92 PhilipLa Created
  191. //
  192. //----------------------------------------------------------------------------
  193. inline CMStream * CPagedVector::GetParent(void) const
  194. {
  195. return BP_TO_P(CMStream *, _pmsParent);
  196. }
  197. //+---------------------------------------------------------------------------
  198. //
  199. // Member: CPagedVector::ResetBits, public
  200. //
  201. // Synopsis: Reset all the optimization bits in the vector
  202. //
  203. // History: 08-Feb-93 PhilipLa Created
  204. //
  205. //----------------------------------------------------------------------------
  206. void CPagedVector::ResetBits(void)
  207. {
  208. if (_avb != NULL)
  209. {
  210. for (ULONG i = 0; i < _ulSize; i++)
  211. {
  212. _avb[i].full = FALSE;
  213. _avb[i].firstfree = 0;
  214. }
  215. }
  216. }
  217. #endif // #ifndef __VECTFUNC_HXX__