Programming 版 (精华区)
发信人: zpw (zhao), 信区: Programming
标 题: FAQ for VXD(之八)
发信站: 紫 丁 香 (Tue Jul 28 14:17:00 1998), 转信
I need to write a Windows device driver. Should it be a DLL or a VxD?
This is the kind of question whose answer really depends on your
application and your objectives. In general, a VxD is more difficult to
develop, but yields higher performance when processing interrupts and
accessing I/O ports. A VxD can also do things that aren't otherwise
possible with a DLL.
The first step is to determine what it is that your driver must do. If it
must support a hardware device, then which of the following system
resources are required by your hardware?
a.) I/O ports
b.) IRQ lines
c.) Memory ranges
d.) DMA channels
If I/O ports are involved, then be aware that there are performance issues
related to accessing I/O ports from ring 3, as you would in a DLL, as
compared to accessing them from ring 0 in a VxD. There is overhead
associated with accessing I/O ports from ring 3, perhaps as much as 100% or
more (i.e. ring 3 accesses take twice as much time as ring 0 accesses). If
the port is trapped by another driver, then the overhead to access the port
will be drastically greater.
If IRQ lines are involved, then be aware that there is significantly more
interrupt latency associated with an ISR running in ring 3 than in a VxD.
Access to physical memory can be accomplished with DPMI services in a DLL,
or VMM services in a VxD.
Access to DMA channels from application level should go through VDS
(Virtual DMA Services).
If you need to make your hardware appear to be shared by Windows
applications and DOS applications running in separate DOS boxes, then you
need to "virtualize" your hardware with a VxD. You also need to
"virtualize" your hardware if you need to mediate access, or resolve
contention for your device.
Note also that VxDs are not supported for Windows NT or OS/2, as those
operating systems use a different form of device driver. DLLs should work
correctly across the platforms.
--
※ 来源:.紫 丁 香 bbs.hit.edu.cn.[FROM: yaoyu.hit.edu.cn]
Powered by KBS BBS 2.0 (http://dev.kcn.cn)
页面执行时间:3.523毫秒