Device Control Procedure

Every virtual device needs a device control procedure. The VMM calls this procedure to send the virtual device system control messages. The system control messages direct the virtual device to carry out actions, such as initializing itself, and to notify the virtual device of changes to virtual machines, such as a virtual machine is being created. Most virtual devices define the device control procedure by using the Begin_Control_Dispatch, Control_Dispatch, and End_Control_Dispatch macros as in the following example:


Begin_Control_Dispatch VSAMPLED
    Control_Dispatch   Sys_Critical_Init,  VSAMPLED_Crit_Init
    Control_Dispatch   Device_Init, VSAMPLED_Device_Init
    Control_Dispatch   Sys_Critical_Exit, VSAMPLED_Crit_Exit
End_Control_Dispatch VSAMPLED

In this example, the macros create a device control procedure, named VSAMPLED_Control, and generate instructions that check for the messages Sys_Critical_Init, Device_Init, and Sys_Critical_Exit. When these messages are sent to the procedure, the procedure passes control to a corresponding procedure, such as VSAMPLE_Device_Init, to process the messages. These message-processing procedures must be defined by the virtual device.