summaryrefslogtreecommitdiffstats
path: root/sys/compat
Commit message (Collapse)AuthorAgeFilesLines
* In ntoskrnl_unlock_dpc(), use atomic_store instead of atomic_cmpsetwpaul2004-04-181-2/+2
| | | | | | to give up the spinlock. Suggested by: bde
* - Use memory barrier with atomic operations in ntoskrnl_lock_dpc() andwpaul2004-04-165-56/+21
| | | | | | | | | | | | | | ntoskrnl_unlocl_dpc(). - hal_raise_irql(), hal_lower_irql() and hal_irql() didn't work right on SMP (priority inheritance makes things... interesting). For now, use only two states: DISPATCH_LEVEL (PI_REALTIME) and PASSIVE_LEVEL (everything else). Tested on a dual PIII box. - Use ndis_thsuspend() in ndis_sleep() instead of tsleep(). (I added ndis_thsuspend() and ndis_thresume() to replace kthread_suspend() and kthread_resume(); the former will preserve a thread's priority when it wakes up, the latter will not.) - Change use of tsleep() in ndis_stop_thread() to prevent priority change on wakeup.
* Check in structure definitions for the FreeBSD-3.x signal syscall stuff.peter2004-04-141-0/+43
| | | | Nothing uses these yet, but I dont want to lose them.
* Regenpeter2004-04-144-40/+49
|
* Catch up to the not-so-recent statfs(2) changes.peter2004-04-143-18/+49
|
* Continue my efforts to imitate Windows as closely as possible bywpaul2004-04-148-156/+421
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | attempting to duplicate Windows spinlocks. Windows spinlocks differ from FreeBSD spinlocks in the way they block preemption. FreeBSD spinlocks use critical_enter(), which masks off _all_ interrupts. This prevents any other threads from being scheduled, but it also prevents ISRs from running. In Windows, preemption is achieved by raising the processor IRQL to DISPATCH_LEVEL, which prevents other threads from preempting you, but does _not_ prevent device ISRs from running. (This is essentially what Solaris calls dispatcher locks.) The Windows spinlock itself (kspin_lock) is just an integer value which is atomically set when you acquire the lock and atomically cleared when you release it. FreeBSD doesn't have IRQ levels, so we have to cheat a little by using thread priorities: normal thread priority is PASSIVE_LEVEL, lowest interrupt thread priority is DISPATCH_LEVEL, highest thread priority is DEVICE_LEVEL (PI_REALTIME) and critical_enter() is HIGH_LEVEL. In practice, only PASSIVE_LEVEL and DISPATCH_LEVEL matter to us. The immediate benefit of all this is that I no longer have to rely on a mutex pool. Now, I'm sure many people will be seized by the urge to criticize me for doing an end run around our own spinlock implementation, but it makes more sense to do it this way. Well, it does to me anyway. Overview of the changes: - Properly implement hal_lock(), hal_unlock(), hal_irql(), hal_raise_irql() and hal_lower_irql() so that they more closely resemble their Windows counterparts. The IRQL is determined by thread priority. - Make ntoskrnl_lock_dpc() and ntoskrnl_unlock_dpc() do what they do in Windows, which is to atomically set/clear the lock value. These routines are designed to be called from DISPATCH_LEVEL, and are actually half of the work involved in acquiring/releasing spinlocks. - Add FASTCALL1(), FASTCALL2() and FASTCALL3() macros/wrappers that allow us to call a _fastcall function in spite of the fact that our version of gcc doesn't support __attribute__((__fastcall__)) yet. The macros take 1, 2 or 3 arguments, respectively. We need to call hal_lock(), hal_unlock() etc... ourselves, but can't really invoke the function directly. I could have just made the underlying functions native routines and put _fastcall wrappers around them for the benefit of Windows binaries, but that would create needless bloat. - Remove ndis_mtxpool and all references to it. We don't need it anymore. - Re-implement the NdisSpinLock routines so that they use hal_lock() and friends like they do in Windows. - Use the new spinlock methods for handling lookaside lists and linked list updates in place of the mutex locks that were there before. - Remove mutex locking from ndis_isr() and ndis_intrhand() since they're already called with ndis_intrmtx held in if_ndis.c. - Put ndis_destroy_lock() code under explicit #ifdef notdef/#endif. It turns out there are some drivers which stupidly free the memory in which their spinlocks reside before calling ndis_destroy_lock() on them (touch-after-free bug). The ADMtek wireless driver is guilty of this faux pas. (Why this doesn't clobber Windows I have no idea.) - Make NdisDprAcquireSpinLock() and NdisDprReleaseSpinLock() into real functions instead of aliasing them to NdisAcaquireSpinLock() and NdisReleaseSpinLock(). The Dpr routines use KeAcquireSpinLockAtDpcLevel() level and KeReleaseSpinLockFromDpcLevel(), which acquires the lock without twiddling the IRQL. - In ndis_linksts_done(), do _not_ call ndis_80211_getstate(). Some drivers may call the status/status done callbacks as the result of setting an OID: ndis_80211_getstate() gets OIDs, which means we might cause the driver to recursively access some of its internal structures unexpectedly. The ndis_ticktask() routine will call ndis_80211_getstate() for us eventually anyway. - Fix the channel setting code a little in ndis_80211_setstate(), and initialize the channel to IEEE80211_CHAN_ANYC. (The Microsoft spec says you're not supposed to twiddle the channel in BSS mode; I may need to enforce this later.) This fixes the problems I was having with the ADMtek adm8211 driver: we were setting the channel to a non-standard default, which would cause it to fail to associate in BSS mode. - Use hal_raise_irql() to raise our IRQL to DISPATCH_LEVEL when calling certain miniport routines, per the Microsoft documentation. I think that's everything. Hopefully, other than fixing the ADMtek driver, there should be no apparent change in behavior.
* In ndis_convert_res(), initialize the head of our temporary listwpaul2004-04-071-1/+2
| | | | | | | before calling BUS_GET_RESOURCE_LIST(). Previously, the list head would only be initialized if BUS_GET_RESOURCE_LIST() succeeded; it needs to be initialized unconditionally so that the list cleanup code won't trip over potential stack garbage.
* - The MiniportReset() function can return NDIS_STATUS_PENDING, in whichwpaul2004-04-053-18/+21
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | case we should wait for the resetdone handler to be called before returning. - When providing resources via ndis_query_resources(), uses the computed rsclen when using bcopy() to copy out the resource data rather than the caller-supplied buffer length. - Avoid using ndis_reset_nic() in if_ndis.c unless we really need to reset the NIC because of a problem. - Allow interrupts to be fielded during ndis_attach(), at least as far as allowing ndis_isr() and ndis_intrhand() to run. - Use ndis_80211_rates_ex when probing for supported rates. Technically, this isn't supposed to work since, although Microsoft added the extended rate structure with the NDIS 5.1 update, the spec still says that the OID_802_11_SUPPORTED_RATES OID uses ndis_80211_rates. In spite of this, it appears some drivers use it anyway. - When adding in our guessed rates, check to see if they already exist so that we avoid any duplicates. - Add a printf() to ndis_open_file() that alerts the user when a driver attempts to open a file under /compat/ndis. With these changes, I can get the driver for the SMC 2802W 54g PCI card to load and run. This board uses a Prism54G chip. Note that in order for this driver to work, you must place the supplied smc2802w.arm firmware image under /compat/ndis. (The firmware is not resident on the device.) Note that this should also allow the 3Com 3CRWE154G72 card to work as well; as far as I can tell, these cards also use a Prism54G chip.
* Remove ps_argsopen from this check, because of two reasons:pjd2004-04-011-1/+1
| | | | | | 1. This check if wrong, because it is true by default (kern.ps_argsopen is 1 by default) (p_cansee() is not even checked). 2. Sysctl kern.ps_argsopen is going away.
* Add missing cprd_flags member to partial resource structure inwpaul2004-03-294-1/+15
| | | | | | | | | | | | | resource_var.h. In kern_ndis.c:ndis_convert_res(), fill in the cprd_flags and cprd_sharedisp fields as best we can. In if_ndis.c:ndis_setmulti(), don't bother updating the multicast filter if our multicast address list is empty. Add some missing updates to ndis_var.h and ntoskrnl_var.h that I forgot to check in when I added the KeDpc stuff.
* Apparently, some atheros drivers want rand(), so implement it (in termswpaul2004-03-271-0/+12
| | | | | | | of random()). Requested by: juli Bribe offered: tacos
* Regen for libthr thread synchronization syscalls.mtm2004-03-274-5/+11
|
* Separate thread synchronization from signals in libthr. Insteadmtm2004-03-271-0/+2
| | | | | | use msleep() and wakeup_one(). Discussed with: jhb, peter, tjr
* - In subr_ndis.c:ndis_init_event(), initialize events as notificationwpaul2004-03-252-4/+41
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | objects rather than synchronization objects. When a sync object is signaled, only the first thread waiting on it is woken up, and then it's automatically reset to the not-signaled state. When a notification object is signaled, all threads waiting on it will be woken up, and it remains in the signaled state until someone resets it manually. We want the latter behavior for NDIS events. - In kern_ndis.c:ndis_convert_res(), we have to create a temporary copy of the list returned by BUS_GET_RESOURCE_LIST(). When the PCI bus code probes resources for a given device, it enters them into a singly linked list, head first. The result is that traversing this list gives you the resources in reverse order. This means when we create the Windows resource list, it will be in reverse order too. Unfortunately, this can hose drivers for devices with multiple I/O ranges of the same type, like, say, two memory mapped I/O regions (one for registers, one to map the NVRAM/bootrom/whatever). Some drivers test the range size to figure out which region is which, but others just assume that the resources will be listed in ascending order from lowest numbered BAR to highest. Reversing the order means such drivers will choose the wrong resource as their I/O register range. Since we can't traverse the resource SLIST backwards, we have to make a temporary copy of the list in the right order and then build the Windows resource list from that. I suppose we could just fix the PCI bus code to use a TAILQ instead, but then I'd have to track down all the consumers of the BUS_GET_RESOURCE_LIST() and fix them too.
* - In kern_ndis.c, implement ndis_unsched(), the complement to ndis_sched(),wpaul2004-03-252-28/+86
| | | | | | | | | | | | | | which pulls a job off a thread work queue (assuming it hasn't run yet). This is needed for KeRemoveQueueDpc(). - In subr_ntoskrnl.c, implement KeInsertQueueDpc() and KeRemoveQueueDpc(), to go with KeInitializeDpc() to round out the API. Also change the KeTimer implementation to use this API instead of the private timer callout scheduler. Functionality of the timer API remains unchanged, but we get a couple new Windows kernel API routines and more closely imitate the way thing works in Windows. (As of yet I haven't encountered any drivers that use KeInsertQueueDpc() or KeRemoveQueueDpc(), but it doesn't hurt to have them.)
* Remove another case of grabbing Giant before doing a kthread_exit()wpaul2004-03-221-1/+0
| | | | which is now no longer needed.
* I'm a dumbass: the test in the MOD_SHUTDOWN case in ndis_modevent()wpaul2004-03-221-1/+1
| | | | that checks to see if any devices are still in the devlist was reversed.
* The Intel 2200BG NDIS driver does an alloca() of about 5000 byteswpaul2004-03-223-8/+32
| | | | | | | | | | | | | | | | | when it associates with a net. Because FreeBSD's kstack size is only 2 pages by default, this blows the stack and causes a double fault. To deal with this, we now create all our kthreads with 8 stack pages. Also, we now run all timer callouts in the ndis swi thread (since they would otherwise run in the clock ithread, whose stack is too small). It happens that the alloca() in this case was occuring within the interrupt handler, which was already running in the ndis swi thread, but I want to deal with the callouts too just to be extra safe. NOTE: this will only work if you update vm_machdep.c with the change I just committed. If you don't include this fix, setting the number of stack pages with kthread_create() has essentially no effect.
* Change (yet again, sorry!) the path of the 32 bit ld-elf.so.1.peter2004-03-211-2/+2
|
* - Rewrite the timer and event API routines in subr_ndis.c so that theywpaul2004-03-205-216/+101
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | are actually layered on top of the KeTimer API in subr_ntoskrnl.c, just as it is in Windows. This reduces code duplication and more closely imitates the way things are done in Windows. - Modify ndis_encode_parm() to deal with the case where we have a registry key expressed as a hex value ("0x1") which is being read via NdisReadConfiguration() as an int. Previously, we tried to decode things like "0x1" with strtol() using a base of 10, which would always yield 0. This is what was causing problems with the Intel 2200BG Centrino 802.11g driver: the .inf file that comes with it has a key called RadioEnable with a value of 0x1. We incorrectly decoded this value to '0' when it was queried, hence the driver thought we wanted the radio turned off. - In if_ndis.c, most drivers don't accept NDIS_80211_AUTHMODE_AUTO, but NDIS_80211_AUTHMODE_SHARED may not be right in some cases, so for now always use NDIS_80211_AUTHMODE_OPEN. NOTE: There is still one problem with the Intel 2200BG driver: it happens that the kernel stack in Windows is larger than the kernel stack in FreeBSD. The 2200BG driver sometimes eats up more than 2 pages of stack space, which can lead to a double fault panic. For the moment, I got things to work by adding the following to my kernel config file: options KSTACK_PAGES=8 I'm pretty sure 8 is too big; I just picked this value out of a hat as a test, and it happened to work, so I left it. 4 pages might be enough. Unfortunately, I don't think you can dynamically give a thread a larger stack, so I'm not sure how to handle this short of putting a note in the man page about it and dealing with the flood of mail from people who never read man pages.
* - Replace wait1() with a kern_wait() function that accepts the pid,jhb2004-03-173-70/+31
| | | | | | | | | | | | | | | options, status pointer and rusage pointer as arguments. It is up to the caller to copyout the status and rusage to userland if needed. This lets us axe the 'compat' argument and hide all that functionality in owait(), by the way. This also cleans up some locking in kern_wait() since it no longer has to drop locks around copyout() since all the copyout()'s are deferred. - Convert owait(), wait4(), and the various ABI compat wait() syscalls to use kern_wait() rather than wait1() or wait4(). This removes a bit more stackgap usage. Tested on: i386 Compiled on: i386, alpha, amd64
* Use vfs_nmount() to mount linprocfs filesystems in linux_mount();tjr2004-03-161-4/+21
| | | | linprocfs doesn't support the old mount interface.
* Correct size argument passed to copyinstr() in linux_mount(): mntfromnametjr2004-03-161-2/+2
| | | | and mntonname are both MNAMELEN characters long, not MFSNAMELEN.
* Add vectors for _snprintf() and _vsnprintf() (redirected straight towpaul2004-03-151-0/+2
| | | | | | | | | snprintf() and vsnprintf() in FreeBSD kernel land). This is needed by the Intel Centrino 2200BG driver. Unfortunately, this driver still doesn't work right with Project Evil even with this tweak, but I'm unable to diagnose the problem since I don't have access to a sample card.
* Move the non-MD machine/dvcfg.h and machine/physio_proc.h to a commonpeter2004-03-132-6/+6
| | | | MI area before they proliferate more.
* Remove unused second arg to vfinddev().phk2004-03-111-1/+1
| | | | Don't call addaliasu() on VBLK nodes.
* Fix mind-o: sanity check in ndis_disable_ndis() is not sane.wpaul2004-03-111-1/+1
|
* Fix the problem with the Cisco Aironet 340 PCMCIA card. Most newer driverswpaul2004-03-111-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | for Windows are deserialized miniports. Such drivers maintain their own queues and do their own locking. This particular driver is not deserialized though, and we need special support to handle it correctly. Typically, in the ndis_rxeof() handler, we pass all incoming packets directly to (*ifp->if_input)(). This in turn may cause another thread to run and preempt us, and the packet may actually be processed and then released before we even exit the ndis_rxeof() routine. The problem with this is that releasing a packet calls the ndis_return_packet() function, which hands the packet and its buffers back to the driver. Calling ndis_return_packet() before ndis_rxeof() returns will screw up the driver's internal queues since, not being deserialized, it does no locking. To avoid this problem, if we detect a serialized driver (by checking the attribute flags passed to NdisSetAttributesEx(), we use an alternate ndis_rxeof() handler, ndis_rxeof_serial(), which puts the call to (*ifp->if_input)() on the NDIS SWI work queue. This guarantees the packet won't be processed until after ndis_rxeof_serial() returns. Note that another approach is to always copy the packet data into another mbuf and just let the driver retain ownership of the ndis_packet structure (ndis_return_packet() never needs to be called in this case). I'm not sure which method is faster.
* Fix several issues related to the KeInitializeTimer() etc... API stuffwpaul2004-03-102-39/+56
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | that I added recently: - When a periodic timer fires, it's automatically re-armed. We must make sure to re-arm the timer _before_ invoking any caller-supplied defered procedure call: the DPC may choose to call KeCancelTimer(), and re-arming the timer after the DPC un-does the effect of the cancel. - Fix similar issue with periodic timers in subr_ndis.c. - When calling KeSetTimer() or KeSetTimerEx(), if the timer is already pending, untimeout() it first before timeout()ing it again. - The old Atheros driver for the 5211 seems to use KeSetTimerEx() incorrectly, or at the very least in a very strange way that doesn't quite follow the Microsoft documentation. In one case, it calls KeSetTimerEx() with a duetime of 0 and a period of 5000. The Microsoft documentation says that negative duetime values are relative to the current time and positive values are absolute. But it doesn't say what's supposed to happen with positive values that less than the current time, i.e. absolute values that are in the past. Lacking any further information, I have decided that timers with positive duetimes that are in the past should fire right away (or in our case, after only 1 tick). This also takes care of the other strange usage in the Atheros driver, where the duetime is specified as 500000 and the period is 50. I think someone may have meant to use -500000 and misinterpreted the documentation. - Also modified KeWaitForSingleObject() and KeWaitForMultipleObjects() to make the same duetime adjustment, since they have the same rules regarding timeout values. - Cosmetic: change name of 'timeout' variable in KeWaitForSingleObject() and KeWaitForMultipleObjects() to 'duetime' to avoid senseless (though harmless) overlap with timeout() function name. With these fixes, I can get the 5211 card to associate properly with my adhoc net using driver AR5211.SYS version 2.4.1.6.
* Add preliminary support for PCMCIA devices in addition to PCI/cardbus.wpaul2004-03-071-47/+0
| | | | | | | | | | | | if_ndis.c has been split into if_ndis_pci.c and if_ndis_pccard.c. The ndiscvt(8) utility should be able to parse device info for PCMCIA devices now. The ndis_alloc_amem() has moved from kern_ndis.c to if_ndis_pccard.c so that kern_ndis.c no longer depends on pccard. NOTE: this stuff is not guaranteed to work 100% correctly yet. So far I have been able to load/init my PCMCIA Cisco Aironet 340 card, but it crashes in the interrupt handler. The existing support for PCI/cardbus devices should still work as before.
* kthread_exit() no longer requires Giant, so don't force callers to acquirejhb2004-03-051-1/+0
| | | | | | Giant just to call kthread_exit(). Requested by: many
* - Some older Atheros drivers want KeInitializeTimer(), so implement it,wpaul2004-03-042-19/+215
| | | | | | | | | | | | | | | | | along with KeInitializeTimerEx(), KeSetTimer(), KeSetTimerEx(), KeCancelTimer(), KeReadStateTimer() and KeInitializeDpc(). I don't know for certain that these will make the Atheros driver happy since I don't have the card/driver combo needed to test it, but these are fairly independent so they shouldn't break anything else. - Debugger() is present even in kernels without options DDB, so no conditional compilation is necessary (pointed out by bde). - Remove the extra km_acquirecnt member that I added to struct kmutant and embed it within an unused portion of the structure instead, so that we don't make the structure larger than it's defined to be in Windows. I don't know what crack I was smoking when I decided it was ok to do this, but it's worn off now.
* Add sanity checks to the ndis_packet and ndis_buffer pool handlingwpaul2004-03-042-2/+88
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | routines to guard against problems caused by (possibly) buggy drivers. The RealTek 8180 wireless driver calls NdisFreeBuffer() to release some of its buffers _after_ it's already called NdisFreeBufferPool() to destroy the pool to which the buffers belong. In our implementation, this error causes NdisFreeBuffer() to touch stale heap memory. If you are running a release kernel, and hence have INVARIANTS et al turned off, it turns out nothing happens. But if you're using a development kernel config with INVARIANTS on, the malloc()/free() sanity checks will scribble over the pool memory with 0xdeadc0de once it's released so that any attempts to touch it will cause a trap, and indeed this is what happens. It happens that I run 5.2-RELEASE on my laptop, so when I tested the rtl8180.sys driver, it worked fine for me, but people trying to run it with development systems checked out or cvsupped from -current would get a page fault on driver load. I can't find any reason why the NDISulator would cause the RealTek driver to do the NdisFreeBufferPool() prematurely, and the same driver obviously works with Windows -- or at least, it doesn't cause a crash: the Microsoft documentation for NdisFreeBufferPool() says that failing to return all buffers to the pool before calling NdisFreeBufferPool() causes a memory leak. I've written to my contacts at RealTek asking them to check if this is indeed a bug in their driver. In the meantime, these new sanity checks will catch this problem and issue a warning rather than causing a trap. The trick is to keep a count of outstanding buffers for each buffer pool, and if the driver tries to call NdisFreeBufferPool() while there are still buffers outstanding, we mark the pool for deletion and then defer destroying it until after the last buffer has been reclaimed.
* Add proper support for DbgPrint(): only print messages if bootverbosewpaul2004-03-031-1/+30
| | | | | | | | is set, since some drivers with debug info can be very chatty. Also implement DbgBreakPoint(), which is the Windows equivalent of Debugger(). Unfortunately, this forces subr_ntoskrnl.c to include opt_ddb.h.
* Regen (FWIW)peter2004-02-214-5/+5
|
* Try and make the compat sigreturn prototypes closer to reality.peter2004-02-211-1/+1
|
* Add a note about the landmine in the middle of struct ia32_sigframe.peter2004-02-211-0/+1
|
* DOH!!! Fix signals for freebsd-4.x/i386 binaries. The ucontext haspeter2004-02-211-1/+1
| | | | different alignments due to the sse fxsave dump area.
* Device megapatch 5/6:phk2004-02-211-4/+4
| | | | | | | | | | | | Remove the unused second argument from udev2dev(). Convert all remaining users of makedev() to use udev2dev(). The semantic difference is that udev2dev() will only locate a pre-existing dev_t, it will not line makedev() create a new one. Apart from the tiny well controlled windown in D_PSEUDO drivers, there should no longer be any "anonymous" dev_t's in the system now, only dev_t's created with make_dev() and make_dev_alias()
* Add BSD compatibility tty ioctls LINUX_TIOCSBRK and LINUX_TIOCCBRK. Thisbms2004-02-192-0/+13
| | | | | | | addition appears to allow VMware 3 Workstation to operate with nmdm(4) as a virtual COM device. Tested by: Guido van Rooij
* Add vector for memmove() (currently aliased to memcpy()) a implementwpaul2004-02-171-0/+20
| | | | ExInterlockedAddLargeStatistic().
* More cleanups/fixes for the AMD Am1771 driver:wpaul2004-02-163-22/+80
| | | | | | | | | | | | | | | | | | | | | - When adding new waiting threads to the waitlist for an object, use INSERT_LIST_TAIL() instead of INSERT_LIST_HEAD() so that new waiters go at the end of the list instead of the beginning. When we wake up a synchronization object, only the first waiter is awakened, and this needs to be the first thread that actually waited on the object. - Correct missing semicolon in INSERT_LIST_TAIL() macro. - Implement lookaside lists correctly. Note that the Am1771 driver uses lookaside lists to manage shared memory (i.e. DMAable) buffers by specifying its own alloc and free routines. The Microsoft documentation says you should avoid doing this, but apparently this did not deter the developers at AMD from doing it anyway. With these changes (which are the result of two straight days of almost non-stop debugging), I think I finally have the object/thread handling semantics implemented correctly. The Am1771 driver no longer crashes unexpectedly during association or bringing the interface up.
* Fix a problem with the way we schedule work on the NDIS worker threads.wpaul2004-02-142-2/+22
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The Am1771 driver will sometimes do the following: - Some thread-> NdisScheduleWorkItem(some work) - Worker thread -> do some work, KeWaitForSingleObject(some event) - Some other thread -> NdisScheduleWorkItem(some other work) When the second call to NdisScheduleWorkItem() occurs, the NDIS worker thread (in our case ndis taskqueue) is suspended in KeWaitForSingleObject() and waiting for an event to be signaled. This is different from when the worker thread is idle and waiting on NdisScheduleWorkItem() to send it more jobs. However, the ndis_sched() function in kern_ndis.c always calls kthread_resume() when queueing a new job. Normally this would be ok, but here this causes KeWaitForSingleObject() to return prematurely, which is not what we want. To fix this, the NDIS threads created by kern_ndis.c maintain a state variable to indicate whether they are running (scanning the job list and executing jobs) or sleeping (blocked on kthread_suspend() in ndis_runq()), and ndis_sched() will only call kthread_resume() if the thread is in the sleeping state. Note that we can't just check to see if the thread is on the run queue: in both cases, the thread is sleeping, but it's sleeping for different reasons. This stops the Am1771 driver from emitting various "NDIS ERROR" messages and fixes some cases where it crashes.
* Correct instance of *timeout that should have been timeout.wpaul2004-02-111-1/+1
| | | | Noticed by: mlaier
* Add yet more bulletproofing. This is to guard against the case thatwpaul2004-02-111-31/+52
| | | | | ndis_init_nic() works one during attach, but fails later. Many things will blow up if ndis_init_nic() fails and we aren't careful.
* Add some bulletproofing: don't allow the ndis_get_info() or ndis_set_info()wpaul2004-02-101-0/+7
| | | | | | | | | | routines to do anything except return error if the miniport adapter context is not set (meaning we either having init'ed the driver yet, or the initialization failed). Also, be sure to NULL out the adapter context along with the miniport characteristics pointers if calling the MiniportInitialize() method fails.
* Remove VFS_STATFS() call which violated the lock order and wasn'tdes2004-02-091-4/+0
| | | | | | | really required anyway. PR: kern/61994 Submitted by: Bjoern Groenvall <bg@sics.se>
* Add stub implementations of KfLowerIrql() and KfRaiseIrql() (both ofwpaul2004-02-091-16/+40
| | | | which are _fastcall).
* Make NdisMMapIoSpace() guard against NULL/uninitialized resource pointers too.wpaul2004-02-081-2/+4
|
* Make NdisMMapIoSpace() handle the case where a device has both memwpaul2004-02-081-3/+5
| | | | and altmem ranges mapped.
OpenPOWER on IntegriCloud