亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? chw.cpp

?? Latest USB 802.3, HID printer and mass storage divers from Microsoft for Platform Builder 4.2.
?? CPP
?? 第 1 頁 / 共 3 頁
字號:
//
// Copyright (c) Microsoft Corporation.  All rights reserved.
//
//
// Use of this source code is subject to the terms of the Microsoft end-user
// license agreement (EULA) under which you licensed this SOFTWARE PRODUCT.
// If you did not accept the terms of the EULA, you are not authorized to use
// this source code. For a copy of the EULA, please see the LICENSE.RTF on your
// install media.
//
//
// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
// ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
// PARTICULAR PURPOSE.
//
// Module Name:
//     CHW.cpp
// Abstract:
//     This file implements the UHCI specific register routines
//
// Notes:
//
//

#include "chw.hpp"
#include "cpipe.hpp"
#include "cuhcd.hpp"
#include <nkintr.h>

//#pragma warning (4 : 4100)      // temporary, will clean later. JEFFRO.

CHW::CHW( IN const REGISTER portBase,
                      IN const DWORD dwSysIntr,
                      IN CPhysMem *pCPhysMem,
                      IN LPVOID pvUhcdPddObject)
:m_portBase((HcRegisters *)portBase)
,m_pMem(pCPhysMem)
,m_pPddContext(pvUhcdPddObject)
,m_dwSysIntr(dwSysIntr)
{
// definitions for static variables
    g_fPowerUpFlag = FALSE;
    g_fPowerResuming = FALSE;
    m_pHCCA = 0;
    m_wFrameHigh = 0;
    m_hUsbInterruptEvent = NULL;
    m_hUsbInterruptThread = NULL;
    m_fUsbInterruptThreadClosing = FALSE;

    m_fFrameLengthIsBeingAdjusted = FALSE;
    m_fStopAdjustingFrameLength = FALSE;
    m_hAdjustDoneCallbackEvent = NULL;
    m_uNewFrameLength = 0;

    m_pControlHead = 0;
    m_pBulkHead = 0;
    m_pInterruptTable = 0;
    InitializeCriticalSection( &m_csFrameCounter );
    m_dwCapability = 0;
    m_bDoResume=FALSE;
}
CHW::~CHW()
{
    DeInitialize();
    DeleteCriticalSection( &m_csFrameCounter );
}
// ******************************************************************
BOOL CHW::Initialize(void)
//
// Purpose: Reset and Configure the Host Controller with the schedule.
//
// Parameters: portBase - base address for host controller registers
//
//             dwSysIntr - system interrupt number to use for USB
//                         interrupts from host controller
//
//             frameListPhysAddr - physical address of frame list index
//                                 maintained by CPipe class
//
//             pvUhcdPddObject - PDD specific structure used during suspend/resume
//
// Returns: TRUE if initialization succeeded, else FALSE
//
// Notes: This function is only called from the CUhcd::Initialize routine.
//
//        This function is static
// ******************************************************************
{
    DEBUGMSG( ZONE_INIT, (TEXT("+CHW::Initialize base=0x%x, intr=0x%x\n"), m_portBase, m_dwSysIntr));
#ifdef DEBUG
    dwTickCountLastTime = GetTickCount();
#endif
    WORD lastFn = 0;

    DEBUGCHK( m_wFrameHigh == 0 );

    if ( m_portBase == 0 ) {
        DEBUGMSG( ZONE_ERROR, (TEXT("-CHW::Initialize - zero Register Base\n")));
        return FALSE;
    }

    // set up the Host Controller Communications Area
    if (m_pMem->AllocateSpecialMemory(sizeof(HCCA), (PUCHAR *) &m_pHCCA) == FALSE) {
        DEBUGMSG(ZONE_ERROR, (TEXT("-CHW::Initialize, cannot allocate HCCA!!\n")));
        return FALSE;
    }
    memset((PUCHAR)m_pHCCA, 0, sizeof(HCCA));

    // Reset the HC hardware
    DEBUGMSG(ZONE_INIT && ZONE_REGISTERS, (TEXT("CHW::Initialize - signalling H/W reset\n")));
    m_portBase->HcCommandStatus.HCR = 1;
    while (m_portBase->HcCommandStatus.HCR == 1)
        ; // wait for the reset operation to complete (max 10us)
    m_portBase->HcControl.HCFS = HcRegisters::HcControl::HCFS_RESET;

    m_portBase->HcHCCA = m_pMem->VaToPa((PUCHAR) m_pHCCA);  // locate the HCCA

    // These calculations are from the OHCI 1.0a spec, section 5.4
    // The 210 is the maximum amount of USB protocol overhead per frame, measured in bit-times.
    m_portBase->HcFmInterval.FSMPS = (m_portBase->HcFmInterval.FI - 210) * 6 / 7;
    m_portBase->HcPeriodicStart.PS = m_portBase->HcFmInterval.FI * 9 / 10;

    m_portBase->HcControl.CBSR = 3; // 4:1 Control/Bulk ratio
    DEBUGMSG(ZONE_INIT && ZONE_REGISTERS, (TEXT("CHW::Initialize - end H/W reset\n")));

    DEBUGMSG(ZONE_INIT && ZONE_REGISTERS && ZONE_VERBOSE, (TEXT("CHW::Initialize - initing schedule\n")));
    m_wFrameHigh = 0;           // reset the frame counter
    DEBUGMSG(ZONE_INIT && ZONE_REGISTERS && ZONE_VERBOSE, (TEXT("CHW::Initialize - \n") ));

    // Re-initialize the public constants now that we know the portBase
    // This'll be done properly - in a constructor - in the future.
    m_pControlHead = const_cast<PDWORD>(&m_portBase->HcControlHeadED);
    m_pBulkHead = const_cast<PDWORD>(&m_portBase->HcBulkHeadED);
    m_pInterruptTable = const_cast<PDWORD>(m_pHCCA->HccaInterruptTable);

    // m_hUsbInterrupt - Auto Reset, and Initial State = non-signaled
    DEBUGCHK( m_hUsbInterruptEvent == NULL );
    m_hUsbInterruptEvent = CreateEvent( NULL, FALSE, FALSE, NULL );
    if ( m_hUsbInterruptEvent == NULL ) {
        DEBUGMSG(ZONE_ERROR, (TEXT("-CHW::Initialize. Error creating USBInterrupt event\n")));
        return FALSE;
    }

    InterruptDisable( m_dwSysIntr ); // Just to make sure this is really ours.
    // Initialize Interrupt. When interrupt id # m_sysIntr is triggered,
    // m_hUsbInterruptEvent will be signaled. Last 2 params must be NULL
    if ( !InterruptInitialize( m_dwSysIntr, m_hUsbInterruptEvent, NULL, NULL) ) {
        DEBUGMSG(ZONE_ERROR, (TEXT("-CHW::Initialize. Error on InterruptInitialize\r\n")));
        return FALSE;
    }

    // Apply power to all root hub ports, just like UHCI.
    m_portBase->HcRhDescriptorA.NPS = 1;
    m_portBase->HcRhStatus.reg= HcRegisters::HcRhStatus::LPSC;
    
    // Start up our IST - the parameter passed to the thread
    // is unused for now
    DEBUGCHK( m_hUsbInterruptThread == NULL &&
              m_fUsbInterruptThreadClosing == FALSE );
    m_hUsbInterruptThread = CreateThread( 0, 0, UsbInterruptThreadStub, this, 0, NULL );
    if ( m_hUsbInterruptThread == NULL ) {
        DEBUGMSG(ZONE_ERROR, (TEXT("-CHW::Initialize. Error creating IST\n")));
        return FALSE;
    }
    CeSetThreadPriority( m_hUsbInterruptThread, g_IstThreadPriority );

    // Enable interrupts
    m_portBase->HcInterruptEnable.WDH = 1; // writeback done head was written
    m_portBase->HcInterruptEnable.UE  = 1; // unrecoverable error
    m_portBase->HcInterruptEnable.FNO = 1; // frame number overflow
//    m_portBase->HcInterruptEnable.RHSC= 1; // root hub status change
    m_portBase->HcInterruptEnable.MIE = 1; // master interrupt enable
    
    // Enable Periodic Endpt scan before enable controller. Some HCD require this.
    ListControl(LIST_INTERRUPT, TRUE, TRUE);
    DEBUGMSG( ZONE_INIT, (TEXT("-CHW::Initialize, success!\n")));
    return TRUE;
}

