简体   繁体   English

Arm Cortex-M4定制OS设计

[英]Arm cortex-m4 custom os desgin

I am writing a small os for ARM Cortex-M4 core and have some doubts. 我正在为ARM Cortex-M4内核编写一个小型操作系统,并且对此有所怀疑。 I decided to place os functionalities through Supervisor Call(SVC) where I keep and maintain all kernel objects and kernel functions. 我决定通过Supervisor Call(SVC)来放置os功能,以保留和维护所有内核对象和内核功能。

But, is this a good idea because all kernel code executes and occupies user task stack? 但是,这是个好主意,因为所有内核代码都执行并占用用户任务堆栈吗?

Only thing that comes to my mind is that through supervisor call jump to kernel stack and lock scheduler while executing kernel code. 我唯一想到的是在执行内核代码时,通过超级用户调用跳转到内核堆栈并锁定调度程序。 Is this approach a good one? 这是一个好方法吗?

On a Cortex-M you have a Process Stack Pointer(PSP) and a Main Stack Pointer(MSP). 在Cortex-M上,您有一个过程堆栈指针(PSP)和一个主堆栈指针(MSP)。 Interrupts use the Main Stack Pointer and the tasks should use the process stack pointer. 中断使用主堆栈指针,而任务应使用进程堆栈指针。 Therefore any kernel work done in the SVC uses the MSP so should not interfere with the tasks stacks which use the PSP. 因此,在SVC中完成的任何内核工作都使用MSP,因此不应干扰使用PSP的任务堆栈。 When switching tasks you set the PSP to the new stack. 切换任务时,请将PSP设置为新堆栈。 I would read the Exception Handling section of the Cortex-M4 Generic User guide. 我会阅读《 Cortex-M4通用用户指南》的“异常处理”部分。 Also I would recommend getting and reading The Definitive Guide to the ARM Cortex M3/M4 as this has a good section on RTOS's. 另外,我建议阅读并阅读《 ARM Cortex M3 / M4权威指南》,因为其中有关于RTOS的很好的部分。 The Cortex's were design with RTOS's and provide a lot of useful features. Cortex是与RTOS一起设计的,并提供了许多有用的功能。

Note: Unless you are doing this as a learning exercise, or just really want to write your own OS, you would be better of using something like FreeRTOS which is very well tested and provides all the features you are ever likely to use. 注意:除非您是作为学习练习来这样做的,或者只是真的想编写自己的OS,否则最好使用FreeRTOS之类的东西,该东西经过了很好的测试,并提供了您可能会使用的所有功能。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM