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.

167 lines
4.5 KiB

  1. /*
  2. Copyright (c) 1992 Microsoft Corporation
  3. Module Name:
  4. iopool.h
  5. Abstract:
  6. This module contains the IO pool management stuff.
  7. Author:
  8. Jameel Hyder (microsoft!jameelh)
  9. Revision History:
  10. 25 Feb 1994 Initial Version
  11. Notes: Tab stop: 4
  12. --*/
  13. #ifndef _IOPOOL_
  14. #define _IOPOOL_
  15. #define DWORDSIZEBLOCK(Size) (((Size) + sizeof(DWORD) - 1) & ~(sizeof(DWORD)-1))
  16. #define LONGLONGSIZEBLOCK(Size) ((Size) + (sizeof(LONGLONG) - (Size)%(sizeof(LONGLONG))))
  17. #define PAGED_BLOCK_SIGNATURE *(PDWORD)"PAGD"
  18. #define NONPAGED_BLOCK_SIGNATURE *(PDWORD)"NPGD"
  19. /* MSKK hideyukn, Our Nls table is larger than 0x20000, 07/05/95 */
  20. // used for debug builds only: bumped up to 0x200000 (note one more 0)
  21. #define MAXIMUM_ALLOC_SIZE 0x200000 // For sanity checking
  22. typedef struct
  23. {
  24. unsigned tg_Size:20;
  25. unsigned tg_Flags:4;
  26. unsigned tg_Tag:8;
  27. } TAG, *PTAG;
  28. #define MAX_POOL_AGE 6
  29. #define POOL_AGE_TIME 15
  30. #define POOL_ALLOC_SIZE (0x2000) - POOL_OVERHEAD
  31. #define NUM_BUFS_IN_POOL 3
  32. #define POOL_ALLOC_3 ASP_QUANTUM
  33. #define POOL_ALLOC_2 1600
  34. #define POOL_ALLOC_1 512
  35. #define LOCKS_BUF_SPACE (POOL_ALLOC_SIZE - sizeof(IOPOOL) - \
  36. POOL_ALLOC_1 - POOL_ALLOC_2 - POOL_ALLOC_3 - \
  37. (NUM_BUFS_IN_POOL * sizeof(IOPOOL_HDR)))
  38. #define IO_POOL_NOT_IN_USE 0
  39. #define IO_POOL_IN_USE 1
  40. #define IO_POOL_HUGE_BUFFER 2
  41. #define NUM_LOCKS_IN_POOL ((LOCKS_BUF_SPACE)/(sizeof(IOPOOL_HDR) + sizeof(FORKLOCK)))
  42. // The pool is structured as a set of 1 each of POOL_ALLOC_x buffers linked in
  43. // ascending order of sizes. The balance of the POOL_ALLOC_SIZE is divided into
  44. // a number of fork-lock structures. The layout is as follows:
  45. //
  46. // +---------------------+
  47. // | IoPool Structure |----------+
  48. // | |--+ |
  49. // +---------------------+ | |
  50. // +--| IoPool Hdr |<-+ |
  51. // | +---------------------+ |
  52. // | | | |
  53. // | . Buffer 1 . |
  54. // | | | |
  55. // | +---------------------+ |
  56. // +->| IoPool Hdr |--+ |
  57. // +---------------------+ | |
  58. // | | | |
  59. // . Buffer 2 . | |
  60. // | | | |
  61. // +---------------------+ | |
  62. // |||--| IoPool Hdr |<-+ |
  63. // +---------------------+ |
  64. // | | |
  65. // . Buffer 3 . |
  66. // | | |
  67. // +---------------------+ |
  68. // +--| IoPool Hdr |<---------+
  69. // | +---------------------+
  70. // | | |
  71. // . . ForkLock1 .
  72. // . | |
  73. // | +---------------------+
  74. // +->| IoPool Hdr |--|||
  75. // +---------------------+
  76. // | |
  77. // . ForkLockN .
  78. // | |
  79. // +---------------------+
  80. //
  81. //
  82. #if DBG
  83. #define POOLHDR_SIGNATURE *(PDWORD)"PLH"
  84. #define VALID_PLH(pPoolHdr) (((pPoolHdr) != NULL) && \
  85. ((pPoolHdr)->Signature == POOLHDR_SIGNATURE))
  86. #else
  87. #define VALID_PLH(pPoolHdr) ((pPoolHdr) != NULL)
  88. #endif
  89. typedef struct _IoPoolHdr
  90. {
  91. #if DBG
  92. DWORD Signature;
  93. DWORD IoPoolHdr_Align1;
  94. #endif
  95. union
  96. {
  97. struct _IoPoolHdr * iph_Next; // Valid when it is on the free list
  98. struct _IoPool * iph_pPool; // Valid when it is allocated. Used
  99. // to put it back on the free list
  100. };
  101. DWORD IoPoolHdr_Align2;
  102. TAG iph_Tag; // Keep it at end since it is accessed
  103. // by moving back from the free ptr
  104. } IOPOOL_HDR, *PIOPOOL_HDR;
  105. #if DBG
  106. #define IOPOOL_SIGNATURE *(PDWORD)"IOP"
  107. #define VALID_IOP(pPool) (((pPool) != NULL) && \
  108. ((pPool)->Signature == IOPOOL_SIGNATURE))
  109. #else
  110. #define VALID_IOP(pPool) ((pPool) != NULL)
  111. #endif
  112. typedef struct _IoPool
  113. {
  114. #if DBG
  115. DWORD Signature;
  116. DWORD QuadAlign1;
  117. #endif
  118. struct _IoPool * iop_Next;
  119. struct _IoPool ** iop_Prev;
  120. struct _IoPoolHdr * iop_FreeBufHead; // The list of POOL headers start here
  121. struct _IoPoolHdr * iop_FreeLockHead; // The list of fork-locks start here
  122. DWORD QuadAlign2;
  123. USHORT iop_Age; // Used to age out pool
  124. BYTE iop_NumFreeBufs; // Number of free IO buffer
  125. BYTE iop_NumFreeLocks; // Number of free fork locks
  126. } IOPOOL, *PIOPOOL;
  127. LOCAL PIOPOOL afpIoPoolHead = { NULL };
  128. LOCAL AFP_SPIN_LOCK afpIoPoolLock = { 0 };
  129. LOCAL USHORT afpPoolAllocSizes[NUM_BUFS_IN_POOL] =
  130. {
  131. POOL_ALLOC_1,
  132. POOL_ALLOC_2,
  133. POOL_ALLOC_3
  134. };
  135. LOCAL AFPSTATUS FASTCALL
  136. afpIoPoolAge(
  137. IN PVOID pContext
  138. );
  139. #endif // _IOPOOL_
  140.