debug ("### main_loop entered: bootdelay=%d\n\n", bootdelay);
s = getenv ("bootcmd"); //取得環(huán)境中設(shè)置的啟動(dòng)命令行
debug ("### main_loop: bootcmd=\"%s\"\n", s ? s : "");
if (bootdelay >= 0 && s && !abortboot (bootdelay))
{
run_command (s, 0);//執(zhí)行啟動(dòng)命令行,smdk2410.h中沒(méi)有定義CONFIG_BOOTCOMMAND,所以沒(méi)有命令執(zhí)行。
}
for (;;) {
len = readline(CFG_PROMPT);//讀取鍵入的命令行到console_buffer
flag = 0; /* assume no special flags for now */
if (len > 0)
strcpy (lastcommand, console_buffer);//拷貝命令行到lastcommand.
else if (len == 0)
flag |= CMD_FLAG_REPEAT;
if (len == -1)
puts ("\n");
else
rc = run_command (lastcommand, flag); //執(zhí)行這個(gè)命令行。
//建立sector起始地址表。
if ((info->flash_id & FLASH_VENDMASK) == FLASH_MAN_SST )
{
for (i = 0; i sector_count; i++)
info->start = CFG_FLASH_BASE + (i * 0x00010000);
}
//設(shè)置sector保護(hù)信息,對(duì)于SST生產(chǎn)的FLASH,全部設(shè)為0。
for (i = 0; i sector_count; i++)
{
if((info->flash_id & FLASH_VENDMASK) == FLASH_MAN_SST)
info->protect = 0;
}
[color="#d2691e"] //write_word操作,這個(gè)函數(shù)由write_buff一調(diào)用,完成寫(xiě)入一個(gè)word的操作,其操作命令序列由上圖中Word-Program指定。
static int write_word (flash_info_t *info, ulong dest, ulong data)
{
volatile CFG_FLASH_WORD_SIZE *dest2 = (CFG_FLASH_WORD_SIZE *)dest;
volatile CFG_FLASH_WORD_SIZE *data2 = (CFG_FLASH_WORD_SIZE *)&data;
ulong start;
int flag;
int i;
/* Check if Flash is (sufficiently) erased */
if ((*((volatile ulong *)dest) & data) != data) {
return (2);
}
/* Disable interrupts which might cause a timeout here */
flag = disable_interrupts();
for (i=0; i CFG_FLASH_WRITE_TOUT) {
return (1);
}
}
}
return (0);
}