⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 hw.c

📁 我自己编译的armv4i wince60模拟器的bps源文件,已经验证可以使用,欢迎下载
💻 C
📖 第 1 页 / 共 2 页
字号:
    PSERDMA_UART_INFO pHWHead = (PSERDMA_UART_INFO)pHead;
    ULONG cbRead;
    BOOL bRet;

    RETAILMSG(DEBUGMODE, (TEXT("SL_RxIntr \r\n")));

    bRet = ReadFile(pHWHead->hDMAChannel,
                    pRxBuffer,
                    *pBufflen,
                    &cbRead,
                    NULL);
    if (!bRet) {
        ASSERT(FALSE);
        cbRead=(ULONG)-1; // the caller treats this value as an error;
    }

    *pBufflen = cbRead;

    return 0;
}

// @doc OEM
// @func ULONG | SL_PutBytes | This routine is called from the MDD
//   in order to write a stream of data to the device. (Obsolete)
// 
// @rdesc Always returns 0
//
ULONG
SL_PutBytes(
           PVOID   pHead,        // @parm    PVOID returned by HWInit.
           PUCHAR  pSrc,        // @parm    Pointer to bytes to be sent.
           ULONG   NumberOfBytes,  // @parm    Number of bytes to be sent.
           PULONG  pBytesSent        // @parm    Pointer to actual number of bytes put.
           )
{
	RETAILMSG(1,(TEXT("This routine is called by old MDD\r\n")));
        ASSERT(FALSE);
	return 0;
}

//
// @doc OEM
// @func ULONG | SL_TXIntr | This routine is called from the old MDD
//   whenever INTR_TX is returned by SL_GetInterruptType (Obsolete)
// 
// @rdesc None
//
VOID
SL_TxIntr(
         PVOID pHead                // Hardware Head
         )
{
    RETAILMSG(1, (TEXT("SL_TxIntr(From old MDD)\n")));
    ASSERT(FALSE);
}

//
// @doc OEM
// @func ULONG | SL_TXIntrEx | This routine is called from the new MDD
//   whenever INTR_TX is returned by SL_GetInterruptType
// 
// @rdesc None
//
VOID
SL_TxIntrEx(
           PVOID pHead,                // Hardware Head
           PUCHAR pTxBuffer,          // @parm Pointer to receive buffer
           ULONG *pBufflen            // @parm In = max bytes to transmit, out = bytes transmitted
           )
{
    PSERDMA_UART_INFO pHWHead = (PSERDMA_UART_INFO)pHead;
    ULONG cbWritten;
    BOOL bRet;

    RETAILMSG(DEBUGMODE, (TEXT("+SL_TxIntrEx \r\n")));

    bRet = WriteFile(pHWHead->hDMAChannel,
                     pTxBuffer,
                     *pBufflen,
                     &cbWritten,
                     NULL);
    if (!bRet) {
        ASSERT(FALSE);
        *pBufflen = (ULONG)-1; // the caller treats this value as an error
    }
    *pBufflen = cbWritten;

    RETAILMSG(DEBUGMODE, (TEXT("-SL_TxIntrEx \r\n")));
}

//
// @doc OEM
// @func ULONG | SL_LineIntr | This routine is called from the MDD
//   whenever INTR_LINE is returned by SL_GetInterruptType.
// 
// @rdesc None
//
VOID
SL_LineIntr(
           PVOID pHead                // Hardware Head
           )
{
    RETAILMSG(DEBUGMODE,(TEXT("INTR_LINE \r\n")));
}

//
// @doc OEM
// @func ULONG | SL_OtherIntr | This routine is called from the MDD
//   whenever INTR_MODEM is returned by SL_GetInterruptType.
// 
// @rdesc None
//
VOID
SL_OtherIntr(
            PVOID pHead                // Hardware Head
            )
{
    RETAILMSG(DEBUGMODE,(TEXT("SL_OtherIntr \r\n")));
}

