Merge from ndis_wip_22102004 branch:
authorFilip Navara <filip.navara@gmail.com>
Tue, 23 Nov 2004 18:58:47 +0000 (18:58 +0000)
committerFilip Navara <filip.navara@gmail.com>
Tue, 23 Nov 2004 18:58:47 +0000 (18:58 +0000)
- Compile with W32API headers.
- Remove obsolate and no more exported functions (as of NDIS 5.1).
- Shrink the LOGICAL_ADAPTER structure a bit and use NDIS_MINIPORT_BLOCK fields instead.
- Make the WrapperConfigurationHandle an opaque structure instead of registry key handle.
- Use PnP DMA interface instead of the HAL one (TODO: Add reference counting).
- Move Ethernet filter routines from 40gone.c/miniport.c to separate file (efilter.c).
- Add PnP IRP handler and move device intitialization to IRP_MN_START_DEVICE handler.
- Implement device shutdown in IRP_MN_STOP_DEVICE.
- Minor fix for sending packets with deserialized miniports.
- Read bus type, bus number and slot number from registry if the PnP manager doesn't supply them.
- NdisMFreeMapRegisters shouldn't crash if no map registers were allocated.
- Implement NdisMQueryAdapterResources, NdisMGetDmaAlignment and NdisMReadDmaCounter.
- Implement NdisMPciAssignResources (Eric Kohl).
- Fix Ndis[Read/Write]PciSlotInformation to work for non-primary PCI buses (Eric Kohl).

svn path=/trunk/; revision=11789

19 files changed:
reactos/drivers/net/ndis/Makefile
reactos/drivers/net/ndis/include/efilter.h [new file with mode: 0644]
reactos/drivers/net/ndis/include/miniport.h
reactos/drivers/net/ndis/include/ndissys.h
reactos/drivers/net/ndis/ndis.def
reactos/drivers/net/ndis/ndis/40gone.c
reactos/drivers/net/ndis/ndis/50gone.c
reactos/drivers/net/ndis/ndis/buffer.c
reactos/drivers/net/ndis/ndis/config.c
reactos/drivers/net/ndis/ndis/efilter.c [new file with mode: 0644]
reactos/drivers/net/ndis/ndis/enum.c [deleted file]
reactos/drivers/net/ndis/ndis/hardware.c
reactos/drivers/net/ndis/ndis/io.c
reactos/drivers/net/ndis/ndis/main.c
reactos/drivers/net/ndis/ndis/memory.c
reactos/drivers/net/ndis/ndis/miniport.c
reactos/drivers/net/ndis/ndis/protocol.c
reactos/drivers/net/ndis/ndis/string.c
reactos/drivers/net/ndis/ndis/stubs.c

index ffac8ff..f74f2f6 100644 (file)
@@ -1,4 +1,4 @@
-# $Id: Makefile,v 1.22 2004/10/09 18:17:08 navaraf Exp $
+# $Id: Makefile,v 1.23 2004/11/23 18:58:44 navaraf Exp $
 
 PATH_TO_TOP = ../../..
 
@@ -8,7 +8,9 @@ TARGET_NAME = ndis
 
 TARGET_PCH = include/ndissys.h
 
-TARGET_CFLAGS = -I./include -DNDIS_WRAPPER -Wall -Werror
+TARGET_CFLAGS = -I./include -D__USE_W32API -Wall -Werror
+
+TARGET_CFLAGS += -DNDIS_WRAPPER -DNDIS50 -DNDIS50_MINIPORT -DBINARY_COMPATIBLE
 
 TARGET_OBJECTS = \
   ndis/main.o \
@@ -27,7 +29,8 @@ TARGET_OBJECTS = \
   ndis/protocol.o \
   ndis/string.o \
   ndis/stubs.o \
-  ndis/time.o
+  ndis/time.o \
+  ndis/efilter.o
 
 include $(PATH_TO_TOP)/rules.mak
 
diff --git a/reactos/drivers/net/ndis/include/efilter.h b/reactos/drivers/net/ndis/include/efilter.h
new file mode 100644 (file)
index 0000000..84375b4
--- /dev/null
@@ -0,0 +1,38 @@
+/*
+ * COPYRIGHT:   See COPYING in the top level directory
+ * PROJECT:     ReactOS NDIS library
+ * FILE:        ndis/miniport.h
+ * PURPOSE:     Definitions for Ethernet filter
+ */
+
+#ifndef __EFILTER_H
+#define __EFILTER_H
+
+BOOLEAN
+STDCALL
+EthCreateFilter(
+    IN  UINT                MaximumMulticastAddresses,
+    IN  PUCHAR              AdapterAddress,
+    OUT PETH_FILTER         * Filter);
+
+VOID
+STDCALL
+EthFilterDprIndicateReceive(
+    IN PETH_FILTER Filter,
+    IN NDIS_HANDLE MacReceiveContext,
+    IN PCHAR       Address,
+    IN PVOID       HeaderBuffer,
+    IN UINT        HeaderBufferSize,
+    IN PVOID       LookaheadBuffer,
+    IN UINT        LookaheadBufferSize,
+    IN UINT        PacketSize);
+
+VOID
+STDCALL
+EthFilterDprIndicateReceiveComplete(
+    IN  PETH_FILTER Filter);
+
+#endif /* __EFILTER_H */
+
+/* EOF */
+
index 8f3e44a..4eeb02c 100644 (file)
 
 #include <ndissys.h>
 
