Re: Usb stick support when plugged in at boot

Tech-Archive recommends: Fix windows errors by optimizing your registry

From: Werner (Werner_at_discussions.microsoft.com)
Date: 02/17/05


Date: Thu, 17 Feb 2005 00:05:01 -0800

My chip was a UHCI compliant chipset, not OHCI. So that might be different
See also http://www.intel.com/technology/usb/uhci11d.htm
Also know that some modern chipsets allow USB keyboard legacy mode to be
programmed. Some BIOS will enable USB keyboard and mouse (redirect it to PS2)
prior to booting your WinCE image. It is better to disable this mode in the
BIOS, because it might interfere with your UHCI (or OHCI) driver starting up.
It is also possible to disable this directly from the driver, but that is
chipset specific. See the data*** of your chipset.

This is what I changed. You need to declare some variables, but I haven't
listed that

In cdevice.cpp
BOOL CRootHub::WaitForPortStatusChange( OUT UCHAR& rPort,
                                        OUT USB_HUB_AND_PORT_STATUS& rStatus )
{
    DEBUGMSG( ZONE_ATTACH && ZONE_VERBOSE,
(TEXT("+CRootHub::WaitForPortStatusChange\n")) );

    BOOL fSuccess = FALSE;
    // root hub - we need to poll for status changes.
    while ( !m_fHubThreadClosing && !fSuccess ) {
        WaitForSingleObject( m_hHubStatusChangeEvent, 100 );
        if ( m_fHubThreadClosing ) {
            break;
        }
        for ( UCHAR port = 1; !fSuccess && port <=
m_usbHubDescriptor.bNumberOfPorts; port++ ) {
                        if ( m_pCHcd->DidPortStatusChange( port ) ||
// Changes start
                                // port status changed on this port
                                 (m_bFirstTime[port] && m_pCHcd->GetPortConnectStatus( port )) ) {
                                // if first time, do not rely on StatusChange bits only
                                // they might not have been (re)set properly
// Changes stop
                                rPort = port;
                                // we could just call CHW::GetPortStatus, but it is
                                // better to call CRootHub::GetStatus which is
                                // designed to implement the virtual CHub::GetStatus function.
                                fSuccess = GetStatus( port, rStatus );
// Changes start
                                if (m_bFirstTime[port]) {
                                        // Fake Connect Status Change
                                        rStatus.change.port.ConnectStatusChange = 1;
                                }
            }
                        m_bFirstTime[port] = false;
// Changes stop
        }
    }
    if (fSuccess) {
        // acknowledge the change bits
        for (USHORT bit = 0; bit < 16; ++bit) {
            if (rStatus.change.word & (1 << bit))
                SetOrClearFeature( rPort, USB_REQUEST_CLEAR_FEATURE, bit |
0x10 );
        }
    }

    DEBUGMSG( ZONE_ATTACH && ZONE_VERBOSE,
(TEXT("-CRootHub::WaitForPortStatusChange, rPort = %d, fSuccess = %d\n"),
rPort, fSuccess) );
    return fSuccess;
}

In uhcd\chw.cpp
BOOL CHW::GetPortConnectStatus( IN const UCHAR port )
{
    // port == specifies root hub itself, whose status never changes
    BOOL fChanged = FALSE;
    if ( port > 0 ) {
        fChanged = Read_PORTSC( port ) & (UHCD_PORTSC_CONNECT_STATUS);
    }
    return !!fChanged;
}

Werner


Quantcast