debug ("### main_loop entered: bootdelay=%d\n\n", bootdelay); s = getenv ("bootcmd"); //取得环境中设置的启动命令行 debug ("### main_loop: bootcmd=\"%s\"\n", s ? s : "");
if (bootdelay >= 0 && s && !abortboot (bootdelay)) { run_command (s, 0);//执行启动命令行,smdk2410.h中没有定义CONFIG_BOOTCOMMAND,所以没有命令执行。 }
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); //执行这个命令行。
if (rc flash_id = FLASH_MAN_SST; else { panic("NOT expected FLASH FOUND!\n");return 0; } value=READ_ADDR1; //read device ID
//建立sector起始地址表。 if ((info->flash_id & FLASH_VENDMASK) == FLASH_MAN_SST ) { for (i = 0; i sector_count; i++) info->start = CFG_FLASH_BASE + (i * 0x00010000); }
//设置sector保护信息,对于SST生产的FLASH,全部设为0。 for (i = 0; i sector_count; i++) { if((info->flash_id & FLASH_VENDMASK) == FLASH_MAN_SST) info->protect = 0; }
//write_word操作,这个函数由write_buff一调用,完成写入一个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); }