intertask_interface_types.h 4.91 KB
Newer Older
Cedric Roux's avatar
 
Cedric Roux committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
/*******************************************************************************

 Eurecom OpenAirInterface
 Copyright(c) 1999 - 2012 Eurecom

 This program is free software; you can redistribute it and/or modify it
 under the terms and conditions of the GNU General Public License,
 version 2, as published by the Free Software Foundation.

 This program is distributed in the hope 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.

 The full GNU General Public License is included in this distribution in
 the file called "COPYING".

 Contact Information
 Openair Admin: openair_admin@eurecom.fr
 Openair Tech : openair_tech@eurecom.fr
 Forums       : http://forums.eurecom.fr/openairinterface
 Address      : EURECOM, Campus SophiaTech, 450 Route des Chappes
 06410 Biot FRANCE

 *******************************************************************************/

/** @defgroup _intertask_interface_impl_ Intertask Interface Mechanisms
 * Implementation
 * @ingroup _ref_implementation_
 * @{
 */

#ifndef INTERTASK_INTERFACE_TYPES_H_
#define INTERTASK_INTERFACE_TYPES_H_

40
41
#include <stdint.h>

Cedric Roux's avatar
 
Cedric Roux committed
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
/* Defines to handle bit fields on unsigned long values */
#define UL_BIT_MASK(lENGTH)             ((1UL << (lENGTH)) - 1UL)
#define UL_BIT_SHIFT(vALUE, oFFSET)     ((vALUE) << (oFFSET))
#define UL_BIT_UNSHIFT(vALUE, oFFSET)   ((vALUE) >> (oFFSET))

#define UL_FIELD_MASK(oFFSET, lENGTH)                   UL_BIT_SHIFT(UL_BIT_MASK(lENGTH), (oFFSET))
#define UL_FIELD_INSERT(vALUE, fIELD, oFFSET, lENGTH)   (((vALUE) & (~UL_FIELD_MASK(oFFSET, lENGTH))) | UL_BIT_SHIFT(((fIELD) & UL_BIT_MASK(lENGTH)), oFFSET))
#define UL_FIELD_EXTRACT(vALUE, oFFSET, lENGTH)         (UL_BIT_UNSHIFT((vALUE), (oFFSET)) & UL_BIT_MASK(lENGTH))

/* Definitions of task ID fields */
#define TASK_THREAD_ID_OFFSET   8
#define TASK_THREAD_ID_LENGTH   8

#define TASK_SUB_TASK_ID_OFFSET 0
#define TASK_SUB_TASK_ID_LENGTH 8

/* Defines to extract task ID fields */
59
#define TASK_GET_THREAD_ID(tASKiD)          (itti_desc.tasks_info[tASKiD].thread)
60
/* Extract the instance from a message */
Cedric Roux's avatar
Cedric Roux committed
61
#define ITTI_MESSAGE_GET_INSTANCE(mESSAGE)  ((mESSAGE)->ittiMsgHeader.instance)
62

Cedric Roux's avatar
 
Cedric Roux committed
63
64
65
66
67
68
69
70
71
#include <messages_types.h>

/* This enum defines messages ids. Each one is unique. */
typedef enum
{
#define MESSAGE_DEF(iD, pRIO, sTRUCT, fIELDnAME) iD,
#include <messages_def.h>
#undef MESSAGE_DEF

72
    MESSAGES_ID_MAX,
Cedric Roux's avatar
 
Cedric Roux committed
73
74
75
76
77
78
79
} MessagesIds;

//! Thread id of each task
typedef enum
{
    THREAD_FIRST = 1, THREAD_NULL = 0,

80
81
#define TASK_DEF(tHREADiD, pRIO, qUEUEsIZE)             THREAD_##tHREADiD,
#define SUB_TASK_DEF(tHREADiD, sUBtASKiD, qUEUEsIZE)
Cedric Roux's avatar
 
Cedric Roux committed
82
83
84
85
#include <tasks_def.h>
#undef SUB_TASK_DEF
#undef TASK_DEF

86
    THREAD_MAX,
Cedric Roux's avatar
 
Cedric Roux committed
87
88
89
90
91
} thread_id_t;

//! Sub-tasks id, to defined offset form thread id
typedef enum
{
92
93
#define TASK_DEF(tHREADiD, pRIO, qUEUEsIZE)             tHREADiD##_THREAD = THREAD_##tHREADiD,
#define SUB_TASK_DEF(tHREADiD, sUBtASKiD, qUEUEsIZE)    sUBtASKiD##_THREAD = THREAD_##tHREADiD,
Cedric Roux's avatar
 
Cedric Roux committed
94
95
96
#include <tasks_def.h>
#undef SUB_TASK_DEF
#undef TASK_DEF
97
} task_thread_id_t;
Cedric Roux's avatar
 
Cedric Roux committed
98
99
100
101

//! Tasks id of each task
typedef enum
{
102
103
    TASK_FIRST = 1, TASK_UNKNOWN = 0,

104
105
#define TASK_DEF(tHREADiD, pRIO, qUEUEsIZE)             tHREADiD,
#define SUB_TASK_DEF(tHREADiD, sUBtASKiD, qUEUEsIZE)    sUBtASKiD,
Cedric Roux's avatar
 
Cedric Roux committed
106
107
108
109
#include <tasks_def.h>
#undef SUB_TASK_DEF
#undef TASK_DEF

110
    TASK_MAX,
Cedric Roux's avatar
 
Cedric Roux committed
111
112
113
114
115
116
117
118
119
} task_id_t;

typedef union msg_s
{
#define MESSAGE_DEF(iD, pRIO, sTRUCT, fIELDnAME) sTRUCT fIELDnAME;
#include <messages_def.h>
#undef MESSAGE_DEF
} msg_t;

120
121
#define INSTANCE_DEFAULT    (UINT16_MAX - 1)
#define INSTANCE_ALL        (UINT16_MAX)
Cedric Roux's avatar
 
Cedric Roux committed
122

123
typedef uint16_t instance_t;
Cedric Roux's avatar
 
Cedric Roux committed
124
125
typedef uint16_t MessageHeaderSize;

126
127
128
129
130
131
typedef struct itti_lte_time_s
{
    uint32_t frame;
    uint8_t slot;
} itti_lte_time_t;

Cedric Roux's avatar
 
Cedric Roux committed
132
133
134
135
136
/** @struct MessageHeader
 *  @brief Message Header structure for inter-task communication.
 */
typedef struct MessageHeader_s
{
137
        MessagesIds messageId;          /**< Unique message id as referenced in enum MessagesIds */
Cedric Roux's avatar
 
Cedric Roux committed
138

Cedric Roux's avatar
Cedric Roux committed
139
140
141
        task_id_t  originTaskId;        /**< ID of the sender task */
        task_id_t  destinationTaskId;   /**< ID of the destination task */
        instance_t instance;            /**< Task instance for virtualization */
Cedric Roux's avatar
 
Cedric Roux committed
142

Cedric Roux's avatar
Cedric Roux committed
143
        MessageHeaderSize ittiMsgSize;         /**< Message size (not including header size) */
144
145

        itti_lte_time_t lte_time;       /**< Reference LTE time */
Cedric Roux's avatar
 
Cedric Roux committed
146
147
148
149
150
151
152
} MessageHeader;

/** @struct MessageDef
 *  @brief Message structure for inter-task communication.
 */
typedef struct MessageDef_s
{
Cedric Roux's avatar
Cedric Roux committed
153
        MessageHeader ittiMsgHeader; /**< Message header */
154
        msg_t         ittiMsg; /**< Union of payloads as defined in x_messages_def.h headers */
Cedric Roux's avatar
 
Cedric Roux committed
155
156
157
158
} MessageDef;

#endif /* INTERTASK_INTERFACE_TYPES_H_ */
/* @} */