summaryrefslogtreecommitdiff
path: root/arch/arm/plat-omap/include/syslink/gatemp.h
blob: d2d2e4714f3b819ddf842843f47331b2cc607575 (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
/*
 *  gatemp.h
 *
 *  gatemp wrapper defines
 *
 *  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 _GATEMP_H_
#define _GATEMP_H_

#include <sharedregion.h>

/* Unique module ID. */
#define GATEMP_MODULEID		(0xAF70)

/* The resource is still in use */
#define GateMP_S_BUSY		2

/* The module has been already setup */
#define GateMP_S_ALREADYSETUP	1

/* Operation is successful. */
#define GateMP_S_SUCCESS	0

/* Generic failure. */
#define GateMP_E_FAIL		-1

/* The specified entity already exists. */
#define GateMP_E_ALREADYEXISTS	-4

/* Unable to find the specified entity. */
#define GateMP_E_NOTFOUND	-5

/* Operation timed out. */
#define GateMP_E_TIMEOUT	-6

/* Module is not initialized. */
#define GateMP_E_INVALIDSTATE	-7

/* A failure occurred in an OS-specific call */
#define GateMP_E_OSFAILURE	-8

/* Specified resource is not available */
#define GateMP_E_RESOURCE	-9

/* Operation was interrupted. Please restart the operation */
#define GateMP_E_RESTART	-10

/* Gate is local gate not remote */
#define GateMP_E_LOCALGATE	-11


/*
 * A set of local context protection levels
 *
 *  Each member corresponds to a specific local processor gates used for
 *  local protection.
 *
 *  In linux user mode, the following are the mapping for the constants
 *   - INTERRUPT -> [N/A]
 *   - TASKLET   -> [N/A]
 *   - THREAD    -> GateMutex
 *   - PROCESS   -> GateMutex
 *
 *  In linux kernel mode, the following are the mapping for the constants
 *   - INTERRUPT -> [Interrupts disabled]
 *   - TASKLET   -> GateMutex
 *   - THREAD    -> GateMutex
 *   - PROCESS   -> GateMutex
 *
 *  For SYS/BIOS users, the following are the mappings for the constants
 *   - INTERRUPT -> GateHwi: disables interrupts
 *   - TASKLET   -> GateSwi: disables Swi's (software interrupts)
 *   - THREAD    -> GateMutexPri: based on Semaphores
 *   - PROCESS   -> GateMutexPri: based on Semaphores
 */
enum gatemp_local_protect {
	GATEMP_LOCALPROTECT_NONE = 0,
	/* Use no local protection */

	GATEMP_LOCALPROTECT_INTERRUPT = 1,
	/* Use the INTERRUPT local protection level */

	GATEMP_LOCALPROTECT_TASKLET = 2,
	/* Use the TASKLET local protection level */

	GATEMP_LOCALPROTECT_THREAD = 3,
	/* Use the THREAD local protection level */

	GATEMP_LOCALPROTECT_PROCESS = 4
	/* Use the PROCESS local protection level */
};

/*
 * Type of remote Gate
 *
 *  Each member corresponds to a specific type of remote gate.
 *  Each enum value corresponds to the following remote protection levels:
 *   - NONE      -> No remote protection (the gatemp instance will
 *                  exclusively offer local protection configured in
 *                  #GateMP_Params::local_protect
 *   - SYSTEM    -> Use the SYSTEM remote protection level (default for
 *                  remote protection
 *   - CUSTOM1   -> Use the CUSTOM1 remote protection level
 *   - CUSTOM2   -> Use the CUSTOM2 remote protection level
 */
enum gatemp_remote_protect {
	GATEMP_REMOTEPROTECT_NONE = 0,
	/* No remote protection (the gatemp instance will exclusively
	 * offer local protection configured in #GateMP_Params::local_protect)
	 */

	GATEMP_REMOTEPROTECT_SYSTEM = 1,
	/* Use the SYSTEM remote protection level (default remote protection) */

	GATEMP_REMOTEPROTECT_CUSTOM1 = 2,
	/* Use the CUSTOM1 remote protection level */

	GATEMP_REMOTEPROTECT_CUSTOM2 = 3
	/* Use the CUSTOM2 remote protection level */
};

/* Structure defining parameters for the gatemp module. */
struct gatemp_params {
	char *name;
	/* Name of this instance.
	 * The name (if not NULL) must be unique among all GateMP
	 * instances in the entire system.  When creating a new
	 * heap, it is necessary to supply an instance name.
	 */

	u32 region_id;
	/* Shared region ID
	 * The index corresponding to the shared region from which shared memory
	 * will be allocated.
	 * If not specified, the default of '0' will be used.
	 */

	void *shared_addr;
	/* Physical address of the shared memory
	 * This value can be left as 'null' unless it is required to place the
	 * heap at a specific location in shared memory.  If sharedAddr is null,
	 * then shared memory for a new instance will be allocated from the
	 * heap belonging to the region identified by #GateMP_Params::region_id.
	 */

	enum gatemp_local_protect local_protect;
	/* Local protection level.
	 * The default value is #GATEMP_LOCALPROTECT_THREAD */

	enum gatemp_remote_protect remote_protect;
	/* Remote protection level
	 * The default value is #GATEMP_REMOTEPROTECT_SYSTEM */
};

/* Structure defining config parameters for the gatemp module. */
struct gatemp_config {
	u32 num_resources;
	/* Maximum number of resources */
	enum gatemp_local_protect default_protection;
	u32 max_name_len;
	u32 max_runtime_entries;
};


/* Close an opened gate */
int gatemp_close(void **handle_ptr);

/* Create a gatemp instance */
void *gatemp_create(const struct gatemp_params *params);

/* Delete a created gatemp instance */
int gatemp_delete(void **handle_ptr);

/* Query the gate */
bool gatemp_query(int qual);

/* Get the default remote gate */
void *gatemp_get_default_remote(void);

/* Get the local protect gate. */
enum gatemp_local_protect gatemp_get_local_protect(void *obj);

/* Get the remote protect gate. */
enum gatemp_remote_protect gatemp_get_remote_protect(void *obj);

/* Open a created gatemp by name */
int gatemp_open(char *name, void **handle_ptr);

/* Open a created gatemp by address */
int gatemp_open_by_addr(void *shared_addr, void **handle_ptr);

/* Initialize a gatemp parameters struct */
void gatemp_params_init(struct gatemp_params *params);

/* Amount of shared memory required for creation of each instance */
uint gatemp_shared_mem_req(const struct gatemp_params *params);

/* Enter the gatemp */
int *gatemp_enter(void *handle);

/* Leave the gatemp */
void gatemp_leave(void *handle, int *key);

/* Get the default configuration for the gatemp module. */
void gatemp_get_config(struct gatemp_config *cfg_params);

/* Setup the gatemp module. */
s32 gatemp_setup(const struct gatemp_config *cfg);

/* Function to destroy the gatemp module. */
s32 gatemp_destroy(void);

/* Function to attach gatemp to a remote processor */
int gatemp_attach(u16 remote_proc_id, void *shared_addr);

/* Function to detach gatemp from a remote processor */
int gatemp_detach(u16 remote_proc_id, void *shared_addr);

/* Function to start gatemp */
int gatemp_start(void *shared_addr);

/* Function to start gatemp */
int gatemp_stop(void);

/* Function to create local gatemp */
void *gatemp_create_local(enum gatemp_local_protect local_protect);

/* Function to return size required in shared region 0 */
uint gatemp_get_region0_reserved_size(void);

/* Function to get the shared address of a gatemp object */
u32 *gatemp_get_shared_addr(void *obj);


#endif /* _GATEMP_H_ */