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.

150 lines
2.7 KiB

  1. /*++
  2. Copyright (c) 1999-1999 Microsoft Corporation
  3. Module Name:
  4. objtablep.h
  5. Abstract:
  6. This module contains private declarations and definitions for the
  7. UL object table package.
  8. Author:
  9. Keith Moore (keithmo) 20-Apr-1999
  10. Revision History:
  11. --*/
  12. #ifndef _OBJTABLEP_H_
  13. #define _OBJTABLEP_H_
  14. //
  15. // Our cyclic type. Just a 32-bit value.
  16. //
  17. typedef ULONG CYCLIC;
  18. //
  19. // An object table.
  20. //
  21. typedef struct _UL_OBJECT_TABLE
  22. {
  23. //
  24. // Structure signature.
  25. //
  26. ULONG Signature;
  27. //
  28. // The lock protecting the table.
  29. //
  30. UL_SPIN_LOCK TableSpinLock;
  31. //
  32. // The free entry list. Note that the spin-lock is only used on
  33. // processor architectures that don't natively support SLISTs.
  34. //
  35. SLIST_HEADER FreeEntrySListHead;
  36. KSPIN_LOCK FreeEntrySListLock;
  37. //
  38. // The first-level lookup table.
  39. //
  40. struct _UL_OBJECT_TABLE_ENTRY **ppFirstLevelTable;
  41. //
  42. // Usage counters.
  43. //
  44. ULONG FirstLevelTableSize;
  45. ULONG FirstLevelTableInUse;
  46. //
  47. // The cyclic.
  48. //
  49. CYCLIC Cyclic;
  50. } UL_OBJECT_TABLE, *PUL_OBJECT_TABLE;
  51. //
  52. // The internal structure of an UL_OPAQUE_ID.
  53. //
  54. // N.B. This structure must be EXACTLY the same size as an UL_OPAQUE_ID!
  55. //
  56. #define FIRST_INDEX_BIT_WIDTH 24
  57. #define SECOND_INDEX_BIT_WIDTH 8
  58. typedef union _OPAQUE_ID_INTERNAL
  59. {
  60. UL_OPAQUE_ID OpaqueId;
  61. struct
  62. {
  63. CYCLIC Cyclic;
  64. ULONG FirstIndex:FIRST_INDEX_BIT_WIDTH;
  65. ULONG SecondIndex:SECOND_INDEX_BIT_WIDTH;
  66. };
  67. } OPAQUE_ID_INTERNAL, *POPAQUE_ID_INTERNAL;
  68. C_ASSERT( sizeof(UL_OPAQUE_ID) == sizeof(OPAQUE_ID_INTERNAL) );
  69. C_ASSERT( (FIRST_INDEX_BIT_WIDTH + SECOND_INDEX_BIT_WIDTH) ==
  70. (sizeof(CYCLIC) * 8) );
  71. //
  72. // A second-level table entry.
  73. //
  74. // Note that FreeListEntry and pContext are in an anonymous
  75. // union to save space; an entry is either on the free list or in use,
  76. // so only one of these fields will be used at a time.
  77. //
  78. // Also note that Cyclic is in a second anonymous union. It's overlayed
  79. // with FirstLevelIndex (which is basically the second-level table's
  80. // index in the first-level table) and EntryType (used to distinguish
  81. // free entries from in-use entries). The internal GetNextCyclic() function
  82. // is careful to always return cyclics with EntryType set to
  83. // ENTRY_TYPE_IN_USE.
  84. //
  85. typedef struct _OPAQUE_ID_TABLE_ENTRY
  86. {
  87. union
  88. {
  89. SINGLE_LIST_ENTRY FreeListEntry;
  90. PVOID pContext;
  91. };
  92. union
  93. {
  94. CYCLIC Cyclic;
  95. struct
  96. {
  97. ULONG FirstLevelIndex:FIRST_INDEX_BIT_WIDTH;
  98. ULONG EntryType:SECOND_INDEX_BIT_WIDTH;
  99. };
  100. };
  101. } OPAQUE_ID_TABLE_ENTRY, *POPAQUE_ID_TABLE_ENTRY;
  102. #define ENTRY_TYPE_FREE 0xFF
  103. #define ENTRY_TYPE_IN_USE 0x00
  104. #endif // _OBJTABLEP_H_