1 /*
2  *
3  *  sep_driver_api.h - Security Processor Driver api definitions
4  *
5  *  Copyright(c) 2009,2010 Intel Corporation. All rights reserved.
6  *  Contributions(c) 2009,2010 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		mark.a.allyn@intel.com
24  *  Jayant Mangalampalli jayant.mangalampalli@intel.com
25  *
26  *  CHANGES:
27  *
28  *  2010.09.14  Upgrade to Medfield
29  *
30  */
31 
32 #ifndef __SEP_DRIVER_API_H__
33 #define __SEP_DRIVER_API_H__
34 
35 /* Type of request from device */
36 #define SEP_DRIVER_SRC_REPLY		1
37 #define SEP_DRIVER_SRC_REQ		2
38 #define SEP_DRIVER_SRC_PRINTF		3
39 
40 
41 /*-------------------------------------------
42     TYPEDEFS
43 ----------------------------------------------*/
44 
45 struct alloc_struct {
46 	/* offset from start of shared pool area */
47 	u32  offset;
48 	/* number of bytes to allocate */
49 	u32  num_bytes;
50 };
51 
52 /* command struct for getting caller id value and address */
53 struct caller_id_struct {
54 	/* pid of the process */
55 	u32 pid;
56 	/* virtual address of the caller id hash */
57 	aligned_u64 callerIdAddress;
58 	/* caller id hash size in bytes */
59 	u32 callerIdSizeInBytes;
60 };
61 
62 /*
63   structure that represents DCB
64 */
65 struct sep_dcblock {
66 	/* physical address of the first input mlli */
67 	u32	input_mlli_address;
68 	/* num of entries in the first input mlli */
69 	u32	input_mlli_num_entries;
70 	/* size of data in the first input mlli */
71 	u32	input_mlli_data_size;
72 	/* physical address of the first output mlli */
73 	u32	output_mlli_address;
74 	/* num of entries in the first output mlli */
75 	u32	output_mlli_num_entries;
76 	/* size of data in the first output mlli */
77 	u32	output_mlli_data_size;
78 	/* pointer to the output virtual tail */
79 	aligned_u64 out_vr_tail_pt;
80 	/* size of tail data */
81 	u32	tail_data_size;
82 	/* input tail data array */
83 	u8	tail_data[68];
84 };
85 
86 struct sep_caller_id_entry {
87 	int pid;
88 	unsigned char callerIdHash[SEP_CALLER_ID_HASH_SIZE_IN_BYTES];
89 };
90 
91 /*
92 	command structure for building dcb block (currently for ext app only
93 */
94 struct build_dcb_struct {
95 	/* address value of the data in */
96 	aligned_u64 app_in_address;
97 	/* size of data in */
98 	u32  data_in_size;
99 	/* address of the data out */
100 	aligned_u64 app_out_address;
101 	/* the size of the block of the operation - if needed,
102 	every table will be modulo this parameter */
103 	u32  block_size;
104 	/* the size of the block of the operation - if needed,
105 	every table will be modulo this parameter */
106 	u32  tail_block_size;
107 };
108 
109 /**
110  * @struct sep_dma_map
111  *
112  * Structure that contains all information needed for mapping the user pages
113  *	     or kernel buffers for dma operations
114  *
115  *
116  */
117 struct sep_dma_map {
118 	/* mapped dma address */
119 	dma_addr_t    dma_addr;
120 	/* size of the mapped data */
121 	size_t        size;
122 };
123 
124 struct sep_dma_resource {
125 	/* array of pointers to the pages that represent
126 	input data for the synchronic DMA action */
127 	struct page **in_page_array;
128 
129 	/* array of pointers to the pages that represent out
130 	data for the synchronic DMA action */
131 	struct page **out_page_array;
132 
133 	/* number of pages in the sep_in_page_array */
134 	u32 in_num_pages;
135 
136 	/* number of pages in the sep_out_page_array */
137 	u32 out_num_pages;
138 
139 	/* map array of the input data */
140 	struct sep_dma_map *in_map_array;
141 
142 	/* map array of the output data */
143 	struct sep_dma_map *out_map_array;
144 
145 	/* number of entries of the input mapp array */
146 	u32 in_map_num_entries;
147 
148 	/* number of entries of the output mapp array */
149 	u32 out_map_num_entries;
150 };
151 
152 
153 /* command struct for translating rar handle to bus address
154    and setting it at predefined location */
155 struct rar_hndl_to_bus_struct {
156 
157 	/* rar handle */
158 	aligned_u64 rar_handle;
159 };
160 
161 /*
162   structure that represent one entry in the DMA LLI table
163 */
164 struct sep_lli_entry {
165 	/* physical address */
166 	u32 bus_address;
167 
168 	/* block size */
169 	u32 block_size;
170 };
171 
172 /*----------------------------------------------------------------
173 	IOCTL command defines
174 	-----------------------------------------------------------------*/
175 
176 /* magic number 1 of the sep IOCTL command */
177 #define SEP_IOC_MAGIC_NUMBER	                     's'
178 
179 /* sends interrupt to sep that message is ready */
180 #define SEP_IOCSENDSEPCOMMAND	 \
181 	_IO(SEP_IOC_MAGIC_NUMBER, 0)
182 
183 /* sends interrupt to sep that message is ready */
184 #define SEP_IOCSENDSEPRPLYCOMMAND	 \
185 	_IO(SEP_IOC_MAGIC_NUMBER, 1)
186 
187 /* allocate memory in data pool */
188 #define SEP_IOCALLOCDATAPOLL	\
189 	_IOW(SEP_IOC_MAGIC_NUMBER, 2, struct alloc_struct)
190 
191 /* free dynamic data aalocated during table creation */
192 #define SEP_IOCFREEDMATABLEDATA	 \
193 	_IO(SEP_IOC_MAGIC_NUMBER, 7)
194 
195 /* get the static pool area addersses (physical and virtual) */
196 #define SEP_IOCGETSTATICPOOLADDR	\
197 	_IO(SEP_IOC_MAGIC_NUMBER, 8)
198 
199 /* end transaction command */
200 #define SEP_IOCENDTRANSACTION	 \
201 	_IO(SEP_IOC_MAGIC_NUMBER, 15)
202 
203 #define SEP_IOCRARPREPAREMESSAGE	\
204 	_IOW(SEP_IOC_MAGIC_NUMBER, 20, struct rar_hndl_to_bus_struct)
205 
206 #define SEP_IOCTLSETCALLERID	\
207 	_IOW(SEP_IOC_MAGIC_NUMBER, 34, struct caller_id_struct)
208 
209 #define SEP_IOCPREPAREDCB					\
210 	_IOW(SEP_IOC_MAGIC_NUMBER, 35, struct build_dcb_struct)
211 
212 #define SEP_IOCFREEDCB					\
213 	_IO(SEP_IOC_MAGIC_NUMBER, 36)
214 
215 #endif
216