aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/staging/sep/sep_driver_api.h
blob: cdebc217cc9013b6e5cbc2e756e6d0b0ff3f470e (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
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
/*
 *
 *  sep_driver_api.h - Security Processor Driver api definitions
 *
 *  Copyright(c) 2009 Intel Corporation. All rights reserved.
 *  Copyright(c) 2009 Discretix. All rights reserved.
 *
 *  This program is free software; you can redistribute it and/or modify it
 *  under the terms of the GNU General Public License as published by the Free
 *  Software Foundation; version 2 of the License.
 *
 *  This program is distributed in the hope that 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., 59
 *  Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 *
 *  CONTACTS:
 *
 *  Mark Allyn		mark.a.allyn@intel.com
 *
 *  CHANGES:
 *
 *  2010.09.14  Upgrade to Medfield
 *
 */

#ifndef __SEP_DRIVER_API_H__
#define __SEP_DRIVER_API_H__

/* Type of request from device */
#define SEP_DRIVER_SRC_REPLY		1
#define SEP_DRIVER_SRC_REQ		2
#define SEP_DRIVER_SRC_PRINTF		3


/*-------------------------------------------
    TYPEDEFS
----------------------------------------------*/

/*
  init command struct
*/
struct sep_driver_init_t {
	/* start of the 1G of the host memory address that SEP can access */
	u32 *message_addr;

	/* start address of resident */
	u32   message_size_in_words;

	/* offset of the init message in the sep sram */
	u32   sep_sram_addr;

	/* resident size in bytes*/
	u32   resident_size_in_bytes;

	/* cache size in bytes*/
	u32   cache_size_in_bytes;

	/* ext cache current address */
	void  *extcache_addr;

	/* ext cache size in bytes*/
	u32   extcache_size_in_bytes;
};

struct sep_driver_realloc_ext_cache_t {
	/* current external cache address */
	void  *ext_cache_addr;

	/* external cache size in bytes*/
	u32   ext_cache_size_in_bytes;
};

struct sep_driver_alloc_t {
	/* virtual address of allocated space */
	u32  offset;

	/* number of bytes to allocate */
	u32  num_bytes;
};

/*
*/
struct sep_driver_build_sync_table_t {
	/* address value of the data in */
	unsigned long app_in_address;

	/* size of data in */
	u32 data_in_size;

	/* address of the data out */
	unsigned long app_out_address;

	/* the size of the block of the operation - if needed,
	   every table will be modulo this parameter */
	u32 block_size;

	/* distinct user/kernel layout */
	bool isKernelVirtualAddress;

};

/* command struct for static pool addresses  */
struct sep_driver_static_pool_addr_t {

	/* virtual address of the static pool */
	void   *static_virt_address;
};

/* command struct for getiing offset of the physical address from
	the start of the mapped area  */
struct sep_driver_get_mapped_offset_t {
	/* physical address of the static pool */
	unsigned long physical_address;

	/* virtual address of the static pool */
	u32 offset;
};

/* command struct for getting time value and address */
struct sep_driver_set_caller_id_t {
	/* pid of the process */
	u32   pid;

	/* virtual address of the caller id hash */
	void  *callerIdAddress;

	/* caller id hash size in bytes */
	u32   callerIdSizeInBytes;
};

/*
  structure that represents DCB
*/
struct sep_dcb_t {
	/* physical address of the first input mlli */
	u32	input_mlli_address;

	/* num of entries in the first input mlli */
	u32	input_mlli_num_entries;

	/* size of data in the first input mlli */
	u32	input_mlli_data_size;

	/* physical address of the first output mlli */
	u32	output_mlli_address;

	/* num of entries in the first output mlli */
	u32	output_mlli_num_entries;

	/* size of data in the first output mlli */
	u32	output_mlli_data_size;

	/* pointer to the output virtual tail */
	void	*out_vr_tail_pt;

	/* size of tail data */
	u32	tail_data_size;

	/* input tail data array */
	u8	tail_data[64];
};

struct sep_caller_id_entry {
	int pid;
	unsigned char callerIdHash[SEP_CALLER_ID_HASH_SIZE_IN_BYTES];
};

/*
	command structure for building dcb block (currently for ext app only
*/
struct sep_driver_build_dcb_t {
	/* address value of the data in */
	unsigned long  app_in_address;

	/* size of data in */
	u32  data_in_size;

	/* address of the data out */
	unsigned long  app_out_address;

	/* the size of the block of the operation - if needed,
	every table will be modulo this parameter */
	u32  block_size;

	/* the size of the block of the operation - if needed,
	every table will be modulo this parameter */
	u32  tail_block_size;
};

/**
 * @struct sep_dma_map
 *
 * Structure that contains all information needed for mapping the user pages
 *	     or kernel buffers for dma operations
 *
 *
 */
struct sep_dma_map {

	/* mapped dma address */
	dma_addr_t    dma_addr;

	/* size of the mapped data */
	size_t        size;
};

struct sep_dma_resource {
	/* array of pointers to the pages that represent
	input data for the synchronic DMA action */
	struct page **in_page_array;

	/* array of pointers to the pages that represent out
	data for the synchronic DMA action */
	struct page **out_page_array;

	/* number of pages in the sep_in_page_array */
	u32 in_num_pages;

	/* number of pages in the sep_out_page_array */
	u32 out_num_pages;

	/* map array of the input data */
	struct sep_dma_map *in_map_array;

	/* map array of the output data */
	struct sep_dma_map *out_map_array;

	/* number of entries of the input mapp array */
	u32 in_map_num_entries;

	/* number of entries of the output mapp array */
	u32 out_map_num_entries;
};


/* command struct for translating rar handle to bus address
   and setting it at predefined location */
struct sep_driver_rar_handle_to_bus {

	/* rar handle */
	void	*rar_handle;
};

/*
  structure that represent one entry in the DMA LLI table
*/
struct sep_lli_entry_t {
	/* physical address */
	u32 bus_address;

	/* block size */
	u32 block_size;
};

/*----------------------------------------------------------------
	IOCTL command defines
	-----------------------------------------------------------------*/

/* magic number 1 of the sep IOCTL command */
#define SEP_IOC_MAGIC_NUMBER	                     's'

/* sends interrupt to sep that message is ready */
#define SEP_IOCSENDSEPCOMMAND	 \
	_IO(SEP_IOC_MAGIC_NUMBER, 0)

/* sends interrupt to sep that message is ready */
#define SEP_IOCSENDSEPRPLYCOMMAND	 \
	_IO(SEP_IOC_MAGIC_NUMBER, 1)

/* allocate memory in data pool */
#define SEP_IOCALLOCDATAPOLL	\
	_IOW(SEP_IOC_MAGIC_NUMBER, 2, struct sep_driver_alloc_t)

/* create sym dma lli tables */
#define SEP_IOCCREATESYMDMATABLE	\
	_IOW(SEP_IOC_MAGIC_NUMBER, 5, struct sep_driver_build_sync_table_t)

/* free dynamic data aalocated during table creation */
#define SEP_IOCFREEDMATABLEDATA	 \
	_IO(SEP_IOC_MAGIC_NUMBER, 7)

/* get the static pool area addersses (physical and virtual) */
#define SEP_IOCGETSTATICPOOLADDR	\
	_IOR(SEP_IOC_MAGIC_NUMBER, 8, struct sep_driver_static_pool_addr_t)

/* set flow id command */
#define SEP_IOCSETFLOWID	\
	_IO(SEP_IOC_MAGIC_NUMBER, 9)

/* add tables to the dynamic flow */
#define SEP_IOCADDFLOWTABLE	 \
	_IO(SEP_IOC_MAGIC_NUMBER, 10)

/* add flow add tables message */
#define SEP_IOCADDFLOWMESSAGE	 \
	_IO(SEP_IOC_MAGIC_NUMBER, 11)

/* start sep command */
#define SEP_IOCSEPSTART	 \
	_IO(SEP_IOC_MAGIC_NUMBER, 12)

/* init sep command */
#define SEP_IOCSEPINIT	\
	_IOW(SEP_IOC_MAGIC_NUMBER, 13, struct sep_driver_init_t)

/* end transaction command */
#define SEP_IOCENDTRANSACTION	 \
	_IO(SEP_IOC_MAGIC_NUMBER, 15)

/* reallocate external app */
#define SEP_IOCREALLOCEXTCACHE	\
	_IOW(SEP_IOC_MAGIC_NUMBER, 18, struct sep_driver_realloc_ext_cache_t)

#define SEP_IOCRARPREPAREMESSAGE	\
	_IOW(SEP_IOC_MAGIC_NUMBER, 20, struct sep_driver_rar_handle_to_bus)

#define SEP_IOCTLSINGLETONLOCK	\
	_IO(SEP_IOC_MAGIC_NUMBER, 32)

#define SEP_IOCTLSINGLETONUNLOCK	\
	_IO(SEP_IOC_MAGIC_NUMBER, 33)

#define SEP_IOCTLSETCALLERID	\
	_IOW(SEP_IOC_MAGIC_NUMBER, 34, struct sep_driver_set_caller_id_t)

#define SEP_IOCPREPAREDCB					\
	_IOW(SEP_IOC_MAGIC_NUMBER, 35, struct sep_driver_build_dcb_t)

#define SEP_IOCFREEDCB					\
	_IO(SEP_IOC_MAGIC_NUMBER, 36)

#endif