none
Windows 7 and pcmcia support RRS feed

  • Question

  • I am having to port a device driver to Windows 7.

    The original code is old and is based on obsolete Compuware Driver Studio libraries.

    The hardware is a PCI card with a TI 1410 PCI to PCMCIA bridge chip the rest of the hardware looks like a custom PCMCIA card.

    I have this card installed on a Windows 7 64-bit platform. Windows has installed pcmcia.sys to talk to the TI 1410 and has sucessfully enumerated the PCMCIA device.

    I have created a skeleton KMDF driver and installed this for the PCMCIA device.

    I am now attempting to re-implement the old driver's IO Control functions. One of these is to read PCMCIA attribute memory.

    The old driver did this by getting the PCMCIA_BUS_INTERFACE_STANDARD and called the ReadConfig() functions.

    I have tried to obtain this interface using WdfFdoQueryInterface() and a raw WDM approach (see below) but both just return STATUS_NOT_SUPPORTED.

    I have also tried sending IRP_MN_READ_CONFIG to directly access PCMCIA config space but that also fails with STATUS_NOT_SUPPORTED.

    So my question are:

    i)   Am I doing something stupid (I am relatively new to KMDF) e.g. using the wrong ioTarget ?

    ii)  Could Windows 7 Security be preventing access? (I've had enogh fun and games just getting the test driver loaded)

    iii) Is Windows 7 support for PCMCIA devices broken?

    Any help here would be gratefully received.

    thanks

    Ian

    WdfFdoQueryInterface Method.

    NTSTATUS FeDrvEvtDeviceSelfManagedIoInit(IN WDFDEVICE hDevice )
    {
        NTSTATUS status;
        FEDRV_FDO_DATA_T *     pFdoData;
       
        pFdoData = FEDrvFdoGetData(hDevice);
        status = WdfFdoQueryForInterface(hDevice,
                                         (LPGUID)&GUID_PCMCIA_BUS_INTERFACE_STANDARD,
                                         (PINTERFACE) &pFdoData->m_BusInterface, // Object context space
                                         sizeof(PCMCIA_BUS_INTERFACE_STANDARD),
                                         1,
                                         NULL);
       return status;

    }

    WDM Method (based on the original code)

        KeInitializeEvent( &event, NotificationEvent, FALSE );

        pFdoData = FEDrvFdoGetData(hDevice);
        targetObject = IoGetAttachedDeviceReference( WdfDeviceWdmGetDeviceObject(hDevice));

        irp = IoBuildSynchronousFsdRequest( IRP_MJ_PNP, targetObject, NULL, 0, NULL, &event, &ioStatusBlock );

        irpStack = IoGetNextIrpStackLocation( irp );
        irpStack->MinorFunction = IRP_MN_QUERY_INTERFACE;
        irpStack->Parameters.QueryInterface.InterfaceType = (LPGUID)&GUID_PCMCIA_BUS_INTERFACE_STANDARD;
        irpStack->Parameters.QueryInterface.Size = sizeof(PCMCIA_BUS_INTERFACE_STANDARD);
        irpStack->Parameters.QueryInterface.Version = 1;
        irpStack->Parameters.QueryInterface.Interface = (PINTERFACE)&pFdoData->m_BusInterface;
        irpStack->Parameters.QueryInterface.InterfaceSpecificData = NULL;

        irp->IoStatus.Status = STATUS_NOT_SUPPORTED;
        status = IoCallDriver( targetObject, irp );

        if (status == STATUS_PENDING)
        {
            KeWaitForSingleObject( &event, Executive, KernelMode, FALSE, NULL );
            status = ioStatusBlock.Status;
        }

        ObDereferenceObject( targetObject );

    IRP_MN_READ_CONFIG Method

        ioTarget = WdfDeviceGetIoTarget(hDevice);

        status = WdfRequestCreate(WDF_NO_OBJECT_ATTRIBUTES,ioTarget,&request);
        if (NT_SUCCESS(status))
        {
            WDF_REQUEST_REUSE_PARAMS_INIT(&reuse,WDF_REQUEST_REUSE_NO_FLAGS,STATUS_NOT_SUPPORTED);
            WdfRequestReuse(request,&reuse);

            RtlZeroMemory(&stack,sizeof(stack));
            stack.MajorFunction = IRP_MJ_PNP;
            stack.MinorFunction = IRP_MN_READ_CONFIG;
            stack.Parameters.ReadWriteConfig.WhichSpace = PCCARD_ATTRIBUTE_MEMORY;
            stack.Parameters.ReadWriteConfig.Length = wordCount * sizeof(unsigned __int16);
            stack.Parameters.ReadWriteConfig.Buffer = pOutData;
            stack.Parameters.ReadWriteConfig.Offset = byteOffset;

            WdfRequestWdmFormatUsingStackLocation(request,&stack);

            WDF_REQUEST_SEND_OPTIONS_INIT(&options, WDF_REQUEST_SEND_OPTION_SYNCHRONOUS);

            WdfRequestSend(request,ioTarget,&options);
            status = WdfRequestGetStatus(request);
           
            WdfObjectDelete(request);

    Tuesday, January 29, 2013 3:34 PM

Answers

  • how did you install the driver? perhaps you installed your driver on the wrong device stack. if you used devcon install <...> to install the driver you installed the driver on a root enumerated device stack, not the PCMCIA enumerated device.  if that is the case, delete the root enumerated PDO in device manager and then use devcon update <...> to install on the pcmcia stack.

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

    Tuesday, January 29, 2013 5:49 PM

All replies

  • how did you install the driver? perhaps you installed your driver on the wrong device stack. if you used devcon install <...> to install the driver you installed the driver on a root enumerated device stack, not the PCMCIA enumerated device.  if that is the case, delete the root enumerated PDO in device manager and then use devcon update <...> to install on the pcmcia stack.

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

    Tuesday, January 29, 2013 5:49 PM
  • Exactly the problem!

    This elderly PCMCIA implementation required a LogConfig override (which I had omitted from the INF file).

    Installing the driver the normal way created a device that would not start. Having had issues with Test Signing etc I assumed UAC and the security police were getting in the way.

    So I re-wound and tried devcon instead. This gave me a working device that I could open so I thought I was in business. But of course this device was not actually attached to any bus.

    Wednesday, January 30, 2013 2:52 PM
  • This maybe should be in a different thread but there are issues with the LogConfig override.

    The section is:

    [Basic.Override0]
    ConfigPriority=Normal
    IRQConfig=7,8,9,10,11
    MemConfig=100000@C0000-FFFFFFFF%F0000(DRW)
    MemConfig=4000@C0000-FFFFFFFF%F0000(DRW)
    PcCardConfig=0::(CA)

    On the same hardware platform this section is accepted by XP but rejected by Windows 7 32 and 64 bit. (Driver fails to load (code 12)).

    If have experimented with these settings and have found the problem is with the first MemConfig statement. If I drop the size by 64K to:

    MemConfig=F0000@C0000-FFFFFFFF%F0000(DRW) (or MemConfig=F0000@C0000-FFFFFFFFFFFFFFFF%F0000(DRW) on Win 7 64-bit)

    then everything is accepted. If XP can accept the original 1MB memory windows then why can't Windows 7?

    One other point: the IRQConfig statement lists numbers 7,8,9,10 and 11. I WDK documentation states these are decimal values. But when I checked the actual resource allocations the card had been given IRQ 16 0x00000010. I have no idea at this point if this allocation will actually work in practice.

    Thursday, January 31, 2013 3:46 PM
  • The irq number in device manager is is specific, not meant to be the irq number wired in the (Io)apic. As for the memory window, is it the same machine running XP and 7? The 7 machine can easily be more resource constrained.

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

    Thursday, January 31, 2013 4:01 PM
  • It is exactly the same machine - I have XP Pro SP3, Win 7 32-bit SPI1 and Win 7 64-bit ghost images which I can swap in and out.

    I could understand Win 7 32-bit having resource allocation problems but the 64-bit variant really should have no problem finding a 1MB window for the card.

    Friday, February 1, 2013 9:49 AM
  • While 64 but has more VA space for memory it can be more highly constrained in the first 4 gigs of memory due to 32 bit device compat . Look at assigned resources by range in device manager and the output of !arbiter with various flags

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

    Friday, February 1, 2013 3:27 PM