-/* WrapperConfigurationContext is a pointer to this structure */
-typedef struct _WRAPPER_CONTEXT {
-  PDEVICE_OBJECT DeviceObject;
-  ULONG BusNumber;
-  HANDLE DeviceKeyHandle;
-} WRAPPER_CONTEXT, *PWRAPPER_CONTEXT;
 
 typedef struct _HARDWARE_ADDRESS {
     union {
@@ -59,23 +53,22 @@ typedef struct _MINIPORT_BUGCHECK_CONTEXT {
 
 /* a miniport's shared memory */
 typedef struct _MINIPORT_SHARED_MEMORY {
-    PADAPTER_OBJECT   AdapterObject;
+    PDMA_ADAPTER      AdapterObject;
     ULONG             Length;
     PHYSICAL_ADDRESS  PhysicalAddress;
     PVOID             VirtualAddress;
     BOOLEAN           Cached;
 } MINIPORT_SHARED_MEMORY, *PMINIPORT_SHARED_MEMORY;
 
-#define GET_MINIPORT_DRIVER(Handle)((PMINIPORT_DRIVER)Handle)
-
-/* detected adapters that are driverless */
-typedef struct _ORPHAN_ADATER {
-    LIST_ENTRY        ListEntry;
-    NDIS_STRING       RegistryPath;
-    INTERFACE_TYPE    BusType;
+/* A structure of WrapperConfigurationContext (not compatible with the
+   Windows one). */
+typedef struct _NDIS_WRAPPER_CONTEXT {
+    HANDLE            RegistryHandle;
+    PDEVICE_OBJECT    DeviceObject;
     ULONG             BusNumber;
-    ULONG             SlotNumber;
-} ORPHAN_ADAPTER, *PORPHAN_ADAPTER;
+} NDIS_WRAPPER_CONTEXT, *PNDIS_WRAPPER_CONTEXT;
+
+#define GET_MINIPORT_DRIVER(Handle)((PMINIPORT_DRIVER)Handle)
 
 /* Information about a logical adapter */
 typedef struct _LOGICAL_ADAPTER 
@@ -83,7 +76,6 @@ typedef struct _LOGICAL_ADAPTER
     NDIS_MINIPORT_BLOCK         NdisMiniportBlock;      /* NDIS defined fields */
     KDPC                        MiniportDpc;            /* DPC routine for adapter */
     BOOLEAN                     MiniportBusy;           /* A MiniportXxx routine is executing */
-    NDIS_HANDLE                 MiniportAdapterBinding; /* Binding handle for current caller */
     ULONG                       WorkQueueLevel;         /* Number of used work item buffers */
     NDIS_MINIPORT_WORK_ITEM     WorkQueue[NDIS_MINIPORT_WORK_QUEUE_SIZE];
     PNDIS_MINIPORT_WORK_ITEM    WorkQueueHead;          /* Head of work queue */
@@ -93,7 +85,6 @@ typedef struct _LOGICAL_ADAPTER
     LIST_ENTRY                  ProtocolListHead;       /* List of bound protocols */
     ULONG                       RefCount;               /* Reference count */
     PMINIPORT_DRIVER            Miniport;               /* Miniport owning this adapter */
-    UNICODE_STRING              DeviceName;             /* Device name of this adapter */
     ULONG                       Attributes;             /* Attributes of adapter */
     BOOLEAN                     AttributesSet;          /* Whether NdisMSetAttributes(Ex) has been called */
     PVOID                       QueryBuffer;            /* Buffer to use for queries */
@@ -103,25 +94,12 @@ typedef struct _LOGICAL_ADAPTER
     ULONG                       AddressLength;          /* Length of hardware address */
     PUCHAR                      LookaheadBuffer;        /* Pointer to lookahead buffer */
     ULONG                       LookaheadLength;        /* Length of lookahead buffer */
-    ULONG                       CurLookaheadLength;     /* Current (selected) length of lookahead buffer */
-    ULONG                       MaxLookaheadLength;     /* Maximum length of lookahead buffer */
     PNDIS_PACKET                PacketQueueHead;        /* Head of packet queue */
     PNDIS_PACKET                PacketQueueTail;        /* Head of packet queue */
     PNDIS_PACKET                LoopPacket;             /* Current packet beeing looped */
     PMINIPORT_BUGCHECK_CONTEXT  BugcheckContext;        /* Adapter's shutdown handler */
     KEVENT                      DmaEvent;               /* Event to support DMA register allocation */
     KSPIN_LOCK                  DmaLock;                /* Spinlock to protect the dma list */
-    UINT                        BusNumber;              /* The bus number of the adapter  */
-    INTERFACE_TYPE              BusType;                /* The bus type of the adapter */
-    UINT                        SlotNumber;             /* The slot number of the adapter*/
-    ULONG                       Irql;                   /* The Irql assigned to the adapter */
-    ULONG                       Vector;                 /* The interrupt vector assigned to the adapter */
-    KAFFINITY                   Affinity;               /* The processor affinity of the adapter */
-    PHYSICAL_ADDRESS            BaseIoAddress;          /* The base IO address of the adapter */
-    PHYSICAL_ADDRESS            BaseMemoryAddress;      /* The base memory address of mapped memory for the adapter */
-    ULONG                       DmaChannel;             /* The DMA channel number of the adapter */
-    ULONG                       DmaPort;                /* The DMA port number of the adapter */
-    PNDIS_MINIPORT_TIMER        Timer;                  /* The timer  object of the adapter */
 } LOGICAL_ADAPTER, *PLOGICAL_ADAPTER;
 
 #define GET_LOGICAL_ADAPTER(Handle)((PLOGICAL_ADAPTER)Handle)
@@ -169,16 +147,14 @@ FASTCALL
 MiniQueueWorkItem(
     PLOGICAL_ADAPTER    Adapter,
     NDIS_WORK_ITEM_TYPE WorkItemType,
-    PVOID               WorkItemContext,
-    NDIS_HANDLE         Initiator);
+    PVOID               WorkItemContext);
 
 NDIS_STATUS
 FASTCALL
 MiniDequeueWorkItem(
     PLOGICAL_ADAPTER    Adapter,
     NDIS_WORK_ITEM_TYPE *WorkItemType,
-    PVOID               *WorkItemContext,
-    NDIS_HANDLE         *Initiator);
+    PVOID               *WorkItemContext);
 
 NDIS_STATUS
 MiniDoRequest(
index dbc3986..548e1fc 100644 (file)
 #include <ndis.h>
 #else /* _MSC_VER */
 #include <ddk/ntddk.h>
+#include <ddk/ndis.h>
 #include <ddk/xfilter.h>
-#include <net/ndis.h>
+#include <ddk/afilter.h>
+typedef struct _ATM_ADDRESS *PATM_ADDRESS;
+/* FIXME: Get rid of this dependance. */
+#include <ddk/ntapi.h>
 #endif /* _MSC_VER */
 
 #include "miniport.h"
index b04806b..89c80c5 100644 (file)
@@ -5,38 +5,10 @@ LIBRARY NDIS.SYS
 EXPORTS
 ArcFilterDprIndicateReceive@16
 ArcFilterDprIndicateReceiveComplete@4
-EthChangeFilterAddresses@24
-EthCreateFilter@28
-EthDeleteFilter@4
-EthDeleteFilterOpenAdapter@12
-EthFilterAdjust@20
 EthFilterDprIndicateReceive@32
 EthFilterDprIndicateReceiveComplete@4
-EthFilterIndicateReceive@32
-EthFilterIndicateReceiveComplete@4
-EthNoteFilterOpenAdapter@16
-EthNumberOfOpenFilterAddresses@8
-EthQueryGlobalFilterAddresses@20
-EthQueryOpenFilterAddresses@24
-EthShouldAddressLoopBack@8
-FddiChangeFilterLongAddresses@24
-FddiChangeFilterShortAddresses@24
-FddiCreateFilter@36
-FddiDeleteFilter@4
-FddiDeleteFilterOpenAdapter@12
-FddiFilterAdjust@20
-;FddiFilterDprIndicateReceive@36 ?
-;FddiFilterDprIndicateReceiveComplete@4 ?
-FddiFilterIndicateReceive@36
-FddiFilterIndicateReceiveComplete@4
-FddiNoteFilterOpenAdapter@16
-FddiNumberOfOpenFilterLongAddresses@8
-FddiNumberOfOpenFilterShortAddresses@8
-FddiQueryGlobalFilterLongAddresses@20
-FddiQueryGlobalFilterShortAddresses@20
-FddiQueryOpenFilterLongAddresses@24
-FddiQueryOpenFilterShortAddresses@24
-FddiShouldAddressLoopBack@12
+FddiFilterDprIndicateReceive@36
+FddiFilterDprIndicateReceiveComplete@4
 NDIS_BUFFER_TO_SPAN_PAGES@4
 NdisAcquireReadWriteLock@12
 NdisAcquireSpinLock@4
@@ -171,7 +143,6 @@ NdisInterlockedInsertTailList@12
 NdisInterlockedPopEntrySList@8
 NdisInterlockedPushEntrySList@12
 NdisInterlockedRemoveHeadList@8
-NdisInitializeListHead@4
 NdisMAllocateMapRegisters@20
 NdisMAllocateSharedMemory@20
 NdisMAllocateSharedMemoryAsync@16
@@ -204,12 +175,12 @@ NdisMFlushLog@4
 NdisMFreeMapRegisters@4
 NdisMFreeSharedMemory@24
 NdisMGetDeviceProperty@24
+NdisMGetDmaAlignment@4
 NdisMIndicateStatus@16
 NdisMIndicateStatusComplete@4
 NdisMInitializeScatterGatherDma@12
 NdisMInitializeTimer@16
 NdisMMapIoSpace@20
-NdisMoveMappedMemory@12
 NdisMPciAssignResources@12
 NdisMPromoteMiniport@4
 NdisMQueryAdapterInstanceName@8
@@ -301,17 +272,7 @@ NdisWriteErrorLogEntry
 NdisWriteEventLogEntry@28
 NdisWritePciSlotInformation@20
 NdisWritePcmciaAttributeMemory@16
-TrChangeFunctionalAddress@20
-TrChangeGroupAddress@20
-TrCreateFilter@28
-TrDeleteFilter@4
-TrDeleteFilterOpenAdapter@12
-TrFilterAdjust@20
-;TrFilterDprIndicateReceive@28
-;TrFilterDprIndicateReceiveComplete@4
-TrFilterIndicateReceive@28
-TrFilterIndicateReceiveComplete@4
-TrNoteFilterOpenAdapter@16
-TrShouldAddressLoopBack@12
+TrFilterDprIndicateReceive@28
+TrFilterDprIndicateReceiveComplete@4
 
 ; EOF
index ecf3a95..ce1c560 100644 (file)
@@ -38,345 +38,12 @@ ArcFilterDprIndicateReceiveComplete(
 }
 
 
-/*
- * @unimplemented
- */
-NDIS_STATUS
-EXPORT
-EthChangeFilterAddresses(
-    IN  PETH_FILTER     Filter,
-    IN  NDIS_HANDLE     NdisFilterHandle,
-    IN  PNDIS_REQUEST   NdisRequest,
-    IN  UINT            AddressCount,
-    IN  CHAR            Addresses [] [ETH_LENGTH_OF_ADDRESS],
-    IN  BOOLEAN         Set)
-{
-    UNIMPLEMENTED
-
-       return NDIS_STATUS_FAILURE;
-}
-
-
-/*
- * @unimplemented
- */
-BOOLEAN
-EXPORT
-EthCreateFilter(
-    IN  UINT                MaximumMulticastAddresses,
-    IN  ETH_ADDRESS_CHANGE  AddressChangeAction,
-    IN  ETH_FILTER_CHANGE   FilterChangeAction,
-    IN  ETH_DEFERRED_CLOSE  CloseAction,
-    IN  PUCHAR              AdapterAddress,
-    IN  PNDIS_SPIN_LOCK     Lock,
-    OUT PETH_FILTER         * Filter)
-{
-    UNIMPLEMENTED
-
-       return FALSE;
-}
-
-
-/*
- * @unimplemented
- */
-VOID
-EXPORT
-EthDeleteFilter(
-    IN  PETH_FILTER Filter)
-{
-    UNIMPLEMENTED
-}
-
-
-/*
- * @unimplemented
- */
-NDIS_STATUS
-EXPORT
-EthDeleteFilterOpenAdapter(
-    IN  PETH_FILTER    Filter,
-    IN  NDIS_HANDLE    NdisFilterHandle,
-    IN  PNDIS_REQUEST  NdisRequest)
-{
-    UNIMPLEMENTED
-
-    return NDIS_STATUS_FAILURE;
-}
-
-
-/*
- * @unimplemented
- */
-NDIS_STATUS
-EXPORT
-EthFilterAdjust(
-    IN  PETH_FILTER     Filter,
-    IN  NDIS_HANDLE     NdisFilterHandle,
-    IN  PNDIS_REQUEST   NdisRequest,
-    IN  UINT            FilterClasses,
-    IN  BOOLEAN         Set)
-{
-    UNIMPLEMENTED
-
-       return NDIS_STATUS_FAILURE;
-}
-
-
-/*
- * @unimplemented
- */
-VOID
-EXPORT
-EthFilterIndicateReceive(
-    IN PETH_FILTER Filter,
-    IN NDIS_HANDLE MacReceiveContext,
-    IN PCHAR       Address,
-    IN PVOID       HeaderBuffer,
-    IN UINT        HeaderBufferSize,
-    IN PVOID       LookaheadBuffer,
-    IN UINT        LookaheadBufferSize,
-    IN UINT        PacketSize)
-{
-    UNIMPLEMENTED
-}
-
-
-/*
- * @unimplemented
- */
-VOID
-EXPORT
-EthFilterIndicateReceiveComplete(
-    IN  PETH_FILTER Filter)
-{
-    UNIMPLEMENTED
-}
-
-
 /*
  * @unimplemented
  */
 VOID
 EXPORT
-EthFilterDprIndicateReceive(
-    IN PETH_FILTER Filter,
-    IN NDIS_HANDLE MacReceiveContext,
-    IN PCHAR       Address,
-    IN PVOID       HeaderBuffer,
-    IN UINT        HeaderBufferSize,
-    IN PVOID       LookaheadBuffer,
-    IN UINT        LookaheadBufferSize,
-    IN UINT        PacketSize)
-{
-    UNIMPLEMENTED
-}
-
-
-/*
- * @unimplemented
- */
-VOID
-EXPORT
-EthFilterDprIndicateReceiveComplete(
-    IN  PETH_FILTER Filter)
-{
-    UNIMPLEMENTED
-}
-
-
-/*
- * @unimplemented
- */
-BOOLEAN
-EXPORT
-EthNoteFilterOpenAdapter(
-    IN  PETH_FILTER     Filter,
-    IN  NDIS_HANDLE     MacBindingHandle,
-    IN  NDIS_HANDLE     NdisBindingContext,
-    OUT PNDIS_HANDLE    NdisFilterHandle)
-{
-    UNIMPLEMENTED
-
-       return FALSE;
-}
-
-
-/*
- * @unimplemented
- */
-UINT
-EXPORT
-EthNumberOfOpenFilterAddresses(
-    IN  PETH_FILTER Filter,
-    IN  NDIS_HANDLE NdisFilterHandle)
-{
-    UNIMPLEMENTED
-
-       return 0;
-}
-
-
-/*
- * @unimplemented
- */
-VOID
-EXPORT
-EthQueryGlobalFilterAddresses (
-    OUT PNDIS_STATUS    Status,
-    IN  PETH_FILTER     Filter,
-    IN  UINT            SizeOfArray,
-    OUT PUINT           NumberOfAddresses,
-    IN  OUT    CHAR        AddressArray [] [ETH_LENGTH_OF_ADDRESS])
-{
-    UNIMPLEMENTED
-}
-
-
-/*
- * @unimplemented
- */
-VOID
-EXPORT
-EthQueryOpenFilterAddresses(
-    OUT            PNDIS_STATUS    Status,
-    IN     PETH_FILTER     Filter,
-    IN     NDIS_HANDLE     NdisFilterHandle,
-    IN     UINT            SizeOfArray,
-    OUT            PUINT           NumberOfAddresses,
-    IN OUT  CHAR            AddressArray [] [ETH_LENGTH_OF_ADDRESS])
-{
-    UNIMPLEMENTED
-}
-
-
-/*
- * @unimplemented
- */
-BOOLEAN
-EXPORT
-EthShouldAddressLoopBack(
-    IN  PETH_FILTER Filter,
-    IN  CHAR        Address [ETH_LENGTH_OF_ADDRESS])
-{
-    UNIMPLEMENTED
-
-       return FALSE;
-}
-
-
-/*
- * @unimplemented
- */
-NDIS_STATUS
-EXPORT
-FddiChangeFilterLongAddresses(
-    IN  PFDDI_FILTER    Filter,
-    IN  NDIS_HANDLE     NdisFilterHandle,
-    IN  PNDIS_REQUEST   NdisRequest,
-    IN  UINT            AddressCount,
-    IN  CHAR            Addresses [] [FDDI_LENGTH_OF_LONG_ADDRESS],
-    IN  BOOLEAN         Set)
-{
-    UNIMPLEMENTED
-
-       return NDIS_STATUS_FAILURE;
-}
-
-
-/*
- * @unimplemented
- */
-NDIS_STATUS
-EXPORT
-FddiChangeFilterShortAddresses(
-    IN  PFDDI_FILTER    Filter,
-    IN  NDIS_HANDLE     NdisFilterHandle,
-    IN  PNDIS_REQUEST   NdisRequest,
-    IN  UINT            AddressCount,
-    IN  CHAR            Addresses [] [FDDI_LENGTH_OF_SHORT_ADDRESS],
-    IN  BOOLEAN         Set)
-{
-    UNIMPLEMENTED
-
-       return NDIS_STATUS_FAILURE;
-}
-
-
-/*
- * @unimplemented
- */
-BOOLEAN
-EXPORT
-FddiCreateFilter(
-    IN  UINT                MaximumMulticastLongAddresses,
-    IN  UINT                MaximumMulticastShortAddresses,
-    IN  FDDI_ADDRESS_CHANGE AddressChangeAction,
-    IN  FDDI_FILTER_CHANGE  FilterChangeAction,
-    IN  FDDI_DEFERRED_CLOSE CloseAction,
-    IN  PUCHAR              AdapterLongAddress,
-    IN  PUCHAR              AdapterShortAddress,
-    IN  PNDIS_SPIN_LOCK     Lock,
-    OUT PFDDI_FILTER        * Filter)
-{
-    UNIMPLEMENTED
-
-       return FALSE;
-}
-
-
-/*
- * @unimplemented
- */
-VOID
-EXPORT
-FddiDeleteFilter(
-    IN  PFDDI_FILTER    Filter)
-{
-    UNIMPLEMENTED
-}
-
-
-/*
- * @unimplemented
- */
-NDIS_STATUS
-EXPORT
-FddiDeleteFilterOpenAdapter(
-    IN  PFDDI_FILTER    Filter,
-    IN  NDIS_HANDLE     NdisFilterHandle,
-    IN  PNDIS_REQUEST   NdisRequest)
-{
-    UNIMPLEMENTED
-
-       return NDIS_STATUS_SUCCESS;
-}
-
-
-/*
- * @unimplemented
- */
-NDIS_STATUS
-EXPORT
-FddiFilterAdjust(
-    IN  PFDDI_FILTER    Filter,
-    IN  NDIS_HANDLE     NdisFilterHandle,
-    IN  PNDIS_REQUEST   NdisRequest,
-    IN  UINT            FilterClasses,
-    IN  BOOLEAN         Set)
-{
-    UNIMPLEMENTED
-
-       return NDIS_STATUS_FAILURE;
-}
-
-
-/*
- * @unimplemented
- */
-VOID
-EXPORT
-FddiFilterIndicateReceive(
+FddiFilterDprIndicateReceive(
     IN  PFDDI_FILTER    Filter,
     IN  NDIS_HANDLE     MacReceiveContext,
     IN  PCHAR           Address,
@@ -396,142 +63,13 @@ FddiFilterIndicateReceive(
  */
 VOID
 EXPORT
-FddiFilterIndicateReceiveComplete(
+FddiFilterDprIndicateReceiveComplete(
     IN  PFDDI_FILTER    Filter)
 {
     UNIMPLEMENTED
 }
 
 
-/*
- * @unimplemented
- */
-BOOLEAN
-EXPORT
-FddiNoteFilterOpenAdapter(
-    IN  PFDDI_FILTER    Filter,
-    IN  NDIS_HANDLE     MacBindingHandle,
-    IN  NDIS_HANDLE     NdisBindingContext,
-    OUT PNDIS_HANDLE    NdisFilterHandle)
-{
-    UNIMPLEMENTED
-
-       return FALSE;
-}
-
-
-/*
- * @unimplemented
- */
-UINT
-EXPORT
-FddiNumberOfOpenFilterLongAddresses(
-    IN  PFDDI_FILTER    Filter,
-    IN  NDIS_HANDLE     NdisFilterHandle)
-{
-    UNIMPLEMENTED
-
-       return 0;
-}
-
-
-/*
- * @unimplemented
- */
-UINT
-EXPORT
-FddiNumberOfOpenFilterShortAddresses(
-    IN  PFDDI_FILTER    Filter,
-    IN  NDIS_HANDLE     NdisFilterHandle)
-{
-    UNIMPLEMENTED
-
-       return 0;
-}
-
-
-/*
- * @unimplemented
- */
-VOID
-EXPORT
-FddiQueryGlobalFilterLongAddresses(
-    OUT     PNDIS_STATUS    Status,
-    IN      PFDDI_FILTER    Filter,
-    IN      UINT            SizeOfArray,
-    OUT     PUINT           NumberOfAddresses,
-    IN OUT  CHAR            AddressArray [] [FDDI_LENGTH_OF_LONG_ADDRESS])
-{
-    UNIMPLEMENTED
-}
-
-
-/*
- * @unimplemented
- */
-VOID
-EXPORT
-FddiQueryGlobalFilterShortAddresses(
-    OUT     PNDIS_STATUS    Status,
-    IN      PFDDI_FILTER    Filter,
-    IN      UINT            SizeOfArray,
-    OUT     PUINT           NumberOfAddresses,
-    IN OUT  CHAR            AddressArray [] [FDDI_LENGTH_OF_SHORT_ADDRESS])
-{
-    UNIMPLEMENTED
-}
-
-
-/*
- * @unimplemented
- */
-VOID
-EXPORT
-FddiQueryOpenFilterLongAddresses(
-    OUT     PNDIS_STATUS    Status,
-    IN      PFDDI_FILTER    Filter,
-    IN      NDIS_HANDLE     NdisFilterHandle,
-    IN      UINT            SizeOfArray,
-    OUT     PUINT           NumberOfAddresses,
-    IN OUT  CHAR            AddressArray [] [FDDI_LENGTH_OF_LONG_ADDRESS])
-{
-    UNIMPLEMENTED
-}
-
-
-/*
- * @unimplemented
- */
-VOID
-EXPORT
-FddiQueryOpenFilterShortAddresses(
-    OUT     PNDIS_STATUS    Status,
-    IN      PFDDI_FILTER    Filter,
-    IN      NDIS_HANDLE     NdisFilterHandle,
-    IN      UINT            SizeOfArray,
-    OUT     PUINT           NumberOfAddresses,
-    IN OUT  CHAR            AddressArray [] [FDDI_LENGTH_OF_SHORT_ADDRESS])
-{
-    UNIMPLEMENTED
-}
-
-
-/*
- * @unimplemented
- */
-BOOLEAN
-EXPORT
-FddiShouldAddressLoopBack(
-    IN  PFDDI_FILTER    Filter,
-    IN  CHAR            Address [],
-    IN  UINT            LengthOfAddress)
-{
-    UNIMPLEMENTED
-
-       return FALSE;
-}
-
-
 /*
  * @unimplemented
  */
@@ -783,116 +321,12 @@ NdisUnmapIoSpace(
 {
     UNIMPLEMENTED
 }
-
-
-/*
- * @unimplemented
- */
-NDIS_STATUS
-EXPORT
-TrChangeFunctionalAddress(
-    IN  PTR_FILTER      Filter,
-    IN  NDIS_HANDLE     NdisFilterHandle,
-    IN  PNDIS_REQUEST   NdisRequest,
-    IN  CHAR            FunctionalAddressArray [TR_LENGTH_OF_FUNCTIONAL],
-    IN  BOOLEAN         Set)
-{
-    UNIMPLEMENTED
-
-       return NDIS_STATUS_FAILURE;
-}
-
-
-/*
- * @unimplemented
- */
-NDIS_STATUS
-EXPORT
-TrChangeGroupAddress(
-    IN  PTR_FILTER      Filter,
-    IN  NDIS_HANDLE     NdisFilterHandle,
-    IN  PNDIS_REQUEST   NdisRequest,
-    IN  CHAR            GroupAddressArray [TR_LENGTH_OF_FUNCTIONAL],
-    IN  BOOLEAN         Set)
-{
-    UNIMPLEMENTED
-
-       return NDIS_STATUS_FAILURE;
-}
-
-
-/*
- * @unimplemented
- */
-BOOLEAN
-EXPORT
-TrCreateFilter(
-    IN  TR_ADDRESS_CHANGE   AddressChangeAction,
-    IN  TR_GROUP_CHANGE     GroupChangeAction,
-    IN  TR_FILTER_CHANGE    FilterChangeAction,
-    IN  TR_DEFERRED_CLOSE   CloseAction,
-    IN  PUCHAR              AdapterAddress,
-    IN  PNDIS_SPIN_LOCK     Lock,
-    OUT PTR_FILTER          * Filter)
-{
-    UNIMPLEMENTED
-
-       return FALSE;
-}
-
-
 /*
  * @unimplemented
  */
 VOID
 EXPORT
-TrDeleteFilter(
-    IN  PTR_FILTER  Filter)
-{
-    UNIMPLEMENTED
-}
-
-
-/*
- * @unimplemented
- */
-NDIS_STATUS
-EXPORT
-TrDeleteFilterOpenAdapter (
-    IN  PTR_FILTER      Filter,
-    IN  NDIS_HANDLE     NdisFilterHandle,
-    IN  PNDIS_REQUEST   NdisRequest)
-{
-    UNIMPLEMENTED
-
-       return NDIS_STATUS_SUCCESS;
-}
-
-
-/*
- * @unimplemented
- */
-NDIS_STATUS
-EXPORT
-TrFilterAdjust(
-    IN  PTR_FILTER      Filter,
-    IN  NDIS_HANDLE     NdisFilterHandle,
-    IN  PNDIS_REQUEST   NdisRequest,
-    IN  UINT            FilterClasses,
-    IN  BOOLEAN         Set)
-{
-    UNIMPLEMENTED
-
-       return NDIS_STATUS_FAILURE;
-}
-
-
-/*
- * @unimplemented
- */
-VOID
-EXPORT
-TrFilterIndicateReceive(
+TrFilterDprIndicateReceive(
     IN  PTR_FILTER  Filter,
     IN  NDIS_HANDLE MacReceiveContext,
     IN  PVOID       HeaderBuffer,
@@ -910,43 +344,10 @@ TrFilterIndicateReceive(
  */
 VOID
 EXPORT
-TrFilterIndicateReceiveComplete(
+TrFilterDprIndicateReceiveComplete(
     IN  PTR_FILTER  Filter)
 {
     UNIMPLEMENTED
 }
 
-
-/*
- * @unimplemented
- */
-BOOLEAN
-EXPORT
-TrNoteFilterOpenAdapter(
-    IN  PTR_FILTER      Filter,
-    IN  NDIS_HANDLE     MacBindingHandle,
-    IN  NDIS_HANDLE     NdisBindingContext,
-    OUT PNDIS_HANDLE    NdisFilterHandle)
-{
-    UNIMPLEMENTED
-
-       return FALSE;
-}
-
-
-/*
- * @unimplemented
- */
-BOOLEAN
-EXPORT
-TrShouldAddressLoopBack(
-    IN  PTR_FILTER  Filter,
-    IN  CHAR        DestinationAddress [TR_LENGTH_OF_ADDRESS],
-    IN  CHAR        SourceAddress [TR_LENGTH_OF_ADDRESS])
-{
-    UNIMPLEMENTED
-
-       return FALSE;
-}
-
 /* EOF */
index 24c3fba..51b863c 100644 (file)
@@ -259,7 +259,7 @@ NdisMapIoSpace(
 
 
 /*
- * @implemented
+ * @unimplemented
  */
 VOID
 EXPORT
@@ -274,12 +274,7 @@ NdisOverrideBusNumber(
  *    NDIS 4.0
  */
 {
-  PWRAPPER_CONTEXT WrapperContext = (PWRAPPER_CONTEXT)WrapperConfigurationContext;
-  PLOGICAL_ADAPTER Adapter = (PLOGICAL_ADAPTER)MiniportAdapterHandle;
-
-  WrapperContext->BusNumber = BusNumber;
-  if (Adapter)
-    Adapter->BusNumber = BusNumber;
+    UNIMPLEMENTED
 }
 
 
index 8fd5f59..186b31e 100644 (file)
@@ -376,25 +376,9 @@ NdisAllocateBuffer(
 
         Temp->Next = NULL;
 
-#ifdef _MSC_VER
         MmInitializeMdl(&Temp->Mdl, VirtualAddress, Length);
         Temp->Mdl.MdlFlags      |= (MDL_SOURCE_IS_NONPAGED_POOL | MDL_ALLOCATED_FIXED_SIZE);
         Temp->Mdl.MappedSystemVa = VirtualAddress;
-#else
-       Temp->Mdl.Next = (PMDL)NULL;
-       Temp->Mdl.Size = (CSHORT)(sizeof(MDL) +
-                                 (ADDRESS_AND_SIZE_TO_SPAN_PAGES(VirtualAddress, Length) * sizeof(ULONG)));
-       Temp->Mdl.MdlFlags   = (MDL_SOURCE_IS_NONPAGED_POOL | MDL_ALLOCATED_FIXED_SIZE);
-       ;           Temp->Mdl.StartVa    = (PVOID)PAGE_ROUND_DOWN(VirtualAddress);
-       Temp->Mdl.ByteOffset = (ULONG_PTR)(VirtualAddress - PAGE_ROUND_DOWN(VirtualAddress));
-       Temp->Mdl.ByteCount  = Length;
-        Temp->Mdl.MappedSystemVa = VirtualAddress;
-#if 0
-           //Temp->Mdl.Process    = PsGetCurrentProcess();
-#else
-        Temp->Mdl.Process    = NULL;
-#endif
-#endif
         
         Temp->BufferPool = Pool;
 
@@ -1024,6 +1008,29 @@ NdisQueryBuffer(
 }
 
 
+/*
+ * @implemented
+ */
+VOID
+EXPORT
+NdisQueryBufferSafe(
+    IN  PNDIS_BUFFER    Buffer,
+    OUT PVOID           *VirtualAddress OPTIONAL,
+    OUT PUINT           Length,
+    IN  UINT            Priority)
+/*
+ * FUNCTION:
+ * ARGUMENTS:
+ * NOTES:
+ *    NDIS 5.0
+ */
+{
+    if (VirtualAddress != NULL)
+        *VirtualAddress = MmGetSystemAddressForMdlSafe(Buffer, Priority);
+    *Length = MmGetMdlByteCount(Buffer);
+}
+
+
 /*
  * @implemented
  */
index f1cd3f8..208a08e 100644 (file)
@@ -171,11 +171,12 @@ NdisOpenConfiguration(
 {
     HANDLE KeyHandle;
     PMINIPORT_CONFIGURATION_CONTEXT ConfigurationContext;
-    PWRAPPER_CONTEXT WrapperContext = (PWRAPPER_CONTEXT)WrapperConfigurationContext;
+    PNDIS_WRAPPER_CONTEXT WrapperContext = (PNDIS_WRAPPER_CONTEXT)WrapperConfigurationContext;
+    HANDLE RootKeyHandle = WrapperContext->RegistryHandle;
 
     NDIS_DbgPrint(MAX_TRACE, ("Called\n"));
 
-    *Status = ZwDuplicateObject(NtCurrentProcess(), WrapperContext->DeviceKeyHandle,
+    *Status = ZwDuplicateObject(NtCurrentProcess(), RootKeyHandle,
                                 NtCurrentProcess(), &KeyHandle, 0, FALSE,
                                 DUPLICATE_SAME_ACCESS);
     if(!NT_SUCCESS(*Status))
diff --git a/reactos/drivers/net/ndis/ndis/efilter.c b/reactos/drivers/net/ndis/ndis/efilter.c
new file mode 100644 (file)
index 0000000..e93f575
--- /dev/null
@@ -0,0 +1,138 @@
+/*
+ * COPYRIGHT:   See COPYING in the top level directory
+ * PROJECT:     ReactOS NDIS library
+ * FILE:        ndis/efilter.c
+ * PURPOSE:     Ethernet filter functions
+ * PROGRAMMERS: Casper S. Hornstrup (chorns@users.sourceforge.net)
+ *              Vizzini (vizzini@plasmic.com)
+ * REVISIONS:
+ *   CSH 01/08-2000 Created
+ */
+
+#include "ndissys.h"
+
+BOOLEAN
+EXPORT
+EthCreateFilter(
+    IN  UINT                MaximumMulticastAddresses,
+    IN  PUCHAR              AdapterAddress,
+    OUT PETH_FILTER         * Filter)
+/*
+ * FUNCTION: Construct an ethernet filter
+ * ARGUMENTS:
+ *     MaximumMulticastAddresses: Maximum number of multicast adderesses.
+ *     AdapterAddress: Current ethernet address of the adapter.
+ *     Filter: The created filter on successful return.
+ * RETURNS:
+ *     TRUE if the filter was created
+ *     FALSE otherwise
+ * NOTE:
+ *     - This function is no longer exported and intentionally doesn't
+ *       follow the W2K prototype. It was deprecated since NDIS 4 so it
+ *       shouldn't be problem.
+ */
+{
+  PETH_FILTER NewFilter;
+
+  NewFilter = ExAllocatePool(NonPagedPool, sizeof(ETH_FILTER));
+  if (NewFilter != NULL) 
+    {
+      RtlZeroMemory(NewFilter, sizeof(ETH_FILTER));
+      NewFilter->MaxMulticastAddresses = MaximumMulticastAddresses;
+      RtlCopyMemory(NewFilter->AdapterAddress, AdapterAddress, ETH_LENGTH_OF_ADDRESS);
+      *Filter = NewFilter;
+      return TRUE;
+    }
+  return FALSE;
+}
+
+
+VOID
+EXPORT
+EthDeleteFilter(
+    IN  PETH_FILTER Filter)
+{
+    ExFreePool(Filter);
+}
+
+
+/*
+ * @unimplemented
+ */
+VOID
+EXPORT
+EthFilterDprIndicateReceive(
+    IN PETH_FILTER Filter,
+    IN NDIS_HANDLE MacReceiveContext,
+    IN PCHAR       Address,
+    IN PVOID       HeaderBuffer,
+    IN UINT        HeaderBufferSize,
+    IN PVOID       LookaheadBuffer,
+    IN UINT        LookaheadBufferSize,
+    IN UINT        PacketSize)
+/*
+ * FUNCTION: Receive indication function for Ethernet devices
+ * ARGUMENTS:
+ *     MiniportAdapter     = Miniport Adapter Handle (PLOGICAL_ADAPTER)
+ *     MacReceiveContext   = MAC receive context handle
+ *     Address             = Pointer to destination Ethernet address
+ *     HeaderBuffer        = Pointer to Ethernet header buffer
+ *     HeaderBufferSize    = Size of Ethernet header buffer
+ *     LookaheadBuffer     = Pointer to lookahead buffer
+ *     LookaheadBufferSize = Size of lookahead buffer
+ *     PacketSize          = Total size of received packet
+ */
+{
+    MiniIndicateData((PLOGICAL_ADAPTER)Filter->Miniport,
+                    MacReceiveContext,
+                    HeaderBuffer,
+                    HeaderBufferSize,
+                    LookaheadBuffer,
+                    LookaheadBufferSize,
+                    PacketSize);
+}
+
+
+/*
+ * @unimplemented
+ */
+VOID
+EXPORT
+EthFilterDprIndicateReceiveComplete(
+    IN  PETH_FILTER Filter)
+/*
+ * FUNCTION: Receive indication complete function for Ethernet devices
+ * ARGUMENTS:
+ *     Filter = Pointer to Ethernet filter
+ */
+{
+  KIRQL OldIrql;
+  PLIST_ENTRY CurrentEntry;
+  PLOGICAL_ADAPTER Adapter;
+  PADAPTER_BINDING AdapterBinding;
+
+  NDIS_DbgPrint(DEBUG_MINIPORT, ("Called.\n"));
+
+  if( !Filter ) return;
+
+  Adapter = (PLOGICAL_ADAPTER)Filter->Miniport;
+
+  NDIS_DbgPrint(MAX_TRACE, ("acquiring miniport block lock\n"));
+  KeAcquireSpinLock(&Adapter->NdisMiniportBlock.Lock, &OldIrql);
+    {
+      CurrentEntry = Adapter->ProtocolListHead.Flink;
+
+      while (CurrentEntry != &Adapter->ProtocolListHead) 
+        {
+          AdapterBinding = CONTAINING_RECORD(CurrentEntry, ADAPTER_BINDING, AdapterListEntry);
+
+          (*AdapterBinding->ProtocolBinding->Chars.ReceiveCompleteHandler)(
+              AdapterBinding->NdisOpenBlock.NdisCommonOpenBlock.ProtocolBindingContext);
+
+          CurrentEntry = CurrentEntry->Flink;
+        }
+    }
+  KeReleaseSpinLock(&Adapter->NdisMiniportBlock.Lock, OldIrql);
+}
+
+/* EOF */
diff --git a/reactos/drivers/net/ndis/ndis/enum.c b/reactos/drivers/net/ndis/ndis/enum.c
deleted file mode 100644 (file)
index bfae545..0000000
+++ /dev/null
@@ -1,450 +0,0 @@
-/*
- * COPYRIGHT:   See COPYING in the top level directory
- * PROJECT:     ReactOS NDIS library
- * FILE:        ndis/config.c
- * PURPOSE:     NDIS Configuration Services
- * PROGRAMMERS: Vizzini (vizzini@plasmic.com)
- * REVISIONS:
- *     Vizzini 08-20-2003 Created
- * NOTES:
- *     - Currently this only supports enumeration of Root and PCI devices
- *     - This whole thing is really just a band-aid until we have real PnP
- *     - Strictly speaking, I'm not even sure it's my job to call 
- *       HalAssignSlotResources(), but the vmware nic driver likes it
- *     - Please send me feedback if there is a better way :)
- * TODO:
- *     - Break these functions up a bit; i hate 200-line functions
- */
-
-#include "ndissys.h"
-
-/* Registry path to the enumeration database */
-#define ENUM_KEY L"\\Registry\\Machine\\System\\CurrentControlSet\\Enum"
-
-/* Registry path to the services database */
-#define SERVICES_KEY L"\\Registry\\Machine\\System\\CurrentControlSet\\Services"
-
-/*
- * This has to be big enough to hold enumerated registry paths until
- * registry accesses are properly re-coded
- */
-#define KEY_INFORMATION_SIZE 512
-
-/* same sort of deal as above */
-#define VALUE_INFORMATION_SIZE 100
-
-/*
- * NET class GUID, as defined by Microsoft, used to tell if a
- * device belongs to NDIS or not.
- */
-#define NET_GUID L"{4D36E972-E325-11CE-BFC1-08002BE10318}"
-
-#define RZ() do { DbgPrint("%s:%i Checking RedZone\n", __FILE__, __LINE__ ); ExAllocatePool(PagedPool,0); } while (0);
-
-/* see miniport.c */
-extern LIST_ENTRY OrphanAdapterListHead;
-extern KSPIN_LOCK OrphanAdapterListLock;
-
-
-BOOLEAN NdisFindDevicePci(UINT VendorID, UINT DeviceID, PUINT BusNumber, PUINT SlotNumber)
-/*
- * FUNCTION: Find a PCI device given its Vendor and Device IDs
- * ARGUMENTS:
- *     VendorID: The card's PCI Vendor ID
- *     DeviceID: The card's PCI Device ID
- *     BusNumber: The card's bus number on success
- *     SlotNumber: The card's slot number on success
- * RETURNS:
- *     TRUE if the card is fouund
- *     FALSE Otherwise
- * NOTES:
- *     - This only finds the first card of a type
- *     - This doesn't handle function enumeration correctly
- *     - Based loosely on Dekker & Newcomer examples
- */
-{
-  PCI_COMMON_CONFIG PciData;
-  int i, j, k;
-
-  ASSERT(KeGetCurrentIrql() == PASSIVE_LEVEL);
-
-  /* dekker says there are 256 possible PCI buses */
-  for(i = 0; i < 256; i++)
-    {
-      for(j = 0; j < PCI_MAX_DEVICES; j++)
-        {
-          for(k = 0; k < PCI_MAX_FUNCTION; k++)
-            {
-              /* TODO: figure out what to do with k */
-
-              if(HalGetBusData(PCIConfiguration, i, j, &PciData, sizeof(PciData)))
-                {
-                  if(PciData.VendorID == 0xffff) /* Is this handled right? */
-                    continue;
-
-                  if(PciData.VendorID == VendorID && PciData.DeviceID == DeviceID)
-                    {
-                      if(BusNumber) 
-                        *BusNumber = i;
-                      if(SlotNumber) 
-                        *SlotNumber = j;
-
-                      return TRUE;
-                    }
-                }
-            }
-        }
-    }
-
-  NDIS_DbgPrint(MAX_TRACE, ("Didn't find device 0x%x:0x%x\n", VendorID, DeviceID));
-
-  return FALSE;
-}
-
-\f
-VOID NdisStartDriver(PUNICODE_STRING uBusName, PUNICODE_STRING uDeviceId, PUNICODE_STRING uServiceName)
-/*
- * FUNCTION: Starts an NDIS driver
- * ARGUMENTS:
- *     uBusName: the card's bus type, by name, as extracted from the 
- *               enumeration database in the registry
- *     uDeviceId: the card's device ID
- *     uServiceName: the driver (scm db entry) associated with the card
- * NOTES:
- *     - This doesn't prooperly handle multiple instances of the same card or driver
- *     - for PCI cards, this finds the card and creates an "orphan" adapter object for
- *       it.  This object is tagged with the registry key to the driver and includes
- *       the slot number and bus number of the card.  NOTE that some stupid nic drivers
- *       still depend on a registry key for slot number, so this isn't always enough.
- *       Whatever the case, all of the card's resources are enumerated and assigned
- *       via HalAssignSlotResources() and the orphan adapter is put onto the list. 
- *       When the miniport calls NdisMRegisterMiniport(), ndis loops through the list
- *       of orphans and associates any orphans that belong to that miniport with
- *       its corresponding LOGICAL_ADAPTER objects.  
- */
-{
-  ULONG            VendorId;
-  ULONG            DeviceId;
-  UINT             SlotNumber;
-  UINT             BusNumber;
-  UNICODE_STRING   Temp;
-  UNICODE_STRING   ServiceKey;
-  PWCHAR           ServiceKeyStr;
-  NTSTATUS         NtStatus;
-  PORPHAN_ADAPTER  OrphanAdapter;
-
-  NDIS_DbgPrint(MAX_TRACE, ("Called; Starting %wZ\n", uServiceName));
-
-  ASSERT(KeGetCurrentIrql() == PASSIVE_LEVEL);
-
-  /* prepare a services key */
-  ServiceKeyStr = ExAllocatePool(PagedPool, sizeof(SERVICES_KEY) + sizeof(WCHAR) + uServiceName->Length);
-  if(!ServiceKeyStr)
-    {
-      NDIS_DbgPrint(MIN_TRACE, ("Insufficient Resources.\n"));
-      return;
-    }
-
-  wcscpy(ServiceKeyStr, SERVICES_KEY);
-  wcscat(ServiceKeyStr, L"\\");
-  wcsncat(ServiceKeyStr, uServiceName->Buffer, uServiceName->Length/sizeof(WCHAR));
-  ServiceKeyStr[wcslen(SERVICES_KEY)+1+uServiceName->Length/sizeof(WCHAR)] = 0;
-
-  RtlInitUnicodeString(&ServiceKey, ServiceKeyStr);
-
-  if(!wcsncmp(uBusName->Buffer, L"PCI", uBusName->Length))
-  {
-    /*
-     * first see if a card with the requested id exists. 
-     * PCI IDs are formatted VEN_ABCD&DEV_ABCD[&...] 
-     */
-
-    if(wcsncmp(uDeviceId->Buffer, L"VEN_", 4))
-      {
-        NDIS_DbgPrint(MIN_TRACE, ("Bogus uDeviceId parsing VEN\n"));
-        ExFreePool(ServiceKeyStr);
-        return;
-      }
-
-    Temp.Buffer = &(uDeviceId->Buffer[4]);                      /* offset of vendor id */
-    Temp.Length = Temp.MaximumLength = 4 * sizeof(WCHAR);       /* 4-digit id */
-
-    NtStatus = RtlUnicodeStringToInteger(&Temp, 16, &VendorId);
-    if(!NT_SUCCESS(NtStatus))
-      {
-        NDIS_DbgPrint(MIN_TRACE, ("RtlUnicodeStringToInteger returned 0x%x\n", NtStatus));
-        ExFreePool(ServiceKeyStr);
-        return;
-      }
-
-    if(wcsncmp(&(uDeviceId->Buffer[9]), L"DEV_", 4))    
-      {
-        NDIS_DbgPrint(MIN_TRACE, ("Bogus uDeviceId parsing DEV\n"));
-        ExFreePool(ServiceKeyStr);
-        return;
-      }
-
-    Temp.Buffer = &(uDeviceId->Buffer[13]);     /* offset of device id */
-    Temp.Length = 4 * sizeof(WCHAR);            /* 4-dight id */
-
-    NtStatus = RtlUnicodeStringToInteger(&Temp, 16, &DeviceId);
-    if(!NT_SUCCESS(NtStatus))
-      {
-        NDIS_DbgPrint(MIN_TRACE, ("RtlUnicodeStringToInteger returned 0x%x\n", NtStatus));
-        ExFreePool(ServiceKeyStr);
-        return;
-      }
-
-    if(!NdisFindDevicePci(VendorId, DeviceId, &BusNumber, &SlotNumber))
-      {
-        NDIS_DbgPrint(MIN_TRACE, ("Didn't find a configured card 0x%x 0x%x\n", VendorId, DeviceId));
-        ExFreePool(ServiceKeyStr);
-        return;
-      }
-
-    NDIS_DbgPrint(MAX_TRACE, ("Found a card 0x%x 0x%x at bus 0x%x slot 0x%x\n", VendorId, DeviceId, BusNumber, SlotNumber));
-
-    OrphanAdapter = ExAllocatePool(PagedPool, sizeof(ORPHAN_ADAPTER));
-    if(!OrphanAdapter)
-      {
-        NDIS_DbgPrint(MIN_TRACE, ("Insufficient Resources.\n"));
-        ExFreePool(ServiceKeyStr);
-        return;
-      }
-
-    OrphanAdapter->RegistryPath.Buffer = ExAllocatePool(PagedPool, Temp.MaximumLength);
-    if(!OrphanAdapter->RegistryPath.Buffer)
-      {
-        NDIS_DbgPrint(MIN_TRACE, ("Insufficient Resources.\n"));
-        ExFreePool(ServiceKeyStr);
-        return;
-      }
-
-    OrphanAdapter->RegistryPath.Length = Temp.Length;
-    OrphanAdapter->RegistryPath.MaximumLength = Temp.MaximumLength;
-    memcpy(OrphanAdapter->RegistryPath.Buffer, Temp.Buffer, Temp.Length);
-
-    OrphanAdapter->BusType    = PCIBus; 
-    OrphanAdapter->BusNumber  = BusNumber;
-    OrphanAdapter->SlotNumber = SlotNumber;
-
-    ExInterlockedInsertTailList(&OrphanAdapterListHead, &OrphanAdapter->ListEntry, &OrphanAdapterListLock);
-  }
-
-  /*
-   * found a card; start its driver. this should be done from a 
-   * system thread, after NDIS.SYS's DriverEntry returns, but I 
-   * really don't know how to block on DriverEntry returning, so 
-   * what the hell.
-   */
-
-  NDIS_DbgPrint(MID_TRACE, ("Loading driver %wZ\n", &ServiceKey));
-  ZwLoadDriver(&ServiceKey);
-
-  ExFreePool(ServiceKeyStr);
-}
-
-\f
-VOID NdisStartDevices()
-/*
- * FUNCTION: Find and start all NDIS Net class devices
- * NOTES:
- *     - Not sure if this handles multiple instances of the same
- *       device or driver correctly yet
- */
-{
-  HANDLE EnumHandle;
-  OBJECT_ATTRIBUTES ObjectAttributes;
-  UNICODE_STRING KeyName;
-  NTSTATUS NtStatus;
-  ULONG EnumIndex = 0;
-  ULONG ResultLength;
-  PKEY_BASIC_INFORMATION KeyInformation;
-  ULONG KeyInformationLength;
-
-  NDIS_DbgPrint(MAX_TRACE, ("Called.\n"));
-
-  ASSERT(KeGetCurrentIrql() == PASSIVE_LEVEL);
-
-  RtlInitUnicodeString(&KeyName, ENUM_KEY);
-  InitializeObjectAttributes(&ObjectAttributes, &KeyName, OBJ_CASE_INSENSITIVE, 0, 0);
-  NtStatus = ZwOpenKey(&EnumHandle, KEY_ALL_ACCESS, &ObjectAttributes);
-  if(!NT_SUCCESS(NtStatus))
-    {
-      NDIS_DbgPrint(MIN_TRACE, ("Unable to open the Enum key\n"));
-      return;
-    }
-
-  NDIS_DbgPrint(MAX_TRACE, ("Opened the enum key\n"));
-
-  KeyInformation = ExAllocatePool(PagedPool, KEY_INFORMATION_SIZE);    // should be enough for most key names?
-  if(!KeyInformation)
-    {
-      NDIS_DbgPrint(MIN_TRACE, ("Insufficient resources.\n"));
-      return;
-    }
-
-  KeyInformationLength = KEY_INFORMATION_SIZE;
-
-  while(NT_SUCCESS(ZwEnumerateKey(EnumHandle, EnumIndex, 
-        KeyBasicInformation, KeyInformation, KeyInformationLength, &ResultLength)))
-    {
-      /* iterate through each enumerator (PCI, Root, ISAPNP, etc) */
-
-      HANDLE EnumeratorHandle;
-      WCHAR *EnumeratorStr;
-      UINT EnumeratorIndex = 0;
-
-      NDIS_DbgPrint(MAX_TRACE, ("Enum iteration 0x%x\n", EnumIndex));
-
-      EnumIndex++;
-
-      EnumeratorStr = ExAllocatePool(PagedPool, sizeof(WCHAR) + KeyInformation->NameLength);
-      if(!EnumeratorStr)
-        {
-          NDIS_DbgPrint(MIN_TRACE, ("Insufficient resources.\n"));
-          return;
-        }
-
-      wcsncpy(EnumeratorStr, KeyInformation->Name, KeyInformation->NameLength/sizeof(WCHAR));
-      EnumeratorStr[KeyInformation->NameLength/sizeof(WCHAR)] = 0;
-
-      RtlInitUnicodeString(&KeyName, EnumeratorStr);
-      InitializeObjectAttributes(&ObjectAttributes, &KeyName, OBJ_CASE_INSENSITIVE, EnumHandle, 0);
-      if(!NT_SUCCESS(ZwOpenKey(&EnumeratorHandle, KEY_ALL_ACCESS, &ObjectAttributes)))
-        {
-          NDIS_DbgPrint(MIN_TRACE, ("Failed to open key %wZ\n", &KeyName));
-          return;
-        }
-        
-      while(NT_SUCCESS(ZwEnumerateKey(EnumeratorHandle, EnumeratorIndex, KeyBasicInformation,
-          KeyInformation, KeyInformationLength, &ResultLength)))
-        {
-          /* iterate through each device id */
-
-          HANDLE DeviceHandle;
-          WCHAR *DeviceStr;
-          UINT DeviceIndex = 0;
-          UNICODE_STRING BusName;
-
-          BusName.Buffer = KeyName.Buffer;
-          BusName.Length = KeyName.Length;
-          BusName.MaximumLength = KeyName.MaximumLength;
-
-          EnumeratorIndex++;
-
-          DeviceStr = ExAllocatePool(PagedPool, KeyInformation->NameLength + sizeof(WCHAR));
-          if(!DeviceStr)
-            {
-              NDIS_DbgPrint(MIN_TRACE, ("Insufficient resources.\n"));
-              return;
-            }
-
-          wcsncpy(DeviceStr, KeyInformation->Name, KeyInformation->NameLength/sizeof(WCHAR));
-          DeviceStr[KeyInformation->NameLength/sizeof(WCHAR)] = 0;
-
-          RtlInitUnicodeString(&KeyName, DeviceStr);
-          InitializeObjectAttributes(&ObjectAttributes, &KeyName, OBJ_CASE_INSENSITIVE, EnumeratorHandle, 0);
-          if(!NT_SUCCESS(ZwOpenKey(&DeviceHandle, KEY_ALL_ACCESS, &ObjectAttributes)))
-            {
-              NDIS_DbgPrint(MIN_TRACE, ("Failed to open key %wZ\n", &KeyName));
-              return;
-            }
-
-          while(NT_SUCCESS(ZwEnumerateKey(DeviceHandle, DeviceIndex, KeyBasicInformation, 
-                KeyInformation, KeyInformationLength, &ResultLength)))
-            {
-              /* iterate through each instance id, starting drivers in the process */
-              HANDLE InstanceHandle;
-              WCHAR *InstanceStr;
-              UNICODE_STRING ValueName;
-              UNICODE_STRING ServiceName;
-              PKEY_VALUE_PARTIAL_INFORMATION KeyValueInformation;
-              ULONG KeyValueInformationLength;
-              UNICODE_STRING DeviceId;
-
-              DeviceId.Buffer = KeyName.Buffer;
-              DeviceId.Length = KeyName.Length;
-              DeviceId.MaximumLength = KeyName.MaximumLength;
-
-              DeviceIndex++;
-
-              InstanceStr = ExAllocatePool(PagedPool, KeyInformation->NameLength + sizeof(WCHAR));
-              if(!InstanceStr)
-                {
-                  NDIS_DbgPrint(MIN_TRACE, ("Insufficient resources.\n"));
-                  return;
-                }
-
-              wcsncpy(InstanceStr, KeyInformation->Name, KeyInformation->NameLength/sizeof(WCHAR));
-              InstanceStr[KeyInformation->NameLength/sizeof(WCHAR)] = 0;
-
-              NDIS_DbgPrint(MAX_TRACE, ("NameLength = 0x%x and InstanceStr: %ws\n", KeyInformation->NameLength, InstanceStr));
-
-              RtlInitUnicodeString(&KeyName, InstanceStr);
-              InitializeObjectAttributes(&ObjectAttributes, &KeyName, OBJ_CASE_INSENSITIVE, DeviceHandle, 0);
-              if(!NT_SUCCESS(ZwOpenKey(&InstanceHandle, KEY_ALL_ACCESS, &ObjectAttributes)))
-                {
-                  NDIS_DbgPrint(MIN_TRACE, ("Failed to open key %wZ\n", &KeyName));
-                  return;
-                }
-
-              /* read class, looking for net guid */
-              RtlInitUnicodeString(&ValueName, L"ClassGUID");
-
-              KeyValueInformation = ExAllocatePool(PagedPool, VALUE_INFORMATION_SIZE);
-              if(!KeyValueInformation)
-                {
-                  NDIS_DbgPrint(MIN_TRACE, ("Insufficient resources.\n"));
-                  return;
-                }
-
-              KeyValueInformationLength = VALUE_INFORMATION_SIZE;
-
-              NtStatus = ZwQueryValueKey(InstanceHandle, &ValueName, KeyValuePartialInformation, 
-                  KeyValueInformation, KeyValueInformationLength, &ResultLength);
-              if(!NT_SUCCESS(NtStatus))
-                {
-                  /* this isn't fatal, it just means that this device isn't ours */
-                  NDIS_DbgPrint(MID_TRACE, ("Failed to query value %wZ from key %wZ\n", &ValueName, &KeyName));
-                  continue;
-                }
-
-              if(!wcsncmp(NET_GUID, (PWCHAR)KeyValueInformation->Data, KeyValueInformation->DataLength/sizeof(WCHAR)))
-                {
-                  RtlInitUnicodeString(&ValueName, L"Service");
-
-                  NtStatus = ZwQueryValueKey(InstanceHandle, &ValueName, KeyValuePartialInformation, 
-                      KeyValueInformation, KeyValueInformationLength, &ResultLength);
-                  if(!NT_SUCCESS(NtStatus))
-                    {
-                      /* non-fatal also */
-                      NDIS_DbgPrint(MID_TRACE, ("Failed to query value %wZ from key %wZ\n", &ValueName, &KeyName));
-                      continue;
-                    }
-
-                  /* this is a net driver; start it */
-                  ServiceName.Length = ServiceName.MaximumLength = KeyValueInformation->DataLength;
-                  ServiceName.Buffer = (PWCHAR)KeyValueInformation->Data;
-                  NdisStartDriver(&BusName, &DeviceId, &ServiceName);
-                }
-              else
-                NDIS_DbgPrint(MAX_TRACE, ("...this device is not ours\n"));
-
-              ExFreePool(KeyValueInformation);
-              ExFreePool(InstanceStr);
-              ZwClose(InstanceHandle);
-            }
-
-          ExFreePool(DeviceStr);
-          ZwClose(DeviceHandle);
-        }
-
-      ExFreePool(EnumeratorStr);
-      ZwClose(EnumeratorHandle);
-    }
-
-  ZwClose(EnumHandle);
-  ExFreePool(KeyInformation);
-}
-
index 6b2327b..fcd132a 100644 (file)
@@ -9,6 +9,7 @@
  *   CSH 01/08-2000 Created
  *   25 Aug 2003 Vizzini - NDIS4/5 and PnP additions
  *   3  Oct 2003 Vizzini - formatting and minor bugfixes
+ *
  */
 
 #include <roscfg.h>
@@ -27,7 +28,7 @@ NdisImmediateReadPciSlotInformation(
     IN  PVOID       Buffer,
     IN  ULONG       Length)
 {
-  PWRAPPER_CONTEXT WrapperContext = (PWRAPPER_CONTEXT)WrapperConfigurationContext;
+  PNDIS_WRAPPER_CONTEXT WrapperContext = (PNDIS_WRAPPER_CONTEXT)WrapperConfigurationContext;
   return HalGetBusDataByOffset(PCIConfiguration, WrapperContext->BusNumber,
                                SlotNumber, Buffer, Offset, Length);
 }
@@ -45,7 +46,7 @@ NdisImmediateWritePciSlotInformation(
     IN  PVOID       Buffer,
     IN  ULONG       Length)
 {
-  PWRAPPER_CONTEXT WrapperContext = (PWRAPPER_CONTEXT)WrapperConfigurationContext;
+  PNDIS_WRAPPER_CONTEXT WrapperContext = (PNDIS_WRAPPER_CONTEXT)WrapperConfigurationContext;
   return HalSetBusDataByOffset(PCIConfiguration, WrapperContext->BusNumber,
                                SlotNumber, Buffer, Offset, Length);
 }
@@ -60,36 +61,32 @@ NdisMPciAssignResources(
     IN  NDIS_HANDLE             MiniportHandle,
     IN  ULONG                   SlotNumber,
     OUT PNDIS_RESOURCE_LIST     *AssignedResources)
-/*
- * NOTES:
- *     - I think this is fundamentally broken
- */
 {
-  PCM_RESOURCE_LIST ResourceList;
-  NTSTATUS Status;
-  PLOGICAL_ADAPTER Adapter = (PLOGICAL_ADAPTER)MiniportHandle;
-
-  ResourceList = NULL;
-  Status = HalAssignSlotResources (Adapter->Miniport->RegistryPath,
-                                  0,
-                                  Adapter->Miniport->DriverObject,
-                                  0,
-                                  PCIBus,
-                                  Adapter->BusNumber,
-                                  SlotNumber,
-                                  &ResourceList);
-  if (!NT_SUCCESS (Status))
+  PNDIS_MINIPORT_BLOCK MiniportBlock = &((PLOGICAL_ADAPTER)MiniportHandle)->NdisMiniportBlock;
+
+  if (MiniportBlock->BusType != PCIBus ||
+      MiniportBlock->AllocatedResources == NULL)
     {
       *AssignedResources = NULL;
       return NDIS_STATUS_FAILURE;
     }
 
-  *AssignedResources = (PNDIS_RESOURCE_LIST)&ResourceList->List[0].PartialResourceList;
+  *AssignedResources = &MiniportBlock->AllocatedResources->List[0].PartialResourceList;
 
   return NDIS_STATUS_SUCCESS;
 }
 
 \f
+/*
+ * @implemented
+ */
+VOID
+EXPORT
+NdisMQueryAdapterResources(
+    OUT     PNDIS_STATUS        Status,
+    IN      NDIS_HANDLE         WrapperConfigurationContext,
+    OUT     PNDIS_RESOURCE_LIST ResourceList,
+    IN OUT  PUINT               BufferSize)
 /*
  * FUNCTION: returns a nic's hardware resources
  * ARGUMENTS:
@@ -100,25 +97,42 @@ NdisMPciAssignResources(
  * NOTES:
  *     - Caller must allocate Status and ResourceList
  *     - Must be called at IRQL = PASSIVE_LEVEL;
- * BUGS:
- *     - Needs an implementation; for now i think we are waiting on pnp
- *
- * @unimplemented
  */
-VOID
-EXPORT
-NdisMQueryAdapterResources(
-    OUT     PNDIS_STATUS        Status,
-    IN      NDIS_HANDLE         WrapperConfigurationContext,
-    OUT     PNDIS_RESOURCE_LIST ResourceList,
-    IN OUT  PUINT               BufferSize)
 {
+  PNDIS_WRAPPER_CONTEXT WrapperContext = (PNDIS_WRAPPER_CONTEXT)WrapperConfigurationContext;
+  PNDIS_MINIPORT_BLOCK MiniportBlock = WrapperContext->DeviceObject->DeviceExtension;
+  ULONG ResourceListSize;
+
   PAGED_CODE();
   ASSERT(Status && ResourceList);
 
-  NDIS_DbgPrint(MIN_TRACE, ("Unimplemented!\n"));
+  NDIS_DbgPrint(MAX_TRACE, ("Called\n"));
 
-  *Status = STATUS_NOT_SUPPORTED;
+  if (MiniportBlock->AllocatedResources == NULL)
+    {
+      NDIS_DbgPrint(MIN_TRACE, ("No allocated resources!\n"));
+      *Status = NDIS_STATUS_FAILURE;
+      return;
+    }
+
+  ResourceListSize = 
+    FIELD_OFFSET(CM_PARTIAL_RESOURCE_LIST, PartialDescriptors) +
+    MiniportBlock->AllocatedResources->List[0].PartialResourceList.Count *
+    sizeof(CM_PARTIAL_RESOURCE_DESCRIPTOR);
+
+  if (*BufferSize >= ResourceListSize)
+    {
+      RtlCopyMemory(ResourceList,
+                    &MiniportBlock->AllocatedResources->List[0].PartialResourceList,
+                    ResourceListSize);
+      *BufferSize = ResourceListSize;
+      *Status = STATUS_SUCCESS;
+    }
+  else
+    {
+      *BufferSize = ResourceListSize;
+      *Status = NDIS_STATUS_RESOURCES;
+    }
 }
 
 
@@ -183,11 +197,12 @@ NdisReadPciSlotInformation(
     IN  PVOID       Buffer,
     IN  ULONG       Length)
 {
-  PLOGICAL_ADAPTER AdapterObject = (PLOGICAL_ADAPTER)NdisAdapterHandle;
+  PLOGICAL_ADAPTER Adapter = (PLOGICAL_ADAPTER)NdisAdapterHandle;
   /* Slot number is ignored since W2K for all NDIS drivers. */
-  NDIS_DbgPrint(MAX_TRACE, ("Slot: %d\n", AdapterObject->SlotNumber));
-  return HalGetBusDataByOffset(PCIConfiguration, AdapterObject->BusNumber,
-                               AdapterObject->SlotNumber, Buffer, Offset, Length);
+  return HalGetBusDataByOffset(PCIConfiguration,
+                               Adapter->NdisMiniportBlock.BusNumber,
+                               Adapter->NdisMiniportBlock.SlotNumber,
+                               Buffer, Offset, Length);
 }
 
 \f
@@ -203,12 +218,12 @@ NdisWritePciSlotInformation(
     IN  PVOID       Buffer,
     IN  ULONG       Length)
 {
-  PLOGICAL_ADAPTER AdapterObject = (PLOGICAL_ADAPTER)NdisAdapterHandle;
+  PLOGICAL_ADAPTER Adapter = (PLOGICAL_ADAPTER)NdisAdapterHandle;
   /* Slot number is ignored since W2K for all NDIS drivers. */
-  NDIS_DbgPrint(MAX_TRACE, ("Slot: %d\n", AdapterObject->SlotNumber));
-  return HalSetBusDataByOffset(PCIConfiguration, AdapterObject->BusNumber,
-                               AdapterObject->SlotNumber, Buffer, Offset, Length);
+  return HalSetBusDataByOffset(PCIConfiguration,
+                               Adapter->NdisMiniportBlock.BusNumber,
+                               Adapter->NdisMiniportBlock.SlotNumber,
+                               Buffer, Offset, Length);
 }
 
 /* EOF */
-
index 322b0e8..7be838e 100644 (file)
@@ -11,6 +11,7 @@
  *   3  Oct 2003 Vizzini - Formatting and minor bugfixes
  */
 
+#include <roscfg.h>
 #include "ndissys.h"
 
 \f
@@ -312,8 +313,7 @@ NdisMAllocateMapRegisters(
  */
 {
   DEVICE_DESCRIPTION Description;
-  PADAPTER_OBJECT    AdapterObject = 0;
-  UINT               MapRegistersRequired = 0;
+  PDMA_ADAPTER       AdapterObject = 0;
   UINT               MapRegistersPerBaseRegister = 0;
   ULONG              AvailableMapRegisters;
   NTSTATUS           NtStatus;
@@ -352,21 +352,14 @@ NdisMAllocateMapRegisters(
 
   /* unhandled corner case: {1,2}-byte max buffer size */
   ASSERT(MaximumBufferSize > 2);
-  MapRegistersPerBaseRegister = ((MaximumBufferSize-2) / PAGE_SIZE) + 2;
-  MapRegistersRequired = BaseMapRegistersNeeded * MapRegistersPerBaseRegister;
-
-  if(MapRegistersRequired > 64)
-    {
-      NDIS_DbgPrint(MID_TRACE, ("Request for too many map registers: %d\n", MapRegistersRequired));
-      return NDIS_STATUS_RESOURCES;
-    }
+  MapRegistersPerBaseRegister = ((MaximumBufferSize-2) / (2*PAGE_SIZE)) + 2;
 
   Description.Version = DEVICE_DESCRIPTION_VERSION;
   Description.Master = TRUE;                         /* implied by calling this function */
   Description.ScatterGather = TRUE;                  /* XXX UNTRUE: All BM DMA are S/G (ms seems to do this) */
   Description.Dma32BitAddresses = DmaSize;
-  Description.BusNumber = Adapter->BusNumber;
-  Description.InterfaceType = Adapter->BusType;
+  Description.BusNumber = Adapter->NdisMiniportBlock.BusNumber;
+  Description.InterfaceType = Adapter->NdisMiniportBlock.BusType;
   Description.DmaChannel = DmaChannel;
   Description.MaximumLength = MaximumBufferSize;
 
@@ -393,8 +386,9 @@ NdisMAllocateMapRegisters(
       ASSERT(0);
     }
 
-  AvailableMapRegisters = MapRegistersRequired;
-  AdapterObject = HalGetAdapter(&Description, &AvailableMapRegisters);
+  AdapterObject = IoGetDmaAdapter(
+    Adapter->NdisMiniportBlock.PhysicalDeviceObject,
+    &Description, &AvailableMapRegisters);
 
   if(!AdapterObject)
     {
@@ -404,10 +398,10 @@ NdisMAllocateMapRegisters(
 
   Adapter->NdisMiniportBlock.SystemAdapterObject = AdapterObject;
 
-  if(AvailableMapRegisters < MapRegistersRequired)
+  if(AvailableMapRegisters < MapRegistersPerBaseRegister)
     {
       NDIS_DbgPrint(MIN_TRACE, ("Didn't get enough map registers from hal - requested 0x%x, got 0x%x\n", 
-          MapRegistersRequired, AvailableMapRegisters));
+          MapRegistersPerBaseRegister, AvailableMapRegisters));
 
       return NDIS_STATUS_RESOURCES;
     }
@@ -421,17 +415,19 @@ NdisMAllocateMapRegisters(
     }
 
   memset(Adapter->NdisMiniportBlock.MapRegisters, 0, BaseMapRegistersNeeded * sizeof(MAP_REGISTER_ENTRY));
+  Adapter->NdisMiniportBlock.BaseMapRegistersNeeded = BaseMapRegistersNeeded;
 
   while(BaseMapRegistersNeeded)
     {
-      NDIS_DbgPrint(MAX_TRACE, ("iterating, basemapregistersneeded = %d, IoAlloc = 0x%x\n", BaseMapRegistersNeeded, IoAllocateAdapterChannel));
+      NDIS_DbgPrint(MAX_TRACE, ("iterating, basemapregistersneeded = %d\n", BaseMapRegistersNeeded));
 
       BaseMapRegistersNeeded--;
       Adapter->NdisMiniportBlock.CurrentMapRegister = BaseMapRegistersNeeded;
       KeRaiseIrql(DISPATCH_LEVEL, &OldIrql);
         {
-          NtStatus = IoAllocateAdapterChannel(AdapterObject, DeviceObject, 
-              MapRegistersPerBaseRegister, NdisMapRegisterCallback, Adapter);
+          NtStatus = AdapterObject->DmaOperations->AllocateAdapterChannel(
+              AdapterObject, DeviceObject, MapRegistersPerBaseRegister,
+              NdisMapRegisterCallback, Adapter);
         }
       KeLowerIrql(OldIrql);
 
@@ -507,7 +503,8 @@ NdisMStartBufferPhysicalMapping(
     {
       ULONG Length = TotalLength;
 
-      ReturnedAddress = IoMapTransfer(Adapter->NdisMiniportBlock.SystemAdapterObject, Buffer, 
+      ReturnedAddress = Adapter->NdisMiniportBlock.SystemAdapterObject->DmaOperations->MapTransfer(
+          Adapter->NdisMiniportBlock.SystemAdapterObject, Buffer, 
           Adapter->NdisMiniportBlock.MapRegisters[PhysicalMapRegister].MapRegister, 
           CurrentVa, &Length, WriteToDevice);
 
@@ -556,7 +553,8 @@ NdisMCompleteBufferPhysicalMapping(
   CurrentVa = MmGetMdlVirtualAddress(Buffer);
   Length = MmGetMdlByteCount(Buffer);
 
-  IoFlushAdapterBuffers(Adapter->NdisMiniportBlock.SystemAdapterObject, Buffer, 
+  Adapter->NdisMiniportBlock.SystemAdapterObject->DmaOperations->FlushAdapterBuffers(
+      Adapter->NdisMiniportBlock.SystemAdapterObject, Buffer, 
       Adapter->NdisMiniportBlock.MapRegisters[PhysicalMapRegister].MapRegister,
       CurrentVa, Length, 
       Adapter->NdisMiniportBlock.MapRegisters[PhysicalMapRegister].WriteToDevice);
@@ -650,7 +648,7 @@ NdisMFreeMapRegisters(
 {
   KIRQL            OldIrql;
   PLOGICAL_ADAPTER Adapter = (PLOGICAL_ADAPTER)MiniportAdapterHandle;
-  PADAPTER_OBJECT  AdapterObject;
+  PDMA_ADAPTER     AdapterObject;
   UINT             MapRegistersPerBaseRegister;
   UINT             i;
 
@@ -660,7 +658,8 @@ NdisMFreeMapRegisters(
 
   /* only bus masters may call this routine */
   ASSERT(Adapter->NdisMiniportBlock.Flags & NDIS_ATTRIBUTE_BUS_MASTER);
-  if(!(Adapter->NdisMiniportBlock.Flags & NDIS_ATTRIBUTE_BUS_MASTER))
+  if(!(Adapter->NdisMiniportBlock.Flags & NDIS_ATTRIBUTE_BUS_MASTER) ||
+     Adapter->NdisMiniportBlock.SystemAdapterObject == NULL)
     return;
 
   MapRegistersPerBaseRegister = ((Adapter->NdisMiniportBlock.MaximumPhysicalMapping - 2) / PAGE_SIZE) + 2;
@@ -669,14 +668,19 @@ NdisMFreeMapRegisters(
 
   KeRaiseIrql(DISPATCH_LEVEL, &OldIrql);
     {
-      for(i = 0; i < Adapter->NdisMiniportBlock.PhysicalMapRegistersNeeded; i++)
+      for(i = 0; i < Adapter->NdisMiniportBlock.BaseMapRegistersNeeded; i++)
         {
-          IoFreeMapRegisters(Adapter->NdisMiniportBlock.SystemAdapterObject, 
-              Adapter->NdisMiniportBlock.MapRegisters[i].MapRegister, MapRegistersPerBaseRegister);
+          AdapterObject->DmaOperations->FreeMapRegisters(
+              Adapter->NdisMiniportBlock.SystemAdapterObject, 
+              Adapter->NdisMiniportBlock.MapRegisters[i].MapRegister,
+              MapRegistersPerBaseRegister);
         }
     }
  KeLowerIrql(OldIrql);
 
+ AdapterObject->DmaOperations->PutDmaAdapter(AdapterObject);
+ Adapter->NdisMiniportBlock.SystemAdapterObject = NULL;
+
  ExFreePool(Adapter->NdisMiniportBlock.MapRegisters);
 }
 
@@ -724,16 +728,42 @@ NdisMMapIoSpace(
 
 \f
 /*
- * @unimplemented
+ * @implemented
  */
 ULONG
 EXPORT
 NdisMReadDmaCounter(
     IN  NDIS_HANDLE MiniportDmaHandle)
 {
-    UNIMPLEMENTED
+  PNDIS_MINIPORT_BLOCK MiniportBlock = (PNDIS_MINIPORT_BLOCK)MiniportDmaHandle;
+  PDMA_ADAPTER AdapterObject = MiniportBlock->SystemAdapterObject;
 
-  return 0;
+  NDIS_DbgPrint(MAX_TRACE, ("Called.\n"));
+
+  if (AdapterObject == NULL)
+    return 0;
+    
+  return AdapterObject->DmaOperations->ReadDmaCounter(AdapterObject);
+}
+
+\f
+/*
+ * @implemented
+ */
+ULONG
+EXPORT
+NdisMGetDmaAlignment(
+    IN  NDIS_HANDLE MiniportDmaHandle)
+{
+  PNDIS_MINIPORT_BLOCK MiniportBlock = (PNDIS_MINIPORT_BLOCK)MiniportDmaHandle;
+  PDMA_ADAPTER AdapterObject = MiniportBlock->SystemAdapterObject;
+
+  NDIS_DbgPrint(MAX_TRACE, ("Called.\n"));
+
+  if (AdapterObject == NULL)
+    return 0;
+    
+  return AdapterObject->DmaOperations->GetDmaAlignment(AdapterObject);
 }
 
 \f
@@ -805,7 +835,10 @@ NdisMRegisterInterrupt(
 
   Adapter->NdisMiniportBlock.Interrupt = Interrupt;
 
-  MappedIRQ = HalGetInterruptVector(Adapter->BusType, Adapter->BusNumber, InterruptLevel, InterruptVector, &DIrql, &Affinity);
+  MappedIRQ = HalGetInterruptVector(Adapter->NdisMiniportBlock.BusType,
+                                    Adapter->NdisMiniportBlock.BusNumber,
+                                    InterruptLevel, InterruptVector, &DIrql,
+                                    &Affinity);
 
   NDIS_DbgPrint(MAX_TRACE, ("Connecting to interrupt vector (0x%X)  Affinity (0x%X).\n", MappedIRQ, Affinity));
 
@@ -860,19 +893,20 @@ NdisMRegisterIoPortRange(
 
   /*
    * FIXME: NDIS 5+ completely ignores the InitialPort parameter, but
-   * currently Adapter->BaseIoAddress isn't initialized anywhere.
+   * we don't have a way to get the I/O base address yet (see
+   * NDIS_MINIPORT_BLOCK->AllocatedResources and
+   * NDIS_MINIPORT_BLOCK->AllocatedResourcesTranslated).
    */
-#if 1
-  /* this might be a hack - ndis5 miniports seem to specify 0 */
   if(InitialPort)
       PortAddress = RtlConvertUlongToLargeInteger(InitialPort);
   else
-#endif
-      PortAddress = Adapter->BaseIoAddress;
+      ASSERT(FALSE);
 
   NDIS_DbgPrint(MAX_TRACE, ("Translating address 0x%x 0x%x\n", PortAddress.u.HighPart, PortAddress.u.LowPart));
 
-  if(!HalTranslateBusAddress(Adapter->BusType, Adapter->BusNumber, PortAddress, &AddressSpace, &TranslatedAddress))
+  if(!HalTranslateBusAddress(Adapter->NdisMiniportBlock.BusType,
+                             Adapter->NdisMiniportBlock.BusNumber,
+                             PortAddress, &AddressSpace, &TranslatedAddress))
     {
       NDIS_DbgPrint(MIN_TRACE, ("Unable to translate address\n"));
       return NDIS_STATUS_RESOURCES;
index f4bf18e..5fe7b94 100644 (file)
@@ -62,13 +62,6 @@ DriverEntry(
 
   DriverObject->DriverUnload = MainUnload;
 
-  /* 
-   * until we have PNP support, query the enum key and NdisFindDevice() each one
-   * NOTE- this will load and start other services before this one returns STATUS_SUCCESS.
-   * I hope there aren't code reentrancy problems. :) 
-   */
-  //NdisStartDevices();
-
   return STATUS_SUCCESS;
 }
 
index 2d975ad..300b4a1 100644 (file)
@@ -74,63 +74,6 @@ NdisDestroyLookaheadBufferFromSharedMemory(
 }
 
 \f
-/*
- * @unimplemented
- */
-VOID
-EXPORT
-NdisMoveFromMappedMemory(
-    OUT PVOID   Destination,
-    IN  PVOID   Source,
-    IN  ULONG   Length)
-{
-    UNIMPLEMENTED
-}
-
-\f
-/*
- * @unimplemented
- */
-VOID
-EXPORT
-NdisMoveMappedMemory(
-    OUT PVOID   Destination,
-    IN  PVOID   Source,
-    IN  ULONG   Length)
-{
-    RtlCopyMemory(Destination,Source,Length);
-}
-
-\f
-/*
- * @unimplemented
- */
-VOID
-EXPORT
-NdisMoveToMappedMemory(
-    OUT PVOID   Destination,
-    IN  PVOID   Source,
-    IN  ULONG   Length)
-{
-    UNIMPLEMENTED
-}
-
-\f
-/*
- * @unimplemented
- */
-VOID
-EXPORT
-NdisMUpdateSharedMemory(
-    IN  NDIS_HANDLE             MiniportAdapterHandle,
-    IN  ULONG                   Length,
-    IN  PVOID                   VirtualAddress,
-    IN  NDIS_PHYSICAL_ADDRESS   PhysicalAddress)
-{
-    UNIMPLEMENTED
-}
-
-\f
 /*
  * @implemented
  */
@@ -275,7 +218,8 @@ NdisMAllocateSharedMemory(
 
   NDIS_DbgPrint(MAX_TRACE,("Called.\n"));
 
-  *VirtualAddress = HalAllocateCommonBuffer(Adapter->NdisMiniportBlock.SystemAdapterObject, Length, PhysicalAddress, Cached);
+  *VirtualAddress = Adapter->NdisMiniportBlock.SystemAdapterObject->DmaOperations->AllocateCommonBuffer(
+      Adapter->NdisMiniportBlock.SystemAdapterObject, Length, PhysicalAddress, Cached);
 }
 
 \f
@@ -318,7 +262,8 @@ NdisMFreeSharedMemoryPassive(
 
   ASSERT(KeGetCurrentIrql() == PASSIVE_LEVEL);
 
-  HalFreeCommonBuffer(Memory->AdapterObject, Memory->Length, Memory->PhysicalAddress,
+  Memory->AdapterObject->DmaOperations->FreeCommonBuffer(
+      Memory->AdapterObject, Memory->Length, Memory->PhysicalAddress,
       Memory->VirtualAddress, Memory->Cached);
 
   ExFreePool(Memory);
index d0bdc47..f1d599c 100644 (file)
@@ -12,6 +12,7 @@
  */
 #include <roscfg.h>
 #include "ndissys.h"
+#include "efilter.h"
 
 #ifdef DBG
 #include <buffer.h>
@@ -209,9 +210,9 @@ MiniIndicateData(
               break;
             }
 
-          if(!AdapterBinding->ProtocolBinding->Chars.u4.ReceiveHandler)
+          if(!AdapterBinding->ProtocolBinding->Chars.ReceiveHandler)
             {
-              NDIS_DbgPrint(MIN_TRACE, ("AdapterBinding->ProtocolBinding->Chars.u4.ReceiveHandler was null\n"));
+              NDIS_DbgPrint(MIN_TRACE, ("AdapterBinding->ProtocolBinding->Chars.ReceiveHandler was null\n"));
               break;
             }
 #endif
@@ -219,8 +220,8 @@ MiniIndicateData(
          NDIS_DbgPrint
              (MID_TRACE, 
               ("XXX (%x) %x %x %x %x %x %x %x XXX\n",
-               *AdapterBinding->ProtocolBinding->Chars.u4.ReceiveHandler,
-               AdapterBinding->NdisOpenBlock.ProtocolBindingContext,
+               *AdapterBinding->ProtocolBinding->Chars.ReceiveHandler,
+               AdapterBinding->NdisOpenBlock.NdisCommonOpenBlock.ProtocolBindingContext,
                MacReceiveContext,
                HeaderBuffer,
                HeaderBufferSize,
@@ -229,8 +230,8 @@ MiniIndicateData(
                PacketSize));
 
           /* call the receive handler */
-          (*AdapterBinding->ProtocolBinding->Chars.u4.ReceiveHandler)(
-              AdapterBinding->NdisOpenBlock.ProtocolBindingContext,
+          (*AdapterBinding->ProtocolBinding->Chars.ReceiveHandler)(
+              AdapterBinding->NdisOpenBlock.NdisCommonOpenBlock.ProtocolBindingContext,
               MacReceiveContext,
               HeaderBuffer,
               HeaderBufferSize,
@@ -309,87 +310,6 @@ MiniIndicateReceivePacket(
 }
 
 \f
-VOID STDCALL
-MiniEthReceiveComplete(
-    IN  PETH_FILTER Filter)
-/*
- * FUNCTION: Receive indication complete function for Ethernet devices
- * ARGUMENTS:
- *     Filter = Pointer to Ethernet filter
- */
-{
-  KIRQL OldIrql;
-  PLIST_ENTRY CurrentEntry;
-  PLOGICAL_ADAPTER Adapter;
-  PADAPTER_BINDING AdapterBinding;
-
-  NDIS_DbgPrint(DEBUG_MINIPORT, ("Called.\n"));
-
-  if( !Filter ) return;
-
-  Adapter = (PLOGICAL_ADAPTER)Filter->Miniport;
-
-  NDIS_DbgPrint(MAX_TRACE, ("acquiring miniport block lock\n"));
-  KeAcquireSpinLock(&Adapter->NdisMiniportBlock.Lock, &OldIrql);
-    {
-      CurrentEntry = Adapter->ProtocolListHead.Flink;
-
-      while (CurrentEntry != &Adapter->ProtocolListHead) 
-        {
-          AdapterBinding = CONTAINING_RECORD(CurrentEntry, ADAPTER_BINDING, AdapterListEntry);
-
-          /* see comment in MiniIndicateData */
-          /* KeReleaseSpinLock(&Adapter->NdisMiniportBlock.Lock, OldIrql); */
-
-          (*AdapterBinding->ProtocolBinding->Chars.ReceiveCompleteHandler)(
-              AdapterBinding->NdisOpenBlock.ProtocolBindingContext);
-
-          /* see above */
-          /* KeAcquireSpinLock(&Adapter->NdisMiniportBlock.Lock, &OldIrql); */
-
-          CurrentEntry = CurrentEntry->Flink;
-        }
-    }
-  KeReleaseSpinLock(&Adapter->NdisMiniportBlock.Lock, OldIrql);
-}
-
-\f
-VOID STDCALL
-MiniEthReceiveIndication(
-    IN  PETH_FILTER Filter,
-    IN  NDIS_HANDLE MacReceiveContext,
-    IN  PCHAR       Address,
-    IN  PVOID       HeaderBuffer,
-    IN  UINT        HeaderBufferSize,
-    IN  PVOID       LookaheadBuffer,
-    IN  UINT        LookaheadBufferSize,
-    IN  UINT        PacketSize)
-/*
- * FUNCTION: Receive indication function for Ethernet devices
- * ARGUMENTS:
- *     MiniportAdapter     = Miniport Adapter Handle (PLOGICAL_ADAPTER)
- *     MacReceiveContext   = MAC receive context handle
- *     Address             = Pointer to destination Ethernet address
- *     HeaderBuffer        = Pointer to Ethernet header buffer
- *     HeaderBufferSize    = Size of Ethernet header buffer
- *     LookaheadBuffer     = Pointer to lookahead buffer
- *     LookaheadBufferSize = Size of lookahead buffer
- *     PacketSize          = Total size of received packet
- */
-{
-    /* If there is no filter, then we can't do any more */
-    if( !Filter ) return;
-
-    MiniIndicateData((PLOGICAL_ADAPTER)Filter->Miniport,
-                    MacReceiveContext,
-                    HeaderBuffer,
-                    HeaderBufferSize,
-                    LookaheadBuffer,
-                    LookaheadBufferSize,
-                    PacketSize);
-}
-
-\f
 VOID STDCALL
 MiniResetComplete(
     IN  NDIS_HANDLE MiniportAdapterHandle,
@@ -420,8 +340,8 @@ MiniSendComplete(
 
     AdapterBinding = (PADAPTER_BINDING)Packet->Reserved[0];
 
-    (*AdapterBinding->ProtocolBinding->Chars.u2.SendCompleteHandler)(
-        AdapterBinding->NdisOpenBlock.ProtocolBindingContext,
+    (*AdapterBinding->ProtocolBinding->Chars.SendCompleteHandler)(
+        AdapterBinding->NdisOpenBlock.NdisCommonOpenBlock.ProtocolBindingContext,
         Packet,
         Status);
 }
@@ -442,16 +362,16 @@ MiniTransferDataComplete(
     IN  NDIS_STATUS     Status,
     IN  UINT            BytesTransferred)
 {
-    PLOGICAL_ADAPTER Adapter        = (PLOGICAL_ADAPTER)MiniportAdapterHandle;
-    PADAPTER_BINDING AdapterBinding = Adapter->MiniportAdapterBinding;
+    PADAPTER_BINDING AdapterBinding;
 
     NDIS_DbgPrint(DEBUG_MINIPORT, ("Called.\n"));
 
-    (*AdapterBinding->ProtocolBinding->Chars.u3.TransferDataCompleteHandler)(
-        AdapterBinding->NdisOpenBlock.ProtocolBindingContext,
+    AdapterBinding = (PADAPTER_BINDING)Packet->Reserved[0];
+
+    (*AdapterBinding->ProtocolBinding->Chars.SendCompleteHandler)(
+        AdapterBinding->NdisOpenBlock.NdisCommonOpenBlock.ProtocolBindingContext,
         Packet,
-        Status,
-        BytesTransferred);
+        Status);
 }
 
 \f
@@ -460,7 +380,7 @@ MiniAdapterHasAddress(
     PLOGICAL_ADAPTER Adapter,
     PNDIS_PACKET Packet)
 /*
- * FUNCTION: Determines wether a packet has the same destination address as an adapter
+ * FUNCTION: Determines whether a packet has the same destination address as an adapter
  * ARGUMENTS:
  *     Adapter = Pointer to logical adapter object
  *     Packet  = Pointer to NDIS packet
@@ -546,7 +466,6 @@ MiniLocateDevice(
   KIRQL OldIrql;
   PLIST_ENTRY CurrentEntry;
   PLOGICAL_ADAPTER Adapter = 0;
-  UNICODE_STRING ToCompare;
 
   ASSERT(AdapterName);
 
@@ -570,19 +489,15 @@ MiniLocateDevice(
 
               ASSERT(Adapter);
 
-              NDIS_DbgPrint(DEBUG_MINIPORT, ("AdapterName = %wZ\n", AdapterName));
-              NDIS_DbgPrint(DEBUG_MINIPORT, ("DeviceName = %wZ\n", &Adapter->DeviceName));
-             ToCompare = *AdapterName;
-             if( ToCompare.Length > Adapter->DeviceName.Length )
-                 ToCompare.Length = Adapter->DeviceName.Length;
+              NDIS_DbgPrint(DEBUG_MINIPORT, ("AdapterName = %wZ\n", &AdapterName));
+              NDIS_DbgPrint(DEBUG_MINIPORT, ("DeviceName = %wZ\n", &Adapter->NdisMiniportBlock.MiniportName));
 
-              if (RtlCompareUnicodeString(&ToCompare, &Adapter->DeviceName, TRUE) == 0) 
+              if (RtlCompareUnicodeString(AdapterName, &Adapter->NdisMiniportBlock.MiniportName, TRUE) == 0) 
                 {
                   ReferenceObject(Adapter);
                   break;
                 }
 
-             Adapter = 0;
               CurrentEntry = CurrentEntry->Flink;
             }
         } while (0);
@@ -694,15 +609,13 @@ FASTCALL
 MiniQueueWorkItem(
     PLOGICAL_ADAPTER    Adapter,
     NDIS_WORK_ITEM_TYPE WorkItemType,
-    PVOID               WorkItemContext,
-    NDIS_HANDLE         Initiator)
+    PVOID               WorkItemContext)
 /*
  * FUNCTION: Queues a work item for execution at a later time
  * ARGUMENTS:
  *     Adapter         = Pointer to the logical adapter object to queue work item on
  *     WorkItemType    = Type of work item to queue
  *     WorkItemContext = Pointer to context information for work item
- *     Initiator       = Pointer to ADAPTER_BINDING structure of initiating protocol
  * NOTES:
  *     Adapter lock must be held when called
  * RETURNS:
@@ -715,20 +628,17 @@ MiniQueueWorkItem(
 
   ASSERT(Adapter);
 
+#if 0
   if (Adapter->WorkQueueLevel < NDIS_MINIPORT_WORK_QUEUE_SIZE - 1) 
     {
       Item = &Adapter->WorkQueue[Adapter->WorkQueueLevel];
       Adapter->WorkQueueLevel++;
     } 
   else 
+#endif
     {
       Item = ExAllocatePool(NonPagedPool, sizeof(NDIS_MINIPORT_WORK_ITEM));
-      if (Item) 
-        {
-          /* Set flag so we know that the buffer should be freed when work item is dequeued */
-          Item->Allocated = TRUE;
-        } 
-      else 
+      if (Item == NULL) 
         {
           NDIS_DbgPrint(MIN_TRACE, ("Insufficient resources.\n"));
           return NDIS_STATUS_RESOURCES;
@@ -737,7 +647,6 @@ MiniQueueWorkItem(
 
   Item->WorkItemType    = WorkItemType;
   Item->WorkItemContext = WorkItemContext;
-  Item->Initiator       = Initiator;
 
   /* safe due to adapter lock held */
   Item->Link.Next = NULL;
@@ -763,15 +672,13 @@ FASTCALL
 MiniDequeueWorkItem(
     PLOGICAL_ADAPTER    Adapter,
     NDIS_WORK_ITEM_TYPE *WorkItemType,
-    PVOID               *WorkItemContext,
-    NDIS_HANDLE         *Initiator)
+    PVOID               *WorkItemContext)
 /*
  * FUNCTION: Dequeues a work item from the work queue of a logical adapter
  * ARGUMENTS:
  *     Adapter         = Pointer to the logical adapter object to dequeue work item from
  *     WorkItemType    = Address of buffer for work item type
  *     WorkItemContext = Address of buffer for pointer to context information
- *     Initiator       = Address of buffer for initiator of the work (ADAPTER_BINDING)
  * NOTES:
  *     Adapter lock must be held when called
  * RETURNS:
@@ -794,22 +701,8 @@ MiniDequeueWorkItem(
 
       *WorkItemType    = Item->WorkItemType;
       *WorkItemContext = Item->WorkItemContext;
-      *Initiator       = Item->Initiator;
 
-      if (Item->Allocated) 
-        {
-            ExFreePool(Item);
-        } 
-      else 
-        {
-          Adapter->WorkQueueLevel--;
-#ifdef DBG
-          if (Adapter->WorkQueueLevel < 0) 
-            {
-              NDIS_DbgPrint(MIN_TRACE, ("Adapter->WorkQueueLevel is < 0 (should be >= 0).\n"));
-            }
-#endif
-        }
+      ExFreePool(Item);
 
       return NDIS_STATUS_SUCCESS;
     }
@@ -880,18 +773,15 @@ VOID STDCALL MiniportDpc(
   NDIS_STATUS NdisStatus;
   PVOID WorkItemContext;
   NDIS_WORK_ITEM_TYPE WorkItemType;
-  PADAPTER_BINDING AdapterBinding;
   PLOGICAL_ADAPTER Adapter = GET_LOGICAL_ADAPTER(DeferredContext);
 
   NDIS_DbgPrint(DEBUG_MINIPORT, ("Called.\n"));
 
   /* XXX is adapter lock held here?  should be... */
-  NdisStatus = MiniDequeueWorkItem(Adapter, &WorkItemType, &WorkItemContext, (PNDIS_HANDLE)&AdapterBinding);
+  NdisStatus = MiniDequeueWorkItem(Adapter, &WorkItemType, &WorkItemContext);
 
   if (NdisStatus == NDIS_STATUS_SUCCESS) 
     {
-      Adapter->MiniportAdapterBinding = AdapterBinding;
-
       switch (WorkItemType) 
         {
           case NdisWorkItemSend:
@@ -918,12 +808,13 @@ VOID STDCALL MiniportDpc(
               {
                 NDIS_DbgPrint(MAX_TRACE, ("Calling miniport's Send handler\n"));
 
-                NdisStatus = (*Adapter->Miniport->Chars.u1.SendHandler)(
+                NdisStatus = (*Adapter->Miniport->Chars.SendHandler)(
                     Adapter->NdisMiniportBlock.MiniportAdapterContext, (PNDIS_PACKET)WorkItemContext, 0);
 
                 NDIS_DbgPrint(MAX_TRACE, ("back from miniport's Send handler\n"));
 
-                if (NdisStatus != NDIS_STATUS_PENDING) 
+                if ((NdisStatus != NDIS_STATUS_PENDING) &&
+                    !(Adapter->NdisMiniportBlock.Flags & NDIS_ATTRIBUTE_DESERIALIZE)) 
                     MiniSendComplete((NDIS_HANDLE)Adapter, (PNDIS_PACKET)WorkItemContext, NdisStatus);
               }
 
@@ -1042,6 +933,7 @@ NdisMFlushLog(
     UNIMPLEMENTED
 }
 
+#undef NdisMIndicateStatus
 
 /*
  * @unimplemented
@@ -1057,6 +949,7 @@ NdisMIndicateStatus(
     UNIMPLEMENTED
 }
 
+#undef NdisMIndicateStatusComplete
 
 /*
  * @unimplemented
@@ -1153,6 +1046,8 @@ NdisInitializeWrapper(
   *NdisWrapperHandle = Miniport;
 }
 
+#undef NdisMQueryInformationComplete
+
 \f
 /*
  * @implemented
@@ -1163,15 +1058,7 @@ NdisMQueryInformationComplete(
     IN  NDIS_HANDLE MiniportAdapterHandle,
     IN  NDIS_STATUS Status)
 {
-  PLOGICAL_ADAPTER Adapter        = GET_LOGICAL_ADAPTER(MiniportAdapterHandle);
-  PADAPTER_BINDING AdapterBinding = (PADAPTER_BINDING)Adapter->MiniportAdapterBinding;
-
-  NDIS_DbgPrint(MAX_TRACE, ("Called.\n"));
-
-  (*AdapterBinding->ProtocolBinding->Chars.RequestCompleteHandler)(
-      AdapterBinding->NdisOpenBlock.ProtocolBindingContext,
-      Adapter->NdisMiniportBlock.MediaRequest,
-      Status);
+  (*((PNDIS_MINIPORT_BLOCK)(MiniportAdapterHandle))->QueryCompleteHandler)(MiniportAdapterHandle, Status);
 }
 
 \f
@@ -1301,9 +1188,9 @@ DoQueries(
       return NdisStatus;
     }
 
-  Adapter->MaxLookaheadLength = *((PULONG)Adapter->QueryBuffer);
+  Adapter->NdisMiniportBlock.MaximumLookahead = *((PULONG)Adapter->QueryBuffer);
 
-  NDIS_DbgPrint(DEBUG_MINIPORT, ("MaxLookaheadLength (0x%X).\n", Adapter->MaxLookaheadLength));
+  NDIS_DbgPrint(DEBUG_MINIPORT, ("MaxLookaheadLength (0x%X).\n", Adapter->NdisMiniportBlock.MaximumLookahead));
 
   /* Get current lookahead buffer size of adapter */
   NdisStatus = MiniQueryInformation(Adapter, OID_GEN_CURRENT_LOOKAHEAD, 0, &BytesWritten);
@@ -1314,13 +1201,13 @@ DoQueries(
       return NdisStatus;
     }
 
-  Adapter->CurLookaheadLength = *((PULONG)Adapter->QueryBuffer);
+  Adapter->NdisMiniportBlock.CurrentLookahead = *((PULONG)Adapter->QueryBuffer);
 
-  NDIS_DbgPrint(DEBUG_MINIPORT, ("CurLookaheadLength (0x%X).\n", Adapter->CurLookaheadLength));
+  NDIS_DbgPrint(DEBUG_MINIPORT, ("CurLookaheadLength (0x%X).\n", Adapter->NdisMiniportBlock.CurrentLookahead));
 
-  if (Adapter->MaxLookaheadLength != 0) 
+  if (Adapter->NdisMiniportBlock.MaximumLookahead != 0) 
     {
-      Adapter->LookaheadLength = Adapter->MaxLookaheadLength + Adapter->MediumHeaderSize;
+      Adapter->LookaheadLength = Adapter->NdisMiniportBlock.MaximumLookahead + Adapter->MediumHeaderSize;
       Adapter->LookaheadBuffer = ExAllocatePool(NonPagedPool, Adapter->LookaheadLength);
 
       if (!Adapter->LookaheadBuffer)
@@ -1331,195 +1218,354 @@ DoQueries(
 }
 
 \f
-VOID
-NdisIStartAdapter(
-    UNICODE_STRING *DeviceName,
-    PDEVICE_OBJECT PhysicalDeviceObject,
-    PMINIPORT_DRIVER Miniport
-)
+NTSTATUS
+STDCALL
+NdisIForwardIrpAndWaitCompletionRoutine(
+    PDEVICE_OBJECT Fdo,
+    PIRP Irp,
+    PVOID Context)
+{
+  PKEVENT Event = Context;
+
+  if (Irp->PendingReturned)
+    KeSetEvent(Event, IO_NO_INCREMENT, FALSE);
+
+  return STATUS_MORE_PROCESSING_REQUIRED;
+}
+
+\f
+NTSTATUS
+STDCALL
+NdisIForwardIrpAndWait(PLOGICAL_ADAPTER Adapter, PIRP Irp)
+{
+  KEVENT Event;
+  NTSTATUS Status;
+
+  KeInitializeEvent(&Event, NotificationEvent, FALSE);
+  IoCopyCurrentIrpStackLocationToNext(Irp);
+  IoSetCompletionRoutine(Irp, NdisIForwardIrpAndWaitCompletionRoutine, &Event, TRUE, TRUE, TRUE);
+  Status = IoCallDriver(Adapter->NdisMiniportBlock.NextDeviceObject, Irp);
+  if (Status == STATUS_PENDING)
+    {
+      KeWaitForSingleObject(&Event, Executive, KernelMode, FALSE, NULL);
+      Status = Irp->IoStatus.Status;
+    }
+  return Status;
+}
+
+\f
+NTSTATUS
+STDCALL
+NdisIPnPStartDevice(
+    IN PDEVICE_OBJECT DeviceObject,
+    PIRP Irp)
 /*
- * FUNCTION: Start an adapter
+ * FUNCTION: Handle the PnP start device event
  * ARGUMENTS:
- *     DeviceName: Name of device to start
- *     PhysicalDeviceObject: PDO for our adapter
- * NOTES:
- * TODO:
- *     - verify that all resources are properly freed on success & failure
- *     - break up this 250-line function
+ *     DeviceObejct = Functional Device Object
+ *     Irp          = IRP_MN_START_DEVICE I/O request packet
+ * RETURNS:
+ *     Status of operation
  */
 {
+  PIO_STACK_LOCATION Stack = IoGetCurrentIrpStackLocation(Irp);
+  PLOGICAL_ADAPTER Adapter = (PLOGICAL_ADAPTER)DeviceObject->DeviceExtension;
+  NDIS_WRAPPER_CONTEXT WrapperContext;
   NDIS_STATUS NdisStatus;
   NDIS_STATUS OpenErrorStatus;
   NTSTATUS Status;
   UINT SelectedMediumIndex = 0;
-  PLOGICAL_ADAPTER Adapter = 0;
   NDIS_OID AddressOID;
-  BOOLEAN MemError = FALSE;
-  KIRQL OldIrql;
+  BOOLEAN Success;
+  ULONG ResourceCount;
+  ULONG ResourceListSize;
+  UNICODE_STRING ParamName;
+  PNDIS_CONFIGURATION_PARAMETER ConfigParam;
+  NDIS_HANDLE ConfigHandle;
   ULONG Size;
-  PWRAPPER_CONTEXT WrapperContext;
+  KIRQL OldIrql;
 
-  Adapter = ExAllocatePool(NonPagedPool, sizeof(LOGICAL_ADAPTER));
-  if (!Adapter)
+  /*
+   * Prepare wrapper context used by HW and configuration routines.
+   */
+  
+  Status = IoOpenDeviceRegistryKey(
+    Adapter->NdisMiniportBlock.PhysicalDeviceObject, PLUGPLAY_REGKEY_DRIVER,
+    KEY_ALL_ACCESS, &WrapperContext.RegistryHandle);
+  if (!NT_SUCCESS(Status))
     {
-      NDIS_DbgPrint(MIN_TRACE, ("Insufficient resources.\n"));
-      return;
+      NDIS_DbgPrint(MIN_TRACE,("failed to open adapter-specific reg key\n"));
+      return Status;
     }
 
-  /* This is very important */
-  RtlZeroMemory(Adapter, sizeof(LOGICAL_ADAPTER));
+  NDIS_DbgPrint(MAX_TRACE, ("opened device reg key\n"));
+
+  WrapperContext.DeviceObject = Adapter->NdisMiniportBlock.DeviceObject;
+
+  /*
+   * Store the adapter resources used by HW routines such as
+   * NdisMQueryAdapterResources.
+   */
 
-  Adapter->DeviceName.Buffer = ExAllocatePool(NonPagedPool, DeviceName->Length);
-  if (!Adapter->DeviceName.Buffer)
+  if (Stack->Parameters.StartDevice.AllocatedResources != NULL &&
+      Stack->Parameters.StartDevice.AllocatedResourcesTranslated != NULL)
     {
-      NDIS_DbgPrint(MIN_TRACE,("Insufficient memory\n"));
-      ExFreePool(Adapter);
-      return;
+      ResourceCount = Stack->Parameters.StartDevice.AllocatedResources->List[0].
+                      PartialResourceList.Count;
+      ResourceListSize = 
+        FIELD_OFFSET(CM_RESOURCE_LIST, List[0].PartialResourceList.
+                     PartialDescriptors[ResourceCount]);
+
+      Adapter->NdisMiniportBlock.AllocatedResources =
+        ExAllocatePool(PagedPool, ResourceListSize);
+      if (Adapter->NdisMiniportBlock.AllocatedResources == NULL)
+        {
+          return STATUS_INSUFFICIENT_RESOURCES;
+        }
+
+      Adapter->NdisMiniportBlock.AllocatedResourcesTranslated =
+        ExAllocatePool(PagedPool, ResourceListSize);
+      if (Adapter->NdisMiniportBlock.AllocatedResourcesTranslated == NULL)
+        {
+          ExFreePool(Adapter->NdisMiniportBlock.AllocatedResources);
+          Adapter->NdisMiniportBlock.AllocatedResources = NULL;
+          return STATUS_INSUFFICIENT_RESOURCES;
+        }
+
+      RtlCopyMemory(Adapter->NdisMiniportBlock.AllocatedResources,
+                    Stack->Parameters.StartDevice.AllocatedResources,
+                    ResourceListSize);
+                
+      RtlCopyMemory(Adapter->NdisMiniportBlock.AllocatedResourcesTranslated,
+                    Stack->Parameters.StartDevice.AllocatedResourcesTranslated,
+                    ResourceListSize);
     }
-  Adapter->DeviceName.MaximumLength = DeviceName->Length;
-  RtlCopyUnicodeString(&Adapter->DeviceName, DeviceName);
 
-  WrapperContext = ExAllocatePool(NonPagedPool, sizeof(WRAPPER_CONTEXT));
-  if (!WrapperContext)
+  /*
+   * Store the Bus Type, Bus Number and Slot information. It's used by
+   * the hardware routines then.
+   */
+    
+  NdisOpenConfiguration(&NdisStatus, &ConfigHandle, (NDIS_HANDLE)&WrapperContext);
+
+  Size = sizeof(ULONG);
+  Status = IoGetDeviceProperty(Adapter->NdisMiniportBlock.PhysicalDeviceObject,
+                               DevicePropertyLegacyBusType, Size,
+                               &Adapter->NdisMiniportBlock.BusType, &Size);
+  if (!NT_SUCCESS(Status) || Adapter->NdisMiniportBlock.BusType == -1)
     {
-      NDIS_DbgPrint(MIN_TRACE,("Insufficient memory\n"));
-      ExFreePool(Adapter->DeviceName.Buffer);
-      ExFreePool(Adapter);
-      return;
+      NdisInitUnicodeString(&ParamName, L"BusType");
+      NdisReadConfiguration(&NdisStatus, &ConfigParam, ConfigHandle,
+                            &ParamName, NdisParameterInteger);
+      if (NdisStatus == NDIS_STATUS_SUCCESS)
+        Adapter->NdisMiniportBlock.BusType = ConfigParam->ParameterData.IntegerData;
+      else
+        Adapter->NdisMiniportBlock.BusType = Isa;
     }
-  WrapperContext->DeviceObject = PhysicalDeviceObject;
 
-  NDIS_DbgPrint(MAX_TRACE, ("creating device %wZ\n", DeviceName));
-
-  Status = IoCreateDevice(Miniport->DriverObject, 0, &Adapter->DeviceName, FILE_DEVICE_PHYSICAL_NETCARD,
-      0, FALSE, &Adapter->NdisMiniportBlock.DeviceObject);
-  if (!NT_SUCCESS(Status)) 
+  Status = IoGetDeviceProperty(Adapter->NdisMiniportBlock.PhysicalDeviceObject,
+                               DevicePropertyBusNumber, Size,
+                               &Adapter->NdisMiniportBlock.BusNumber, &Size);
+  if (!NT_SUCCESS(Status) || Adapter->NdisMiniportBlock.BusNumber == -1)
     {
-      NDIS_DbgPrint(MIN_TRACE, ("Could not create device object.\n"));
-      ExFreePool(WrapperContext);
-      ExFreePool(Adapter->DeviceName.Buffer);
-      ExFreePool(Adapter);
-      return;
+      NdisInitUnicodeString(&ParamName, L"BusNumber");
+      NdisReadConfiguration(&NdisStatus, &ConfigParam, ConfigHandle,
+                            &ParamName, NdisParameterInteger);
+      if (NdisStatus == NDIS_STATUS_SUCCESS)
+        Adapter->NdisMiniportBlock.BusNumber = ConfigParam->ParameterData.IntegerData;
+      else
+        Adapter->NdisMiniportBlock.BusNumber = 0;
     }
+  WrapperContext.BusNumber = Adapter->NdisMiniportBlock.BusNumber;
 
-  Status = IoOpenDeviceRegistryKey(PhysicalDeviceObject, PLUGPLAY_REGKEY_DRIVER,
-                                   KEY_ALL_ACCESS, &WrapperContext->DeviceKeyHandle);
-  if(Status != STATUS_SUCCESS)
+  Status = IoGetDeviceProperty(Adapter->NdisMiniportBlock.PhysicalDeviceObject,
+                               DevicePropertyAddress, Size,
+                               &Adapter->NdisMiniportBlock.SlotNumber, &Size);
+  if (!NT_SUCCESS(Status) || Adapter->NdisMiniportBlock.SlotNumber == -1)
     {
-      NDIS_DbgPrint(MIN_TRACE,("failed to open adapter-specific reg key\n"));
-      ExFreePool(WrapperContext);
-      ExFreePool(Adapter->DeviceName.Buffer);
-      ExFreePool(Adapter);
-      return;
+      NdisInitUnicodeString(&ParamName, L"SlotNumber");
+      NdisReadConfiguration(&NdisStatus, &ConfigParam, ConfigHandle,
+                            &ParamName, NdisParameterInteger);
+      if (NdisStatus == NDIS_STATUS_SUCCESS)
+        Adapter->NdisMiniportBlock.SlotNumber = ConfigParam->ParameterData.IntegerData;
+      else
+        Adapter->NdisMiniportBlock.SlotNumber = 0;
     }
 
-  NDIS_DbgPrint(MAX_TRACE, ("opened device reg key\n"));
+  NdisCloseConfiguration(ConfigHandle);
 
-  NDIS_DbgPrint(MAX_TRACE, ("acquiring miniport block lock\n"));
-  KeInitializeSpinLock(&Adapter->NdisMiniportBlock.Lock);
-  InitializeListHead(&Adapter->ProtocolListHead);
-  Adapter->RefCount = 1;
-  Adapter->Miniport = Miniport;
+  /*
+   * Call MiniportInitialize.
+   */
 
-  /* FIXME: Check return values. */
-  Size = sizeof(ULONG);
-  IoGetDeviceProperty(PhysicalDeviceObject, DevicePropertyLegacyBusType,
-                      Size, &Adapter->BusType, &Size);
-  IoGetDeviceProperty(PhysicalDeviceObject, DevicePropertyBusNumber,
-                      Size, &Adapter->BusNumber, &Size);
-  IoGetDeviceProperty(PhysicalDeviceObject, DevicePropertyAddress,
-                      Size, &Adapter->SlotNumber, &Size);
-  WrapperContext->BusNumber = Adapter->BusNumber;
+  NDIS_DbgPrint(MID_TRACE, ("calling MiniportInitialize\n"));
+  NdisStatus = (*Adapter->Miniport->Chars.InitializeHandler)(
+    &OpenErrorStatus, &SelectedMediumIndex, &MediaArray[0],
+    MEDIA_ARRAY_SIZE, Adapter, (NDIS_HANDLE)&WrapperContext);
+
+  ZwClose(WrapperContext.RegistryHandle);
+
+  if (NdisStatus != NDIS_STATUS_SUCCESS ||
+      SelectedMediumIndex >= MEDIA_ARRAY_SIZE) 
+    {
+      NDIS_DbgPrint(MIN_TRACE, ("MiniportInitialize() failed for an adapter.\n"));
+      return (NTSTATUS)NdisStatus;
+    }
 
   /* Set handlers (some NDIS macros require these) */
 
-  Adapter->NdisMiniportBlock.EthRxCompleteHandler = MiniEthReceiveComplete;
-  Adapter->NdisMiniportBlock.EthRxIndicateHandler = MiniEthReceiveIndication;
+  Adapter->NdisMiniportBlock.EthRxCompleteHandler = EthFilterDprIndicateReceiveComplete;
+  Adapter->NdisMiniportBlock.EthRxIndicateHandler = EthFilterDprIndicateReceive;
   Adapter->NdisMiniportBlock.SendCompleteHandler  = MiniSendComplete;
   Adapter->NdisMiniportBlock.SendResourcesHandler = MiniSendResourcesAvailable;
   Adapter->NdisMiniportBlock.ResetCompleteHandler = MiniResetComplete;
   Adapter->NdisMiniportBlock.TDCompleteHandler    = MiniTransferDataComplete;
   Adapter->NdisMiniportBlock.PacketIndicateHandler= MiniIndicateReceivePacket;
 
-  KeInitializeDpc(&Adapter->MiniportDpc, MiniportDpc, (PVOID)Adapter);
-  
+  Adapter->NdisMiniportBlock.MediaType = MediaArray[SelectedMediumIndex];
+
+  switch (Adapter->NdisMiniportBlock.MediaType) 
+    {
+      case NdisMedium802_3:
+        Adapter->MediumHeaderSize = 14;       /* XXX figure out what to do about LLC */
+        AddressOID = OID_802_3_CURRENT_ADDRESS;
+        Adapter->AddressLength = ETH_LENGTH_OF_ADDRESS;
+        NdisStatus = DoQueries(Adapter, AddressOID);
+        if (NdisStatus == NDIS_STATUS_SUCCESS)
+          {
+            Success = EthCreateFilter(32, /* FIXME: Query this from miniport. */
+                                      Adapter->Address.Type.Medium802_3,
+                                      &Adapter->NdisMiniportBlock.FilterDbs.EthDB);
+            if (Success)
+              Adapter->NdisMiniportBlock.FilterDbs.EthDB->Miniport = (PNDIS_MINIPORT_BLOCK)Adapter;
+            else
+              NdisStatus = NDIS_STATUS_RESOURCES;
+          }
+        break;
+
+      default:
+        /* FIXME: Support other types of media */
+        NDIS_DbgPrint(MIN_TRACE, ("error: unsupported media\n"));
+        ASSERT(FALSE);
+        KeReleaseSpinLock(&Adapter->NdisMiniportBlock.Lock, OldIrql);
+        return STATUS_UNSUCCESSFUL;
+    }
+
+  if (!Success || NdisStatus != NDIS_STATUS_SUCCESS) 
+    {
+      NDIS_DbgPrint(MAX_TRACE, ("couldn't create filter (%x)\n", NdisStatus));
+      if (Adapter->LookaheadBuffer)
+        {
+          ExFreePool(Adapter->LookaheadBuffer);
+          Adapter->LookaheadBuffer = NULL;
+        }
+      return (NTSTATUS)NdisStatus;
+    }
+
+  Adapter->NdisMiniportBlock.OldPnPDeviceState = Adapter->NdisMiniportBlock.PnPDeviceState;
+  Adapter->NdisMiniportBlock.PnPDeviceState = NdisPnPDeviceStarted;
+
   /* Put adapter in adapter list for this miniport */
-  ExInterlockedInsertTailList(&Miniport->AdapterListHead, &Adapter->MiniportListEntry, &Miniport->Lock);
+  ExInterlockedInsertTailList(&Adapter->Miniport->AdapterListHead, &Adapter->MiniportListEntry, &Adapter->Miniport->Lock);
 
   /* Put adapter in global adapter list */
   ExInterlockedInsertTailList(&AdapterListHead, &Adapter->ListEntry, &AdapterListLock);
 
-  /* Call MiniportInitialize */
-  NDIS_DbgPrint(MID_TRACE, ("calling MiniportInitialize\n"));
-  NdisStatus = (*Miniport->Chars.InitializeHandler)( &OpenErrorStatus, &SelectedMediumIndex, &MediaArray[0],
-      MEDIA_ARRAY_SIZE, Adapter, WrapperContext);
-
-  ZwClose(WrapperContext->DeviceKeyHandle);
-  ExFreePool(WrapperContext);
+  return STATUS_SUCCESS;
+}
 
-  if ((NdisStatus == NDIS_STATUS_SUCCESS) && (SelectedMediumIndex < MEDIA_ARRAY_SIZE)) 
-    {
-      NDIS_DbgPrint(MID_TRACE,("successful return from MiniportInitialize\n"));
+\f
+NTSTATUS
+STDCALL
+NdisIPnPStopDevice(
+    IN PDEVICE_OBJECT DeviceObject,
+    PIRP Irp)
+/*
+ * FUNCTION: Handle the PnP stop device event
+ * ARGUMENTS:
+ *     DeviceObejct = Functional Device Object
+ *     Irp          = IRP_MN_STOP_DEVICE I/O request packet
+ * RETURNS:
+ *     Status of operation
+ */
+{
+  PLOGICAL_ADAPTER Adapter = (PLOGICAL_ADAPTER)DeviceObject->DeviceExtension;
+  KIRQL OldIrql;
 
-      Adapter->NdisMiniportBlock.MediaType = MediaArray[SelectedMediumIndex];
+  /* Remove adapter from adapter list for this miniport */
+  KeAcquireSpinLock(&Adapter->Miniport->Lock, &OldIrql);
+  RemoveEntryList(&Adapter->MiniportListEntry);
+  KeReleaseSpinLock(&Adapter->Miniport->Lock, OldIrql);
 
-      switch (Adapter->NdisMiniportBlock.MediaType) 
-        {
-        case NdisMedium802_3:
-          Adapter->MediumHeaderSize = 14;       /* XXX figure out what to do about LLC */
-          AddressOID = OID_802_3_CURRENT_ADDRESS;
-          Adapter->AddressLength = ETH_LENGTH_OF_ADDRESS;
+  /* Remove adapter from global adapter list */
+  KeAcquireSpinLock(&AdapterListLock, &OldIrql);
+  RemoveEntryList(&Adapter->ListEntry);
+  KeReleaseSpinLock(&AdapterListLock, OldIrql);
 
-          Adapter->NdisMiniportBlock.FilterDbs.u.EthDB = ExAllocatePool(NonPagedPool, sizeof(ETH_FILTER));
-          if (Adapter->NdisMiniportBlock.FilterDbs.u.EthDB) 
-            {
-              RtlZeroMemory(Adapter->NdisMiniportBlock.FilterDbs.u.EthDB, sizeof(ETH_FILTER));
-              Adapter->NdisMiniportBlock.FilterDbs.u.EthDB->Miniport = (PNDIS_MINIPORT_BLOCK)Adapter;
-            } 
-          else
-            MemError = TRUE;
-
-          break;
-
-        default:
-          /* FIXME: Support other types of media */
-          NDIS_DbgPrint(MIN_TRACE, ("error: unsupported media\n"));
-          ExFreePool(Adapter);
-          ASSERT(FALSE);
-         KeReleaseSpinLock(&Adapter->NdisMiniportBlock.Lock, OldIrql);
-          return;
-        }
+  (*Adapter->Miniport->Chars.HaltHandler)(Adapter);
 
-      NdisStatus = DoQueries(Adapter, AddressOID);
+  if (Adapter->LookaheadBuffer)
+    {
+      ExFreePool(Adapter->LookaheadBuffer);
+      Adapter->LookaheadBuffer = NULL;
     }
-
-  if ((MemError) || (NdisStatus != NDIS_STATUS_SUCCESS) || (SelectedMediumIndex >= MEDIA_ARRAY_SIZE)) 
+  if (Adapter->NdisMiniportBlock.AllocatedResources)
+    {
+      ExFreePool(Adapter->NdisMiniportBlock.AllocatedResources);
+      Adapter->NdisMiniportBlock.AllocatedResources = NULL;
+    }
+  if (Adapter->NdisMiniportBlock.AllocatedResourcesTranslated)
     {
-      NDIS_DbgPrint(MAX_TRACE, ("return from MiniportInitialize: NdisStatus 0x%x, SelectedMediumIndex 0x%x\n",
-          NdisStatus, SelectedMediumIndex));
+      ExFreePool(Adapter->NdisMiniportBlock.AllocatedResourcesTranslated);
+      Adapter->NdisMiniportBlock.AllocatedResourcesTranslated = NULL;
+    }
 
-      /* Remove adapter from adapter list for this miniport */
-      KeAcquireSpinLock(&Miniport->Lock, &OldIrql);
-      RemoveEntryList(&Adapter->MiniportListEntry);
-      KeReleaseSpinLock(&Miniport->Lock, OldIrql);
+  Adapter->NdisMiniportBlock.OldPnPDeviceState = Adapter->NdisMiniportBlock.PnPDeviceState;
+  Adapter->NdisMiniportBlock.PnPDeviceState = NdisPnPDeviceStopped;
 
-      /* Remove adapter from global adapter list */
-      KeAcquireSpinLock(&AdapterListLock, &OldIrql);
-      RemoveEntryList(&Adapter->ListEntry);
-      KeReleaseSpinLock(&AdapterListLock, OldIrql);
+  return STATUS_SUCCESS;
+}
 
-      if (Adapter->LookaheadBuffer)
-        ExFreePool(Adapter->LookaheadBuffer);
+\f
+NTSTATUS
+STDCALL
+NdisIDispatchPnp(
+    IN PDEVICE_OBJECT DeviceObject,
+    PIRP Irp)
+{
+  PIO_STACK_LOCATION Stack = IoGetCurrentIrpStackLocation(Irp);
+  PLOGICAL_ADAPTER Adapter = (PLOGICAL_ADAPTER)DeviceObject->DeviceExtension;
+  NTSTATUS Status;
 
-      IoDeleteDevice(Adapter->NdisMiniportBlock.DeviceObject);
-      ExFreePool(Adapter);
-      NDIS_DbgPrint(MIN_TRACE, ("MiniportInitialize() failed for an adapter.\n"));
-    }
-  else
+  switch (Stack->MinorFunction)
     {
-      IoAttachDeviceToDeviceStack(Adapter->NdisMiniportBlock.DeviceObject,
-                                  PhysicalDeviceObject);
+      case IRP_MN_START_DEVICE:
+        Status = NdisIForwardIrpAndWait(Adapter, Irp);
+        if (NT_SUCCESS(Status) && NT_SUCCESS(Irp->IoStatus.Status))
+          {
+            Status = NdisIPnPStartDevice(DeviceObject, Irp);
+          }
+        Irp->IoStatus.Status = Status;
+        IoCompleteRequest(Irp, IO_NO_INCREMENT);
+        break;
+
+      case IRP_MN_STOP_DEVICE:
+        break;
+        Status = NdisIForwardIrpAndWait(Adapter, Irp);
+        if (NT_SUCCESS(Status) && NT_SUCCESS(Irp->IoStatus.Status))
+          {
+            Status = NdisIPnPStopDevice(DeviceObject, Irp);
+          }
+        Irp->IoStatus.Status = Status;
+        IoCompleteRequest(Irp, IO_NO_INCREMENT);
+        break;
+
+      default:
+        IoSkipCurrentIrpStackLocation(Irp);
+        return IoCallDriver(Adapter->NdisMiniportBlock.NextDeviceObject, Irp);
     }
+
+  return Status;
 }
 
 \f
@@ -1527,10 +1573,9 @@ NTSTATUS
 STDCALL
 NdisIAddDevice(
     IN PDRIVER_OBJECT DriverObject,
-    IN PDEVICE_OBJECT PhysicalDeviceObject
-)
+    IN PDEVICE_OBJECT PhysicalDeviceObject)
 /*
- * FUNCTION: Start an adapter found using PnP
+ * FUNCTION: Create a device for an adapter found using PnP
  * ARGUMENTS:
  *     DriverObject         = Pointer to the miniport driver object
  *     PhysicalDeviceObject = Pointer to the PDO for our adapter
@@ -1544,6 +1589,8 @@ NdisIAddDevice(
   ULONG DriverKeyLength;
   RTL_QUERY_REGISTRY_TABLE QueryTable[2];
   UNICODE_STRING ExportName;
+  PDEVICE_OBJECT DeviceObject;
+  PLOGICAL_ADAPTER Adapter;
   NTSTATUS Status;
 
   /*
@@ -1613,17 +1660,54 @@ NdisIAddDevice(
 
   Status = RtlQueryRegistryValues(RTL_REGISTRY_CONTROL, LinkageKeyBuffer,
                                   QueryTable, NULL, NULL);
+  ExFreePool(LinkageKeyBuffer);
   if (!NT_SUCCESS(Status))
     {
       NDIS_DbgPrint(DEBUG_MINIPORT, ("Can't get miniport device name. (%x)\n", Status));
-      ExFreePool(LinkageKeyBuffer);
       return Status;
     }
-  ExFreePool(LinkageKeyBuffer);
 
-  NdisIStartAdapter(&ExportName, PhysicalDeviceObject, Miniport);
-  RtlFreeUnicodeString(&ExportName);
+  /*
+   * Create the device object.
+   */
+  
+  NDIS_DbgPrint(MAX_TRACE, ("creating device %wZ\n", &ExportName));
+
+  Status = IoCreateDevice(Miniport->DriverObject, sizeof(LOGICAL_ADAPTER),
+    &ExportName, FILE_DEVICE_PHYSICAL_NETCARD,
+    0, FALSE, &DeviceObject);
+  if (!NT_SUCCESS(Status)) 
+    {
+      NDIS_DbgPrint(MIN_TRACE, ("Could not create device object.\n"));
+      RtlFreeUnicodeString(&ExportName);
+      return Status;
+    }
+
+  /*
+   * Initialize the adapter structure.
+   */
+
+  Adapter = (PLOGICAL_ADAPTER)DeviceObject->DeviceExtension;
+  KeInitializeSpinLock(&Adapter->NdisMiniportBlock.Lock);
+  InitializeListHead(&Adapter->ProtocolListHead);
+  Adapter->RefCount = 1;
+  Adapter->Miniport = Miniport;
+
+  Adapter->NdisMiniportBlock.MiniportName = ExportName;
+
+  Adapter->NdisMiniportBlock.DeviceObject = DeviceObject;
+  Adapter->NdisMiniportBlock.PhysicalDeviceObject = PhysicalDeviceObject;
+  Adapter->NdisMiniportBlock.NextDeviceObject =
+    IoAttachDeviceToDeviceStack(Adapter->NdisMiniportBlock.DeviceObject,
+                                PhysicalDeviceObject);
+
+  Adapter->NdisMiniportBlock.OldPnPDeviceState = 0;
+  Adapter->NdisMiniportBlock.PnPDeviceState = NdisPnPDeviceAdded;
+                                
+  KeInitializeDpc(&Adapter->MiniportDpc, MiniportDpc, (PVOID)Adapter);
 
+  DeviceObject->Flags &= ~DO_DEVICE_INITIALIZING;
+  
   return STATUS_SUCCESS;
 }
 
@@ -1657,15 +1741,15 @@ NdisMRegisterMiniport(
   switch (MiniportCharacteristics->MajorNdisVersion) 
     {
       case 0x03:
-        MinSize = sizeof(NDIS30_MINIPORT_CHARACTERISTICS_S);
+        MinSize = sizeof(NDIS30_MINIPORT_CHARACTERISTICS);
         break;
 
       case 0x04:
-        MinSize = sizeof(NDIS40_MINIPORT_CHARACTERISTICS_S);
+        MinSize = sizeof(NDIS40_MINIPORT_CHARACTERISTICS);
         break;
 
       case 0x05:
-        MinSize = sizeof(NDIS50_MINIPORT_CHARACTERISTICS_S);
+        MinSize = sizeof(NDIS50_MINIPORT_CHARACTERISTICS);
         break;
 
       default:
@@ -1692,7 +1776,7 @@ NdisMRegisterMiniport(
 
   if (MiniportCharacteristics->MajorNdisVersion == 0x03) 
     {
-      if (!MiniportCharacteristics->u1.SendHandler) 
+      if (!MiniportCharacteristics->SendHandler) 
         {
           NDIS_DbgPrint(DEBUG_MINIPORT, ("Bad miniport characteristics.\n"));
           return NDIS_STATUS_BAD_CHARACTERISTICS;
@@ -1701,7 +1785,7 @@ NdisMRegisterMiniport(
   else if (MiniportCharacteristics->MajorNdisVersion >= 0x04) 
     {
       /* NDIS 4.0+ */
-      if ((!MiniportCharacteristics->u1.SendHandler) &&
+      if ((!MiniportCharacteristics->SendHandler) &&
           (!MiniportCharacteristics->SendPacketsHandler)) 
         {
           NDIS_DbgPrint(DEBUG_MINIPORT, ("Bad miniport characteristics.\n"));
@@ -1727,6 +1811,8 @@ NdisMRegisterMiniport(
     }
 
   *MiniportPtr = Miniport;
+
+  Miniport->DriverObject->MajorFunction[IRP_MJ_PNP] = NdisIDispatchPnp;
   Miniport->DriverObject->DriverExtension->AddDevice = NdisIAddDevice;
 
   return NDIS_STATUS_SUCCESS;
@@ -1746,6 +1832,8 @@ NdisMResetComplete(
   MiniResetComplete(MiniportAdapterHandle, Status, AddressingReset);
 }
 
+#undef NdisMSendComplete
+
 \f
 /*
  * @implemented
@@ -1795,6 +1883,8 @@ NdisMTransferDataComplete(
   MiniTransferDataComplete(MiniportAdapterHandle, Packet, Status, BytesTransferred);
 }
 
+#undef NdisMSetInformationComplete
+
 \f
 /*
  * @implemented
@@ -1805,17 +1895,11 @@ NdisMSetInformationComplete(
     IN  NDIS_HANDLE MiniportAdapterHandle,
     IN  NDIS_STATUS Status)
 {
-  PLOGICAL_ADAPTER Adapter        = GET_LOGICAL_ADAPTER(MiniportAdapterHandle);
-  PADAPTER_BINDING AdapterBinding = (PADAPTER_BINDING)Adapter->MiniportAdapterBinding;
-
-  NDIS_DbgPrint(MAX_TRACE, ("Called.\n"));
-
-  (*AdapterBinding->ProtocolBinding->Chars.RequestCompleteHandler)(
-      AdapterBinding->NdisOpenBlock.ProtocolBindingContext,
-      Adapter->NdisMiniportBlock.MediaRequest,
-      Status);
+  (*((PNDIS_MINIPORT_BLOCK)(MiniportAdapterHandle))->SetCompleteHandler)(MiniportAdapterHandle, Status);
 }
 
+#undef NdisMSetAttributes
+
 \f
 /*
  * @implemented
@@ -1836,17 +1920,10 @@ NdisMSetAttributes(
  *     AdapterType            = Specifies the I/O bus interface of the caller's NIC
  */
 {
-  PLOGICAL_ADAPTER Adapter = GET_LOGICAL_ADAPTER(MiniportAdapterHandle);
-
   NDIS_DbgPrint(MAX_TRACE, ("Called.\n"));
-
-  Adapter->NdisMiniportBlock.MiniportAdapterContext = MiniportAdapterContext;
-  
-  if(BusMaster)
-    Adapter->NdisMiniportBlock.Flags |= NDIS_ATTRIBUTE_BUS_MASTER;
-
-  Adapter->NdisMiniportBlock.AdapterType   = AdapterType;
-  Adapter->AttributesSet = TRUE;
+  NdisMSetAttributesEx(MiniportAdapterContext, MiniportAdapterContext, 0,
+                       BusMaster ? NDIS_ATTRIBUTE_BUS_MASTER : 0,
+                       AdapterType);
 }
 
 \f
index 6ee5462..0cd27f0 100644 (file)
@@ -79,7 +79,7 @@ ProIndicatePacket(
   KeAcquireSpinLock(&Adapter->NdisMiniportBlock.Lock, &OldIrql);
     {
       Adapter->LoopPacket = Packet;
-      BufferedLength = CopyPacketToBuffer(Adapter->LookaheadBuffer, Packet, 0, Adapter->CurLookaheadLength);
+      BufferedLength = CopyPacketToBuffer(Adapter->LookaheadBuffer, Packet, 0, Adapter->NdisMiniportBlock.CurrentLookahead);
     }
   KeReleaseSpinLock(&Adapter->NdisMiniportBlock.Lock, OldIrql);
 
@@ -151,7 +151,7 @@ ProRequest(
 
   if (QueueWorkItem) 
     {
-      MiniQueueWorkItem(Adapter, NdisWorkItemRequest, (PVOID)NdisRequest, (NDIS_HANDLE)AdapterBinding);
+      MiniQueueWorkItem(Adapter, NdisWorkItemRequest, (PVOID)NdisRequest);
       return NDIS_STATUS_PENDING;
     } 
 
@@ -268,7 +268,7 @@ ProSend(
 
       if (QueueWorkItem) 
         {
-          MiniQueueWorkItem(Adapter, NdisWorkItemSendLoopback, (PVOID)Packet, (NDIS_HANDLE)AdapterBinding);
+          MiniQueueWorkItem(Adapter, NdisWorkItemSendLoopback, (PVOID)Packet);
           return NDIS_STATUS_PENDING;
         }
 
@@ -305,7 +305,7 @@ ProSend(
   /* This is a normal send packet, not a loopback packet. */
   if (QueueWorkItem) 
     {
-      MiniQueueWorkItem(Adapter, NdisWorkItemSend, (PVOID)Packet, (NDIS_HANDLE)AdapterBinding);
+      MiniQueueWorkItem(Adapter, NdisWorkItemSend, (PVOID)Packet);
       NDIS_DbgPrint(MAX_TRACE, ("Queued a work item and returning\n"));
       return NDIS_STATUS_PENDING;
     }
@@ -346,7 +346,7 @@ ProSend(
       if(Adapter->NdisMiniportBlock.Flags & NDIS_ATTRIBUTE_DESERIALIZE)
         {
           NDIS_DbgPrint(MAX_TRACE, ("Calling miniport's Send handler\n"));
-          NdisStatus = (*Adapter->Miniport->Chars.u1.SendHandler)(Adapter->NdisMiniportBlock.MiniportAdapterContext, Packet, 0);
+          NdisStatus = (*Adapter->Miniport->Chars.SendHandler)(Adapter->NdisMiniportBlock.MiniportAdapterContext, Packet, 0);
           NDIS_DbgPrint(MAX_TRACE, ("back from miniport's send handler\n"));
         }
       else
@@ -355,7 +355,7 @@ ProSend(
           KeRaiseIrql(DISPATCH_LEVEL, &RaiseOldIrql);
 
           NDIS_DbgPrint(MAX_TRACE, ("Calling miniport's Send handler\n"));
-          NdisStatus = (*Adapter->Miniport->Chars.u1.SendHandler)(Adapter->NdisMiniportBlock.MiniportAdapterContext, Packet, 0);
+          NdisStatus = (*Adapter->Miniport->Chars.SendHandler)(Adapter->NdisMiniportBlock.MiniportAdapterContext, Packet, 0);
           NDIS_DbgPrint(MAX_TRACE, ("back from miniport's send handler\n"));
 
           KeLowerIrql(RaiseOldIrql);
@@ -428,7 +428,7 @@ ProTransferData(
         return NDIS_STATUS_SUCCESS;
     }
 
-    return (*Adapter->Miniport->Chars.u2.TransferDataHandler)(
+    return (*Adapter->Miniport->Chars.TransferDataHandler)(
         Packet,
         BytesTransferred,
         Adapter->NdisMiniportBlock.MiniportAdapterContext,
@@ -598,18 +598,18 @@ NdisOpenAdapter(
 
   AdapterBinding->ProtocolBinding        = Protocol;
   AdapterBinding->Adapter                = Adapter;
-  AdapterBinding->NdisOpenBlock.ProtocolBindingContext = ProtocolBindingContext;
+  AdapterBinding->NdisOpenBlock.NdisCommonOpenBlock.ProtocolBindingContext = ProtocolBindingContext;
 
   /* Set fields required by some NDIS macros */
-  AdapterBinding->NdisOpenBlock.MacBindingHandle = (NDIS_HANDLE)AdapterBinding;
+  AdapterBinding->NdisOpenBlock.NdisCommonOpenBlock.BindingHandle = (NDIS_HANDLE)AdapterBinding;
     
   /* Set handlers (some NDIS macros require these) */
 
-  AdapterBinding->NdisOpenBlock.RequestHandler      = ProRequest;
-  AdapterBinding->NdisOpenBlock.ResetHandler        = ProReset;
-  AdapterBinding->NdisOpenBlock.u1.SendHandler      = ProSend;
-  AdapterBinding->NdisOpenBlock.SendPacketsHandler  = ProSendPackets;
-  AdapterBinding->NdisOpenBlock.TransferDataHandler = ProTransferData;
+  AdapterBinding->NdisOpenBlock.NdisCommonOpenBlock.RequestHandler      = ProRequest;
+  AdapterBinding->NdisOpenBlock.NdisCommonOpenBlock.ResetHandler        = ProReset;
+  AdapterBinding->NdisOpenBlock.NdisCommonOpenBlock.SendHandler         = ProSend;
+  AdapterBinding->NdisOpenBlock.NdisCommonOpenBlock.SendPacketsHandler  = ProSendPackets;
+  AdapterBinding->NdisOpenBlock.NdisCommonOpenBlock.TransferDataHandler = ProTransferData;
 
 #if 0
   /* XXX this looks fishy */
@@ -661,8 +661,8 @@ NdisRegisterProtocol(
   UINT MinSize;
   HANDLE DriverKeyHandle = NULL;
   PKEY_VALUE_PARTIAL_INFORMATION KeyInformation = NULL;
-  WCHAR *CurrentStr;
-  
+  WCHAR *DataPtr;
+
   NDIS_DbgPrint(MAX_TRACE, ("Called.\n"));
 
   /* first validate the PROTOCOL_CHARACTERISTICS */
@@ -671,15 +671,15 @@ NdisRegisterProtocol(
     case 0x03: 
       /* we don't really want to support ndis3 drivers - so we complain for now */
       NDIS_DbgPrint(MID_TRACE, ("NDIS 3 protocol attempting to register\n"));
-      MinSize = sizeof(NDIS30_PROTOCOL_CHARACTERISTICS_S);
+      MinSize = sizeof(NDIS30_PROTOCOL_CHARACTERISTICS);
       break;
 
     case 0x04:
-      MinSize = sizeof(NDIS40_PROTOCOL_CHARACTERISTICS_S);
+      MinSize = sizeof(NDIS40_PROTOCOL_CHARACTERISTICS);
       break;
 
     case 0x05:
-      MinSize = sizeof(NDIS50_PROTOCOL_CHARACTERISTICS_S);
+      MinSize = sizeof(NDIS50_PROTOCOL_CHARACTERISTICS);
       break;
 
     default:
@@ -807,7 +807,9 @@ NdisRegisterProtocol(
       }
   }
 
-    for(CurrentStr = (WCHAR*)&KeyInformation->Data[0]; *CurrentStr != '\0'; CurrentStr += wcslen(CurrentStr) + 1)
+  for (DataPtr = (WCHAR *)KeyInformation->Data;
+       *DataPtr != 0;
+       DataPtr += wcslen(DataPtr) + 1)
     {
       /* BindContext is for tracking pending binding operations */
       VOID *BindContext = 0;
@@ -816,7 +818,7 @@ NdisRegisterProtocol(
       WCHAR *RegistryPathStr = NULL;
       ULONG PathLength = 0;
 
-      RtlInitUnicodeString(&DeviceName, CurrentStr);   /* we know this is 0-term */
+      RtlInitUnicodeString(&DeviceName, DataPtr);      /* we know this is 0-term */
 
       /*
        * RegistryPath should be:
@@ -827,7 +829,7 @@ NdisRegisterProtocol(
        */
 
       PathLength = sizeof(SERVICES_KEY) +                               /* \Registry\Machine\System\CurrentControlSet\Services\ */
-          wcslen( CurrentStr+8 ) * sizeof(WCHAR) +                     /* Adapter1  (extracted from \Device\Adapter1)          */
+          wcslen( DataPtr + 8 ) * sizeof(WCHAR) + /* Adapter1  (extracted from \Device\Adapter1)          */
           sizeof(PARAMETERS_KEY) +                                      /* \Parameters\                                         */
           ProtocolCharacteristics->Name.Length;                         /* Tcpip                                                */
 
@@ -842,7 +844,7 @@ NdisRegisterProtocol(
         }
 
       wcscpy(RegistryPathStr, SERVICES_KEY);
-      wcscat(RegistryPathStr, CurrentStr +8 );
+      wcscat(RegistryPathStr, (((WCHAR *)(KeyInformation->Data)) +8 ));
       wcscat(RegistryPathStr, PARAMETERS_KEY);
       wcsncat(RegistryPathStr, ProtocolCharacteristics->Name.Buffer, ProtocolCharacteristics->Name.Length / sizeof(WCHAR) );
 
@@ -872,7 +874,6 @@ NdisRegisterProtocol(
         {
           /* Put protocol binding struct on global list */
           ExInterlockedInsertTailList(&ProtocolListHead, &Protocol->ListEntry, &ProtocolListLock);
-         NDIS_DbgPrint(MAX_TRACE, ("Added to global list.\n"));
         }
 
       /*
@@ -882,7 +883,7 @@ NdisRegisterProtocol(
         }
        */
     }
-  NDIS_DbgPrint(MAX_TRACE, ("Leaving..\n"));
+
   *Status             = NDIS_STATUS_SUCCESS;
 }
 
index 39c9976..90fb733 100644 (file)
@@ -39,6 +39,8 @@ NdisAnsiStringToUnicodeString(
       (PANSI_STRING)SourceString, FALSE);
 }
 
+#undef NdisEqualString
+
 \f
 /*
  * @implemented
index 4113cb5..91091c8 100644 (file)
@@ -38,17 +38,7 @@ NdisCompleteUnbindAdapter(
 }
 
 
-/*
- * @implemented
- */
-VOID
-EXPORT
-NdisInitializeListHead(
-    IN  PLIST_ENTRY ListHead)
-{
-       InitializeListHead(ListHead);
-}
-
+#undef NdisInterlockedAddUlong
 
 /*
  * @implemented
@@ -60,10 +50,12 @@ NdisInterlockedAddUlong (
     IN  ULONG           Increment,
     IN  PNDIS_SPIN_LOCK SpinLock)
 {
-  ExInterlockedAddUlong ( Addend, Increment, (PKSPIN_LOCK)SpinLock );
+   ExInterlockedAddUlong ( Addend, Increment, (PKSPIN_LOCK)SpinLock );
 }
 
 
+#undef NdisInterlockedInsertHeadList
+
 /*
  * @implemented
  */
@@ -78,6 +70,8 @@ NdisInterlockedInsertHeadList(
 }
 
 
+#undef NdisInterlockedInsertTailList
+
 /*
  * @implemented
  */
@@ -92,6 +86,8 @@ NdisInterlockedInsertTailList(
 }
 
 
+#undef NdisInterlockedRemoveHeadList
+
 /*
  * @implemented
  */
@@ -187,6 +183,8 @@ NdisIMDeInitializeDeviceInstance(
 }
 
 
+#undef NdisIMInitializeDeviceInstance
+
 /*
  * @unimplemented
  */
@@ -543,6 +541,8 @@ NdisGetSystemUptime(
 }
 
 
+#undef NdisInterlockedDecrement
+
 /*
  * @implemented
  */
@@ -561,6 +561,8 @@ NdisInterlockedDecrement(
 }
 
 
+#undef NdisInterlockedIncrement
+
 /*
  * @implemented
  */
@@ -831,27 +833,6 @@ NdisQueryAdapterInstanceName(
 }
 
 
-/*
- * @unimplemented
- */
-VOID
-EXPORT
-NdisQueryBufferSafe(
-    IN  PNDIS_BUFFER    Buffer,
-    OUT PVOID           *VirtualAddress OPTIONAL,
-    OUT PUINT           Length,
-    IN  UINT            Priority)
-/*
- * FUNCTION:
- * ARGUMENTS:
- * NOTES:
- *    NDIS 5.0
- */
-{
-    UNIMPLEMENTED
-}
-
-
 /*
  * @unimplemented
  */