// ******************************************************************
void CHW::DeInitialize( void )
//
// Purpose: Delete any resources associated with static members
//
// Parameters: none
//
// Returns: nothing
//
// Notes: This function is only called from the ~CUhcd() routine.
//
//        This function is static
// ******************************************************************
{
    m_fUsbInterruptThreadClosing = TRUE; // tell USBInterruptThread that we are closing
    // tell adjustment thread (if it exists) to close
    InterlockedExchange( &m_fStopAdjustingFrameLength, TRUE );

    if ( m_fFrameLengthIsBeingAdjusted ) {
        Sleep( 20 ); // give adjustment thread time to close
        DEBUGCHK( !m_fFrameLengthIsBeingAdjusted );
    }
    // m_hAdjustDoneCallbackEvent <- don't need to do anything to this
    // m_uNewFrameLength <- don't need to do anything to this

    // Wake up the interrupt thread and give it time to die.
    if ( m_hUsbInterruptEvent ) {
        SetEvent(m_hUsbInterruptEvent);
        if ( m_hUsbInterruptThread ) {
            DWORD dwWaitReturn = WaitForSingleObject(m_hUsbInterruptThread, 1000);
            if ( dwWaitReturn != WAIT_OBJECT_0 ) {
                DEBUGCHK( 0 );
                TerminateThread(m_hUsbInterruptThread, DWORD(-1));
            }
            CloseHandle(m_hUsbInterruptThread);
            m_hUsbInterruptThread = NULL;
        }
        // we have to close our interrupt before closing the event!
        InterruptDisable( m_dwSysIntr );

        CloseHandle(m_hUsbInterruptEvent);
        m_hUsbInterruptEvent = NULL;
    } else {
        InterruptDisable( m_dwSysIntr );
    }

    m_fUsbInterruptThreadClosing = FALSE;
    m_wFrameHigh = 0;
}

