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.

113 lines
2.8 KiB

  1. /*++
  2. Copyright (c) 1992 Microsoft Corporation
  3. Module Name:
  4. blkpool.h
  5. Abstract:
  6. This module contains routines to manage block pools.
  7. Author:
  8. Jameel Hyder (jameelh@microsoft.com)
  9. Nikhil Kamkolkar (nikhilk@microsoft.com)
  10. Revision History:
  11. 19 Jun 1992 Initial Version
  12. Notes: Tab stop: 4
  13. --*/
  14. #ifndef _BLK_POOL
  15. #define _BLK_POOL
  16. #define SM_BLK 1024
  17. #define LG_BLK 2048
  18. #define XL_BLK 4096
  19. #define BC_SIGNATURE *(PULONG)"BLKC"
  20. #if DBG
  21. #define VALID_BC(pChunk) (((pChunk) != NULL) && \
  22. ((pChunk)->bc_Signature == BC_SIGNATURE))
  23. #else
  24. #define VALID_BC(pChunk) ((pChunk) != NULL)
  25. #endif
  26. typedef struct _BLK_CHUNK
  27. {
  28. #if DBG
  29. DWORD bc_Signature;
  30. #endif
  31. struct _BLK_CHUNK * bc_Next; // Pointer to next in the link
  32. struct _BLK_CHUNK **bc_Prev; // Pointer to previous one
  33. UCHAR bc_NumFree; // Number of free blocks in the chunk
  34. UCHAR bc_NumAlloc; // Number of blocks used (DBG only)
  35. UCHAR bc_Age; // Number of invocations since the chunk free
  36. BLKID bc_BlkId; // Id of the block
  37. struct _BLK_HDR * bc_FreeHead; // Head of the list of free blocks
  38. // This is followed by an array of N blks of size M such that the block header
  39. // is exactly atalkChunkSize[i]
  40. } BLK_CHUNK, *PBLK_CHUNK;
  41. #define BH_SIGNATURE *(PULONG)"BLKH"
  42. #if DBG
  43. #define VALID_BH(pBlkHdr) (((pBlkHdr) != NULL) && \
  44. ((pBlkHdr)->bh_Signature == BH_SIGNATURE))
  45. #else
  46. #define VALID_BH(pBlkHdr) ((pBlkHdr) != NULL)
  47. #endif
  48. typedef struct _BLK_HDR
  49. {
  50. #if DBG
  51. DWORD bh_Signature;
  52. #endif
  53. union
  54. {
  55. struct _BLK_HDR * bh_Next; // Valid when it is free
  56. struct _BLK_CHUNK * bh_pChunk; // The parent chunk to which this blocks belong
  57. // valid when it is allocated
  58. };
  59. } BLK_HDR, *PBLK_HDR;
  60. #if DBG
  61. #define BC_OVERHEAD (8+4) // DWORD for AtalkAllocMemory() header and
  62. // POOL_HEADER for ExAllocatePool() header
  63. #else
  64. #define BC_OVERHEAD (8+8) // 2*DWORD for AtalkAllocMemory() header and
  65. // POOL_HEADER for ExAllocatePool() header
  66. #endif
  67. #define BLOCK_SIZE(VirginSize) DWORDSIZEBLOCK(sizeof(BLK_HDR)+VirginSize)
  68. #define NUM_BLOCKS(VirginSize, ChunkSize) \
  69. ((ChunkSize) - BC_OVERHEAD - sizeof(BLK_CHUNK))/BLOCK_SIZE(VirginSize)
  70. extern USHORT atalkBlkSize[NUM_BLKIDS];
  71. extern USHORT atalkChunkSize[NUM_BLKIDS];
  72. extern BYTE atalkNumBlks[NUM_BLKIDS];
  73. extern ATALK_SPIN_LOCK atalkBPLock[NUM_BLKIDS];
  74. #define BLOCK_POOL_TIMER 150 // Check interval - in 100ms units
  75. #define MAX_BLOCK_POOL_AGE 6 // # of timer invocations before free
  76. extern PBLK_CHUNK atalkBPHead[NUM_BLKIDS];
  77. extern TIMERLIST atalkBPTimer;
  78. #if DBG
  79. extern LONG atalkNumChunksForId[NUM_BLKIDS];
  80. extern LONG atalkBlksForId[NUM_BLKIDS];
  81. #endif
  82. LOCAL LONG FASTCALL
  83. atalkBPAgePool(
  84. IN PTIMERLIST Context,
  85. IN BOOLEAN TimerShuttingDown
  86. );
  87. #endif // _BLK_POOL
  88.