INF: Routines in the Virtual Display Driver

ID Number: Q75004

3.00

WINDOWS

Summary:

This article contains brief descriptions of the modules in the Windows

3.0 virtual display driver (VDD) sources distributed with the Windows

Device Development Kit (DDK). The table also provides descriptions of

many of the routines within each of the modules.

More Information:

The following contains the module name, the description of the module,

the names of routines in the module, and a description of the

routines.

Module: VDDDATA.ASM

Description: Global data definitions

Module: VDDMSG.ASM

Description: Contains all of the string messages used by the VDD.

Module: VDDINT.ASM

Description: Handles INT 10h, video BIOS interrupts and video-specific

INT 2F (foreground and background signaling) processing. There is

code to handle mode changes and code to increase efficiency by

emulating some BIOS calls.

Routines:

- VDD_Int_10, VDD_I10_Mode_Switch, VDD_I10_Mode_Sw_Done, and

VDD_Int_10_PM are the routines that handle the video BIOS calls.

- VDD_PM_Int_2F, VDD_Int_2F are the routines that handle video INT 2F

calls. See the Appendix D of the "Windows Device Development Kit

Virtual Device Adaptation Guide" for specific information on these

INT 2F calls.

Module: VDDINIT.ASM

Description: Handles setting up hooks and initializing data.

Routines:

- VDD_Sys_Critical_Init does the minimum initialization necessary to

claim resources for the VDD. This routine actually does some of the

processing that should be left until Device_Init; specifically, the

code to claim and map video memory and some SYSTEM.INI parsing

associated with that.

- VDD_VM_Int_10_Stub is code used to hook the INT 10 vector in a

virtual machine (VM). It is copied to make the V86 address space

available globally. Note that the assembly code is of the opposite

size of the actual execution; it is assembled as 32-bit code, but

will execute as 16-bit code. Exercise caution when modifying this

code to add new INT 10 processing.

- VDD_Device_Init is code used to complete VDD initialization,

including setting up the states necessary to enter message mode and

save and restore the video memory.

- VDD_Real_init is real mode code that is loaded and executed before

the transition into protected mode. Note that in some configurations,

this code may be running in Virtual 8086 mode of the processor.

This code detects specific display adapters and passes flags to the

above initialization routines.

Module: VDDSVC.ASM

Description: Routines used by Winoldap, the Grabber and other VxDs.

The routines include message mode processing, VM video state

update, and VDD error message processing.

Routines:

- VDD_Get_Version and VDD_Get_GrbVersion are used to verify

compatibility with other components of the system.

- VDD_Msg_ClrScrn and VDD_Msg_InitScreen initialize message mode.

- VDD_Msg_ForColor, VDD_Msg_BakColor, VDD_Msg_TextOut, and

VDD_Msg_SetCursPos are routines that support text mode messages

during message mode.

- VDD_PIF_State is used by Winoldap to pass PIF information to the

VDD.

- VDD_Set_HCurTrk is used by the VKD (virtual keyboard driver) to

indicate that the cursor should be kept visible during horizontal

scrolling because the user is typing.

- VDD_Get_GrabRtn is used by Winoldap to get the procedure for full

screen grabs.

- VDD_Hide_Cursor is used to hide the cursor when the VM is windowed

so that Window's caret and a cursor are not both present in the

VM's display.

- VDD_Query_Access is provided for other VxDs to determine if the

video memory may be accessed at a given time. This is primarily

used by the mouse driver when erasing the VM's mouse cursor.

Erasing the cursor may occasionally be delayed (the cursor may show

in the window for a while).

- VDD_Set_VMType is used by Winoldap to inform the VDD of the method

of display for this VM.

- VDD_Get_ModTime allows for idle detection by returning the last

time the VM modified its video state.

- VDD_Begin_Msg_Mode and VDD_End_Msg_Mode allow for clean transitions

in to and out of message mode.

- VDD_PM_API is the entry for the Grabber to call the VDD.

- VDD_Grb_Version returns the VDD version to the Grabber.

- VDD_Get_GrbState returns VM video state for last full screen grab.

- VDD_Get_State returns current VM video state.

- VDD_Get_Mod returns the changes to the VM video state.

- VDD_Clear_Mod clears the changes to the VM video state. Note that

because enhanced mode preemptively multitasks VMs, it is possible

to get changes from the beginning of rendering a VM's state in a

window to this Clear Mod call. The 3.0 VDD handles this by not

clearing modifications when these changes are detected.