// ******************************************************************
void CHW::EnterOperationalState( void )
//
// Purpose: Signal the host controller to start processing the schedule
//
// Parameters: None
//
// Returns: Nothing.
//
// Notes: This function is only called from the CUhcd::Initialize routine.
//        It assumes that CPipe::Initialize and CHW::Initialize
//        have already been called.
//
//        This function is static
// ******************************************************************
{
    DEBUGMSG( ZONE_INIT, (TEXT("+CHW::EnterOperationalState\n")));

    DEBUGMSG(ZONE_INIT && ZONE_REGISTERS && ZONE_VERBOSE, (TEXT("CHW::EnterOperationalState - setting USBCMD run bit\n")));
    m_portBase->HcControl.HCFS = HcRegisters::HcControl::HCFS_OPERATIONAL;

    DEBUGMSG( ZONE_INIT, (TEXT("-CHW::EnterOperationalState\n")));
}

// ******************************************************************
void CHW::StopHostController( void )
//
// Purpose: Signal the host controller to stop processing the schedule
//
// Parameters: None
//
// Returns: Nothing.
//
// Notes: This function can be called from the power handler callbacks and must
//        therefore abide by the restrictions. No system calls, no blocking.
//        Hence no DEBUGMSG's either.
//        This function is static
// ******************************************************************
{
    //DEBUGMSG( ZONE_INIT, (TEXT("+CHW::StopHostController\n")));
    if ( m_portBase != 0 ) {
        m_portBase->HcInterruptDisable.MIE = 1; // disable all interrupts
        m_portBase->HcControl.HCFS = HcRegisters::HcControl::HCFS_RESET;
    }
    //DEBUGMSG( ZONE_INIT, (TEXT("-CHW::StopHostController\n")));
}

