Some cleanups to object manager and I/O context code

Signed-off-by: Alex Smith <alex@alex-smith.me.uk>
Fix static_assert macro definition

Signed-off-by: Alex Smith <alex@alex-smith.me.uk>
Use a recursive mutex on notifiers

With the upcoming object event changes, object_event_signal() may call
the object type's unwait function. When the event is implemented using
notifiers, the former is called from notifier_run() and the latter will
call notifier_unregister(), so using a recursive mutex allows this to
happen. Also clean up the notifier code a bit.

Signed-off-by: Alex Smith <alex@alex-smith.me.uk>
Add container_of() macro

Given a pointer to a structure which is embedded within another
structure, gets a pointer to the parent structure.

Signed-off-by: Alex Smith <alex@alex-smith.me.uk>
Use static_assert macro rather than _Static_assert directly

Signed-off-by: Alex Smith <alex@alex-smith.me.uk>
Tidy up object event API, implement asynchronous event callbacks

Replaced the signalled member of object_event_t with a flags field.
This has a signalled flag, as well as a new OBJECT_EVENT_ERROR flag
which is set to indicate which event caused the error when an error is
returned from kern_object_wait().

Also added is OBJECT_EVENT_EDGE which will implement edge-triggered
wait semantics. The current level-triggered behaviour will signal an
event immediately if the event condition is true at the time that
kern_object_wait() is called. In edge-triggered mode the event will
only be signalled on a change of the event condition from false to
true. This is not implemented completely by this commit, it is added
in following commits.

Finally, implemented asynchronous event callbacks. Threads can register
a callback function for an object event which will be executed when the
event occurs via a thread interrupt. They are registered with an
interrupt priority, which means that they can be temporarily blocked by
changing the IPL. Callbacks work in edge-triggered mode only for the
moment, as supporting level-triggered mode for them would be somewhat
more complex.

Signed-off-by: Alex Smith <alex@alex-smith.me.uk>
Implement edge-triggered event waiting

Mostly just minor changes in the object type wait callbacks. Also
changed the semantics of the timer object event. Previously the fired
state would be cleared when the event is received by a wait call. Now
the behaviour depends on the timer mode: for one shot mode, the fired
state remains set until the timer is restarted or stopped, so a level-
triggered wait after the event has fired will always be signalled
immediately. For periodic mode, it is cleared after each period, so
it always has edge-triggered behaviour.

Signed-off-by: Alex Smith <alex@alex-smith.me.uk>
Add event callback test program

Signed-off-by: Alex Smith <alex@alex-smith.me.uk>