Virtual Keyboard Device Driver

The Virtual Keyboard Device Driver VKBD.SYS provides virtualization support for the keyboard. It allows keystrokes to be passed from the keyboard to virtual DOS machines. It also allows for text to be pasted into the VDM as key strokes.

Upon creation of the VDM, VKBD establishes communication with the physical keyboard device driver and initializes the portions of the CBIOS data area associated with the keyboard. Subsequently, the physical device driver notifies VKBD of each scan code that is bound for the VDM.

To allow monitoring of I/O activity, VKBD registers itself with the 8086 Emulation component. 8086 Emulation then notifies VKBD when a DOS application in a VDM accesses a virtual keyboard port.

VKBD supports two virtual I/O ports:

  • Port 64h - Controller Status/Command

  • Port 60h - Controller Input/Output Buffer.

    These two ports may respond to requests in a variety of ways, depending on the state of the controller at the time of the request.

    Read Output Buffer

    An I/O read request to port 0x60 reads the contents of the controller output buffer. If the "output-buffer-full" status was set before the read request, a timer (T1) is started. The output-buffer-full status is then cleared. When the T1 timer expires, VKBD determines if another byte is ready to be placed into the output buffer. If so, the byte is placed into the output buffer and the "output-buffer-full" status is set.

    Write Output Buffer

    An I/O write request to port 0x60 writes the specified byte to the controller input buffer. The previous contents of the input buffer are lost. The port number (0x60) is saved and the byte written is processed, depending on the current state of the keyboard controller. The "input-buffer-empty" status is never set.

    Status Read

    An I/O read request to port 0x64 simply returns the contents of the controller internal status register. Reading this port has no effect on the state of the virtual keyboard hardware.

    Write Controller Command

    An I/O write request to port 0x64, like a write request to port 0x60, writes the specified byte to the controller input buffer. Since the port number (0x64) is saved here, the system distinguishes between a command byte and a data byte. As above, the byte written is processed, depending on the state of the controller, and the "input-buffer-empty" status is never set.

    Physical Device Driver Notification

    Since keystrokes are external events, it is the responsibility of the physical device driver to notify VKBD when keystrokes are available for processing. In particular, the physical device driver calls VKBD when hardware scan codes arrive, and passes each scan code received to VKBD. This occurs whenever the keyboard's current focus is a virtual DOS machine.

    When called, VKBD places the scan code in a queue. If the queue was previously empty, the controller "output-buffer-full" status condition is set and if interrupts are enabled, the Virtual Programmable Interrupt Controller is called to simulate the interrupt to the VDM. If the queue was not previously empty, the scan code is added without any other processing. If the queue is full, the speaker is sounded.

    INT 09h Processing

    In a "real" DOS environment, the IRQ1 interrupt request is translated by the interrupt controller, causing the INT 09h interrupt service routine to be invoked. This interrupt vector normally points to a routine in the CBIOS. This manner of processing is not desirable in a VDM since the CBIOS only performs U.S. key translation; such processing would complicate the task of national language support. Instead, VKBD simulates this CBIOS function, and may thus use whatever key translation is appropriate for the current country and code page.

    The INT 09h emulation code within VKBD performs all functions that the CBIOS would normally perform. This includes:

  • Key and scan code enqueueing

  • INT 05h (Print Screen) processing

  • INT 15h processing for monitoring scan codes and handling the SysReq key

  • INT 1Bh for Ctrl+Break and Pause key processing

  • Key translation

  • Update of keyboard LEDs

  • Update of the CBIOS data area status.

    Upon termination, VKBD relinquishes access to the keyboard.


    [Back: VFLPY Device Driver]
    [Next: Virtual Printer Device Driver]