- VDD_Get_Mem returns a pointer to a copy of the video memory for the

Grabber. It also invokes VDD_Suspend_NormSch.

- VDD_Suspend_NormSch provides for speedy painting of a VM in a

window since other VMs will only get interrupts until normal

scheduling is resumed.

- VDD_Get_GrbMem returns a pointer to a copy of the grabbed video

memory for the Grabber.

- VGMm_Set_Struc returns a structure of information on the VM's video

state.

- VDD_Free_Grab releases the copy of video memory made for the

Grabber.

- VDD_Free_Mem indicates the memory has been rendered in a Windows.

It also invokes VDD_Unlock_App.

- VDD_Unlock_App undoes the Suspend_NormSch.

- VDD_SysModalMsg, VDD_Message, VDD_Msg_NotWindow, VDD_Msg_Exclusive,

VDD_Msg_NoSupMode, VDD_Msg_NoFGrnd, VDD_Msg_NoMainMem,

VDD_Msg_NoCopyMem, and VDD_Msg_CannotGrab are routines that support VDD

error messages.

Module: VDDCTL.ASM

Description: Handles messages sent by the virtual machine manager (VMM),

including dispatching of some message to other modules.

Routines:

- VDD_VMCreate initializes VM control block.

- VDD_VMInit sets VM initial video state.

- VDD_VMSetFocus changes ownership of physical display.

- VDD_VMDestroy releases resources owned by VM.

- VDD_Suspend allows VDD to temporarily cease processing for this VM,

including unlocking memory and canceling timeouts.

- VDD_Resume undoes the suspend.

- VDD_System_Exit and VDD_Sys_Critical_Exit provide for system clean-

up and video restore as Windows exits.

- VDD_SetupInitialVideoState is used to initialize message mode and

initial VM video state.

- VDD_VM_Critical_Init performs critical VM initialization. This

probably could be done in VM_Init.

- VDD_Resume_Bkgnd_VMs - When a VM is suspended by the VDD because it

cannot get the video resources it needs to run, it is resumed here

when those resources become available.

- VDD_DebugQuery is called when the debugger ".VDD" command is

invoked. Displays information on the video state.

Module: VDDMEM.ASM

Description: Handles the VM's video address space and allocating

physical memory to VMs.

Routines:

- VDD_Mem_VMCreate allocates resources needed.

- VDD_Mem_VMInit initializes data.

- VDD_SetEGAMemSize limits EGA BIOS to 256K (so second half is available

for background VMs).

- VDD_Mem_VMSetTyp handles adjusting state for windowed or full

screen.

- VDD_SetCopyMask.

- VDD_Mem_VMDestroy releases memory allocated for VM and adjusts data

structures.

- VDD_CheckMmgrCallOK makes sure MMGR is not busy.

- VDD_Mem_AMain allocates "save" memory for a VM.

- VDD_Mem_ACopy allocates "copy" memory for a VM used for grabs and

windowed updates.

- VDD_Mem_DMain and VDD_Mem_DCopy deallocate memory.

- VDD_Mem_Disable disables a VM's access to video pages.

- VDD_Mem_Physical maps a VM's video pages to physical display

adapter.

- VDD_Mem_Physical2 maps a VM's video pages to physical display

adapter pages that are not visible.

- VDD_Unmapped disables access to pages not available in the current

video mode.

- VDD_Mem_Update copies "save" memory to "copy" memory as part of a

Window update.

- VDD_Mem_ModPag determines which pages of video memory have been

touched.

- VDD_Mem_UpdOff and VDD_Adj_Msk adjust modified pages by visible

pages for window update.

- VDD_Mem_ChkPag and VDD_Mem_Chg return a data structure on modified

video memory.

- VDD_Mem_Valid checks the memory that is mapped for video access and

the video adapter register values to determine if memory is not

correctly mapped.

- VDD_Mem_Remap adjusts video page mapping for current video state.

- VDD_Mem_Null and VDD_Mem_MapNull maps null memory in VM's video

address space.

- VDD_Mem_CalcPage maps linear address to save memory page number.

- VDD_Mem_I10Done remaps video memory at end of mode change.

Module: VDDPROC.ASM

Description: Miscellaneous procedures, including handling of display

ownership, windowed VM updating, and VM video page faults.

Routines:

- VDD_PFault handles page faults. Page faults are generated when VM

needs to access video memory not currently owned. This is due to a

mode change or when running in background in second half of memory

and display owner has run.

