您好,欢迎访问三七文档
HowtoPortWDMDrivertoKMDF育儿知识(con’t)DifferenttypesofqueuesHowqueuestatesaremanagedbyWDFRequestCancellationHandlingCreate,Cleanup&CloserequestsHandlingI/Orequests–Read/Write/IoctlTimers/DPC/WorkitemsLocks:WaitLock,SpinlockAutomaticI/OsynchronizationSendingrequesttoanotherdriverEscapingtoWDMWhatisWDF?WindowsDriverFoundationconsistsofUserModeDriverFramework(UMDF)KernelModeDriverFramework(KMDF)Tools:SDV,DriverPREfast,DIG,etc.KMDFisbuiltontopofWDMDriverswrittenusingKMDFarecompatiblefromWindows2000forwardDriversarewrittenusingobjectsWhyConverttoWDF?ListofthingsyouworryaboutinWDMTonsofrulesonhandlingPnPandpowerIRPsWhentouseremovelocksIRPqueuingandcancellationWhentomapandunmapHWresourcesWhentoenable/disabledeviceinterfacesWhentoregister/deregisterwithWMIWhentoconnect&disconnectinterruptsTimerDPCanddeviceremove/unloadsynchronizationWhyConverttoWDF?(con’t)ConvertingSIRPstoDIRPsSupportingwait-wakeSupportingselectivesuspend(S0Sleep)FastresumeAsynchronousstartChilddeviceenumerationComplexrulesondeletingaPDOHandlingPnP/powerIRPsinafilterdriverErrorhandlingBackwardcompatibilityCaseStudy:PCIDRVSampleStatsWDMWDFCommentsLineCount13,1477,271ExplicitregistrationofgranulareventcallbacksaddstothelinecountLOCdevotedtoPnP/PM7,9911,795Almost6000linesofcodeareeliminatedLocks83Thisisthemostimportantstatistic.Thisexplainsthecomplexity.StatevariablesdevotedtoPnP/PM300Therearefewerpathsinthedriverandthuslesstestingandcomplexity.ThissampleiswrittenfortheIntelE100BNICCardIt’saWDMversionofnetworkdriverwithNDISinterfacesseparatedoutinanupperfilterdriver(ndisedge)BothsamplesareintheDDKandarefunctionallyequivalentCaseStudy:SerialSampleStatsWDMWDFCommentsLineCount24,00017,000ExplicitregistrationofgranulareventcallbacksaddstothelinecountLOCdevotedtoPnP/PM5,0002,500Locks100Thisisthemostimportantstatistic.Thisexplainsthecomplexity.StatevariablesdevotedtoPnP/PM530Therearefewerpathsinthedriverandthuslesstestingandcomplexity.WDFsampledoesnotsupportmulti-portserial(WDMsamplesupportsit)WDMstatisticsexcludemulti-portsupportserialcodeCaseStudy:OSRUSBFX2SampleStatsWDMWDFCommentsLineCount16,3502,300ExplicitregistrationofgranulareventcallbacksaddstothelinecountLOCdevotedtoPnP/PM6,700742742includescodetoinitializetheUSBLocks90Thisisthemostimportantstatistic.ThisexplainsthecomplexityStatevariablesdevotedtoPnP/PM210TherearefewerpathsinthedriverandthuslesstestingandcomplexityTheWDMversionofOSRUSBFx2sample(availableonosronline.com)andtheWDFversionprovidedintheDDKarefunctionallyequivalentObjectModelObjectsarethebasisofWDFEverythinginframeworkisrepresentedbyobjects(Driver,Device,Request,etc.)Objectshaveproperties,methods,andeventsWDFfunctionsthatoperateonobjectCallsmadebyWDFintothedrivertonotifysomethingMethodsthatgetorsetasinglevalueWDFOBJECTMethodsPropertiesEventsHaveoneormoredriverownedcontextmemoryareasLifetimeoftheobjectiscontrolledbyreferencecountsOrganizedhierarchicallyforcontrollingobjectlifetimeNotaninheritancebasedhierarchyDriverreferencesobjectsashandles,notpointersCreatinganObject(Abc)WDF_OBJECT_ATTRIBUTESSizeEvtCleanupCallbackEvtDestroyCallbackExecutionLevelSynchronizationScopeParentObjectContextSizeOverrideContextTypeInfoHeaderFile:Struct_ABC_CONTEXT{…}ABC_CONTEXT*PABC_CONTEXTWDF_DECLARE_CONTEXT_TYPE_WITH_NAME(ABC_CONTEXT,GetAbcContext)SourceFile:WDF_OBJECT_ATTRIBUTES_INIT(&Attributes);WDF_OBJECT_ATTRIBUTES_SET_CONTEXT_TYPE(&Attributes,ABC_CONTEXT);Attributes.EvtCleanupCallback=AbcEvtCleanup;Attributes.EvtDestroyCallback=AbcEvtDestroy;WDF_ABC_CONFIG_INIT(&Config);WdfAbcCreate(&Attributes,&Config,&Handle)Context=GetAbcContext(Handle);WDF_ABC_CONFIGSizeEvtCallbackPeriod…InheritParentPassiveDispatchInheritParentDeviceObjectNoneObjectRelationshipDefault,butcanbeparentedtoanyobjectPredefinedWDFDEVICEWDFINTERRUPTWDFIOTARGETWDFCHILDLISTWDFFILEOBJECTWDFREQUEST–queuedeliveredWDFTRANSACTIONWDFCOMMONBUFFERWDFWMIPROVIDERWDFQUEUEWDFDRIVERWDFWMIINSTANCEWDFDMAENABLERWDFCOLLECTIONWDFLOOKASIDEWDFKEYWDFWAITLOCKWDFSPINLOCKWDFSTRINGWDFREQUEST–DrivercreatedWDFDPCWDFTIMERWDFWORKITEMWDFUSBDEVICEWDFUSBPIPEDeletinganObjectWdfObjectDelete()-singledeletefunctiontodeletealltypesofobjectsChildobjectswillbedeletedwhentheirparentisdeletedSomeobjectscannotbedeletedbythedriverbecausethelifetimeiscontrolledbyWDFWDFDRIVERWDFDEVICEforFDOandPDOWDFFILEOBJECTWDFREQUESTEtc.Mapping–WDFObjectstoWDMWDFDRIVERDriverobjectWDFDEVICEDeviceobjectWDFQUEUECancel-safequeue/Dispatching/Serialization/Auto-locking/SynchwithPnPWDFREQUESTIRPWDFINTERRUPTInterruptWDFDPCDPCWDFWORKITEMWorkitemWDFDMAENABLERDMAadapterobjectWDFIOTARGETSendingI/Otoanotherdriver-IoCallDriverWDFWAITLOCKEventdispatcherobject–passivelevellockWDFSPINLOCKSpinlockWDFMEMORYKernelpool-refcountedWDFKEYRegistryaccessNamingPatternMethods:Status=WdfDeviceCreate()
本文标题:夏天育儿保健小常识
链接地址:https://www.777doc.com/doc-3283670 .html