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.

257 lines
11 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 Adapter Adapter_h
  12. @module Adapter.h |
  13. This module defines the interface to the <t MINIPORT_ADAPTER_OBJECT>.
  14. @head3 Contents |
  15. @index class,mfunc,func,msg,mdata,struct,enum | Adapter_h
  16. @end
  17. */
  18. /* @doc EXTERNAL INTERNAL
  19. @topic 4.1 Adapter Overview |
  20. This section describes the interfaces defined in <f Adapter\.h>.
  21. This module isolates most the NDIS specific, logical adapter interfaces.
  22. It should require very little change if you follow this same overall
  23. architecture. You should try to isolate your changes to the <t CARD_OBJECT>
  24. that is contained within the logical adapter <t MINIPORT_ADAPTER_OBJECT>.
  25. The driver assumes one <t MINIPORT_ADAPTER_OBJECT> per physical ISDN card.
  26. Each adapter contains a single logical D-Channel, and an aribitrary number
  27. of logical B-Channels. It is up to you to map these logical interfaces to
  28. the physical interfaces on your card. I have been pretty successful at
  29. using this model on a variety of ISDN hardware including BRI, PRI, T1, and
  30. E1. By maintaining the logical abstraction, you can configure your cards
  31. and lines any way you choose, and then let Windows think they are B Channels.
  32. Even though they may be configured as bonded DS-0's on a T1 using robbed
  33. bit signalling. Just hide those details in your Card, Port, and BChannel
  34. objects.
  35. @end
  36. */
  37. #ifndef _ADAPTER_H
  38. #define _ADAPTER_H
  39. #define MINIPORT_ADAPTER_OBJECT_TYPE ((ULONG)'A')+\
  40. ((ULONG)'D'<<8)+\
  41. ((ULONG)'A'<<16)+\
  42. ((ULONG)'P'<<24)
  43. /* @doc INTERNAL Adapter Adapter_h MINIPORT_ADAPTER_OBJECT
  44. @struct MINIPORT_ADAPTER_OBJECT |
  45. This structure contains the data associated with a single Miniport
  46. adapter instance. Here, Adapter is defined as the manager of specific
  47. Network Interface Card (NIC) installed under the NDIS wrapper. This
  48. adapter is responsible for managing all interactions between the NIC and
  49. the host operating system using the NDIS library.
  50. @comm
  51. This structure must contain a reference to all other objects being managed
  52. by this adapter object. The adapter object is the only reference passed
  53. between NDIS and the Miniport. This is the <t MiniportAdapterContext> we
  54. pass into <f NdisMSetAttributes> from <f MiniportInitialize>. This value
  55. is passed as a parameter to the Miniport entry points called by the NDIS
  56. wrapper.
  57. One of these objects is created each time that our <f MiniportInitialize>
  58. routine is called. The NDIS wrapper calls this routine once for each of
  59. our devices installed and enabled in the system. In the case of a hot
  60. swappable NIC (e.g. PCMCIA) the adapter might come and go several times
  61. during a single Windows session.
  62. */
  63. typedef struct MINIPORT_ADAPTER_OBJECT
  64. {
  65. #if DBG
  66. ULONG DbgFlags; // @field
  67. // Debug flags control how much debug is displayed in the checked version.
  68. // Put it at the front so we can set it easily with debugger.
  69. UCHAR DbgID[12]; // @field
  70. // This field is initialized to an ASCII decimal string containing the
  71. // adapter instance number 1..N. It is only used to output debug messages.
  72. #endif
  73. ULONG ObjectType; // @field
  74. // Four characters used to identify this type of object 'ADAP'.
  75. ULONG ObjectID; // @field
  76. // Instance number used to identify a specific object instance.
  77. NDIS_HANDLE MiniportAdapterHandle; // @field
  78. // Specifies a handle identifying the miniport's NIC, which is assigned
  79. // by the NDIS library. MiniportInitialize should save this handle; it
  80. // is a required parameter in subsequent calls to NdisXxx functions.
  81. NDIS_HANDLE WrapperConfigurationContext;// @field
  82. // Specifies a handle used only during initialization for calls to
  83. // NdisXxx configuration and initialization functions. For example,
  84. // this handle is a required parameter to NdisOpenConfiguration and
  85. // the NdisImmediateReadXxx and NdisImmediateWriteXxx functions.
  86. PCARD_OBJECT pCard; // @field
  87. // Pointer to the hardware specific <t CARD_OBJECT>. Created by
  88. // <f CardCreate>.
  89. PDCHANNEL_OBJECT pDChannel; // @field
  90. // Pointer to the <t DCHANNEL_OBJECT> created by <f DChannelCreate>.
  91. // One for the entire NIC.
  92. ULONG NumBChannels; // @field
  93. // The number of <t BCHANNEL_OBJECT>'s supported by the NIC.
  94. PBCHANNEL_OBJECT * pBChannelArray; // @field
  95. // An array of <t BCHANNEL_OBJECT>'s created by <f BChannelCreate>.
  96. // One entry for each logical BChannel on NIC.
  97. LIST_ENTRY BChannelAvailableList; // @field
  98. // Linked list of available BChannels.
  99. // Keep listening BChannel's at the end of the available list,
  100. // so they can be easily allocated to incoming calls.
  101. // By using those on the front of the list for outgoing calls,
  102. // we can help insure that there will be a BChannel available for
  103. // an incoming call. But still, we may end up using a listening
  104. // BChannel for an outgoing call, and that's okay; we're just trying
  105. // to be prudent with the allocation scheme.
  106. ULONG NumLineOpens; // @field
  107. // The number of line open calls currently on this adapter.
  108. NDIS_SPIN_LOCK TransmitLock; // @field
  109. // This spin lock is used to provide mutual exclusion around accesses
  110. // to the transmit queue manipulation routines. This is necessary since
  111. // we can be called at any time by the B-channel services driver and
  112. // we could already be processing an NDIS request.
  113. LIST_ENTRY TransmitPendingList; // @field
  114. // Packets waiting to be sent when the controller is available.
  115. // See <t NDIS_PACKET>.
  116. LIST_ENTRY TransmitCompleteList; // @field
  117. // Packets waiting for completion processing. After the packet is
  118. // transmitted, the protocol stack is given an indication.
  119. // See <t NDIS_PACKET>.
  120. NDIS_SPIN_LOCK ReceiveLock; // @field
  121. // This spin lock is used to provide mutual exclusion around accesses
  122. // to the receive queue manipulation routines. This is necessary since
  123. // we can be called at any time by the B-channel services driver and
  124. // we could already be processing an NDIS request.
  125. LIST_ENTRY ReceiveCompleteList; // @field
  126. // Buffers waiting to be processed by the
  127. NDIS_SPIN_LOCK EventLock; // @field
  128. // This spin lock is used to provide mutual exclusion around accesses
  129. // to the event queue manipulation routines. This is necessary since
  130. // we can be called at any time by the B-channel services driver and
  131. // we could already be processing an NDIS request.
  132. LIST_ENTRY EventList; // @field
  133. // driver callback events waiting to be processed.
  134. // See <t BCHANNEL_EVENT_OBJECT>.
  135. NDIS_MINIPORT_TIMER EventTimer; // @field
  136. // This timer is used to schedule the event processing routine to run
  137. // when the system reaches a quiescent state.
  138. ULONG NextEvent; // @field
  139. // Where do we store the next event.
  140. long NestedEventHandler; // @field
  141. // Keeps track of entry to and exit from the event handler.
  142. long NestedDataHandler; // @field
  143. // Keeps track of entry to and exit from the Tx/Rx handlers.
  144. NDIS_HANDLE NdisAfHandle; // @field
  145. // Used to store the NDIS address family handle passed into
  146. // <f ProtocolCmOpenAf>.
  147. ULONG Flags;
  148. # define ADAP_PENDING_SAP_CLOSE 0x00000002
  149. NDIS_WAN_CO_INFO WanInfo; // @field
  150. // A copy of our <t NDIS_WAN_CO_INFO> structure is setup at init
  151. // time and doesn't change.
  152. BOOLEAN NeedStatusCompleteIndication; // @field
  153. // This flag indicates whether or not <f NdisMIndicateStatusComplete>
  154. // needs to be called after the completion of requests or event processing.
  155. // This is set TRUE if <f NdisMIndicateStatus> is called while
  156. // processing a request or event.
  157. ULONG TotalRxBytes; // @field
  158. // Total bytes read by driver during this session.
  159. ULONG TotalTxBytes; // @field
  160. // Total bytes written by driver during this session.
  161. ULONG TotalRxPackets; // @field
  162. // Total packets read by driver during this session.
  163. ULONG TotalTxPackets; // @field
  164. // Total packets written by driver during this session.
  165. ULONG TODO; // @field
  166. // Add your data members here.
  167. } MINIPORT_ADAPTER_OBJECT;
  168. extern PMINIPORT_ADAPTER_OBJECT g_Adapters[MAX_ADAPTERS];
  169. /*
  170. Function prototypes.
  171. */
  172. NDIS_STATUS AdapterCreate(
  173. OUT PMINIPORT_ADAPTER_OBJECT *ppAdapter,
  174. IN NDIS_HANDLE MiniportAdapterHandle,
  175. IN NDIS_HANDLE WrapperConfigurationContext
  176. );
  177. void AdapterDestroy(
  178. IN PMINIPORT_ADAPTER_OBJECT pAdapter
  179. );
  180. NDIS_STATUS AdapterInitialize(
  181. IN PMINIPORT_ADAPTER_OBJECT pAdapter
  182. );
  183. #endif // _ADAPTER_H