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

📄 xllp_pm_sleepcontext.c

📁 优龙pxa270平台试验程序
💻 C
📖 第 1 页 / 共 2 页
字号:
    // Must wait until after last time record.  Necessary although
    //   it slightly underreports execution time for context save.
    (*pSleepParam->pOsSpecificFlushFn)();


} // XllpPmSleepCLevelProcessing()



// Call after all other data are saved.  Will perform checksum at the end.

void XllpPmSleepCLevelSaveCksm (P_XLLP_PM_SLEEP_SAVE_DATA_T pSleepSaveArea)
{
    // (total number of 32-bit words stored, excluding only checksum))
    pSleepSaveArea->SleepAreaWordCount =
    (sizeof(XLLP_PM_SLEEP_SAVE_DATA_T)/4) // Checksum is done on 4-byte words
    - 1               // Don't include the checksum itself.
    // Add in optional extended checksummed word count.
    + pSleepSaveArea->extendedChecksumWordCount;

    pSleepSaveArea->AwakeAddr = XllpPmRestoreAfterSleep;

    XllpPmSaveAllRegLists (pSleepSaveArea);

    //
    // Internal memory banks are copied to SDRAM.
    //
    if (pSleepSaveArea->StoreAddrForIntlMem_0)
    {
        memcpy (pSleepSaveArea->StoreAddrForIntlMem_0, pSleepSaveArea->IntlMemVA_0, XLLP_IM_BANK_SIZE);
    }
    if (pSleepSaveArea->StoreAddrForIntlMem_1)
    {
        memcpy (pSleepSaveArea->StoreAddrForIntlMem_1, pSleepSaveArea->IntlMemVA_1, XLLP_IM_BANK_SIZE);
    }
    if (pSleepSaveArea->StoreAddrForIntlMem_2)
    {
        memcpy (pSleepSaveArea->StoreAddrForIntlMem_2, pSleepSaveArea->IntlMemVA_2, XLLP_IM_BANK_SIZE);
    }
    if (pSleepSaveArea->StoreAddrForIntlMem_3)
    {
        memcpy (pSleepSaveArea->StoreAddrForIntlMem_3, pSleepSaveArea->IntlMemVA_3, XLLP_IM_BANK_SIZE);
    }

    // Now, set the checksum to validate data at wakeup
    // Must be done after all data saved.
    pSleepSaveArea->checksum = XllpPmChecksumSleepDataVi
                               (&pSleepSaveArea->SleepAreaWordCount,
                                pSleepSaveArea->SleepAreaWordCount);

} // XllpPmSleepCLevelSave()


//
// Saves the values from all addresses in the list to the pointed-to storage area,
//  after applying the associated masks.
//
// Inputs:
//
void XllpPmSaveRegsInList ( P_XLLP_PM_ADDR_WITH_MASK_T  pRegList,
                            int                         count,
                            P_XLLP_VUINT32_T            pulStorage)
{
    while ( count--)
    {
        *pulStorage++ =  *(pRegList->regAddr) & pRegList->mask;
        pRegList++;
    }
} // XllpPmSaveRegsInList()


//
// Restores the values to all addresses in the list, from the the
//  pointed-to storage area.  It is assumed that the bit-validity
//  masks were applied before initial storage.
//
// Inputs:
//
void XllpPmRestoreRegsInList ( P_XLLP_PM_ADDR_WITH_MASK_T  pRegList,
                               int                         count,
                               P_XLLP_VUINT32_T            pulStorage)
{
    while ( count--)
    {
        *(pRegList->regAddr)  =  *pulStorage++ ;
        pRegList++;
    }

} // XllpPmSaveRegsInList()


void XllpPmSaveAllRegLists (P_XLLP_PM_SLEEP_SAVE_DATA_T pDataSaveArea)
{

//#if 0
// Exclude  for test
    // First, store registers from standard list
    XllpPmSaveRegsInList (  &XllpPmSleepStdRegList[0],
                            XLLP_PM_SLEEP_STD_REGLIST_CNT,
                            &pDataSaveArea->StandardRegListStore[0]);
//#endif

    // Then, if any, store registers from deep sleep  list
    #if XLLP_PM_SLEEP_DEEP_REGLIST_CNT
    XllpPmSaveRegsInList (  &XllpPmSleepDeepRegList[0],
                            sizeof (XllpPmSleepDeepRegList)   /XLLP_PM_ADDR_WITH_MASK_T,
                            /*XLLP_PM_SLEEP_DEEP_REGLIST_CNT,*/
                            &pDataSaveArea->DeepSleepRegListStore[0]);
    #endif //  XLLP_PM_SLEEP_DEEP_REGLIST_CNT

    // Then, if any, store registers from optional list
    XllpPmSaveRegsInList (  pDataSaveArea->pOptionalRegList,
                            pDataSaveArea->privateRegListCount,
                            pDataSaveArea->pPrivateRegListStorage);

    // Also call special coprocessor save function here.

    #ifdef USING_COPROCSUPPORT
//    XllpStoreWmxRegs()
// Current name in WinCE space:
    Xllp_Store_All_WMMX_Regs(&pDataSaveArea->IWMMXTRegs[0]);
    #endif  // def USING_COPROCSUPPORT

}  // XllpPmSaveAllRegLists()


void XllpPmRestoreAllRegLists (P_XLLP_PM_SLEEP_SAVE_DATA_T pDataSaveArea)
{

    // First, restore registers from standard list
    XllpPmRestoreRegsInList ( &XllpPmSleepStdRegList[0],
                              sizeof (XllpPmSleepStdRegList) /sizeof (XllpPmSleepStdRegList[0]),
                              /*XLLP_PM_SLEEP_STD_REGLIST_CNT,*/
                              &pDataSaveArea->StandardRegListStore[0]);

    // Then, if any, restore registers from deep sleep  list
    #if XLLP_PM_SLEEP_DEEP_REGLIST_CNT
    XllpPmRestoreRegsInList ( &XllpPmSleepDeepRegList[0],
                              sizeof (XllpPmSleepDeepRegList)   /XLLP_PM_ADDR_WITH_MASK_T,
                              /*XLLP_PM_SLEEP_DEEP_REGLIST_CNT,*/
                              &pDataSaveArea->DeepSleepRegListStore[0]);
    #endif //  XLLP_PM_SLEEP_DEEP_REGLIST_CNT

    // Then, if any, restore registers from optional list
    XllpPmRestoreRegsInList ( pDataSaveArea->pOptionalRegList,
                              pDataSaveArea->privateRegListCount,
                              pDataSaveArea->pPrivateRegListStorage);

    // Also call special coprocessor restore function here.
    #ifdef USING_COPROCSUPPORT
//    XllpRestoreWmxRegs()
// Current name in WinCE space:
    Xllp_Restore_All_WMMX_Regs(&pDataSaveArea->IWMMXTRegs[0]);
    #endif //def USING_COPROCSUPPORT

}   // XllpPmRestoreAllRegLists()

void XllpPmRestoreIM(P_XLLP_PM_SLEEP_SAVE_DATA_T pSleepSaveArea)
{

    P_XLLP_CLKMGR_T pClkRegs    = (P_XLLP_CLKMGR_T) XLLP_U_V_CLKMGR_BASE;
    // Enable IM clock
    pClkRegs->cken |= XLLP_CLKEN_MEMCLOCK;

    // Restore IM control
    *pSleepSaveArea->impmcr_va = pSleepSaveArea->impmcr;

    //
    // Internal memory banks are copied from SDRAM.
    //
    if (pSleepSaveArea->StoreAddrForIntlMem_0)
    {
        memcpy (pSleepSaveArea->IntlMemVA_0, pSleepSaveArea->StoreAddrForIntlMem_0, XLLP_IM_BANK_SIZE);
    }
    if (pSleepSaveArea->StoreAddrForIntlMem_1)
    {
        memcpy (pSleepSaveArea->IntlMemVA_1, pSleepSaveArea->StoreAddrForIntlMem_1, XLLP_IM_BANK_SIZE);
    }
    if (pSleepSaveArea->StoreAddrForIntlMem_2)
    {
        memcpy (pSleepSaveArea->IntlMemVA_2, pSleepSaveArea->StoreAddrForIntlMem_2, XLLP_IM_BANK_SIZE);
    }
    if (pSleepSaveArea->StoreAddrForIntlMem_3)
    {
        memcpy (pSleepSaveArea->IntlMemVA_3, pSleepSaveArea->StoreAddrForIntlMem_3, XLLP_IM_BANK_SIZE);
    }

} // XllpPmRestoreIM ()



// XllpPmCalculatePKWR():
//  Takes a standard dimensioned GPIO pin list of pins which should
//    be used to trigger wakeups by means of the PKWR.
//  Output parameter: pointer to a variable to accept the calculated
//    value for PKWR, based on that list.
// Returns 0 for list with all valid GPIOs
// Returns nonzero if any GPIOs not supported in PKWR.

XLLP_UINT32_T XllpPmCalculatePKWR (XLLP_UINT32_T aPkwrGpioPinArray[],
                        XLLP_UINT32_T* pPkwrVal)
{
    unsigned int i;
    XLLP_UINT32_T status = 0;
    XLLP_UINT32_T pkwrValTmp = 0;

    // All GPIOs supported in PKWR

    for (i=1 ;i<aPkwrGpioPinArray[0]+1 ;i++ )
    {
        switch (aPkwrGpioPinArray[i]) 
        {
            case  13:
                pkwrValTmp |= (1u <<  0);
                break;
            case  16:
                pkwrValTmp |= (1u <<  1);
                break;
            case  17:
                pkwrValTmp |= (1u <<  2);
                break;
            case  34:
                pkwrValTmp |= (1u <<  3);
                break;
            case  36:
                pkwrValTmp |= (1u <<  4);
                break;
            case  37:
                pkwrValTmp |= (1u <<  5);
                break;
            case  38:
                pkwrValTmp |= (1u <<  6);
                break;
            case  39:
                pkwrValTmp |= (1u <<  7);
                break;
            case  90:
                pkwrValTmp |= (1u <<  8);
                break;
            case  91:
                pkwrValTmp |= (1u <<  9);
                break;
            case  93:
                pkwrValTmp |= (1u << 10);
                break;
            case  94:
                pkwrValTmp |= (1u << 11);
                break;
            case  95:
                pkwrValTmp |= (1u << 12);
                break;
            case  96:
                pkwrValTmp |= (1u << 13);
                break;
            case  97:
                pkwrValTmp |= (1u << 14);
                break;
            case  98:
                pkwrValTmp |= (1u << 15);
                break;
            case  99:
                pkwrValTmp |= (1u << 16);
                break;
            case 100:
                pkwrValTmp |= (1u << 17);
                break;
            case 101:
                pkwrValTmp |= (1u << 18);
                break;
            case 102:
                pkwrValTmp |= (1u << 19);
                break;
            default:
                status++;

        } // switch (aPkwrGpioPinArray[i]) 
    } // for (i=1 ;i<aPkwrGpioPinArray[0]+1 ;i++ )

    *pPkwrVal = pkwrValTmp;
    return(status);

} // XllpPmCalculatePKWR()

⌨️ 快捷键说明

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