cvs commit: src/sys/compat/ndis kern_ndis.c kern_windrv.c ndis_var.h ntoskrnl_var.h subr_hal.c subr_ndis.c subr_ntoskrnl.c src/sys/dev/if_ndis if_ndis.c if_ndis_pccard.c if_ndis_pci.c...

Bill Paul wpaul at FreeBSD.org
Tue Feb 8 17:23:26 GMT 2005


wpaul       2005-02-08 17:23:26 UTC

  FreeBSD src repository

  Modified files:
    sys/compat/ndis      kern_ndis.c ndis_var.h ntoskrnl_var.h 
                         subr_hal.c subr_ndis.c subr_ntoskrnl.c 
    sys/dev/if_ndis      if_ndis.c if_ndis_pccard.c if_ndis_pci.c 
                         if_ndisvar.h 
    usr.sbin/ndiscvt     ndiscvt.c 
    sys/modules/ndis     Makefile 
    sys/conf             files.i386 
  Added files:
    sys/compat/ndis      kern_windrv.c 
  Log:
  Next step on the road to IRPs: create and use an imitation of the
  Windows DRIVER_OBJECT and DEVICE_OBJECT mechanism so that we can
  simulate driver stacking.
  
  In Windows, each loaded driver image is attached to a DRIVER_OBJECT
  structure. Windows uses the registry to match up a given vendor/device
  ID combination with a corresponding DRIVER_OBJECT. When a driver image
  is first loaded, its DriverEntry() routine is invoked, which sets up
  the AddDevice() function pointer in the DRIVER_OBJECT and creates
  a dispatch table (based on IRP major codes). When a Windows bus driver
  detects a new device, it creates a Physical Device Object (PDO) for
  it. This is a DEVICE_OBJECT structure, with semantics analagous to
  that of a device_t in FreeBSD. The Windows PNP manager will invoke
  the driver's AddDevice() function and pass it pointers to the DRIVER_OBJECT
  and the PDO.
  
  The AddDevice() function then creates a new DRIVER_OBJECT structure of
  its own. This is known as the Functional Device Object (FDO) and
  corresponds roughly to a private softc instance. The driver uses
  IoAttachDeviceToDeviceStack() to add this device object to the
  driver stack for this PDO. Subsequent drivers (called filter drivers
  in Windows-speak) can be loaded which add themselves to the stack.
  When someone issues an IRP to a device, it travel along the stack
  passing through several possible filter drivers until it reaches
  the functional driver (which actually knows how to talk to the hardware)
  at which point it will be completed. This is how Windows achieves
  driver layering.
  
  Project Evil now simulates most of this. if_ndis now has a modevent
  handler which will use MOD_LOAD and MOD_UNLOAD events to drive the
  creation and destruction of DRIVER_OBJECTs. (The load event also
  does the relocation/dynalinking of the image.) We don't have a registry,
  so the DRIVER_OBJECTS are stored in a linked list for now. Eventually,
  the list entry will contain the vendor/device ID list extracted from
  the .INF file. When ndis_probe() is called and detectes a supported
  device, it will create a PDO for the device instance and attach it
  to the DRIVER_OBJECT just as in Windows. ndis_attach() will then call
  our NdisAddDevice() handler to create the FDO. The NDIS miniport block
  is now a device extension hung off the FDO, just as it is in Windows.
  The miniport characteristics table is now an extension hung off the
  DRIVER_OBJECT as well (the characteristics are the same for all devices
  handled by a given driver, so they don't need to be per-instance.)
  We also do an IoAttachDeviceToDeviceStack() to put the FDO on the
  stack for the PDO. There are a couple of fake bus drivers created
  for the PCI and pccard buses. Eventually, there will be one for USB,
  which will actually accept USB IRP.s
  
  Things should still work just as before, only now we do things in
  the proper order and maintain the correct framework to support passing
  IRPs between drivers.
  
  Various changes:
  
  - corrected the comments about IRQL handling in subr_hal.c to more
    accurately reflect reality
  - update ndiscvt to make the drv_data symbol in ndis_driver_data.h a
    global so that if_ndis_pci.o and/or if_ndis_pccard.o can see it.
  - Obtain the softc pointer from the miniport block by referencing
    the PDO rather than a private pointer of our own (nmb_ifp is no
    longer used)
  - implement IoAttachDeviceToDeviceStack(), IoDetachDevice(),
    IoGetAttachedDevice(), IoAllocateDriverObjectExtension(),
    IoGetDriverObjectExtension(), IoCreateDevice(), IoDeleteDevice(),
    IoAllocateIrp(), IoReuseIrp(), IoMakeAssociatedIrp(), IoFreeIrp(),
    IoInitializeIrp()
  - fix a few mistakes in the driver_object and device_object definitions
  - add a new module, kern_windrv.c, to handle the driver registration
    and relocation/dynalinkign duties (which don't really belong in
    kern_ndis.c).
  - made ndis_block and ndis_chars in the ndis_softc stucture pointers
    and modified all references to it
  - fixed NdisMRegisterMiniport() and NdisInitializeWrapper() so they
    work correctly with the new driver_object mechanism
  - changed ndis_attach() to call NdisAddDevice() instead of ndis_load_driver()
    (which is now deprecated)
  - used ExAllocatePoolWithTag()/ExFreePool() in lookaside list routines
    instead of kludged up alloc/free routines
  - added kern_windrv.c to sys/modules/ndis/Makefile and files.i386.
  
  Revision  Changes    Path
  1.64      +116 -154  src/sys/compat/ndis/kern_ndis.c
  1.1       +416 -0    src/sys/compat/ndis/kern_windrv.c (new)
  1.33      +9 -6      src/sys/compat/ndis/ndis_var.h
  1.22      +154 -17   src/sys/compat/ndis/ntoskrnl_var.h
  1.17      +19 -6     src/sys/compat/ndis/subr_hal.c
  1.73      +128 -76   src/sys/compat/ndis/subr_ndis.c
  1.49      +523 -65   src/sys/compat/ndis/subr_ntoskrnl.c
  1.515     +1 -0      src/sys/conf/files.i386
  1.77      +87 -25    src/sys/dev/if_ndis/if_ndis.c
  1.8       +14 -3     src/sys/dev/if_ndis/if_ndis_pccard.c
  1.10      +17 -5     src/sys/dev/if_ndis/if_ndis_pci.c
  1.18      +4 -3      src/sys/dev/if_ndis/if_ndisvar.h
  1.7       +1 -0      src/sys/modules/ndis/Makefile
  1.10      +1 -0      src/usr.sbin/ndiscvt/ndiscvt.c


More information about the cvs-src mailing list