Presentation is loading. Please wait.

Presentation is loading. Please wait.

请点击以下链接下载 WinHEC 的演讲材料 Download WinHEC presentations here:

Similar presentations


Presentation on theme: "请点击以下链接下载 WinHEC 的演讲材料 Download WinHEC presentations here:"— Presentation transcript:

1 请点击以下链接下载 WinHEC 的演讲材料 Download WinHEC presentations here:

2

3

4

5

6

7

8

9

10 Driver Initialization Hardware preparation I/O Request handling H/W Interaction Driver Cleanup Pnp/Power Interaction

11 WDFOBJECT Methods Properties Events WDF functions that operate on objects Where you can register callbacks Single values accessible via get/set methods

12 WdfRequestCompleteWithInformation( Request, STATUS_INVALID_DEVICE_REQUEST, (ULONG_PTR) 0 ); Driver (WDFDRIVER) Device (WDFDEVICE) Device (WDFDEVICE) Queue (WDFQUEUE) Queue (WDFQUEUE) … …

13

14 Driver Initialization Hardware preparation I/O Request handling H/W Interaction Driver Cleanup Pnp/Power Interaction

15 WdfDriverCreate ( RawDriverObject, […], attributes, &driver )

16 NTSTATUS DriverEntry( _In_ PDRIVER_OBJECT DriverObject, _In_ PUNICODE_STRING RegistryPath ) { […] // Create WDF Driver Object WDF_OBJECT_ATTRIBUTES_INIT(&attributes); attributes.EvtDriverUnload = OnDriverUnload; WDF_DRIVER_CONFIG_INIT(&config, OnDeviceAdd); status = WdfDriverCreate(DriverObject, RegistryPath, &attributes, &config, &driver ); } WDF Event WDF Method WDF Object Declare vars

17

18 NTSTATUS OnDeviceAdd( WDFDRIVER Driver, PWDFDEVICE_INIT DeviceInit ) { WDFDEVICE device; IWDFIoQueue * pDefaultQueue = NULL; DeviceInit->SetPowerPolicyOwnership(TRUE); status = WdfDeviceCreate(&DeviceInit, &deviceAttributes, &device); context = GetContext(device); context->WdfDevice = device; status = pIWDFDevice->CreateIoQueue( NULL, TRUE, WdfIoQueueDispatchParallel, TRUE, FALSE, &pDefaultQueue ); return status; } Static Configuration Device Create Setting Context Queue Create

19 Driver Initialization Hardware preparation I/O Request handling H/W Interaction Driver Cleanup Pnp/Power Interaction

20 Enter powered state (D0Entry) Enable interrupts (InterruptEnable) … Get hardware resources, Do some static configuration, (PrepareHardware)

21 NTSTATUS OnPrepareHardware( WDFDEVICE Device, WDFCMRESLIST ResourcesRaw, WDFCMRESLIST ResourcesTranslated ) { int ResourceCount = WdfCmResourceListGetCount( ResourcesTranslated ); for (i=0; i < ResourceCount; i++) { descriptor = WdfCmResourceListGetDescriptor( ResourcesTranslated, i); switch(descriptor->Type) { case CmResourceTypePort: […] case CmResourceTypeMemory: […] case CmResourceTypeInterrupt: […] default: break; } return STATUS_SUCCESS; } Get hardware resources, Do some static configuration, (PrepareHardware) Enable interrupts (InterruptEnable) … Enter powered state (D0Entry)

22 NTSTATUS OnD0Entry( IN WDFDEVICE Device, IN WDF_POWER_DEVICE_STATE RecentPowerState ) { PADXL345AccDevice pAccDevice = nullptr pAccDevice = GetContext(Device); WdfWaitLockAcquire(pAccDevice->m_WaitLock); I2CSensorWriteRegister( pAccDevice->m_I2CIoTarget, MY_REGISTER, MY_VALUE, sizeof(MY_VALUE) ); pAccDevice->m_PoweredOn = true; WdfWaitLockRelease(pAccDevice->m_WaitLock); return STATUS_SUCCESS; } Get hardware resources, Do some static configuration, (PrepareHardware) Enable interrupts (InterruptEnable) … Enter powered state (D0Entry)

23 NTSTATUS OnInterruptEnable( IN WDFINTERRUPT Interrupt, IN WDFDEVICE Device){ PDEVICE_EXTENSION devExt; ULONG regUlong; PULONG intCsr; devContext = GetDeviceContext( WdfInterruptGetDevice(Interrupt) ); intRegId = &devContext->IntRegisterId regVal = READ_REGISTER_ULONG( intRegId ); regVal = ENABLE_INTERRUPT_BYTE( regVal ); WRITE_REGISTER_ULONG( intRegId, regVal ); return STATUS_SUCCESS; } Get hardware resources, Do some static configuration, (PrepareHardware) Enable interrupts (InterruptEnable) … Enter powered state (D0Entry)

24 Get hardware resources, Do some static configuration, (PrepareHardware) Enable interrupts (InterruptEnable) … Enter powered state (D0Entry)

25 Driver Initialization Hardware preparation I/O Request handling H/W Interaction Driver Cleanup Pnp/Power Interaction

26 I/O Dispatcher Queue Selection Execution Level & Sync Scope Driver’s OnRead IRP Power Management WDFREQUES T

27 I/O Dispatcher Queue Selection Execution Level & Sync Scope Driver’s OnRead I/O Power Management I/O Dispatcher Parallel Sequential Manual IRPs WDFREQUEST Read Write IOCTL

28 IRQL: Interrupt Request Level ( PASSIVE_LEVEL, DISPATCH_LEVEL ) Execution Level: IRQL at which event callbacks are invoked Synchronization Scope: Mechanism for enforcing serialization of callback execution by managing locks I/O Dispatcher Queue Selection Execution Level & Sync Scope Driver’s OnRead I/O Power Management Device Scope: Synchronization of callbacks for a device’s queue and file objects Queue Scope: Synchronization of callbacks for a queue None: No synchronization

29 I/O Dispatcher Queue Selection Execution Level & Sync Scope Driver’s OnRead I/O Power Management

30 WdfRequestMarkCancelable ( Request, OnRequestCancel );

31 Driver Initialization Hardware preparation I/O Request handling H/W Interaction Driver Cleanup Pnp/Power Interaction

32

33

34 WdfIoTargetSendIoctlSynchronously( ioTarget, NULL, IOCTL_ACPI_ASYNC_EVAL_METHOD, &inputBufDesc, &outputBufDesc, NULL, NULL);

35 Driver Initialization Hardware preparation I/O Request handling H/W Interaction Driver Cleanup Pnp/Power Interaction

36

37

38

39 WDF_DEVICE_POWER_POLICY_WAKE_SETTINGS_INIT(&wakeSettings); WdfDeviceAssignSxWakeSettings( device, &wakeSettings );

40 Driver Initialization Hardware preparation I/O Request handling H/W Interaction Driver Cleanup Pnp/Power Interaction

41

42 WDF on GitHub! Available starting tomorrow Includes KMDF and UMDF v2 Published under MIT License

43

44

45

46

47

48 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

49

50 (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.


Download ppt "请点击以下链接下载 WinHEC 的演讲材料 Download WinHEC presentations here:"

Similar presentations


Ads by Google