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.

202 lines
3.9 KiB

  1. /*++
  2. Copyright (c) 2000 Microsoft Corporation
  3. Module Name:
  4. halcmn.h
  5. Abstract:
  6. This module contains a variety of constants, function prototypes,
  7. inline functions and external data declarations used by the AMD64
  8. hal code.
  9. Author:
  10. Forrest Foltz (forrestf) 24-Oct-2000
  11. --*/
  12. #ifndef _HALCMN_H_
  13. #define _HALCMN_H_
  14. #include <halp.h>
  15. #include <apic.inc>
  16. #include <ntapic.inc>
  17. #include <ntacpi.h>
  18. #include "io_cmos.h"
  19. #include "8259.h"
  20. #include "mp8254.inc"
  21. typedef VOID (*PHALP_SOFTWARE_INTERRUPT)(VOID);
  22. extern PHALP_SOFTWARE_INTERRUPT HalpSoftwareInterruptTable[];
  23. extern KIRQL SWInterruptLookupTable[];
  24. extern USHORT Halp8259MaskTable[];
  25. extern LARGE_INTEGER (*QueryTimer)(VOID);
  26. extern KAFFINITY HalpDefaultInterruptAffinity;
  27. extern KAFFINITY HalpActiveProcessors;
  28. extern ULONG HalpTimerWatchdogEnabled;
  29. //
  30. // Number of 100nS units in one second
  31. //
  32. #define TIME_UNITS_PER_SECOND 10000000
  33. #if defined(DBG)
  34. #define AMD64_IMPLEMENT DbgPrint("AMD64: Not implemented\n"); DbgBreakPoint()
  35. #else
  36. #define AMD64_IMPLEMENT
  37. #endif
  38. #if !defined(RTL_FIELD_SIZE)
  39. #define RTL_FIELD_SIZE(type, field) (sizeof(((type *)0)->field))
  40. #endif
  41. VOID
  42. HalpAcquireSystemHardwareSpinLock(
  43. VOID
  44. );
  45. VOID
  46. HalpReleaseSystemHardwareSpinLock(
  47. VOID
  48. );
  49. __forceinline
  50. VOID
  51. KPcrReadData (
  52. IN ULONG Offset,
  53. IN ULONG Length,
  54. OUT PVOID Buffer
  55. )
  56. /*++
  57. Routine Description:
  58. Used to read data from the current processor's KPCR. This is a support
  59. function for KPCR_READ_FIELD
  60. Arguments:
  61. Offset - Supplies the offset within the KPCR to begin the read
  62. Length - Supplies the length of the data to read from the KPCR. Must
  63. be one of 1, 2, 4 or 8.
  64. Buffer - Supplies the target buffer that contains the data to read from
  65. the KPCR.
  66. Return value:
  67. None
  68. --*/
  69. {
  70. switch (Length) {
  71. case 1:
  72. *(PUCHAR)Buffer = __readgsbyte(Offset);
  73. break;
  74. case 2:
  75. *(PUSHORT)Buffer = __readgsword(Offset);
  76. break;
  77. case 4:
  78. *(PULONG)Buffer = __readgsdword(Offset);
  79. break;
  80. case 8:
  81. *(PULONG64)Buffer = __readgsqword(Offset);
  82. break;
  83. }
  84. }
  85. __forceinline
  86. VOID
  87. KPcrWriteData (
  88. IN ULONG Offset,
  89. IN ULONG Length,
  90. IN PVOID Buffer
  91. )
  92. /*++
  93. Routine Description:
  94. Used to write data to the current processor's KPCR. This is a support
  95. function for KPCR_WRITE_FIELD
  96. Arguments:
  97. Offset - Supplies the offset within the KPCR to begin the write
  98. Length - Supplies the length of the data to write within the KPCR. Must
  99. be one of 1, 2, 4 or 8
  100. Buffer - Supplies the source buffer that contains the data to write into
  101. the KPCR.
  102. Return value:
  103. None
  104. --*/
  105. {
  106. switch (Length) {
  107. case 1:
  108. __writegsbyte(Offset,*(PUCHAR)Buffer);
  109. break;
  110. case 2:
  111. __writegsword(Offset,*(PUSHORT)Buffer);
  112. break;
  113. case 4:
  114. __writegsdword(Offset,*(PULONG)Buffer);
  115. break;
  116. case 8:
  117. __writegsqword(Offset,*(PULONG64)Buffer);
  118. break;
  119. }
  120. }
  121. #define KPCR_READ_FIELD(field,value) \
  122. KPcrReadData(FIELD_OFFSET(KPCR,field), \
  123. RTL_FIELD_SIZE(KPCR,field), \
  124. value);
  125. #define KPCR_WRITE_FIELD(field,value) \
  126. KPcrWriteData(FIELD_OFFSET(KPCR,field), \
  127. RTL_FIELD_SIZE(KPCR,field), \
  128. value);
  129. NTSTATUS
  130. HalpConnectInterrupt (
  131. IN ULONG SystemInterruptVector,
  132. IN KIRQL SystemIrql,
  133. IN PHAL_INTERRUPT_SERVICE_ROUTINE HalInterruptServiceRoutine,
  134. IN KINTERRUPT_MODE InterruptMode
  135. );
  136. BOOLEAN
  137. PicSpuriousService37 (
  138. IN struct _KINTERRUPT *Interrupt,
  139. IN PVOID ServiceContext
  140. );
  141. BOOLEAN
  142. HalpApicSpuriousService (
  143. IN struct _KINTERRUPT *Interrupt,
  144. IN PVOID ServiceContext
  145. );
  146. #endif // _HALCMN_H_