- 论坛徽章:
- 0
|
static int write_word (flash_info_t *info, ulong dest, ulong data)
{
vu_long *addr = (vu_long*)(info->start[0]);
ulong start,barf;
int flag;
/* Check if Flash is (sufficiently) erased */
if ((*((vu_long *)dest) & data) != data) {
return (2);
}
/* Disable interrupts which might cause a timeout here */
flag = disable_interrupts();//关中断
if(info->flash_id > FLASH_AMD_COMP) {
/* AMD stuff */
addr[0x0555] = 0x00AA00AA;//这些地址是做什么用的?为什么是常数?
addr[0x02AA] = 0x00550055;
addr[0x0555] = 0x00A000A0;
} else {
/* intel stuff */
*addr = 0x00400040;
}
*((vu_long *)dest) = data;
/* re-enable interrupts if necessary */
if (flag)
enable_interrupts();//开中断
/* data polling for D7 */
start = get_timer (0);
if(info->flash_id > FLASH_AMD_COMP) {
while ((*((vu_long *)dest) & 0x00800080) != (data & 0x00800080)) {//同问,为何是0x00800080
if (get_timer(start) > CFG_FLASH_WRITE_TOUT) {
return (1);
}
}
} else {
while(!(addr[0] & 0x00800080)){ /* wait for error or finish */
if (get_timer(start) > CFG_FLASH_WRITE_TOUT) {
return (1);
}
if( addr[0] & 0x003A003A) { /* check for error */
barf = addr[0] & 0x003A0000;
if( barf ) {
barf >>=16;
} else {
barf = addr[0] & 0x0000003A;
}
printf("\nFlash write error at address %lx\n",(unsigned long)dest);
if(barf & 0x0002) printf("Block locked, not erased.\n");
if(barf & 0x0010) printf("Programming error.\n");
if(barf & 0x0008) printf("Vpp Low error.\n");
return(2);
}
}
return (0);
}
上面有很多十六进制的常数进行的与或操作,它们的作用是什么呢?
[ 本帖最后由 fuchuangbob 于 2009-10-27 11:21 编辑 ] |
|