IO Request Flow in WDF Kernel-Mode Drivers

Slides:



Advertisements
Similar presentations
1 Symbian Client Server Architecture. 2 Client, who (a software module) needs service from service provider (another software module) Server, who provide.
Advertisements

Generalized Requests. The current definition They are defined in MPI 2 under the hood of the chapter 8 (External Interfaces) Page 166 line 16 The objective.
请点击以下链接下载WinHEC的演讲材料
Introduction to Plug and Play and Power Management in the Windows Driver Foundation 陳怡碩.
Threads Irfan Khan Myo Thein What Are Threads ? a light, fine, string like length of material made up of two or more fibers or strands of spun cotton,
Chapter 7 Protocol Software On A Conventional Processor.
ECE 526 – Network Processing Systems Design Software-based Protocol Processing Chapter 7: D. E. Comer.
Chapter 5 Processes and Threads Copyright © 2008.
6/9/2015B.Ramamurthy1 Process Description and Control B.Ramamurthy.
Linux Device Driver Report I/O Request Flow in WDF Kernel- Mode Drivers.
Process Description and Control
Architectural Support for OS March 29, 2000 Instructor: Gary Kimura Slides courtesy of Hank Levy.
Page 1 Processes and Threads Chapter Processes 2.2 Threads 2.3 Interprocess communication 2.4 Classical IPC problems 2.5 Scheduling.
Introduction to Operating Systems – Windows process and thread management In this lecture we will cover Threads and processes in Windows Thread priority.
Memory Management, File Systems, I/O How Multiprogramming Issues Mesh ECEN 5043 Software Engineering of Multiprogram Systems University of Colorado, Boulder.
I/O Request Flow in WDF Kernel‑Mode Drivers
I/O Request Flaw in WDF Kernel-Mode Driver
© 2004 Microsoft Corporation. All rights reserved. 1 Accessing User Buffers.
1 I/O Management in Representative Operating Systems.
Driver Verifier Advancements In Windows 7 Daniel Mihai Principal Software Design Engineer Windows Engineering Tools.
Kumar Rajeev SDET Microsoft Corporation. KMDF does not support HID minidrivers natively due to conflicting KMDF and HID architecture requirements HID.
1 Lecture 4: Threads Operating System Fall Contents Overview: Processes & Threads Benefits of Threads Thread State and Operations User Thread.
A Critical Analysis of the Windows mLAN Driver Supervisor: Prof. Foss By: Shaun Miles.
© Microsoft Corporation1 Windows Kernel Internals I/O Architecture *David B. Probert, Ph.D. Windows Kernel Development Microsoft Corporation.
FINAL MPX DELIVERABLE Due when you schedule your interview and presentation.
Windows Operating System Internals - by David A. Solomon and Mark E. Russinovich with Andreas Polze Unit OS6: Device Management 6.1. Principles of I/O.
CHAPTER 3 TOP LEVEL VIEW OF COMPUTER FUNCTION AND INTERCONNECTION
Threaded Applications Introducing additional threads in a Delphi application is easy.
Recall: Three I/O Methods Synchronous: Wait for I/O operation to complete. Asynchronous: Post I/O request and switch to other work. DMA (Direct Memory.
10/16/ Realizing Concurrency using the thread model B. Ramamurthy.
Windows 2000 Course Summary Computing Department, Lancaster University, UK.
Tami Meredith, Ph.D. CSCI  Devices need CPU access  E.g., NIC has a full buffer it needs to empty  These device needs are often asynchronous.
Operating Systems Lecture 7 OS Potpourri Adapted from Operating Systems Lecture Notes, Copyright 1997 Martin C. Rinard. Zhiqing Liu School of Software.
Device Drivers CPU I/O Interface Device Driver DEVICECONTROL OPERATIONSDATA TRANSFER OPERATIONS Disk Seek to Sector, Track, Cyl. Seek Home Position.
NT Kernel CS Spring Overview Interrupts and Exceptions: Trap Handler Interrupt Request Levels and IRT DPC’s, and APC’s System Service Dispatching.
14.1 Silberschatz, Galvin and Gagne ©2009 Operating System Concepts with Java – 8 th Edition Chapter 4: Threads.
OS2014 PROJECT 2 Supplemental Information. Outline Sequence Diagram of Project 2 Kernel Modules Kernel Sockets Work Queues Synchronization.
CS333 Intro to Operating Systems Jonathan Walpole.
WHDC PowerPoint Template Notes & Handouts
Chapter 2 Processes and Threads Introduction 2.2 Processes A Process is the execution of a Program More specifically… – A process is a program.
© 2004 Microsoft Corporation. All rights reserved. 1 Minifilter Generated IO’s.
CE Operating Systems Lecture 2 Low level hardware support for operating systems.
1 1999/Ph 514: Flow of Control EPICS Flow of Control Marty Kraimer APS.
I/O, Devices & Device Drivers I/O subsystem It is the responsibility of the I/O subsystem of an OS to schedule, manage, & control the interactions between.
12/22/ Thread Model for Realizing Concurrency B. Ramamurthy.
How to Develop a KMDF Driver. Outline WDF Object model DDI Organization Object context memory Object lifetime WDF Request Flow Through the Driver Request.
CE Operating Systems Lecture 2 Low level hardware support for operating systems.
© Janice Regan, CMPT 300, May CMPT 300 Introduction to Operating Systems Operating Systems Processes and Threads.
4P13 Week 12 Talking Points Device Drivers 1.Auto-configuration and initialization routines 2.Routines for servicing I/O requests (the top half)
© 2004 Microsoft Corporation. All rights reserved. 1 Rules for Filters (both Legacy and Mini)
Windows Operating System Internals - by David A. Solomon and Mark E. Russinovich with Andreas Polze Unit OS3: Concurrency 3.3. Advanced Windows Synchronization.
Cs431-cotter1 Processes and Threads Tanenbaum 2.1, 2.2 Crowley Chapters 3, 5 Stallings Chapter 3, 4 Silberschaz & Galvin 3, 4.
Embedded Computer - Definition When a microcomputer is part of a larger product, it is said to be an embedded computer. The embedded computer retrieves.
Unit 4: Processes, Threads & Deadlocks June 2012 Kaplan University 1.
1 EPICS Flow of Control: EPICS Workshop at IHEP, Beijing, August 2001 EPICS Flow of Control Marty Kraimer APS.
© 2004 Microsoft Corporation. All rights reserved. 1 Processing IO Operations.
Embedded Real-Time Systems Processing interrupts Lecturer Department University.
CSCI/CMPE 4334 Operating Systems Review: Exam 1 1.
Lecture 8 Task Utilization. Theoretical Analysis.
Advanced Operating Systems CS6025 Spring 2016 Processes and Threads (Chapter 2)
NDIS-WDM Miniport Drivers Larry Cleeton Program Manager Windows Networking And Communications Microsoft Corporation.
Oracle Subledger Accounting
Protection of System Resources
I/O Manager, 64-bit Porting, and New Driver Models
Process Description and Control
I/O Procedures.
Process Description and Control
Chapter 2 Processes and Threads 2.1 Processes 2.2 Threads
Mr. M. D. Jamadar Assistant Professor
Chapter 13: I/O Systems “The two main jobs of a computer are I/O and [CPU] processing. In many cases, the main job is I/O, and the [CPU] processing is.
Presentation transcript:

IO Request Flow in WDF Kernel-Mode Drivers 電機所通訊與網路組 694415036 胡育誌

Introduction Every Windows driver must handle I/O requests,even if all the driver does is forward them to another driver Two part: Part one: overall path of an I/O request from the initial request by application Part two: KMDF driver processes an I/O request

Part 1 Application I/O Requests Common I/O Requests Create Close Read & Write Device Control Synchronous and Asynchronous Application Request

I/O Request Path from Application to Driver

I/O Request Path from Application to the Framework Windows Issues a System Service Call for an Application I/O Request The System Service Dispatcher Calls the I/O Manager The I/O Manager Builds an IRP and Sends It to the Framework

Validating request parameters Always checks to ensure that the handle used is valid. Always checks that the user has appropriate access to the device (that is, the user has read access if a read request is being issued, or write access for a write request). If the request uses buffers, checks to ensure that the user-supplied data buffer pointers and data buffer lengths are valid.

Building the IRP Allocates an IRP of the appropriate size (that is, one with enough I/O stack locations for all drivers in the driver stack). Initializes the fixed-size part of the IRP. Initializes the first I/O stack location in the I/O stack. This first I/O stack location contains the request parameters that will be used by the first driver to receive the I/O request. Starting with the first driver, each driver in the stack is responsible for initializing the I/O stack location for the next-lower driver before forwarding the IRP to that driver. The IRP major function code. A description of the user’s data buffer

Sending the IRP to the framework IoCallDriver

I/O Request Path from Framework to Driver

The Framework Routes the Request to the Appropriate Package The I/O Package Checks the I/O Request Type Create (IRP_MJ_CREATE) Cleanup (IRP_MJ_CLEANUP) Close (IRP_MJ_CLOSE) Read (IRP_MJ_READ) Write (IRP_MJ_WRITE) Device control (IRP_MJ_DEVICE_CONTROL) Internal device control (IRP_MJ_INTERNAL_DEVICE_CONTROL)

The I/O Package Further Validates Request Parameters Read and write requests Device control requests

The Framework Processes the Request Handles the request on behalf of the driver Forwards the requests to the driver for the next-lower device in the device stack Creates a WDFREQUEST object that represents the arriving request and passes it to the KMDF driver

KMDF Driver Processing of I/O Requests Processing a Request Internally Processing a Request by Sending It to Another Driver Initializing the next I/O stack location in the request WdfRequestCopyCurrentStackLocationToNext WdfIoTargetFormatRequestForXxxx

Creating and sending new requests Sending requests synchronously or asynchronously Establishing an I/O completion routine callback

Requests Marked Pending During Processing If the application has requested asynchronous processing for this I/O request, control is returned to the calling thread. If the application has requested synchronous processing, the I/O Manager places the thread in a wait state until the request is ultimately completed.

I/O Completion Path from Driver to Application

Driver Completion of a Request I/O status Completion information Requested data

I/O Completion Path from Framework to I/O Manager I/O Manager Completion of a Request Stage 1: Completion processing that might take place in any process and thread context (sometimes called an "arbitrary" process and thread context). Stage 2: Completion processing that must take place in the context of the thread that issued the I/O request.

Part 2: Flow of an I/O Request Within a KMDF Driver Factors that influence the path of an I/O request within a KMDF driver The type of device being supported The driver’s WDFQUEUE configuration The driver’s synchronization scope configuration The overall state of the WDFDEVICE and WDFQUEUE

Framework Receives a Request and Inserts It on a WDFQUEUE WDFQUEUE Insertion Logic Driver Queue Implementation

Framework Invokes the Driver's I/O Event Processing Callback Dispatch Type of the Queue Dispatch Types WdfIoQueueDispatchParallel WdfIoQueueDispatchSequential WdfIoQueueDispatchManual Impact of Dispatch Type on Driver Design

Synchronization Scope for WDFDEVICEs and WDFQUEUEs Specifying Synchronization Scope How Synchronization Scope Works

Queue State WdfIoQueueAcceptRequests WdfIoQueueDispatchRequests WdfIoQueueNoRequests WdfioQueueDriverNoRequests WdfIoQueuePnPHeld

Driver's I/O Event Processing Callback Executes Validating the Arriving Request Processing the Arriving Request Satisfying the Request within the I/O Event Processing Callback Initiating a Request on the Device Sending a Request to Another Driver for Processing

I/O Request Completion Examples WDFDIO Synchronous Request Completion WDFDIO Initiating a Request and Awaiting an Interrupt OSRUSBFX2 Sending a Request and Awaiting Completion

OSRUSBFX2 Sending an Alternate Request Synchronously

Driver's I/O Completion Routine Executes VOID EvtRequestReadCompletionRoutine( IN WDFREQUEST Request, IN WDFIOTARGET Target, PWDF_REQUEST_COMPLETION_PARAMS CompletionParams, IN WDFCONTEXT Context ) { NTSTATUS status; size_t bytesRead = 0; PWDF_USB_REQUEST_COMPLETION_PARAMS usbCompletionParams; UNREFERENCED_PARAMETER(Target); UNREFERENCED_PARAMETER(Context); status = CompletionParams->IoStatus.Status; usbCompletionParams = CompletionParams->Parameters.Usb.Completion; bytesRead = usbCompletionParams->Parameters.PipeRead.Length; WdfRequestCompleteWithInformation(Request, status, bytesRead); return; }

Driver's Interrupt Event Callback Executes Interrupt Event Callback Example

Driver's DpcForIsr Callback Executes DpcForIsr Callback Example

Summary understand the overall flow of an I/O request through the system. It also shows where the kernel-mode driver framework (KMDF) fits within the process, and the type of work that the framework performs are defined by the device type, driver design, WDFQUEUE and dispatching configuration and the device’s synchronization scope. Because of the various processing and synchronization options, a well-designed KMDF driver will typically require few, if any, manually acquired locks to properly serialize access to its shared data structures.