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

📄 init.c

📁 Freescale ARM9系列CPU MX27的WINCE 5.0下的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.
//-----------------------------------------------------------------------------
//
// Copyright (C) 2004-2006,2007 Freescale Semiconductor, Inc. All Rights Reserved.
// THIS SOURCE CODE, AND ITS USE AND DISTRIBUTION, IS SUBJECT TO THE TERMS
// AND CONDITIONS OF THE APPLICABLE LICENSE AGREEMENT
//
//-----------------------------------------------------------------------------

//-----------------------------------------------------------------------------
//
//  File:  init.c
//
//  MX27 ADS board initialization code.
//
//-----------------------------------------------------------------------------
#include <bsp.h>
#include <pehdr.h>
#include <Romldr.h>

//-----------------------------------------------------------------------------
// Types
#ifndef BSP_NO_TRUST
typedef BOOL (* OEMLoadInit_t)(LPWSTR lpszName);
typedef DWORD (* OEMLoadModule_t)(LPBYTE lpData, DWORD cbData);
#endif // BSP_NO_TRUST

//-----------------------------------------------------------------------------
// External Functions

// External Functions
extern BOOL OALDisplaySplashScreen(void);
extern wdogReset_c WdogGetReset(void);

#ifndef BSP_NO_TRUST
extern BOOL InitPubKey(const BYTE *KeyBlob, DWORD cbKeyBlob);
extern BOOL OEMCertifyModuleInit(LPWSTR lpModuleName);
extern DWORD OEMCertifyModule(LPBYTE lpData, DWORD cbData);
#endif // BSP_NO_TRUST
extern UINT32 OALTimerGetClkFreq(void);
extern UINT32 OALTimerGetClkPrescalar(void);
extern BOOL OALPmicInit(UINT32 voltCodeNormal, UINT32 voltCodeStandby);

//-----------------------------------------------------------------------------
// External Variables


#ifndef BSP_NO_TRUST
extern OEMLoadInit_t pOEMLoadInit;
extern OEMLoadModule_t pOEMLoadModule;

/*
 * This is the public used to verify the signature of trusted applications.
 */
static const unsigned char g_bSignPublicKeyBlob[] = {
    0x06,0x02,0x00,0x00,0x00,0x24,0x00,0x00,0x52,0x53,0x41,0x31,0x00,0x02,
    0x00,0x00,0x01,0x00,0x01,0x00,0x53,0x93,0xe8,0x12,0x13,0x63,0x44,0x9e,
    0x07,0xd7,0xb7,0xa3,0x20,0x2c,0x2f,0xe7,0x95,0x23,0xba,0xec,0x79,0xa9,
    0x37,0xd3,0x09,0xd7,0x53,0x47,0x27,0x76,0x10,0x1d,0xbd,0x22,0x61,0xd0,
    0x82,0x91,0x26,0xf6,0x1f,0x94,0x74,0x24,0xbc,0xe6,0xd1,0x07,0x86,0x2f,
    0xad,0x60,0x50,0x7e,0x55,0xb5,0x58,0x46,0xcd,0xe9,0xf5,0x89,0xb1,0xe5
};
#endif // BSP_NO_TRUST

//-----------------------------------------------------------------------------
// OAL global Variables
BOOL coldBoot = FALSE;

// 
extern void (*lpNKHaltSystem)(void);

//-----------------------------------------------------------------------------
//
// Function: OEMHaltSystem
//
// Function turns on leds to indicate error condition before system halt.
//
// Parameters:
//
// Returns:
//      
//
//-----------------------------------------------------------------------------
void OEMHaltSystem(void)
{
    CSP_PBC_REGS *pPBC;

    // On both on board leds
    // TBD
    pPBC = (PCSP_PBC_REGS)OALPAtoVA((UINT32)BSP_BASE_REG_PA_PBC_BASE, FALSE);
   // OUTREG16(&pPBC->BCTRL1_SET, CSP_BITFMASK(PBC_BCTRL1_SET_LED0));
   // OUTREG16(&pPBC->BCTRL1_SET, CSP_BITFMASK(PBC_BCTRL1_SET_LED1));
}

//------------------------------------------------------------------------------
//
//  Function:  OEMInit
//
//  This is Windows CE OAL initialization function. It is called from kernel
//  after basic initialization is made.
//
void OEMInit()
{

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

    // Initialize system halt handler.
    lpNKHaltSystem = OEMHaltSystem;

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

    // Initilize cache globals
    OALCacheGlobalsInit();

   
#ifndef BSP_NO_TRUST
    // Set the module signature verification hooks.
    pOEMLoadInit = OEMCertifyModuleInit;
    pOEMLoadModule = OEMCertifyModule;

    // Initialize the signature verification public key.
    InitPubKey(g_bSignPublicKeyBlob, sizeof(g_bSignPublicKeyBlob));
#endif // BSP_NO_TRUST

    // Clean RAMFree Signature for Cold Boot
    //
    ResetType = WdogGetReset();
    if(ResetType == wdogResetPowerOn)
    {
        // Power On Reset
        lpWriteDebugStringFunc(TEXT("Power on Reset - Clear RAM\r\n"));
        // NKForceCleanBoot() is required for WinCE .Net 4.2 and later.
        // deprecated: memset((void*)pTOC->ulRAMFree, 0, sizeof(DWORD)*3);
        NKForceCleanBoot();
        coldBoot = TRUE;
    }
	
    // Initialize interrupts
    if (!OALIntrInit()) {
        OALMSG(OAL_ERROR, (
            L"ERROR: OEMInit: failed to initialize interrupts\r\n"
        ));
    }

    // Display splash screen
    OALDisplaySplashScreen();


    // Initialize system clock
    OALTimerInit(RESCHED_PERIOD, OEM_TICKS_1MS, OEM_TICKS_MARGIN);

    // Initialize the PMIC interface
    OALPmicInit(BSP_PMIC_NORMAL_VOLT, BSP_PMIC_STANDBY_VOLT);

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

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

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

⌨️ 快捷键说明

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