- Get NDIS (almost) compiling with msvc/ddk.
[reactos.git] / reactos / drivers / net / 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 } NDIS_M_DRIVER_BLOCK, *PNDIS_M_DRIVER_BLOCK;
32
33 /* resources allocated on behalf on the miniport */
34 #define MINIPORT_RESOURCE_TYPE_MEMORY 0
35 typedef struct _MINIPORT_RESOURCE {
36 LIST_ENTRY ListEntry;
37 ULONG ResourceType;
38 PVOID Resource;
39 } MINIPORT_RESOURCE, *PMINIPORT_RESOURCE;
40
41 /* Configuration context */
42 typedef struct _MINIPORT_CONFIGURATION_CONTEXT {
43 NDIS_HANDLE Handle;
44 LIST_ENTRY ResourceListHead;
45 KSPIN_LOCK ResourceLock;
46 } MINIPORT_CONFIGURATION_CONTEXT, *PMINIPORT_CONFIGURATION_CONTEXT;
47
48 /* Bugcheck callback context */
49 typedef struct _MINIPORT_BUGCHECK_CONTEXT {
50 PVOID DriverContext;
51 ADAPTER_SHUTDOWN_HANDLER ShutdownHandler;
52 PKBUGCHECK_CALLBACK_RECORD CallbackRecord;
53 } MINIPORT_BUGCHECK_CONTEXT, *PMINIPORT_BUGCHECK_CONTEXT;
54
55 /* a miniport's shared memory */
56 typedef struct _MINIPORT_SHARED_MEMORY {
57 PDMA_ADAPTER AdapterObject;
58 ULONG Length;
59 PHYSICAL_ADDRESS PhysicalAddress;
60 PVOID VirtualAddress;
61 BOOLEAN Cached;
62 } MINIPORT_SHARED_MEMORY, *PMINIPORT_SHARED_MEMORY;
63
64 /* A structure of WrapperConfigurationContext (not compatible with the
65 Windows one). */
66 typedef struct _NDIS_WRAPPER_CONTEXT {
67 HANDLE RegistryHandle;
68 PDEVICE_OBJECT DeviceObject;
69 ULONG BusNumber;
70 } NDIS_WRAPPER_CONTEXT, *PNDIS_WRAPPER_CONTEXT;
71
72 #define GET_MINIPORT_DRIVER(Handle)((PNDIS_M_DRIVER_BLOCK)Handle)
73
74 #ifndef NUMBER_OF_WORK_ITEM_TYPES
75
76 typedef enum _NDIS_WORK_ITEM_TYPE {
77 NdisWorkItemRequest,
78 NdisWorkItemSend,
79 NdisWorkItemReturnPackets,
80 NdisWorkItemResetRequested,
81 NdisWorkItemResetInProgress,
82 NdisWorkItemHalt,
83 NdisWorkItemSendLoopback,
84 NdisWorkItemMiniportCallback,
85 NdisMaxWorkItems
86 } NDIS_WORK_ITEM_TYPE, *PNDIS_WORK_ITEM_TYPE;
87
88 #define NUMBER_OF_WORK_ITEM_TYPES NdisMaxWorkItems
89 #define NUMBER_OF_SINGLE_WORK_ITEMS 6
90
91 typedef struct _NDIS_MINIPORT_WORK_ITEM {
92 SINGLE_LIST_ENTRY Link;
93 NDIS_WORK_ITEM_TYPE WorkItemType;
94 PVOID WorkItemContext;
95 } NDIS_MINIPORT_WORK_ITEM, *PNDIS_MINIPORT_WORK_ITEM;
96
97 typedef struct _X_FILTER FDDI_FILTER, *PFDDI_FILTER;
98
99 typedef VOID (NTAPI *W_MINIPORT_CALLBACK)(
100 IN NDIS_HANDLE MiniportAdapterContext,
101 IN PVOID CallbackContext);
102 #endif
103
104 /* Information about a logical adapter */
105 typedef struct _LOGICAL_ADAPTER
106 {
107 NDIS_MINIPORT_BLOCK NdisMiniportBlock; /* NDIS defined fields */
108 BOOLEAN MiniportBusy; /* A MiniportXxx routine is executing */
109 PNDIS_MINIPORT_WORK_ITEM WorkQueueHead; /* Head of work queue */
110 PNDIS_MINIPORT_WORK_ITEM WorkQueueTail; /* Tail of work queue */
111 LIST_ENTRY ListEntry; /* Entry on global list */
112 LIST_ENTRY MiniportListEntry; /* Entry on miniport driver list */
113 LIST_ENTRY ProtocolListHead; /* List of bound protocols */
114 ULONG MediumHeaderSize; /* Size of medium header */
115 HARDWARE_ADDRESS Address; /* Hardware address of adapter */
116 ULONG AddressLength; /* Length of hardware address */
117 PUCHAR LookaheadBuffer; /* Pointer to lookahead buffer */
118 ULONG LookaheadLength; /* Length of lookahead buffer */
119 PMINIPORT_BUGCHECK_CONTEXT BugcheckContext; /* Adapter's shutdown handler */
120 } LOGICAL_ADAPTER, *PLOGICAL_ADAPTER;
121
122 #define GET_LOGICAL_ADAPTER(Handle)((PLOGICAL_ADAPTER)Handle)
123
124 extern LIST_ENTRY MiniportListHead;
125 extern KSPIN_LOCK MiniportListLock;
126 extern LIST_ENTRY AdapterListHead;
127 extern KSPIN_LOCK AdapterListLock;
128
129
130 #ifdef DBG
131 VOID
132 MiniDisplayPacket(
133 PNDIS_PACKET Packet);
134 #endif /* DBG */
135
136 VOID
137 MiniIndicateData(
138 PLOGICAL_ADAPTER Adapter,
139 NDIS_HANDLE MacReceiveContext,
140 PVOID HeaderBuffer,
141 UINT HeaderBufferSize,
142 PVOID LookaheadBuffer,
143 UINT LookaheadBufferSize,
144 UINT PacketSize);
145
146 BOOLEAN
147 MiniAdapterHasAddress(
148 PLOGICAL_ADAPTER Adapter,
149 PNDIS_PACKET Packet);
150
151 PLOGICAL_ADAPTER
152 MiniLocateDevice(
153 PNDIS_STRING AdapterName);
154
155 NDIS_STATUS
156 MiniQueryInformation(
157 PLOGICAL_ADAPTER Adapter,
158 NDIS_OID Oid,
159 ULONG Size,
160 PVOID Buffer,
161 PULONG BytesWritten);
162
163 NDIS_STATUS
164 FASTCALL
165 MiniQueueWorkItem(
166 PLOGICAL_ADAPTER Adapter,
167 NDIS_WORK_ITEM_TYPE WorkItemType,
168 PVOID WorkItemContext);
169
170 NDIS_STATUS
171 FASTCALL
172 MiniDequeueWorkItem(
173 PLOGICAL_ADAPTER Adapter,
174 NDIS_WORK_ITEM_TYPE *WorkItemType,
175 PVOID *WorkItemContext);
176
177 NDIS_STATUS
178 MiniDoRequest(
179 PNDIS_MINIPORT_BLOCK Adapter,
180 PNDIS_REQUEST NdisRequest);
181
182 BOOLEAN
183 NdisFindDevice(
184 UINT VendorID,
185 UINT DeviceID,
186 PUINT BusNumber,
187 PUINT SlotNumber);
188
189 VOID
190 NdisStartDevices();
191
192 #endif /* __MINIPORT_H */
193
194 /* EOF */
195