summaryrefslogtreecommitdiff
path: root/arch/arm/plat-omap/include/syslink/messageq_transportshm.h
blob: e2b55f6b0b4dda1ed82d1937d2233b2136d44c28 (plain)
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
/*
 *  messageq_transportshm.h
 *
 *  MessageQ shared memory based physical transport for
 *  communication with the remote processor.
 *
 *  This file contains the declarations of types and APIs as part
 *  of interface of the MessageQ shared memory transport.
 *
 *  Copyright (C) 2008-2009 Texas Instruments, Inc.
 *
 *  This package is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License version 2 as
 *  published by the Free Software Foundation.
 *
 *  THIS PACKAGE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
 *  IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
 *  WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
 *  PURPOSE.
 */

#ifndef _MESSAGEQ_TRANSPORTSHM_H_
#define _MESSAGEQ_TRANSPORTSHM_H_

/* Standard headers */
#include <linux/types.h>

/* Utilities headers */
#include <linux/list.h>

/* =============================================================================
 *  All success and failure codes for the module
 * =============================================================================
 */
/*!
 *  @def	MESSAGEQ_TRANSPORTSHM_MODULEID
 *  @brief  Unique module ID.
 */
#define MESSAGEQ_TRANSPORTSHM_MODULEID		(0x0a7a)

/* =============================================================================
 *  All success and failure codes for the module
 * =============================================================================
 */
/*!
 *  @def	MESSAGEQ_TRANSPORTSHM_STATUSCODEBASE
 *  @brief  Error code base for MessageQ.
 */
#define MESSAGEQ_TRANSPORTSHM_STATUSCODEBASE \
					(MESSAGEQ_TRANSPORTSHM_MODULEID << 12)

/*!
 *  @def	MESSAGEQ_TRANSPORTSHM_MAKE_FAILURE
 *  @brief  Macro to make error code.
 */
#define MESSAGEQ_TRANSPORTSHM_MAKE_FAILURE(x)	((int)  (0x80000000 \
				+ (MESSAGEQ_TRANSPORTSHM_STATUSCODEBASE \
				+ (x))))

/*!
 *  @def	MESSAGEQ_TRANSPORTSHM_MAKE_SUCCESS
 *  @brief  Macro to make success code.
 */
#define MESSAGEQ_TRANSPORTSHM_MAKE_SUCCESS(x) \
				(MESSAGEQ_TRANSPORTSHM_STATUSCODEBASE + (x))

/*!
 *  @def	MESSAGEQ_TRANSPORTSHM_E_INVALIDARG
 *  @brief  Argument passed to a function is invalid.
 */
#define MESSAGEQ_TRANSPORTSHM_E_INVALIDARG \
				MESSAGEQ_TRANSPORTSHM_MAKE_FAILURE(1)

/*!
 *  @def	MESSAGEQ_TRANSPORTSHM_E_INVALIDSIZE
 *  @brief  Invalid shared address size
 */
#define MESSAGEQ_TRANSPORTSHM_E_INVALIDSIZE \
				MESSAGEQ_TRANSPORTSHM_MAKE_FAILURE(2)

/*!
 *  @def	MESSAGEQ_TRANSPORTSHM_E_INVALIDSTATE
 *  @brief  Module is not initialized.
 */
#define MESSAGEQ_TRANSPORTSHM_E_INVALIDSTATE \
				MESSAGEQ_TRANSPORTSHM_MAKE_FAILURE(3)

/*!
 *  @def	MESSAGEQ_TRANSPORTSHM_E_BADVERSION
 *  @brief  Versions don't match
 */
#define MESSAGEQ_TRANSPORTSHM_E_BADVERSION \
				MESSAGEQ_TRANSPORTSHM_MAKE_FAILURE(4)

/*!
 *  @def	MESSAGEQ_TRANSPORTSHM_E_FAIL
 *  @brief  General Failure
*/
#define MESSAGEQ_TRANSPORTSHM_E_FAIL \
				MESSAGEQ_TRANSPORTSHM_MAKE_FAILURE(5)

/*!
 *  @def	MESSAGEQ_TRANSPORTSHM_E_MEMORY
 *  @brief  Memory allocation failed
 */
#define MESSAGEQ_TRANSPORTSHM_E_MEMORY \
				MESSAGEQ_TRANSPORTSHM_MAKE_FAILURE(6)

/*!
 *  @def	MESSAGEQ_TRANSPORTSHM_E_OSFAILURE
 *  @brief  Failure in OS call.
 */
#define MESSAGEQ_TRANSPORTSHM_E_OSFAILURE \
				MESSAGEQ_TRANSPORTSHM_MAKE_FAILURE(7)

/*!
 *  @def	MESSAGEQ_TRANSPORTSHM_E_HANDLE
 *  @brief  Invalid handle specified.
 */
#define MESSAGEQ_TRANSPORTSHM_E_HANDLE \
				MESSAGEQ_TRANSPORTSHM_MAKE_FAILURE(8)

/*!
 *  @def    MESSAGEQTRANSPORTSHM_E_NOTSUPPORTED
 *  @brief  The specified operation is not supported.
 */
#define MESSAGEQTRANSPORTSHM_E_NOTSUPPORTED \
				MESSAGEQ_TRANSPORTSHM_MAKE_FAILURE(9)

