关于risc-v的mtime的简单描述
在risc-v里mtime是作为外设存在的,他的寄存器地址不在risc-v的规范范围内,是有soc设计厂商自己定义的。mtime包括了两个寄存器mtime和mtimecmp。这两个寄存器的长度在官方的规范里规定是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相关的适配。
最近编辑记录 xiaohui (2020-12-29 22:24:10)
离线
20210306更新:https://whycan.com/t_5844.html#p60439
最近编辑记录 xiaohui (2021-03-06 18:38:28)
离线