Git Product home page Git Product logo

Comments (3)

alilee avatar alilee commented on April 28, 2024

This is a very interesting question, but also remember small functions may not use the stack.

This does come up - if I compile with opt-level=0 then I think my code hangs for this reason.

from rust-raspberrypi-os-tutorials.

andre-richter avatar andre-richter commented on April 28, 2024

You‘re right.

Setting the stack pointer should ideally be done in early boot assembly before the first function call happens.
You cannot rule out that the compiler does not honor the inline attributes in this code snippet.

I threw out the assembly here nevertheless, mostly “because we can”, because I like to have as much Rust code as possible in this toy-kernel 😎.
We have emulation for testing and a corresponding CI pipeline that would raise a flag if the compiler inserts function calls here, because the booting would fail early on.
Also, for functions that boil down to very few lines of assembly (in the SP case a single one), you can be quite optimistic that the compiler honors the inline suggestion.

In the original version of this particular tutorial I mentioned that we would need to manually check that function calls don’t happen here.
I wanted to mention it in the new version here too, it didn’t come around porting the text over yet.

Hope that helps!

Best,
Andre

from rust-raspberrypi-os-tutorials.

imsut avatar imsut commented on April 28, 2024

@andre-richter -- thx for the explanation and the pointer to the original post!

mostly “because we can”, because I like to have as much Rust code as possible in this toy-kernel sunglasses.

makes sense :)

from rust-raspberrypi-os-tutorials.

Related Issues (20)

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.