Win HEC Download Win HEC presentations here http

  • Slides: 50
Download presentation
�点�以下�接下� Win. HEC的演�材料 Download Win. HEC presentations here: http: //channel 9. msdn. com/Events/Win. HEC/2015

�点�以下�接下� Win. HEC的演�材料 Download Win. HEC presentations here: http: //channel 9. msdn. com/Events/Win. HEC/2015

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

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

WDFOBJECT Methods Events Properties WDF functions that operate on objects Where you can register

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

Driver (WDFDRIVER) Device (WDFDEVICE) … Queue (WDFQUEUE) … Wdf. Request. Complete. With. Information( Request,

Driver (WDFDRIVER) Device (WDFDEVICE) … Queue (WDFQUEUE) … Wdf. Request. Complete. With. Information( Request, STATUS_INVALID_DEVICE_REQUEST, (ULONG_PTR) 0 );

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

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

Wdf. Driver. Create ( Raw. Driver. Object, […] , attributes, &driver )

Wdf. Driver. Create ( Raw. Driver. Object, […] , attributes, &driver )

NTSTATUS Driver. Entry( _In_ PDRIVER_OBJECT Driver. Object, _In_ PUNICODE_STRING Registry. Path ) { […]

NTSTATUS Driver. Entry( _In_ PDRIVER_OBJECT Driver. Object, _In_ PUNICODE_STRING Registry. Path ) { […] // Create WDF Driver Object WDF_OBJECT_ATTRIBUTES_INIT(&attributes); attributes. Evt. Driver. Unload = On. Driver. Unload; WDF_DRIVER_CONFIG_INIT(&config, On. Device. Add); status = Wdf. Driver. Create(Driver. Object, Registry. Path, &attributes, &config, &driver ); } Declare vars WDF Event WDF Method WDF Object

NTSTATUS On. Device. Add( WDFDRIVER Driver, PWDFDEVICE_INIT Device. Init ) { WDFDEVICE device; IWDFIo.

NTSTATUS On. Device. Add( WDFDRIVER Driver, PWDFDEVICE_INIT Device. Init ) { WDFDEVICE device; IWDFIo. Queue * p. Default. Queue = NULL; Device. Init->Set. Power. Policy. Ownership(TRUE); status = Wdf. Device. Create(&Device. Init, &device. Attributes, &device); context = Get. Context(device); context->Wdf. Device = device; status = p. IWDFDevice->Create. Io. Queue( NULL, TRUE, Wdf. Io. Queue. Dispatch. Parallel, TRUE, FALSE, &p. Default. Queue ); return status; } Static Configuration Device Create Setting Context Queue Create

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

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

Get hardware resources, Do some static configuration, (Prepare. Hardware) Enter powered state (D 0

Get hardware resources, Do some static configuration, (Prepare. Hardware) Enter powered state (D 0 Entry) Enable interrupts (Interrupt. Enable) …

Get hardware resources, Do some static configuration, (Prepare. Hardware) NTSTATUS On. Prepare. Hardware( WDFDEVICE

Get hardware resources, Do some static configuration, (Prepare. Hardware) NTSTATUS On. Prepare. Hardware( WDFDEVICE Device, WDFCMRESLIST Resources. Raw, WDFCMRESLIST Resources. Translated ) { int Resource. Count = Wdf. Cm. Resource. List. Get. Count( Resources. Translated ); for (i=0; i < Resource. Count; i++) { Enter powered state (D 0 Entry) descriptor = Wdf. Cm. Resource. List. Get. Descriptor( Resources. Translated, i); switch(descriptor->Type) { case Cm. Resource. Type. Port: […] case Cm. Resource. Type. Memory: […] case Cm. Resource. Type. Interrupt: […] default: break; } Enable interrupts (Interrupt. Enable) … } return STATUS_SUCCESS; }

Get hardware resources, Do some static configuration, (Prepare. Hardware) Enter powered state (D 0

Get hardware resources, Do some static configuration, (Prepare. Hardware) Enter powered state (D 0 Entry) NTSTATUS On. D 0 Entry( IN WDFDEVICE Device, IN WDF_POWER_DEVICE_STATE Recent. Power. State ){ PADXL 345 Acc. Device p. Acc. Device = nullptr p. Acc. Device = Get. Context(Device); Wdf. Wait. Lock. Acquire(p. Acc. Device->m_Wait. Lock); I 2 CSensor. Write. Register( p. Acc. Device->m_I 2 CIo. Target, MY_REGISTER, MY_VALUE, sizeof(MY_VALUE) ); Enable interrupts (Interrupt. Enable) … p. Acc. Device->m_Powered. On = true; Wdf. Wait. Lock. Release(p. Acc. Device->m_Wait. Lock); return STATUS_SUCCESS; }

Get hardware resources, Do some static configuration, (Prepare. Hardware) NTSTATUS On. Interrupt. Enable( IN

Get hardware resources, Do some static configuration, (Prepare. Hardware) NTSTATUS On. Interrupt. Enable( IN WDFINTERRUPT Interrupt, IN WDFDEVICE Device){ PDEVICE_EXTENSION ULONG reg. Ulong; PULONG int. Csr; Enter powered state (D 0 Entry) dev. Ext; dev. Context = Get. Device. Context( Wdf. Interrupt. Get. Device(Interrupt) ); int. Reg. Id = &dev. Context->Int. Register. Id Enable interrupts (Interrupt. Enable) reg. Val = READ_REGISTER_ULONG( int. Reg. Id ); reg. Val = ENABLE_INTERRUPT_BYTE( reg. Val ); WRITE_REGISTER_ULONG( int. Reg. Id, reg. Val ); … return STATUS_SUCCESS; }

Get hardware resources, Do some static configuration, (Prepare. Hardware) Enter powered state (D 0

Get hardware resources, Do some static configuration, (Prepare. Hardware) Enter powered state (D 0 Entry) Enable interrupts (Interrupt. Enable) …

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

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

IRP I/O WDFREQUEST Dispatcher Queue Selection Execution Level & Sync Scope Power Management WDFREQUEST

IRP I/O WDFREQUEST Dispatcher Queue Selection Execution Level & Sync Scope Power Management WDFREQUEST Driver’s On. Read

I/O ead R IRPs I/O Dispatcher Write IOC TL I/O Dispatcher Queue Selection Execution

I/O ead R IRPs I/O Dispatcher Write IOC TL I/O Dispatcher Queue Selection Execution Level & Sync Scope Power Management Parallel WDFREQUEST Sequential WDFREQUEST Manual WDFREQUEST Driver’s On. Read

I/O Dispatcher Queue Selection Execution Level & Sync Scope Power Management Driver’s On. Read

I/O Dispatcher Queue Selection Execution Level & Sync Scope Power Management Driver’s On. Read 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 Device Scope: Synchronization of callbacks for a device’s queue and file objects Queue Scope: Synchronization of callbacks for a queue None: No synchronization

I/O Dispatcher Queue Selection Execution Level & Sync Scope Power Management Driver’s On. Read

I/O Dispatcher Queue Selection Execution Level & Sync Scope Power Management Driver’s On. Read

Wdf. Request. Mark. Cancelable ( Request, On. Request. Cancel );

Wdf. Request. Mark. Cancelable ( Request, On. Request. Cancel );

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

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

Wdf. Io. Target. Send. Ioctl. Synchronously( io. Target, NULL, IOCTL_ACPI_ASYNC_EVAL_METHOD, &input. Buf. Desc, &output.

Wdf. Io. Target. Send. Ioctl. Synchronously( io. Target, NULL, IOCTL_ACPI_ASYNC_EVAL_METHOD, &input. Buf. Desc, &output. Buf. Desc, NULL);

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

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

WDF_DEVICE_POWER_POLICY_WAKE_SETTINGS_INIT(&wake. Settings); Wdf. Device. Assign. Sx. Wake. Settings( device, &wake. Settings );

WDF_DEVICE_POWER_POLICY_WAKE_SETTINGS_INIT(&wake. Settings); Wdf. Device. Assign. Sx. Wake. Settings( device, &wake. Settings );

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

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

WDF on Git. Hub! Available starting tomorrow Includes KMDF and UMDF v 2 Published

WDF on Git. Hub! Available starting tomorrow Includes KMDF and UMDF v 2 Published under MIT License

Developing Drivers with Windows Driver Foundation Kernel-Mode Driver Framework Design Guide User-Mode Driver Framework

Developing Drivers with Windows Driver Foundation Kernel-Mode Driver Framework Design Guide User-Mode Driver Framework Design Guide Choosing a driver model A basic “Toaster” sample (UMDF 2) Echo driver sample, showing queues and IOCTLS (KMDF) USB FX 2 Function Driver (UMDF 2)

Grand Ballroom III 12: 30 Introduction to Hardware Lifecycle 13: 40 Tools for Windows

Grand Ballroom III 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 Mansion VIII <Day 2> Lab: Getting Started with Driver Dev 10: 30 11: 30 Lunch 12: 30 Accessing GPIO, I 2 C, and UART devices Lab: Driver Testing and Debugging 13: 40 Driver Testing and Debugging Lab: Sensor Driver on Sharks Cove 15: 00 Testing with the Hardware Lab Kit Lab: Sensor Driver on Sharks Cove 16: 10 Intro to Driver Signing, Distribution, Servicing Lab: Testing with the Hardware Lab Kit 17: 20 <Day 3> 09: 00 Lab: Getting Started with Driver Dev 10: 10 Lab: Driver Testing and Debugging

(c) 2015 Microsoft Corporation. All rights reserved. This document is provided "as-is. " Information

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