freebsd-nq/sys/conf
Bill Paul b545a3b822 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.
2005-02-08 17:23:25 +00:00
..
defines
files Hook acpi_throttle(4) up to the build. It's currently part of acpi_perf.ko 2005-02-06 21:13:41 +00:00
files.alpha
files.amd64
files.arm
files.i386 Next step on the road to IRPs: create and use an imitation of the 2005-02-08 17:23:25 +00:00
files.ia64
files.pc98 cosmetic changes. 2005-02-04 15:34:52 +00:00
files.powerpc
files.sparc64
kern.mk
kern.post.mk
kern.pre.mk Embellish rev 1.61. If we're not building a debug kernel, use -O2 as before. 2005-01-22 00:58:34 +00:00
kmod_syms.awk
kmod.mk Hook up the cpufreq framework, acpi_perf(4), and cpufreq(4) drivers. 2005-02-04 05:49:36 +00:00
ldscript.alpha
ldscript.amd64
ldscript.arm
ldscript.i386
ldscript.ia64
ldscript.powerpc
ldscript.sparc64
majors
majors.awk
Makefile.alpha
Makefile.amd64
Makefile.arm Add a new make option, ARM_BIG_ENDIAN, to compile big endian kernels. 2005-01-19 16:43:43 +00:00
Makefile.i386
Makefile.ia64
Makefile.pc98
Makefile.powerpc - remove NO_MODULES since they've been working for some time 2005-02-03 06:28:17 +00:00
Makefile.sparc64
makeLINT.mk
makeLINT.sed
newvers.sh If USER of HOSTNAME is set to an empty value, use the fallback value. 2005-01-15 13:25:41 +00:00
NOTES Fix sloppy use of "manpage", bump .Dd where applicable and rename RED to 2005-02-07 23:20:12 +00:00
options Hook up ng_ipfw to kernel build. 2005-02-05 12:15:56 +00:00
options.alpha
options.amd64
options.arm
options.i386
options.ia64
options.pc98 The bs and wdc drivers are gone. 2005-02-04 15:29:54 +00:00
options.powerpc
options.sparc64
systags.sh