AEM - The Linux Asynchronous Event Mechanism

Back to main page

AEM core


The module aem-core provides the basic AEM functionalities. It must be loaded before any other AEM modules.  As such, it doesn't provide some specific event interface but implements a de/multiplexing and management interface towards these event modules.


/* Event/Job operations */
#define EVJOBPRIO      1
#define EVTBLINIT         2
#define EVJOBSHTDN  3
#define EVJOBSTART    4
#define EVJOBSTOP     5

#define TBL_UZONE     0
#define TBL_VZONE     1

/* Runtime control flags */
#define EVF_EXCL             (1<<17) /* not used */
#define EVF_ONESHOT     (1<<18)
#define EVF_CLONE          (1<<19)  /* not used */
#define EVF_FORK             (1<<20)
#define EVF_NOCLDWAIT  (1<<21)
#define EVF_CAPSULE      (1<<22)
#define EVF_KEEPALIVE   (1<<23)


aem_evkeepalive - endless-loop to keep a process running so that it can continue to receive event notifications.

void  aem_evkeepalive (void);

aem_keepalive exits when being sent a signal.

aem_evctl - event control entry point.

int aem_evctl (unsigned int eid, unsigned long opt, unsigned long args);

aem_evctl is the control function towards events. The opt and args parameters represents the operation and its arguments to apply to the event specified by eid. This identifier is obtained during event registration using aem_entry.

aem_entry - event  registration function

int aem_entry (int sys_nr, void * args);

aem_entry is the control fuction used to register an event of type sys_nr with the options specified by args. These two parameters are event specific. It returns an system unique identifier in case of succes or a negative value in case of error.

The integer sys_nr is a reference for one of the specific event registration methods implemented by event modules. sys_nrrepresents one specific event and is unique in the system. It is obtained by reading the number from the module using ioctlt:

fd = open ("/dev/aem-my_module", O_RDONLY);
sys_nr = ioctl (fd, GET_SYSNR);
close (fd);

The GET_SYSNR value is the event reference for the module and is unique for the module only.
The structure arg defines the event specific information part:

struct my_aem_struct  {
    some_type1_t specific_field1; 
    some_type2_t specific_field2;
    some_type3_t specific_field3;
    int flags;
    unsigned long handler;
} args;

args.specific_field1 = ...;
args.specific_field2 = ...;
args.specific_field3 = ...;
args.flags = (Runtime control flag1 | flag2 | ...);
args.handler = (unsigned long) handler;