Flow Mini Drive Development Guide (5)

zhaozj2021-02-17  53

Port_configuration_information_information Party Explain is as follows:

SizeOfThispacket

Set the size of this structure, which is responsible for filling this domain by Class Driver.

· Hwdeviceextension

Pointer to the device extension of the device extension of Minidriver. MiniDriver will take this buffer to record some public information for Minidriver, but the external private information. The size of this structure is set by MiniDriver itself, which is recorded in the DeviceExtensions InceSize member of the HW_InInitialization_Data structure. When the MINIDRIVER calls StreamClassRegisterminIDriver registers itself to Class Driver, the structure is passed as a parameter. Class Driver assigns a space for this extended structure and records a pointer to the buffer in the HW_Stream_Object, hw_stream_request_block, and HW_Time_Context members hwdeviceextension, return to MINIDRIVER.

· ClassDeviceObject

Class Driver provides a functional device object (FUNCTIONAL DEVICE OBJECT, FDO) for the driver, and this member retains a pointer to the FDO.

· PhysicalDeviceObject

Pointer to the physical device object PDO. It points to the physical device object PDO corresponding to the driver of the stack top before the Class Driver is added to the driver stack, which is the PDO corresponding to the driver of the secondary stack. . The driver uses the routine IOCALLDRIVER and the driver stack to communicate with the member. RealPhysicalDeviceObject member points to the actual PDO of the device of the driver.

SystemiobusNumber

Class Driver is responsible for populating the domain using the System Bus ID Number of the device. Bus 0 is the main system bus

· AdapterInterfaceType

Specifies the system bus type used by the device to connect to the system, such as ISA, Eisa, Microchannel, PCIBUS, and PCMCIABUS.

· BusInterRuptlevel

Set the mid-end request grade IRQL of the bus, fill in the class driver.

· BusInterruptVector

Set the interrupt vector used by the device, fill in the Class Driver.

InterruptMode, INTERRUPTMODE

Set the interrupt status, shutdown or interrupt level sensitive (LevelSensitive)

· DMACHANNEL

If the device is connected to the ISA bus, Class Driver fills in the member according to the DMA channel of the device.

· NumberofaccessRanges

The number of elements contained in the AccessRange array.

· AccessRanges

Access_Range type structural array, each element describes the scope of hardware resources, such as I / O port range, and memory address range.

· Streamdescriptorsize

MiniDriver will populate the domain with the size of the HW_Stream_Descriptor structure.

· IRP

Penp devices pointing to IRP packets that cause this SRB_INITIALIZE_DEVICE request.

· InterruptObject

If the device uses an interrupt, the Class Driver fills in the member to point to the associated interrupt object.

· DMAADAPterObject If the device uses DMA, Class Driver fills in the member to point to the associated DMAADAPter object.

· RealPhysicalDeviceObject

Point pointing to the driver device PDO

Reserved

It should be ignored by the system.

Typedef struct _hw_stream_descriptor

{

HW_Stream_Header StreamHeader;

HW_stream_information streamfo;

} HW_Stream_Descriptor, * phw_stream_descriptor;

Once the MiniDriver handles that the request (SRB_INITIALIZE_DEVICE), the Class Driver uses routine STRMINIRECEIVEDEVICEPACKET sends SRB_GET_STREAM_INFO requests. After the MiniDriver receives the request, information about all streams of it will provide the callback function of each stream.

When the CLASS DRIVER processing flow data, it sends an SRB_Initialization_complete request with the StrMinireceDevicePacket routine. At this point, MiniDriver is ready to start processing a request for each stream.

Sixth, the steps of the MINIDRIVER control process are generally related to the initialization, call, and uninstall of Minidriver. The commands and structures to be used in the DDK are described in detail in DDK. The steps of initialization, calls, and uninstall of Minidriver are as follows:

1. The PNP Manager enumerates the hardware adapter supported by the MiniDriver, and then the PNP Manager parses all relevant symbol references by checking the registry and sends a request to the I / O subsystem.

2. The I / O subsystem loads MiniDriver and then calls the minidriver's DriveREntry routine, and the assignment will be assigned and initialized and initiallyified. Create a file object (File Object) based on the information in DriveREntry.

3. The DriveREntry routine of Minidriver then calls the stream class deactRegisterminIDriver function and passes the HW_InInitialization_Data structure to this function as a parameter. The HW_InInitialization_Data structure provides the address of those used in MiniDriver to handle functions of SRB. Such MiniDriver can corresponding from the SRB package from Class Driver.

4. During initialization, stream class driver calls the MiniDriver responsible for receiving the SRB's harbor function. This function is specified by the member hwreceivepacket of HW_InInitialization_Data. HwReceivePacket is a function pointer, see StrminireceiveDevicePacket. When called, the Class Driver will put the SRB_INITIALIZE_DEVICE command in the Command domain of the SRB package. After the MiniDriver receives the SRB package, the corresponding to the corresponding to the hardware adapter will be performed.

