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