Git Product home page Git Product logo

Comments (4)

jserv avatar jserv commented on August 19, 2024

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.

jserv avatar jserv commented on August 19, 2024

@lecopzer, any further evidence?

from mini-arm-os.

lecopzer avatar lecopzer commented on August 19, 2024

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.

jserv avatar jserv commented on August 19, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.