关于risc-v的mtime的简单描述

在risc-v里mtime是作为外设存在的,他的寄存器地址不在risc-v的规范范围内,是有soc设计厂商自己定义的。mtime包括了两个寄存器mtimemtimecmp。这两个寄存器的长度在官方的规范里规定是64bit(无论xlen是多少

mtime的中断使能在csrji寄存器mie(machine interrupt enable)里指定。

mtime中断发生时,ecode为7(特权文档版本:1.12-draft里描述到),flag为1.
下面引用原文。

The mtime register has a 64-bit precision on all RV32 and RV64
systems. Platforms provide a 64- bit memory-mapped machine-mode timer
compare register (mtimecmp). A timer interrupt becomes 34 Volume II:
RISC-V Privileged Architectures V1.12-draft pending whenever mtime
contains a value greater than or equal to mtimecmp, treating the
values as unsigned integers. The interrupt remains posted until
mtimecmp becomes greater than mtime (typically as a result of writing
mtimecmp). The interrupt will only be taken if interrupts are enabled
and the MTIE bit is set in the mie register.

mtime寄存器里的值 大于等于 mtimecmp寄存器的值时(比较时使用无符号的大小比较方式),需要触发mtime中断。

而且中断会一直触发直到mtimecmp寄存器的值 大于 mtime寄存器里的值 。

下一篇文章会描述freertos里对于risc-v的mtime相关的适配。

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值