- Main Page
- Modules
- Data Structures
- Files

- File List
- Globals

# /space/home/slher/rel/Beken/v6_4_5/macsw/modules/ke/src/ke_msg.h

Go to the documentation of this file.

    00001
    00013 #ifndef _KE_MSG_H_
    00014 #define _KE_MSG_H_
    00015
    00048 /*
    00049  * INCLUDE FILES
    00050  ****************************************************************************************
    00051  */
    00052 #include <stddef.h>
    00053 #include "co_int.h"
    00054 #include "co_bool.h"
    00055 #include "dbg_assert.h"
    00056 #include "compiler.h"
    00057
    00058 #include "ke_config.h"
    00059 #include "co_list.h"
    00060
    00061
    00062
    00064 typedef uint16_t ke_task_id_t;
    00065
    00067 #define KE_BUILD_ID(type, index) ( (ke_task_id_t)(((index) << 8)|(type)) )
    00068
    00070 #define KE_TYPE_GET(ke_task_id) ((ke_task_id) & 0xFF)
    00071
    00073 #define KE_IDX_GET(ke_task_id) (((ke_task_id) >> 8) & 0xFF)
    00074
    00076 typedef uint16_t ke_state_t;
    00077
    00082 typedef uint16_t ke_msg_id_t;
    00083
    00085 struct ke_msg
    00086 {
    00087     struct co_list_hdr hdr;
    00088     ke_msg_id_t     id;
    00089     ke_task_id_t    dest_id;
    00090     ke_task_id_t    src_id;
    00091     uint16_t        param_len;
    00092     uint32_t        param[1];
    00093 };
    00094
    00095
    00097 enum ke_msg_status_tag
    00098 {
    00099     KE_MSG_CONSUMED = 0,
    00100     KE_MSG_NO_FREE,
    00101     KE_MSG_SAVED,
    00102 };
    00103
    00114 __INLINE struct ke_msg * ke_param2msg(void const *param_ptr)
    00115 {
    00116     return (struct ke_msg*) (((uint8_t*)param_ptr) - offsetof(struct ke_msg, param));
    00117 }
    00118
    00128 __INLINE void * ke_msg2param(struct ke_msg const *msg)
    00129 {
    00130     return (void*) (((uint8_t*) msg) + offsetof(struct ke_msg, param));
    00131 }
    00132
    00149 #define KE_MSG_ALLOC(id, dest, src, param_str) \
    00150     (struct param_str*) ke_msg_alloc(id, dest, src, sizeof(struct param_str))
    00151
    00170 #define KE_MSG_ALLOC_VAR(id, dest, src, param_str, var_len) \
    00171     (struct param_str*) ke_msg_alloc(id, dest, src, sizeof(struct param_str) + var_len)
    00172
    00183 #define KE_MSG_FREE(param_ptr) ke_msg_free(ke_param2msg((param_ptr)))
    00184
    00185 void *ke_msg_alloc(ke_msg_id_t const id,
    00186                    ke_task_id_t const dest_id,
    00187                    ke_task_id_t const src_id,
    00188                    uint16_t const param_len);
    00189
    00190 void ke_msg_send(void const *param_ptr);
    00191
    00192 void ke_msg_send_basic(ke_msg_id_t const id,
    00193                        ke_task_id_t const dest_id,
    00194                        ke_task_id_t const src_id);
    00195
    00196 void ke_msg_forward(void const *param_ptr,
    00197                     ke_task_id_t const dest_id,
    00198                     ke_task_id_t const src_id);
    00199
    00200 void ke_msg_forward_and_change_id(void const *param_ptr,
    00201                                   ke_msg_id_t const msg_id,
    00202                                   ke_task_id_t const dest_id,
    00203                                   ke_task_id_t const src_id);
    00204
    00205 void ke_msg_free(struct ke_msg const *param);
    00206
    00208
    00209 #endif // _KE_MSG_H_