https://mp.weixin.qq.com/s/ChXNTbx94WDC72GvmE9bGA

介绍riscv-debug的使用实例:使用三种方法读取内存。

1. Using System Bus Access

1) System Bus Access

除了抽象命令,Program Buffer之外,调试模块可以包含一个系统总线访问模块,以在不依赖核心的情况下,访问系统总线(使用物理地址):

访问大小可以是8/16/32/64/128位:

需要自己保证访问的缓存一致性:

2) sbcs/sbaddress/sbdata

a. sbcs

用于控制系统总线访问,以及获取访问状态:

b. sbaddress0..3

存储要访问的系统总线物理地址。

写sbaddress寄存器可能触发对该地址的读操作:

c. sbdata0..3

保存读取和要写入的数据。

读sbdata0寄存器可能触发系统总线的读操作:

写sbdata0寄存器可能触发系统总线的写操作:

3) 实例:Read a word from memory

A. 写sbcs寄存器:

a. sbaccess=2:访问大小为32bit;

b. sbreadonaddr=1:every write to sbaddress0 automatically triggers a system bus read at the new address.

B. 写sbaddress0寄存器:写入要访问的内存物理地址;由于A中把sbreadonaddr置位,所以这一步写sbaddress0寄存器会触发对刚写入的这个内存地址的读操作,读取的内容存放在sbdata0寄存器中;

C. 读sbdata0寄存器,获取目标内存地址处的内容;

4) 实例:Read block of memory

A. 写sbcs寄存器:

a. sbaccess=2:访问大小为32bit;

b. sbreadonaddr=1:every write to sbaddress0 automatically triggers a system bus read at the new address.

c. sbreadondata=1:every read from sbdata0 automatically triggers a system bus read at the (possibly auto-incremented) address.

d. sbautoincrement=1:sbaddress is incremented by the access size (in bytes) selected in sbaccess after every system bus access.

B. 写sbaddress0寄存器:写入要读取的内存的物理地址;这个写入动作会触发针对目标地址的读取操作,读取的内容存放在sbdata0寄存器;读取之后sbaddress0中的内存地址自动增加4个字节;

C. 读sbdata0寄存器:读取目标地址处的内容;这个读取动作会触发针对sbaddress0中地址的读取动作,读取的内容存放在sbdata0寄存器中,读取之后sbaddress0中的内存地址自动增加4个字节;

D. 连续读取sbdata0寄存器,以获取目标内存地址的内容;

E. 写sbcs寄存器:sbcs=0,亦即sbreadondata=0,下一次读取sbdata0时,不会再出发针对sbaddress0中地址的读取动作;

F. 读sbdata0寄存器:获取最后一个需要的内存数据;

2. Using Program Buffer

1) abstractauto

用于触发抽象命令自动执行的配置寄存器,两种触发方式及配置:

a. 修改Program Buffer;

b. 读取sbdata寄存器;

2) 实例:Read a word from memory

A. 准备Program Buffer:

a. 写progbuf0为指令:lw s0 0(s0),即读取s0中地址的内容,存入s0中;

b. 写progbuf1为指令:ebreak,即停止执行,返回调试环境;

B. 写data0寄存器:存入要读取的目标内存地址;

C. 写command寄存器:写入要执行的抽象命令:

a. regno=0x1008:即访问的对象寄存器为s0;

b. write=1:访问操作为写操作,即把sbdata0寄存器中的数据写入到寄存器s0中;

c. postexec=1:Execute the program in the Program Buffer exactly once after performing the transfer, if any.

D. 写command寄存器:写入要执行的抽象命令:

a. regno=0x1008:即访问的对象寄存器为s0;

b. (补)transfer=1:Do the operation specied by write;

c. write=0:即访问操作为读操作;Copy data from the specified register into arg0 portion of data;

E. 读data0寄存器:读取从s0拷贝过来的数据,即目标内存地址处的内容;

