-/*!
+/**
* \file
* <!--
+ * This file is part of BeRTOS.
+ *
+ * Bertos is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * As a special exception, you may use this file as part of a free software
+ * library without restriction. Specifically, if other files instantiate
+ * templates or use macros or inline functions from this file, or you compile
+ * this file and link it with other files to produce an executable, this
+ * file does not by itself cause the resulting executable to be covered by
+ * the GNU General Public License. This exception does not however
+ * invalidate any other reasons why the executable file might be covered by
+ * the GNU General Public License.
+ *
* Copyright 2004 Develer S.r.l. (http://www.develer.com/)
* Copyright 1999,2001 Bernardo Innocenti <bernie@develer.com>
- * This file is part of DevLib - See devlib/README for information.
+ *
* -->
*
- * \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 <bernie@develer.com>
- */
-
-/*#*
- *#* $Log$
- *#* Revision 1.6 2005/01/22 04:20:26 bernie
- *#* Write extensive documentation; Add simple locking.
- *#*
- *#* Revision 1.5 2004/11/28 23:20:25 bernie
- *#* Remove obsolete INITLIST macro.
- *#*
- *#* Revision 1.4 2004/10/19 08:22:09 bernie
- *#* msg_peek(): New function.
- *#*
- *#* Revision 1.3 2004/08/25 14:12:09 rasky
- *#* Aggiornato il comment block dei log RCS
- *#*
- *#* Revision 1.2 2004/08/14 19:37:57 rasky
- *#* Merge da SC: macros.h, pool.h, BIT_CHANGE, nome dei processi, etc.
- *#*
- *#* Revision 1.1 2004/06/06 15:11:08 bernie
- *#* Import into DevLib.
- *#*
- *#*/
-#ifndef KERN_MSG_H
-#define KERN_MSG_H
-
-#include "event.h"
-#include <mware/list.h>
-
-
-/*!
+ *
+ * \brief Simple inter-process messaging system
+ *
* Handle queues of messages associated an action.
*
* A message port is an abstraction used to exchange information
* }
* }
* }
- * \end code
+ * \endcode
+ */
+
*/
+
+#ifndef KERN_MSG_H
+#define KERN_MSG_H
+
+#include "event.h"
+#include <mware/list.h>
+
+
typedef struct MsgPort
{
- List queue; /*!< Messages queued at this port. */
- Event event; /*!< Event to trigger when a message arrives. */
+ List queue; /**< Messages queued at this port. */
+ Event event; /**< 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. */
+ Node link; /**< Link into message port queue. */
+ MsgPort *replyPort; /**< Port to which the msg is to be replied. */
/* User data may follow */
} Msg;
-/*!
+/**
* Lock a message port.
*
* This is required before reading or manipulating
proc_forbid();
}
-/*!
+/**
* Unlock a message port.
*
* \see msg_lockPort()
}
-/*! Initialize a message port */
+/** Initialize a message port */
INLINE void msg_initPort(MsgPort *port, Event event)
{
LIST_INIT(&port->queue);
port->event = event;
}
-/*! Queue \a msg into \a port, triggering the associated event */
+/** Queue \a msg into \a port, triggering the associated event */
INLINE void msg_put(MsgPort *port, Msg *msg)
{
msg_portLock(port);
event_do(&port->event);
}
-/*!
+/**
* Get the first message from the queue of \a port.
*
* \return Pointer to the message or NULL if the port was empty.
return msg;
}
-/* Peek the first message in the queue of \a port, or NULL if the port is empty */
+/** Peek the first message in the queue of \a port, or NULL if the port is empty. */
INLINE Msg *msg_peek(MsgPort *port)
{
Msg *msg;
return msg;
}
-/*! Send back (reply) \a msg to its sender. */
+/** Send back (reply) \a msg to its sender. */
INLINE void msg_reply(Msg *msg)
{
msg_put(msg->replyPort, msg);