This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Get Stack init info at runtime

Hi,

Is there any way to get information about stack and heap at runtime in a C function? I'm looking for a var/table/way to get Stack_Base, Heap_base, Stack_limit and heap_limit at runtime.

That's because I'm trying to make a very very small multitasking kernel for Cortex-M3 and I need somehow to know the Stack memory avail for my alloc routines.

Regards,

Christos Houtouridis,
Electrical Engineer

Parents
  • Dear Per,

    For start I have to say that I agree with both of your messages. It is exactly how you describe it.
    Now. You said
    "There is a startup file, where _you_ specify stack size and heap size"

    And this is the reason I need to pass this _user_demand_ to my kernel. I dont want to specify the avail RAM sizes in two places both the startupxxx.s and in some xxconfig.h header. I need to know how much memory the _user_ (probably me again) decide to left for stack/heap in the startupxxx.s. So my kernel will read this information and do its magic. That's why I ask for a way to read the Stack_base etc...(the labels used in the startup file).

    Of course there are ways like "read the SP just after the system init" or "do a search using exception handler", or even "do specify eventually RAM sizes and addresses in two places", but I seek for a much more elegant way.

    I have to say that this is not the first time i make my own kernel. I have made one for x86. It is just the first time that i build something so freaking small. And I will make it a small module to use it beside any "my-kernel-compatible" project.

    Regards,

    Christos Houtouridis

Reply
  • Dear Per,

    For start I have to say that I agree with both of your messages. It is exactly how you describe it.
    Now. You said
    "There is a startup file, where _you_ specify stack size and heap size"

    And this is the reason I need to pass this _user_demand_ to my kernel. I dont want to specify the avail RAM sizes in two places both the startupxxx.s and in some xxconfig.h header. I need to know how much memory the _user_ (probably me again) decide to left for stack/heap in the startupxxx.s. So my kernel will read this information and do its magic. That's why I ask for a way to read the Stack_base etc...(the labels used in the startup file).

    Of course there are ways like "read the SP just after the system init" or "do a search using exception handler", or even "do specify eventually RAM sizes and addresses in two places", but I seek for a much more elegant way.

    I have to say that this is not the first time i make my own kernel. I have made one for x86. It is just the first time that i build something so freaking small. And I will make it a small module to use it beside any "my-kernel-compatible" project.

    Regards,

    Christos Houtouridis

Children