在线咨询
eetop公众号 创芯大讲堂 创芯人才网
切换到宽版

EETOP 创芯网论坛 (原名:电子顶级开发网)

手机号码,快捷登录

手机号码,快捷登录

找回密码

  登录   注册  

快捷导航
搜帖子
芯片精品文章合集(500篇!)    创芯人才网--重磅上线啦!
查看: 5915|回复: 8

帮忙分析一个reset.S函数,我有一整套的yamon bootloarder代码

[复制链接]
发表于 2007-9-21 14:19:14 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?注册

x
LEAF(__reset_vector)

        .set noreorder
       
       
         
        
  /* Determine processor */       
        MFC0(   t0, C0_PRId)
        li        t1, M_PRIdImp | M_PRIdCoID
        and t0, t1       
        li        t1, PRID_IMP_4Kec | PRID_COMP_mips /*0x019000*/
        beq        t1, t0, is_4Kec
        nop
       
       
       
       
        /* wait for DCU is ok */
       
        li      t1, 0x1000;
       
1:       
        addiu   t1, -1
        bne     t1, zero, 1b
        nop
       
         
       
        la        t0, av_entry  
        jalr        t0                       /*5280 will auto flush cache after reset */
        nop


       
       
       
       
               
       
       
is_4Kec:       
        /**** linked cached (start address 0x9fc00000)
         **** Processor is running code uncached (i.e. 0xbfc00000)
         ****/
       
       
       
       
        /* set EJ_TDO to 4mA , for ICE help*/
        lw        t0,0xb801a150 ;   
        or  t0, 0x4;
       sw  t0, 0xb801a150;
  
       
             
       
       
        /* Clear watch registers */
        MTC0(        zero, C0_WatchLo)
        MTC0(        zero, C0_WatchHi)

        /* Disable interrupts and KSU field (power up issue) */
        MFC0(   k0, C0_Status)
        li        k1, ~(M_StatusIE | M_StatusKSU)
        and        k0, k1
        MTC0(        k0, C0_Status)

1:         
  
       
         
        li        k1, KSEG1BASE
        la        k0, _reset_handler_le   /* Defined in linker script */
        or        k0, k1                        /* Make sure it is uncached */
        jr        k0
        nop
/*cy test */         
error:  
      
1:        
        b       1b
        nop        
  

.org 0x200
        /* 0xBFC00200 TLB refill, 32 bit task                    */
        /*********************************************************/
1:        b        1b        /* Stay here */
        nop
       

.org 0x280
        /* 0xBFC00280 XTLB refill, 64 bit task                   */
        /*********************************************************/
1:        b        1b        /* Stay here */
        nop
       

.org 0x300
        /* 0xBFC00300 Cache error exception                      */
        /*********************************************************/
1:        b        1b        /* Stay here */
        nop
       

.org 0x380
        /* 0xBFC00380 General exception                          */
        /*********************************************************/

  li       t1, 0x49;
  sw       t1, 0xb801b200;
1:                /* Stay here */  
  b        1b
        nop


.org 0x400
        /* 0xBFC00400 Catch interrupt exceptions, some QEDs only */
        /*********************************************************/
1:        b        1b        /* Stay here */
        nop
       

.org 0x480
       /* 0xBFC00480 EJTAG debug exception -- don't touch ANY GPR */
       /******************************************************************
        * This exception cannot be moved from here, so below code
        * transfers it to RAM entry 0x80000300. The RAM entry will look
        * similar, which may give this sequence of machine instructions:
        *        bfc0049c:  jr    v0
        *        bfc004a0:  mfc0  v0, C0_DESAVE
        *            (v0):  mtc0  xx, CO-DESAVE
        * Notes on hazard:
        * On cpus without GPR interlocking, xx must be different from v0.
        * The mfc0 and mtc0 placed back to back should not be a problem,
        * as the read in CP0 takes place at an earlier stage than write,
        * and DESAVE is a scratchpad register with no operational effects.
        * Below: Two instructions between mtc0 and mfc0 is sufficient.
        */
       mtc0     v0, C0_DESAVE
       li       v0, KSEG0(SYS_EJTAG_RAM_VECTOR_OFS)
       jr        v0
       mfc0     v0, C0_DESAVE


.org 0x500
       /* 0xBFC00500 Vector table for shell functions */


END(__reset_vector)
 楼主| 发表于 2007-9-21 14:23:00 | 显示全部楼层
这是一个项目的启动代码的一部分,由于本人没有负责这部分,公司找不到人一起学习,所以就拿出来一起分析,如果效果可以的话,会有已整套的yamon bootloarder代码展现出来
发表于 2007-9-24 12:58:17 | 显示全部楼层
是不懂mips assembly 的语法? 还是其他的? 要看懂每个寄存器值要还要参考CPU的datasheet
发表于 2007-9-25 09:23:20 | 显示全部楼层
能否给我提供该bootloader的源码?
一起学习吧。
zwolfox@gmail.com
发表于 2007-10-6 16:04:06 | 显示全部楼层
从逻辑上看, 引导代码是极其简单的。 但是要求你懂你使用的平台, 再就是很少的一点点技巧而已。 楼主贴出的代码, 只要你懂MIPS汇编和CPU的一些寄存器,很容易明白的。
发表于 2007-12-2 11:26:54 | 显示全部楼层
这不挺简单的吗?都有注释啊。
首先判断处理器的类型,
   如果是4KEC就跳转到is_4Kec;
   否则就等一段时间,跳转到av_entry.

如果是4KEC,
    配置JTAG相关的管脚
    清除watch register
    关中断
    跳转到_reset_handler_le
再后面的是异常向量,跟启动无关,只是用来初始化系统异常程序。

至于启动的汇编代码,也很common,如果看不明白,查一下手册就是了。
发表于 2009-12-30 23:34:08 | 显示全部楼层
good !
发表于 2010-3-3 23:11:24 | 显示全部楼层
没有看到代嗎
发表于 2010-5-3 11:31:23 | 显示全部楼层
good...........
您需要登录后才可以回帖 登录 | 注册

本版积分规则

关闭

站长推荐 上一条 /2 下一条

小黑屋| 关于我们| 联系我们| 在线咨询| 隐私声明| EETOP 创芯网
( 京ICP备:10050787号 京公网安备:11010502037710 )

GMT+8, 2024-5-1 09:51 , Processed in 0.033499 second(s), 11 queries , Gzip On, Redis On.

eetop公众号 创芯大讲堂 创芯人才网
快速回复 返回顶部 返回列表