Many virtual devices are written to replace one of the standard virtual devices, that is, one of the virtual devices provided with the Microsoft Windows 95 operating system. However, most virtual devices are written to support new hardware devices or software. In such cases, it is often easier to write a virtual device from scratch than to modify an existing virtual device, because so much of a virtual device is device-specific. Nevertheless, the sources for existing virtual devices should be carefully examined whenever possible because they can reveal the general format and structure of virtual devices, as well as illustrate how to use VMM and virtual device services to carry out useful tasks.
Use the following guidelines when writing a virtual device:
Start with a skeletal virtual device containing the virtual device segments, a virtual device declaration, a device control procedure, stubs for the procedures that process the system control messages, and stubs for the API procedures.
Add a real-mode initialization procedure (optional).
Fill out the procedures that process the initialization messages. These procedures should initialize the control block, allocate global memory, and install callback procedures for interrupts, I/O traps, and page faults.
Fill out the callback procedures that handle the various interrupts and faults.
Add a service table declaration and definitions for the services (optional).
Fill out the API procedures (optional).
Fill out the procedures that process system control messages for creating and destroying virtual machines.
At each stage in writing a virtual device, you can install the virtual device and run Windows under the control of the debugger. Setting breakpoints in your virtual device and monitoring the various interrupts managed by your virtual device can help you determine whether your virtual device is operating correctly.
Share with your friends: |