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.

158 lines
3.4 KiB

  1. /*++
  2. Copyright (c) 1990 Microsoft Corporation
  3. Module Name:
  4. SysInit.c
  5. Abstract:
  6. This module implements the Log File Service initialization.
  7. Author:
  8. Brian Andrew [BrianAn] 20-June-1991
  9. Revision History:
  10. --*/
  11. #include "lfsprocs.h"
  12. //
  13. // The debug trace level
  14. //
  15. #define Dbg (DEBUG_TRACE_INITIALIZATION)
  16. #undef MODULE_POOL_TAG
  17. #define MODULE_POOL_TAG ('IsfL')
  18. #ifdef ALLOC_PRAGMA
  19. #pragma alloc_text(PAGE, LfsInitializeLogFileService)
  20. #endif
  21. extern USHORT LfsUsaSeqNumber;
  22. BOOLEAN
  23. LfsInitializeLogFileService (
  24. )
  25. /*++
  26. Routine Description:
  27. This routine must be called during system initialization before the
  28. first call to logging service, to allow the Log File Service to initialize
  29. its global data structures. This routine has no dependencies on other
  30. system components being initialized.
  31. This routine will initialize the global structures used by the logging
  32. service and start the Lfs worker thread.
  33. Arguments:
  34. None
  35. Return Value:
  36. TRUE if initialization was successful
  37. --*/
  38. {
  39. LARGE_INTEGER CurrentTime;
  40. PAGED_CODE();
  41. DebugTrace( +1, Dbg, "LfsInitializeLogFileService: Enter\n", 0 );
  42. //
  43. // If the structure has already been initialized then we can return
  44. // immediately.
  45. //
  46. if (LfsData.NodeTypeCode == LFS_NTC_DATA
  47. && LfsData.NodeByteSize == sizeof( LFS_DATA )
  48. && FlagOn( LfsData.Flags, LFS_DATA_INITIALIZED )) {
  49. DebugTrace( -1, Dbg, "LfsInitializeLogFileService: Exit -> %01x\n", TRUE );
  50. return TRUE;
  51. }
  52. //
  53. // Zero out the structure initially.
  54. //
  55. RtlZeroMemory( &LfsData, sizeof( LFS_DATA ));
  56. //
  57. // Assume the operation will fail.
  58. //
  59. LfsData.Flags = LFS_DATA_INIT_FAILED;
  60. //
  61. // Initialize the global structure for Lfs.
  62. //
  63. LfsData.NodeTypeCode = LFS_NTC_DATA;
  64. LfsData.NodeByteSize = sizeof( LFS_DATA );
  65. InitializeListHead( &LfsData.LfcbLinks );
  66. //
  67. // Initialize the synchronization objects.
  68. //
  69. ExInitializeFastMutex( &LfsData.LfsDataLock );
  70. //
  71. // Initialize the buffer allocation. System will be robust enough to tolerate
  72. // allocation failures.
  73. //
  74. ExInitializeFastMutex( &LfsData.BufferLock );
  75. KeInitializeEvent( &LfsData.BufferNotification, NotificationEvent, TRUE );
  76. LfsData.Buffer1 = LfsAllocatePoolNoRaise( PagedPool, LFS_BUFFER_SIZE );
  77. if (LfsData.Buffer1 == NULL) {
  78. return FALSE;
  79. }
  80. LfsData.Buffer2 = LfsAllocatePoolNoRaise( PagedPool, LFS_BUFFER_SIZE );
  81. //
  82. // Make sure we got both.
  83. //
  84. if (LfsData.Buffer2 == NULL) {
  85. LfsFreePool( LfsData.Buffer1 );
  86. LfsData.Buffer1 = NULL;
  87. return FALSE;
  88. }
  89. //
  90. // Initialization has been successful.
  91. //
  92. ClearFlag( LfsData.Flags, LFS_DATA_INIT_FAILED );
  93. SetFlag( LfsData.Flags, LFS_DATA_INITIALIZED );
  94. //
  95. // Get a random number as a seed for the Usa sequence numbers. Use the lower
  96. // bits of the current time.
  97. //
  98. KeQuerySystemTime( &CurrentTime );
  99. LfsUsaSeqNumber = (USHORT) CurrentTime.LowPart;
  100. DebugTrace( -1, Dbg, "LfsInitializeLogFileService: Exit -> %01x\n", TRUE );
  101. return TRUE;
  102. }