init.c
来自「该BSP是基于PXA270+WINCE的BSP」· C语言 代码 · 共 214 行
C
214 行
//
// 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
//
// Intel Mainstone II board initialization code.
//
#include <bsp.h>
#include <dbgserial.h>
// trace collection support if xdbbrowser is compiled into the image
//
#ifdef USING_XSCALEBROWSER
#include <xdbioctl.h>
#endif
// Global FixUp variables
DWORD dwOEMPlatform = OAL_IOCTL_PLATFORM_WINCE;
// External function prototypes.
//
extern TURN_ON_BTB(void);
extern VOID BSPPowerOffInit();
// External global variables.
//
extern DWORD dwNKDrWatsonSize;
extern DWORD CEProcessorType; // From nkarm.h in the private tree
// 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
//------------------------------------------------------------------------------
//
// 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);
//------------------------------------------------
OALMSG(OAL_FUNC, (L"+OEMInit\r\n"));
// Update kernel variables
if (dwOEMPlatform != OAL_IOCTL_PLATFORM_WINCE)
{
g_oalIoCtlPlatform = dwOEMPlatform;
}
// 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;
}
}
}
// Expose the MainstoneII processor type.
//the 'true' processory type is PROCESSOR_ARM920 as Xscale is based on ARM920 core
//but most of the ISVs expect this value to be PROCESSOR_STRONGARM and their apps fail
//to install if it is otherwise.
CEProcessorType = PROCESSOR_STRONGARM;
//-----------------------------------
//OEMInitDebugSerial();
//-----------------------------------
// 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"
));
}
// Initialize system clock.
//
OALTimerInit(1, OEM_TICKS_1MS, OEM_TICK_COUNT_MARGIN);
// Initialize the KITL connection if required.
//
//------------------------------------------------
OALKitlStart();
//------------------------------------------------
//------------------------------------------------
// 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"));
#ifdef BSP_POCKETPC
OALMSG(1, (L"OEMInit - WPC\r\n"));
#endif
#ifdef BSP_SMARTPHONE
OALMSG(1, (L"OEMInit - SMARTFON\r\n"));
#endif
#ifdef PROJECT_ULDR
OALMSG(1, (L"OEMInit - ULDR\r\n"));
#endif
}
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);
}
}
//------------------------------------------------------------------------------
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?