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.

200 lines
3.8 KiB

  1. /*++
  2. Copyright (c) 1995-1998 Microsoft Corporation
  3. Module Name:
  4. rcantini.c
  5. Abstract:
  6. The module contains the NT-specific init code for the NDIS RCA.
  7. Author:
  8. Richard Machin (RMachin)
  9. Revision History:
  10. Who When What
  11. -------- -------- ----------------------------------------------
  12. RMachin 2-18-97 created
  13. JameelH 4-18-98 Cleaned up
  14. Notes:
  15. --*/
  16. #include <precomp.h>
  17. #define MODULE_NUMBER MODULE_NTINIT
  18. #define _FILENUMBER 'NITN'
  19. RCA_GLOBAL RcaGlobal = {0};
  20. //
  21. // Local funcion prototypes
  22. //
  23. NTSTATUS
  24. DriverEntry(
  25. IN PDRIVER_OBJECT DriverObject,
  26. IN PUNICODE_STRING RegistryPath
  27. );
  28. //
  29. // All of the init code can be discarded.
  30. //
  31. #ifdef ALLOC_PRAGMA
  32. #pragma alloc_text(INIT, DriverEntry)
  33. #endif // ALLOC_PRAGMA
  34. NTSTATUS
  35. DriverEntry(
  36. IN PDRIVER_OBJECT DriverObject,
  37. IN PUNICODE_STRING RegistryPath
  38. )
  39. /*++
  40. Routine Description:
  41. Sets up the driver object to handle the KS interface and PnP Add Device
  42. request. Does not set up a handler for PnP Irp's, as they are all dealt
  43. with directly by the PDO.
  44. Arguments:
  45. DriverObject -
  46. Driver object for this instance.
  47. RegistryPathName -
  48. Contains the registry path which was used to load this instance.
  49. Return Values:
  50. Returns STATUS_SUCCESS.
  51. --*/
  52. {
  53. RCADEBUGP(0, ("RCA DriverEntry: Built %s, %s\n", __DATE__, __TIME__));
  54. DriverObject->MajorFunction[IRP_MJ_PNP] = KsDefaultDispatchPnp;
  55. DriverObject->MajorFunction[IRP_MJ_POWER] = KsDefaultDispatchPower;
  56. DriverObject->DriverExtension->AddDevice = PnpAddDevice;
  57. DriverObject->DriverUnload = RCAUnload;
  58. KsSetMajorFunctionHandler(DriverObject, IRP_MJ_CREATE);
  59. KsSetMajorFunctionHandler(DriverObject, IRP_MJ_CLOSE);
  60. KsSetMajorFunctionHandler(DriverObject, IRP_MJ_DEVICE_CONTROL);
  61. RCAInitLock(&(RcaGlobal.SpinLock));
  62. //
  63. // Initialize our stream header pool.
  64. //
  65. RCASHPoolInit();
  66. #if PACKET_POOL_OPTIMIZATION
  67. // SendPPOpt - Start
  68. NdisZeroMemory(g_alSendPPOptBuckets, SENDPPOPT_NUM_BUCKETS * sizeof(g_alSendPPOptBuckets[0]));
  69. g_lSendPPOptOutstanding = 0;
  70. NdisAllocateSpinLock(&g_SendPPOptLock);
  71. // SendPPOpt - End
  72. // RecvPPOpt - Start
  73. NdisZeroMemory(g_alRecvPPOptBuckets, RECVPPOPT_NUM_BUCKETS * sizeof(g_alRecvPPOptBuckets[0]));
  74. g_lRecvPPOptOutstanding = 0;
  75. NdisAllocateSpinLock(&g_RecvPPOptLock);
  76. // RecvPPOpt - End
  77. #endif
  78. return STATUS_SUCCESS;
  79. }
  80. VOID
  81. RCAUnload(
  82. IN PDRIVER_OBJECT DriverObject
  83. )
  84. /*++
  85. Routine Description:
  86. Free all the allocated resources, etc.
  87. Arguments:
  88. DriverObject - pointer to a driver object
  89. Return Value:
  90. --*/
  91. {
  92. NDIS_STATUS Status;
  93. PRCA_ADAPTER pAdapter;
  94. #if DBG
  95. KIRQL EntryIrq;
  96. #endif
  97. RCA_GET_ENTRY_IRQL(EntryIrq);
  98. RCADEBUGP (RCA_LOUD, ( "RCAUnload: enter\n"));
  99. if (RcaGlobal.bProtocolInitialized) {
  100. RCACoNdisUninitialize();
  101. RcaGlobal.bProtocolInitialized = FALSE;
  102. }
  103. RCAFreeLock(&(RcaGlobal.SpinLock));
  104. #if PACKET_POOL_OPTIMIZATION
  105. // SendPPOpt - Start
  106. NdisAcquireSpinLock(&g_SendPPOptLock);
  107. {
  108. LONG SendPPOptLoopCtr;
  109. DbgPrint("Send Packet Pool Stats:\n");
  110. for (SendPPOptLoopCtr = 0; SendPPOptLoopCtr < SENDPPOPT_NUM_BUCKETS; SendPPOptLoopCtr++) {
  111. DbgPrint("%d\t%d\n", SendPPOptLoopCtr, g_alSendPPOptBuckets[SendPPOptLoopCtr]);
  112. }
  113. DbgPrint("-----------------------\n");
  114. }
  115. NdisReleaseSpinLock(&g_SendPPOptLock);
  116. // SendPPOpt - End
  117. // RecvPPOpt - Start
  118. NdisAcquireSpinLock(&g_RecvPPOptLock);
  119. {
  120. LONG RecvPPOptLoopCtr;
  121. DbgPrint("Receive Packet Pool Stats:\n");
  122. for (RecvPPOptLoopCtr = 0; RecvPPOptLoopCtr < RECVPPOPT_NUM_BUCKETS; RecvPPOptLoopCtr++) {
  123. DbgPrint("%d\t%d\n", RecvPPOptLoopCtr, g_alRecvPPOptBuckets[RecvPPOptLoopCtr]);
  124. }
  125. DbgPrint("--------------------------\n");
  126. }
  127. NdisReleaseSpinLock(&g_RecvPPOptLock);
  128. // RecvPPOpt - End
  129. #endif
  130. RCASHPoolFree();
  131. RCADEBUGP (RCA_LOUD, ("RCAUnload: exit\n"));
  132. RCA_CHECK_EXIT_IRQL(EntryIrq);
  133. }