chSysInit-Hook and/or chSysInit-Flag

This forum is dedicated to feedback, discussions about ongoing or future developments, ideas and suggestions regarding the ChibiOS projects are welcome. This forum is NOT for support.
User avatar
levrik
Posts: 26
Joined: Wed Dec 21, 2011 7:35 am

chSysInit-Hook and/or chSysInit-Flag

Postby levrik » Wed Apr 03, 2013 8:29 pm

Hi there,
i wonder if there is such a thing like a Hook for own code in chSysInit() or a flag which indicates that ChibiOS is up and ready to provide all system-functions.
Background of this question is that i'm using ChibiOS in conjunction with C++ and TLSF. Thread-safe allocations are implemented with mutexes. But the "operator new()"-content has to know whether or not chibi is up and running and therefore the mutex-functions are functional, because allocations can also happen before the OS has startet (for example in static constructors ). It would be very nice if the system could provide some kind of information about the status of Chibi's initialisation status.

Thanks

User avatar
Giovanni
Site Admin
Posts: 14704
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 1146 times
Been thanked: 960 times

Re: chSysInit-Hook and/or chSysInit-Flag

Postby Giovanni » Wed Apr 03, 2013 8:44 pm

Hi,

The system is up after invoking chSysInit() so it is easy enough to set a flag just before calling chSysInit() and check the flag from code called by static initializers. You could also check the links in the structure rlist, those are guaranteed to be zero before chSysInit() and not zero after.

Giovanni

User avatar
levrik
Posts: 26
Joined: Wed Dec 21, 2011 7:35 am

Re: chSysInit-Hook and/or chSysInit-Flag

Postby levrik » Thu Apr 04, 2013 10:05 am

Hi Giovanny, thank you for your answer.
Giovanni wrote:The system is up after invoking chSysInit() so it is easy enough to set a flag just before calling chSysInit() and check the flag from code called by static initializers.
I know this possibility and have implemented it this way already. But there are so many nice possibilities for placing board-individual code in ChibiOS ( for example the diverse *_ERROR_HOOKs, the __early_init()-function, boardInit()-function and so on ), so i hoped to find a similar place to put own system-dependant init-code into the chSysInit()-function without touching it.
Giovanni wrote:You could also check the links in the structure rlist, those are guaranteed to be zero before chSysInit() and not zero after.
I don't like working system-internal-structures directly without setters/getters, even to check values. If there is an update wich changes the layout, the check may fail.


Return to “Development and Feedback”

Who is online

Users browsing this forum: No registered users and 21 guests