RIOT icon indicating copy to clipboard operation
RIOT copied to clipboard

sys/bhp_*: add initial support for generic Bottom Half Processor

Open jia200x opened this issue 3 years ago • 0 comments

Contribution description

This PR addresses this comment and adds a generic Bottom Half Processor mechanism to be used by any device that requires ISR offloading. The mechanism is agnostic to the underlying processing module (events, messages, thread flags), as it simply defines an interface for storing an (IRQ) handler and a context.

On top of that, a dedicated Bottom Half Processor module (bhp_*) exposes an init function that configures the underlying mechanism and setups the callback. Then, the device driver init function sets the ISR callback to bhp_*_cb and passes the bhp_*_t descriptor as the ISR context. The module will take care of the rest.

Based on this, I implemented an event based Bottom Half Processor (see bhp_event), which allows to offload the handler to an event queue. In the future, there could be more of these implementations (bhp_thread_flags, bhp_msg, bhp_mbox, etc).

Testing procedure

Unittests should pass.

Issues/PRs references

It will be come extremely handy to implement network-stack-and-device-agnostic IRQ offloaders for SPI radios (https://github.com/RIOT-OS/RIOT/pull/18383)

jia200x avatar Aug 10 '22 15:08 jia200x

I have a follow up PR that adapts #18383 to this mechanism. See it in action

jia200x avatar Aug 10 '22 15:08 jia200x

@leandrolanzieri, @MrKevinWeiss could you please check if the Kconfig modelling looks ok?

jia200x avatar Aug 10 '22 15:08 jia200x

if this is merged before #18383, I can adapt the kinetis radio to this BHP mechanism

jia200x avatar Aug 11 '22 08:08 jia200x

thanks for the review!

jia200x avatar Aug 12 '22 07:08 jia200x

The mechanism is agnostic to the underlying processing module (events, messages, thread flags), as it simply defines an interface for storing an (IRQ) handler and a context.

Is it that simple? The memory model of the four methods is very different.

kaspar030 avatar Aug 17 '22 19:08 kaspar030

The mechanism is agnostic to the underlying processing module (events, messages, thread flags), as it simply defines an interface for storing an (IRQ) handler and a context.

Is it that simple? The memory model of the four methods is very different.

It is agnostic from an interface point of view. Neither the device nor the network stack care about which underlying mechanism is being used and these can be exchanged at any time.

jia200x avatar Aug 17 '22 21:08 jia200x