Driverentry
Driverentry is the entry driver driver, and each miniPort driver should implement it. The tasks that should be completed in Driverentry are as follows:
l Define a video_hw_initialization_data structure and initialize it. The initialized content includes: other portions of the MiniPort driver, the size of Device Extension, and the like.
Video_hw_initialization_data hwinitdata.
// Zero Out Structure.
VideoPortzeromeMory
& HwinitData, Sizeof (Video_HW_Initialization_Data);
// Specify Sizes of structure and extension.
HwinitData.hwinitDataSize = sizeof (video_hw_initialization_data);
// set entry points.
Hwinitdata.hwfindadapter = & virtualfindadapter;
Hwinitdata.hwinitialize = & virtualinitialize;
Hwinitdata.hwstartio = & virtualstartio;
Hwinitdata.hwgetpowerState = & virtualgetpowerState;
HwinitData.hwsetpowerState = & virtualSetPowerState;
Hwinitdata.hwlegacyResourceList = NULL;
Hwinitdata.hwlegacyResourceCount = 0;
// set Device Extension size.
HwinitData.hwdeviceExtensionsIze = sizeof (hw_device_extension);
// Virtual Device's Interface Type IS ZERO.
Hwinitdata.adapterInterfaceType = 0;
l Call the Video_HW_Initialization_Data structure of the video_hw_initialization_data structure to notify the system.
InitializationStatus = VideoPortInitialize (Context1,
CONTEXT2,
& hwinitdata,
NULL);
l Use the return value of the VideoPortInitialize as the return value of the DriveRETRY function, and return to the caller.
Return InitializationStatus;
Code description:
Virtual display driver is similar to mirror driver, so I have a corresponding revision on the basis of Mirror; this is also a Microsoft recommendation implementation: Modify an existing display driver to reduce development time. MIRROR driver is very simple, basically all functions are an empty function. My modification for DriveREntry is primarily: Apply for customized device extension requests storage space.
HwinitData.hwdeviceExtensionsIze = sizeof (hw_device_extension);
HW_Device_extension is a structure I defined myself, used to store the address of the frame buffer: //
// define device extension structure. This is device dependent / private
// information.
//
Typedef struct _hw_device_extension
{
// Frame Buffer
Ulong ulframebuffersize;
PVOID PFRAMEBUFFERADDR;
} HW_DEVICE_EXTENSION, * PHW_DEVICE_EXTENSITION;
Driverentry complete code is as follows:
Ulong
Driverentry
PVOID CONTEXT1,
PVOID Context2
)
{
Video_hw_initialization_data hwinitdata;
Ulong InitializationStatus;
VideoDebugPrint ((0, "Virtualed Driver Videoport [Driver Entry] / N")))
// Zero Out Structure.
VideoPortzeromeMory (& HwinitData, sizeof (video_hw_initialization_data);
// Specify Sizes of structure and extension.
HwinitData.hwinitDataSize = sizeof (video_hw_initialization_data);
// set entry points.
Hwinitdata.hwfindadapter = & virtualfindadapter;
Hwinitdata.hwinitialize = & virtualinitialize;
Hwinitdata.hwstartio = & virtualstartio;
Hwinitdata.hwgetpowerState = & virtualgetpowerState;
HwinitData.hwsetpowerState = & virtualSetPowerState;
Hwinitdata.hwlegacyResourceList = NULL;
Hwinitdata.hwlegacyResourceCount = 0;
// set Device Extension size.
HwinitData.hwdeviceExtensionsIze = sizeof (hw_device_extension);
// Virtual Device's Interface Type IS ZERO.
Hwinitdata.adapterInterfaceType = 0;
InitializationStatus = VideoPortInitialize (Context1,
CONTEXT2,
& hwinitdata,
NULL);
Return InitializationStatus;
} // end driverentry ()