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