Install_IO_Handler


include vmm.inc

mov     esi, IOCallback     ; points to callback procedure
mov     edx, Port           ; I/O port number
VMMcall Install_IO_Handler

jc      not_installed       ; carry flag set if procedure not installed

Installs a callback procedure for I/O port trapping, and enables trapping for the specified port. Only one procedure may be installed for a given port. For Windows 95, this service can be called following initialization. Uses Flags.

IOCallback

Address of the callback procedure. For more information about the callback procedure, see below.

Port

Number of the I/O port trap.

The service returns an error if a callback procedure is already installed for the specified port or the system limit for I/O callback procedures has been reached.

The system calls the callback procedure whenever a program in a virtual machine attempts to access the specified I/O port, and I/O trapping is enabled. The system calls the procedure as follows:


mov     ebx, VM             ; current VM handle
mov     ecx, IOType         ; type of I/O
mov     edx, Port           ; port number
mov     ebp, OFFSET32 crs   ; points to a Client_Reg_Struc
mov     eax, Data           ; output data (if I/O type is output)
call    [IOCallback]

mov     [Data], eax         ; input data (if I/O type is input)

The VM parameter specifies the current virtual machine, the Port parameter specifies the I/O port, and the crs parameter points to a Client_Reg_Struc structure containing the register contents for the current virtual machine.

The IOType parameter specifies the type of input or output operation requested and determines whether the callback procedure receives data in the EAX register or must return data in the EAX register. The IOType parameter can be a combination of the following values:

Value

Meaning

Addr_32_IO

Use 32-bit address offsets for input or output string operations. If this value is not given, the 16-bit offsets are used.

Byte_Input

Input a single byte; place in AL if String_IO not given.

Byte_Output

Output a single byte from AL if String_IO not given.

Dword_Input

Input a double word; place in EAX if String_IO not given.

Dword_Output

Output a double word from EAX if String_IO not given.

Rep_IO

Repeat the input or output string operation the number of times specified by the Client_CX field in the Client_Reg_Struc structure. (The number of repetitions is stored in the Client_ECX field if Addr_32_IO is also set.)

Reverse_IO

Decrement string address on each input or output operation. If this value is not given, the string address is incremented on each operation.

String_IO

Input or output a string. The high 16-bits specifies segment address of buffer containing the string to output or to receive the string input.

Word_Input

Input a word; place in AX if String_IO not given.

Word_Output

Output a word from AX if String_IO not given.


The Data parameter is used only for when I/O type is for output.

A virtual machine can disable trapping of a port for every or for specific virtual machines by using the Disable_Global_Trapping and Disable_Local_Trapping services.

See also Disable_Global_Trapping, Disable_Local_Trapping, Install_Mult_IO_Handlers