GET_VDD_BANK (Function 1)

Call With

EBX: Contains the Windows VM Handle.

ECX and Client ECX: Contain the byte offset of the start of the 32K or 64K VGA 4 plane virtualization area.

EBP: Contains the Windows VM's Client Registers.

Return Values

AH contains the page offset from the start of the VDD bank of the virtualization area. ECX must be preserved. EDX contains the amount of video memory that is devoted to the VGA 4 plane virtualization area. If not allowing VGA 4 plane virtualization, set EDX = ECX or Client_ECX. If allowing VGA 4 plane virtualization, set EDX to either the value 64K or 32K.

Remarks

This function allows the mini-VDD to prepare to implement 4 plane VGA virtualization in a window or in background VM's. In order to allow running VGA 4 plane graphics in a window, your hardware must allow the VGA data pathway while you are in your hi-res packed pixel configuration. The Main VDD sets the hardware up so that the CPU communicates to a 64K piece of memory located below the Windows visible screen just as it would to a 4 plane VGA at address A000h. The VGA 4 plane program draws to this off-screen memory using the VGA's rudimentary BLTer (that is, the VGA write modes and set/reset support). The VDD then reads back the 4 planes and sends the video data back to the Grabber which converts the 4 plane image to a device-independent bitmap and sends it to GDI for display in a window.

Because the off-screen piece of memory is mapped to its A000h segment, the VGA 4 plane application communicates with it just as it would to a real VGA. The Main VDD decides when to map the memory in and out and when to change from the 4 plane state back to packed pixel state. The only thing that the mini-VDD must do is to set to the 64K bank when requested to by the Main VDD and set any hardware registers to their necessary configuration to simulate 4 plane VGA graphics to the program while displaying packed pixel graphics on the monitor.

This functionality is very important to Far East DBCS Windows implementations since they use VGA mode 12h (640x480x4 planes) to implement their DBCS text mode MS-DOS window. This functionality also allows VGA games to run windowed under Windows 95.

The following scenario describes how the Main VDD determines when to do VGA virtualization.

  1. A VGA 4 plane application writes to memory address A000h:xxxx.
  2. The Main VDD gets a page fault from a VM other than the Windows VM.
  3. The Main VDD determines that it is running 4 plane VGA graphics in a window or in the background.
  4. The Main VDD calls RESTORE_REGISTERS in the mini-VDD to setup the hardware for planar VGA support. The appearance of the screen must not change when this state is setup. The mini-VDD should also make sure that banking is accessible on the hardware at this time and not when the Main VDD calls SET_VDD_BANK.
  5. The Main VDD calls SET_VDD_BANK to set to the 64K or 32K off-screen VGA virtualization area. The mini-VDD responds by setting the banking registers to values that it determined when the Main VDD called GET_VDD_BANK.
  6. The Main VDD maps A000h and returns to the VGA 4 plane application which now has a block of memory that it believes is at address A000:0, but in reality is the off-screen memory that the VDD has setup the hardware to access.
  7. The VGA 4 plane application draws to this off-screen memory until Windows 95 decides to switch back to the Windows VM.
  8. Windows 95 does a pre-emptive task switch to the Windows VM. Next the Windows display driver accesses memory at address A000h or flat linear memory; or it uses the I/O registers or memory mapped BLTer registers to access memory. The Main VDD takes either a page fault, register trap or memory fault depending on how the display driver accessed the memory. The Main VDD may at this time read the 4 plane image from the VGA virtualization area and deliver it to the Grabber.
  9. The Main VDD calls the mini-VDD function RESET_BANK to reset the banking registers back to their previous value. The mini-VDD verifies that the banking registers have not been changed and restores them. (The banking registers may be changed if they are not virtualized by the mini-VDD).
  10. The Main VDD calls the mini-VDD function RESTORE_REGISTERS to set the hardware registers back to the Windows running state.
  11. The Main VDD maps A000h or the flat linear buffer, or the memory mapped registers back into the Windows VM. In the case of memory-mapped BLTer or I/O registers, it simulates the I/O on behalf of the VM.
  12. The Windows VM runs until the VGA 4 plane application runs again.

Currently, your card must be able to map in a 32K or 64K bank of video memory at A000h. The mini-VDD, in response to this call, should determine if it has enough memory to do this, and setup the hardware register states to accomplish this. The sample mini-VDDs provide examples of how to do this. If your video card uses a flat linear address space and cannot bank its video memory in at A000h, you cannot do VGA 4 plane graphics in a window or in the background. In case you decide that your current configuration cannot do VGA 4 plane graphics in a window, you should set EDX equal to the entry value of ECX (or Client_ECX) and return. This will indicate to the Main VDD not to allow VGA 4 plane graphics in a window. You can however, still do text (although not DBCS text) in a window and the non-planar graphics modes (such as mode 13H) in a window.

You should allocate the 32K or 64K block of virtualization memory on an even bank boundary. However, the VDD allows you to allocate it on 16K page boundaries (4K per page * 4 planes) by returning a page offset value in AH. For example, if a mini-VDD wants to allocate the last 32K of bank 12 to VGA virtualization, it would return a 2 in AH. This would tell the Main VDD to start halfway down the bank when it maps video memory into the VGA 4 plane VM.

The Main VDD calls this function in response to the display driver calling VDD_DRIVER_REGISTER. It is not called if the display driver passed Client_EDX == -1 (indicating that the display driver decided not to allow VGA 4 plane virtualization).