There are three stages of minidriver initialization:
Note that the parameters passed to the Enable DDI indicate whether the driver should initialize the GDIINFO structure or the video hardware. Drivers should not rely on the order of the Enable calls.
The kernel calls the display driver's initialization routine when it first loads the driver. At this point, neither GDI nor USER have been loaded, so no graphics operations are required. Instead, you can carry out initialization procedures that do not affect the display adapter. For an example of init code, see the INIT.ASM file in the display driver samples.
GDI calls Enable twice whenever it creates or restores a display DC. One of the calls is to get the GDIINFO block from your minidriver. For a code example, see the ENABLE.ASM file in the display driver samples.
You must set the following fields in the GDIINFO structure for your adapter. Do this after using the DIB_Enable function to get the information from the DIB engine.
dpVersion | dpNumBrushes |
dpHorzRes | dpNumPens |
dpVertRes | dpNumFonts |
dpBitsPixel | dpNumColors |
dpPlanes |
Note that the DIB engine may set capability bits in GDIINFO in addition to those set by the display minidriver. The driver should not modify the bits set by the engine. To achieve this, the driver should use the logical OR operator when setting bits. Minidrivers that do not have an accessible frame buffer should set the NOT_FRAMEBUFFER bit in the deFlags member of the DIBENGINE structure.
If your adapter does not provide a hardware graphics accelerator, set the C1_SLOW_CARD bit in the dpCaps1 member.
When your minidriver has completed initializing the GDIINFO structure, return it to GDI.
Minidrivers initialize the video hardware and create their PDEVICE structure on one of the calls to Enable. Use the following steps to initialize your hardware:
A minidriver should not call FatalExit if it is not possible to enable the hardware. Instead, the Enable function should return zero, indicating failure. This causes the system to reboot into clean Windows with the default VGA driver.
If the display adapter registers itself as requiring bank switching, whenever a page fault occurs during a drawing operation, the VxD maps the required block of memory from the logical frame buffer to A000:0000. By calling the VxD's Create_Virtual_Frame_Buffer function, a driver registers its bank-switching procedure and obtains a selector identifying the logical frame buffer. For more information about the VFLATD, see About Virtual Flat-Frame Buffer Device.
You now have a generic display minidriver. You need to follow the remaining steps in order to customize your minidriver for your display adapter.