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.

173 lines
6.8 KiB

  1. #ifndef _CONNECTIONS_HPP_
  2. #define _CONNECTIONS_HPP_
  3. // Ruler
  4. // 1 2 3 4 5 6 7 8
  5. //345678901234567890123456789012345678901234567890123456789012345678901234567890
  6. /********************************************************************/
  7. /* */
  8. /* The standard layout. */
  9. /* */
  10. /* The standard layout for 'hpp' files for this code is as */
  11. /* follows: */
  12. /* */
  13. /* 1. Include files. */
  14. /* 2. Constants exported from the class. */
  15. /* 3. Data structures exported from the class. */
  16. /* 4. Forward references to other data structures. */
  17. /* 5. Class specifications (including inline functions). */
  18. /* 6. Additional large inline functions. */
  19. /* */
  20. /* Any portion that is not required is simply omitted. */
  21. /* */
  22. /********************************************************************/
  23. #include "Global.hpp"
  24. #include "Environment.hpp"
  25. #include "Common.hpp"
  26. #include "Find.hpp"
  27. #include "NewPage.hpp"
  28. #include "Prefetch.hpp"
  29. /********************************************************************/
  30. /* */
  31. /* Constants exported from the class. */
  32. /* */
  33. /* At the top level the parent of all caches is a constant */
  34. /* called 'GlobalRoot'. */
  35. /* */
  36. /********************************************************************/
  37. CONST SBIT32 GlobalRoot = -1;
  38. /********************************************************************/
  39. /* */
  40. /* Class forward references. */
  41. /* */
  42. /* We need to refer to the following classes before they are */
  43. /* fully specified so here we list them as forward references. */
  44. /* */
  45. /********************************************************************/
  46. class CACHE;
  47. class HEAP;
  48. class PAGE;
  49. /********************************************************************/
  50. /* */
  51. /* Data structures exported from the class. */
  52. /* */
  53. /* We communicate between a page and the associated cache */
  54. /* using an address pointer, page pointer and version triple. */
  55. /* */
  56. /********************************************************************/
  57. typedef struct
  58. {
  59. VOID *Address;
  60. PAGE *Page;
  61. SBIT32 Version;
  62. }
  63. ADDRESS_AND_PAGE;
  64. /********************************************************************/
  65. /* */
  66. /* Connections to other classes. */
  67. /* */
  68. /* The connections between the various classes in the memory */
  69. /* allocator is a twisted mess. The root cause is that at a */
  70. /* fundamental level. Every part depends on every other part. */
  71. /* Nonetheless, a significant effort has been made to seperate */
  72. /* the parts as best as possible. The various classes are */
  73. /* linked here so every part can find the correct instance of */
  74. /* every other part. */
  75. /* */
  76. /********************************************************************/
  77. class CONNECTIONS : public ENVIRONMENT, public COMMON
  78. {
  79. //
  80. // Private data.
  81. //
  82. BOOLEAN Active;
  83. public:
  84. //
  85. // Public data.
  86. //
  87. // All the classes that inherit this class get
  88. // pointers to related classes they need to call
  89. // from time to time.
  90. //
  91. FIND *Find;
  92. HEAP *Heap;
  93. NEW_PAGE *NewPage;
  94. CACHE *ParentCache;
  95. //
  96. // The 'Prefetch' is a class that will trigger
  97. // a cache fetch if the CPU supports it.
  98. //
  99. PREFETCH Prefetch;
  100. //
  101. // Public functions.
  102. //
  103. // The sole job of this class is to provide
  104. // pointers to related classes. These pointers
  105. // are unknown until after the heap has been
  106. // created and this need to be dynamically
  107. // linked during the execution of the top
  108. // level heap constructor.
  109. //
  110. CONNECTIONS( VOID );
  111. VOID UpdateConnections
  112. (
  113. FIND *NewFind,
  114. HEAP *NewHeap,
  115. NEW_PAGE *NewPages,
  116. CACHE *NewParentCache
  117. );
  118. ~CONNECTIONS( VOID );
  119. //
  120. // Public inline functions.
  121. //
  122. // The complex linkages in the heap sometimes
  123. // lead to the case where a class has a pointer
  124. // to it's cache but not to the class it needs
  125. // to call. Thus, to avoid replicating large
  126. // numbers of pointers we export call interfaces
  127. // from here to allow the required calls to be
  128. // made indirectly.
  129. //
  130. INLINE VOID DeleteFromFindList( PAGE *Page )
  131. { Find -> DeleteFromFindList( Page ); }
  132. INLINE VOID DeletePage( PAGE *Page )
  133. { NewPage -> DeletePage( Page ); }
  134. INLINE HEAP *GetHeap( VOID )
  135. { return Heap; }
  136. INLINE CACHE *GetParentCache( VOID )
  137. { return ParentCache; }
  138. INLINE VOID InsertInFindList( PAGE *Page )
  139. { Find -> InsertInFindList( Page ); }
  140. INLINE BOOLEAN TopCache( VOID )
  141. { return (ParentCache == ((CACHE*) GlobalRoot)); }
  142. private:
  143. //
  144. // Disabled operations.
  145. //
  146. CONNECTIONS( CONST CONNECTIONS & Copy );
  147. VOID operator=( CONST CONNECTIONS & Copy );
  148. };
  149. #endif