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.

267 lines
5.4 KiB

  1. /*++
  2. Copyright (c) 1991 Microsoft Corporation
  3. Module Name:
  4. ixinfo.c
  5. Abstract:
  6. Author:
  7. Ken Reneris (kenr) 08-Aug-1994
  8. Environment:
  9. Kernel mode only.
  10. Revision History:
  11. --*/
  12. #include "halp.h"
  13. VOID
  14. HalInitSystemPhase2 (
  15. VOID
  16. );
  17. #ifdef _PNP_POWER_
  18. HAL_CALLBACKS HalCallback;
  19. extern WCHAR rgzSuspendCallbackName[];
  20. VOID
  21. HalpLockSuspendCode (
  22. IN PVOID CallbackContext,
  23. IN PVOID Argument1,
  24. IN PVOID Argument2
  25. );
  26. #endif
  27. NTSTATUS
  28. HalpQueryInstalledBusInformation (
  29. OUT PVOID Buffer,
  30. IN ULONG BufferLength,
  31. OUT PULONG ReturnedLength
  32. );
  33. #ifdef ALLOC_PRAGMA
  34. #pragma alloc_text(PAGE,HaliQuerySystemInformation)
  35. #pragma alloc_text(PAGE,HaliSetSystemInformation)
  36. #pragma alloc_text(INIT,HalInitSystemPhase2)
  37. #ifdef _PNP_POWER_
  38. #pragma alloc_text(PAGE,HalpLockSuspendCode)
  39. #endif
  40. #endif
  41. VOID
  42. HalInitSystemPhase2 (
  43. VOID
  44. )
  45. {
  46. #ifdef _PNP_POWER_
  47. OBJECT_ATTRIBUTES ObjectAttributes;
  48. NTSTATUS Status;
  49. UNICODE_STRING unicodeString;
  50. PCALLBACK_OBJECT CallbackObject;
  51. //
  52. // Create hal callbacks
  53. //
  54. InitializeObjectAttributes(
  55. &ObjectAttributes,
  56. NULL,
  57. OBJ_CASE_INSENSITIVE,
  58. NULL,
  59. NULL
  60. );
  61. ExCreateCallback (&HalCallback.SetSystemInformation, &ObjectAttributes, TRUE, TRUE);
  62. ExCreateCallback (&HalCallback.BusCheck, &ObjectAttributes, TRUE, TRUE);
  63. //
  64. // Connect to suspend callback to lock hal hibaration code
  65. //
  66. RtlInitUnicodeString(&unicodeString, rgzSuspendCallbackName);
  67. InitializeObjectAttributes(
  68. &ObjectAttributes,
  69. &unicodeString,
  70. OBJ_CASE_INSENSITIVE,
  71. NULL,
  72. NULL
  73. );
  74. Status = ExCreateCallback (&CallbackObject, &ObjectAttributes, FALSE, FALSE);
  75. if (NT_SUCCESS(Status)) {
  76. ExRegisterCallback (
  77. CallbackObject,
  78. HalpLockSuspendCode,
  79. NULL
  80. );
  81. ObDereferenceObject (CallbackObject);
  82. }
  83. #endif
  84. }
  85. NTSTATUS
  86. HaliQuerySystemInformation(
  87. IN HAL_QUERY_INFORMATION_CLASS InformationClass,
  88. IN ULONG BufferSize,
  89. OUT PVOID Buffer,
  90. OUT PULONG ReturnedLength
  91. )
  92. {
  93. NTSTATUS Status;
  94. PVOID InternalBuffer;
  95. ULONG Length;
  96. union {
  97. HAL_POWER_INFORMATION PowerInf;
  98. HAL_PROCESSOR_SPEED_INFORMATION ProcessorInf;
  99. HAL_DISPLAY_BIOS_INFORMATION DisplayBiosInf;
  100. } U;
  101. BOOLEAN bUseFrameBufferCaching;
  102. PAGED_CODE();
  103. Status = STATUS_SUCCESS;
  104. *ReturnedLength = 0;
  105. Length = 0;
  106. switch (InformationClass) {
  107. case HalInstalledBusInformation:
  108. Status = HalpQueryInstalledBusInformation (
  109. Buffer,
  110. BufferSize,
  111. ReturnedLength
  112. );
  113. break;
  114. case HalFrameBufferCachingInformation:
  115. // Note - we want to return TRUE here to enable USWC in all
  116. // cases except in a "Shared Memory Cluster" machine.
  117. bUseFrameBufferCaching = TRUE;
  118. InternalBuffer = &bUseFrameBufferCaching;
  119. Length = sizeof (BOOLEAN);
  120. break;
  121. #ifdef _PNP_POWER_
  122. case HalPowerInformation:
  123. RtlZeroMemory (&U.PowerInf, sizeof(HAL_POWER_INFORMATION));
  124. InternalBuffer = &U.PowerInf;
  125. Length = sizeof (HAL_POWER_INFORMATION);
  126. break;
  127. case HalProcessorSpeedInformation:
  128. RtlZeroMemory (&U.ProcessorInf, sizeof(HAL_POWER_INFORMATION));
  129. U.ProcessorInf.MaximumProcessorSpeed = 100;
  130. U.ProcessorInf.CurrentAvailableSpeed = 100;
  131. U.ProcessorInf.ConfiguredSpeedLimit = 100;
  132. InternalBuffer = &U.PowerInf;
  133. Length = sizeof (HAL_PROCESSOR_SPEED_INFORMATION);
  134. break;
  135. case HalCallbackInformation:
  136. InternalBuffer = &HalCallback;
  137. Length = sizeof (HAL_CALLBACKS);
  138. break;
  139. #endif
  140. default:
  141. Status = STATUS_INVALID_LEVEL;
  142. break;
  143. }
  144. //
  145. // If non-zero Length copy data to callers buffer
  146. //
  147. if (Length) {
  148. if (BufferSize < Length) {
  149. Length = BufferSize;
  150. }
  151. *ReturnedLength = Length;
  152. RtlCopyMemory (Buffer, InternalBuffer, Length);
  153. }
  154. return Status;
  155. }
  156. NTSTATUS
  157. HaliSetSystemInformation (
  158. IN HAL_SET_INFORMATION_CLASS InformationClass,
  159. IN ULONG BufferSize,
  160. IN PVOID Buffer
  161. )
  162. {
  163. NTSTATUS Status;
  164. PAGED_CODE();
  165. Status = STATUS_SUCCESS;
  166. switch (InformationClass) {
  167. default:
  168. Status = STATUS_INVALID_LEVEL;
  169. break;
  170. }
  171. return Status;
  172. }
  173. #ifdef _PNP_POWER_
  174. VOID
  175. HalpLockSuspendCode (
  176. IN PVOID CallbackContext,
  177. IN PVOID Argument1,
  178. IN PVOID Argument2
  179. )
  180. {
  181. static PVOID CodeLock;
  182. switch ((ULONG) Argument1) {
  183. case 0:
  184. //
  185. // Lock code down which might be needed to perform a suspend
  186. //
  187. ASSERT (CodeLock == NULL);
  188. CodeLock = MmLockPagableCodeSection (&HaliSuspendHibernateSystem);
  189. break;
  190. case 1:
  191. //
  192. // Release the code lock
  193. //
  194. MmUnlockPagableImageSection (CodeLock);
  195. CodeLock = NULL;
  196. break;
  197. }
  198. }
  199. #endif