找回密码
 注册
搜索
查看: 736|回复: 1

[讨论] 分析下这段程序,真的很考人

[复制链接]
发表于 2007-12-20 16:25:04 | 显示全部楼层 |阅读模式
这本程序是从龚俊S3C44BO_BIOS中的一个小段程序,实在是看不懂,那位能分析下???


if((prog_begin==0)&&overwrite0) {
   unsigned int ins;
  
   ins = *(unsigned int *)data_begin;   
   if((ins>>24)==0xea)   // instruction: b xxxx, now just support b instruction!!!   
    bios_load_addr = ((ins&0xffffff)<<2)+8;
   else
    bios_load_addr = 4;  // other instruction, jump to 4
            
   bios_load_addr = (bios_load_addr-BIOS_LOAD-8)/4;
   bios_load_addr = (bios_load_addr&0xffffff)|0xea000000;     
   
   *(unsigned int *)data_begin = 0xea000000+(BIOS_BASE-8)/4;   
  
   modify_a0 = 1;
  }
  cache_cfg = rNCACHBE0;
  rNCACHBE0 = 0x20000000;
  SectorProg(prog_begin, (unsigned short *)data_begin, size);

  if(modify_a0) {
   size = FlashSector(size-1)+SECTOR_SIZE;   
  
   FlashRead(FlashSector(BIOS_LOAD), (unsigned short *)(DFT_DOWNLOAD_ADDR+size), SECTOR_SIZE);   
   *(unsigned int *)(DFT_DOWNLOAD_ADDR+size+SECTOR_SIZE-4) = bios_load_addr;
   SectorProg(FlashSector(BIOS_LOAD), (unsigned short *)(DFT_DOWNLOAD_ADDR+size), SECTOR_SIZE);
  }
  rNCACHBE0 = cache_cfg;
}
对if(modify_a0) {
   size = FlashSector(size-1)+SECTOR_SIZE;   
  
   FlashRead(FlashSector(BIOS_LOAD), (unsigned short *)(DFT_DOWNLOAD_ADDR+size), SECTOR_SIZE);   
   *(unsigned int *)(DFT_DOWNLOAD_ADDR+size+SECTOR_SIZE-4) = bios_load_addr;
   SectorProg(FlashSector(BIOS_LOAD), (unsigned short *)(DFT_DOWNLOAD_ADDR+size), SECTOR_SIZE);
  }
这一段实在是不明白. *(unsigned int *)(DFT_DOWNLOAD_ADDR+size+SECTOR_SIZE-4) = bios_load_addr;
放一条跳转指令.跳去那里?
BIOS_LOAD这个地址是怎样来的??
各位解释下,实在是看不懂.
发表于 2008-1-19 14:03:40 | 显示全部楼层
DFT_DOWNLOAD_ADDR
SECTOR_SIZE
BIOS_LOAD

这3个好像都没有出处啊,是不是编译器设置的参数,还是前面头文件已经定义了,仅凭贴出来的程序任谁都看不出来吧。

[em06]
点评回复

使用道具 举报

高级模式
B Color Image Link Quote Code Smilies

本版积分规则

Archiver|手机版|小黑屋|52RD我爱研发网 ( 沪ICP备2022007804号-2 )

GMT+8, 2024-11-26 00:27 , Processed in 0.045025 second(s), 17 queries , Gzip On.

Powered by Discuz! X3.5

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表