/*!
 *  @def	MESSAGEQ_TRANSPORTSHM_SUCCESS
 *  @brief  Operation successful.
 */
#define MESSAGEQ_TRANSPORTSHM_SUCCESS \
				MESSAGEQ_TRANSPORTSHM_MAKE_SUCCESS(0)

/*!
 *  @def	MESSAGETRANSPORTSHM_S_ALREADYSETUP
 *  @brief  The MESSAGETRANSPORTSHM module has
 *	  already been setup in this process.
 */
#define MESSAGEQ_TRANSPORTSHM_S_ALREADYSETUP \
				MESSAGEQ_TRANSPORTSHM_MAKE_SUCCESS(1)


/* =============================================================================
 * Structures & Enums
 * =============================================================================
 */

/*!
 *  @brief  Structure defining the reason for error function being called
 */
enum  MessageQTransportShm_Reason {
    MessageQTransportShm_Reason_FAILEDPUT,
    /*!< Failed to send the message. */
    MessageQTransportShm_Reason_INTERNALERR,
    /*!< An internal error occurred in the transport */
    MessageQTransportShm_Reason_PHYSICALERR,
    /*!<  An error occurred in the physical link in the transport */
    MessageQTransportShm_Reason_FAILEDALLOC
    /*!<  Failed to allocate a message. */
};

/*!
 *  @brief   transport error callback function.
 *
 *  First parameter: Why the error function is being called.
 *
 *  Second parameter: Handle of transport that had the error. NULL denotes
 *  that it is a system error, not a specific transport.
 *
 *  Third parameter: Pointer to the message. This is only valid for
 *  #MessageQTransportShm_Reason_FAILEDPUT.
 *
 *  Fourth parameter: Transport specific information. Refer to individual
 *  transports for more details.
 */

/*!
 *  @brief  Module configuration structure.
 */
struct messageq_transportshm_config {
	void (*err_fxn)(enum MessageQTransportShm_Reason reason,
				void *handle,
				void *msg,
				u32 info);
	/*!< Asynchronous error function for the transport module */
};

/*!
 *  @brief  Structure defining config parameters for the MessageQ transport
 *  instances.
 */
struct messageq_transportshm_params {
	u32 priority;
	/*!<  Priority of messages supported by this transport */
	void *gate;
	/*!< Gate used for critical region management of the shared memory */
	void *shared_addr;
	/*!<  Address of the shared memory. The creator must supply the shared
	*    memory that this will use for maintain shared state information.
	*/
	u32 shared_addr_size;
	/*!<  Size of shared region provided. */
	u32 notify_event_no;
	/*!<  Notify event number to be used by the transport */
	void *notify_driver;
	/*!<  Notify driver to be used by the transport */
};

/*!
 *  @brief  Structure defining Transport status values
 */
enum messageq_transportshm_status {
	messageq_transportshm_status_INIT,
	/*!< MessageQ transport Shm instance has not not completed
	* initialization. */
	messageq_transportshm_status_UP,
	/*!< MessageQ transport Shm instance is up and functional. */
	messageq_transportshm_status_DOWN,
	/*!<  MessageQ transport Shm instance is down and not functional. */
	messageq_transportshm_status_RESETTING
	/*!<  MessageQ transport Shm instance was up at one point and is in
	* process of resetting.
	*/
};


/* =============================================================================
 *  APIs called by applications
 * =============================================================================
 */
/* Function to get the default configuration for the MessageQTransportShm
 * module. */
void messageq_transportshm_get_config(struct messageq_transportshm_config *cfg);

/* Function to setup the MessageQTransportShm module. */
int messageq_transportshm_setup(const struct messageq_transportshm_config *cfg);

/* Function to destroy the MessageQTransportShm module. */
int messageq_transportshm_destroy(void);

/* Get the default parameters for the NotifyShmDriver. */
void messageq_transportshm_params_init(void *mqtshm_handle,
				struct messageq_transportshm_params *params);

/* Create an instance of the MessageQTransportShm. */
void *messageq_transportshm_create(u16 proc_id,
			const struct messageq_transportshm_params *params);

/* Delete an instance of the MessageQTransportShm. */
int messageq_transportshm_delete(void **mqtshm_handleptr);

/* Get the shared memory requirements for the MessageQTransportShm. */
u32 messageq_transportshm_shared_mem_req(const
				struct messageq_transportshm_params *params);

/* Set the asynchronous error function for the transport module */
void messageq_transportshm_set_err_fxn(
				void (*err_fxn)(
				enum MessageQTransportShm_Reason reason,
				void *handle,
				void *msg,
				u32 info));


/* =============================================================================
 *  APIs called internally by MessageQ module.
 * =============================================================================
 */
/* Put msg to remote list */
int messageq_transportshm_put(void *mqtshm_handle, void *msg);

/* Control Function */
int messageq_transportshm_control(void *mqtshm_handle, u32 cmd,
					u32 *cmd_arg);

/* Get current status of the MessageQTransportShm */
enum messageq_transportshm_status messageq_transportshm_get_status(
						void *mqtshm_handle);

#endif /* _MESSAGEQ_TRANSPORTSHM_H_ */