Something else related to work item.

Discussion in 'Windows Vista Drivers' started by KMDF_FW, Mar 22, 2006.

  1. KMDF_FW

    KMDF_FW Guest

    Ah, I got something else to ask. I understand that when a device is removed,
    the work itme related to it will also be removed since we specified work
    item's ParentObject to be the device. But in my case, when I remove my usb
    device, my work item callback routine is still called. Is it because I didn't
    specifiy correct ParentObject or there is something else we need to do? BTW,
    does anyone know how/when to use KMDF's
    WDF_OBJECT_ATTRIBUTES_SET_CONTEXT_TYPE() macro as there is no sample in kmdf
    ddk uses it and the short code in help file is not detailed enough to be
    helpful.

    Thanks.

    AT.
     
    KMDF_FW, Mar 22, 2006
    #1
    1. Advertisements

  2. there is no way to cancel a WDM work item once it is queued, so the callback
    will be called. What KMDF will guarantee is that by the time your
    WDFDEVICE's EvtObjectCleanup() routine is called, that the work item
    callback has been called and completed.

    WDF_OBJECT_ATTRIBUTES_SET_CONTEXT_TYPE() is just the 2nd part of
    WDF_OBJECT_ATTRIBUTES_INIT_CONTEXT_TYPE(). For instance

    WDF_DECLARE_CONTEXT_TYPE_WITH_NAME(DEVICE_CONTEXT, GetDeviceContext);

    WDF_OBJECT_ATTRIBUTES woa;
    WDF_OBJECT_ATTRIBUTES_INIT(&woa);
    WDF_OBJECT_ATTRIBUTES_SET_CONTEXT_TYPE(&woa, DEVICE_CONTEXT);

    which is functionally the same as this code
    WDF_OBJECT_ATTRIBUTES woa;
    WDF_OBJECT_ATTRIBUTES_INIT_CONTEXT_TYPE(&woa, DEVICE_CONTEXT);

    d
     
    Doron Holan [MS], Mar 22, 2006
    #2
    1. Advertisements

  3. KMDF_FW

    KMDF_FW Guest

    Doron:

    Hi, thank you for your reply. Based on what you said about the object
    attribute, these two approaches are equivalent ways of initilizing it.
    However, it seems that none of the samples of kmdf ddk use either

    WDF_OBJECT_ATTRIBUTES_SET_CONTEXT_TYPE(&woa, DEVICE_CONTEXT);

    or

    WDF_OBJECT_ATTRIBUTES_INIT_CONTEXT_TYPE(&woa, DEVICE_CONTEXT);
    Then I wonder how the device context info of the work item will be used by
    KMDF framework, or the context info is only used by driver writers' own use
    and it's optional?

    Meanwhile, for WDM work item object, we can specify whether we want to use
    DelayedWorkQueue or CriticalWorkQueue for it. But it seems that we can't
    specify that any more for KMDF work item anymore, is that right?

    Thanks.

    AT.
     
    KMDF_FW, Mar 23, 2006
    #3
  4. you must not be looking very hard

    C:\WINDDK\WDF\KMDF10\src\kmdf>findstr /s
    WDF_OBJECT_ATTRIBUTES_INIT_CONTEXT_TYPE *
    1394\driver\pnp.c:
    WDF_OBJECT_ATTRIBUTES_INIT_CONTEXT_TYPE(&fdoAttributes, DE
    VICE_EXTENSION);
    AMCC5933\sys\AMCC5933.c:
    WDF_OBJECT_ATTRIBUTES_INIT_CONTEXT_TYPE(&fdoAttributes,
    AMCC_DEVICE_EXTENSION);
    [...]

    WDF_OBJECT_ATTRIBUTES_SET_CONTEXT_TYPE() was created before
    INIT_CONTEXT_TYPE existed. It is still there so that existing samples that
    were written before the new INIT call still work.

    yes, you cannot control the queue type. the DDK says "Drivers must specify
    DelayedWorkQueue."

    d

    --
    Please do not send e-mail directly to this alias. this alias is for
    newsgroup purposes only.
    This posting is provided "AS IS" with no warranties, and confers no rights.
     
    Doron Holan [MS], Mar 23, 2006
    #4
  5. KMDF_FW

    KMDF_FW Guest

    Doron:

    Hi, thank you for your reply and now I am able to connect all the dots
    together.

    AT.

     
    KMDF_FW, Mar 23, 2006
    #5
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.