Events are handled by EventHandlers which can rely either on
portals or, when delivered inside the kernel, on function calls. The
default handler simply does nothing.
<Off event handler. >= (U->)
// An event handler.
class off_EventHandler {
public:
// Calls the handler
virtual err_t operator()(const off_EventReq *ev, vm_size_t s) {
(void)ev; (void)s;
return EOK;
}
};
class off_KrnEventHandler : public off_EventHandler {
public:
<Other public methods of off_KrnEventHandler. >
// Calls the handler
virtual err_t operator()(const off_EventReq *ev, vm_size_t s);
private:
<Other private members of off_KrnEventHandler. >
};
class off_UsrEventHandler : public off_EventHandler {
public:
<Other public methods of off_UsrEventHandler. >
// Calls the handler
virtual err_t operator()(const off_EventReq *ev, vm_size_t s);
private:
<Other private members of off_UsrEventHandler. >
};
Definesoff_EventHandler,off_KrnEventHandler,off_UsrEventHandler(links are to index).
There is a null handler defined to do nothing.
<Off null event handler. >= (U->) const off_EventHandler OFF_NULL_HANDLER;
But usually, event handlers will be created either to dispatch to a local function or to a system portal.
<Other public methods of off_KrnEventHandler. >= (<-U)
// Creates an in-kernel event handler.
off_KrnEventHandler(off_PrtlHandlerFn *h);
<Other public methods of off_UsrEventHandler. >= (<-U)
// Creates an in-kernel event handler.
off_UsrEventHandler(const off_prtl_id_t &p);
Where PrtlHandlerFn is a local function servicing the portal
invocation. The event handler constructor simply records the handler.
<off_KrnEventHandler::off_KrnEventHandler implementation. >= (U->)
// Creates an in-kernel event handler.
off_KrnEventHandler::off_KrnEventHandler(off_PrtlHandlerFn *h) :
k_hndlr(h)
{;}
<Other private members of off_KrnEventHandler. >= (<-U)
off_PrtlHandlerFn *k_hndlr; // The handling function.
<off_UsrEventHandler::off_UsrEventHandler implementation. >= (U->)
// Creates a cross-domain event handler.
off_UsrEventHandler::off_UsrEventHandler(const off_prtl_id_t &p) :
u_hndlr(p)
{;}
<Other private members of off_UsrEventHandler. >= (<-U)
off_prtl_id_t u_hndlr; // The handling portal.
<off_KrnEventHandler::operator() implementation. >= (U->)
err_t off_KrnEventHandler::operator()(const off_EventReq *ev, vm_size_t s)
{
return (*k_hndlr)(s,(void*)ev);
}
<off_UsrEventHandler::operator() implementation. >= (U->)
err_t off_UsrEventHandler::operator()(const off_EventReq *ev, vm_size_t s)
{
(void)ev;
return ENOSYS;
}