//
// @doc OEM
// @func ULONG | SL_OtherIntr | This routine is called from the MDD
//   whenever INTR_MODEM is returned by SL_GetInterruptType.
//
//   For SERDMA, it is called at the end of SERDMA_Init()
// 
// @rdesc None
//
VOID
SL_ModemIntr(
            PVOID pHead                // Hardware Head
            )
{
    PSERDMA_UART_INFO pHWHead = (PSERDMA_UART_INFO)pHead;

    RETAILMSG (DEBUGMODE, (TEXT("+SL_ModemIntr\r\n")));

    if ( pHWHead->ControlFlags & 1) {
        RETAILMSG (DEBUGMODE, (TEXT("Connecting on request from host\r\n")));
        pHWHead->DSRIsHigh = 1;
        pHWHead->EventCallback(pHWHead->pMddHead, EV_DSR|EV_RLSD);

        RETAILMSG (DEBUGMODE, (TEXT("Indicating RS232 Cable Event\r\n")));
        if ( WAIT_OBJECT_0 == WaitForAPIReady(SH_WMGR, INFINITE) ) {
            CeEventHasOccurred (NOTIFICATION_EVENT_RS232_DETECTED,NULL);
        }
    }
    else if (pHWHead->ControlFlags & 0x2) {
        // We want to disconnect
        RETAILMSG (DEBUGMODE, (TEXT("Disconnecting on request from host\r\n")));
        pHWHead->DSRIsHigh = 0;
        pHWHead->EventCallback(pHWHead->pMddHead, EV_DSR|EV_RLSD);
    }

    RETAILMSG (DEBUGMODE, (TEXT("-SL_ModemIntr\r\n")));
}

//  
// @doc OEM
// @func    ULONG | SL_GetStatus | This structure is called by the MDD
//   to retrieve the contents of a COMSTAT structure.
//
// @rdesc    The return is a ULONG, representing success (0) or failure (-1).
//
ULONG
SL_GetStatus(
            PVOID    pHead,    // @parm PVOID returned by HWInit.
            LPCOMSTAT    lpStat    // Pointer to LPCOMMSTAT to hold status.
            )
{
    RETAILMSG(DEBUGMODE, (TEXT("+SL_GetStatus 0x%X\r\n"), pHead));

    memset(lpStat, 0, sizeof(*lpStat)); // clear all status

    RETAILMSG(DEBUGMODE, (TEXT("-SL_GetStatus 0x%X\r\n"), pHead));
    return 0;
}

//
// @doc OEM
// @func    ULONG | SL_Reset | Perform any operations associated
//   with a device reset
//
// @rdesc    None.
//
VOID
SL_Reset(
        PVOID   pHead    // @parm PVOID returned by HWInit.
        )
{
    RETAILMSG(DEBUGMODE,(TEXT("SL_Reset 0x%X\r\n"), pHead));

    // A no-op for SERDMA
}

//
// @doc OEM
// @func    VOID | SL_GetModemStatus | Retrieves modem status.
//
// @rdesc    None.
//
VOID
SL_GetModemStatus(
                 PVOID   pHead,        // @parm PVOID returned by HWInit.
                 PULONG  pModemStatus    // @parm PULONG passed in by user.
                 )
{
    PSERDMA_UART_INFO pHWHead = (PSERDMA_UART_INFO)pHead;

    RETAILMSG(DEBUGMODE,  (TEXT("SL_GetModemStatus:\r\n")));

    *pModemStatus |= MS_CTS_ON;
    *pModemStatus |= pHWHead->DSRIsHigh ? MS_DSR_ON : 0;
    *pModemStatus |= pHWHead->DSRIsHigh ? MS_RLSD_ON : 0;
}

//
// @doc OEM
// @func    VOID | SL_PurgeComm | Purge RX and/or TX
// 
// @rdesc    None.
//

VOID
SL_PurgeComm(
            PVOID   pHead,        // @parm PVOID returned by HWInit.
            DWORD   fdwAction        // @parm Action to take. 
            )
{
    RETAILMSG(DEBUGMODE,(TEXT("SL_PurgeComm 0x%X\r\n"), fdwAction));
}

//
// @doc OEM
// @func    BOOL | SL_XmitComChar | Transmit a char immediately
// 
// @rdesc    TRUE if succesful
//
BOOL
SL_XmitComChar(
              PVOID   pHead,    // @parm PVOID returned by HWInit.
              UCHAR   ComChar   // @parm Character to transmit. 
              )
{
	RETAILMSG (DEBUGMODE,(TEXT("SL_XmitComChar 0x%X\r\n"), pHead));
        ASSERT(FALSE); // this is never called for SERDMA
        return FALSE;
}

