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