RT-Thread / RT-Thread/rt-thread

[Feature] risc-v/common64: unify header file for rv64 mmu

Open
#9,567 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Arch: RISC-V
Dominant language
C
Stars
12.2k
Forks
5.4k
Avg merge
4d 12h
Merged PRs (30d)
40

Description

Describe problem solved by the proposed feature

riscv common64 目录中的 mmu.h 文件提供了与 MMU 相关的通用接口。该文件包含了 riscv_mmu.h,后者用于定义 RV64 架构中与 MMU 相关的具体内容。
riscv_mmu.h 在不同的 CPU 相关目录中有各自的具体实现,例如 virt64/riscv_mmu.h、t-head/c906/riscv_mmu.h 等。这些文件根据目标 CPU 及其支持的相关RV64标准(如是否符合RISC-V Privileged ISA、是否支持Svadu扩展等)定义了 PTE(页表项)属性。例如,像 MMU_MAP_K_RW 和 MMU_MAP_K_DEVICE 这样的属性值。

但是,根据当前的代码结构,common64 中应该是RV64的通用实现,所以mmu.h和riscv_mmu.h的包含关系似乎不太合理。

Describe your preferred solution

1、将原common64中mmu.h和具体cpu目录下的riscv_mmu.h中的内容抽取公共部分合并,新增rv64_mmu.h,原mmu.h删除;
2、将原virt64等目录下的riscv_mmu.h删除,新增mmu.h,内容如下:

#ifndef __MMU_H__
#define __MMU_H__

#include <rv64_mmu.h>

#undef  MMU_MAP_K_RW
#define MMU_MAP_K_RW      (PTE_G | PTE_X | PTE_W | PTE_R | PTE_V | PTE_A | PTE_D)

#endif

这样修改是不是更合理些?

Describe possible alternatives

No response

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Compare common64/mmu.h with the riscv_mmu.h files under virt64 and t-head/c906, then identify the shared RV64 MMU definitions and CPU-specific overrides. Review how these headers are included before reorganizing them into the proposed common and per-CPU files; done means the common header is unified without losing target-specific PTE attributes.

Written by the indexing model from the issue text.

Assessment

Tech stack
c
Domain
embedded-iot, operating-systems
Issue type
Refactor
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.