X-Git-Url: https://codewiz.org/gitweb?a=blobdiff_plain;f=mware%2Fevent.h;h=5bc94e9ef3b875ad6ce84654ec90867273271a2c;hb=HEAD;hp=4270e94698100af607168b8e6a1a0590155bc0c7;hpb=5b9ba07bc069e4403dd5713b6be6c5f98f8a86a7;p=bertos.git diff --git a/mware/event.h b/mware/event.h deleted file mode 100644 index 4270e946..00000000 --- a/mware/event.h +++ /dev/null @@ -1,140 +0,0 @@ -/** - * \file - * - * - * \brief Events handling - * - * This module implements a common system for executing - * a user defined action calling a hook function. - * - * \version $Id$ - * - * \author Bernardo Innocenti - */ - -#ifndef KERN_EVENT_H -#define KERN_EVENT_H - -#include -#include - -#if CONFIG_KERNEL - #include - #if defined(CONFIG_KERN_SIGNALS) && CONFIG_KERN_SIGNALS - #include - #endif - - /* Forward decl */ - struct Process; -#endif - - -/// User defined callback type -typedef void (*Hook)(void *); - -typedef struct Event -{ - void (*action)(struct Event *); - union - { -#if defined(CONFIG_KERN_SIGNALS) && CONFIG_KERN_SIGNALS - struct - { - struct Process *sig_proc; /* Process to be signalled */ - sigbit_t sig_bit; /* Signal to send */ - } Sig; -#endif - struct - { - Hook func; /* Pointer to softint hook */ - void *user_data; /* Data to be passed back to user hook */ - } Int; - } Ev; -} Event; - -void event_hook_ignore(Event *event); -void event_hook_signal(Event *event); -void event_hook_softint(Event *event); - -/** Initialize the event \a e as a no-op */ -#define event_initNone(e) \ - ((e)->action = event_hook_ignore) - -/** Same as event_initNone(), but returns the initialized event */ -INLINE Event event_createNone(void); -INLINE Event event_createNone(void) -{ - Event e; - e.action = event_hook_ignore; - return e; -} - -/** Initialize the event \a e with a software interrupt (call function \a f, with parameter \a u) */ -#define event_initSoftInt(e,f,u) \ - ((e)->action = event_hook_softint,(e)->Ev.Int.func = (f), (e)->Ev.Int.user_data = (u)) - -/** Same as event_initSoftInt(), but returns the initialized event */ -INLINE Event event_createSoftInt(Hook func, void *user_data) -{ - Event e; - e.action = event_hook_softint; - e.Ev.Int.func = func; - e.Ev.Int.user_data = user_data; - return e; -} - - -#if defined(CONFIG_KERN_SIGNALS) && CONFIG_KERN_SIGNALS - -/** Initialize the event \a e with a signal (send signal \a s to process \a p) */ -#define event_initSignal(e,p,s) \ - ((e)->action = event_hook_signal,(e)->Ev.Sig.sig_proc = (p), (e)->Ev.Sig.sig_bit = (s)) - -/** Same as event_initSignal(), but returns the initialized event */ -INLINE Event event_createSignal(struct Process *proc, sigbit_t bit) -{ - Event e; - e.action = event_hook_signal; - e.Ev.Sig.sig_proc = proc; - e.Ev.Sig.sig_bit = bit; - return e; -} - -#endif - -/** Trigger an event */ -INLINE void event_do(struct Event *e) -{ - e->action(e); -} - -#endif /* KERN_EVENT_H */