Comments (4)
While developing mini-arm-os
, I encountered a bug triggered by GCC optimizations (version 5.x).
You can check again for the generated instructions by recent GNU toolchain. Such workaround should be eliminated.
from mini-arm-os.
@lecopzer, any further evidence?
from mini-arm-os.
Sorry for suspending this issue.
PendSV is not only an interrupt handler but where the context switch happends
r7 is usually used to preserve system call number (isr number).
Without __attribute__, it looks like:
80005c8: b480 push {r7}
80005ca: af00 add r7, sp, #0
/* Save the old task's context */
asm volatile("mrs r0, psp\n"
80005cc: f3ef 8009 mrs r0, PSP
But our pendsv_handler
has context switch code at end of
asm volatile("mov r0, %0\n" : : "r" (tasks[lastTask].stack));
40 /* Restore the new task's context and jump to the task */
41 asm volatile("ldmia r0!, {r4-r11, lr}\n"
42 "msr psp, r0\n"
43 "bx lr\n");
The core register was changed here and we even have our own return
code (line 41 to 43)
that the compiler will never know this.
Compiler don't know we handle core register and stack in C function in our own
and will never assume user "corrupt" calling convention.
Compiler is doing its jobs performing regular push r7
and pop r7
Even in 7.2.1 arm-eabi
compiler, there is still push r7
in pendsv_handler
So it's reasonable to have naked
attribute where we do the context switch or have our own register/stack handling in C function and should not be a FIXME.
from mini-arm-os.
I agree. Please send another pull request to revise the existing C comment to reflect its necessity. It is no longer "FIXME". Instead, it appears with "Caution".
from mini-arm-os.
Related Issues (10)
- 01-HelloWorld cannot use "Press Ctrl-A and then X to exit QEMU" in ubuntu 14.04 x86_64 guest by virtualbox HOT 1
- Irrational exception return behavior HOT 2
- Functions declared with the naked attribute also require basic asm HOT 1
- https://gcc.gnu.org/onlinedocs/gcc/ARM-Function-Attributes.html
- Wrong processor mode in first time exception return
- Should not force LR to specific EXC_RETURN value HOT 1
- Support for MPU HOT 2
- Question about naked attribute HOT 4
- No actual guides for implementing and running OS HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mini-arm-os.