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.

191 lines
4.4 KiB

  1. /*++
  2. Copyright (c) 2000 Microsoft Corporation
  3. Module Name:
  4. mmTimer.h
  5. Abstract:
  6. This module contains multimedia event timer definitions
  7. Author:
  8. Eric Nelson (enelson) July 7, 2000
  9. Revision History:
  10. --*/
  11. #ifndef __MMTIMER_H__
  12. #define __MMTIMER_H__
  13. #define ETDT_SIGNATURE 0x54445445 // "ETDT"
  14. //
  15. // Event Timer Description Table
  16. //
  17. typedef struct _EVENT_TIMER_DESCRIPTION_TABLE {
  18. DESCRIPTION_HEADER Header;
  19. //
  20. // Hardware ID of Event Timer Block:
  21. // Contents of General_Cap & ID Reg of Timer Block
  22. // [31:16] = PCI Vendor ID of 1st Timer Block
  23. // [5] = Legacy IRQ Routing Capable
  24. // [14] = Reserved
  25. // [12:8] = Number of Comparitors in 1st Timer Block
  26. // [7:0] = Hardware Rev ID
  27. //
  28. ULONG EventTimerBlockID;
  29. //
  30. // Base address of Event Timer Block
  31. //
  32. // Each Event Timer Block consumes 1K of system memory,
  33. // regardless of how many comparators are actually implemented
  34. // by hardware
  35. //
  36. ULONG BaseAddress;
  37. } EVENT_TIMER_DESCRIPTION_TABLE, *PEVENT_TIMER_DESCRIPTION_TABLE;
  38. #define ANYSIZE_ARRAY 1
  39. #define ON 1
  40. #define OFF 0
  41. //
  42. // Define volatile pointer offsets for easy access of event timer
  43. // registers
  44. //
  45. typedef struct _TIMER_REGISTERS {
  46. volatile ULONG ConfigCapabilities; // 0x100, 0x120, 0x140, ...
  47. ULONG Unknown;
  48. volatile ULONG Comparator; // 0x108
  49. ULONG Mystery;
  50. volatile ULONG FSBInterruptRoute; // 0x110
  51. volatile ULONG FSBInterruptAddress; // 0x114
  52. ULONGLONG Secret;
  53. } TIMER_REGISTERS, *PTIMER_REGISTERS;
  54. //
  55. // Don't try to allocate one of these puppies, it's just a collecton of
  56. // volatile pointer/offsets to make reading of registers easier
  57. //
  58. typedef struct _EVENT_TIMER_BLOCK {
  59. volatile ULONG GeneralCapabilities; // 0x000
  60. volatile ULONG ClockPeriod; // 0x004
  61. ULONGLONG Unknown;
  62. volatile ULONG GeneralConfig; // 0x010
  63. ULONG Mystery[3];
  64. volatile ULONG GeneralIRQStatus; // 0x020
  65. ULONG Secret[51];
  66. volatile ULONG MainCounter; // 0x0F0
  67. ULONG Abyss[3];
  68. TIMER_REGISTERS mmTimer[ANYSIZE_ARRAY]; // 0x100
  69. } EVENT_TIMER_BLOCK, *PEVENT_TIMER_BLOCK;
  70. //
  71. // Define our multi media event timer block context
  72. //
  73. typedef struct _ETB_CONTEXT {
  74. ULONG TimerCount;
  75. PEVENT_TIMER_BLOCK EventTimer;
  76. PHYSICAL_ADDRESS BaseAddress;
  77. ULONG ClockPeriod; // In nanoseconds
  78. ULONG SystemClockFrequency; // Rate of system clock in Hz
  79. ULONG SystemClockTicks; // Period of system clock in ticks
  80. BOOLEAN Initialized;
  81. BOOLEAN NewClockFrequency;
  82. } ETB_CONTEXT, *PETB_CONTEXT;
  83. //
  84. // General Capabilities and ID
  85. //
  86. typedef union {
  87. struct {
  88. ULONG RevisionID: 8;
  89. ULONG TimerCount: 5;
  90. ULONG MainCounterSize: 1;
  91. ULONG Reserved: 1;
  92. ULONG LegacyIRQRoutingCapable: 1;
  93. ULONG VendorID: 16;
  94. };
  95. ULONG AsULONG;
  96. } ETB_GEN_CAP_ID, *PETB_GEN_CAP_ID;
  97. //
  98. // General Configuration
  99. //
  100. typedef union {
  101. struct {
  102. ULONG GlobalIRQEnable: 1;
  103. ULONG LegacyIRQRouteEnable: 1;
  104. ULONG Reserved: 30;
  105. };
  106. ULONG AsULONG;
  107. } ETB_GEN_CONF, *PETB_GEN_CONF;
  108. //
  109. // Timer n Configuration and Capabilities
  110. //
  111. typedef union {
  112. struct {
  113. ULONG Reserved0: 1;
  114. ULONG EdgeLevelSelect: 1;
  115. ULONG IRQEnable: 1;
  116. ULONG PeriodicModeEnable: 1;
  117. ULONG PeriodicCapable: 1;
  118. ULONG CompareWidth: 1;
  119. ULONG ValueSetConfig: 1;
  120. ULONG Reserved1: 1;
  121. ULONG Mode32BitConfig: 1;
  122. ULONG IRQRouteConfig: 5;
  123. ULONG IRQDeliverySelect: 1;
  124. ULONG FSBIRQCapable: 1;
  125. ULONG Reserved2: 16;
  126. };
  127. ULONG AsULONG;
  128. } ETB_CONF_CAPS, *PETB_CONF_CAPS;
  129. VOID
  130. HalpmmTimerInit(
  131. IN ULONG EventTimerBlockID,
  132. IN ULONG BaseAddress
  133. );
  134. ULONG
  135. HalpmmTimerSetTimeIncrement(
  136. IN ULONG DesiredIncrement
  137. );
  138. VOID
  139. HalpmmTimerStallExecProc(
  140. IN ULONG Microseconds
  141. );
  142. LARGE_INTEGER
  143. HalpmmTimerQueryPerfCount(
  144. OUT PLARGE_INTEGER PerformanceFrequency OPTIONAL
  145. );
  146. VOID
  147. HalpmmTimerCalibratePerfCount(
  148. IN LONG volatile *Number,
  149. IN ULONGLONG NewCount
  150. );
  151. BOOLEAN
  152. HalpmmTimer(
  153. VOID
  154. );
  155. VOID
  156. HalpmmTimerClockInit(
  157. VOID
  158. );
  159. #endif // __MMTIMER_H__