freebsd-dev/sys/compat/ndis
Bill Paul 58a6edd121 When you call MiniportInitialize() for an 802.11 driver, it will
at some point result in a status event being triggered (it should
be a link down event: the Microsoft driver design guide says you
should generate one when the NIC is initialized). Some drivers
generate the event during MiniportInitialize(), such that by the
time MiniportInitialize() completes, the NIC is ready to go. But
some drivers, in particular the ones for Atheros wireless NICs,
don't generate the event until after a device interrupt occurs
at some point after MiniportInitialize() has completed.

The gotcha is that you have to wait until the link status event
occurs one way or the other before you try to fiddle with any
settings (ssid, channel, etc...). For the drivers that set the
event sycnhronously this isn't a problem, but for the others
we have to pause after calling ndis_init_nic() and wait for the event
to arrive before continuing. Failing to wait can cause big trouble:
on my SMP system, calling ndis_setstate_80211() after ndis_init_nic()
completes, but _before_ the link event arrives, will lock up or
reset the system.

What we do now is check to see if a link event arrived while
ndis_init_nic() was running, and if it didn't we msleep() until
it does.

Along the way, I discovered a few other problems:

- Defered procedure calls run at PASSIVE_LEVEL, not DISPATCH_LEVEL.
  ntoskrnl_run_dpc() has been fixed accordingly. (I read the documentation
  wrong.)

- Similarly, the NDIS interrupt handler, which is essentially a
  DPC, also doesn't need to run at DISPATCH_LEVEL. ndis_intrtask()
  has been fixed accordingly.

- MiniportQueryInformation() and MiniportSetInformation() run at
  DISPATCH_LEVEL, and each request must complete before another
  can be submitted. ndis_get_info() and ndis_set_info() have been
  fixed accordingly.

- Turned the sleep lock that guards the NDIS thread job list into
  a spin lock. We never do anything with this lock held except manage
  the job list (no other locks are held), so it's safe to do this,
  and it's possible that ndis_sched() and ndis_unsched() can be
  called from DISPATCH_LEVEL, so using a sleep lock here is
  semantically incorrect. Also updated subr_witness.c to add the
  lock to the order list.
2005-03-07 03:05:31 +00:00
..
cfg_var.h
hal_var.h Add support for Windows/x86-64 binaries to Project Evil. 2005-02-16 05:41:18 +00:00
kern_ndis.c When you call MiniportInitialize() for an 802.11 driver, it will 2005-03-07 03:05:31 +00:00
kern_windrv.c In windrv_load(), I was allocating the driver object using 2005-03-01 17:21:25 +00:00
ndis_var.h MAXPATHLEN is 1024, which means NdisOpenFile() and ndis_find_sym() were 2005-03-03 03:51:02 +00:00
ntoskrnl_var.h MDLs are supposed to be variable size (they include an array of pages 2005-02-26 00:22:16 +00:00
pe_var.h Fix a couple of u_int_foos that should have been uint_foos. 2005-02-18 04:33:34 +00:00
resource_var.h Add support for Windows/x86-64 binaries to Project Evil. 2005-02-16 05:41:18 +00:00
subr_hal.c Add support for Windows/x86-64 binaries to Project Evil. 2005-02-16 05:41:18 +00:00
subr_ndis.c MAXPATHLEN is 1024, which means NdisOpenFile() and ndis_find_sym() were 2005-03-03 03:51:02 +00:00
subr_ntoskrnl.c When you call MiniportInitialize() for an 802.11 driver, it will 2005-03-07 03:05:31 +00:00
subr_pe.c Couple of lessons learned during USB driver testing: 2005-02-24 17:58:27 +00:00
subr_usbd.c - Correct one aspect of the driver_object/device_object/IRP framework: 2005-02-24 21:49:14 +00:00
usbd_var.h - Correct one aspect of the driver_object/device_object/IRP framework: 2005-02-24 21:49:14 +00:00
winx64_wrap.S Make the Win64 -> ELF64 template a little smaller by using a string 2005-02-18 03:22:37 +00:00