// ******************************************************************
void CHW::ListControl( IN const DWORD bfList, IN const BOOL fEnable, IN const BOOL fFill )
//
// Purpose: Instruct the host controller to modify its list management policies.
//
// Parameters: a bitfield indicating which lists to affect;
//             whether to enable or disable processing of the affected lists;    
//         and whether to signal the HC that new transfers are on the affected lists.
//
// Returns: Nothing.
//
// Notes: It's kind of pointless to set bFill when a list is disabled.
//        Also, fFill is ignored for periodic (intr, isoch) lists.
//        Enabling a list may also reset its currentED pointer
//        because CPipe only knows about the HeadED pointers;
//        it does so only when the list starts out disabled in order
//        to avoid tickling a bug whereby the HC becomes confused about
//        what the current ED is during TD retirement.
//
//        This function is static
// ******************************************************************
{
    DEBUGMSG( ZONE_INIT && ZONE_VERBOSE, (TEXT("+CHW::ListControl %x ena:%d fill:%d\n"), bfList, fEnable, fFill));

    if (bfList & LIST_CONTROL) {
        if (fEnable && !m_portBase->HcControl.CLE)
            m_portBase->HcControlCurrentED = 0;
        m_portBase->HcControl.CLE=fEnable;
        if (fFill) m_portBase->HcCommandStatus.CLF=1;
    }
    if (bfList & LIST_BULK) {
        if (fEnable && !m_portBase->HcControl.BLE)
            m_portBase->HcBulkCurrentED = 0;
        m_portBase->HcControl.BLE=fEnable;
        if (fFill) m_portBase->HcCommandStatus.BLF=1;
    }
    if (bfList & LIST_INTERRUPT) {
        m_portBase->HcControl.PLE=fEnable;
    }
    if (bfList & LIST_ISOCH) {
        if (fEnable)
            m_portBase->HcControl.PLE=fEnable;
        m_portBase->HcControl.IE=fEnable;
    }
}
DWORD CALLBACK CHW::CeResumeThreadStub( IN PVOID context )
{
    return ((CHW *)context)->CeResumeThread();
}