- VPF_SuspendNow_Event and VPF_Susp_Event handle suspending VMs when

they cannot access needed resources.

- VDD_VMIdle allows VDD to indicate to Winoldap that VM's windowed

display needs updating whenever VM has no other processing to do.

- VDD_Set_Time_Slice adjust VM's and system VM's execution when

updating a windowed VM. This is to account for the system VM

executing on behalf of the windowed VM.

- VDD_VMTimeOut, VDD_Set_VM_Time_Out, and VDD_Clr_VM_Time_Out provide

regular windowed VM update processing.

- VDD_Update_Window signals Winoldap that VM's window should be

updated.

- VDD_Detach removes VM from display ownership.

- VDD_Attach2 and VDD_Detach2 support running a graphics application in

the background on nonvisible display memory.

- VDD_VMDA_Update, VV_Update_Event, Vid_Upd_CallBack support updating

windowed VMs.

- VDD_VMDA_Grab, VV_Grab_Event and Vid_Grab_CallBack support full

screen grabs.

Module: VDDSAVE.ASM

Description: Save and restore of the video memory and registers.

Routines:

- VDD_Save saves VM state of VM that owns display.

- VDD_FGrnd_Notify and VDD_Backgrnd_Event support INT 2F processing

for application in the VM.

- VDD_Restore, VDD_Do_Restore, VDD_Dont_Restore, VDD_Cancel_Restore,

and VDD_Restore_Event support moving foreground VMs in to and out

of visible video memory.

- VDD_Save2, VDD_Restore2, VDD_Cancel_Restore2, and

VDD_Restore2_Event support moving background and windowed VMs in to

and out of nonvisible video memory.

- VDD_Grab, VDD_GrabTextMode, and VDD_CopyTextPages support full

screen grabs.

- VDD_Pre_SR and VDD_SR_Setup set up for save/restore memory.

- VDD_SRAM and VDD_Save_RAM save video memory.

- VDD_Clear_RAM and VDD_Restore_RAM support restoring video memory.

- VDD_MsgRestFontAndClear, VDD_SaveMsgStt, VDD_RestMsgStt, and

VDD_MsgSaveFont support initializing and restoring message mode

video memory.

- VDD_RestCRTC, VDD_OutC_Ctrlr, VDD_Scrn_Off, VDD_RestIndx, and

VDD_Global_Restore support restoring video registers.

- VDD_Save_Latches and VDD_Restore_Latches support video latch

save/restore.

- VDD_RestCtlr restores registers associated with CPU access to video

memory without affecting the display. This is to support running

background VMs in nonvisible display memory.

- VDD_SaveRegs_Event and VDD_SaveRegs save video registers.

- VDD_Save_HW_Regs and VDD_Res_HW_Regs support a special interface

for saving and restoring video state on an EGA in the system VM.

Note that this avoids trapping the system VM and is closely linked

with the EGA display driver.

Module: VDDSTATE.ASM

Description: Keeps track of VM's state and changes of state to report

to Grabber for rendering display in a Window.

Routines:

- VDD_State_VMCreate initializes VDD data structures associated with

VM's video state.

- VDD_State_GetStt updates Grabber data structure with current VM

video state.

- VDD_State_CtlrChgs updates Grabber data structure with indications

of mode and cursor changes.

- VDD_Mod_Text, VDD_State_MemChgs updates Grabber data structure with

VM's video memory changes.

- Vid_Chk_Cursor, VDD_State_Query indicate if controller state has

changed.

- VDD_State_Update copies current state to copy of state (used for

tracking changes to controller state).

- VDD_Scrn_Size calculates screen size.

- VDD_Get_Mode calculates video mode from register values.

- VDD_Get_EGA_Posn gets cursor position.

Module: VDDTIO.ASM

Description: Handles I/O trapping and register state maintenance.

Routines:

- VDD_IO_Init installs port hooks.

- VDD_IO_SetTrap enables/disables port hooks.

- VIOT_* - The port trap handlers.

Module: VDDVGA.ASM

Description: Additional VGA-specific register save/restore and I/O

traps.

Routines:

- VDD_Init_DAC, VDD_VGA_SaveDAC, and VDD_Rest_DAC initialize the data

structure, save, and restore the DAC.

- VDD_SaveCtlr, VDD_VGA_SaveAttr, VDD_VGA_SaveMisc, VDD_VGA_SaveCRTC,

VDD_VGA_SaveGrp, and VDD_VGA_SaveSeq read the VGA registers.