Download presentation
Presentation is loading. Please wait.
Published byJeffry Miles Modified over 9 years ago
1
请点击以下链接下载 WinHEC 的演讲材料 Download WinHEC presentations here: http://channel9.msdn.com/Events/WinHEC/2015
5
Driver Stacks
6
Audio Devices Battery Devices Biometric Devices Bluetooth Devices Bus Drivers Display Adapters and Monitors File System Drivers Human Input Devices Imaging Devices (Scanner) Network Devices Print Devices Proximity Devices Radio Management Sensor Devices Smart Card Reader Devices Storage Devices Streaming Media Devices Windows Touch Drivers
7
Driver Stack Driver Stacks Audio Devices Battery Devices Biometric Devices Bluetooth Devices Bus Drivers Display Adapters and Monitors File System Drivers Human Input Devices Imaging Devices (Scanner) Network Devices Print Devices Proximity Devices Radio Management Sensor Devices Smart Card Reader Devices Storage Devices Streaming Media Devices Windows Touch Drivers Networking Stack
8
Called by IOMGR to start IO requests Validates requests Sends work to the control layer Called by PNP to setup, start, stop driver Sends work to control layer Tells control layer to suspend/restart work Work Queue
13
DriverEntry(DriverObject) { initialize driver_object_config with: AddDevice = OnDeviceAdd Unload = OnDriverUnload return WdfDriverCreate( DriverObject, driver_object_config ) // creates WDFDRIVER }
14
OnDeviceAdd(DriverObject, DeviceInfo) { initialize obj_attributes with: ContextType = MyContext wdfDevice = WdfDeviceCreate(&obj_attributes, DeviceInfo) // init context object allocated with device context = GetContext(wdfDevice) context->WdfDevice = wdfDevice return status } struct MyContext { WDFDEVICE Device; BYTE ReadingBuffer[6]; }; WDF_DECLARE_CONTEXT_TYPE_WITH_NAME(MyContext, GetMyContext);
17
[Version] Signature = "$Windows NT$" Class = Sensor ClassGuid= {5175D334-C371-4806-B3BA-71FD53C9258D} Provider=%ManufacturerName% CatalogFile=ADXL345Acc.cat DriverVer= [Manufacturer] %ManufacturerName%=Standard,NT$ARCH$ [Standard.NT$ARCH$] %DeviceName%=MyDevice_Install, ACPI\ADXL345Acc … [Strings] ManufacturerName="Me" DeviceName="ADXL345Acc Device"
21
#TypeValue 0InterruptType: Level Triggered Secondary Interrupt (GPIO) Level: 0x20 Vector: 0x1e 1ConnectionClass: Serial Type: I2C Id: #TypeValue 0MemoryReadWrite Start: 0x00010024 Length: 32-bytes 1InterruptType: Level Triggered Level: 0x21 Vector: 0x05
22
OnPrepareHardware(Device, ResourceList) { i2c_id = find i2c resource in ResourceList // connect to I2C i2c_path = RESOURCE_HUB_CREATE_PATH_FROM_ID(i2c_id) deviceContext->IoTarget = WdfIoTargetCreate(Device) WdfIoTargetOpen(context->IoTarget, i2c_path) }
23
OnD0Entry(Device) { WriteI2CRegister(ADXL345_INT_ENABLE, 0); WriteI2CRegister(ADXL345_POWER_CTL, ADXL345_POWER_CTL_MEASURE); ReadI2CRegister(ADXL345_DATA_X0, 6 bytes); } OnD0Exit(Device, NewPowerState) { WriteI2CRegister(ADXL345_INT_ENABLE, 0); WriteI2CRegister(ADXL345_POWER_CTL, ADXL345_POWER_CTL_STANDBY); }
27
DEFINE_GUID(GUID_Adxl345_Interface, {c2506459-cded-40ab-8ead-0b9ad1db69e4}) OnDeviceAdd(DriverObject, DeviceInfo) { // create WDFDEVICE // … WdfDeviceCreateDeviceInterface( device, GUID_Adxl345_Interface ) … }
28
OnDeviceAdd(Device) { // Create device object & context … initialize queue_config with: DispatchType = Sequential Power Managed = true IO Read Callback = OnRead WdfIoQueueCreate(Device, queue_config) … }
29
OnRead(Queue, Request, Length) { data_buffer = get Request output buffer if data_buffer too small complete request with error & return initialize i2c_sequence buffer to read 6 bytes from ADXL345_DATA_X0 (data register index) into context->ReadingBuffer Reformat Request as I2C Sequence ioctl WdfRequestSetCompletionRoutine(Request, OnDataReadComplete) WdfRequestSend(Request, context->IoTarget) }
30
OnDataReadComplete(Request, CompletionInfo) { if (CompletionInfo->Status == success && CompletionInfo->BytesRead == 6) define local tmp of type SENSOR_READING read_data_buffer = get Request output buffer convert context->ReadingBuffer into tmp copy tmp into read_data_buffer requestStatus = success bytesReturned = sizeof(SENSOR_READING) else requestStatus = error code bytesReturned = 0 WdfRequestComplete(Request, requestStatus, bytesReturned) }
34
Grand Ballroom IIIMansion VIII 12:30 Introduction to Hardware Lifecycle 13:40 Tools for Windows Driver Development 15:00 Intro to Windows Driver Development 16:10 Writing Drivers with the WDF 10:30 Lab: Getting Started with Driver Dev 11:30 Lunch 12:30 Accessing GPIO, I2C, and UART devicesLab: Driver Testing and Debugging 13:40 Driver Testing and DebuggingLab: Sensor Driver on Sharks Cove 15:00 Testing with the Hardware Lab KitLab: Sensor Driver on Sharks Cove 16:10 Intro to Driver Signing, Distribution, ServicingLab: Testing with the Hardware Lab Kit 17:20 Lab: Testing with the Hardware Lab Kit 09:00 Lab: Getting Started with Driver Dev 10:10 Lab: Driver Testing and Debugging
36
(c) 2015 Microsoft Corporation. All rights reserved. This document is provided "as-is." Information and views expressed in this document, including URL and other Internet Web site references, may change without notice. You bear the risk of using it. This document does not provide you with any legal rights to any intellectual property in any Microsoft product. You may copy and use this document for your internal, reference purposes. Some information relates to pre-released product which may be substantially modified before it’s commercially released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.