From 1c931bf1180bac40c40b9e3a496b06588e45d3b9 Mon Sep 17 00:00:00 2001 From: Chris Sutcliffe Date: Sat, 30 Aug 2008 23:08:11 +0000 Subject: [PATCH] 2008-08-29 Andy Grover * include/ddk/ndis.h (NDIS_MINIPORT_MAJOR_VERSION, NDIS_MINIPORT_MINOR_VERSION, struct NDIS_TASK_OFFLOAD_HEADER, PROTOCOL_RESERVED_SIZE_IN_PACKET, NdisGetFirstBufferFromPacketSafe, NdisMIndicateReceivePacket, NdisSetPacketPoolProtocolId, NdisMInitializeTimer, NdisMSetPeriodicTimer, NdisMCancelTimer): Define. (enum NDIS_ENCAPSULATION, struct NDIS_ENCAPSULATION_FORMAT): move in file. (struct _NDIS_PACKET): Define using _ANONYMOUS_UNION and ANONYMOUS_STRUCT to eliminate warnings. (NdisReinitializePacket): Rename from NdisReinitializePacketCounts. * lib/ddk/ndis.def (NdisInitAnsiString, NdisInitUnicodeString, NdisMCancelTimer, NdisMInitializeTimer, NdisMSetPeriodicTimer, NdisSetPacketPoolProtocolId): Export. --- winsup/w32api/ChangeLog | 15 ++++ winsup/w32api/include/ddk/ndis.h | 132 ++++++++++++++++++++++++++----- winsup/w32api/lib/ddk/ndis.def | 12 +-- 3 files changed, 132 insertions(+), 27 deletions(-) diff --git a/winsup/w32api/ChangeLog b/winsup/w32api/ChangeLog index 8bab93f55..15f513608 100644 --- a/winsup/w32api/ChangeLog +++ b/winsup/w32api/ChangeLog @@ -1,3 +1,18 @@ +2008-08-29 Andy Grover + + * include/ddk/ndis.h (NDIS_MINIPORT_MAJOR_VERSION, NDIS_MINIPORT_MINOR_VERSION, + struct NDIS_TASK_OFFLOAD_HEADER, PROTOCOL_RESERVED_SIZE_IN_PACKET, + NdisGetFirstBufferFromPacketSafe, NdisMIndicateReceivePacket, + NdisSetPacketPoolProtocolId, NdisMInitializeTimer, NdisMSetPeriodicTimer, + NdisMCancelTimer): Define. + (enum NDIS_ENCAPSULATION, struct NDIS_ENCAPSULATION_FORMAT): move in file. + (struct _NDIS_PACKET): Define using _ANONYMOUS_UNION and ANONYMOUS_STRUCT to + eliminate warnings. + (NdisReinitializePacket): Rename from NdisReinitializePacketCounts. + * lib/ddk/ndis.def (NdisInitAnsiString, NdisInitUnicodeString, NdisMCancelTimer, + NdisMInitializeTimer, NdisMSetPeriodicTimer, NdisSetPacketPoolProtocolId): + Export. + 2008-08-29 Andy Grover * include/ddk/winddk.h (RtlStringCbCopyA, RtlStringCbPrintfA, diff --git a/winsup/w32api/include/ddk/ndis.h b/winsup/w32api/include/ddk/ndis.h index ce573ac3c..2e61beaa1 100644 --- a/winsup/w32api/include/ddk/ndis.h +++ b/winsup/w32api/include/ddk/ndis.h @@ -52,12 +52,16 @@ extern "C" { #if defined(NDIS50_MINIPORT) #ifndef NDIS50 #define NDIS50 +#define NDIS_MINIPORT_MAJOR_VERSION 5 +#define NDIS_MINIPORT_MINOR_VERSION 0 #endif #endif /* NDIS50_MINIPORT */ #if defined(NDIS51_MINIPORT) #ifndef NDIS51 #define NDIS51 +#define NDIS_MINIPORT_MAJOR_VERSION 5 +#define NDIS_MINIPORT_MINOR_VERSION 1 #endif #endif /* NDIS51_MINIPORT */ @@ -399,19 +403,19 @@ typedef struct _NDIS_PACKET_PRIVATE { typedef struct _NDIS_PACKET { NDIS_PACKET_PRIVATE Private; - union { - struct { + _ANONYMOUS_UNION union { + _ANONYMOUS_STRUCT struct { UCHAR MiniportReserved[2 * sizeof(PVOID)]; UCHAR WrapperReserved[2 * sizeof(PVOID)]; - } s1; - struct { + } DUMMYSTRUCTNAME; + _ANONYMOUS_STRUCT struct { UCHAR MiniportReservedEx[3 * sizeof(PVOID)]; UCHAR WrapperReservedEx[sizeof(PVOID)]; - } s2; - struct { + } DUMMYSTRUCTNAME; + _ANONYMOUS_STRUCT struct { UCHAR MacReserved[4 * sizeof(PVOID)]; - } s3; - } u; + } DUMMYSTRUCTNAME; + } DUMMYUNIONNAME; ULONG_PTR Reserved[2]; UCHAR ProtocolReserved[1]; } NDIS_PACKET, *PNDIS_PACKET, **PPNDIS_PACKET; @@ -915,18 +919,6 @@ typedef struct _NDIS_TASK_IPSEC { } V4ESP; } NDIS_TASK_IPSEC, *PNDIS_TASK_IPSEC; -typedef struct _NDIS_TASK_OFFLOAD { - ULONG Version; - ULONG Size; - NDIS_TASK Task; - ULONG OffsetNextTask; - ULONG TaskBufferLength; - UCHAR TaskBuffer[1]; -} NDIS_TASK_OFFLOAD, *PNDIS_TASK_OFFLOAD; - -/* NDIS_TASK_OFFLOAD_HEADER.Version constants */ -#define NDIS_TASK_OFFLOAD_VERSION 1 - typedef enum _NDIS_ENCAPSULATION { UNSPECIFIED_Encapsulation, NULL_Encapsulation, @@ -945,6 +937,27 @@ typedef struct _NDIS_ENCAPSULATION_FORMAT { ULONG EncapsulationHeaderSize; } NDIS_ENCAPSULATION_FORMAT, *PNDIS_ENCAPSULATION_FORMAT; +typedef struct _NDIS_TASK_OFFLOAD_HEADER +{ + ULONG Version; + ULONG Size; + ULONG Reserved; + UCHAR OffsetFirstTask; + NDIS_ENCAPSULATION_FORMAT EncapsulationFormat; +} NDIS_TASK_OFFLOAD_HEADER, *PNDIS_TASK_OFFLOAD_HEADER; + +typedef struct _NDIS_TASK_OFFLOAD { + ULONG Version; + ULONG Size; + NDIS_TASK Task; + ULONG OffsetNextTask; + ULONG TaskBufferLength; + UCHAR TaskBuffer[1]; +} NDIS_TASK_OFFLOAD, *PNDIS_TASK_OFFLOAD; + +/* NDIS_TASK_OFFLOAD_HEADER.Version constants */ +#define NDIS_TASK_OFFLOAD_VERSION 1 + typedef struct _NDIS_TASK_TCP_IP_CHECKSUM { struct { ULONG IpOptionsSupported:1; @@ -1543,6 +1556,8 @@ NdisAllocatePacketPool( /*IN*/ UINT NumberOfDescriptors, /*IN*/ UINT ProtocolReservedLength); +#define PROTOCOL_RESERVED_SIZE_IN_PACKET (4 * sizeof(PVOID)) + NDISAPI VOID DDKAPI @@ -1754,6 +1769,46 @@ NdisFreeBuffer( } \ } +/* + * VOID + * NdisGetFirstBufferFromPacketSafe( + * IN PNDIS_PACKET _Packet, + * OUT PNDIS_BUFFER * _FirstBuffer, + * OUT PVOID * _FirstBufferVA, + * OUT PUINT _FirstBufferLength, + * OUT PUINT _TotalBufferLength), + * IN MM_PAGE_PRIORITY _Priority) + */ +#define NdisGetFirstBufferFromPacketSafe(_Packet, \ + _FirstBuffer, \ + _FirstBufferVA, \ + _FirstBufferLength, \ + _TotalBufferLength, \ + _Priority) \ +{ \ + PNDIS_BUFFER _Buffer; \ + \ + _Buffer = (_Packet)->Private.Head; \ + *(_FirstBuffer) = _Buffer; \ + if (_Buffer != NULL) \ + { \ + *(_FirstBufferVA) = MmGetSystemAddressForMdlSafe(_Buffer, _Priority); \ + *(_FirstBufferLength) = MmGetMdlByteCount(_Buffer); \ + _Buffer = _Buffer->Next; \ + *(_TotalBufferLength) = *(_FirstBufferLength); \ + while (_Buffer != NULL) { \ + *(_TotalBufferLength) += MmGetMdlByteCount(_Buffer); \ + _Buffer = _Buffer->Next; \ + } \ + } \ + else \ + { \ + *(_FirstBufferVA) = 0; \ + *(_FirstBufferLength) = 0; \ + *(_TotalBufferLength) = 0; \ + } \ +} + /* * VOID * NdisQueryBuffer( @@ -2092,7 +2147,7 @@ NdisFreeBuffer( * NdisReinitializePacket( * IN OUT PNDIS_PACKET Packet); */ -#define NdisReinitializePacketCounts(Packet) \ +#define NdisReinitializePacket(Packet) \ { \ (Packet)->Private.Head = (PNDIS_BUFFER)NULL; \ (Packet)->Private.ValidCounts = FALSE; \ @@ -2967,6 +3022,11 @@ NdisMWanIndicateReceive( /*IN*/ PUCHAR PacketBuffer, /*IN*/ UINT PacketSize); +#define NdisMIndicateReceivePacket(_handle, _packets, _number) \ +{ \ + (*((PNDIS_MINIPORT_BLOCK)(_handle))->PacketIndicateHandler)(_handle, _packets, _number); \ +} + NDISAPI VOID DDKAPI @@ -3156,6 +3216,13 @@ DDKAPI NdisPacketPoolUsage( /*IN*/ NDIS_HANDLE PoolHandle); +NTOSAPI +VOID +DDKAPI +NdisSetPacketPoolProtocolId( + /*IN*/ NDIS_HANDLE PacketPoolHandle, + /*IN*/ UINT ProtocolId); + NDISAPI NDIS_STATUS DDKAPI @@ -4517,6 +4584,29 @@ struct _NDIS_OPEN_BLOCK /* Routines for NDIS miniport drivers */ +NTOSAPI +VOID +DDKAPI +NdisMInitializeTimer( + /*IN*/ /*OUT*/ PNDIS_MINIPORT_TIMER Timer, + /*IN*/ NDIS_HANDLE MiniportAdapterHandle, + /*IN*/ PNDIS_TIMER_FUNCTION TimerFunction, + /*IN*/ PVOID FunctionContext); + +NTOSAPI +VOID +DDKAPI +NdisMSetPeriodicTimer( + /*IN*/ PNDIS_MINIPORT_TIMER Timer, + /*IN*/ UINT MillisecondsPeriod); + +NTOSAPI +VOID +DDKAPI +NdisMCancelTimer( + /*IN*/ PNDIS_MINIPORT_TIMER Timer, + /*OUT*/ PBOOLEAN TimerCancelled); + NDISAPI VOID DDKAPI diff --git a/winsup/w32api/lib/ddk/ndis.def b/winsup/w32api/lib/ddk/ndis.def index 100ee492a..965575875 100644 --- a/winsup/w32api/lib/ddk/ndis.def +++ b/winsup/w32api/lib/ddk/ndis.def @@ -130,8 +130,8 @@ NdisImmediateReadSharedMemory@16 ;NdisImmediateWritePortUlong ;NdisImmediateWritePortUshort NdisImmediateWriteSharedMemory@16 -;NdisInitAnsiString DATA -;NdisInitUnicodeString DATA +NdisInitAnsiString@8 +NdisInitUnicodeString@8 ;NdisInitializeEvent NdisInitializeReadWriteLock@4 ;NdisInitializeString @@ -149,7 +149,7 @@ NdisInitializeWrapper@16 NdisMAllocateMapRegisters@20 NdisMAllocateSharedMemory@20 NdisMAllocateSharedMemoryAsync@16 -;NdisMCancelTimer +NdisMCancelTimer@8 NdisMCloseLog@4 NdisMCmActivateVc@8 NdisMCmCreateVc@16 @@ -179,7 +179,7 @@ NdisMGetDeviceProperty@24 ;NdisMIndicateStatus ;NdisMIndicateStatusComplete NdisMInitializeScatterGatherDma@12 -;NdisMInitializeTimer +NdisMInitializeTimer@16 NdisMMapIoSpace@20 ;NdisMPciAssignResources NdisMPromoteMiniport@4 @@ -202,7 +202,7 @@ NdisMRemoveMiniport@4 NdisMSetAttributesEx@20 ;NdisMSetInformationComplete NdisMSetMiniportSecondary@8 -;NdisMSetPeriodicTimer +NdisMSetPeriodicTimer@8 ;NdisMSetTimer NdisMSleep@4 ;NdisMStartBufferPhysicalMapping @@ -252,7 +252,7 @@ NdisSend@12 NdisSendPackets@12 ;NdisSetEvent ;NdisSetPacketCancelId -;NdisSetPacketPoolProtocolId +NdisSetPacketPoolProtocolId@8 ;NdisSetPacketStatus ;NdisSetProtocolFilter ;NdisSetTimer