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.

127 lines
3.8 KiB

  1. // Copyright (c) 1997, Microsoft Corporation, all rights reserved
  2. //
  3. // main.c
  4. // RAS L2TP WAN mini-port/call-manager driver
  5. // Main routine (DriverEntry) and global data definitions
  6. //
  7. // 01/07/97 Steve Cobb
  8. #include "l2tpp.h"
  9. //-----------------------------------------------------------------------------
  10. // Local prototypes
  11. //-----------------------------------------------------------------------------
  12. NDIS_STATUS
  13. DriverEntry(
  14. IN PDRIVER_OBJECT DriverObject,
  15. IN PUNICODE_STRING RegistryPath );
  16. // Mark routine to be unloaded after initialization.
  17. //
  18. #pragma NDIS_INIT_FUNCTION(DriverEntry)
  19. //-----------------------------------------------------------------------------
  20. // Routines
  21. //-----------------------------------------------------------------------------
  22. NDIS_STATUS
  23. DriverEntry(
  24. IN PDRIVER_OBJECT DriverObject,
  25. IN PUNICODE_STRING RegistryPath )
  26. // Standard 'DriverEntry' driver initialization entrypoint called by the
  27. // I/0 system at IRQL PASSIVE_LEVEL before any other call to the driver.
  28. //
  29. // On NT, 'DriverObject' is the driver object created by the I/0 system
  30. // and 'RegistryPath' specifies where driver specific parameters are
  31. // stored. These arguments are opaque to this driver (and should remain
  32. // so for portability) which only forwards them to the NDIS wrapper.
  33. //
  34. // Returns the value returned by NdisMRegisterMiniport, per the doc on
  35. // "DriverEntry of NDIS Miniport Drivers".
  36. //
  37. {
  38. NDIS_STATUS status;
  39. NDIS_MINIPORT_CHARACTERISTICS nmc;
  40. NDIS_HANDLE NdisWrapperHandle;
  41. TRACE( TL_N, TM_Init, ( "DriverEntry" ) );
  42. #ifdef TESTMODE
  43. DbgBreakPoint();
  44. #endif
  45. // Register this driver with the NDIS wrapper. This call must occur
  46. // before any other NdisXxx calls.
  47. //
  48. NdisMInitializeWrapper(
  49. &NdisWrapperHandle, DriverObject, RegistryPath, NULL );
  50. // Set up the mini-port characteristics table that tells NDIS how to call
  51. // our mini-port.
  52. //
  53. NdisZeroMemory( &nmc, sizeof(nmc) );
  54. nmc.MajorNdisVersion = NDIS_MajorVersion;
  55. nmc.MinorNdisVersion = NDIS_MinorVersion;
  56. nmc.Reserved = NDIS_USE_WAN_WRAPPER;
  57. // no CheckForHangHandler
  58. // no DisableInterruptHandler
  59. // no EnableInterruptHandler
  60. nmc.HaltHandler = LmpHalt;
  61. // no HandleInterruptHandler
  62. nmc.InitializeHandler = LmpInitialize;
  63. // no ISRHandler
  64. // no QueryInformationHandler (see CoRequestHandler)
  65. nmc.ResetHandler = LmpReset;
  66. // no SendHandler (see CoSendPacketsHandler)
  67. // no WanSendHandler (see CoSendPacketsHandler)
  68. // no SetInformationHandler (see CoRequestHandler)
  69. // no TransferDataHandler
  70. // no WanTransferDataHandler
  71. nmc.ReturnPacketHandler = LmpReturnPacket;
  72. // no SendPacketsHandler (see CoSendPacketsHandler)
  73. // no AllocateCompleteHandler
  74. nmc.CoActivateVcHandler = LmpCoActivateVc;
  75. nmc.CoDeactivateVcHandler = LmpCoDeactivateVc;
  76. nmc.CoSendPacketsHandler = LmpCoSendPackets;
  77. nmc.CoRequestHandler = LmpCoRequest;
  78. // Register this driver as the L2TP mini-port. This will result in NDIS
  79. // calling back at LmpInitialize.
  80. //
  81. TRACE( TL_V, TM_Init, ( "NdisMRegMp" ) );
  82. status = NdisMRegisterMiniport( NdisWrapperHandle, &nmc, sizeof(nmc) );
  83. TRACE( TL_A, TM_Init, ( "NdisMRegMp=$%x", status ) );
  84. if (status == NDIS_STATUS_SUCCESS)
  85. {
  86. {
  87. extern CALLSTATS g_stats;
  88. extern NDIS_SPIN_LOCK g_lockStats;
  89. NdisZeroMemory( &g_stats, sizeof(g_stats) );
  90. NdisAllocateSpinLock( &g_lockStats );
  91. }
  92. #ifdef PSDEBUG
  93. {
  94. extern LIST_ENTRY g_listDebugPs;
  95. extern NDIS_SPIN_LOCK g_lockDebugPs;
  96. InitializeListHead( &g_listDebugPs );
  97. NdisAllocateSpinLock( &g_lockDebugPs );
  98. }
  99. #endif
  100. }
  101. else
  102. {
  103. NdisTerminateWrapper( NdisWrapperHandle, NULL );
  104. }
  105. return status;
  106. }