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

📄 init.c

📁 Lido PXA270平台开发板的最新BSP,包括源代码
💻 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:  init.c
//
//  Emdoor XSBASE270_G board initialization code.
//
#include <bsp.h>

// External function prototypes.
//
extern TURN_ON_BTB(void);
extern void InitDebugSerial(UINT32 DbgSerPhysAddr);

// External global variables.
//
extern DWORD dwNKDrWatsonSize;
extern DWORD CEProcessorType;	// From nkarm.h in the private tree

// Cache-related variables.
//
// TODO.
#define ZBANK_BASE_C_VIRTUAL        0x96500000
DWORD CacheBufferFlag;  // NOTE: this needn't be a const variable and OEMCacheRangeFlush won't be called before KernelRe locate.
const LPVOID gpvCacheFlushBaseMemoryAddress = (LPVOID)ZBANK_BASE_C_VIRTUAL;
extern void OEMExecuteAfterAllResets(void);
// Common timer routine constants.
//
const DWORD OEMTimerFreq     = OEM_CLOCK_FREQ;
const int OEMMinTickDistance = (OEM_CLOCK_FREQ / 20000);    // 50 us

//extern BOOL OEMSetRealTime(LPSYSTEMTIME pTime); 
extern void RTC4513_Init(void);
extern void RTC4513GetRealTime(LPSYSTEMTIME lpst);
extern void RTC4513SetRealTime(LPSYSTEMTIME lpst);
//------------------------------------------------------------------------------
//
//  Function:  OEMInit
//
//  This is Windows CE OAL initialization function. It is called from kernel
//  after basic initialization is made.
//
void OEMInit()
{
    volatile XSBASE270_G_CPLD_REGS *pCPLDRegs = (volatile XSBASE270_G_CPLD_REGS *) OALPAtoVA(XSBASE270_G_BASE_REG_PA_CPLD, FALSE);

	SYSTEMTIME pTime;
    OALMSG(OAL_FUNC, (L"+OEMInit\r\n"));

    //
    // Expose the XSBASE270_G processor type.
    CEProcessorType = PROCESSOR_ARM920;

    // Enable the branch-target buffer.
    //
    TURN_ON_BTB();

    // Set memory size for DrWatson kernel support.
    //
    dwNKDrWatsonSize = 128 * 1024;

    // Intialize optional kernel functions.
    //
    pOEMIsProcessorFeaturePresent = OALIsProcessorFeaturePresent;

    // Initialize interrupts.
    //
    if (!OALIntrInit())
    {
        OALMSG(OAL_ERROR, (
            L"ERROR: OEMInit: failed to initialize interrupts.\r\n"
        ));
    }
	RTC4513_Init();
	RTC4513GetRealTime(&pTime);
	
	if ((pTime.wYear < 2004) ||
        (pTime.wMonth < 1) ||
        (pTime.wMonth > 12) ||
        (pTime.wDay < 1) ||
        (pTime.wDay > 31) ||
        (pTime.wHour > 23) ||
        (pTime.wMinute > 59) ||
        (pTime.wSecond > 59) ||
        (pTime.wMilliseconds > 999)) {
		
		pTime.wYear = 2004;
		pTime.wMonth = 1;
		pTime.wDayOfWeek = 1;
		pTime.wDay = 1;
		pTime.wHour = 23;
		pTime.wMinute = 59;
		pTime.wSecond = 00;
		pTime.wMilliseconds = 0;          
		
		
        RTC4513SetRealTime(&pTime);
    }
//	OEMSetRealTime(&pTime);
    // Initialize system clock.
    //
    OALTimerInit(1, OEM_TICKS_1MS, OEM_TICK_COUNT_MARGIN);

    // Initialize the KITL connection if required.
    //
    OALKitlStart();

    // LCD and Audio power ON
    pCPLDRegs->BCR1 |= BCR_RED_LED | BCR_AUDIO;	
    // Speaker ON
    pCPLDRegs->BCR1 &= ~(BCR_SPRK | BCR_GREEN_LED);

    // DAC power ON
    pCPLDRegs->BCR2 |= BCR2_DAC_ON;

    OALMSG(OAL_FUNC, (L"-OEMInit\r\n"));
}


VOID OALStall(UINT32 microSec)
{
    volatile PBULVERDE_OST_REG pOSTRegs = NULL;

    pOSTRegs = (PBULVERDE_OST_REG)OALPAtoVA(BULVERDE_BASE_REG_PA_OST, FALSE);

    XllpOstDelayMicroSeconds(pOSTRegs, microSec);
}


VOID OEMInitDebugSerial(void)
{
    UINT32 *pDbgSerPhysAddr = (UINT32*) OALArgsQuery(BSP_ARGS_QUERY_DBGSERIAL);

    if (pDbgSerPhysAddr)
    {
        InitDebugSerial(*pDbgSerPhysAddr);
    }
}

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


void OEMExecuteAfterAllResets(void)
{

    volatile BULVERDE_MEMCTRL_REG *v_pMEMC = (volatile BULVERDE_MEMCTRL_REG *) OALPAtoVA(BULVERDE_BASE_REG_PA_MEMC, FALSE);

    //  Configure the Arbiter Control Register so that LCD has higher priority than the DMA and GASKET.
    //  Park at the GASKET.  LCD has weight 15, DMA has weight 1, and GASKET has weight 2.
#ifdef BSP_C0_BULVERDE
    v_pMEMC->arb_cntl = 0x01000234; //Park fixed
#else
    v_pMEMC->arb_cntl = 0x000002F1; //no park,  Gasket 1 < LCD weight 2 < DMA 15
#endif

} // OEMExecuteAfterAllResets()

⌨️ 快捷键说明

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