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.

298 lines
9.5 KiB

  1. /*
  2. (C) Copyright 1998
  3. All rights reserved.
  4. Portions of this software are:
  5. (C) Copyright 1995, 1999 TriplePoint, Inc. -- http://www.TriplePoint.com
  6. License to use this software is granted under the terms outlined in
  7. the TriplePoint Software Services Agreement.
  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_h
  12. @module Miniport.h |
  13. This module defines the interface to the <t MINIPORT_DRIVER_OBJECT_TYPE>.
  14. @comm
  15. This module defines the software structures and values used to support
  16. the NDIS WAN/TAPI Minport. It's a good place to look when your trying
  17. to figure out how the driver structures are related to each other.
  18. Include this file at the top of each module in the Miniport.
  19. @head3 Contents |
  20. @index class,mfunc,func,msg,mdata,struct,enum | Miniport_h
  21. @end
  22. */
  23. #ifndef _MPDMAIN_H
  24. #define _MPDMAIN_H
  25. #define MINIPORT_DRIVER_OBJECT_TYPE ((ULONG)'D')+\
  26. ((ULONG)'R'<<8)+\
  27. ((ULONG)'V'<<16)+\
  28. ((ULONG)'R'<<24)
  29. #define INTERRUPT_OBJECT_TYPE ((ULONG)'I')+\
  30. ((ULONG)'N'<<8)+\
  31. ((ULONG)'T'<<16)+\
  32. ((ULONG)'R'<<24)
  33. #define RECEIVE_OBJECT_TYPE ((ULONG)'R')+\
  34. ((ULONG)'E'<<8)+\
  35. ((ULONG)'C'<<16)+\
  36. ((ULONG)'V'<<24)
  37. #define TRANSMIT_OBJECT_TYPE ((ULONG)'T')+\
  38. ((ULONG)'R'<<8)+\
  39. ((ULONG)'A'<<16)+\
  40. ((ULONG)'N'<<24)
  41. #define REQUEST_OBJECT_TYPE ((ULONG)'R')+\
  42. ((ULONG)'Q'<<8)+\
  43. ((ULONG)'S'<<16)+\
  44. ((ULONG)'T'<<24)
  45. /*
  46. // NDIS_MINIPORT_DRIVER and BINARY_COMPATIBLE must be defined before the
  47. // NDIS include files. Normally, it is defined on the command line by
  48. // setting the C_DEFINES variable in the SOURCES build file.
  49. */
  50. #include <ndis.h>
  51. #include <ndiswan.h>
  52. #include <ndistapi.h>
  53. #include "vTarget.h"
  54. #include "TpiDebug.h"
  55. // Figure out which DDK we're building with.
  56. #if defined(NDIS_LCODE)
  57. # if defined(NDIS_DOS)
  58. # define USING_WFW_DDK
  59. # define NDIS_MAJOR_VERSION 0x03
  60. # define NDIS_MINOR_VERSION 0x00
  61. # elif defined(OID_WAN_GET_INFO)
  62. # define USING_WIN98_DDK
  63. # elif defined(NDIS_WIN)
  64. # define USING_WIN95_DDK
  65. # else
  66. # error "BUILDING WITH UNKNOWN 9X DDK"
  67. # endif
  68. #elif defined(NDIS_NT)
  69. # if defined(OID_GEN_MACHINE_NAME)
  70. # define USING_NT51_DDK
  71. # elif defined(OID_GEN_SUPPORTED_GUIDS)
  72. # define USING_NT50_DDK
  73. # elif defined(OID_GEN_MEDIA_CONNECT_STATUS)
  74. # define USING_NT40_DDK
  75. # elif defined(OID_WAN_GET_INFO)
  76. # define USING_NT351_DDK
  77. # else
  78. # define USING_NT31_DDK
  79. # endif
  80. #else
  81. # error "BUILDING WITH UNKNOWN DDK"
  82. #endif
  83. // Figure out which DDK we should be building with.
  84. #if defined(NDIS51) || defined(NDIS51_MINIPORT)
  85. # if defined(USING_NT51_DDK)
  86. # define NDIS_MAJOR_VERSION 0x05
  87. # define NDIS_MINOR_VERSION 0x01
  88. # else
  89. # error "YOU MUST BUILD WITH THE NT 5.1 DDK"
  90. # endif
  91. #elif defined(NDIS50) || defined(NDIS50_MINIPORT)
  92. # if defined(USING_NT50_DDK) || defined(USING_NT51_DDK)
  93. # define NDIS_MAJOR_VERSION 0x05
  94. # define NDIS_MINOR_VERSION 0x00
  95. # else
  96. # error "YOU MUST BUILD WITH THE NT 5.0 or 5.1 DDK"
  97. # endif
  98. #elif defined(NDIS40) || defined(NDIS40_MINIPORT)
  99. # if defined(USING_NT40_DDK) || defined(USING_NT50_DDK) || defined(USING_NT51_DDK)
  100. # define NDIS_MAJOR_VERSION 0x04
  101. # define NDIS_MINOR_VERSION 0x00
  102. # else
  103. # error "YOU MUST BUILD WITH THE NT 4.0 or 5.0 DDK"
  104. # endif
  105. #elif defined(NDIS_MINIPORT_DRIVER)
  106. # if defined(USING_NT351_DDK) || defined(USING_NT40_DDK) || defined(USING_NT50_DDK) || defined(USING_NT51_DDK)
  107. # define NDIS_MAJOR_VERSION 0x03
  108. # define NDIS_MINOR_VERSION 0x00
  109. # else
  110. # error "YOU MUST BUILD WITH THE NT 3.51, 4.0, or 5.0 DDK"
  111. # endif
  112. #elif !defined(NDIS_MAJOR_VERSION) || !defined(NDIS_MINOR_VERSION)
  113. // Must be FULL MAC
  114. # define NDIS_MAJOR_VERSION 0x03
  115. # define NDIS_MINOR_VERSION 0x00
  116. #endif
  117. // Gotta nest NDIS_STRING_CONST or compiler/preprocessor won't be able to
  118. // handle L##DEFINED_STRING.
  119. #define INIT_STRING_CONST(name) NDIS_STRING_CONST(name)
  120. typedef struct MINIPORT_ADAPTER_OBJECT *PMINIPORT_ADAPTER_OBJECT;
  121. typedef struct BCHANNEL_OBJECT *PBCHANNEL_OBJECT;
  122. typedef struct DCHANNEL_OBJECT *PDCHANNEL_OBJECT;
  123. typedef struct CARD_OBJECT *PCARD_OBJECT;
  124. typedef struct PORT_OBJECT *PPORT_OBJECT;
  125. /*
  126. // The <t NDIS_MAC_LINE_UP> structure is confusing, so I redefine the
  127. // field name to be what makes sense.
  128. */
  129. #define MiniportLinkContext NdisLinkHandle
  130. #if defined(_VXD_) && !defined(NDIS_LCODE)
  131. # define NDIS_LCODE code_seg("_LTEXT", "LCODE")
  132. # define NDIS_LDATA data_seg("_LDATA", "LCODE")
  133. #endif
  134. /*
  135. // The link speeds we support.
  136. */
  137. #define _64KBPS 64000
  138. #define _56KBPS 56000
  139. #define MICROSECONDS (1)
  140. #define MILLISECONDS (1000*MICROSECONDS)
  141. #define SECONDS (1000*MILLISECONDS)
  142. /*
  143. // Include everything here so the driver modules can just include this
  144. // file and get all they need.
  145. */
  146. #include "Keywords.h"
  147. #include "Card.h"
  148. #include "Adapter.h"
  149. #include "BChannel.h"
  150. #include "DChannel.h"
  151. #include "Link.h"
  152. #include "Port.h"
  153. #include "Tspi.h"
  154. #include "TpiParam.h"
  155. #include "TpiMem.h"
  156. /***************************************************************************
  157. // These routines are defined in Miniport.c
  158. */
  159. NTSTATUS DriverEntry(
  160. IN PDRIVER_OBJECT DriverObject,
  161. IN PUNICODE_STRING RegistryPath
  162. );
  163. NDIS_STATUS MiniportInitialize(
  164. OUT PNDIS_STATUS OpenErrorStatus,
  165. OUT PUINT SelectedMediumIndex,
  166. IN PNDIS_MEDIUM MediumArray,
  167. IN UINT MediumArraySize,
  168. IN NDIS_HANDLE MiniportAdapterHandle,
  169. IN NDIS_HANDLE WrapperConfigurationContext
  170. );
  171. void MiniportHalt(
  172. IN PMINIPORT_ADAPTER_OBJECT pAdapter
  173. );
  174. void MiniportShutdown(
  175. IN PMINIPORT_ADAPTER_OBJECT pAdapter
  176. );
  177. NDIS_STATUS MiniportReset(
  178. OUT PBOOLEAN AddressingReset,
  179. IN PMINIPORT_ADAPTER_OBJECT pAdapter
  180. );
  181. /***************************************************************************
  182. // These routines are defined in interrup.c
  183. */
  184. BOOLEAN MiniportCheckForHang(
  185. IN PMINIPORT_ADAPTER_OBJECT pAdapter
  186. );
  187. void MiniportDisableInterrupt(
  188. IN PMINIPORT_ADAPTER_OBJECT pAdapter
  189. );
  190. void MiniportEnableInterrupt(
  191. IN PMINIPORT_ADAPTER_OBJECT pAdapter
  192. );
  193. void MiniportHandleInterrupt(
  194. IN PMINIPORT_ADAPTER_OBJECT pAdapter
  195. );
  196. void MiniportISR(
  197. OUT PBOOLEAN InterruptRecognized,
  198. OUT PBOOLEAN QueueMiniportHandleInterrupt,
  199. IN PMINIPORT_ADAPTER_OBJECT pAdapter
  200. );
  201. void MiniportTimer(
  202. IN PVOID SystemSpecific1,
  203. IN PMINIPORT_ADAPTER_OBJECT pAdapter,
  204. IN PVOID SystemSpecific2,
  205. IN PVOID SystemSpecific3
  206. );
  207. /***************************************************************************
  208. // These routines are defined in receive.c
  209. */
  210. void ReceivePacketHandler(
  211. IN PBCHANNEL_OBJECT pBChannel,
  212. IN PUCHAR ReceiveBuffer,
  213. IN ULONG BytesReceived
  214. );
  215. /***************************************************************************
  216. // These routines are defined in request.c
  217. */
  218. NDIS_STATUS MiniportQueryInformation(
  219. IN PMINIPORT_ADAPTER_OBJECT pAdapter,
  220. IN NDIS_OID Oid,
  221. IN PVOID InformationBuffer,
  222. IN ULONG InformationBufferLength,
  223. OUT PULONG BytesWritten,
  224. OUT PULONG BytesNeeded
  225. );
  226. NDIS_STATUS MiniportSetInformation(
  227. IN PMINIPORT_ADAPTER_OBJECT pAdapter,
  228. IN NDIS_OID Oid,
  229. IN PVOID InformationBuffer,
  230. IN ULONG InformationBufferLength,
  231. OUT PULONG BytesRead,
  232. OUT PULONG BytesNeeded
  233. );
  234. /***************************************************************************
  235. // These routines are defined in send.c
  236. */
  237. NDIS_STATUS MiniportWanSend(
  238. IN NDIS_HANDLE MacBindingHandle,
  239. IN PBCHANNEL_OBJECT pBChannel,
  240. IN PNDIS_WAN_PACKET pWanPacket
  241. );
  242. void TransmitCompleteHandler(
  243. IN PMINIPORT_ADAPTER_OBJECT pAdapter
  244. );
  245. #endif // _MPDMAIN_H