RKH
|
Files | |
file | rkhevt.h |
Defines event data type and other related macros. | |
file | rkhfwk_dynevt.h |
Specifies the interface of dynamic event support. | |
Data Structures | |
struct | RKH_EVT_T |
Represents events without parameters. More... | |
Macros | |
#define | RKH_EVT_CAST(_e) ((RKH_EVT_T *)(_e)) |
Perform cast to pointer to RKH event structure (RKH_EVT_T*). | |
#define | RKH_ALLOC_EVT(et, e, sender_) (et *)rkh_fwk_ae((RKH_ES_T)sizeof(et),(RKH_SIG_T)(e), sender_) |
This macro dynamically creates a new event of type et with its signal. More... | |
#define | RKH_FWK_GC(e, sender_) rkh_fwk_gc(e, sender_) |
Recycle a dynamic event. More... | |
#define | RKH_FWK_RSV(e) rkh_fwk_reserve(e) |
Reserve the dynamic event to be recycled. More... | |
#define | RKH_SET_STATIC_EVENT(ev_obj, ev_sig) MK_SET_EVT(ev_obj, ev_sig) |
This macro initialize an event e with es signal and establishes it as one static event. More... | |
#define | RKH_STATIC_EVENT(ev_obj, ev_sig) MK_EVT(ev_obj, ev_sig) |
This macro declares and initializes the event structure ev_ob with ev_sig signal number and establishes it as one static event. More... | |
#define | RKH_ROM_STATIC_EVENT(ev_obj, ev_sig) MK_ROM_EVT(ev_obj, ev_sig) |
This macro declares and initializes the event structure ev_ob with ev_sig signal number and establishes it as one static event. More... | |
#define | RKH_INIT_STATIC_EVT(ev_sig) MK_EVT_STRUCT(ev_sig) |
Initializes the attibutes of a RKH's event object structure. More... | |
Functions | |
void | rkh_dynEvt_init (void) |
Initializes the dynamic event manager. | |
void | rkh_fwk_registerEvtPool (void *sstart, rui32_t ssize, RKH_ES_T esize) |
Registers a new event pool into the event pool list. More... | |
RKH_EVT_T * | rkh_fwk_ae (RKH_ES_T esize, RKH_SIG_T e, const void *const sender) |
Allocates an event from the previously created event pool. More... | |
void | rkh_fwk_gc (RKH_EVT_T *e, const void *const sender) |
Recycle a dynamic event. More... | |
void | rkh_fwk_reserve (RKH_EVT_T *e) |
Reserve the dynamic event to be recycled. More... | |
#define RKH_ALLOC_EVT | ( | et, | |
e, | |||
sender_ | |||
) | (et *)rkh_fwk_ae((RKH_ES_T)sizeof(et),(RKH_SIG_T)(e), sender_) |
This macro dynamically creates a new event of type et with its signal.
The basic policy is to allocate the event from the first pool that has a block size big enough to fit the requested event size. RKH can manage up to three event pools (e.g., small, medium, and large events, like shirt sizes). It returns a pointer to the event already cast to the event type (et*).
[in] | et | type of event |
[in] | e | event signal |
[in] | sender_ | pointer to the actor that request a memory block. It is not necessarily a pointer to an active object. In fact, if RKH_ALLOC_EVT() is called from an interrupt or other context, it can create a unique object just to unambiguously identify the publisher of the event. |
Definition at line 104 of file rkhfwk_dynevt.h.
#define RKH_FWK_GC | ( | e, | |
sender_ | |||
) | rkh_fwk_gc(e, sender_) |
Recycle a dynamic event.
This macro implements a simple garbage collector for the dynamic events. Only dynamic events are candidates for recycling. (A dynamic event is one that is allocated from an event pool, which is determined as non-zero e->nref attribute.) Next, the function decrements the reference counter of the event, and recycles the event only if the counter drops to zero (meaning that no more references are outstanding for this event). The dynamic event is recycled by returning it to the pool from which it was originally allocated. The pool-of-origin information is stored in the e->pool member.
[in] | e | pointer to event to be potentially recycled. |
[in] | sender_ | Pointer to the actor that request a memory block. It is not necessarily a pointer to an active object. In fact, if RKH_FWK_GC() is called from an interrupt or other context, it can create a unique object just to unambiguously identify the publisher of the event. |
Definition at line 148 of file rkhfwk_dynevt.h.
#define RKH_FWK_RSV | ( | e | ) | rkh_fwk_reserve(e) |
Reserve the dynamic event to be recycled.
This is the complement to RKH_FWK_GC(). It increments the reference count of a dynamic event so the event can be saved by an SMA (AO). Sometime later the SMA should manually release the event with RKH_FWK_GC().
[in] | e | pointer to event to be reserved. |
Definition at line 167 of file rkhfwk_dynevt.h.
#define RKH_SET_STATIC_EVENT | ( | ev_obj, | |
ev_sig | |||
) | MK_SET_EVT(ev_obj, ev_sig) |
This macro initialize an event e with es signal and establishes it as one static event.
[in] | ev_obj | name of event structure (object). |
[in] | ev_sig | event signal. The RKH takes this value for triggering a state transition. |
Definition at line 214 of file rkhfwk_dynevt.h.
#define RKH_STATIC_EVENT | ( | ev_obj, | |
ev_sig | |||
) | MK_EVT(ev_obj, ev_sig) |
This macro declares and initializes the event structure ev_ob with ev_sig signal number and establishes it as one static event.
[in] | ev_obj | name of event structure (object). |
[in] | ev_sig | event signal. The RKH takes this value for triggering a state transition. |
Definition at line 243 of file rkhfwk_dynevt.h.
#define RKH_ROM_STATIC_EVENT | ( | ev_obj, | |
ev_sig | |||
) | MK_ROM_EVT(ev_obj, ev_sig) |
This macro declares and initializes the event structure ev_ob with ev_sig signal number and establishes it as one static event.
[in] | ev_obj | name of event structure (object). |
[in] | ev_sig | event signal. The RKH takes this value for triggering a state transition. |
Definition at line 275 of file rkhfwk_dynevt.h.
#define RKH_INIT_STATIC_EVT | ( | ev_sig | ) | MK_EVT_STRUCT(ev_sig) |
Initializes the attibutes of a RKH's event object structure.
Definition at line 308 of file rkhfwk_dynevt.h.
void rkh_fwk_registerEvtPool | ( | void * | sstart, |
rui32_t | ssize, | ||
RKH_ES_T | esize | ||
) |
Registers a new event pool into the event pool list.
Before using dynamic events (or event with arguments) the application code must register the event pools, which stores the events as a fixed-sized memory block. Each event pool must be registered with the RKH framework, by means of the rkh_fwk_registerEvtPool() function.
This function initializes one event pool at a time and must be called exactly once for each event pool before the pool can be used.
The application code might initialize the event pools by making calls to the rkh_fwk_registerEvtPool() function. However, for the simplicity of the internal implementation, the application code initialize event pools in the ascending order of the event size.
Many RTOSes provide fixed block-size heaps, a.k.a. memory pools that can be adapted for RKH event pools. In case such support is missing, RKH provides a native RKH event pool manager implementation. See rkhfwk_evtpool.c.
For adapting RKH event pools to any fixed-size memory block service RTOS provided the application code must provides the implementation of the rkhfwk_etpoo.h interface.
The dynamic allocation of events is optional then if the RKH_CFGPORT_NATIVE_DYN_EVT_EN is set to 1 and the native fixed-size memory block facility is enabled (see RKH_CFG_MP_EN) then RKH will include its own implementation of dynamic memory management. When RKH_CFGPORT_NATIVE_DYN_EVT_EN is enabled RKH also will provide the event pool manager implementation based on its native memory pool module.
[in] | sstart | storage start. Pointer to memory from which memory blocks are allocated. |
[in] | ssize | storage size. Size of the memory pool storage in bytes. |
[in] | esize | event size. This number determines the size of each memory block in the pool. |
Allocates an event from the previously created event pool.
[in] | esize | size of event [in bytes]. |
[in] | e | event signal. |
[in] | sender | pointer to the actor that request a memory block. It is not necessarily a pointer to an active object. In fact, if RKH_ALLOC_EVT() is called from an interrupt or other context, it can create a unique object just to unambiguously identify the publisher of the event. |
void rkh_fwk_gc | ( | RKH_EVT_T * | e, |
const void *const | sender | ||
) |
Recycle a dynamic event.
[in] | e | Event signal. |
[in] | sender | Pointer to the actor that request a memory block. It is not necessarily a pointer to an active object. In fact, if RKH_FWK_GC() is called from an interrupt or other context, it can create a unique object just to unambiguously identify the publisher of the event. |
void rkh_fwk_reserve | ( | RKH_EVT_T * | e | ) |
Reserve the dynamic event to be recycled.
[in] | e | event signal. |