Kernel state?

ChibiOS public support forum for all topics not covered by a specific support forum.

Moderators: RoccoMarco, lbednarz, tfAteba

Post Reply
avrhack
Posts: 140
Joined: Tue Dec 24, 2013 1:42 pm
Has thanked: 17 times
Been thanked: 3 times

Kernel state?

Post by avrhack »

I've got a function that calls a number of APIs and I want it to be usable from I-State as well as normal-state, by checking what state it has been called from and invoking the appropriate I-class or normal API.

However I can't find an API that gives me the current kernel state! I've looked in the documentation, searched this forum, nada.

Sure it's there and just me being stupid, so could anyone point me to it please?

Thanks.
User avatar
Giovanni
Site Admin
Posts: 14895
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 997 times

Re: Kernel state?

Post by Giovanni »

There isn't one, usually you know in what context runs your code.

The kernel 3.0 has support for "universal" functions, you may switch to that one.

Giovanni
avrhack
Posts: 140
Joined: Tue Dec 24, 2013 1:42 pm
Has thanked: 17 times
Been thanked: 3 times

Re: Kernel state?

Post by avrhack »

Giovanni wrote:There isn't one, usually you know in what context runs your code.

The kernel 3.0 has support for "universal" functions, you may switch to that one.

Giovanni


Yeah I've ended up adding another parameter to the function I want to 'share' and it invokes the appropriate I-class or normal API accordingly. All working now.

As an aside, as an enhancement suggestion, is it worth considering a new class of API that can be called from either context and figures things out itself? Would make things a lot easier than the current API situation? It could be done with a naming convention to sit alongside the current API to make migration easy?
User avatar
Giovanni
Site Admin
Posts: 14895
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 997 times

Re: Kernel state?

Post by Giovanni »

Hi,

3.0 has a convention for universal APIs, the "X" suffix. Any I-Class function can be turned in X-Class by putting it in between: chSysGetStatusAndLockX() and chSysRestoreStatusX().

Giovanni
Post Reply