📄 bl_main.c
字号:
{
g_eboot.type = DOWNLOAD_TYPE_FLASH;
}
else
{
g_eboot.type = DOWNLOAD_TYPE_RAM;
}
rc = TRUE;
cleanUp:
if (!rc)
{
SpinForever();
}
OALMSGS(OAL_FUNC, (L"-OEMMultiBinNotify\r\n"));
}
//------------------------------------------------------------------------------
//
// OEMReportError
//
// This function is called for error report
//
BOOL OEMReportError(DWORD dwReason, DWORD dwReserved)
{
SpinForever();
return FALSE;
}
//------------------------------------------------------------------------------
//
// OEMPlatformInit
//
// This function provide platform initialization functions.
//
BOOL OEMPlatformInit(void)
{
// Initialize callback pointer
g_pOEMMultiBINNotify = OEMMultiBinNotify;
g_pOEMReportError = OEMReportError;
return TRUE;
}
//------------------------------------------------------------------------------
//
// OEMShowProgress
//
// This function is called during the download process to visualise
// download progress.
//
void OEMShowProgress (DWORD dwPacketNum)
{
SetLEDValue((UCHAR)(dwPacketNum >> 8));
}
//------------------------------------------------------------------------------
//
// OEMPreDownload
//
// This function is called before downloading an image.
//
DWORD OEMPreDownload(void)
{
BOOL gdcfg;
UINT8 *p8;
int idx;
ULONG rc = BL_ERROR;
__security_init_cookie();
// Get data for serial port speed
BLInitBootCfg();
gdcfg = getbldata();
OEMDebugInit();
sport_update_rate(g_bootCfg.baudRate);
OALMSG(OAL_INFO, (
L"Microsoft Windows CE EBOOT %d.%d for NXP LPC32XX "
L"Built %S at %S\r\n",
EBOOT_VERSION_MAJOR, EBOOT_VERSION_MINOR, __DATE__, __TIME__
));
// Read saved configration and check for validity
if (gdcfg == FALSE)
{
BLWriteBootCfg(&g_bootCfg);
OALLog(L"WARN: Boot config wasn't found, using defaults\r\n");
}
else
{
OALLog(L"INFO: Boot configuration found\r\n");
}
// Get board configuration
p8 = (UINT8 *) &phyhwdesc;
for (idx = 0; idx < sizeof(phyhwdesc); idx++)
{
*p8 = lpc3250_sspread(PHY3250_SEEPROM_CFGOFS + idx);
p8++;
}
if (phyhwdesc.fieldvval != PHY_HW_VER_VAL)
{
OALLog(L"INFO: Board configuration not found, using defaults\r\n");
OALLog(L"INFO: 0x%x\r\n", phyhwdesc.dramcfg);
OALLog(L"INFO: 0x%x\r\n", phyhwdesc.syscfg);
OALLog(L"INFO: 0x%x\r\n", phyhwdesc.fieldvval);
/* Set some defaults */
phyhwdesc.dramcfg = (PHYHW_DRAM_TYPE_LPSDRAM |
PHYHW_DRAM_SIZE_64M);
phyhwdesc.syscfg = PHYHW_SDIO_POP;
phyhwdesc.fieldvval = PHY_HW_VER_VAL;
/* Default MAC address in index order of 0:1:2:3:4:5 */
phyhwdesc.mac [0] = 0x00;
phyhwdesc.mac [1] = 0x01;
phyhwdesc.mac [2] = 0x90;
phyhwdesc.mac [3] = 0x00;
phyhwdesc.mac [4] = 0xC0;
phyhwdesc.mac [5] = 0x81;
phyhwdesc.mac [6] = 0x00;
phyhwdesc.mac [7] = 0x00;
}
cleanboot = FALSE;
flashburnflag = FALSE;
// Initialize FLASH
flashgood = nand_init(&savedgeom);
// Call configuration menu
BLMenu();
// Image download depends on protocol
g_eboot.bootDeviceType = OALKitlDeviceType( &g_bootCfg.bootDevLoc, g_bootDevices );
switch (g_eboot.bootDeviceType)
{
case OAL_KITL_TYPE_ETH:
rc = BLEthDownload(&g_bootCfg, g_bootDevices);
break;
case OAL_KITL_TYPE_FLASH:
if (g_bootCfg.bootDevLoc.LogicalLoc == SD_BASE)
{
rc = BLSDMMCDownload(&g_bootCfg, g_bootDevices);
}
else
{
rc = BLFLASHDownload(&g_bootCfg, g_bootDevices);
}
break;
default:
OALLog(L"WARN: Unknown boot device type.\r\n");
SpinForever();
}
return rc;
}
//------------------------------------------------------------------------------
//
// OEMLaunch
//
// This function is the last one called by the boot framework and it is
// responsible for to launching the image.
//
VOID OEMLaunch(ULONG start, ULONG size, ULONG launch, const ROMHDR *pRomHeader)
{
BSP_ARGS *pArgs = OALPAtoCA(IMAGE_SHARE_ARGS_PA);
OALMSG(OAL_FUNC, (L"+OEMLaunch(0x%08x, 0x%08x, 0x%08x, 0x%08x - %d/%d)\r\n", start, size,launch, pRomHeader, g_eboot.bootDeviceType, g_eboot.type));
// Initialize shared ARGS structure
memset(pArgs, 0, IMAGE_SHARE_ARGS_SIZE);
pArgs->header.signature = OAL_ARGS_SIGNATURE;
pArgs->header.oalVersion = OAL_ARGS_VERSION;
pArgs->header.bspVersion = BSP_ARGS_VERSION;
pArgs->kitl.flags = g_bootCfg.kitlFlags;
pArgs->kitl.devLoc = g_bootCfg.kitlDevLoc;
pArgs->kitl.ipAddress = g_bootCfg.ipAddress;
pArgs->kitl.ipMask = g_bootCfg.ipMask;
pArgs->kitl.ipRoute = g_bootCfg.ipRoute;
pArgs->phyhwdesc = phyhwdesc;
pArgs->bCleanBootFlag = cleanboot;
// Save MAC address
pArgs->kitl.mac [0] = (phyhwdesc.mac[0] | (phyhwdesc.mac[1] << 8));
pArgs->kitl.mac [1] = (phyhwdesc.mac[2] | (phyhwdesc.mac[3] << 8));
pArgs->kitl.mac [2] = (phyhwdesc.mac[4] | (phyhwdesc.mac[5] << 8));
// Depending on protocol there can be some action required
switch (g_eboot.bootDeviceType)
{
case OAL_KITL_TYPE_ETH:
BLEthConfig(pArgs);
switch (g_eboot.type)
{
case DOWNLOAD_TYPE_EBOOT:
OALMSG(OAL_INFO, (L"Bootloader update not supported. Please reset system.\r\n"));
SetLEDValue(0xaa);
while(TRUE);
default:
launch = (UINT32)OEMMapMemAddr(start, launch);
break;
}
break;
case OAL_KITL_TYPE_FLASH:
switch (g_eboot.type)
{
default:
launch = (UINT32)OEMMapMemAddr(start, launch);
break;
}
break;
launch = (UINT32)OEMMapMemAddr(start, launch);
break;
}
// Check if we get launch address
if (launch == (UINT32)INVALID_HANDLE_VALUE)
{
OALMSG(OAL_ERROR, (L"ERROR: OEMLaunch: Unknown image launch address\r\n"));
SpinForever();
}
// Print message, flush caches and jump to image
OALLog(L"INFO: Lauching Windows CE .NET by jumping to 0x%08x...\r\n\r\n\r\n", launch);
SetLEDValue(0xaa);
OEMDebugDeinit();
JumpTo(launch);
}
//------------------------------------------------------------------------------
//
// OEMReadData
//
// This function is called to read data from the transport during
// the download process.
//
BOOL OEMReadData(ULONG size, UCHAR *pData)
{
BOOL rc = FALSE;
switch (g_eboot.bootDeviceType)
{
case OAL_KITL_TYPE_ETH:
rc = EbootEtherReadData(size, pData);
break;
case OAL_KITL_TYPE_FLASH:
if (g_bootCfg.bootDevLoc.LogicalLoc == SD_BASE)
{
rc = BLSDMMCReadData(size, pData);
}
else
{
rc = BLFLASHReadData(size, pData);
}
break;
default:
break;
}
return rc;
}
//------------------------------------------------------------------------------
//
// OEMMapMemAddr
//
// This function maps image relative address to memory address. It is used
// by boot loader to determine if an image is to be FLASH in NAND or executed.
//
UINT8* OEMMapMemAddr( DWORD image, DWORD address )
{
UINT8 *pAddress = NULL;
OALMSG(OAL_FUNC, (L"+OEMMapMemAddr(0x%08x, 0x%08x)\r\n", image, address));
switch (g_eboot.type)
{
case DOWNLOAD_TYPE_EBOOT:
// Download image to RAM to program into FLASH
pAddress = BLVAtoPA(IMAGE_EBOOT_RAM_PA);
break;
case DOWNLOAD_TYPE_FLASH:
case DOWNLOAD_TYPE_RAM:
pAddress = BLVAtoPA(address);
break;
default:
OALMSG(OAL_ERROR, (L"ERROR: OEMMapMemAddr: Invalid download type %d\r\n", g_eboot.type));
break;
}
OALMSGS(OAL_FUNC, (L"-OEMMapMemAddr(pAddress = 0x%08x)\r\n", pAddress));
return pAddress;
}
//------------------------------------------------------------------------------
//
// OEMIsFlashAddr
//
// This function determines whether the address provided lies in a platform's
// flash or RAM address range.
//
BOOL OEMIsFlashAddr(ULONG address)
{
BOOL rc;
OALMSG(OAL_FUNC, (L"+OEMIsFlashAddr(0x%08x)\r\n", address));
// Depending on download type
switch (g_eboot.type)
{
case DOWNLOAD_TYPE_EBOOT:
rc = TRUE;
break;
case DOWNLOAD_TYPE_FLASH:
rc = flashburnflag && flashgood;
break;
default:
rc = FALSE;
break;
}
OALMSG(OAL_FUNC, (L"-OEMIsFlashAddr(rc = %d)\r\n", rc));
return rc;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -