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.

155 lines
2.4 KiB

  1. /*++
  2. Copyright (c) 1998 Microsoft Corporation
  3. Module Name:
  4. spuddata.c
  5. Abstract:
  6. This module contains global data for SPUD.
  7. Author:
  8. John Ballard (jballard) 21-Oct-1996
  9. Revision History:
  10. Keith Moore (keithmo) 04-Feb-1998
  11. Cleanup, added much needed comments.
  12. --*/
  13. #include "spudp.h"
  14. //
  15. // Public globals.
  16. //
  17. SPUD_COUNTERS SpudCounters;
  18. PSPUD_NONPAGED_DATA SpudNonpagedData;
  19. PVOID SpudCompletionPort;
  20. ULONG SpudCompletionPortRefCount;
  21. KSPIN_LOCK SpudCompletionPortLock;
  22. PEPROCESS SpudOwningProcess;
  23. PDEVICE_OBJECT SpudSelfDeviceObject;
  24. HANDLE SpudSelfHandle;
  25. PDEVICE_OBJECT SpudAfdDeviceObject;
  26. PFAST_IO_DEVICE_CONTROL SpudAfdFastIoDeviceControl;
  27. #if DBG
  28. BOOLEAN SpudUsePrivateAssert;
  29. #endif
  30. #if ENABLE_OB_TRACING
  31. struct _TRACE_LOG *SpudTraceLog;
  32. #endif
  33. #ifdef ALLOC_PRAGMA
  34. #pragma alloc_text( INIT, SpudInitializeData )
  35. #endif
  36. //
  37. // Public functions.
  38. //
  39. NTSTATUS
  40. SpudInitializeData (
  41. VOID
  42. )
  43. /*++
  44. Routine Description:
  45. Performs one-time global SPUD initialization.
  46. Arguments:
  47. None.
  48. Return Value:
  49. NTSTATUS - Completion status.
  50. --*/
  51. {
  52. //
  53. // Sanity check.
  54. //
  55. PAGED_CODE();
  56. //
  57. // We don't allow SPUD on NTW systems.
  58. //
  59. if( !MmIsThisAnNtAsSystem() ) {
  60. return FALSE;
  61. }
  62. //
  63. // Initialize the spinlock that protects the completion port.
  64. //
  65. KeInitializeSpinLock(
  66. &SpudCompletionPortLock
  67. );
  68. //
  69. // Allocate the structure that's to contain all of our non-paged
  70. // data.
  71. //
  72. SpudNonpagedData = ExAllocatePoolWithTag(
  73. NonPagedPool,
  74. sizeof(*SpudNonpagedData),
  75. SPUD_NONPAGED_DATA_POOL_TAG
  76. );
  77. if( SpudNonpagedData == NULL ) {
  78. return STATUS_INSUFFICIENT_RESOURCES;
  79. }
  80. //
  81. // Initialize it.
  82. //
  83. ExInitializeNPagedLookasideList(
  84. &SpudNonpagedData->ReqContextList,
  85. NULL,
  86. NULL,
  87. NonPagedPool,
  88. sizeof( SPUD_AFD_REQ_CONTEXT ),
  89. SPUD_REQ_CONTEXT_POOL_TAG,
  90. 12
  91. );
  92. ExInitializeResourceLite(
  93. &SpudNonpagedData->ReqHandleTableLock
  94. );
  95. #if ENABLE_OB_TRACING
  96. SpudTraceLog = CreateRefTraceLog( 4096, 0 );
  97. #endif
  98. RtlZeroMemory(
  99. &SpudCounters,
  100. sizeof(SpudCounters)
  101. );
  102. return STATUS_SUCCESS;
  103. } // SpudInitializeData