// ******************************************************************
DWORD CHW::CeResumeThread ()
//
// Purpose: Force the HCD to reset and regenerate itself after power loss.
//
// Parameters: None
//
// Returns: Nothing.
//
// Notes: Because the PDD is probably maintaining pointers to the Hcd and Memory
//   objects, we cannot free/delete them and then reallocate. Instead, we destruct
//   them explicitly and use the placement form of the new operator to reconstruct
//   them in situ. The two flags synchronize access to the objects so that they
//   cannot be accessed before being reconstructed while also guaranteeing that
//   we don't miss power-on events that occur during the reconstruction.
//
//        This function is static
// ******************************************************************
{
    // reconstruct the objects at the same addresses where they were before;
    // this allows us not to have to alert the PDD that the addresses have changed.

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
国产精品进线69影院| 国产精品萝li| 欧美浪妇xxxx高跟鞋交| 99国产精品久久久| 91丨porny丨在线| 色综合色狠狠综合色| 一本色道久久综合亚洲精品按摩| 欧美日韩精品一区二区三区蜜桃 | 欧美人伦禁忌dvd放荡欲情| 91激情在线视频| 欧美日韩国产综合一区二区| 欧美日韩成人综合天天影院 | 亚洲国产美女搞黄色| 亚洲在线视频免费观看| 午夜伦欧美伦电影理论片| 婷婷久久综合九色国产成人| 老鸭窝一区二区久久精品| 久久爱另类一区二区小说| 国产一区二区在线看| 成人爱爱电影网址| 欧美日韩欧美一区二区| 日韩一级大片在线观看| 欧美国产欧美亚州国产日韩mv天天看完整| 欧美极品少妇xxxxⅹ高跟鞋| 一区二区三区在线免费视频| 日韩不卡在线观看日韩不卡视频| 国产一区二区三区四| 91女人视频在线观看| 制服丝袜亚洲精品中文字幕| 久久一日本道色综合| 玉米视频成人免费看| 伦理电影国产精品| www.亚洲精品| 日韩精品影音先锋| 亚洲精品ww久久久久久p站| 性久久久久久久| 成人免费视频国产在线观看| 欧美日韩国产一二三| 国产精品每日更新| 日韩av午夜在线观看| 99久久夜色精品国产网站| 91精品国产高清一区二区三区蜜臀 | 九色porny丨国产精品| 色综合视频一区二区三区高清| 日韩欧美成人一区二区| 1024成人网| 国产一区二三区| 91精品久久久久久久99蜜桃 | 在线观看一区不卡| 国产欧美日韩视频一区二区| 天涯成人国产亚洲精品一区av| 国产二区国产一区在线观看| 51精品秘密在线观看| 亚洲日本va午夜在线影院| 国产精品主播直播| 91精品国产综合久久久久久漫画| 亚洲欧洲精品一区二区三区不卡| 麻豆国产一区二区| 欧美美女网站色| 一区二区三区中文字幕精品精品 | 国内精品国产成人国产三级粉色| 欧美另类z0zxhd电影| 一区二区三区四区在线免费观看| 成人中文字幕电影| 国产亚洲成年网址在线观看| 人人狠狠综合久久亚洲| 欧美精品免费视频| 亚洲第一av色| 欧美视频在线观看一区二区| 亚洲综合免费观看高清在线观看| 91色综合久久久久婷婷| 国产精品剧情在线亚洲| 粉嫩av一区二区三区在线播放| 久久只精品国产| 国产乱码精品一区二区三区忘忧草 | 欧美一区二区三区性视频| 石原莉奈在线亚洲三区| 欧美日韩不卡一区| 青青草97国产精品免费观看 | 亚洲婷婷国产精品电影人久久| 成人亚洲精品久久久久软件| 国产精品欧美极品| av在线不卡电影| 亚洲精品中文字幕乱码三区 | 日本亚洲视频在线| 日韩精品一区二区三区老鸭窝| 久久99精品国产麻豆婷婷洗澡| 欧美精品一区二区三区在线播放| 激情综合色综合久久综合| 久久在线观看免费| 99久久777色| 亚洲午夜精品一区二区三区他趣| 欧美日韩亚洲综合一区二区三区| 免费高清在线一区| 久久久www免费人成精品| 成人午夜av影视| 一区二区三区日本| 欧美mv日韩mv国产网站app| 国产成人精品亚洲日本在线桃色| 中文字幕制服丝袜成人av| 91福利视频网站| 久久99九九99精品| 一区在线中文字幕| 777午夜精品免费视频| 激情丁香综合五月| 亚洲欧洲制服丝袜| 91精品国产综合久久久久久| 国产精品一区二区果冻传媒| 亚洲色图视频网| 欧美一区二区精品在线| 丰满白嫩尤物一区二区| 午夜精品福利久久久| 久久精品亚洲国产奇米99| 色综合 综合色| 国产一区二区三区综合| 亚洲精选一二三| 久久精品亚洲乱码伦伦中文| 欧美日韩国产综合视频在线观看| 国产精品羞羞答答xxdd| 午夜精品一区二区三区三上悠亚| 国产亚洲一本大道中文在线| 欧美性淫爽ww久久久久无| 国产麻豆一精品一av一免费| 性做久久久久久| 亚洲欧美日韩国产手机在线| 久久亚洲综合色| 欧美一区二区视频免费观看| 日本高清无吗v一区| 成人蜜臀av电影| 国产一区二区剧情av在线| 三级一区在线视频先锋 | 国产呦萝稀缺另类资源| 亚洲一区二区综合| 中文字幕一区二区三区视频| 欧美精品一区二区精品网| 777xxx欧美| 精品视频在线免费看| 91农村精品一区二区在线| 懂色av中文一区二区三区| 男女激情视频一区| 图片区小说区国产精品视频| 一区二区三区四区在线| 亚洲欧美日韩一区二区| 国产精品国产三级国产aⅴ中文| 精品国产区一区| 亚洲精品在线电影| 日韩女优电影在线观看| 欧美一级视频精品观看| 欧美精品在线观看播放| 欧美日韩精品综合在线| 欧美亚洲国产bt| 欧美日韩国产天堂| 欧美视频中文一区二区三区在线观看| 91麻豆高清视频| 91国产福利在线| 欧美精品一二三四| 欧美一区二区三区在线视频| 日韩三级在线观看| 久久久久亚洲综合| 国产欧美综合在线观看第十页| 国产欧美日韩麻豆91| 国产精品免费视频网站| 亚洲天堂av老司机| 亚洲一区二区精品3399| 日韩—二三区免费观看av| 久久精品99久久久| 国产精品影音先锋| 91香蕉国产在线观看软件| 在线亚洲欧美专区二区| 久久精品人人做人人爽97| 国产丝袜欧美中文另类| 亚洲欧美日韩精品久久久久| 亚洲成人免费看| 美女诱惑一区二区| 成人手机电影网| 欧美三电影在线| 国产亚洲欧美在线| 尤物av一区二区| 国模一区二区三区白浆| 99久久精品免费| 91精品国产乱码| 中文字幕日韩av资源站| 日韩不卡一区二区三区| 国产69精品久久99不卡| 欧美日韩另类一区| 国产日韩欧美亚洲| 亚洲成a人片在线观看中文| 国产自产v一区二区三区c| 一本一本大道香蕉久在线精品 | 经典三级在线一区| 99视频一区二区| 在线电影院国产精品| 中文字幕中文字幕中文字幕亚洲无线| 午夜天堂影视香蕉久久| 欧美精品精品一区| 久久久久久亚洲综合| 日韩精品欧美精品| 91片在线免费观看| 国产婷婷色一区二区三区| 日本在线不卡视频|