阅读:1090回复:1
Win 2000 Device Drivers Tutorial 6
IRPs
IRPs, or I/O Request Packets, are the main form of communication between the Windows 2000 I/O Manager and its device drivers. When the I/O Manager receives a request from an application program, it formats that request as an IRP, and sends the IRP down to the Device Driver. The driver performs whatever function it is requested to perform, extracting relevant information from the IRP and returning status codes in it. The function code contained in the IRP describes the exact action to be performed: for example, there are IRPs such as IRP_MJ_CREATE to create a file communication to a device, IRP_MJ_READ to read a block of device data into a system or user buffer, IRP_MJ_WRITE to write data to the device from a system or user buffer, and IRP_MJ_DEVICE_CONTROL to issue control requests to the driver. In its simplest form, the communication between application and driver is mediated by the I/O Manager in the way shown in the picture below. Fig 1 This implements a synchronous communication, in the sense that the driver won\'t return a status to the caller application until the I/O request is completed. A driver can also operate in asynchronous mode, where it immediately returns a \"pending\" state to the application while concurrently starting the processing of the I/O request. When the request is completed, the driver uses the Deferred Procedure Call (DPC) mechanism to finish the required I/O processing. We will look at DPCs in a separate tutorial. The I/O Manager uses the IRP to pass information back and forth between itself and the device driver. Some of the fields in the IRP are shown below: Fig 2 Note that the IRP does in fact have a fixed part and a variable part. The variable part contains stack entries that mirror the stacking of device drivers maintained by Windows. We\'ll see later on that Windows 2000 allows you to have multiple drivers per device, and these drivers are stacked in a tree model, generating a structure that\'s loosely called \"the driver stack\". More on this later ! |
|
最新喜欢:![]() |
沙发#
发布于:2002-06-27 14:39
辛苦了!
|
|
|