Flow Mini Drive Development Guide (4)

zhaozj2021-02-17  63

P 5, initialization process of Minidriver

MINIDRIVER DRIVERENTRY routines will be called when the operating system initializes Stream Class Minidrivers. MINIDRIVER must call StreamClassRegisterminIDriver to register itself to Class Driver. For the DriveREntry routine of Stream Class Minidrivers, please see the sixth section.

When MINIDRIVER Call the StreamClassRegisterminIDriver function registers to the Class Driver, it passes an HW_InIction_Data structure that will be provided to the Class Driver Some basic information, and the Class Driver is initialized by this information to initialize the Minidriver. This information includes, Device-Wide Callbacks, StrminiRecePacket, StrminiRequestTimeout, and StrminiInterrupt.

HW_initialization_data is defined as follows:

typedef struct HW_INITIALIZATION_DATA {ULONG HwInitializationDataSize; PHW_INTERRUPT HwInterrupt; PHW_RECEIVE_DEVICE_SRB HwReceivePacket; PHW_CANCEL_SRB HwCancelPacket; PHW_REQUEST_TIMEOUT_HANDLER HwRequestTimeoutHandler; ULONG DeviceExtensionSize; ULONG PerRequestExtensionSize; ULONG PerStreamExtensionSize; ULONG FilterInstanceExtensionSize; BOOLEAN BusMasterDMA; BOOLEAN Dma24BitAddresses; ULONG BufferAlignment; BOOLEAN TurnOffSynchronization; ULONG DmaBufferSize; ULONG Reserved [2 ];} Hw_initialization_data, * phw_initialization_data; I will explain the meaning of each member of the structure in detail.

Below I explain in detail the meaning of each member of the structure.

· HwinitializationDataSize

Describe the size of this structure, by bytes.

Hwinterrupt

Function pointer points to the STRMINTERRUPT routine for MINIDRIVER.

· Hwreceivepacket

Function pointer, pointing to the STRMINIRECEIVICEVICEPACKET routine of Minidriver.

HWCANCELPACKET

Function pointer points to the STRMINICANCELPACKET routine for MINIDRIVER.

· Hwrequesttimeouthandler

Function pointer, pointing to the StrminireQuestTimeout routine of Minidriver.

· DeviceExtensionsionSize

Note The size of the "Device Extension" "of the device extension" is that Class Driver can know how much buffer space is to be assigned it. Minidriver can be recorded using this space, which is public, but the external private information is for MINIDRIVER. Class Driver will start pointer are stored in the buffer structure HW_STREAM_OBJECT, HW_STREAM_REQUEST_BLOCK, HW_TIME_CONTEXT, and members of HwDeviceExtension PORT_CONFIGURATION_INFORMATION, and then passed to the Minidriver these structures, such as the Class Driver Minidriver know its allocated buffer where the . PERREQUESTEXTENSISIZE

In the Class Driver, the member srbextension is a pointer, which is a buffer, which is used to store the "flow request block extension", which is allocated by Class Driver, so in Class Drive must know how big this space can be found before opening the space. This size is set here. Each SRB has an extension structure, so each SRB will have such a buffer.

Perstreamextensions Ize

The member hwstreamExtension of HW_STREAM_Object is a pointer, pointing to a buffer, this buffer is used to store the stream extension, which is allocated by Class Driver, so before the space is opened, Class Drive must know how big this space is . This size is set here. Each stream has a stream extension structure, so each stream has such a buffer.

· FilterInstanceExtensionsionsize

In the Class Driver, it is also a pointer, which is a pointer, pointing to the starting address of the "instance extension" buffer, which is mush from Class Driver, so it is used here FilterInstanceExtensionsize members set the size of the buffer. There will be such a buffer for each instance of MiniDriver.

· BusmasterDMA

If this member is set to TRUE, the device can perform direct bus control DMA (Direct Bus Master DMA) for MINIDRIVER's DMA Buffer.

· DMA24BITDRESSESSSESSSESSSESSSESSSESSSES

If the DMA hardware used by the device only supports a low 24 bit for all address lines (32 bits to X86), then MINIDRIVER should set this variable to TURE;

· Bufferalignment

Setting the alignment requirements of the DMA buffer, for example, when the value is 4, the DMA buffer requests the DMA buffer to be aligned in the 4-byte boundary.

· Turnoffsynchronization

If the member is set to TURE, then MINIDRIVER handles its own synchronization; otherwise the Class Driver will process synchronous processing. Most MiniDriver should set this member to false, see MINIDRIVER SYNCHRONIZATION (in section 12). · DMABUFFERSIZE

Set the size of the DMA buffer, then Class Driver will open space according to the size. MiniDriver can get the starting address of this buffer by calling streamclassgetdmabuffer. Because this space is continuous, non-paging memory, and once allocated, the space is no longer available to the operating system and other drivers, so it should be set as little as possible.

· Reserved [2]

The system is reserved, and the MiniDriver should ignore this member.

After registration, Class Driver uses strMinireceIveDevicePacket to notify the MiniDriver initializer. It transmits the SRB_Initialize_Device request to MiniDriver and passes a port_configuration_information structure (with a pointer to the structure in the SRB), which contains the necessary hardware information. When the request is processed, MiniDriver tells Class Driver about the size of the Structural HW_STREAM_DESCRIPtor (in bytes), it will use this structure to describe all its streams. The structure of port_configuration_information and hw_stream_descriptor is defined as follows:

typedef struct _PORT_CONFIGURATION_INFORMATION {ULONG SizeOfThisPacket; PVOID HwDeviceExtension; PDEVICE_OBJECT ClassDeviceObject; PDEVICE_OBJECT PhysicalDeviceObject; ULONG SystemIoBusNumber; INTERFACE_TYPE AdapterInterfaceType; ULONG BusInterruptLevel; ULONG BusInterruptVector; KINTERRUPT_MODE InterruptMode; ULONG DmaChannel; ULONG NumberOfAccessRanges; PACCESS_RANGE AccessRanges; ULONG StreamDescriptorSize; PIRP Irp; PKINTERRUPT InterruptObject; PADAPTER_OBJECT DmaadapterObject; PDEvice_Object RealPhysicalDeviceObject; ulong reserved [1];} port_configuration_information, pport_configure_information;

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

New Post(0)