3) 实例:Read block of memory

A. 准备Program Buffer:

a. 写progbuf0为指令:lw s1, 0(s0),即读取s0中地址的内容,存入s1中;

b. 写progbuf1为指令:addi s0, s0, 4,即地址增加4;

c. 写progbuf2为指令:ebreak,即停止执行,返回调试环境;

B. 写data0寄存器:写入目标内存起始地址;

C. 写command寄存器:写入要执行的抽象命令:

a. regno=0x1008:即访问的对象寄存器为s0;

b. write=1:访问操作为写操作,即把sbdata0寄存器中的数据写入到寄存器s0中;

c. postexec=1:Execute the program in the Program Buffer exactly once after performing the transfer, if any.

该命令的效果如下:

a. 把data0中的目标内存地址,写入到s0寄存器;

b. 触发Program Buffer执行;

D. 写command寄存器:写入要执行的抽象命令:

a. regno=0x1009:即访问的对象寄存器为s1;

b. (补)transfer=1:Do the operation specied by write;

c. write=0:即访问操作为读操作;Copy data from the specified register into arg0 portion of data;

d. postexec=1:Execute the program in the Program Buffer exactly once after performing the transfer, if any.

该命令的效果如下:

a. 把s1的值读入data0寄存器;

b. 触发Program Buffer执行;

E. 写abstractauto寄存器:

a. autoexecdata=1:read or write accesses to the corresponding data word cause the command in command to be executed again.

效果是:每次读写data0寄存器都会触发D中命令的执行;

F. 读data0寄存器:

a. 获取目标内存地址处的值;

b. 触发抽象命令的执行:把s1的值读入data0寄存器;

c. 触发Program Buffer执行:读取s0中地址的内容并写入s1,s0中的地址加4;

G. 读data0寄存器:触发连续读取;

H. 写abstractauto寄存器:

a. autoexecdata=0:读取data0寄存器,不会触发抽象命令的执行;

I. 读data0寄存器:获取最后一个数据;

3. Using Abstract Memory Access

1) Access Memory

抽象命令的一种:

其格式如下:

其中:

aam前缀的意义是:Abstract command Access Memory;相较之下,

aar前缀的意义是:Abstract command Access Register;

2) 实例:Read a word from memory

A. 写data1寄存器:存入目标内存地址;

B. 写command寄存器:存入要执行的抽象命令:

a. cmdtype=2:表示命令的类型为Access Memory;

b. aamsize=2:Access the lowest 32 bits of the memory location.

c. aamvirtual=0:Addresses are physical (to the hart they are performed on).

d. write=0:Copy data from the memory location specified in arg1 into arg0 portion of data.

这条命令的效果是:读取data1中地址的内容,并存入data0寄存器;

C. 读data0寄存器:获取从内存地址中读到的内容;

3) 实例:Read block of memory

这里只介绍要点:

a. abstractauto=1:读取data0寄存器后,触发抽象命令执行;

b. aampostincrement=1:After a memory access has completed, if this bit is 1, increment arg1 (which contains the address used) by the number of bytes encoded in aamsize. 即每次读取内存之后,都把目标内存地址加4,即data1寄存器的值加4;

