Skip to content

Conversation

messigogogo
Copy link
Contributor

@messigogogo messigogogo commented Jan 31, 2024

拉取/合并请求描述:(PR description)

[

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

#8469 解决issue

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

对cortex-a cpu的启动步骤仿照aarch64的风格进行了整理,使逻辑更加清晰,并解决了上述问题。已在qemu-vexpress-a9,raspi4-32,phytium开发板上进行测试,目前可以正常启动

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

  • BSP:
    360866a0b7bc56143fc1e44d5ee778a
    f40ff977c306726581486ea388fb356
  • .config:
  • action:

]

当前拉取/合并请求的状态 Intent for your PR

必须选择一项 Choose one (Mandatory):

  • 本拉取/合并请求是一个草稿版本 This PR is for a code-review and is intended to get feedback
  • 本拉取/合并请求是一个成熟版本 This PR is mature, and ready to be integrated into the repo

代码质量 Code Quality:

我在这个拉取/合并请求中已经考虑了 As part of this pull request, I've considered the following:

  • 已经仔细查看过代码改动的对比 Already check the difference between PR and old code
  • 代码风格正确,包括缩进空格,命名及其他风格 Style guide is adhered to, including spacing, naming and other styles
  • 没有垃圾代码,代码尽量精简,不包含#if 0代码,不包含已经被注释了的代码 All redundant code is removed and cleaned up
  • 所有变更均有原因及合理的,并且不会影响到其他软件组件代码或BSP All modifications are justified and not affect other components or BSP
  • 对难懂代码均提供对应的注释 I've commented appropriately where code is tricky
  • 代码是高质量的 Code in this PR is of high quality
  • 已经使用formatting 等源码格式化工具确保格式符合RT-Thread代码规范 This PR complies with RT-Thread code specification

@BernardXiong
Copy link
Member

Good Job!

@BernardXiong
Copy link
Member

[cpp_check.py 28 INFO] libcpu/arm/cortex-a/mmu.c:211:30: error: Overflow in pointer arithmetic, NULL pointer is subtracted. [nullPointerArithmetic]
rt_mpr_start = (void *)0 - rt_mpr_size;

这里也帮忙做个调整吧,原来的代码有些不太规范

@messigogogo
Copy link
Contributor Author

[cpp_check.py 28 INFO] libcpu/arm/cortex-a/mmu.c:211:30: error: Overflow in pointer arithmetic, NULL pointer is subtracted. [nullPointerArithmetic]
rt_mpr_start = (void *)0 - rt_mpr_size;

这里也帮忙做个调整吧,原来的代码有些不太规范

已修改 rt_mpr_start = (void *)((rt_size_t)0 - rt_mpr_size);

@mysterywolf mysterywolf added the v5.1.0 version 5.1.0 (planned to be released by the end of 2023) label Feb 18, 2024
@BernardXiong BernardXiong changed the title [libcpu/arm/cortex-a]修改arm/cortex-a启动方式,解决cortex-a开启SMP工作异常问题 🎯 [libcpu/arm/cortex-a]修改arm/cortex-a启动方式,解决cortex-a开启SMP工作异常问题 Feb 19, 2024
@mysterywolf
Copy link
Member

你好 这份代码先挂在这里 等#8537 合并之后再麻烦您重新rebase和测试一下~

@mysterywolf mysterywolf added the in progress PR/issue in progress. label Feb 20, 2024
@messigogogo
Copy link
Contributor Author

你好 这份代码先挂在这里 等#8537 合并之后再麻烦您重新rebase和测试一下~

好的,这份代码和刚才合入的有一些冲突,我只是重新修改提交一下

@messigogogo
Copy link
Contributor Author

messigogogo commented Feb 21, 2024

你好 这份代码先挂在这里 等#8537 合并之后再麻烦您重新rebase和测试一下~

你们近期会对#8537 进行合入吗?我看那边改动比较大?

@BernardXiong
Copy link
Member

你好 这份代码先挂在这里 等#8537 合并之后再麻烦您重新rebase和测试一下~

你们近期会对#8537 进行合入吗?我看那边改动比较大?

在推进着合并,然后开始准备发版本。

@mysterywolf
Copy link
Member

#8537 已经合并 麻烦重新rebase到最新基线并测试一下把~

@@ -189,27 +189,28 @@ void rt_hw_board_aarch64_init(void)
}
#else


extern void rt_hw_mmu_init(void) ;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

最好是放到头文件里面。否则后续原型修改很容易不一致,而且发现不了。

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

放在mmu.h里了

@@ -64,12 +64,16 @@ void idle_wfi(void)
asm volatile ("wfi");
}


extern void rt_hw_mmu_init(void);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

同理,应该是引用个头文件。

wfe
b _halt
.weak rt_asm_cpu_id
rt_asm_cpu_id:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个命名得改成 rt_hw_cpu_id

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

已修改

Comment on lines 32 to 34
.macro get_phy, reg, symbol
ldr \reg, =\symbol
add \reg, pv_off
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个 pv_off 最好是个参数,否则用这个宏的时候,就依赖于 pv_off 这个寄存器的初始化。后面加代码,或者维护起来容易疏忽。

Suggested change
.macro get_phy, reg, symbol
ldr \reg, =\symbol
add \reg, pv_off
.macro get_phy, reg, symbol, _pvoff
ldr \reg, =\symbol
add \reg, \_pvoff

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

.macro get_phy, reg, symbol, _pvoff
ldr \reg, =\symbol
add \reg, _pvoff
.endm
/Calculate the offset between the physical address and the virtual address of the "_reset"./
.macro get_pvoff, tmp, out
ldr \tmp, =_reset
adr \out, _reset
sub \out, \out, \tmp
.endm

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这两个函数修改成这样可以吗?

Comment on lines 50 to 52
ldr r0, =_reset
adr pv_off, _reset
sub pv_off, pv_off, r0
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

如果修改了,这个就可以用 get_pvoff 宏替换。

Comment on lines 37 to 41
.macro get_pvoff, tmp, out
ldr \tmp, =_reset
get_phy \out, _reset
sub \out, \out, \tmp
.endm
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

而且,按照现在的参数设计, get_pvoff 依赖了 get_phy,get_phy 依赖了 pv_off。虽然 pv_off 可以单独先初始化,结果上也对。但是逻辑上很奇怪。

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

.macro get_pvoff, tmp, out
ldr \tmp, =_reset
adr \out, _reset
sub \out, \out, \tmp
.endm

Comment on lines 184 to 185
get_phy r0, init_mtbl
get_pvoff r2,r1
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里就是 get_phy 的参数设计很容易造成混乱的例子。get_phy 依赖于 pvoff 的,但是这里又先计算了 get_phy,然后计算一个新的 pvoff。看的时候就很别扭。

如果给 get_phy 加入 pvoff 作为第三个参数,修改后个人感觉是更清晰可读的。

Suggested change
get_phy r0, init_mtbl
get_pvoff r2,r1
get_phy r0, init_mtbl, pv_off
mov r1, pv_off

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

请您再检查一下

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

我没别的建议了 👍

@BernardXiong BernardXiong merged commit 76202e2 into RT-Thread:master Mar 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in progress PR/issue in progress. v5.1.0 version 5.1.0 (planned to be released by the end of 2023)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants