Introduction to Virtual Device Drivers


Initializing a Win386_Startup_Info_Struc Structure



Download 274.5 Kb.
Page64/80
Date19.01.2022
Size274.5 Kb.
#58083
1   ...   60   61   62   63   64   65   66   67   ...   80
VXDS
Initializing a Win386_Startup_Info_Struc Structure

An MS-DOS device driver or TSR initializes a Win386_Startup_Info_Struc structure to direct Windows to load the virtual device and to reserve the instance data the device driver or TSR needs to operate in the Windows environment. The device driver or TSR is also responsible for establishing a chain of startup structures by copying the contents of the ES:BX register pair to the Next_Dev_Ptr member. It is assumed that any other device driver or TSR in the Interrupt 2Fh chain will have set the ES:BX register pair to the address of its own startup structure prior to returning.

Any device driver or TSR can use a Windows virtual device to help support its operation in the Windows environment. To specify a virtual device, the device driver or TSR sets the SIS_Virt_Dev_File_Ptr member to the address of the virtual device's filename. The device file is assumed to be in the Windows SYSTEM directory. The device driver or TSR can also set the SIS_Reference_Data member to specify additional data to be passed to the virtual device when loaded.

Any device driver or TSR can reserve instance data for itself. Instance data is one or more blocks of memory used by the device or TSR, and managed by Windows. For device drivers or TSRs loaded before Windows starts, reserving instance data allows the device driver or TSR to keep separate data for each virtual machine. Whenever Windows switches virtual machines, it saves the previous VMs instance data and loads the current VMs instance data. If a device driver or TSR does not specify instance data, the same data is used for all virtual machines.

A device driver or TSR reserves instance data by appending an array of Instance_Item_Struc structures to the Win386_Startup_Info_Struc structure. The last structure in the array must be set to zero. Each Instance_Item_Struc structure specifies the starting address and size (in bytes) of an instance data block.

The device driver or TSR must copy the address of its startup structure to the ES:BX register pair before returning.

See also Interrupt 2Fh Function 1606h Windows Termination Notification

Interrupt 2Fh Function 1606h

mov dx, [Flags] ; bit 0 clear


mov ax, 1606h ; Windows Termination Notification

int 2fh ; multiplex interrupt


Windows Termination Notification (Interrupt 2Fh Function 1606h) notifies MS-DOS device drivers and TSRs that Windows is terminating. Windows calls this function as it terminates allowing MS-DOS device drivers and TSRs that monitor Interrupt 2Fh the opportunity to prepare for leaving the Windows environment.

Flags

Specifies whether Windows 95 is terminating. Bit 0 set to 0 for Windows 95; bit 0 to 1 for other, previous versions of Windows. Only bit 0 is used; all other bits reserved and undefined.

 This function has no return value.

Windows calls this function when the processor is in real mode.

See also Interrupt 2Fh Function 1605h Windows Initialization Notification

Interrupt 2Fh Function 1607h

mov bx, [DeviceID] ; device identifier


mov ax, 1607h ; Device Call Out

int 2fh ; Multiplex Interrupt


Device Call Out (Interrupt 2Fh Function 1607h) directs an MS-DOS device driver or TSR to provide information to the calling virtual device. Although the BX register specifies a device identifier, other registers may be used to specify the action to take.

DeviceID

Specifies the device identifier for a virtual device.

 The return value depends on the specific action requested.

This function typically is used by a virtual device to communicate with the driver or TSR that explicitly loaded the virtual device. It is up to the virtual device to supply a correct device identifier and any other parameters that specify what action to take. It is up to the driver or TSR to monitor Interrupt 2Fh, and respond to the function appropriately.

A virtual device can call this function at any time, either in real mode or after Windows has started.

See also Interrupt 2Fh Function 1684h Get Device Entry Point Address



Interrupt 2Fh Function 1608h

mov ax, 1608h ; Windows Initialization Complete Notification

int 2Fh ; multiplex interrupt
Windows Initialization Complete Notification (Interrupt 2Fh Function 1608h) notifies MS-DOS device drivers and TSRs that Windows has completed its initialization. Windows calls this function after it has installed and initialized all virtual devices allowing MS-DOS device drivers and TSRs that monitor Interrupt 2Fh the opportunity to identify instance data and perform other functions that are restricted to Windows initialization.

This function has no parameters.

 This function has no return value.

When Windows calls this function, all virtual-device initialization is complete, so a device driver or TSR can call virtual-device entry points.

Windows does not necessarily call this function immediately after calling Windows Initialization Notification (Interrupt 2Fh Function 1605h). In particular, virtual devices may call Device Call Out (Interrupt 2Fh Function 1607h) or other functions prior to Windows calling this function. In such cases, any MS-DOS device driver or TSR responding to these calls is responsible for detecting and properly handling these calls.

See also Interrupt 2Fh Function 1605h Windows Initialization Notification



Interrupt 2Fh Function 1609h

mov ax, 1609h ; Windows Begin Exit

int 2fh ; multiplex interrupt
Windows Begin Exit (Interrupt 2Fh Function 1609h) notifies MS-DOS device drivers and TSRs that Windows is about to terminate. Windows calls this function when it first begins termination to allow a device driver or TSR to prepare for a return to a non-Windows environment.

This function has no parameters.

 This function has no return value.

Windows calls this function at the start of the Sys_VM_Terminate device control call. All virtual devices still exist, so a device driver or TSR can call a virtual device's entry point if necessary.

Windows does not call this function in the event of a fatal system crash.

Windows may execute real-mode code after this function has been called and before Windows returns to real mode. It is the responsibility of the device driver or TSR to detect and properly handle these situations.



Interrupt 2Fh Function 1680h

mov ax, 1680h ; Release Current VM Time-Slice

int 2Fh ; multiplex interrupt
Release Current VM Time-Slice (Interrupt 2Fh Function 1680h) directs Windows to suspend the time slice of the current VM and start a new time slice for another VM. MS-DOS programs use this function when they are idle, such as when waiting for user input, to allow Windows to run other programs that are not idle.

This function has no parameters.

 The return value is 00h in the AL register if the function is supported. Otherwise, AL is unchanged (contains 80h).

Only non-Windows programs should use Release Current VM Time-Slice; Windows applications should yield by calling the WaitMessage function. A program can call this function at any time, even when running in environments other than Windows environment. If the current environment does not support the function, the function returns and the program continues execution.

Windows suspends the current VM only if there is another VM scheduled to run. If no other VM is ready, the function returns to the program and execution continues. A program should call the function frequently (for example, once during each pass of the program's idle loop) to give Windows ample opportunity to check for other VMs that are ready for execution.

Before calling this function, a program should check that the Interrupt 2Fh address is not zero.



Example

The following example checks for a valid Interrupt 2Fh address, then releases the current VM time slice:

mov ax, 352Fh ; Get Interrupt Vector

int 21h
mov ax, es

or ax, bx

jz Skip_Idle_Call ; es:bx is equal to 0:0


mov ax, 1680h ; otherwise, Release Current VM Time-Slice

int 2Fh


Skip_Idle_Call:
Interrupt 2Fh Function 1681h

mov ax, 1681h ; Begin Critical Section

int 2Fh ; multiplex interrupt
Begin Critical Section (Interrupt 2Fh Function 1681h) prevents Windows from switching execution from the current VM to some other. MS-DOS device drivers and TSRs use this function to prevent a task-switch from occurring.

This function has no parameters.

 This function has no return value.

When a virtual machine is in a critical section, no other task will be allowed to run except to service hardware interrupts. For this reason, the critical section should be released using End Critical Section (Interrupt 2Fh Function 1682h) as soon as possible.

See also Interrupt 2Fh Function 1682h End Critical Section

Interrupt 2Fh Function 1682h

mov ax, 1682h ; End Critical Section

int 2Fh ; multiplex interrupt
End Critical Section (Interrupt 2Fh Function 1682h) releases the critical section previously started using Begin Critical Section (Interrupt 2Fh Function 1681h). Every call to Begin Critical Section must be followed by a matching call to End Critical Section.

This function has no parameters.

 This function has no return value.

See also Interrupt 2Fh Function 1681h Begin Critical Section



Interrupt 2Fh Function 1683h

mov ax, 1683h ; Get Current Virtual Machine ID

int 2Fh ; multiplex interrupt
Get Current Virtual Machine ID (Interrupt 2Fh Function 1683h) returns the identifier for the current virtual machine. MS-DOS device drivers, TSRs, and other programs use this function to determine which virtual machine is running. This is especially important for programs that independently manage separate data or execution contexts for separate virtual machines.

This function has no parameters.

 The return value is the current virtual-machine identifier in the BX register.

Each virtual machine has a unique, nonzero identifier. Although Windows currently runs in virtual machine 1, programs should not rely on this. Windows assigns the identifier when it creates the virtual machine, and releases the identifier when it destroys the virtual machine. Since Windows may reuse identifiers from previous destroyed virtual machines, programs should monitor changes to virtual machines to ensure no mismatches.



Interrupt 2Fh Function 1684h

mov bx, [DeviceID] ; Device identifier


mov ax, 1684h ; Get Device Entry Point Address

int 2Fh ; multiplex interrupt


mov word ptr [DevAddr], di

mov word ptr [DevAddr+2], es ; es:di contains entry point address


Get Device Entry Point Address (Interrupt 2Fh Function 1684h) retrieves the entry point address for a virtual device's service functions. MS-DOS device drivers or TSRs typically use this function to communicate with virtual devices they have explicitly loaded.
1   ...   60   61   62   63   64   65   66   67   ...   80




The database is protected by copyright ©ininet.org 2024
send message

    Main page