Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
sep_driver_api.h
Go to the documentation of this file.
1 /*
2  *
3  * sep_driver_api.h - Security Processor Driver api definitions
4  *
5  * Copyright(c) 2009-2011 Intel Corporation. All rights reserved.
6  * Contributions(c) 2009-2011 Discretix. All rights reserved.
7  *
8  * This program is free software; you can redistribute it and/or modify it
9  * under the terms of the GNU General Public License as published by the Free
10  * Software Foundation; version 2 of the License.
11  *
12  * This program is distributed in the hope that it will be useful, but WITHOUT
13  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
15  * more details.
16  *
17  * You should have received a copy of the GNU General Public License along with
18  * this program; if not, write to the Free Software Foundation, Inc., 59
19  * Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20  *
21  * CONTACTS:
22  *
23  * Mark Allyn [email protected]
24  * Jayant Mangalampalli [email protected]
25  *
26  * CHANGES:
27  *
28  * 2010.09.14 Upgrade to Medfield
29  * 2011.02.22 Enable kernel crypto
30  *
31  */
32 
33 #ifndef __SEP_DRIVER_API_H__
34 #define __SEP_DRIVER_API_H__
35 
36 /* Type of request from device */
37 #define SEP_DRIVER_SRC_REPLY 1
38 #define SEP_DRIVER_SRC_REQ 2
39 #define SEP_DRIVER_SRC_PRINTF 3
40 
41 /* Power state */
42 #define SEP_DRIVER_POWERON 1
43 #define SEP_DRIVER_POWEROFF 2
44 
45 /* Following enums are used only for kernel crypto api */
55  MD5,
58  };
59 
60 enum hash_stage {
67 };
68 
69 /*
70  structure that represents DCB
71 */
72 struct sep_dcblock {
73  /* physical address of the first input mlli */
75  /* num of entries in the first input mlli */
77  /* size of data in the first input mlli */
79  /* physical address of the first output mlli */
81  /* num of entries in the first output mlli */
83  /* size of data in the first output mlli */
85  /* pointer to the output virtual tail */
87  /* size of tail data */
89  /* input tail data array */
91 };
92 
93 /*
94  command structure for building dcb block (currently for ext app only)
95 */
97  /* address value of the data in */
99  /* size of data in */
101  /* address of the data out */
103  /* the size of the block of the operation - if needed,
104  every table will be modulo this parameter */
106  /* the size of the block of the operation - if needed,
107  every table will be modulo this parameter */
109 
110  /* which application calls the driver DX or applet */
112 };
113 
114 /*
115  command structure for building dcb block for kernel crypto
116 */
118  /* address value of the data in */
120  /* size of data in */
122  /* address of the data out */
124  /* the size of the block of the operation - if needed,
125  every table will be modulo this parameter */
127  /* the size of the block of the operation - if needed,
128  every table will be modulo this parameter */
130 
131  /* which application calls the driver DX or applet */
133 
136 };
137 
146 struct sep_dma_map {
147  /* mapped dma address */
149  /* size of the mapped data */
150  size_t size;
151 };
152 
154  /* array of pointers to the pages that represent
155  input data for the synchronic DMA action */
156  struct page **in_page_array;
157 
158  /* array of pointers to the pages that represent out
159  data for the synchronic DMA action */
161 
162  /* number of pages in the sep_in_page_array */
164 
165  /* number of pages in the sep_out_page_array */
167 
168  /* map array of the input data */
170 
171  /* map array of the output data */
173 
174  /* number of entries of the input mapp array */
176 
177  /* number of entries of the output mapp array */
179 
180  /* Scatter list for kernel operations */
183 };
184 
185 
186 /* command struct for translating rar handle to bus address
187  and setting it at predefined location */
189 
190  /* rar handle */
192 };
193 
194 /*
195  structure that represent one entry in the DMA LLI table
196 */
198  /* physical address */
200 
201  /* block size */
203 };
204 
205 /*
206  * header format for each fastcall write operation
207  */
213 };
214 
215 /*
216  * structure used in file pointer's private data field
217  * to track the status of the calls to the various
218  * driver interface
219  */
221  unsigned long status;
222 };
223 
224 /*
225  * format of dma context buffer used to store all DMA-related
226  * context information of a particular transaction
227  */
229  /* number of data control blocks */
231  /* number of the lli tables created in the current transaction */
233  /* size of currently allocated dma tables region */
235  /* size of input data */
237  /* secure dma use (for imr memory restricted area in output) */
240  /* Scatter gather for kernel crypto */
243 };
244 
245 /*
246  * format for file pointer's private_data field
247  */
253 };
254 
255 
256 /* Functions used by sep_crypto */
257 
265 void sep_queue_status_remove(struct sep_device *sep,
266  struct sep_queue_info **queue_elem);
280  struct sep_device *sep,
281  u32 opcode,
282  u32 size,
283  u32 pid,
284  u8 *name, size_t name_len);
285 
297  struct sep_dcblock **dcb_region,
298  void **dmatables_region,
299  struct sep_dma_context **dma_ctx,
300  const struct build_dcb_struct_kernel *dcb_data,
301  const u32 num_dcbs);
302 
312  struct sep_dcblock **dcb_region,
313  void **dmatables_region,
314  struct sep_dma_context *dma_ctx);
315 
334  unsigned long app_in_address,
335  unsigned long app_out_address,
336  u32 data_in_size,
337  u32 block_size,
338  u32 tail_block_size,
339  bool isapplet,
340  bool is_kva,
341  bool secure_dma,
342  struct sep_dcblock *dcb_region,
343  void **dmatables_region,
344  struct sep_dma_context **dma_ctx,
345  struct scatterlist *src_sg,
346  struct scatterlist *dst_sg);
347 
356  struct sep_dma_context **dma_ctx);
366 int sep_send_command_handler(struct sep_device *sep);
367 
372 int sep_wait_transaction(struct sep_device *sep);
373 
377 /* magic number 1 of the sep IOCTL command */
378 #define SEP_IOC_MAGIC_NUMBER 's'
379 
380 /* sends interrupt to sep that message is ready */
381 #define SEP_IOCSENDSEPCOMMAND \
382  _IO(SEP_IOC_MAGIC_NUMBER, 0)
383 
384 /* end transaction command */
385 #define SEP_IOCENDTRANSACTION \
386  _IO(SEP_IOC_MAGIC_NUMBER, 15)
387 
388 #define SEP_IOCPREPAREDCB \
389  _IOW(SEP_IOC_MAGIC_NUMBER, 35, struct build_dcb_struct)
390 
391 #define SEP_IOCFREEDCB \
392  _IO(SEP_IOC_MAGIC_NUMBER, 36)
393 
394 struct sep_device;
395 
396 #define SEP_IOCPREPAREDCB_SECURE_DMA \
397  _IOW(SEP_IOC_MAGIC_NUMBER, 38, struct build_dcb_struct)
398 
399 #define SEP_IOCFREEDCB_SECURE_DMA \
400  _IO(SEP_IOC_MAGIC_NUMBER, 39)
401 
402 #endif