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

📄 secureclock.c

📁 freescale i.mx31 BSP CE5.0全部源码
💻 C
字号:
//
// 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.
//
//------------------------------------------------------------------------------
//
//  File: secureclock.c           
//
//  This file implements PMC's DRM clock functions.
//

#ifdef PLAT_PMC

#include "bsp.h"

//------------------------------------------------------------------------------
//
//  Function:  OALIoCtlPmcGetSecureClockStatus
//
//  This function returns a bool indicating whether the secure clock is currently set.
//  This is part of Janus DRM support.
//
BOOL OALIoCtlPmcGetSecureClockStatus( 
    UINT32 code, VOID *pInpBuffer, UINT32 inpSize, VOID *pOutBuffer, 
    UINT32 outSize, UINT32 *pOutSize )
{
    BOOL ret = FALSE;

    if(pOutBuffer && outSize >= sizeof(BOOL))
    {
        PPMC_ARGS pPmcArgs = (PPMC_ARGS) OALArgsQuery(PMC_ARGS_QUERY_PMCARGS);
        if (pPmcArgs == NULL)
        {
            ret = FALSE;
        }
        else
        {
            memcpy(pOutBuffer, &pPmcArgs->fDRMClockSet, sizeof(BOOL));
            if(pOutSize)
            {
                *pOutSize = sizeof(BOOL);
            }
            ret = TRUE;
        }
    }

    return(ret);
}

//------------------------------------------------------------------------------
//
//  Function:  OALIoCtlPmcSetSecureClockStatus
//
//  This function sets whether the secure clock is set or not.  
//  This is part of Janus DRM support.
//
BOOL OALIoCtlPmcSetSecureClockStatus( 
    UINT32 code, VOID *pInpBuffer, UINT32 inpSize, VOID *pOutBuffer, 
    UINT32 outSize, UINT32 *pOutSize )
{
    BOOL ret = FALSE;

    if(pInpBuffer && inpSize >= sizeof(BOOL))
    {
        PPMC_ARGS pPmcArgs = (PPMC_ARGS) OALArgsQuery(PMC_ARGS_QUERY_PMCARGS);
        if (pPmcArgs == NULL)
        {
            ret = FALSE;
        }
        else
        {
            BOOL fClockValid = *((LPBOOL) pInpBuffer);
            pPmcArgs->fDRMClockSet = fClockValid;
            ret = TRUE;
        }
    }

    return(ret);
}

//--------------------------------------------------------------------------------------------
//
//  Function:  OEMInitSecureClockStatus
//
// *** Janus DRM support ***
// Initializes the flag indicating whether the clock is set or not.  It should be 
// called during OEMInit().
// NOTE:  OEMS that are using the system RTC for the DRM clock should NOT reset
// the clock during IOCTL_HAL_INIT_RTC.
//
void OEMInitSecureClockStatus(void)
{
    PPMC_ARGS pPmcArgs = (PPMC_ARGS) OALArgsQuery(PMC_ARGS_QUERY_PMCARGS);

    if (pPmcArgs == NULL)
    {
        RETAILMSG(TRUE, (_T("OEMInitSecureClockStatus: Unable to locate PMCARGS\r\n")));
        return;
    }

    // TODO: For now, assume we lost the clock
    pPmcArgs->fDRMClockSet  = FALSE;

    // was the value somehow corrupted?
    if(pPmcArgs->fDRMClockSet != TRUE && pPmcArgs->fDRMClockSet != FALSE) {
        RETAILMSG(TRUE, (_T("OEMInitSecureClockStatus: ERROR -- DRM clock state corrupted\r\n")));
        pPmcArgs->fDRMClockSet  = FALSE;
    }

    DEBUGMSG(TRUE, (_T("OEMInitSecureClockStatus: DRM clock %s\r\n"), 
        pPmcArgs->fDRMClockSet ? _T("valid") : _T("invalid")));
}

//------------------------------------------------------------------------------

#endif // PLAT_PMC

⌨️ 快捷键说明

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