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

📄 init.c

📁 Windows CE 6.0 BSP for VOIPAC Board (PXA270) Version 2b.
💻 C
字号:
//
// Copyright (c) Microsoft Corporation.  All rights reserved.
//
//
// Use of this sample source code is subject to the terms of the Microsoft
// license agreement under which you licensed this sample source code. If
// you did not accept the terms of the license agreement, you are not
// authorized to use this sample source code. For the terms of the license,
// please see the license agreement between you and Microsoft or, if applicable,
// see the LICENSE.RTF on your install media or the root of your tools installation.
// THE SAMPLE SOURCE CODE IS PROVIDED "AS IS", WITH NO WARRANTIES.
//
//------------------------------------------------------------------------------
//
//  File:  init.c
//
//  Intel Mainstone II board initialization code.
//
#include <bsp.h>
#include <profiler.h>
#include <dbgserial.h>

// trace collection support if xdbbrowser is compiled into the image
//
#ifdef USING_XSCALEBROWSER
#include <xdbioctl.h>
#endif

// External function prototypes.
//
extern TURN_ON_BTB(void);
extern VOID BSPPowerOffInit();

// Cache-related variables.
//
#define ZBANK_BASE_C_VIRTUAL        0x9A500000
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;

// Common timer routine constants.
//
const DWORD OEMTimerFreq     = OEM_CLOCK_FREQ;
const int OEMMinTickDistance = (OEM_CLOCK_FREQ / 20000);    // 50 us

#if defined(USING_COPROCSUPPORT) || defined(USING_XSCALEBROWSER)
// init function to set up coproc callbacks
extern void OALInitCoProc();
#endif

#ifdef USING_XSCALEBROWSER
// Space allocation for xdbbrowser trace collector (space for 20 captures)
static BYTE xdbTraceBuffer[20][XDBTRACEBUFFERBLOCKSIZE];
#endif


/*
    Global:  dwOEMDrWatsonSize

    Global variable which specify DrWatson buffer size. It can be fixed
    in config.bib via FIXUPVAR.
 */
#define DR_WATSON_SIZE_NOT_FIXEDUP (-1)
DWORD dwOEMDrWatsonSize = DR_WATSON_SIZE_NOT_FIXEDUP;


BOOL OEMIsRom (DWORD dwShiftedPhysAddr);

//------------------------------------------------------------------------------
//
//  Function:  OEMInit
//
//  This is Windows CE OAL initialization function. It is called from kernel
//  after basic initialization is made.
//
void OEMInit()
{
//    volatile MAINSTONEII_BLR_REGS *pBLRegs = (volatile MAINSTONEII_BLR_REGS *) OALPAtoVA(MAINSTONEII_BASE_REG_PA_FPGA, FALSE);    

    // Set up the debug zones according to the fix-up variable initialOALLogZones
    OALLogSetZones(initialOALLogZones);
//    OALLogSetZones((UINT32)-1);

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

    // Expose the Mainstone processor type.
    //
    CEProcessorType = PROCESSOR_STRONGARM;

    // profiling support
    //
    g_pOemGlobal->pfnProfileTimerEnable  = OEMProfileTimerEnable;
    g_pOemGlobal->pfnProfileTimerDisable = OEMProfileTimerDisable;
    
    // ROM breakpoint support
    // 
    g_pOemGlobal->pfnIsRom = OEMIsRom;

    // Check clean boot flag in BSP Args area
    //
    {
      // This is the global shared Args flag
      BOOL *bCleanBootFlag = (BOOL*) OALArgsQuery(BSP_ARGS_QUERY_CLEANBOOT);

      if(*bCleanBootFlag)
      {
        OALMSG(1, (TEXT("OEM: Force clean boot.\r\n")));

        // Clear the flag so that we don't get here in the next boot unless it is set again.
        *bCleanBootFlag = FALSE;

        // Tell filesys.exe that we want a clean boot.
        NKForceCleanBoot();

        // Also set the hive and storage clean flags if not already set
        {
          BOOL *bHiveCleanFlag  = (BOOL*) OALArgsQuery(BSP_ARGS_QUERY_HIVECLEAN);
          BOOL *bFormatPartFlag = (BOOL*) OALArgsQuery(BSP_ARGS_QUERY_FORMATPART);

          *bHiveCleanFlag  = TRUE;
          *bFormatPartFlag = TRUE;
        }
      }
    }


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

    // Set memory size for DrWatson kernel support.
    //
    dwNKDrWatsonSize = 0;
    if (dwOEMDrWatsonSize != DR_WATSON_SIZE_NOT_FIXEDUP) {
        dwNKDrWatsonSize = dwOEMDrWatsonSize;
    }

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

    // Initialize interrupts.
    //
    if (!OALIntrInit())
    {
        OALMSG(OAL_ERROR, (
            L"ERROR: OEMInit: failed to initialize interrupts.\r\n"
        ));
    }

    // Initialize system clock.
    //
    OALTimerInit(1, OEM_TICKS_1MS, OEM_TICK_COUNT_MARGIN);

    // Initialize the KITL connection if required.
    //
    KITLIoctl (IOCTL_KITL_STARTUP, NULL, 0, NULL, 0, NULL);

    // Switch on the audio amplifier.
    //
//    pBLRegs->misc_wr2 &= ~(1 << 2);

    // Initialize suspend/resume function
    BSPPowerOffInit();

#if defined(USING_COPROCSUPPORT) || defined(USING_XSCALEBROWSER)
    // init coproc callbacks
    // 
    OALInitCoProc();
#endif

#ifdef USING_XSCALEBROWSER 
    // Initialize the trace module with trace buffer size
    //
    XSCBwrInitExecutionTrace(xdbTraceBuffer, sizeof(xdbTraceBuffer));
#endif
    
    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;

    // Check and initialize the BSP Args area
    //
    OALArgsInit((BSP_ARGS *) IMAGE_SHARE_ARGS_UA_START);

    pDbgSerPhysAddr = (UINT32*) OALArgsQuery(BSP_ARGS_QUERY_DBGSERIAL);
    if (pDbgSerPhysAddr)
    {
        InitDebugSerial(*pDbgSerPhysAddr, FALSE);
    }
}

//------------------------------------------------------------------------------
//
//  Function Name:  OEMIsROM
//
//  Description:    Validates ROM address.
//                  Needed when image is running out of ROM and you want to support ROM breakpoints
//------------------------------------------------------------------------------
BOOL OEMIsRom (DWORD dwShiftedPhysAddr)
{
    DWORD dwPhysAddr;

    dwPhysAddr = dwShiftedPhysAddr << 8;

    if ((dwPhysAddr >= MAINSTONEII_BASE_PA_BOOT_FLASH) && (dwPhysAddr < (MAINSTONEII_BASE_PA_BOOT_FLASH + MAINSTONEII_SIZE_BOOT_FLASH )))
    {
        return(TRUE);
    }

    return FALSE;
}

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

⌨️ 快捷键说明

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