intertask_interface_types.h 4.57 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

Cedric Roux's avatar
 
Cedric Roux committed
61
62
63
64
65
66
67
68
69
#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

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

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

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

84
    THREAD_MAX,
Cedric Roux's avatar
 
Cedric Roux committed
85
86
87
88
89
} thread_id_t;

//! Sub-tasks id, to defined offset form thread id
typedef enum
{
90
91
#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
92
93
94
#include <tasks_def.h>
#undef SUB_TASK_DEF
#undef TASK_DEF
95
} task_thread_id_t;
Cedric Roux's avatar
 
Cedric Roux committed
96
97
98
99

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

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

108
    TASK_MAX,
Cedric Roux's avatar
 
Cedric Roux committed
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
} 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;

#define INSTANCE_DEFAULT    0
#define INSTANCE_ALL        -1

typedef int16_t instance_t;
typedef uint16_t MessageHeaderSize;

/** @struct MessageHeader
 *  @brief Message Header structure for inter-task communication.
 */
typedef struct MessageHeader_s
{
        MessagesIds messageId; /**< Unique message id as referenced in enum MessagesIds */

Cedric Roux's avatar
Cedric Roux committed
131
132
133
        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
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148

        MessageHeaderSize size; /**< Message size (not including header size) */
} MessageHeader;

/** @struct MessageDef
 *  @brief Message structure for inter-task communication.
 */
typedef struct MessageDef_s
{
        MessageHeader header; /**< Message header */
        msg_t msg; /**< Union of payloads as defined in x_messages_def.h headers */
} MessageDef;

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