//
// @doc OEM
// @func    BOOL | SL_PowerOff | Perform powerdown sequence.
// 
// @rdesc    TRUE if succesful
//
VOID
SL_PowerOff(
           PVOID   pHead        // @parm    PVOID returned by HWInit.
           )
{
    PSERDMA_UART_INFO pHWHead = (PSERDMA_UART_INFO)pHead;

    RETAILMSG(DEBUGMODE, (TEXT("SL_PowerOff \r\n")));

    if (pHWHead->OpenCount) {
        // We want to disconnect
        RETAILMSG (DEBUGMODE, (TEXT("Disconnecting for poweroff\r\n")));
        pHWHead->DSRIsHigh = 0;
        pHWHead->EventCallback(pHWHead->pMddHead, EV_DSR|EV_RLSD);
    }
}

//
// @doc OEM
// @func    BOOL | SL_PowerOn | Perform poweron sequence.
// 
// @rdesc    TRUE if succesful
//
VOID
SL_PowerOn(
          PVOID   pHead        // @parm    PVOID returned by HWInit.
          )
{
    // Restore any registers that we need
    RETAILMSG(DEBUGMODE, (TEXT("SL_PowerOn \r\n")));
    // This is a no-op for SERDMA
}

//
// @doc OEM
// @func    BOOL | SL_SetDCB | Sets new values for DCB.  This
// routine gets a DCB from the MDD.  It must then compare
// this to the current DCB, and if any fields have changed take
// appropriate action.
// 
// @rdesc    BOOL
//
BOOL
SL_SetDCB(
         PVOID   pHead,        // @parm    PVOID returned by HWInit.
         LPDCB   lpDCB       // @parm    Pointer to DCB structure
         )
{
    PSERDMA_UART_INFO pHWHead = (PSERDMA_UART_INFO)pHead;

    RETAILMSG(DEBUGMODE,(TEXT("SL_SetDCB\r\n")));
    pHWHead->dcb = *lpDCB;
    return TRUE;
}

//
// @doc OEM
// @func    BOOL | SL_SetCommTimeouts | Sets new values for the
// CommTimeouts structure. routine gets a DCB from the MDD.  It
// must then compare this to the current DCB, and if any fields
// have changed take appropriate action.
// 
// @rdesc    ULONG
//
ULONG
SL_SetCommTimeouts(
                  PVOID   pHead,        // @parm    PVOID returned by HWInit.
                  LPCOMMTIMEOUTS   lpCommTimeouts // @parm Pointer to CommTimeout structure
                  )
{
    PSERDMA_UART_INFO pHWHead = (PSERDMA_UART_INFO)pHead;

    RETAILMSG(DEBUGMODE,(TEXT("SL_SetCommTimeout 0x%X\r\n"), pHead));
    pHWHead->CommTimeouts = *lpCommTimeouts;
    return 0;
}

//
//  @doc OEM
//  @func    BOOL | SL_Ioctl | Device IO control routine.  
//  @parm DWORD | dwOpenData | value returned from COM_Open call
//    @parm DWORD | dwCode | io control code to be performed
//    @parm PBYTE | pBufIn | input data to the device
//    @parm DWORD | dwLenIn | number of bytes being passed in
//    @parm PBYTE | pBufOut | output data from the device
//    @parm DWORD | dwLenOut |maximum number of bytes to receive from device
//    @parm PDWORD | pdwActualOut | actual number of bytes received from device
//
//    @rdesc        Returns TRUE for success, FALSE for failure
//
//  @remark  The MDD will pass any unrecognized IOCTLs through to this function.
//
BOOL
SL_Ioctl(PVOID pHead, DWORD dwCode,PBYTE pBufIn,DWORD dwLenIn,
         PBYTE pBufOut,DWORD dwLenOut,PDWORD pdwActualOut)
{
	BOOL RetVal = TRUE;
	RETAILMSG(DEBUGMODE, (TEXT("+SL_Ioctl 0x%X\r\n"), pHead));
	switch (dwCode) {
	// Currently, no defined IOCTLs
	default:
		RetVal = FALSE;
		DEBUGMSG (ZONE_FUNCTION, (TEXT(" Unsupported ioctl 0x%X\r\n"), dwCode));
	break;            
	}
	RETAILMSG(DEBUGMODE, (TEXT("-SL_Ioctl 0x%X\r\n"), pHead));
	return(RetVal);
}


⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -