Skip to content

[libcpu][cortex-m7]Canonical alignment#11250

Open
wdfk-prog wants to merge 1 commit intoRT-Thread:masterfrom
wdfk-prog:pr/02-sdmmc
Open

[libcpu][cortex-m7]Canonical alignment#11250
wdfk-prog wants to merge 1 commit intoRT-Thread:masterfrom
wdfk-prog:pr/02-sdmmc

Conversation

@wdfk-prog
Copy link
Contributor

为什么提交这份PR (why to submit this PR)

当前 Cortex-M7 cache 操作实现中,在 I-Cache 和 D-Cache 地址对齐时使用了手工位运算写法:

(rt_uint32_t)addr & ~(L1CACHE_LINESIZE_BYTE - 1)

虽然该实现本身是正确的,但这种写法可读性较弱,也不够统一。
RT-Thread 已经提供了通用的地址对齐辅助宏 RT_ALIGN_DOWN(),继续保留手工位运算会增加风格不一致和维护成本。

因此,提交此 PR,将 cache 操作中的地址向下对齐逻辑统一替换为公共宏实现,提升代码可读性和一致性。

你的解决方案是什么 (what is your solution)

本 PR 做了以下调整:

  1. rt_hw_cpu_icache_ops() 中,将:

    • 手工位运算地址对齐逻辑
    • 替换为 RT_ALIGN_DOWN((rt_uint32_t)addr, L1CACHE_LINESIZE_BYTE)
  2. rt_hw_cpu_dcache_ops() 中,将:

    • 手工位运算地址对齐逻辑
    • 替换为 RT_ALIGN_DOWN((rt_uint32_t)addr, L1CACHE_LINESIZE_BYTE)
  3. 保持后续 size_byte 的计算方式和 cache 操作流程不变,确保行为逻辑一致;

  4. 同步更新文件头版权年份。

通过以上调整,代码语义更加直观,也更符合 RT-Thread 中通用对齐宏的使用习惯,便于后续维护。

请提供验证的bsp和config (provide the config and bsp)

  • BSP:

    • 请填写已验证的 BSP 路径,例如 bsp/stm32/stm32h750-artpi
  • .config:

    • 与 Cortex-M7 和 cache 相关的配置项
    • 例如启用 cache 的相关配置
  • action:

    • 请填写你自己仓库 PR 分支触发的 CI / Action 链接

@github-actions
Copy link

👋 感谢您对 RT-Thread 的贡献!Thank you for your contribution to RT-Thread!

为确保代码符合 RT-Thread 的编码规范,请在你的仓库中执行以下步骤运行代码格式化工作流(如果格式化CI运行失败)。
To ensure your code complies with RT-Thread's coding style, please run the code formatting workflow by following the steps below (If the formatting of CI fails to run).


🛠 操作步骤 | Steps

  1. 前往 Actions 页面 | Go to the Actions page
    点击进入工作流 → | Click to open workflow →

  2. 点击 Run workflow | Click Run workflow

  • 设置需排除的文件/目录(目录请以"/"结尾)
    Set files/directories to exclude (directories should end with "/")
  • 将目标分支设置为 \ Set the target branch to:pr/02-sdmmc
  • 设置PR number为 \ Set the PR number to:11250
  1. 等待工作流完成 | Wait for the workflow to complete
    格式化后的代码将自动推送至你的分支。
    The formatted code will be automatically pushed to your branch.

完成后,提交将自动更新至 pr/02-sdmmc 分支,关联的 Pull Request 也会同步更新。
Once completed, commits will be pushed to the pr/02-sdmmc branch automatically, and the related Pull Request will be updated.

如有问题欢迎联系我们,再次感谢您的贡献!💐
If you have any questions, feel free to reach out. Thanks again for your contribution!

@wdfk-prog
Copy link
Contributor Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant