250 likes | 601 Views
Introduction to User-Mode Driver Framework. Outline. What 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?. Goals. How UMDF fits into WDF Understand UMDF’s capabilities.
E N D
Outline • What 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?
Goals • How UMDF fits into WDF • Understand UMDF’s capabilities
Current Driver Models • Windows has several different driver models • Windows Driver Model (WDM) is the generic model • Specific driver models for popular devices classes • Storage, Networking, Printing, Imaging, etc... • Some built on top of WDM. Others run as user-mode services. • WDM Features • Asynchronous, packet-based I/O • I/O Cancellation • Layering of drivers • Dynamic loading and unloading of drivers • Plug and Play & Power management • Low-level high-performance interfaces • WDM Advantages • Large device coverage • Flexible
Limitations with Current Models • Generic driver model (WDM) is too complex • Focuses on very advanced drivers which punishes simple ones • Poor DDI design • Device specific models have complexity of their own • Often this bubbles through from WDM • Developer trapped in device-specific model • Poor 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 software • Cannot concentrate on driving their hardware • Driver quality suffers as a result • Do not allow extension and future growth
Windows Driver Foundation • We need a new generic driver model that ... • Scales conceptually from simple to extremely complex drivers • Can be extended to domain specific models • Can be validated at compile-time as well as run-time • Windows Driver Foundation (WDF) consists of • A generic driver model • Implementations of that model • Kernel Mode Driver Framework (KMDF) • User Mode Driver Framework (UMDF) • Driver Verification Tools • Static Driver Verifier • PREfast for Drivers
Windows Driver Foundation Goals • Simplicity • No harder than it needs to be to accomplish a task • Fast time to market for drivers • Let driver developers focus on their domain, not ours • Reduce crashes and blue screens due to drivers • Better customer experience helps everyone • Provide complete driver development experience • Develop and test • Built-in diagnosability, tracing, verification tools • Deployment and Install • Support versioning
Why Build a User-Mode Framework? • Difficult to provide high-quality drivers • Crash statistics prove this • WDF Framework makes drivers easier to write • Lots of driver models already live in user space • Printers, Audio, Imaging • Divergent driver models has become a problem • UMDF brings general-purpose model into user-mode • General UMDF provides: • Unified facilities • Support for WDF model
What is UMDF? • Implementation of the WDF Driver Model • Provides ... • The infrastructure to run a device driver in user-mode • The WDF I/O Pipeline and PnP/PM State Machine • The core WDF objects • Devices, Files, Queues, Requests, I/O Targets, etc... • UMDF and KMDF both share the WDF Model • So learning how to use one will apply to the other • But they are not source or binary compatible • Have similar but not identical DDIs • Each has additional functionality applicable to its domain
Overview of the Architecture Framework Framework UM driver UM driver Provided by: Microsoft ISV IHV Driver Manager Device Stack Host Process CoInstaller User Kernel Reflector Kernel Driver ... Kernel Driver
Who Should Use UMDF? • Existing driver developers… • Who want to move drivers to user space • Who already have the “driver mindset” • New driver developers… • Coming from application development • Who need to provide device support • Who are learning new skills • Anyone who wants to... • Build a driver without a lot of development overhead • Reduce the risks associated with traditional drivers • Stop causing blue screens
Where can you use UMDF? • Primary Scenarios • “Protocol Bus” devices • Devices attached to USB, 1394, TCP/IP, etc... • Software-only drivers • Filter drivers, virtualized serial port, etc… • Current Devices • Portable Media Players, Cell Phones, PDAs/ActiveSync, Auxiliary Display, Cameras • Future Devices • Devices on future protocol busses • Devices where driver can be split into ... • Small kernel-mode component to do hardware access • Larger user-mode driver to provide complex functionality
When and How To Use UMDF • UMDF is a standard Windows codenamed “Longhorn” feature • Support in WDK • Build with the WDK Build Environment • Standard device driver build environment • No integration with Visual Studio
Why Use UMDF? • Uses the WDF Driver Model • Can learn a single model that applies to KM and UM drivers • Faster development cycle • Easier debugging on a single machine • Crashes during development don’t require a reboot • Access to user-mode services • Win32 file I/O, Function Discovery, WINSOCK, RPC, Crypto • But you have to be careful…
Why Use UMDF? • Improved stability • User-Mode Drivers are isolated from other drivers • Kernel is isolated from user-mode drivers • Increased security • Compromised driver does not crash the system • Lower privileges restrain a compromised driver • Recoverability • System can recover after a driver crash – no blue-screens • The driver can be restarted without rebooting
Kernel-Mode or User-Mode Driver? You must use kernel mode when you: • Need direct hardware access, for example, • Require DMA • Must handle interrupts • Need access to device registers • Have strict timing requirements • UMDF will have increased latency • Need kernel-only resources • Or kernel components need access to your driver
Features You Can Use in Your Driver • General WDF capabilities • PnP/PM provides “opt-in” callbacks for various events • Object model has context management & flow control • I/O Targets allow driver to send new I/O requests • Regardless of where the target device driver is running • Coordinated with cancellation and cleanup • Escape to Win32 and user-mode services • Standard facilities for Windows I/O model • PnP Device Discovery • Synchronous & Asynchronous I/O with Cancellation • Buffered and Direct I/O transfers • Standard INF Driven setup
Common Concerns • Will a user-mode driver be fast enough? • UMDF driver can already flood a portable media device • UMDF may increase latency, but throughput remains high • Performance is one of our top priorities • But 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 models • UMDF will prevent badly behaved drivers from crashing the system
What’s Next? • Development platform is the WDK/LDK • Currently allows developing drivers for Longhorn • But we know that’s not enough… • Plan to support Windows XP in Longhorn time-frame • Versioning support • Support for side-by-side installation • Beta program • Windows Driver Foundation Beta Program Invitation • http://www.microsoft.com/whdc/driver/wdf/beta.mspx
Call To Action • Install the Windows Driver Kit • Join the WDF Beta Program • At http://beta.microsoft.com • Guest ID: Guest4WDF • Evaluate UMDF for your driver projects • Consider development time, customer support for system crashes, etc. • Send Us Feedback - We want to know • If UMDF will meet your needs • What stops you from writing your drivers with UMDF • Email: umdffdbk @ microsoft.com
Additional Resources • Web 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 2005 • Focuses on KMDF but provides general WDF information as well
© 2005 Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.