Lounge - EHCI[HCD1] driver interaction using IOCTL from user application

Asked By Yuvaraj Kumar on 09-Dec-11 07:45 AM

Hi,

I am writing a application on WinCE6.0 to test USB HOST.

My application should set USB HOST port into TEST_MODE for TEST_J,TEST_K etc

I am building USB_COMP_TEST.exe in \WINCE600\PLATFORM\SMDK6450\SDK\ and running it on board.

I am trying to get the file handle for EHCI driver using below API

hEHCIDrv = CreateFile(L"HCD1:", GENERIC_READ|GENERIC_WRITE, 0, NULL,OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL,NULL);The API call is success.

Now I am trying to create my IOCTL code using below snippet:

#define EHCI_DEVICE_TYPE        (0xC000)            // EHCI-unique device type random number written 

#define  IOCTL_EHCI_REQ    CTL_CODE(EHCI_DEVICE_TYPE,500, METHOD_BUFFERED, FILE_ANY_ACCESS)

And trying post this IOCTL to HCD1(EHCI driver).
IOCTL_Result =DeviceIoControl(hEHCIDrv, IOCTL_EHCI_REQ, &ctrl_req, sizeof(USB_DEVICE_REQUEST), NULL, 0, NULL, NULL);
But after posting this my control is not coming to HCD_IOControl().
Please let me know Is this the way to Interact with EHCI driver from user app(USB_COMP_TEST.exe ).
Thanks
Sri K replied to Yuvaraj Kumar on 27-Dec-11 08:57 AM

The EHCI USB host driver provided by MSFT does nothing with IOCTL's:

/*
%_WINCEROOT%\PUBLIC\COMMON\OAK\DRIVERS\USB\HCD\USB20\USB2COM\hcddrv.cpp
*/

extern "C" BOOL HCD_IOControl(DWORD hOpenContext, DWORD dwCode, PBYTE pBufIn,
        DWORD dwLenIn, PBYTE pBufOut, DWORD dwLenOut, PDWORD pdwActualOut)
{
    return HcdPdd_IOControl(hOpenContext, dwCode, pBufIn, dwLenIn, pBufOut,
            dwLenOut, pdwActualOut);
}

/*
%_WINCEROOT%\PUBLIC\COMMON\OAK\DRIVERS\USB\HCD\USB20\EHCIPDD\system.c
*/

extern BOOL HcdPdd_IOControl(DWORD hOpenContext, DWORD dwCode, PBYTE pBufIn,
        DWORD dwLenIn, PBYTE pBufOut, DWORD dwLenOut, PDWORD pdwActualOut)
{
    UnusedParameter(hOpenContext);
    UnusedParameter(dwCode);
    UnusedParameter(pBufIn);
    UnusedParameter(dwLenIn);
    UnusedParameter(pBufOut);
    UnusedParameter(dwLenOut);
    UnusedParameter(pdwActualOut);

    return FALSE;
}

If you need to test a specific USB host you need to modify its device driver so it does something useful with the custom IOCTL you pass to it