Umdf Intro

25
Introduction to User-Mode Driver Framework

Transcript of Umdf Intro

Page 1: Umdf Intro

Introduction to User-Mode Driver Framework

Page 2: Umdf Intro

OutlineOutlineWhat is UMDF?When should I use UMDF?When shouldn’t I use UMDF?What does UMDF give me?

What kind of drivers can I write?What can my drivers do?

What next?

Page 3: Umdf Intro

GoalsGoalsHow UMDF fits into WDFUnderstand UMDF’s capabilities

Page 4: Umdf Intro

Current Driver ModelsCurrent Driver ModelsWindows has several different driver models

Windows Driver Model (WDM) is the generic modelSpecific driver models for popular devices classes

Storage, Networking, Printing, Imaging, etc...Some built on top of WDM. Others run as user-mode services.

WDM FeaturesAsynchronous, packet-based I/OI/O CancellationLayering of driversDynamic loading and unloading of driversPlug and Play & Power managementLow-level high-performance interfaces

WDM AdvantagesLarge device coverageFlexible

Page 5: Umdf Intro

Limitations with Current ModelsLimitations with Current ModelsGeneric driver model (WDM) is too complex

Focuses on very advanced drivers which punishes simple onesPoor DDI design

Device specific models have complexity of their ownOften this bubbles through from WDMDeveloper trapped in device-specific modelPoor knowledge transfer from one to the next

Many drivers must be written in kernel mode Even though much functionality could be user mode

Developers spend too much time driving our softwareCannot concentrate on driving their hardwareDriver quality suffers as a result

Do not allow extension and future growth

Page 6: Umdf Intro

Overview of Current Driver ModelsOverview of Current Driver ModelsDevice/Driver Classes Current Model

Display Adapters Video port

Storage Adapters (SCSI & ATA) SCSIport, Storport, ATAport,

Network Adapters NDIS

Video Capture AvStream

Audio Adapters AVStream, PortClsFile System filters FS Mini filter

Printers UniDrv

Scanners,Cameras WIA

PCI, PC Card, generic filter drivers WDM

Modems, Cable Modem WDM & NDIS WDMBiometric Devices WDM

Smart Card Devices WDM

Keyboard/Mouse Filters WDM

Legacy Devices (Serial, Parallel) WDM

Portable Media Players WMDMUPnP & Network Connected Devices, Cell Phones No support

USB, 1394, Bluetooth, SD devices WDM (kernel), no support (user)

Others WDM

Page 7: Umdf Intro

Windows Driver FoundationWindows Driver FoundationWe need a new generic driver model that ...

Scales conceptually from simple to extremely complex driversCan be extended to domain specific modelsCan be validated at compile-time as well as run-time

Windows Driver Foundation (WDF) consists ofA generic driver modelImplementations of that model

Kernel Mode Driver Framework (KMDF)User Mode Driver Framework (UMDF)

Driver Verification ToolsStatic Driver VerifierPREfast for Drivers

Page 8: Umdf Intro

Windows Driver Foundation GoalsWindows Driver Foundation GoalsSimplicity

No harder than it needs to be to accomplish a task

Fast time to market for driversLet driver developers focus on their domain, not ours

Reduce crashes and blue screens due to driversBetter customer experience helps everyone

Provide complete driver development experienceDevelop and test

Built-in diagnosability, tracing, verification tools

Deployment and InstallSupport versioning

Page 9: Umdf Intro

Windows Driver Foundation- ExperienceWindows Driver Foundation- Experience

Page 10: Umdf Intro

Overview of Current (User) Driver ModelsOverview of Current (User) Driver ModelsDevice/Driver Classes Current Model

Display Adapters Video port

Storage Adapters (SCSI & ATA) SCSIport, Storport, ATAport,

Network Adapters NDIS

Video Capture AvStream

Audio Adapters AVStream, PortClsFile System filters FS Mini filter

Printers UniDrv

Scanners,Cameras WIA

PCI, PC Card, generic filter drivers WDM

Modems, Cable Modem WDM & NDIS WDMBiometric Devices WDM

Smart Card Devices WDM

Keyboard/Mouse Filters WDM

Legacy Devices (Serial, Parallel) WDM

Portable Media Players WMDMUPnP & Network Connected Devices, Cell Phones No support

USB, 1394, Bluetooth, SD devices WDM (kernel), no support (user)

Others WDM

Page 11: Umdf Intro

Why Build a User-Mode Framework?Why Build a User-Mode Framework?Difficult to provide high-quality drivers

Crash statistics prove thisWDF Framework makes drivers easier to write

Lots of driver models already live in user spacePrinters, Audio, ImagingDivergent driver models has become a problemUMDF brings general-purpose model into user-mode

General UMDF provides:Unified facilitiesSupport for WDF model

Page 12: Umdf Intro

What is UMDF?What is UMDF?Implementation of the WDF Driver ModelProvides ...

The infrastructure to run a device driver in user-modeThe WDF I/O Pipeline and PnP/PM State MachineThe core WDF objects

Devices, Files, Queues, Requests, I/O Targets, etc...

UMDF and KMDF both share the WDF ModelSo learning how to use one will apply to the otherBut they are not source or binary compatible

Have similar but not identical DDIsEach has additional functionality applicable to its domain