5. Then, stream Class Driver then calls the function in step 4, in fact, the command sent to minidriver is SRB_GET_STREAM_INFO, indicating that you want to get all the information supported by Minidriver. After the MiniDriver receives this command, it will return information about all streams supported. 6. Subsequently, stream Class Driver continues to call the function in step 4, at this time, the command is SRB_OPEN_STREAM, as mentioned above, a pointer member StreamObject is directed to an HW_STREAM_OBJECT structure, this structure describes information of the stream object. And the flow is identified by a stream number (this stream number is a member of the HW_STREAM_Object structure). After the MiniDriver receives this SRB package, the necessary hardware action will open the specified stream. At the same time, MiniDriver also told Class Driver that has been arranged which two functions have been processed separately from the ReceiveDataPacket, respectively.

7. The initialization and open stream has been completed, by dealing with the data request sent to the Class Driver (another function dedicated to the control request) by deriving the data request from the Class Driver (another function dedicated to the control request), Class Driver can This function is pointed to the ReceiveDataPacket member of the HW_Stream_Object structure of the HW_STREAM_OBJECT structure.

8. By transmitting a function of the Control request issued by the Class Driver, Class Driver can complete the ReceiveControlPacket, which is a ReceiveControlPacket, which is acquiring the streaming properties, setting stream properties, and other control operations. Indicated by it.

9. When the system uses 2 a stream, the stream driver will send a shut-off command SRB_CLOSE_STREAM to MiniDriver's harbor function (this function is pointed to by the HW_InInitialization_data structure). After the MiniDriver receives the command, the corresponding stream is turned off.

10. When you want to uninstall the uninitial adapter, the stream driver sends the SRB_UNINIALIZE_DEVICE command to the MINIDRIVER's harbor function (this function is pointed to by the HW_InInitialization_Data structure). After the MiniDriver receives this command, it will uninstall the device.

DRIVERENTRY routine for stream class minidriver

The DriveREntry routine is used to initialize a stream of MINIDRIVER. This routine is a must. Its prototype is as follows:

Ulong Driverentry

In pvoid argument1,

In pvoid argument2

);

The parameters argument1 and arguement2 provide two context value, which is used in the MINIDRIVER calling streamclassRegisterminIDriver. For Windows2000 and subsequent versions, Argument1 points to a DRIVER_OBJECT structure, and Arguement2 points to the return value of the registration path DriveREntry is the return value of StreamClassRegisterminIDriver.

StreamClassRegisterminIDriver will perform most of the necessary driver initialization, the main task of streaming MINIDRIVER's DriveREntry routine is to assign HW_InIction_Data structures, and populate this structure with driver-specificic constants and entry points. The DriveREntry should then call the StreamClassRegisterminIDriver routine.

Eight, support multi-stream (Multiple Streams)

When MINIDRIVER's STRMINIRECEIVICEPACKET routine responds to the SRB_GET_STREAM_INFO command, MiniDriver describes the information of all its supported streams. SRB's CommandData.StreamBuffer member points to an HW_Stream_Descriptor structure. MINIDRIVER needs to fill this structure with information it supported (see page 7) on the definition of hw_stream_descriptor.

HW_Stream_Descriptor starts with an HW_Stream_Header structure, which describes the number of streams supported by MiniDriver, followed by an HW_STREAM_INFORMATION type structure array, and each element in this array describes a separate stream of information. . Class Driver uses each element in this array to deal with the KsPropsetId_pin property set - the subscript of the array is the type ID of the PIN.

The definition of HW_Stream_Header is as follows:

Typedef struct _hw_stream_header

{

Ulong Numberofstreams;

Ulong sizeofhwstreaminformation;

Ulong Numdevproparrayentries;

PKSPROPERTY_SET DevicePropertiesArray;

Ulong NumdevevenTarrayentries;

PKSEVENT_SET DeviceEventsArray;

PKSTOPOLOGY TOLOGY;

PHW_EVENT_ROUTINE DEVICEEVENTROUTINE

Ulong reserved [2];

HW_STREAM_HEADER, * phw_stream_header;

The definition of HW_Stream_Information is as follows:

Typedef struct _hw_stream_information

{

Ulong NumberofpossibleInstances;

KSPIN_DATAFLOW DATAFLOW;

Boolean DataAccessible;

Ulong NumberofformataRrayEntries;

PKSDataRange * streamFormatsArray;

Pvoid ​​ClassReServed [4];

Ulong NumstreamproparrayEntries;

Pksproperty_Set StreampropertiesArray;

Ulong NumstreamEventArrayEntries;

PKSEVENT_SET streameventsArray;

GUID * category; guid * name;

Ulong Mediumscount;

Const Kspin_Medium * Mediums;

Boolean bridgestream;

Ulong reserved [2];

} Hw_stream_information, * phw_stream_information;

For most Minidriver, the data in the HW_STREAM_DEScriptor structure is determined in the compile period. If this is the case, the MiniDriver can assign a static space for the data structure.

MINIDRIVER describes the topology connection between the stream via the HW_STREAM_HEADER TOPOLOGY. Class Driver uses this structure to process the KspropsetId_topology property set for the MiniDriver processing.

转载请注明原文地址:https://www.9cbs.com/read-29678.html

New Post(0)