none
UMDF IO port access RRS feed

  • Question

  • I am trying to access IO port in UMDF as it is supported in version 1.11. Does anybody have working code to complete the function?

    CMyDevice::OnPrepareHardware(
        __in IWDFDevice3 * pWdfDevice,
        __in IWDFCmResourceList * /* pRaw*/,
        __in IWDFCmResourceList * pTrans
        )
    {
        PCM_PARTIAL_RESOURCE_DESCRIPTOR desc = NULL;
        PHYSICAL_ADDRESS regBasePA = {0X300};
        ULONG regLength = 0XFF;
        HRESULT hr = S_OK;
        UINT i =0;
        //
        // Scan the list and identify our resource
        //

        for (i=0; i < pTrans->GetCount(); i++)
     {
            desc = pTrans->GetDescriptor(i);

            switch (desc->Type)
      {
                case CmResourceTypePort:

                   ???????????????????

                   ???????????????????

            

    Saturday, October 20, 2012 10:20 PM

Answers

  • regBasePA = desc->Port.Start;
    regLength = desc->Port.Length;

    Saturday, October 20, 2012 11:41 PM

All replies

  • Yes I tried that before asking question. Somehow it is not working.

    This is the code I have tried before asking.

     hr = pWdfDevice->MapIoSpace(regBasePA, regLength, 
          MmNonCached,
          (void **)&IOBase);
     if (SUCCEEDED(hr))
     {
      pItf = pWdfDevice;     // save for further use in IO Queues
      pWdfDevice->AddRef();  // ??? So I can save the pointer for further use
      IOLen = regLength;     // save for further use in IO Queues
     }
     else
     {
      TraceEvents(TRACE_LEVEL_ERROR,
         TRACE_DEVICE,
         "%!FUNC! Failed to Map ports %!hresult!",
         hr);
      pItf = NULL;
      IOLen = 0;

     };

    If you can share a working code. that will be great.

    Thanks

       
    Monday, October 22, 2012 6:06 PM
  • what HRESULT are you getting back? how did you get regBasePA? did you use the raw or translated resource list? the MapIoSpace doc page has a great code example, http://msdn.microsoft.com/en-us/library/windows/hardware/hh451225(v=vs.85).aspx


    d -- This posting is provided "AS IS" with no warranties, and confers no rights.

    Monday, October 22, 2012 7:23 PM
  • Strangely the

    pTrans->GetCount() is zero.

    I entered the hardware enble in inf file as follows

    [MyDevice_Install.NT.Wdf]

    UmdfService=GiveIO,GiveIO_Install

    UmdfServiceOrder=GiveIO

    UmdfDirectHardwareAccess=AllowDirectHardwareAccess

    Is the inf file setting correct?

    Thanks,

    Monday, October 22, 2012 10:01 PM
  • what type of device is this? which bus enumerates it?

    d -- This posting is provided "AS IS" with no warranties, and confers no rights.

    Monday, October 22, 2012 11:03 PM
  • This ie legacy device for which I am updating hardware & software using a controller & Win7 Compact, which is about 6 months away.

    However until that happens, I need a quick fix for Win7, to keep the show going.

    All hardware support I need is ports 0X300-0X30F [cannot be changed].

    It is an ISA card without PNP support. [Yes ! such a thing exist in 2012 !]

    I had it partially working in KMDF I could read all ports & that but the effort is huge to port to KMDF.

    As I learned UMDF HW support, I try to get this work in UMDF because it will save me about 90% of coding effort.

    Thanks Doran

    Monday, October 22, 2012 11:18 PM
  • please post your INF. since it is not a pnp device, how are you getting the driver loaded? through devcon install or the add new hardware wizard? does the INF (even the old KMDF version) have a LogConfig section to force resource assignment?

    WRT to the INF question above and UmdfDirectHardwareAccess, did you make this change, remove your old INF from the driver store and then add the new INF with the directive to the driver store before updating your driver? you must perform all of these steps for the new directive to be evaluated


    d -- This posting is provided "AS IS" with no warranties, and confers no rights.

    Monday, October 22, 2012 11:25 PM
  • I use the legacy hardware install wizard in device manager. I did not change the default ini except the keys I mentioned above. I am getting the driver installed, I am getting the IO queue. I can debug & see the IOCtls being passed. It's only the port access issue as I mentioned above, the " pTrans->GetCount() is zero".

    I have made sure that the new inf file indeed has these keys on the target.

    I have logconfig in KMDF .inf but not in UMDF .inf. I put initially, but since I did not see it in UMDF docs, I removed it.

    This is my inf file

    ;

    ; GiveIO.inf

    ;

    [Version]

    Signature="$Windows NT$"

    Class=ISA Card; TODO: edit Class

    ClassGuid={78A1C341-4539-11d3-B88D-00C04FAD5171} ; TODO: edit ClassGuid

    Provider=%ManufacturerName%

    CatalogFile=GiveIO.cat

    DriverVer= ; TODO: set DriverVer in stampinf property pages

    [Manufacturer]

    %ManufacturerName%=Standard,NT$ARCH$

    [Standard.NT$ARCH$]

    %DeviceName%=MyDevice_Install, Root\GiveIO ; TODO: edit hw-id

    [ClassInstall32]

    AddReg=SampleClass_RegistryAdd

    [SampleClass_RegistryAdd]

    HKR,,,,%ClassName%

    HKR,,Icon,,"-10"

    [SourceDisksFiles]

    GiveIO.dll=1

    WudfUpdate_$UMDFCOINSTALLERVERSION$.dll=1

    [SourceDisksNames]

    1 = %DiskName%

    ; =================== UMDF Device ==================================

    [MyDevice_Install.NT]

    CopyFiles=UMDriverCopy

    UmdfDirectHardwareAccess=AllowDirectHardwareAccess

     

    [MyDevice_Install.NT.hw]

     

    [MyDevice_Install.NT.Services]

    AddService=WUDFRd,0x000001fa,WUDFRD_ServiceInstall

    [MyDevice_Install.NT.CoInstallers]

    CopyFiles=CoInstallers_CopyFiles

    AddReg=CoInstallers_AddReg

    [MyDevice_Install.NT.Wdf]

    UmdfService=GiveIO,GiveIO_Install

    UmdfServiceOrder=GiveIO

    UmdfDirectHardwareAccess=AllowDirectHardwareAccess

    UmdfRegisterAccessMode =RegisterAccessUsingUserModeMapping

    [GiveIO_Install]

    UmdfLibraryVersion=$UMDFVERSION$

    ServiceBinary=%12%\UMDF\GiveIO.dll

    DriverCLSID={46c5317e-6f8b-4b76-b5fe-c1981ab6b68b}

    UmdfDirectHardwareAccess=AllowDirectHardwareAccess

    [WUDFRD_ServiceInstall]

    DisplayName = %WudfRdDisplayName%

    ServiceType = 1

    StartType = 3

    ErrorControl = 1

    ServiceBinary = %12%\WUDFRd.sys

    LoadOrderGroup = Base

    UmdfDirectHardwareAccess=AllowDirectHardwareAccess

    [CoInstallers_CopyFiles]

    WudfUpdate_$UMDFCOINSTALLERVERSION$.dll

    [CoInstallers_AddReg]

    HKR,,CoInstallers32,0x00010000,"WudfUpdate_$UMDFCOINSTALLERVERSION$.dll"

    [DestinationDirs]

    UMDriverCopy=12,UMDF ; copy to drivers\umdf

    CoInstallers_CopyFiles=11

    [UMDriverCopy]

    GiveIO.dll

    ; =================== Generic ==================================

    [Strings]

    ManufacturerName="XXX" ; TODO: add ManufacturerName

    ClassName="ISACard" ; TODO: edit ClassName

    DiskName = "GiveIO Installation Disk"

    WudfRdDisplayName="ISA Card Driver"

    DeviceName="XXX ISA Card"

    Monday, October 22, 2012 11:40 PM
  • pavel, not true. Vijay, add the logconfig back.  you need this to hard assign the resources to your device, otherwise no hw resources will be assigned

    d -- This posting is provided "AS IS" with no warranties, and confers no rights.

    Tuesday, October 23, 2012 7:34 PM
  • no luck that way either.

    I turned back to KMDF as I spend too much time making this work.

    Maybe its time [Doron] to use your MS connection to find what is going on.

    Thanks, again

    Wednesday, October 24, 2012 1:32 AM
  • your scenario is so uncommon it is not realy worth our time investigating. non pnp isa cards are quite rare at this point.

    d -- This posting is provided "AS IS" with no warranties, and confers no rights.

    Wednesday, October 24, 2012 3:08 PM
  • Sorry I do not mean the hardware but the resource count being zero. Thought there may be something else that I need to do.

    Thanks  a lot

    Wednesday, October 24, 2012 9:13 PM
  • the resource count is zero because there are no resources assigned to your device. you NEED the LogConfig to force resource assigment since you don't have a pnp aware device

    d -- This posting is provided "AS IS" with no warranties, and confers no rights.

    Wednesday, October 24, 2012 9:58 PM
  • yes even with logconfig in place.

    Anyway I wil try this again.

    Thanks

    Wednesday, October 24, 2012 10:42 PM