Page 13: Umdf Intro

Device Stack

Overview of the ArchitectureOverview of the Architecture

Provided by:Microsoft

ISV

IHV

Driver Manager

Host ProcessUser

Kernel

FrameworkUM driver

FrameworkUM driver

Reflector

...

CoInstaller

Kernel Driver

Kernel Driver

Page 14: Umdf Intro

Who Should Use UMDF?Who Should Use UMDF?Existing driver developers…

Who want to move drivers to user spaceWho already have the “driver mindset”

New driver developers…Coming from application developmentWho need to provide device supportWho are learning new skills

Anyone who wants to...Build a driver without a lot of development overheadReduce the risks associated with traditional driversStop causing blue screens

Page 15: Umdf Intro

Where can you use UMDF?Where can you use UMDF?Primary Scenarios

“Protocol Bus” devicesDevices attached to USB, 1394, TCP/IP, etc...

Software-only driversFilter drivers, virtualized serial port, etc…

Current DevicesPortable Media Players, Cell Phones, PDAs/ActiveSync, Auxiliary Display, Cameras

Future DevicesDevices on future protocol bussesDevices where driver can be split into ...

Small kernel-mode component to do hardware accessLarger user-mode driver to provide complex functionality

Page 16: Umdf Intro

When and How To Use UMDFWhen and How To Use UMDFUMDF is a standard Windows codenamed “Longhorn” feature

Support in WDK

Build with the WDK Build EnvironmentStandard device driver build environmentNo integration with Visual Studio

Page 17: Umdf Intro

Why Use UMDF?Why Use UMDF?Uses the WDF Driver Model

Can learn a single model that applies to KM and UM drivers

Faster development cycleEasier debugging on a single machineCrashes during development don’t require a reboot

Access to user-mode servicesWin32 file I/O, Function Discovery, WINSOCK, RPC, CryptoBut you have to be careful…

Page 18: Umdf Intro

Why Use UMDF?Why Use UMDF?Improved stability

User-Mode Drivers are isolated from other driversKernel is isolated from user-mode drivers

Increased securityCompromised driver does not crash the systemLower privileges restrain a compromised driver

RecoverabilitySystem can recover after a driver crash – no blue-screensThe driver can be restarted without rebooting

Page 19: Umdf Intro

Kernel-Mode or User-Mode Driver?Kernel-Mode or User-Mode Driver?You must use kernel mode when you:

Need direct hardware access, for example,Require DMAMust handle interruptsNeed access to device registers

Have strict timing requirementsUMDF will have increased latency

Need kernel-only resourcesOr kernel components need access to your driver

Page 20: Umdf Intro

Features You Can Use in Your DriverFeatures You Can Use in Your DriverGeneral WDF capabilities

PnP/PM provides “opt-in” callbacks for various eventsObject model has context management & flow controlI/O Targets allow driver to send new I/O requests

Regardless of where the target device driver is runningCoordinated with cancellation and cleanup

Escape to Win32 and user-mode servicesStandard facilities for Windows I/O model

PnP Device DiscoverySynchronous & Asynchronous I/O with CancellationBuffered and Direct I/O transfers

Standard INF Driven setup

Page 21: Umdf Intro

Common ConcernsCommon ConcernsWill a user-mode driver be fast enough?

UMDF driver can already flood a portable media deviceUMDF may increase latency, but throughput remains high

Performance is one of our top prioritiesBut it’s not always the top priority for driver developers

Balanced with improvements in quality, stability, security, etc...

Will a user-mode driver be secure?As secure as any other user-mode service

RPC, LSASS, WinLogon, etc...A compromised user-mode driver is more contained

Cannot crash the system or expose kernel secrets

Will user-mode drivers be high quality drivers?We’ll continue to push to improve driver quality in all modelsUMDF will prevent badly behaved drivers from crashing the system

Page 22: Umdf Intro

What’s Next?What’s Next?Development platform is the WDK/LDKCurrently allows developing drivers for LonghornBut we know that’s not enough…

Plan to support Windows XP in Longhorn time-frame

Versioning supportSupport for side-by-side installation

Beta programWindows Driver Foundation Beta Program Invitation

http://www.microsoft.com/whdc/driver/wdf/beta.mspx

Page 23: Umdf Intro

Call To ActionCall To ActionInstall the Windows Driver KitJoin the WDF Beta Program

At http://beta.microsoft.comGuest ID: Guest4WDF

Evaluate UMDF for your driver projectsConsider development time, customer support for system crashes, etc.

Send Us Feedback - We want to knowIf UMDF will meet your needsWhat stops you from writing your drivers with UMDFEmail: umdffdbk @ microsoft.com

Page 24: Umdf Intro

Additional ResourcesAdditional ResourcesWeb Resources:

WDF Information:http://www.microsoft.com/whdc/driver/wdf/default.mspx

Windows Debugger:http://www.microsoft.com/whdc/devtools/debugging/default.mspx

External Resources“Introduction to the Windows Driver Foundation: How To Develop Device Drivers Using the Kernel Mode Driver Framework” from OSR Press

Release date is September 2005Focuses on KMDF but provides general WDF information as well

Page 25: Umdf Intro

© 2005 Microsoft Corporation. All rights reserved.This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.