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