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

📄 wait.c

📁 Xcale270Bsp包,wince平台
💻 C
字号:
/* 
** INTEL CONFIDENTIAL
** Copyright 2000-2003 Intel Corporation All Rights Reserved.
**
** The source code contained or described herein and all documents
** related to the source code (Material) are owned by Intel Corporation
** or its suppliers or licensors.  Title to the Material remains with
** Intel Corporation or its suppliers and licensors. The Material contains
** trade secrets and proprietary and confidential information of Intel
** or its suppliers and licensors. The Material is protected by worldwide
** copyright and trade secret laws and treaty provisions. No part of the
** Material may be used, copied, reproduced, modified, published, uploaded,
** posted, transmitted, distributed, or disclosed in any way without Intel抯
** prior express written permission.
**
** No license under any patent, copyright, trade secret or other intellectual
** property right is granted to or conferred upon you by disclosure or
** delivery of the Materials, either expressly, by implication, inducement,
** estoppel or otherwise. Any license under such intellectual property rights
** must be express and approved by Intel in writing.
*/
 
/*++

Module Name: wait.c

Abstract:
 Contains delay and sleep routines for drivers 

--*/


#include <windows.h>
#include <nkintr.h>
#include "bvd1.h"
#include "wait.h"

extern PVOID VirtualAllocCopy(unsigned size,char *str,PVOID pVirtualAddress);
static XLLP_OST_T *pOSTRegs = NULL;

void usWait(unsigned usVal)
{
    if (!DelayInit())
    {
        XllpOstDelayMicroSeconds(pOSTRegs, usVal);
    }
} // usWait()

void msWait(unsigned msVal) 
{
    if (!DelayInit())
    {
        XllpOstDelayMilliSeconds(pOSTRegs, msVal);
    }
} // msWait()

/*
 * DelayInit
 *
 * All drivers that plan on using DriverSleep must call
 * DelayInit in their initialization.
 * Returns 0 for success, nonzero for failure
 */
int DelayInit(void)
{
    int status = 0; // Classic "C" for no problem
	if (!(pOSTRegs)) 
    {
	    pOSTRegs = (XLLP_OST_T *)VirtualAllocCopy(0x80,"delayInit OSTRegs",(PVOID)(OST_BASE_U_VIRTUAL));
	    if (!(pOSTRegs)) 
        {
 		    DEBUGMSG(1, (TEXT( "delayInit:  VirtualAllocCopy for OSTRegs failed!\r\n" )) );
            status = 1; // Nonzero, there was a problem.
        }
    }
    return(status);
} // DelayInit()

/*  DriverSleep
 *
 * DriverSleep is used when delays are needed within power handling routines, 
 * where no system calls are allowed.
 *
 *  The following assumptions are made when calling from a power
 *  handler routine:
 *     -- Processor is in kernel mode (so we can access mem directly)
 *     -- We're non preemptible.  Otherwise, we'll get swapped out and
 *        delay could be longer than specified.
 */
void DriverSleep(DWORD dwMS, BOOL bInPowerHandler)
{
    /*
     * If we're not in a power handler, use Sleep to block our
     * thread and let others run.  Note that Sleep() currently
     * is more accurate for low values than 2.12- the minimum sleep
     * interval is at least one system tick (25 ms) for 2.12, whereas
	 * now it is 1ms.  Of course, if a higher priority thread is ready
	 * to run when this is woken, we will see a longer wait.
     *
     */
    if (!bInPowerHandler)
	{
        Sleep(dwMS);
    }
    else
	{
		XllpOstDelayMilliSeconds(pOSTRegs, dwMS);
	}
} // DriverSleep()

⌨️ 快捷键说明

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