Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
Discussion options

多核移植时以邮箱为例
/src/ipc.c/

level = rt_hw_interrupt_disable();
      /*include/rthw.h/
     #define rt_hw_interrupt_disable rt_cpus_lock
     rt_cpus_lock
	level = rt_hw_local_irq_disable();

这里的rt_hw_local_irq_disable函数并没有定义,搜索整个代码仓库也没有发现定义的地方。
这个是需要smp移植的时候实现吗?

You must be logged in to vote

找到了对宏定义的理解不深刻,本质是符号替换,在汇编中不应该使用语言方式去理解
libcpu/aarch64/common/context_gcc.S

#ifdef RT_USING_SMP
#define rt_hw_interrupt_disable rt_hw_local_irq_disable
#define rt_hw_interrupt_enable rt_hw_local_irq_enable
#endif

.text
/*
 * rt_base_t rt_hw_interrupt_disable();
 */
.globl rt_hw_interrupt_disable
rt_hw_interrupt_disable:
    MRS      X0, DAIF
    MSR      DAIFSet, #3
    DSB      SY
    RET

在编译时汇编文件中的rt_hw_interrupt_disable符号会被rt_hw_local_irq_disable替换掉,这样rt_hw_interrupt_disable定义的汇编代码在编译后的函数名字为rt_hw_local_irq_disable。

使用xxd查看context_gcc.o可以印证

Replies: 2 comments

Comment options

找到了对宏定义的理解不深刻,本质是符号替换,在汇编中不应该使用语言方式去理解
libcpu/aarch64/common/context_gcc.S

#ifdef RT_USING_SMP
#define rt_hw_interrupt_disable rt_hw_local_irq_disable
#define rt_hw_interrupt_enable rt_hw_local_irq_enable
#endif

.text
/*
 * rt_base_t rt_hw_interrupt_disable();
 */
.globl rt_hw_interrupt_disable
rt_hw_interrupt_disable:
    MRS      X0, DAIF
    MSR      DAIFSet, #3
    DSB      SY
    RET

在编译时汇编文件中的rt_hw_interrupt_disable符号会被rt_hw_local_irq_disable替换掉,这样rt_hw_interrupt_disable定义的汇编代码在编译后的函数名字为rt_hw_local_irq_disable。

使用xxd查看context_gcc.o可以印证

You must be logged in to vote
0 replies
Answer selected by aozima
Comment options

我現在也在做rtthread在qemu-virt64-riscv的雙核啓動,但是在運行到(gdb) info thread
Id Target Id Frame

  • 1 Thread 1.1 (CPU#0 [running]) rt_cpus_lock () at D:\work\rt-thread-4.1.0\src\cpu.c:171
    2 Thread 1.2 (CPU#1 [running]) wait_for_flag () at D:\work\rt-thread-4.1.0\libcpu\risc-v\virt64\startup_gcc.S:85 (gdb) thread,一直卡在這裏,代碼不變,我把它改成單核的就沒有問題,而且一直沒有進入到main_thread_entry,請問你有運到過這樣的問題嗎
You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
🙏
Q&A
Labels
None yet
2 participants
Morty Proxy This is a proxified and sanitized view of the page, visit original site.