青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品

唐吉訶德

  C++博客 :: 首頁 :: 聯系 :: 聚合  :: 管理
  5 Posts :: 75 Stories :: 3 Comments :: 0 Trackbacks

常用鏈接

留言簿(2)

我參與的團隊

搜索

  •  

最新評論

閱讀排行榜

評論排行榜

1. PDD層代碼簡單分析

PDD層的主要包含了以下2個類:CSerialPDDPowerUpCallback, CSerialPDD, 下面簡單的分析這2個類的作用。

1.1 CSerialPDDPowerUpCallback

CSerialPDDPowerUpCallback 類用于串口電源上電時的處理。

在調用CSerialPDD::Init()后會創建一個CSerialPDDPowerUpCallback類型的對象

在CSerialPDD::PowerOn()函數中會調用此對象的SignalCallBack()函數, 這樣RunThread就開始運行, 進而通過調用CSerialPDD::NotifyPDDInterrupt()進行后續處理, 包括調用

CeEventHasOccurred (NOTIFICATION_EVENT_RS232_DETECTED, NULL) 通知系統有串口被探測到.

以及調用SerialEventHandler()進行MDD層上的處理.

更詳細的細節可以參考微軟的源代碼:

%WINCEROOT%\PUBLIC\COMMON\OAK\DRIVERS\SERIAL\SERPDDCM\cserpdd.cpp

%WINCEROOT%\PUBLIC\COMMON\OAK\INC\cserpdd.h

2.2 CSerialPDD

CSerialPDD 是串口PDD層的關鍵,實現對硬件的操作,開發者開發的驅動就是繼承這個類,并實現重載相關的函數來完成特定設備的PDD功能的。

這個類抽象了以下這些接口:

//  Tx Function.

    virtual BOOL    InitXmit(BOOL bInit) = 0;

    virtual void    XmitInterruptHandler(PUCHAR pTxBuffer, ULONG *pBuffLen) = 0;

    virtual void    XmitComChar(UCHAR ComChar) = 0;

    virtual BOOL    EnableXmitInterrupt(BOOL bEnable)= 0;

    virtual BOOL    CancelXmit() = 0 ;

//  Rx Function.

    virtual BOOL    InitReceive(BOOL bInit) = 0;

    virtual ULONG   ReceiveInterruptHandler(PUCHAR pRxBuffer,ULONG *pBufflen) = 0;

    virtual ULONG   CancelReceive() = 0;

//  Modem

    virtual BOOL    InitModem(BOOL bInit) = 0;

    virtual void    ModemInterruptHandler()= 0; // This is Used to Indicate Modem Signal Changes.

    virtual ULONG   GetModemStatus() = 0;

    virtual void    SetDTR(BOOL bSet)= 0;

    virtual void    SetRTS(BOOL bSet)= 0;

    virtual BOOL    IsCTSOff() {  return ((GetModemStatus() & MS_CTS_ON)==0) ; };

    virtual BOOL    IsDSROff() {  return ((GetModemStatus() & MS_DSR_ON)==0) ; };

//  Line Function

    virtual BOOL    InitLine(BOOL bInit) = 0;

    virtual void    LineInterruptHandler() = 0;

    virtual void    SetBreak(BOOL bSet) = 0 ;   

    virtual BOOL    SetBaudRate(ULONG BaudRate,BOOL bIrModule) = 0;

    virtual BOOL    SetByteSize(ULONG ByteSize) = 0;

    virtual BOOL    SetParity(ULONG Parity)= 0;

    virtual BOOL    SetStopBits(ULONG StopBits)= 0;

    以上這些接口都是純虛函數, 在實現PDD層時, 必須實現這些接口.

當然不需要的功能你可以簡單的用類似virtual BOOL func() {;} 的形式來實現。

其他的非純虛函數的虛函數也可以被用戶重載, 以實現自己特定的功能。

    我們知道PDD層的函數為如下函數:

GetSerialObject

 This function returns a pointer to a HWOBJ structure. The structure contains the function pointers and parameters for the hardware interface functions of the relevant lower layer.

HWClearBreak

 This function clears an RS-232 line break condition.

HWClearDTR

 This function clears the Data Terminal Ready (DTR) signal.

HWClearRTS

 This function clears the Request to Send (RTS) signal.

HWClose

 This function closes the device initialized by the HWInit function.

HWDeinit

 This function is called by the upper layer to de-initialize the hardware when a device driver is unloaded.

HWDisableIR

 This function disables the infrared (IR) serial interface.

HWEnableIR

 This function enables the infrared (IR) serial interface.

HWGetCommProperties

 This function retrieves the current properties of the communications device.

HWGetIntrType

 This function returns the current interrupt type.

HWGetModemStatus

 This function retrieves the modem status.

HWGetRxBufferSize

 This function returns the maximum number of bytes that the hardware buffer can hold, not including the padding, stop, and start bits.

HWGetRxStart

 This function returns the start of the hardware-receive buffer.

HWGetStatus

 This function specifies the hardware status API.

HWInit

 This function initializes a serial device.

HWIoctl

 This function executes device I/O control (IOCTL) routines.

HWLineIntrHandler

 This function handles line interrupts for serial port devices.

HWModemIntrHandler

 This function handles the modem interrupt. In the serial port upper layer implementation available in Microsoft Windows CE 3.0 and later, this function replaces the HWOtherIntrHandler function.

HWOpen

 This function is called by the upper layer to open the serial device.

HWOtherIntrHandler

 In Windows CE 3.0 and later, this function has been replaced with the new function HWModemIntrHandler.

HWPostInit

 This function performs necessary operations after it initializes all data structures and prepares the serial IST to begin handling interrupts. It is called by the upper layer.

HWPowerOff

 This function notifies the platform-dependent driver that the hardware platform is about to enter suspend mode. It is called by the model device driver (MDD).

HWPowerOn

 This function notifies the platform-dependent driver that the hardware platform is resuming from suspend mode. It is called by the MDD.

HWPurgeComm

 This function purges the communications device.

HWPutBytes

 This function writes bytes to hardware. The driver calls this function.

HWReset

 This function resets the hardware API.

HWRxIntrHandler

 This function handles serial port interrupts.

HWSetBreak

 This function sets the line break condition on the transmit line.

HWSetCommTimeouts

 This function sets the communications time-out events in response to a call to the SetCommTimeouts function.

HWSetDCB

 This function sets the device control block.

HWSetDTR

 This function sets the Data Terminal Ready (DTR) signal.

HWSetRTS

 This function sets the Request to Send (RTS) signal.

HWTxIntrHandler

 This function handles the transmit interrupt for serial port devices.

HWXmitComChar

 This function transmits a single character.

更具體的細節可以參考:MSDN幫助 ms-help://MS.WindowsCE.500/wceddk5/html/wce50grfserialportdriverfunctions.htm

    微軟用一堆SerXXXXX()的函數封裝了CSerialPdd相關的操作,來完成PDD功能。

2. PDD與MDD層的交互

2.1 PDD層的函數是如何能夠被MDD層所調用

1.2節介紹的那一堆SerXXXXX()函數會被記錄到一個函數指針表里,真是通過這個函數指針表來實現與MDD層的交互的。此函數指針表是HW_VTBL類型的, 在微軟的代碼里是命名為IoVTbl的函數指針表。

    MDD層通過調用 GetSerialObject(DWORD DeviceArrayIndex)函數來獲取一個HWOBJ結構的指針, 這個結構包含以下成員:

    ULONG  BindFlags; // Flags controlling MDD behaviour.  Se above.

    DWORD   dwIntID;   // Interrupt Identifier used if THREAD_AT_INIT or THREAD_AT_OPEN

    PHW_VTBL   pFuncTbl;

    其中pFuncTbl正是指向我們之前說到的 IoVTbl 函數指針結構的地址.

這樣MDD層就可以通過->pFuncTbl.DDSIFunction()來對特定的硬件做特定的操作了.

2.2 GetSerialObject函數

這個函數的原型是:PHWOBJ GetSerialObject(DWORD DeviceArrayIndex) ,它是連接MDD和PDD層的關鍵函數, 也是實現多端口驅動的關鍵, 這個函數允許一個MDD層連接多個PDD層。

在MDD層的COM_Init函數中,驅動會通過查詢DeviceArrayIndex鍵值, 得到我們需要打開的是普通串口或者是其他種類的串口設備。

而正是這個數值決定了GetSerialObject是返回哪個串口的PHWOBJ指針, PHWOBJ包含了pFuncTbl,這個正是前一節說到的PDD層函數指針表,通過這個函數表我們就可以實現對相應的串口設備進行操作。(串口有可能是標準的串口,也有可能是紅外設備)

2.3 CreateSerialObject 函數

如果開發者選擇直接繼承微軟CSerialPdd類來實現串口的PDD層,還要實現CreateSerialObject及DeleteSerialObject函數。

在MDD層的COM_Init函數被調用時,驅動會通過查詢注冊表來得到相關參數并調用PDD層的HWInit函數,HWInit函數又會調用CreateSerialObject來初始化串口設備,在關閉串口以后DeleteSerialObject函數會被調用。

3. 其他

3.1 COM_Init函數如何被調用

此函數通常是由Device.exe進程調用的, 而此函數的參數Identifier 是一個指向注冊表HKEY_LOCAL_MACHINE\Drivers\Active.下的一個鍵值,這也是決定驅動如何操作硬件的關鍵。

對于使用ActivateDeviceEx函數調用的情況,請參照MSND, http://msdn.microsoft.com/en-us/library/aa447677.aspx

3.2 相關代碼段:

view plaincopy to clipboardprint?

HANDLE 

COM_Init(  

        ULONG   Identifier  

        )  

{  

    PVOID           pHWHead     = NULL;  

    PHW_INDEP_INFO  pSerialHead = NULL;  

    ULONG           HWBufferSize;  

    DWORD           DevIndex;  

    HKEY            hKey;  

    ULONG           kreserved = 0, kvaluetype;  

    ULONG           datasize = sizeof(ULONG);  

    /* 

     *  INTERNAL: this routine initializes the hardware abstraction interface 

     *  via HWInit(). It allocates a data structure representing this 

     *  instantiation of the device. It also creates an event and initializes 

     *  a critical section for receiving as well as registering the logical 

     *  interrupt dwIntID with NK via InterruptInitialize. This call 

     *  requires that the hardware dependent portion export apis that return 

     *  the physical address of the receive buffer and the size of that buffer. 

     *  Finally, it creates a buffer to act as an intermediate 

     *  buffer when receiving. 

     */ 

    DEBUGMSG (ZONE_INIT | ZONE_FUNCTION, (TEXT("+COM_Init\r\n")));  

    // Allocate our control structure.  

    pSerialHead  =  (PHW_INDEP_INFO)LocalAlloc(LPTR, sizeof(HW_INDEP_INFO));  

    // Check that LocalAlloc did stuff ok too.  

    if ( !pSerialHead ) {  

        DEBUGMSG(ZONE_INIT | ZONE_ERROR,  

                 (TEXT("Error allocating memory for pSerialHead, COM_Init failed\n\r")));  

        return(NULL);  

    }  

    // Initially, open list is empty.  

    InitializeListHead( &pSerialHead->OpenList );  

    InitializeCriticalSection(&(pSerialHead->OpenCS));  

    pSerialHead->pAccessOwner = NULL;  

    pSerialHead->fEventMask = 0;  

    // Init CommTimeouts.  

    pSerialHead->CommTimeouts.ReadIntervalTimeout = READ_TIMEOUT;  

    pSerialHead->CommTimeouts.ReadTotalTimeoutMultiplier =  

    READ_TIMEOUT_MULTIPLIER;  

    pSerialHead->CommTimeouts.ReadTotalTimeoutConstant =  

    READ_TIMEOUT_CONSTANT;  

    pSerialHead->CommTimeouts.WriteTotalTimeoutMultiplier=  0;  

    pSerialHead->CommTimeouts.WriteTotalTimeoutConstant =   0;  

    /* Create tx and rx events and stash in global struct field. Check return. 

     */ 

    pSerialHead->hSerialEvent = CreateEvent(0,FALSE,FALSE,NULL);  

    pSerialHead->hKillDispatchThread = CreateEvent(0, FALSE, FALSE, NULL);  

    pSerialHead->hTransmitEvent = CreateEvent(0, FALSE, FALSE, NULL);  

    pSerialHead->hReadEvent = CreateEvent(0, FALSE, FALSE, NULL);  

    if ( !pSerialHead->hSerialEvent || !pSerialHead->hKillDispatchThread ||  

         !pSerialHead->hTransmitEvent || !pSerialHead->hReadEvent ) {  

        DEBUGMSG(ZONE_ERROR | ZONE_INIT,  

                 (TEXT("Error creating event, COM_Init failed\n\r")));  

        LocalFree(pSerialHead);  

        return(NULL);  

    }  

    /* Initialize the critical sections that will guard the parts of 

     * the receive and transmit buffers. 

     */ 

    InitializeCriticalSection(&(pSerialHead->ReceiveCritSec1));  

    InitializeCriticalSection(&(pSerialHead->TransmitCritSec1));  

    /* Want to use the Identifier to do RegOpenKey and RegQueryValue (?) 

     * to get the index to be passed to GetHWObj. 

     * The HWObj will also have a flag denoting whether to start the 

     * listening thread or provide the callback. 

     */ 

    DEBUGMSG (ZONE_INIT,(TEXT("Try to open %s\r\n"), (LPCTSTR)Identifier));  

    hKey = OpenDeviceKey((LPCTSTR)Identifier);  

    // 通過調用OpenDeviceKey, 驅動可以通過Identifier找到驅動的注冊表鍵的所在.  

    if ( !hKey ) {  

        DEBUGMSG (ZONE_INIT | ZONE_ERROR,  

                  (TEXT("Failed to open devkeypath, COM_Init failed\r\n")));  

        LocalFree(pSerialHead);  

        return(NULL);  

    }  

    datasize = sizeof(DWORD);  

    // 通過查詢DeviceArrayIndex鍵值, 我們可以知道需要打開的是普通串口或者是其他類型的串口設備.  

    if ( RegQueryValueEx(hKey, L"DeviceArrayIndex", NULL, &kvaluetype,  

                         (LPBYTE)&DevIndex, &datasize) ) {  

        DEBUGMSG (ZONE_INIT | ZONE_ERROR,  

                  (TEXT("Failed to get DeviceArrayIndex value, COM_Init failed\r\n")));  

        RegCloseKey (hKey);  

        LocalFree(pSerialHead);  

        return(NULL);  

    }  

    datasize = sizeof(DWORD);  

    // 通過查詢Priority256鍵值, 我們可以知道IST的優先級,  在后面會通過這個值來改變IST的優先級.  

    if ( RegQueryValueEx(hKey, L"Priority256", NULL, &kvaluetype,  

                         (LPBYTE)&pSerialHead->Priority256, &datasize) ) {  

        pSerialHead->Priority256 = DEFAULT_CE_THREAD_PRIORITY;  

        DEBUGMSG (ZONE_INIT | ZONE_WARN,  

                  (TEXT("Failed to get Priority256 value, defaulting to %d\r\n"), pSerialHead->Priority256));  

    }  

    RegCloseKey (hKey);  

    DEBUGMSG (ZONE_INIT,  

              (TEXT("DevIndex %X\r\n"), DevIndex));  

    // Initialize hardware dependent data.  

    // GetSerialObject是連接MDD和PDD層的關鍵函數, 在這個函數里面決定了DevIndex是對什么設備進行操作.  

    // 可能是標準的串口, 也可能是紅外接口  

    pSerialHead->pHWObj = GetSerialObject( DevIndex );  

    if ( !pSerialHead->pHWObj ) {  

        DEBUGMSG(ZONE_ERROR | ZONE_INIT,  

                 (TEXT("Error in GetSerialObject, COM_Init failed\n\r")));  

        LocalFree(pSerialHead);  

        return(NULL);  

    }  

    DEBUGMSG (ZONE_INIT, (TEXT("About to call HWInit(%s,0x%X)\r\n"),  

                          Identifier, pSerialHead));  

    // 這里調用了PDD層的HWInit  

    pHWHead = pSerialHead->pHWObj->pFuncTbl->HWInit(Identifier, pSerialHead, pSerialHead->pHWObj);  

    pSerialHead->pHWHead = pHWHead;  

    /* Check that HWInit did stuff ok.  From here on out, call Deinit function 

     * when things fail.  

     */ 

    if ( !pHWHead ) {  

        DEBUGMSG (ZONE_INIT | ZONE_ERROR,  

                  (TEXT("Hardware doesn't init correctly, COM_Init failed\r\n")));  

        COM_Deinit(pSerialHead);  

        return(NULL);  

    }  

    DEBUGMSG (ZONE_INIT,  

              (TEXT("Back from hardware init\r\n")));  

    // Allocate at least twice the hardware buffer size so we have headroom  

    HWBufferSize        = 2 * pSerialHead->pHWObj->pFuncTbl->HWGetRxBufferSize(pHWHead);  

    // Init rx buffer and buffer length here.  

    pSerialHead->RxBufferInfo.Length =  

    HWBufferSize > RX_BUFFER_SIZE ? HWBufferSize:RX_BUFFER_SIZE;  

    pSerialHead->RxBufferInfo.RxCharBuffer =  

    LocalAlloc(LPTR, pSerialHead->RxBufferInfo.Length);  

    if ( !pSerialHead->RxBufferInfo.RxCharBuffer ) {  

        DEBUGMSG(ZONE_INIT|ZONE_ERROR,  

                 (TEXT("Error allocating receive buffer, COM_Init failed\n\r")));  

        COM_Deinit(pSerialHead);  

        return(NULL);  

    }  

    DEBUGMSG (ZONE_INIT, (TEXT("RxHead init'ed\r\n")));  

    RxResetFifo(pSerialHead);  

    InitializeCriticalSection(&(pSerialHead->RxBufferInfo.CS));  

    InitializeCriticalSection(&(pSerialHead->TxBufferInfo.CS));  

    DEBUGMSG (ZONE_INIT, (TEXT("RxBuffer init'ed with start at %x\r\n"),  

                          pSerialHead->RxBufferInfo.RxCharBuffer));  

    if ( pSerialHead->pHWObj->BindFlags & THREAD_AT_INIT ) {  

        // Hook the interrupt and start the associated thread.  

        if ( ! StartDispatchThread( pSerialHead ) ) {  

            // Failed on InterruptInitialize or CreateThread.  Bail.  

            COM_Deinit(pSerialHead);  

            return(NULL);          

        }  

    }  

    // OK, now that everything is ready on our end, give the PDD  

    // one last chance to init interrupts, etc.  

    (void) pSerialHead->pHWObj->pFuncTbl->HWPostInit( pHWHead );  

    DEBUGMSG (ZONE_INIT | ZONE_FUNCTION, (TEXT("-COM_Init\r\n")));  

    return(pSerialHead);  

HANDLE

COM_Init(

        ULONG   Identifier

        )

{

    PVOID           pHWHead     = NULL;

    PHW_INDEP_INFO  pSerialHead = NULL;

    ULONG           HWBufferSize;

    DWORD           DevIndex;

    HKEY            hKey;

    ULONG           kreserved = 0, kvaluetype;

    ULONG           datasize = sizeof(ULONG);

    /*

     *  INTERNAL: this routine initializes the hardware abstraction interface

     *  via HWInit(). It allocates a data structure representing this

     *  instantiation of the device. It also creates an event and initializes

     *  a critical section for receiving as well as registering the logical

     *  interrupt dwIntID with NK via InterruptInitialize. This call

     *  requires that the hardware dependent portion export apis that return

     *  the physical address of the receive buffer and the size of that buffer.

     *  Finally, it creates a buffer to act as an intermediate

     *  buffer when receiving.

     */

    DEBUGMSG (ZONE_INIT | ZONE_FUNCTION, (TEXT("+COM_Init\r\n")));

    // Allocate our control structure.

    pSerialHead = (PHW_INDEP_INFO)LocalAlloc(LPTR, sizeof(HW_INDEP_INFO));

    // Check that LocalAlloc did stuff ok too.

    if ( !pSerialHead ) {

        DEBUGMSG(ZONE_INIT | ZONE_ERROR,

                 (TEXT("Error allocating memory for pSerialHead, COM_Init failed\n\r")));

        return(NULL);

    }

    // Initially, open list is empty.

    InitializeListHead( &pSerialHead->OpenList );

    InitializeCriticalSection(&(pSerialHead->OpenCS));

    pSerialHead->pAccessOwner = NULL;

    pSerialHead->fEventMask = 0;

    // Init CommTimeouts.

    pSerialHead->CommTimeouts.ReadIntervalTimeout = READ_TIMEOUT;

    pSerialHead->CommTimeouts.ReadTotalTimeoutMultiplier =

    READ_TIMEOUT_MULTIPLIER;

    pSerialHead->CommTimeouts.ReadTotalTimeoutConstant =

    READ_TIMEOUT_CONSTANT;

    pSerialHead->CommTimeouts.WriteTotalTimeoutMultiplier=  0;

    pSerialHead->CommTimeouts.WriteTotalTimeoutConstant =   0;

    /* Create tx and rx events and stash in global struct field. Check return.

     */

    pSerialHead->hSerialEvent = CreateEvent(0,FALSE,FALSE,NULL);

    pSerialHead->hKillDispatchThread = CreateEvent(0, FALSE, FALSE, NULL);

    pSerialHead->hTransmitEvent = CreateEvent(0, FALSE, FALSE, NULL);

    pSerialHead->hReadEvent = CreateEvent(0, FALSE, FALSE, NULL);

    if ( !pSerialHead->hSerialEvent || !pSerialHead->hKillDispatchThread ||

         !pSerialHead->hTransmitEvent || !pSerialHead->hReadEvent ) {

        DEBUGMSG(ZONE_ERROR | ZONE_INIT,

                 (TEXT("Error creating event, COM_Init failed\n\r")));

        LocalFree(pSerialHead);

        return(NULL);

    }

    /* Initialize the critical sections that will guard the parts of

     * the receive and transmit buffers.

     */

    InitializeCriticalSection(&(pSerialHead->ReceiveCritSec1));

    InitializeCriticalSection(&(pSerialHead->TransmitCritSec1));

    /* Want to use the Identifier to do RegOpenKey and RegQueryValue (?)

     * to get the index to be passed to GetHWObj.

     * The HWObj will also have a flag denoting whether to start the

     * listening thread or provide the callback.

     */

    DEBUGMSG (ZONE_INIT,(TEXT("Try to open %s\r\n"), (LPCTSTR)Identifier));

    hKey = OpenDeviceKey((LPCTSTR)Identifier);

    // 通過調用OpenDeviceKey, 驅動可以通過Identifier找到驅動的注冊表鍵的所在.

    if ( !hKey ) {

        DEBUGMSG (ZONE_INIT | ZONE_ERROR,

                  (TEXT("Failed to open devkeypath, COM_Init failed\r\n")));

        LocalFree(pSerialHead);

        return(NULL);

    }

    datasize = sizeof(DWORD);

    // 通過查詢DeviceArrayIndex鍵值, 我們可以知道需要打開的是普通串口或者是其他類型的串口設備.

    if ( RegQueryValueEx(hKey, L"DeviceArrayIndex", NULL, &kvaluetype,

                         (LPBYTE)&DevIndex, &datasize) ) {

        DEBUGMSG (ZONE_INIT | ZONE_ERROR,

                  (TEXT("Failed to get DeviceArrayIndex value, COM_Init failed\r\n")));

        RegCloseKey (hKey);

        LocalFree(pSerialHead);

        return(NULL);

    }

    datasize = sizeof(DWORD);

    // 通過查詢Priority256鍵值, 我們可以知道IST的優先級,  在后面會通過這個值來改變IST的優先級.

    if ( RegQueryValueEx(hKey, L"Priority256", NULL, &kvaluetype,

                         (LPBYTE)&pSerialHead->Priority256, &datasize) ) {

        pSerialHead->Priority256 = DEFAULT_CE_THREAD_PRIORITY;

        DEBUGMSG (ZONE_INIT | ZONE_WARN,

                  (TEXT("Failed to get Priority256 value, defaulting to %d\r\n"), pSerialHead->Priority256));

    }

    RegCloseKey (hKey);

    DEBUGMSG (ZONE_INIT,

              (TEXT("DevIndex %X\r\n"), DevIndex));

    // Initialize hardware dependent data.

    // GetSerialObject是連接MDD和PDD層的關鍵函數, 在這個函數里面決定了DevIndex是對什么設備進行操作.

    // 可能是標準的串口, 也可能是紅外接口

    pSerialHead->pHWObj = GetSerialObject( DevIndex );

    if ( !pSerialHead->pHWObj ) {

        DEBUGMSG(ZONE_ERROR | ZONE_INIT,

                 (TEXT("Error in GetSerialObject, COM_Init failed\n\r")));

        LocalFree(pSerialHead);

        return(NULL);

    }

    DEBUGMSG (ZONE_INIT, (TEXT("About to call HWInit(%s,0x%X)\r\n"),

                          Identifier, pSerialHead));

    // 這里調用了PDD層的HWInit

    pHWHead = pSerialHead->pHWObj->pFuncTbl->HWInit(Identifier, pSerialHead, pSerialHead->pHWObj);

    pSerialHead->pHWHead = pHWHead;

    /* Check that HWInit did stuff ok.  From here on out, call Deinit function

     * when things fail.

     */

    if ( !pHWHead ) {

        DEBUGMSG (ZONE_INIT | ZONE_ERROR,

                  (TEXT("Hardware doesn't init correctly, COM_Init failed\r\n")));

        COM_Deinit(pSerialHead);

        return(NULL);

    }

    DEBUGMSG (ZONE_INIT,

              (TEXT("Back from hardware init\r\n")));

    // Allocate at least twice the hardware buffer size so we have headroom

    HWBufferSize = 2 * pSerialHead->pHWObj->pFuncTbl->HWGetRxBufferSize(pHWHead);

    // Init rx buffer and buffer length here.

    pSerialHead->RxBufferInfo.Length =

    HWBufferSize > RX_BUFFER_SIZE ? HWBufferSize:RX_BUFFER_SIZE;

    pSerialHead->RxBufferInfo.RxCharBuffer =

    LocalAlloc(LPTR, pSerialHead->RxBufferInfo.Length);

    if ( !pSerialHead->RxBufferInfo.RxCharBuffer ) {

        DEBUGMSG(ZONE_INIT|ZONE_ERROR,

                 (TEXT("Error allocating receive buffer, COM_Init failed\n\r")));

        COM_Deinit(pSerialHead);

        return(NULL);

    }

    DEBUGMSG (ZONE_INIT, (TEXT("RxHead init'ed\r\n")));

    RxResetFifo(pSerialHead);

    InitializeCriticalSection(&(pSerialHead->RxBufferInfo.CS));

    InitializeCriticalSection(&(pSerialHead->TxBufferInfo.CS));

    DEBUGMSG (ZONE_INIT, (TEXT("RxBuffer init'ed with start at %x\r\n"),

                          pSerialHead->RxBufferInfo.RxCharBuffer));

    if ( pSerialHead->pHWObj->BindFlags & THREAD_AT_INIT ) {

        // Hook the interrupt and start the associated thread.

        if ( ! StartDispatchThread( pSerialHead ) ) {

            // Failed on InterruptInitialize or CreateThread.  Bail.

            COM_Deinit(pSerialHead);

            return(NULL);

        }

    }

    // OK, now that everything is ready on our end, give the PDD

    // one last chance to init interrupts, etc.

    (void) pSerialHead->pHWObj->pFuncTbl->HWPostInit( pHWHead );

    DEBUGMSG (ZONE_INIT | ZONE_FUNCTION, (TEXT("-COM_Init\r\n")));

    return(pSerialHead);

}


posted on 2011-03-01 16:13 心羽 閱讀(604) 評論(0)  編輯 收藏 引用 所屬分類: wince
青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品
  • <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>
            激情国产一区二区| 免费亚洲电影在线| 老鸭窝毛片一区二区三区| 亚洲色在线视频| 欧美1区2区视频| 久久综合给合| 欧美日韩视频在线一区二区 | 久久精品一区二区三区不卡| 日韩亚洲视频在线| 噜噜噜久久亚洲精品国产品小说| 久久aⅴ乱码一区二区三区| 欧美精品一区二区三区四区| 欧美成人精品在线| 国产自产2019最新不卡| 亚洲综合日韩中文字幕v在线| 亚洲综合色婷婷| 欧美日韩国产精品专区 | 亚洲美女在线一区| 亚洲欧洲另类| 麻豆精品一区二区av白丝在线| 噜噜噜91成人网| 国产亚洲欧美一区二区| 欧美一级欧美一级在线播放| 欧美亚洲视频在线观看| 国产精品久久97| 中文欧美字幕免费| 亚洲综合色激情五月| 欧美性感一类影片在线播放| 国产精品99久久久久久久久久久久| 中文精品99久久国产香蕉| 欧美精品激情在线| 亚洲国产另类久久久精品极度| 在线视频观看日韩| 蜜桃av综合| 亚洲国产精品专区久久| a4yy欧美一区二区三区| 欧美日韩日韩| 亚洲在线免费观看| 久久精品二区亚洲w码| 国产一区二区你懂的| 久久亚洲国产精品日日av夜夜| 欧美成人国产va精品日本一级| 亚洲国产精品va在线看黑人| 欧美日韩成人免费| 在线亚洲免费| 久久精品成人| 亚洲日本无吗高清不卡| 欧美日韩亚洲免费| 亚洲永久免费av| 免费在线观看精品| 亚洲精品视频免费在线观看| 欧美日韩亚洲综合| 亚洲综合色噜噜狠狠| 久久免费99精品久久久久久| 亚洲精品乱码久久久久| 国产精品99一区二区| 久久精品人人做人人爽| 亚洲福利专区| 欧美亚洲色图校园春色| 136国产福利精品导航网址| 欧美三区在线| 久久国产夜色精品鲁鲁99| 91久久精品一区二区别| 欧美自拍偷拍午夜视频| 亚洲区欧美区| 国产欧美日韩在线| 欧美成人按摩| 亚洲欧美在线aaa| 欧美丰满少妇xxxbbb| 欧美在线观看视频| 亚洲欧洲精品成人久久奇米网| 国产伦精品一区二区三区视频黑人 | 国产乱肥老妇国产一区二| 蜜桃av一区二区三区| 亚洲一级特黄| 亚洲激情六月丁香| 久久精品1区| 亚洲一区影院| 亚洲人成在线免费观看| 国产亚洲精品久久久久久| 欧美日韩视频不卡| 美女视频黄 久久| 亚洲综合国产激情另类一区| 亚洲精品久久久久久久久| 老司机午夜精品视频| 先锋亚洲精品| 亚洲一级高清| 99精品欧美一区二区蜜桃免费| 精品动漫3d一区二区三区免费版 | 欧美一区二区三区在线免费观看| 最新热久久免费视频| 韩国女主播一区二区三区| 国产精品日韩专区| 欧美日韩国产另类不卡| 欧美护士18xxxxhd| 久久美女性网| 久久久久综合网| 欧美一二区视频| 亚洲欧美国产不卡| 一本到高清视频免费精品| 91久久久精品| 亚洲精品视频在线观看免费| 亚洲福利视频专区| 欧美好骚综合网| 欧美激情成人在线| 亚洲缚视频在线观看| 欧美国产精品中文字幕| 牛夜精品久久久久久久99黑人| 久久免费国产精品| 久久久久久久精| 久久男人资源视频| 可以免费看不卡的av网站| 久久精品成人一区二区三区蜜臀| 欧美在线观看天堂一区二区三区| 欧美在线中文字幕| 久久精品女人| 久热精品视频在线观看| 欧美mv日韩mv国产网站| 免费观看成人| 亚洲国产精品t66y| 99视频国产精品免费观看| 一区二区三区产品免费精品久久75| 99精品国产高清一区二区| 亚洲视频成人| 欧美一区二区视频免费观看| 久久男人av资源网站| 欧美成人视屏| 欧美性色综合| 国内久久精品| 亚洲精品国产精品国自产在线 | 国产农村妇女毛片精品久久麻豆| 国产午夜亚洲精品不卡| 国内成人精品2018免费看| 亚洲福利视频网| 日韩写真在线| 欧美亚洲一区三区| 久久夜色精品亚洲噜噜国产mv| 欧美激情影院| 亚洲一区黄色| 噜噜噜在线观看免费视频日韩| 欧美日本在线观看| 国产欧美一区二区在线观看| 欲色影视综合吧| 亚洲图片在线观看| 欧美专区在线播放| 亚洲高清一区二| 欧美一级一区| 欧美日韩一区二区三区在线| 国产在线观看精品一区二区三区| 日韩一区二区精品葵司在线| 欧美一区二视频| 91久久久久久久久| 午夜精品一区二区三区四区| 欧美激情精品久久久| 国产日韩一区欧美| 日韩一级在线| 男人的天堂亚洲在线| 一区二区三区免费看| 噜噜噜久久亚洲精品国产品小说| 国产精品美女久久久久av超清| 最新日韩在线视频| 久久久久国产一区二区| 亚洲乱码精品一二三四区日韩在线 | 在线播放豆国产99亚洲| 亚洲制服丝袜在线| 欧美黑人一区二区三区| 欧美一区二区三区的| 欧美香蕉大胸在线视频观看| 亚洲黑丝一区二区| 久久都是精品| av成人免费在线| 欧美www视频在线观看| 国产一区二区视频在线观看| 亚洲直播在线一区| 亚洲美女av黄| 欧美国产高潮xxxx1819| 1024日韩| 免费亚洲电影在线观看| 亚洲欧美综合精品久久成人| 欧美午夜免费电影| 一本色道久久综合狠狠躁篇的优点| 欧美暴力喷水在线| 欧美一区二区三区男人的天堂| 国产精品成人一区二区网站软件| 日韩视频在线观看国产| 欧美激情一区二区三区| 久久精品官网| 国产主播喷水一区二区| 久久国内精品视频| 亚洲一区免费视频| 国产精品日本| 性欧美xxxx视频在线观看| 一片黄亚洲嫩模| 欧美丝袜第一区| 亚洲综合色在线| 亚洲欧美国产精品va在线观看 | 久久久久久亚洲精品中文字幕| 香蕉成人伊视频在线观看| 国产精品尤物福利片在线观看| 欧美亚洲视频|