通用 Windows 驱动程序入门Getting Started with Universal Windows drivers

通用 Windows 驱动程序使开发人员能够创建可在多种不同设备类型(从嵌入式系统到平板电脑和台式电脑)上运行的单个驱动程序包。Universal Windows drivers enable developers to create a single driver package that runs across multiple different device types, from embedded systems to tablets and desktop PCs.

通用 Windows 驱动程序包包含一个 INF 文件、在基于通用 Windows 平台 (UWP) 的 Windows 10 版本上安装和运行的二进制文件,以及共享一组通用接口的其他 Windows 10 版本。A Universal Windows driver package contains an INF file and binaries that install and run on Universal Windows Platform (UWP) based editions of Windows 10 as well as other Windows 10 editions that share a common set of interfaces.

驱动程序二进制文件可使用 KMDFUMDF 2 或 Windows 驱动程序模型 (WDM)。The driver binary can use KMDF, UMDF 2 or the Windows Driver Model (WDM).

通用驱动程序由以下部分组成:基准驱动程序、可选组件包和可选硬件支持应用。A universal driver consists of the following parts: a base driver, optional component packages, and an optional hardware support app. 基准驱动程序包含所有核心功能和共享的代码。The base driver contains all core functionality and shared code. 此外,可选组件包可以包含自定义项和其他设置。Separately, optional component packages can contain customizations and additional settings.

通常,设备制造商 (IHV) 编写基准驱动程序,系统组装商 (OEM) 提供任何可选组件包。Typically, a device manufacturer (IHV) writes the base driver, and a system builder (OEM) provides any optional component packages.

IHV 认证基准驱动程序后,可以在所有 OEM 系统上部署该驱动程序。After IHV has certified the base driver, it can be deployed on all OEM systems. 由于可以在共享硬件部件的所有系统中使用基准驱动程序,因此 Microsoft 可以通过 Windows 预览体验成员外部测试广泛地测试基准驱动程序,而不是将分发局限于特定计算机。Because a base driver can be used across all systems that share a hardware part, Microsoft can test the base driver broadly via Windows Insider flighting, rather than limiting distribution to specific machines.

OEM 仅验证它为 OEM 设备提供的可选自定义项。The OEM validates only the optional customizations that it provides for the OEM device.

通用驱动程序通过 Windows 更新来分发,硬件支持应用通过 Microsoft Store 来分发。Universal drivers are distributed through Windows Update, and hardware support apps are distributed through the Store.

设计原则Design Principles

编写通用驱动程序包时,需要考虑以下四个设计原则:When you write a universal driver package, there are four design principles to consider:

  • 声明性 ("D") :仅使用声明性 INF 指令来安装驱动程序,不包含任何辅助安装程序、RegisterDlls 等。Declarative ("D"): Install the driver using only declarative INF directives and do not include any co-installers, RegisterDlls, etc.
  • 组件化 ("C") :特定于版本、特定于 OEM 和可选的驱动程序自定义项独立于基准驱动程序包,因此可以独立于自定义项对只提供核心设备功能的基准驱动程序进行定向、外部测试和维护。Componentized ("C"): Edition-specific, OEM-specific and optional customizations to the driver are separate from the base driver package, so that the base driver, which provides only core device functionality, can be targeted, flighted and serviced independently from the customizations.
  • 硬件支持应用 ("H") :与通用驱动程序关联的任何用户界面 (UI) 组件都必须打包为硬件支持应用 (HSA) 或预安装在 OEM 设备上。Hardware Support Apps ("H"): Any user interface (UI) component associated with a universal driver must be packaged as a Hardware Support App (HSA) or preinstalled on the OEM device. HSA 是与驱动程序配对的可选设备特定应用。An HSA is an optional device-specific app that is paired with a driver. 此类应用程序可以是通用 Windows 平台 (UWP)桌面桥应用。The application can be a Universal Windows Platform (UWP) or a Desktop Bridge app. 必须通过 Microsoft Store 分发和更新 HSA。You must distribute and update an HSA through the Microsoft Store. 有关详细信息,请参阅硬件支持应用 (HSA):适用于驱动程序开发人员的步骤硬件支持应用 (HSA):适用于应用开发人员的步骤For details, see Hardware Support App (HSA): Steps for Driver Developers and Hardware Support App (HSA): Steps for App Developers.
  • 通用 API 合规性 ("U") :通用驱动程序包中的二进制文件仅调用基于 UWP 的 Windows 10 版本中所包含的 API 和 DDI。Universal API compliance ("U"): Binaries in the universal driver package only call APIs and DDIs that are included in UWP-based editions of Windows 10. 这些 DDI 在对应的文档参考页上被标记为“通用” 。These DDIs are marked as Universal on the corresponding documentation reference pages. INF 文件仅使用通用 INF 语法。INF files use only universal INF syntax.

在此文档中,我们使用首字母缩略词 DCHU 来表示上述原则。In the documentation, we use the acronym DCHU to refer to the above principles. 可以在下文中找到关于如何使驱动程序包符合 DCHU 的指南。Below, you'll find guidance on how to make your driver package DCHU-compliant. 此外,请查阅通用驱动程序方案,其中介绍了 DCHU 通用驱动程序示例如何应用 DCHU 设计原则。Also check out Universal Driver Scenarios, which describes how the DCHU universal driver sample applies the DCHU design principles.

要求Requirements

编写通用驱动程序包时,需要考虑以下要求:The following are required when writing a universal driver package:

最佳方案Best Practices