32aab60ace588e1b5ef99e37e0c131538e3a7678
[reactos.git] / reactos / drivers / network / ndis / include / miniport.h
1 /*
2 * COPYRIGHT: See COPYING in the top level directory
3 * PROJECT: ReactOS NDIS library
4 * FILE: ndis/miniport.h
5 * PURPOSE: Definitions for routines used by NDIS miniport drivers
6 */
7
8 #ifndef __MINIPORT_H
9 #define __MINIPORT_H
10
11 #include <ndis.h>
12 #include <ndissys.h>
13
14 struct _ADAPTER_BINDING;
15
16 typedef struct _HARDWARE_ADDRESS {
17 union {
18 UCHAR Medium802_3[ETH_LENGTH_OF_ADDRESS];
19 } Type;
20 } HARDWARE_ADDRESS, *PHARDWARE_ADDRESS;
21
22 /* Information about a miniport */
23 typedef struct _NDIS_M_DRIVER_BLOCK {
24 LIST_ENTRY ListEntry; /* Entry on global list */
25 KSPIN_LOCK Lock; /* Protecting spin lock */
26 NDIS_MINIPORT_CHARACTERISTICS MiniportCharacteristics; /* Miniport characteristics */
27 WORK_QUEUE_ITEM WorkItem; /* Work item */
28 PDRIVER_OBJECT DriverObject; /* Driver object of miniport */
29 LIST_ENTRY DeviceList; /* Adapters created by miniport */
30 PUNICODE_STRING RegistryPath; /* SCM Registry key */
31 #if !defined(_MSC_VER) && defined(__NDIS_H)
32 } NDIS_M_DRIVER_BLOCK_COMPATIBILITY_HACK_DONT_USE;
33 #else
34 } NDIS_M_DRIVER_BLOCK, *PNDIS_M_DRIVER_BLOCK;
35 #endif
36
37 /* There must be some defined struct to do this... */
38 typedef struct _NDIS_M_DEVICE_BLOCK {
39 PDEVICE_OBJECT DeviceObject;
40 PNDIS_STRING SymbolicName;
41 } NDIS_M_DEVICE_BLOCK, *PNDIS_M_DEVICE_BLOCK;
42
43 /* resources allocated on behalf on the miniport */
44 #define MINIPORT_RESOURCE_TYPE_REGISTRY_DATA 0
45 #define MINIPORT_RESOURCE_TYPE_MEMORY 1
46 typedef struct _MINIPORT_RESOURCE {
47 LIST_ENTRY ListEntry;
48 ULONG ResourceType;
49 PVOID Resource;
50 } MINIPORT_RESOURCE, *PMINIPORT_RESOURCE;
51
52 /* Configuration context */
53 typedef struct _MINIPORT_CONFIGURATION_CONTEXT {
54 NDIS_HANDLE Handle;
55 LIST_ENTRY ResourceListHead;
56 KSPIN_LOCK ResourceLock;
57 } MINIPORT_CONFIGURATION_CONTEXT, *PMINIPORT_CONFIGURATION_CONTEXT;
58
59 /* Bugcheck callback context */
60 typedef struct _MINIPORT_BUGCHECK_CONTEXT {
61 PVOID DriverContext;
62 ADAPTER_SHUTDOWN_HANDLER ShutdownHandler;
63 PKBUGCHECK_CALLBACK_RECORD CallbackRecord;
64 } MINIPORT_BUGCHECK_CONTEXT, *PMINIPORT_BUGCHECK_CONTEXT;
65
66 /* a miniport's shared memory */
67 typedef struct _MINIPORT_SHARED_MEMORY {
68 PDMA_ADAPTER AdapterObject;
69 ULONG Length;
70 PHYSICAL_ADDRESS PhysicalAddress;
71 PVOID VirtualAddress;
72 BOOLEAN Cached;
73 PNDIS_MINIPORT_BLOCK Adapter;
74 PVOID Context;
75 PKEVENT Event;
76 } MINIPORT_SHARED_MEMORY, *PMINIPORT_SHARED_MEMORY;
77
78 /* A structure of WrapperConfigurationContext (not compatible with the
79 Windows one). */
80 typedef struct _NDIS_WRAPPER_CONTEXT {
81 HANDLE RegistryHandle;
82 PDEVICE_OBJECT DeviceObject;
83 ULONG BusNumber;
84 ULONG SlotNumber;
85 } NDIS_WRAPPER_CONTEXT, *PNDIS_WRAPPER_CONTEXT;
86
87 #define GET_MINIPORT_DRIVER(Handle)((PNDIS_M_DRIVER_BLOCK)Handle)
88
89 /* Information about a logical adapter */
90 typedef struct _LOGICAL_ADAPTER
91 {
92 NDIS_MINIPORT_BLOCK NdisMiniportBlock; /* NDIS defined fields */
93 PNDIS_MINIPORT_WORK_ITEM WorkQueueHead; /* Head of work queue */
94 PNDIS_MINIPORT_WORK_ITEM WorkQueueTail; /* Tail of work queue */
95 LIST_ENTRY ListEntry; /* Entry on global list */
96 LIST_ENTRY MiniportListEntry; /* Entry on miniport driver list */
97 LIST_ENTRY ProtocolListHead; /* List of bound protocols */
98 ULONG MediumHeaderSize; /* Size of medium header */
99 HARDWARE_ADDRESS Address; /* Hardware address of adapter */
100 ULONG AddressLength; /* Length of hardware address */
101 PMINIPORT_BUGCHECK_CONTEXT BugcheckContext; /* Adapter's shutdown handler */
102 } LOGICAL_ADAPTER, *PLOGICAL_ADAPTER;
103
104 #define GET_LOGICAL_ADAPTER(Handle)((PLOGICAL_ADAPTER)Handle)
105
106 extern LIST_ENTRY MiniportListHead;
107 extern KSPIN_LOCK MiniportListLock;
108 extern LIST_ENTRY AdapterListHead;
109 extern KSPIN_LOCK AdapterListLock;
110
111
112 #if DBG
113 VOID
114 MiniDisplayPacket(
115 PNDIS_PACKET Packet);
116 #endif /* DBG */
117
118 VOID
119 MiniIndicateData(
120 PLOGICAL_ADAPTER Adapter,
121 NDIS_HANDLE MacReceiveContext,
122 PVOID HeaderBuffer,
123 UINT HeaderBufferSize,
124 PVOID LookaheadBuffer,
125 UINT LookaheadBufferSize,
126 UINT PacketSize);
127
128 BOOLEAN
129 MiniAdapterHasAddress(
130 PLOGICAL_ADAPTER Adapter,
131 PNDIS_PACKET Packet);
132
133 PLOGICAL_ADAPTER
134 MiniLocateDevice(
135 PNDIS_STRING AdapterName);
136
137 NDIS_STATUS
138 MiniQueryInformation(
139 PLOGICAL_ADAPTER Adapter,
140 NDIS_OID Oid,
141 ULONG Size,
142 PVOID Buffer,
143 PULONG BytesWritten);
144
145 VOID
146 FASTCALL
147 MiniQueueWorkItem(
148 PLOGICAL_ADAPTER Adapter,
149 NDIS_WORK_ITEM_TYPE WorkItemType,
150 PVOID WorkItemContext,
151 BOOLEAN Top);
152
153 NDIS_STATUS
154 FASTCALL
155 MiniDequeueWorkItem(
156 PLOGICAL_ADAPTER Adapter,
157 NDIS_WORK_ITEM_TYPE *WorkItemType,
158 PVOID *WorkItemContext);
159
160 NDIS_STATUS
161 MiniDoRequest(
162 PLOGICAL_ADAPTER Adapter,
163 PNDIS_REQUEST NdisRequest);
164
165 BOOLEAN
166 NdisFindDevice(
167 UINT VendorID,
168 UINT DeviceID,
169 PUINT BusNumber,
170 PUINT SlotNumber);
171
172 VOID
173 NdisStartDevices();
174
175 VOID
176 NTAPI
177 MiniportWorker(
178 IN PDEVICE_OBJECT DeviceObject,
179 IN PVOID WorkItem);
180
181 VOID NTAPI
182 MiniSendComplete(
183 IN NDIS_HANDLE MiniportAdapterHandle,
184 IN PNDIS_PACKET Packet,
185 IN NDIS_STATUS Status);
186
187 BOOLEAN
188 MiniIsBusy(
189 PLOGICAL_ADAPTER Adapter,
190 NDIS_WORK_ITEM_TYPE Type);
191
192 NDIS_STATUS
193 MiniReset(
194 PLOGICAL_ADAPTER Adapter);
195
196 VOID
197 MiniDoAddressingReset(
198 PLOGICAL_ADAPTER Adapter);
199
200 #endif /* __MINIPORT_H */
201
202 /* EOF */
203