diff options
author | Patrick Williams <iawillia@us.ibm.com> | 2010-06-24 15:51:29 -0500 |
---|---|---|
committer | Patrick Williams <iawillia@us.ibm.com> | 2010-06-24 15:51:29 -0500 |
commit | 8085c7634979f38c1b152d0a35b98c2447ce497a (patch) | |
tree | 844b3527d7b1e8770540f77d1f95c59254aaca60 /src/include/sys/msg.h | |
parent | f760d7d1b0a7872228870b84ebfa85ab9999eb54 (diff) | |
download | talos-hostboot-8085c7634979f38c1b152d0a35b98c2447ce497a.tar.gz talos-hostboot-8085c7634979f38c1b152d0a35b98c2447ce497a.zip |
Add messaging
Diffstat (limited to 'src/include/sys/msg.h')
-rw-r--r-- | src/include/sys/msg.h | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/src/include/sys/msg.h b/src/include/sys/msg.h new file mode 100644 index 000000000..ca5dab7e6 --- /dev/null +++ b/src/include/sys/msg.h @@ -0,0 +1,47 @@ +#ifndef __SYS_MSG_H +#define __SYS_MSG_H + +#include <stdint.h> +#include <stdlib.h> + +#ifdef __cplusplus +extern "C" +{ +#endif + +typedef void* msg_q_t; + +struct msg_t +{ + uint32_t type; + uint32_t __reserved__async; + uint64_t data[2]; + void* extra_data; +}; + +// Message queue interfaces. +msg_q_t msg_q_create(); +int msg_q_destroy(); +int msg_q_register(msg_q_t q, char* name); +msg_q_t msg_q_resolve(char* name); + +// Message interfaces. +__attribute__((always_inline)) + inline msg_t* msg_allocate() { return (msg_t*)malloc(sizeof(msg_t)); } +__attribute__((always_inline)) + inline void msg_free(msg_t* m) { free(m); } + +int msg_send(msg_q_t q, msg_t* msg); +int msg_sendrecv(msg_q_t q, msg_t* msg); +int msg_respond(msg_q_t q, msg_t* msg); +msg_t* msg_wait(msg_q_t q); + +__attribute__((always_inline)) + inline uint32_t msg_is_async(msg_t* msg) + { return 0 == msg->__reserved__async; } + +#ifdef __cplusplus +} +#endif + +#endif |