From: bernie Date: Sun, 6 Jun 2004 15:11:08 +0000 (+0000) Subject: Import into DevLib. X-Git-Tag: 1.0.0~1224 X-Git-Url: https://codewiz.org/gitweb?a=commitdiff_plain;h=52cd7843bd8f38047401c768abee7309157344a2;p=bertos.git Import into DevLib. git-svn-id: https://src.develer.com/svnoss/bertos/trunk@17 38d2e660-2303-0410-9eaa-f027e97ec537 --- diff --git a/kern/msg.h b/kern/msg.h new file mode 100755 index 00000000..0fcfffad --- /dev/null +++ b/kern/msg.h @@ -0,0 +1,59 @@ +/*! + * \file + * + * + * \brief Simple inter-process messaging system + * + * This module implements a common system for executing + * a user defined action calling a hook function. + * + * \version $Id$ + * + * \author Bernardo Innocenti + */ + +/* + * $Log$ + * Revision 1.1 2004/06/06 15:11:08 bernie + * Import into DevLib. + * + */ +#ifndef KERN_MSG_H +#define KERN_MSG_H + +#include "event.h" + + +typedef struct MsgPort +{ + List queue; /*!< Messages queued at this port */ + Event evn; /*!< Event to trigger when a message arrives */ +} MsgPort; + + +typedef struct Msg +{ + Node link; /*!< Link into message port queue */ + MsgPort *replyPort; /*!< Port to which the msg is to be replied */ + /* User data may follow */ +} Msg; + + +/*! Initialize a messge port */ +#define INITPORT(p) INITLIST(&(p)->queue) + +/*! Queue a message to a message port */ +#define PUTMSG(p,m) (ADDTAIL(&(p)->queue,(Node *)(m)), DOEVENT(&(p)->evn)) +#define PUTMSG_INTR(p,m) (ADDTAIL(&(p)->queue,(Node *)(m)), DOEVENT_INTR(&(p)->evn)) + +/*! Get first message from port's queue (returns NULL when the port is empty) */ +#define GETMSG(p) ((Msg *)REMHEAD(&(p)->queue)) + +/*! Reply a message to its sender */ +#define REPLYMSG(m) (PUTMSG((m)->replyPort,(m))) + +#endif /* KERN_MSG_H */