📄 init.c
字号:
//
// Copyright (c) Special Computing. All rights reserved.
// Copyright (c) Microsoft Corporation. All rights reserved.
//
//------------------------------------------------------------------------------
//
// File: init.c
//
#include <bsp.h>
#include <kerneli2c.h>
#include <romxip.h>
extern BOOL OALSetMemoryAttributes(
LPVOID pVirtAddr, // Virtual address of region
LPVOID pPhysAddrShifted, // PhysicalAddress >> 8 (to support up to 40 bit address)
DWORD cbSize, // Size of the region
DWORD dwAttributes // attributes to be set
);
// Function prototype
DWORD OEMEnumExtensionDRAM(PMEMORY_SECTION pMemSections, DWORD cMemSections);
//------------------------------------------------------------------------------
//
// Global: g_oalRtcResetTime
//
// RTC init time after a RTC reset has occured.
//
SYSTEMTIME g_oalRtcResetTime = {2005, 1, 1, 31, 12, 0, 0, 0};
/*
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;
//------------------------------------------------------------------------------
//
// Function: OEMInit
//
// This is Windows CE OAL initialization function. It is called from kernel
// after basic initialization is made.
//
void OEMInit()
{
// OMAP2420_PRCM_REGS *pPRCMReg;
OALMSG(1, (L"+OEMInit\r\n"));
OALMSG(1, (L"DEBUG LED OFF\r\n"));
OALLED(0,DEBUG_LED_OFF);
OALStall(200000);
OALMSG(1, (L"DEBUG LED ON\r\n"));
OALLED(0,DEBUG_LED_ON);
OALStall(200000);
OALMSG(1, (L"Done\r\n"));
// Set memory size for DrWatson kernel support
dwNKDrWatsonSize = 0;
if (dwOEMDrWatsonSize != DR_WATSON_SIZE_NOT_FIXEDUP) {
dwNKDrWatsonSize = dwOEMDrWatsonSize;
}
//----------------------------------------------------------------------
// Initialize OAL log zones
//----------------------------------------------------------------------
OALLogSetZones(
(1<<OAL_LOG_VERBOSE) |
//(1<<OAL_LOG_INTR) |
(1<<OAL_LOG_IOCTL) |
(1<<OAL_LOG_TIMER) |
(1<<OAL_LOG_INFO) |
(1<<OAL_LOG_ERROR) |
(1<<OAL_LOG_WARN) |
//(1<<OAL_LOG_ETHER) |
//(1<<OAL_LOG_KITL) |
(1<<OAL_LOG_FUNC) |
(1<<OAL_LOG_RTC) |
//(1<<OAL_LOG_CACHE) |
0);
// 0xffff);
pfnOEMSetMemoryAttributes = OALSetMemoryAttributes;
//----------------------------------------------------------------------
// Initialize cache globals
//----------------------------------------------------------------------
OALCacheGlobalsInit();
// Initialize interrupt
if (!OALIntrInit()) {
OALMSG(OAL_ERROR, (
L"ERROR: OEMInit: failed to initialize interrupts\r\n"
));
goto cleanUp;
}
OALMSG(OAL_FUNC, (L"Intr Init done...\r\n"));
// Initialize system clock
if (!OALTimerInit(1, 0, 0)) {
OALMSG(OAL_ERROR, (
L"ERROR: OEMInit: Failed to initialize system clock\r\n"
));
goto cleanUp;
}
OALMSG(OAL_FUNC, (L"Timer Init done...\r\n"));
//----------------------------------------------------------------------
// Initialize the PRCM Clock values
//----------------------------------------------------------------------
//By default, XLDR turns all clocks on in hwinit.s
//Eventually, we will want to turn them all off here and have drivers
//manage clocks if they need them
//For now, we'll only turn off the clocks we know are managed by thier
//respective drivers
//pPRCMReg = (OMAP2420_PRCM_REGS *) OALPAtoUA(OMAP2420_PRCM_REGS_PA);
//OALMSG(1, (L"OEMInit: DISABLING CLOCKS FOR FAC,HDQ\r\n"));
////FAC
//CLRREG32(&pPRCMReg->ulCM_FCLKEN1_CORE, PRCM_FCLKEN1_CORE_EN_FAC);
//CLRREG32(&pPRCMReg->ulCM_ICLKEN1_CORE, PRCM_ICLKEN1_CORE_EN_FAC);
////HDQ
//CLRREG32(&pPRCMReg->ulCM_FCLKEN1_CORE, PRCM_FCLKEN1_CORE_EN_HDQ);
//CLRREG32(&pPRCMReg->ulCM_ICLKEN1_CORE, PRCM_ICLKEN1_CORE_EN_HDQ);
// Initialize Platform I2C
KERNELI2C_OEMInit();
// Initialize the KITL
KITLIoctl(IOCTL_KITL_STARTUP, NULL, 0, NULL, 0, NULL);
// Pointer to function that extends memory
//OALMSG(OAL_FUNC, (L"MainMemoryEndAddress = 0x%04X\r\n", g_pOemGlobal->dwMainMemoryEndAddress));
//g_pOemGlobal->pfnEnumExtensionDRAM = OEMEnumExtensionDRAM;
cleanUp:
OALMSG(OAL_FUNC, (L"-OEMInit\r\n"));
}
//------------------------------------------------------------------------------
//
// Function: OEMEnumExtensionDRAM
//
//
DWORD OEMEnumExtensionDRAM(
PMEMORY_SECTION pMemSections,
DWORD cMemSections
)
{
DWORD index = 0;
//pMemSections[index].dwFlags = 0;
//pMemSections[index].dwStart = 0x86000000;
//pMemSections[index].dwLen = 0x01B30000;
//OALMSG(OAL_FUNC, (L"Section map 0x%X for 0x%X\r\n", pMemSections[index].dwStart, pMemSections[index].dwLen));
//index++;
//ASSERT(index<=cMemSections);
return index;
}
VOID OALKitlPowerOn(void)
{
BOOL PowerState = 1;
KITLIoctl (IOCTL_KITL_POWER_CALL, &PowerState, sizeof(PowerState), NULL, 0, NULL);
}
VOID OALKitlPowerOff(void)
{
BOOL PowerState = 0;
KITLIoctl (IOCTL_KITL_POWER_CALL, &PowerState, sizeof(PowerState), NULL, 0, NULL);
}
//------------------------------------------------------------------------------
//
// Function: OALGetTickCount
//
// This function is called by some KITL libraries to obtain relative time
// since device boot. It is mostly used to implement timeout in network
// protocol.
//
UINT32 OALGetTickCount()
{
return CurMSec;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -