From 3c5921822bb8758b239560a9047db35b42196768 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=9B=B6=E4=B8=AD=E6=96=AD=E5=BB=B6=E8=BF=9F=E7=9A=84RTOS?= Date: Mon, 3 Aug 2026 03:39:25 +0000 Subject: [PATCH] update Demo-Build/RISC-V32/readme.txt. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 零中断延迟的RTOS --- Demo-Build/RISC-V32/readme.txt | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/Demo-Build/RISC-V32/readme.txt b/Demo-Build/RISC-V32/readme.txt index 10465efe..3399f4a6 100644 --- a/Demo-Build/RISC-V32/readme.txt +++ b/Demo-Build/RISC-V32/readme.txt @@ -11,9 +11,12 @@ RISC-V32 之系统构建 3、CosyOS 采用了自研先进技术,可实现 CH32V 全程开启硬件压栈。 该技术为纯软件实现,不依赖特定硬件(0x804->bit5),V103、203 等 皆可完美支持。所以,如果您的处理器支持硬件压栈,千万不要忘记开启。 - 如果开启硬件压栈,中断函数的声明原则等同裸机。即如果最大硬件压栈 - 深度为3级,需要将低优先级的三级中断声明为硬件压栈,高优先级的中断 - 声明为软件压栈。 + 如果开启硬件压栈,用户应注意以下两个问题: + (1)处理器需要仅工作在机器模式 + 可在启动文件中,配置 mstatus 的 MPP 为 3 来实现。 + (2)中断函数的声明原则等同裸机 + 即如果最大硬件压栈深度为3级,需要将低优先级的三级中断声明为 + 硬件压栈,高优先级的中断声明为软件压栈。 移植流程(以 MRS2 为例) @@ -139,4 +142,14 @@ void SysTick_Handler(void) tCosyTick_Handler(); } +/* 例程-使能硬件压栈并仅为机器模式 */ +handle_reset: +/* Enable interrupt nesting and hardware stack */ + // HWSTKOVEN, PMTCFG, INESTEN, HWSTKEN + li t0, (1 << 4) | (3 << 2) | (1 << 1) | 1 + csrw 0x804, t0 +/* Enable floating point and global interrupt, configure privileged mode */ + // FS, MPP, MPIE, MIE + li t0, (3 << 13) | (3 << 11) | (1 << 7) | (1 << 3) + csrw mstatus, t0