ID:BU Bus-Mastering Devices and QEMM-386 Quarterdeck Technical Note #121 by Stan Young Bus-Mastering Devices, QEMM-386 and Virtual DMA Services Q: What is a bus-mastering device and what problems might be seen when using one? Bus-mastering devices are ones which do their own direct memory addressing (DMA). DMA is done without going through the machine's processor. The most common bus-mastering devices we see currently are SCSI hard disk controllers, but technically, other types of devices could be bus-mastering as well. The problem seen with bus-mastering devices is that while they are high-performance devices and quite often found on 386 and 486 machines, they are unfortunately, in their design, incompatible with one of the operating modes of the 80386 and i486 processors -- the Virtual 86 mode. Specifically, the problem is that the device puts data into absolute memory addresses and assumes that the contents of those memory addresses will always remain constant. However, on a 386 machine with the processor in Virtual 86 mode, this can often be an incorrect assumption. In Virtual 86 mode, the same physical memory addresses can, at any given moment hold different data, depending on which virtual machine is current. If you are using a bus-mastering device on a 386 or 486 that is in Virtual 86 mode and actual memory paging is occurring (the switching from one virtual machine to another), your machine will probably hang when you use the bus-mastering device. A "real world" example: Quarterdeck first became aware of the problem from customers who had bus-mastering SCSI hard disk controllers. They reported that they could boot their machines, start our multitasking DESQview software and as long as they ran only one application, their system ran fine. As soon as they opened a second application, the system would hang. The problem was also seen by users who were not using DESQview, but who were using the LOADHI feature of QEMM-386. In this case, the hang occurred because the disk controller would prepare to load some absolute memory addresses with data pertaining to an application that was running, but by the time the data was actually transferred to these addresses, QEMM-386 had switched the memory map. Those absolute memory addresses no longer belonged to the application which could process the data. They belonged instead to some other application or process. In theory, this could have caused data corruption, but in reality it never did. The memory corruption was typically so extensive that the systems simply hung as soon as a change in the memory map occurred. Q: How can the problem with running Bus-mastering devices in Virtual 86 mode be corrected? A: There are four possible solutions: 1) QEMM 5.00 (and later versions) has a DB=xx (DISKBUF=xx) parameter which should prevent QEMM-SCSI problems at the expense of a little conventional memory. xx is the number of K used for buffering. Any value for xx is sufficient to correct the problem. DISKBUF=2 would be fine for most cases. Higher numbers, say up to 10 might improve performance. Setting DISKBUF to more than 10 is probably a waste of memory. This approach will not work in cases where the bus-mastering device is something other than a hard disk. 2) Similarly, the drivers of many bus-mastering hard disks have buffering options. Check the documentation for your disk controller to see if the driver has a parameter to set up buffering for disk operations. Some drivers will also document parameters that are specific to 386 operations. For example, the early Adaptec drivers SCSIHA.SYS and AHA1540.SYS included both 386 and disk buffering options invoked by the parameters "/v386" and "/b:64." "/v386" stands for virtual 386; "/b:64" allocates a 64k buffer, for DMA. 3) Check the documentation for your bus-mastering device and see if it can be configured to use the BIOS or any one of the standard DMA channels. QEMM can correct the problem if the BIOS or standard DMA channels are used. 4) THE BEST SOLUTION: Contact the maker of your bus-mastering device and see if they have a driver available which supports the VDS (Virtual DMA Services) specification. VDS is now an industry-wide specification supported by IBM, Microsoft and Quarterdeck, as well as many other hardware and software suppliers. A VDS driver allows a bus-mastering device to find the real physical address of its data when the processor is in Virtual 86 mode. QEMM 5.00 (and later versions) supports the VDS specification. A VDS driver provides the best solution to this problem in terms of reliability, speed and memory efficiency. Q: I know I have a bus-mastering device on my computer, but I haven't seen any problem. Why not? A: It's possible that your bus-mastering device uses a standard DMA channel for DMA operations. QEMM-386 can correct the problem when standard DMA channels are used. Also, it is quite possible that your bus-mastering device was shipped with a VDS driver. Bus-mastering hard disk controllers are starting to ship with drivers that make VDS calls, and these drivers do not require the DB parameter or any other buffering. We expect that most bus-mastering devices will eventually include VDS drivers and therefore will not exhibit any problems when run in Virtual 86 mode. Copyright (C) 1991 by Quarterdeck Office Systems * * * E N D O F F I L E * * *