Rocket - debug - Example: Read Memory的更多相关文章

  1. Rocket - debug - Example: Write Memory

    https://mp.weixin.qq.com/s/on1LugO9fTFJstMes3T2Xg 介绍riscv-debug的使用实例:使用三种方法写内存. 1. Using System Bus ...

  2. Xcode6 运行程序后,右侧Debug区域的Memory显示空白解决方法

    http://chenyh-blog.com/%E8%9B%8B%E7%96%BC%E7%9A%84%E5%86%85%E5%AD%98-%E7%AC%AC%E4%B8%89%E7%AF%87-sdw ...

  3. Rocket - debug - TLDebugModuleInner - Hart Bus Access

    https://mp.weixin.qq.com/s/deNMEyJ1idJDVoZwwo0A1A 简单介绍TLDebugModuleInner中核心总线访问(Hart Bus Access). 参考 ...

  4. Rocket - debug - Example: Triggers

    https://mp.weixin.qq.com/s/zPNyrBOhsytkRrZTDTEvpw 介绍riscv-debug的使用实例:配置Triggers功能. 1. Trigger Trigge ...

  5. Rocket - debug - Periphery

    https://mp.weixin.qq.com/s/uGxn-Xec0LkwdaSsCtQBvw 简单介绍Periphery的实现. 1. ExportDebugDMI/ExportDebugJTA ...

  6. Rocket - debug - DebugTransport

    https://mp.weixin.qq.com/s/EcsuTjb4hFF9Ncig9Gfhew 简单介绍DebugTransport的实现. 1. JtagDTMConfig 1) JtagDTM ...

  7. Rocket - debug - TLDebugModule

    https://mp.weixin.qq.com/s/EhUb1z5oiIw6dJ-90ifDJA 简单介绍TLDebugModule中的实现. 1. device device是一个设备描述符,包含 ...

  8. Rocket - debug - TLDebugModuleInner - ROM Generation

    https://mp.weixin.qq.com/s/j_CgHU4PnY82NMwJzOqHYg 简单介绍Variable ROM Generation. 1. jalAbstract jalAbs ...

  9. Rocket - debug - Example: DMI

    https://mp.weixin.qq.com/s/7suuJ7m2BKCpsHk1K2FzJQ 介绍riscv-debug的使用实例:如何使用DMI. 1. dm Debug Module实现了调 ...

随机推荐

  1. [hdu5521 Meeting]最短路

    题意:有N个点,给定M个集合,集合Si里面的点两两之间的距离都为Ti,集合里面的所有点数之和<=1e6.有两个人分别在1和N处,求1个点使得两个人到这一点距离的最大值最小 思路:这题是裸的最短路 ...

  2. C#实现前向最大匹、字典树(分词、检索)

    场景:现在有一个错词库,维护的是错词和正确词对应关系.比如:错词“我门”对应的正确词“我们”.然后在用户输入的文字进行错词校验,需要判断输入的文字是否有错词,并找出错词以便提醒用户,并且可以显示出正确 ...

  3. Mysql 常用函数(3)- ifnull 函数

    Mysql常用函数的汇总,可看下面系列文章 https://www.cnblogs.com/poloyy/category/1765164.html ifnull 的作用 可以判断某个字段的值是否为 ...

  4. loadrunner Error -27985问题

    错误提示:Error -27985: There is no context for HTML-based functions. A previous function may not have us ...

  5. 网站设计时应考虑哪些因素,以保证网站是对SEO友好

    根据用户的搜索习惯做好栏目的设计 根据用户的习惯做好三大标签的设计 做好首页栏目的展现布局  对于用户来说的重点 展示栏目的合理化 多样化 细节化 代码的静态化 域名 服务器购买稳定 合格 网站内容的 ...

  6. .Net Core3.0 WebApi 项目框架搭建 五: 轻量型ORM+异步泛型仓储

    .Net Core3.0 WebApi 项目框架搭建:目录 SqlSugar介绍 SqlSugar是国人开发者开发的一款基于.NET的ORM框架,是可以运行在.NET 4.+ & .NET C ...

  7. 微信小程序通信录

    第一步:phone.wxml中 <view bindlongtap="clickPhone">{{phoneNum}}</view> 第二步:phone.j ...

  8. DRF路由组件和渲染器组件

    参考博客:https://www.cnblogs.com/wupeiqi/articles/7805382.html

  9. 9.4 Go 数据格式

    9.4 Go 数据格式 1.1. msgpack格式 官方msgpack官网用一句话总结: It’s like JSON. but fast and small. 简单来讲,它的数据格式与json类似 ...

  10. hdu6092 01背包

    Rikka with Subset Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others ...