- Get NDIS to compile on msvc/ddk (thanks to filip for his help)
[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 /* Information about a logical adapter */
75 typedef struct _LOGICAL_ADAPTER
76 {
77 NDIS_MINIPORT_BLOCK NdisMiniportBlock; /* NDIS defined fields */
78 BOOLEAN MiniportBusy; /* A MiniportXxx routine is executing */
79 PNDIS_MINIPORT_WORK_ITEM WorkQueueHead; /* Head of work queue */
80 PNDIS_MINIPORT_WORK_ITEM WorkQueueTail; /* Tail of work queue */
81 LIST_ENTRY ListEntry; /* Entry on global list */
82 LIST_ENTRY MiniportListEntry; /* Entry on miniport driver list */
83 LIST_ENTRY ProtocolListHead; /* List of bound protocols */
84 ULONG MediumHeaderSize; /* Size of medium header */
85 HARDWARE_ADDRESS Address; /* Hardware address of adapter */
86 ULONG AddressLength; /* Length of hardware address */
87 PUCHAR LookaheadBuffer; /* Pointer to lookahead buffer */
88 ULONG LookaheadLength; /* Length of lookahead buffer */
89 PMINIPORT_BUGCHECK_CONTEXT BugcheckContext; /* Adapter's shutdown handler */
90 } LOGICAL_ADAPTER, *PLOGICAL_ADAPTER;
91
92 #define GET_LOGICAL_ADAPTER(Handle)((PLOGICAL_ADAPTER)Handle)
93
94 extern LIST_ENTRY MiniportListHead;
95 extern KSPIN_LOCK MiniportListLock;
96 extern LIST_ENTRY AdapterListHead;
97 extern KSPIN_LOCK AdapterListLock;
98
99
100 #ifdef DBG
101 VOID
102 MiniDisplayPacket(
103 PNDIS_PACKET Packet);
104 #endif /* DBG */
105
106 VOID
107 MiniIndicateData(
108 PLOGICAL_ADAPTER Adapter,
109 NDIS_HANDLE MacReceiveContext,
110 PVOID HeaderBuffer,
111 UINT HeaderBufferSize,
112 PVOID LookaheadBuffer,
113 UINT LookaheadBufferSize,
114 UINT PacketSize);
115
116 BOOLEAN
117 MiniAdapterHasAddress(
118 PLOGICAL_ADAPTER Adapter,
119 PNDIS_PACKET Packet);
120
121 PLOGICAL_ADAPTER
122 MiniLocateDevice(
123 PNDIS_STRING AdapterName);
124
125 NDIS_STATUS
126 MiniQueryInformation(
127 PLOGICAL_ADAPTER Adapter,
128 NDIS_OID Oid,
129 ULONG Size,
130 PVOID Buffer,
131 PULONG BytesWritten);
132
133 NDIS_STATUS
134 FASTCALL
135 MiniQueueWorkItem(
136 PLOGICAL_ADAPTER Adapter,
137 NDIS_WORK_ITEM_TYPE WorkItemType,
138 PVOID WorkItemContext);
139
140 NDIS_STATUS
141 FASTCALL
142 MiniDequeueWorkItem(
143 PLOGICAL_ADAPTER Adapter,
144 NDIS_WORK_ITEM_TYPE *WorkItemType,
145 PVOID *WorkItemContext);
146
147 NDIS_STATUS
148 MiniDoRequest(
149 PNDIS_MINIPORT_BLOCK Adapter,
150 PNDIS_REQUEST NdisRequest);
151
152 BOOLEAN
153 NdisFindDevice(
154 UINT VendorID,
155 UINT DeviceID,
156 PUINT BusNumber,
157 PUINT SlotNumber);
158
159 VOID
160 NdisStartDevices();
161
162 #endif /* __MINIPORT_H */
163
164 /* EOF */
165