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

📄 ipm_kern.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:	IPM_Common.c

Abstract:  
				

Notes:

$Date: 10/08/03 11:47a $

--*/

#include <windows.h>
#include <types.h>
#include "bvd1.h"
#include "gpio.h"
#include "drv_glob.h"
#include "IPM_DrvCommon.h"
#include "xllp_pm.h"
#include "xllp_pm_OsSpecific.h"
#include "xllp_Pm_SleepContext.h"
#include "memdefs.h"
#include "pmgr.h"
#include "IPM_Kern.h"
#include "timerbvd.h"
#include "xllp_rtc.h"


#define MAXRTCVAL				0xFFFFFFFF
#define OSCRTRIM				0
#define	OSCR0_TICKS_1MS			3250

extern DWORD CurMSec;
    
// Note this function can only be called from the kernel.
// Outsiders not allowed.
BOOL IPM_RegisterWakeUpReasons()
{
	PDRIVER_GLOBALS					v_pDriverGlobals =(PDRIVER_GLOBALS ) DRIVER_GLOBALS_PHYSICAL_MEMORY_START;
	P_XLLP_PWRMGR_T					pPwrMgrRegs = (P_XLLP_PWRMGR_T) XLLP_U_V_PWRMGR_BASE;
	volatile P_PM_SLEEP_DATA_T		pPmSleepData = (volatile P_PM_SLEEP_DATA_T) SLEEP_SAVE_U_VIRTUAL;
    P_XLLP_PM_ENTER_SLEEP_PARAMS_T  pSlpParams = &pPmSleepData->sleepParameters;
    
	if(pSlpParams->PEDR & (0x1u << 31))
		v_pDriverGlobals->wup.WakeUpReasons |= RTC_WAKEUP;
	else
		v_pDriverGlobals->wup.WakeUpReasons |= KEYPAD_WAKEUP;

	return(TRUE);

}

BOOL IPM_CorrectTimerVarAfterSleep()
{
    unsigned long OSCRTrim  = (unsigned long)OSCRTRIM;                      // used to account for time elapsed while powering off
    unsigned long MaxRTCVal = (unsigned long) MAXRTCVAL;
    unsigned long secsAsleep, mSecAsleep;
    unsigned long reschedIncrement = (unsigned long)RESCHED_INCREMENT;

    volatile XLLP_RTC_T *v_pRTCReg   = (XLLP_RTC_T *) RTC_BASE_U_VIRTUAL;
	volatile XLLP_OST_T *v_pOSTReg  = (XLLP_OST_T *) OST_BASE_U_VIRTUAL;
	PDRIVER_GLOBALS v_pDriverGlobals = (PDRIVER_GLOBALS ) DRIVER_GLOBALS_PHYSICAL_MEMORY_START;

	unsigned long v_pSavedRCNR    = v_pDriverGlobals->wup.SleepTime;   

    //
    // Caclulate the # seconds we were sleeping:  
    // TODO: take care of rollover window (i.e. if it rolls during this processing below... not too concerned wince we get 1Hz tix)
    //
    if(v_pRTCReg->rcnr < v_pSavedRCNR)
    {
        // assume RCNR has rolled over
        secsAsleep = ((MaxRTCVal - v_pSavedRCNR) + v_pRTCReg->rcnr);
    }
    else
    {
        // RCNR has not rolled over
        secsAsleep = (v_pRTCReg->rcnr - v_pSavedRCNR);
    }

    //
    // Convert to MSec
    //
    mSecAsleep = (secsAsleep * 1000);

    //
    // Increase accuracy by adding in current OSCR converted to MS
    //
    mSecAsleep += ((v_pOSTReg->oscr0 / OSCR0_TICKS_1MS) + OSCRTrim);

    //
    // Update Scheduler variables to reflect that time has elapsed
    //
    CurMSec  += mSecAsleep;
	
    return(TRUE);
}

⌨️ 快捷键说明

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