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.

674 lines
26 KiB

  1. /*
  2. (C) Copyright 1999
  3. All rights reserved.
  4. Portions of this software are:
  5. (C) Copyright 1995 TriplePoint, Inc. -- http://www.TriplePoint.com
  6. License to use this software is granted under the same terms
  7. outlined in the Microsoft Windows Device Driver Development Kit.
  8. (C) Copyright 1992 Microsoft Corp. -- http://www.Microsoft.com
  9. License to use this software is granted under the terms outlined in
  10. the Microsoft Windows Device Driver Development Kit.
  11. @doc INTERNAL Miniport Miniport_c
  12. @module Miniport.c |
  13. This module implements the <f DriverEntry> routine, which is the first
  14. routine called when the driver is loaded into memory. The Miniport
  15. initialization and termination routines are also implemented here.
  16. @comm
  17. This module should not require any changes.
  18. @head3 Contents |
  19. @index class,mfunc,func,msg,mdata,struct,enum | Miniport_c
  20. @end
  21. */
  22. #define __FILEID__ MINIPORT_DRIVER_OBJECT_TYPE
  23. // Unique file ID for error logging
  24. #include "Miniport.h" // Defines all the miniport objects
  25. #include "TpiParam.h"
  26. #if defined(NDIS_LCODE)
  27. # pragma NDIS_LCODE // Windows 9x wants this code locked down!
  28. # pragma NDIS_LDATA
  29. #endif
  30. DBG_STATIC NDIS_HANDLE g_NdisWrapperHandle = NULL; // @globalv
  31. // Receives the context value representing the Miniport wrapper
  32. // as returned from NdisMInitializeWrapper.
  33. NDIS_PHYSICAL_ADDRESS g_HighestAcceptableAddress = // @globalv
  34. // This constant is used for places where NdisAllocateMemory needs to be
  35. // called and the g_HighestAcceptableAddress does not matter.
  36. NDIS_PHYSICAL_ADDRESS_CONST(-1,-1);
  37. /* @doc EXTERNAL INTERNAL Miniport Miniport_c DriverEntry
  38. @func
  39. <f DriverEntry> is called by the operating system when a driver is loaded.
  40. This function creates an association between the miniport NIC driver and
  41. the NDIS library and registers the miniport's characteristics with NDIS.
  42. DriverEntry calls NdisMInitializeWrapper and then NdisMRegisterMiniport.
  43. DriverEntry passes both pointers it received to NdisMInitializeWrapper,
  44. which returns a wrapper handle. DriverEntry passes the wrapper handle to
  45. NdisMRegisterMiniport.
  46. The registry contains data that is persistent across system boots, as well
  47. as configuration information generated anew at each system boot. During
  48. driver installation, data describing the driver and the NIC is stored in
  49. the registry. The registry contains adapter characteristics that are read
  50. by the NIC driver to initialize itself and the NIC. See the Kernel-Mode
  51. Driver Design Guide for more about the registry and the Programmer's Guide
  52. for more information about the .inf files that install the driver and
  53. write to the registry.
  54. @comm
  55. Every miniport driver must provide a function called DriverEntry. By
  56. convention, DriverEntry is the entry point address for a driver. If a
  57. driver does not use the name DriverEntry, the driver developer must define
  58. the name of its entry function to the linker so that the entry point
  59. address can be known into the OS loader.
  60. It is interesting to note, that at the time DriverEntry is called, the OS
  61. doesn't know that the driver is an NDIS driver. The OS thinks it is just
  62. another driver being loaded. So it is possible to do anything any driver
  63. might do at this point. Since NDIS is the one who requested this driver
  64. to be loaded, it would be polite to register with the NDIS wrapper. But
  65. you can also hook into other OS functions to use and provide interfaces
  66. outside the NDIS wrapper. (Not recommended for the faint of heart).
  67. @comm
  68. The parameters passed to DriverEntry are OS specific! NT passes in valid
  69. values, but Windows 3.1 and Windows 95 just pass in zeros. We don't
  70. care, because we just pass them to the NDIS wrapper anyway.
  71. @rdesc
  72. <f DriverEntry> returns zero if it is successful.<nl>
  73. Otherwise, a non-zero return value indicates an error condition.
  74. */
  75. NTSTATUS DriverEntry(
  76. IN PDRIVER_OBJECT DriverObject, // @parm
  77. // A pointer to the driver object, which was created by the I/O system.
  78. IN PUNICODE_STRING RegistryPath // @parm
  79. // A pointer to the registry path, which specifies where driver-specific
  80. // parameters are stored.
  81. )
  82. {
  83. DBG_FUNC("DriverEntry")
  84. NDIS_STATUS Status;
  85. // Status result returned from an NDIS function call.
  86. NTSTATUS Result;
  87. // Result code returned by this function.
  88. NDIS_MINIPORT_CHARACTERISTICS NdisCharacteristics;
  89. // Characteristics table passed to NdisMWanRegisterMiniport.
  90. /*
  91. // Setup default debug flags then breakpoint so we can tweak them
  92. // when this module is first loaded. It is also useful to see the
  93. // build date and time to be sure it's the one you think it is.
  94. */
  95. #if DBG
  96. DbgInfo->DbgFlags = DBG_DEFAULTS;
  97. DbgInfo->DbgID[0] = '0';
  98. DbgInfo->DbgID[1] = ':';
  99. ASSERT (sizeof(VER_TARGET_STR) <= sizeof(DbgInfo->DbgID)-2);
  100. memcpy(&DbgInfo->DbgID[2], VER_TARGET_STR, sizeof(VER_TARGET_STR));
  101. #endif // DBG
  102. DBG_PRINT((VER_TARGET_STR": Build Date:"__DATE__" Time:"__TIME__"\n"));
  103. DBG_PRINT((VER_TARGET_STR": DbgInfo=0x%X DbgFlags=0x%X\n",
  104. DbgInfo, DbgInfo->DbgFlags));
  105. DBG_BREAK(DbgInfo);
  106. DBG_ENTER(DbgInfo);
  107. DBG_PARAMS(DbgInfo,
  108. ("\n"
  109. "\t|DriverObject=0x%X\n"
  110. "\t|RegistryPath=0x%X\n",
  111. DriverObject,
  112. RegistryPath
  113. ));
  114. /*
  115. // Initialize the Miniport wrapper - THIS MUST BE THE FIRST NDIS CALL.
  116. */
  117. NdisMInitializeWrapper(
  118. &g_NdisWrapperHandle,
  119. DriverObject,
  120. RegistryPath,
  121. NULL
  122. );
  123. ASSERT(g_NdisWrapperHandle);
  124. /*
  125. // Initialize the characteristics table, exporting the Miniport's entry
  126. // points to the Miniport wrapper.
  127. */
  128. NdisZeroMemory((PVOID)&NdisCharacteristics, sizeof(NdisCharacteristics));
  129. NdisCharacteristics.MajorNdisVersion = NDIS_MAJOR_VERSION;
  130. NdisCharacteristics.MinorNdisVersion = NDIS_MINOR_VERSION;
  131. NdisCharacteristics.Reserved = NDIS_USE_WAN_WRAPPER;
  132. NdisCharacteristics.InitializeHandler = MiniportInitialize;
  133. NdisCharacteristics.CheckForHangHandler = MiniportCheckForHang;
  134. NdisCharacteristics.HaltHandler = MiniportHalt;
  135. NdisCharacteristics.ResetHandler = MiniportReset;
  136. NdisCharacteristics.ReturnPacketHandler = MiniportReturnPacket;
  137. NdisCharacteristics.CoActivateVcHandler = MiniportCoActivateVc;
  138. NdisCharacteristics.CoDeactivateVcHandler = MiniportCoDeactivateVc;
  139. NdisCharacteristics.CoRequestHandler = MiniportCoRequest;
  140. NdisCharacteristics.CoSendPacketsHandler = MiniportCoSendPackets;
  141. // These two routines are not needed because we are an MCM.
  142. // NdisCharacteristics.CoCreateVcHandler = MiniportCoCreateVc;
  143. // NdisCharacteristics.CoDeleteVcHandler = MiniportCoDeleteVc;
  144. /*
  145. // If the adapter does not generate an interrupt, these entry points
  146. // are not required. Otherwise, you can use the have the ISR routine
  147. // called each time an interupt is generated, or you can use the
  148. // enable/disable routines.
  149. */
  150. #if defined(CARD_REQUEST_ISR)
  151. # if (CARD_REQUEST_ISR == FALSE)
  152. NdisCharacteristics.DisableInterruptHandler = MiniportDisableInterrupt;
  153. NdisCharacteristics.EnableInterruptHandler = MiniportEnableInterrupt;
  154. # endif // CARD_REQUEST_ISR == FALSE
  155. NdisCharacteristics.HandleInterruptHandler = MiniportHandleInterrupt;
  156. NdisCharacteristics.ISRHandler = MiniportISR;
  157. #endif // defined(CARD_REQUEST_ISR)
  158. /*
  159. // Register the driver with the Miniport wrapper.
  160. */
  161. Status = NdisMRegisterMiniport(
  162. g_NdisWrapperHandle,
  163. (PNDIS_MINIPORT_CHARACTERISTICS) &NdisCharacteristics,
  164. sizeof(NdisCharacteristics)
  165. );
  166. /*
  167. // The driver will not load if this call fails.
  168. // The system will log the error for us.
  169. */
  170. if (Status != NDIS_STATUS_SUCCESS)
  171. {
  172. DBG_ERROR(DbgInfo,("Status=0x%X\n",Status));
  173. Result = STATUS_UNSUCCESSFUL;
  174. }
  175. else
  176. {
  177. DBG_NOTICE(DbgInfo,("Status=0x%X\n",Status));
  178. Result = STATUS_SUCCESS;
  179. }
  180. DBG_RETURN(DbgInfo, Result);
  181. return (Result);
  182. }
  183. /* @doc EXTERNAL INTERNAL Miniport Miniport_c MiniportInitialize
  184. @func
  185. <f MiniportInitialize> is a required function that sets up a NIC (or
  186. virtual NIC) for network I/O operations, claims all hardware resources
  187. necessary to the NIC in the registry, and allocates resources the driver
  188. needs to carry out network I/O operations.
  189. @comm
  190. No other outstanding requests to the miniport driver are possible when
  191. MiniportInitialize is called. No other request is submitted to the
  192. miniport driver until initialization is completed.
  193. The NDIS library supplies an array of supported media types. The miniport
  194. driver reads this array and provides the index of the media type that the
  195. NDIS library should use with this miniport driver. If the miniport driver
  196. is emulating a media type, its emulation must be transparent to the NDIS
  197. library.
  198. MiniportInitialize must call NdisMSetAttributes in order to return
  199. MiniportAdapterContext.
  200. If the miniport driver cannot find a common media type supported by both
  201. itself and the NDIS library, it should return
  202. NDIS_STATUS_UNSUPPORTED_MEDIA.
  203. If NDIS_STATUS_OPEN_ERROR is returned, the NDIS wrapper can examine the
  204. output parameter OpenErrorStatus to obtain more information about the
  205. error.
  206. MiniportInitialize is called with interrupts enabled. MiniportISR is
  207. called if the NIC generates any interrupts. The NDIS library will not call
  208. MiniportDisableInterrupt and MiniportEnableInterrupt during the
  209. MiniportInitialize function, so it is the responsibility of the miniport
  210. driver to acknowledge and clear any interrupts generated.
  211. @rdesc
  212. <f MiniportInitialize> returns zero if it is successful.<nl>
  213. Otherwise, a non-zero return value indicates an error condition.
  214. */
  215. NDIS_STATUS MiniportInitialize(
  216. OUT PNDIS_STATUS OpenErrorStatus, // @parm
  217. // Points to a variable that MiniportInitialize sets to an
  218. // NDIS_STATUS_XXX code specifying additional information about the
  219. // error if MiniportInitialize will return NDIS_STATUS_OPEN_ERROR.
  220. OUT PUINT SelectedMediumIndex, // @parm
  221. // Points to a variable in which MiniportInitialize sets the index of
  222. // the MediumArray element that specifies the medium type the driver
  223. // or its NIC uses.
  224. IN PNDIS_MEDIUM MediumArray, // @parm
  225. // Specifies an array of NdisMediumXxx values from which
  226. // MiniportInitialize selects one that its NIC supports or that the
  227. // driver supports as an interface to higher-level drivers.
  228. IN UINT MediumArraySize, // @parm
  229. // Specifies the number of elements at MediumArray.
  230. IN NDIS_HANDLE MiniportAdapterHandle, // @parm
  231. // Specifies a handle identifying the miniport's NIC, which is assigned
  232. // by the NDIS library. MiniportInitialize should save this handle; it
  233. // is a required parameter in subsequent calls to NdisXxx functions.
  234. IN NDIS_HANDLE WrapperConfigurationContext // @parm
  235. // Specifies a handle used only during initialization for calls to
  236. // NdisXxx configuration and initialization functions. For example,
  237. // this handle is a required parameter to NdisOpenConfiguration and
  238. // the NdisImmediateReadXxx and NdisImmediateWriteXxx functions.
  239. )
  240. {
  241. DBG_FUNC("MiniportInitialize")
  242. NDIS_STATUS Status;
  243. // Status result returned from an NDIS function call.
  244. PMINIPORT_ADAPTER_OBJECT pAdapter;
  245. // Pointer to our newly allocated object.
  246. UINT Index;
  247. // Loop counter.
  248. NDIS_CALL_MANAGER_CHARACTERISTICS McmCharacteristics;
  249. // Characteristics table passed to NdisMCmRegisterAddressFamily.
  250. CO_ADDRESS_FAMILY McmAddressFamily;
  251. // Address family passed to NdisMCmRegisterAddressFamily.
  252. DBG_ENTER(DbgInfo);
  253. DBG_PARAMS(DbgInfo,
  254. ("\n"
  255. "\t|OpenErrorStatus=0x%X\n"
  256. "\t|SelectedMediumIndex=0x%X\n"
  257. "\t|MediumArray=0x%X\n"
  258. "\t|MediumArraySize=0x%X\n"
  259. "\t|MiniportAdapterHandle=0x%X\n"
  260. "\t|WrapperConfigurationContext=0x%X\n",
  261. OpenErrorStatus,
  262. SelectedMediumIndex,
  263. MediumArray,
  264. MediumArraySize,
  265. MiniportAdapterHandle,
  266. WrapperConfigurationContext
  267. ));
  268. /*
  269. // Search the MediumArray for the NdisMediumCoWan media type.
  270. */
  271. for (Index = 0; Index < MediumArraySize; Index++)
  272. {
  273. if (MediumArray[Index] == NdisMediumCoWan)
  274. {
  275. break;
  276. }
  277. }
  278. /*
  279. // Make sure the protocol has requested the proper media type.
  280. */
  281. if (Index < MediumArraySize)
  282. {
  283. /*
  284. // Allocate memory for the adapter information structure.
  285. */
  286. Status = AdapterCreate(
  287. &pAdapter,
  288. MiniportAdapterHandle,
  289. WrapperConfigurationContext
  290. );
  291. if (Status == NDIS_STATUS_SUCCESS)
  292. {
  293. /*
  294. // Now it's time to initialize the hardware resources.
  295. */
  296. Status = AdapterInitialize(pAdapter);
  297. if (Status == NDIS_STATUS_SUCCESS)
  298. {
  299. /*
  300. // Initialize the address family so NDIS know's what we support.
  301. */
  302. NdisZeroMemory(&McmAddressFamily, sizeof(McmAddressFamily));
  303. McmAddressFamily.MajorVersion = NDIS_MAJOR_VERSION;
  304. McmAddressFamily.MinorVersion = NDIS_MINOR_VERSION;
  305. McmAddressFamily.AddressFamily = CO_ADDRESS_FAMILY_TAPI_PROXY;
  306. /*
  307. // Initialize the characteristics table, exporting the Miniport's entry
  308. // points to the Miniport wrapper.
  309. */
  310. NdisZeroMemory((PVOID)&McmCharacteristics, sizeof(McmCharacteristics));
  311. McmCharacteristics.MajorVersion = NDIS_MAJOR_VERSION;
  312. McmCharacteristics.MinorVersion = NDIS_MINOR_VERSION;
  313. McmCharacteristics.CmCreateVcHandler = ProtocolCoCreateVc;
  314. McmCharacteristics.CmDeleteVcHandler = ProtocolCoDeleteVc;
  315. McmCharacteristics.CmOpenAfHandler = ProtocolCmOpenAf;
  316. McmCharacteristics.CmCloseAfHandler = ProtocolCmCloseAf;
  317. McmCharacteristics.CmRegisterSapHandler = ProtocolCmRegisterSap;
  318. McmCharacteristics.CmDeregisterSapHandler = ProtocolCmDeregisterSap;
  319. McmCharacteristics.CmMakeCallHandler = ProtocolCmMakeCall;
  320. McmCharacteristics.CmCloseCallHandler = ProtocolCmCloseCall;
  321. McmCharacteristics.CmIncomingCallCompleteHandler = ProtocolCmIncomingCallComplete;
  322. McmCharacteristics.CmActivateVcCompleteHandler = ProtocolCmActivateVcComplete;
  323. McmCharacteristics.CmDeactivateVcCompleteHandler = ProtocolCmDeactivateVcComplete;
  324. McmCharacteristics.CmModifyCallQoSHandler = ProtocolCmModifyCallQoS;
  325. McmCharacteristics.CmRequestHandler = ProtocolCoRequest;
  326. McmCharacteristics.CmRequestCompleteHandler = ProtocolCoRequestComplete;
  327. DBG_NOTICE(pAdapter,("Calling NdisMCmRegisterAddressFamily\n"));
  328. Status = NdisMCmRegisterAddressFamily(
  329. MiniportAdapterHandle,
  330. &McmAddressFamily,
  331. &McmCharacteristics,
  332. sizeof(McmCharacteristics)
  333. );
  334. if (Status != NDIS_STATUS_SUCCESS)
  335. {
  336. DBG_ERROR(DbgInfo,("NdisMCmRegisterAddressFamily Status=0x%X\n",
  337. Status));
  338. /*
  339. // Log error message and return.
  340. */
  341. NdisWriteErrorLogEntry(
  342. MiniportAdapterHandle,
  343. NDIS_ERROR_CODE_OUT_OF_RESOURCES,
  344. 3,
  345. Status,
  346. __FILEID__,
  347. __LINE__
  348. );
  349. }
  350. }
  351. if (Status == NDIS_STATUS_SUCCESS)
  352. {
  353. /*
  354. // Save the selected media type.
  355. */
  356. *SelectedMediumIndex = Index;
  357. }
  358. else
  359. {
  360. /*
  361. // Something went wrong, so let's make sure everything is
  362. // cleaned up.
  363. */
  364. MiniportHalt(pAdapter);
  365. }
  366. }
  367. }
  368. else
  369. {
  370. DBG_ERROR(DbgInfo,("No NdisMediumCoWan found (Array=0x%X, ArraySize=%d)\n",
  371. MediumArray, MediumArraySize));
  372. /*
  373. // Log error message and return.
  374. */
  375. NdisWriteErrorLogEntry(
  376. MiniportAdapterHandle,
  377. NDIS_ERROR_CODE_UNSUPPORTED_CONFIGURATION,
  378. 3,
  379. Index,
  380. __FILEID__,
  381. __LINE__
  382. );
  383. Status = NDIS_STATUS_UNSUPPORTED_MEDIA;
  384. }
  385. /*
  386. // If all goes well, register a shutdown handler for this adapter.
  387. */
  388. if (Status == NDIS_STATUS_SUCCESS)
  389. {
  390. NdisMRegisterAdapterShutdownHandler(MiniportAdapterHandle,
  391. pAdapter, MiniportShutdown);
  392. }
  393. DBG_NOTICE(DbgInfo,("Status=0x%X\n",Status));
  394. DBG_RETURN(DbgInfo, Status);
  395. return (Status);
  396. }
  397. /* @doc EXTERNAL INTERNAL Miniport Miniport_c MiniportHalt
  398. @func
  399. <f MiniportHalt> request is used to halt the adapter such that it is
  400. no longer functioning.
  401. @comm
  402. The Miniport should stop the adapter and deregister all of its resources
  403. before returning from this routine.
  404. It is not necessary for the Miniport to complete all outstanding
  405. requests and no other requests will be submitted to the Miniport
  406. until the operation is completed.
  407. Interrupts are enabled during the call to this routine.
  408. */
  409. VOID MiniportHalt(
  410. IN PMINIPORT_ADAPTER_OBJECT pAdapter // @parm
  411. // A pointer to the <t MINIPORT_ADAPTER_OBJECT> instance.
  412. )
  413. {
  414. DBG_FUNC("MiniportHalt")
  415. DBG_ENTER(DbgInfo);
  416. /*
  417. // Remove our shutdown handler from the system.
  418. */
  419. NdisMDeregisterAdapterShutdownHandler(pAdapter->MiniportAdapterHandle);
  420. /*
  421. // Free adapter instance.
  422. */
  423. AdapterDestroy(pAdapter);
  424. DBG_LEAVE(DbgInfo);
  425. }
  426. /* @doc EXTERNAL INTERNAL Miniport Miniport_c MiniportShutdown
  427. @func
  428. <f MiniportShutdown> is an optional function that restores a NIC to its
  429. initial state when the system is shut down, whether by the user or because
  430. an unrecoverable system error occurred.
  431. @comm
  432. Every NIC driver should have a <f MiniportShutdown> function.
  433. <f MiniportShutdown> does nothing more than restore the NIC to its initial
  434. state (before the miniport's DriverEntry function runs). However, this
  435. ensures that the NIC is in a known state and ready to be reinitialized
  436. when the machine is rebooted after a system shutdown occurs for any
  437. reason, including a crash dump.
  438. A NIC driver's MiniportInitialize function must call
  439. NdisMRegisterAdapterShutdownHandler to set up a <f MiniportShutdown>
  440. function. The driver's MiniportHalt function must make a reciprocal call
  441. to NdisMDeregisterAdapterShutdownHandler.
  442. If <f MiniportShutdown> is called due to a user-initiated system shutdown,
  443. it runs at IRQL PASSIVE_LEVEL in a system-thread context. If it is called
  444. due to an unrecoverable error, <f MiniportShutdown> runs at an arbitrary
  445. IRQL and in the context of whatever component raised the error. For
  446. example, <f MiniportShutdown> might be run at high DIRQL in the context of
  447. an ISR for a device essential to continued execution of the system.
  448. <f MiniportShutdown> should call no NdisXxx functions.
  449. */
  450. VOID MiniportShutdown(
  451. IN PMINIPORT_ADAPTER_OBJECT pAdapter // @parm
  452. // A pointer to the <t MINIPORT_ADAPTER_OBJECT> instance.
  453. )
  454. {
  455. DBG_FUNC("MiniportShutdown")
  456. DBG_ENTER(pAdapter);
  457. /*
  458. // Reset the hardware and bial out - don't release any resources!
  459. */
  460. CardReset(pAdapter->pCard);
  461. DBG_LEAVE(pAdapter);
  462. }
  463. /* @doc EXTERNAL INTERNAL Miniport Miniport_c MiniportReset
  464. @func
  465. <f MiniportReset> request instructs the Miniport to issue a hardware
  466. reset to the network adapter. The Miniport also resets its software
  467. state.
  468. The <F MiniportReset> request may also reset the parameters of the adapter.
  469. If a hardware reset of the adapter resets the current station address
  470. to a value other than what it is currently configured to, the Miniport
  471. driver automatically restores the current station address following the
  472. reset. Any multicast or functional addressing masks reset by the
  473. hardware do not have to be reprogrammed by the Miniport.
  474. <f Note>: This is change from the NDIS 3.0 driver specification. If the
  475. multicast or functional addressing information, the packet filter, the
  476. lookahead size, and so on, needs to be restored, the Miniport indicates
  477. this with setting the flag AddressingReset to TRUE.
  478. It is not necessary for the Miniport to complete all outstanding requests
  479. and no other requests will be submitted to the Miniport until the
  480. operation is completed. Also, the Miniport does not have to signal
  481. the beginning and ending of the reset with NdisMIndicateStatus.
  482. <f Note>: These are different than the NDIS 3.0 driver specification.
  483. The Miniport must complete the original request, if the orginal
  484. call to <F MiniportReset> return NDIS_STATUS_PENDING, by calling
  485. NdisMResetComplete.
  486. If the underlying hardware does not provide a reset function under
  487. software control, then this request completes abnormally with
  488. NDIS_STATUS_NOT_RESETTABLE. If the underlying hardware attempts a
  489. reset and finds recoverable errors, the request completes successfully
  490. with NDIS_STATUS_SOFT_ERRORS. If the underlying hardware resets and,
  491. in the process, finds nonrecoverable errors, the request completes
  492. successfully with the status NDIS_STATUS_HARD_ERRORS. If the
  493. underlying hardware reset is accomplished without any errors,
  494. the request completes successfully with the status NDIS_STATUS_SUCCESS.
  495. Interrupts are in any state during this call.
  496. @comm
  497. I have only seen MiniportReset called when the driver is not working
  498. properly. If this gets called, your code is probably broken, so fix
  499. it. Don't try to recover here unless there is some hardware/firmware
  500. problem you must work around.
  501. @rdesc
  502. <f MiniportReset> returns zero if it is successful.<nl>
  503. Otherwise, a non-zero return value indicates an error condition.
  504. */
  505. NDIS_STATUS MiniportReset(
  506. OUT PBOOLEAN AddressingReset, // @parm
  507. // The Miniport indicates if the wrapper needs to call
  508. // <f MiniportCoRequest> to restore the addressing information
  509. // to the current values by setting this value to TRUE.
  510. IN PMINIPORT_ADAPTER_OBJECT pAdapter // @parm
  511. // A pointer to the <t MINIPORT_ADAPTER_OBJECT> instance.
  512. )
  513. {
  514. DBG_FUNC("MiniportReset")
  515. NDIS_STATUS Result = NDIS_STATUS_SUCCESS;
  516. // Result code returned by this function.
  517. DBG_ENTER(pAdapter);
  518. DBG_ERROR(pAdapter,("##### !!! THIS SHOULD NEVER BE CALLED !!! #####\n"));
  519. /*
  520. // If anything goes wrong here, it's very likely an unrecoverable
  521. // hardware failure. So we'll just shut this thing down for good.
  522. */
  523. Result = NDIS_STATUS_HARD_ERRORS;
  524. *AddressingReset = TRUE;
  525. return (Result);
  526. }