?? main.c
字號:
switch(KeySelect)
{
case '0': // Change IP address.
SetIP(pBootCfg);
pBootCfg->ConfigFlags &= ~CONFIG_FLAGS_DHCP; // clear DHCP flag
bConfigChanged = TRUE;
break;
case '1': // Change subnet mask.
SetMask(pBootCfg);
bConfigChanged = TRUE;
break;
case '2': // Toggle static/DHCP mode.
pBootCfg->ConfigFlags = (pBootCfg->ConfigFlags ^ CONFIG_FLAGS_DHCP);
bConfigChanged = TRUE;
break;
case '3': // Change autoboot delay.
SetDelay(pBootCfg);
bConfigChanged = TRUE;
break;
case '4': // Reset the bootloader configuration to defaults.
OALMSG(TRUE, (TEXT("Resetting default TOC...\r\n")));
TOC_Init(DEFAULT_IMAGE_DESCRIPTOR, (IMAGE_TYPE_RAMIMAGE|IMAGE_TYPE_BINFS), 0, 0, 0);
if ( !TOC_Write() ) {
OALMSG(OAL_WARN, (TEXT("TOC_Write Failed!\r\n")));
}
OALMSG(TRUE, (TEXT("...TOC complete\r\n")));
break;
case '5': // Toggle download/launch status.
pBootCfg->ConfigFlags = (pBootCfg->ConfigFlags ^ BOOT_TYPE_DIRECT);
bConfigChanged = TRUE;
break;
case '6': // Toggle image storage to Smart Media.
pBootCfg->ConfigFlags = (pBootCfg->ConfigFlags ^ TARGET_TYPE_NAND);
bConfigChanged = TRUE;
break;
case '7': // Configure Crystal CS8900 MAC address.
SetCS8900MACAddress(pBootCfg);
bConfigChanged = TRUE;
break;
case '8': // Toggle KD
pBootCfg->ConfigFlags = (pBootCfg->ConfigFlags ^ CONFIG_FLAGS_KITL);
g_bWaitForConnect = (pBootCfg->ConfigFlags & CONFIG_FLAGS_KITL) ? TRUE : FALSE;
bConfigChanged = TRUE;
continue;
break;
#if 0
case '9':
// format the boot media for BinFS
// N.B: this does not destroy our OEM reserved sections (TOC, bootloaders, etc)
if ( !g_bBootMediaExist ) {
OALMSG(OAL_ERROR, (TEXT("ERROR: BootMonitor: boot media does not exist.\r\n")));
continue;
}
// N.B: format offset by # of reserved blocks,
// decrease the ttl # blocks available by that amount.
if ( !BP_LowLevelFormat( g_dwImageStartBlock,
wNUM_BLOCKS - g_dwImageStartBlock,
FORMAT_SKIP_BLOCK_CHECK) )
{
OALMSG(OAL_ERROR, (TEXT("ERROR: BootMonitor: Low-level boot media format failed.\r\n")));
continue;
}
break;
#endif
case 'A' :
case 'a' :
{
OALMSG(TRUE, (TEXT(" ++Format FIL (Erase All Blocks)\r\n")));
if (VFL_Close() != VFL_SUCCESS)
{
OALMSG(TRUE, (TEXT("[ERR] VFL_Close() Failure\r\n")));
break;
}
if (WMR_Format_FIL() == FALSE32)
{
OALMSG(TRUE, (TEXT("[ERR] WMR_Format_FIL() Failure\r\n")));
break;
}
OALMSG(TRUE, (TEXT("[INF] You can not use VFL before Format VFL\r\n")));
OALMSG(TRUE, (TEXT(" --Format FIL (Erase All Blocks)\r\n")));
}
break;
case 'B' :
case 'b' :
{
OALMSG(TRUE, (TEXT(" ++Format VFL (Format FIL + VFL Format)\r\n")));
if (VFL_Close() != VFL_SUCCESS)
{
OALMSG(TRUE, (TEXT("[ERR] VFL_Close() Failure\r\n")));
break;
}
if (WMR_Format_VFL() == FALSE32)
{
OALMSG(TRUE, (TEXT("[ERR] WMR_Format_VFL() Failure\r\n")));
break;
}
if (VFL_Open() != VFL_SUCCESS)
{
OALMSG(TRUE, (TEXT("[ERR] VFL_Open() Failure\r\n")));
break;
}
OALMSG(TRUE, (TEXT(" --Format VFL (Format FIL + VFL Format)\r\n")));
}
break;
case 'C' :
case 'c' :
{
OALMSG(TRUE, (TEXT(" ++Format FTL (Erase FTL Area + FTL Format)\r\n")));
if (WMR_Format_FTL() == FALSE32)
{
OALMSG(TRUE, (TEXT("[ERR] WMR_Format_FTL() Failure\r\n")));
break;
}
if (FTL_Close() != FTL_SUCCESS)
{
OALMSG(TRUE, (TEXT("[ERR] FTL_Close() Failure\r\n")));
break;
}
OALMSG(TRUE, (TEXT(" --Format FTL (Erase FTL Area + FTL Format)\r\n")));
}
break;
case 'E' :
case 'e' :
{
LowFuncTbl *pLowFuncTbl;
OALMSG(TRUE, (TEXT(" ++Erase Physical Block 0\r\n")));
pLowFuncTbl = FIL_GetFuncTbl();
pLowFuncTbl->Erase(0, 0, enuBOTH_PLANE_BITMAP);
if (pLowFuncTbl->Sync(0, &nSyncRet))
{
OALMSG(TRUE, (TEXT("[ERR] Erase Block 0 Error\r\n")));
}
OALMSG(TRUE, (TEXT(" --Erase Physical Block 0\r\n")));
}
break;
case 'F' :
case 'f' :
{
UINT32 nBlock, nPage;
// UCHAR *pTemp = (UCHAR *)prayer16bpp;
UCHAR *pTemp = (UCHAR *)InitialImage_rgb16_320x240;
UCHAR pDBuf[8192];
UCHAR pSBuf[256];
LowFuncTbl *pLowFuncTbl;
OALMSG(TRUE, (TEXT(" ++Make Initial Bad Block Information (Warning))\r\n")));
pLowFuncTbl = FIL_GetFuncTbl();
OALMSG(TRUE, (TEXT("Initial Bad Block Check\r\n")));
for (nBlock=1; nBlock<SUBLKS_TOTAL; nBlock++)
{
IS_CHECK_SPARE_ECC = FALSE32;
pLowFuncTbl->Read(0, nBlock*PAGES_PER_BLOCK+(PAGES_PER_BLOCK-1), 0x0, enuBOTH_PLANE_BITMAP, NULL, pSBuf, TRUE32, FALSE32);
IS_CHECK_SPARE_ECC = TRUE32;
if (pSBuf[0] != 0xff)
{
OALMSG(TRUE, (TEXT("Initial Bad Block @ %d Block\r\n"), nBlock));
#if 0
pLowFuncTbl->Erase(0, nBlock, enuNONE_PLANE_BITMAP);
pLowFuncTbl->Sync(0, &nSyncRet);
memset((void *)pSBuf, 0x00, BYTES_PER_SPARE_PAGE);
IS_CHECK_SPARE_ECC = FALSE32;
pLowFuncTbl->Write(0, nBlock*PAGES_PER_BLOCK+(PAGES_PER_BLOCK-1), 0x0, enuNONE_PLANE_BITMAP, NULL, pSBuf);
IS_CHECK_SPARE_ECC = TRUE32;
if (pLowFuncTbl->Sync(0, &nSyncRet)) // Write Error
{
OALMSG(TRUE, (TEXT("Bad marking Write Error @ %d Block\r\n"), nBlock));
}
#endif
}
#if 1
else
{
pLowFuncTbl->Erase(0, nBlock, enuNONE_PLANE_BITMAP);
if (pLowFuncTbl->Sync(0, &nSyncRet)) // Erase Error
{
OALMSG(TRUE, (TEXT("Erase Error @ %d Block -> Bad Marking\r\n"), nBlock));
memset((void *)pSBuf, 0x00, BYTES_PER_SPARE_PAGE);
IS_CHECK_SPARE_ECC = FALSE32;
pLowFuncTbl->Write(0, nBlock*PAGES_PER_BLOCK+(PAGES_PER_BLOCK-1), 0x0, enuNONE_PLANE_BITMAP, NULL, pSBuf);
IS_CHECK_SPARE_ECC = TRUE32;
if (pLowFuncTbl->Sync(0, &nSyncRet)) // Write Error
{
OALMSG(TRUE, (TEXT("Bad marking Write Error @ %d Block\r\n"), nBlock));
}
}
else
{
for (nPage=0; nPage<PAGES_PER_BLOCK; nPage++) // Write and Read Test
{
// Write Page
memset((void *)pSBuf, 0xff, BYTES_PER_SPARE_PAGE);
pLowFuncTbl->Write(0, nBlock*PAGES_PER_BLOCK+nPage, LEFT_SECTOR_BITMAP_PAGE, enuNONE_PLANE_BITMAP, pTemp, pSBuf);
if (pLowFuncTbl->Sync(0, &nSyncRet)) // Write Error
{
OALMSG(TRUE, (TEXT("Write Error @ %d Block %d Page -> Bad Marking\r\n"), nBlock, nPage));
pLowFuncTbl->Erase(0, nBlock, enuNONE_PLANE_BITMAP);
pLowFuncTbl->Sync(0, &nSyncRet);
memset((void *)pSBuf, 0x00, BYTES_PER_SPARE_PAGE);
IS_CHECK_SPARE_ECC = FALSE32;
pLowFuncTbl->Write(0, nBlock*PAGES_PER_BLOCK+(PAGES_PER_BLOCK-1), 0x0, enuNONE_PLANE_BITMAP, NULL, pSBuf);
IS_CHECK_SPARE_ECC = TRUE32;
if (pLowFuncTbl->Sync(0, &nSyncRet)) // Write Error
{
OALMSG(TRUE, (TEXT("Bad marking Write Error @ %d Block\r\n"), nBlock));
}
break; // Bad Block
}
// Read Page
memset((void *)pSBuf, 0xff, BYTES_PER_SPARE_PAGE);
if (pLowFuncTbl->Read(0, nBlock*PAGES_PER_BLOCK+nPage, LEFT_SECTOR_BITMAP_PAGE, enuNONE_PLANE_BITMAP, pDBuf, pSBuf, 0, 0))
{
OALMSG(TRUE, (TEXT("Read Error @ %d Block %d Page -> Bad Marking\r\n"), nBlock, nPage));
pLowFuncTbl->Erase(0, nBlock, enuNONE_PLANE_BITMAP);
pLowFuncTbl->Sync(0, &nSyncRet);
memset((void *)pSBuf, 0x00, BYTES_PER_SPARE_PAGE);
IS_CHECK_SPARE_ECC = FALSE32;
pLowFuncTbl->Write(0, nBlock*PAGES_PER_BLOCK+(PAGES_PER_BLOCK-1), 0x0, enuNONE_PLANE_BITMAP, NULL, pSBuf);
IS_CHECK_SPARE_ECC = TRUE32;
if (pLowFuncTbl->Sync(0, &nSyncRet)) // Write Error
{
OALMSG(TRUE, (TEXT("Bad marking Write Error @ %d Block\r\n"), nBlock));
}
break; // Bad Block
}
}
}
}
#endif
OALMSG(TRUE, (TEXT(".")));
}
OALMSG(TRUE, (TEXT(" --Make Initial Bad Block Information (Warning)\r\n")));
}
break;
case 'T': // Download? Yes.
case 't':
MLC_LowLevelTest();
break;
case 'D': // Download? Yes.
case 'd':
bDownload = TRUE;
goto MENU_DONE;
case 'L': // Download? No.
case 'l':
bDownload = FALSE;
goto MENU_DONE;
case 'R':
case 'r':
TOC_Read();
TOC_Print();
// TODO
break;
case 'U': // Download? No.
case 'u':
//bConfigChanged = TRUE; // Write to NAND too frequently causes wearout
/* if (!InitializeUSB())
{
DEBUGMSG(1, (TEXT("OEMPlatformInit: Failed to initialize USB.\r\n")));
return(FALSE);
}*/
g_bUSBDownload = TRUE;
bDownload = TRUE;
goto MENU_DONE;
case 'W': // Configuration Write
case 'w':
if (!TOC_Write())
{
OALMSG(OAL_WARN, (TEXT("WARNING: MainMenu: Failed to store updated eboot configuration in flash.\r\n")));
}
else
{
OALMSG(OAL_INFO, (TEXT("Successfully Written\r\n")));
bConfigChanged = FALSE;
}
break;
default:
break;
}
}
MENU_DONE:
// If eboot settings were changed by user, save them to flash.
//
if (bConfigChanged && !TOC_Write())
{
OALMSG(OAL_WARN, (TEXT("WARNING: MainMenu: Failed to store updated bootloader configuration to flash.\r\n")));
}
return(bDownload);
}
/*
@func BOOL | OEMPlatformInit | Initialize the Samsung SMD6410 platform hardware.
@rdesc TRUE = Success, FALSE = Failure.
@comm
@xref
*/
BOOL OEMPlatformInit(void)
{
ULONG BootDelay;
UINT8 KeySelect;
UINT32 dwStartTime, dwPrevTime, dwCurrTime;
BOOL bResult = FALSE;
FlashInfo flashInfo;
OALMSG(OAL_FUNC, (TEXT("+OEMPlatformInit.\r\n")));
// Check if Current ARM speed is not matched to Target Arm speed
// then To get speed up, set Voltage
#if (APLL_CLK == CLK_1332MHz)
LTC3714_Init();
LTC3714_VoltageSet(1,1200,100); // ARM
LTC3714_VoltageSet(2,1300,100); // INT
#endif
#if (TARGET_ARM_CLK == CLK_800MHz)
LTC3714_Init();
LTC3714_VoltageSet(1,1300,100); // ARM
LTC3714_VoltageSet(2,1200,100); // INT
#endif
EdbgOutputDebugString("Microsoft Windows CE Bootloader for the Samsung SMDK6410 Version %d.%d Built %s\r\n\r\n",
EBOOT_VERSION_MAJOR, EBOOT_VERSION_MINOR, __DATE__);
// Initialize the display.
InitializeDisplay();
// Initialize the BSP args structure.
OALArgsInit(pBSPArgs);
g_bCleanBootFlag = (BOOL*)OALArgsQuery(BSP_ARGS_QUERY_CLEANBOOT) ;
g_KITLConfig = (OAL_KITL_ARGS *)OALArgsQuery(OAL_ARGS_QUERY_KITL);
g_DevID = (UCHAR *)OALArgsQuery( OAL_ARGS_QUERY_DEVID);
InitializeInterrupt();
g_dwImageStartBlock = IMAGE_START_BLOCK;
// Try to initialize the boot media block driver and BinFS partition.
//
///*
OALMSG(TRUE, (TEXT("BP_Init\r\n")));
if (!BP_Init((LPBYTE)BINFS_RAM_START, BINFS_RAM_LENGTH, NULL, NULL, NULL) )
{
OALMSG(OAL_WARN, (TEXT("WARNING: OEMPlatformInit failed to initialize Boot Media.\r\n")));
g_bBootMediaExist = FALSE;
}
else
{
g_bBootMediaExist = TRUE;
}
// Get flash info
if (!FMD_GetInfo(&flashInfo))
{
OALMSG(OAL_ERROR, (L"ERROR: BLFlashDownload: FMD_GetInfo call failed\r\n"));
}
wNUM_BLOCKS = flashInfo.dwNumBlocks;
RETAILMSG(1, (TEXT("wNUM_BLOCKS : %d(0x%x) \r\n"), wNUM_BLOCKS, wNUM_BLOCKS));
// stDeviceInfo = GetNandInfo();
// Try to retrieve TOC (and Boot config) from boot media
if ( !TOC_Read( ) )
{
// use default settings
TOC_Init(DEFAULT_IMAGE_DESCRIPTOR, (IMAGE_TYPE_RAMIMAGE), 0, 0, 0);
}
// Display boot message - user can halt the autoboot by pressing any key on the serial terminal emulator.
BootDelay = g_pBootCfg->BootDelay;
if (g_pBootCfg->ConfigFlags & BOOT_TYPE_DIRECT)
{
OALMSG(TRUE, (TEXT("Press [ENTER] to launch image stored on boot media, or [SPACE] to enter boot monitor.\r\n")));
OALMSG(TRUE, (TEXT("\r\nInitiating image launch in %d seconds. "),BootDelay--));
}
else
{
OALMSG(TRUE, (TEXT("Press [ENTER] to download image stored on boot media, or [SPACE] to enter boot monitor.\r\n")));
OALMSG(TRUE, (TEXT("\r\nInitiating image download in %d seconds. "),BootDelay--));
}
dwStartTime = OEMEthGetSecs();
dwPrevTime = dwStartTime;
dwCurrTime = dwStartTime;
KeySelect = 0;
if (!InitializeUSB())
{
DEBUGMSG(1, (TEXT("OEMPlatformInit: Failed to initialize USB.\r\n")));
return(FALSE);
}
// Allow the user to break into the bootloader menu.
while((dwCurrTime - dwStartTime) < g_pBootCfg->BootDelay)
{
KeySelect = OEMReadDebugByte();
if ((KeySelect == 0x20) || (KeySelect == 0x0d))
{
break;
}
dwCurrTime = OEMEthGetSecs();
if (dwCurrTime > dwPrevTime)
{
int i, j;
// 1 Second has elapsed - update the countdown timer.
dwPrevTime = dwCurrTime;
// for text alignment
if (BootDelay < 9)
{
i = 11;
}
else if (BootDelay < 99)
{
i = 12;
}
else if (BootDelay < 999)
{
i = 13;
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -