]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - sys/mips/include/octeon_cop2.h
bhnd(9): Fix a few mandoc related issues
[FreeBSD/FreeBSD.git] / sys / mips / include / octeon_cop2.h
1 /*-
2  * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
3  *
4  * Copyright (c) 2011, Oleksandr Tymoshenko <gonzo@FreeBSD.org>
5  * All rights reserved.
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions
9  * are met:
10  * 1. Redistributions of source code must retain the above copyright
11  *    notice unmodified, this list of conditions, and the following
12  *    disclaimer.
13  * 2. Redistributions in binary form must reproduce the above copyright
14  *    notice, this list of conditions and the following disclaimer in the
15  *    documentation and/or other materials provided with the distribution.
16  *
17  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
18  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
21  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27  * SUCH DAMAGE.
28  *
29  * $FreeBSD$
30  *
31  */
32
33 #ifndef __OCTEON_COP2_H__
34 #define __OCTEON_COP2_H__
35
36 /*
37  * COP2 registers of interest
38  */
39 #define COP2_CRC_IV             0x201
40 #define COP2_CRC_IV_SET         COP2_CRC_IV
41 #define COP2_CRC_LENGTH         0x202
42 #define COP2_CRC_LENGTH_SET     0x1202
43 #define COP2_CRC_POLY           0x200
44 #define COP2_CRC_POLY_SET       0x4200
45 #define COP2_LLM_DAT0           0x402
46 #define COP2_LLM_DAT0_SET       COP2_LLM_DAT0
47 #define COP2_LLM_DAT1           0x40A
48 #define COP2_LLM_DAT1_SET       COP2_LLM_DAT1
49 #define COP2_3DES_IV            0x084
50 #define COP2_3DES_IV_SET        COP2_3DES_IV
51 #define COP2_3DES_KEY0          0x080
52 #define COP2_3DES_KEY0_SET      COP2_3DES_KEY0
53 #define COP2_3DES_KEY1          0x081
54 #define COP2_3DES_KEY1_SET      COP2_3DES_KEY1
55 #define COP2_3DES_KEY2          0x082
56 #define COP2_3DES_KEY2_SET      COP2_3DES_KEY2
57 #define COP2_3DES_RESULT        0x088
58 #define COP2_3DES_RESULT_SET    0x098
59 #define COP2_AES_INP0           0x111
60 #define COP2_AES_INP0_SET       COP2_AES_INP0
61 #define COP2_AES_IV0            0x102
62 #define COP2_AES_IV0_SET        COP2_AES_IV0
63 #define COP2_AES_IV1            0x103
64 #define COP2_AES_IV1_SET        COP2_AES_IV1
65 #define COP2_AES_KEY0           0x104
66 #define COP2_AES_KEY0_SET       COP2_AES_KEY0
67 #define COP2_AES_KEY1           0x105
68 #define COP2_AES_KEY1_SET       COP2_AES_KEY1
69 #define COP2_AES_KEY2           0x106
70 #define COP2_AES_KEY2_SET       COP2_AES_KEY2
71 #define COP2_AES_KEY3           0x107
72 #define COP2_AES_KEY3_SET       COP2_AES_KEY3
73 #define COP2_AES_KEYLEN         0x110
74 #define COP2_AES_KEYLEN_SET     COP2_AES_KEYLEN
75 #define COP2_AES_RESULT0        0x100
76 #define COP2_AES_RESULT0_SET    COP2_AES_RESULT0
77 #define COP2_AES_RESULT1        0x101
78 #define COP2_AES_RESULT1_SET    COP2_AES_RESULT1
79 #define COP2_HSH_DATW0          0x240
80 #define COP2_HSH_DATW0_SET      COP2_HSH_DATW0
81 #define COP2_HSH_DATW1          0x241
82 #define COP2_HSH_DATW1_SET      COP2_HSH_DATW1
83 #define COP2_HSH_DATW2          0x242
84 #define COP2_HSH_DATW2_SET      COP2_HSH_DATW2
85 #define COP2_HSH_DATW3          0x243
86 #define COP2_HSH_DATW3_SET      COP2_HSH_DATW3
87 #define COP2_HSH_DATW4          0x244
88 #define COP2_HSH_DATW4_SET      COP2_HSH_DATW4
89 #define COP2_HSH_DATW5          0x245
90 #define COP2_HSH_DATW5_SET      COP2_HSH_DATW5
91 #define COP2_HSH_DATW6          0x246
92 #define COP2_HSH_DATW6_SET      COP2_HSH_DATW6
93 #define COP2_HSH_DATW7          0x247
94 #define COP2_HSH_DATW7_SET      COP2_HSH_DATW7
95 #define COP2_HSH_DATW8          0x248
96 #define COP2_HSH_DATW8_SET      COP2_HSH_DATW8
97 #define COP2_HSH_DATW9          0x249
98 #define COP2_HSH_DATW9_SET      COP2_HSH_DATW9
99 #define COP2_HSH_DATW10         0x24A
100 #define COP2_HSH_DATW10_SET     COP2_HSH_DATW10
101 #define COP2_HSH_DATW11         0x24B
102 #define COP2_HSH_DATW11_SET     COP2_HSH_DATW11
103 #define COP2_HSH_DATW12         0x24C
104 #define COP2_HSH_DATW12_SET     COP2_HSH_DATW12
105 #define COP2_HSH_DATW13         0x24D
106 #define COP2_HSH_DATW13_SET     COP2_HSH_DATW13
107 #define COP2_HSH_DATW14         0x24E
108 #define COP2_HSH_DATW14_SET     COP2_HSH_DATW14
109 #define COP2_HSH_IVW0           0x250
110 #define COP2_HSH_IVW0_SET       COP2_HSH_IVW0
111 #define COP2_HSH_IVW1           0x251
112 #define COP2_HSH_IVW1_SET       COP2_HSH_IVW1
113 #define COP2_HSH_IVW2           0x252
114 #define COP2_HSH_IVW2_SET       COP2_HSH_IVW2
115 #define COP2_HSH_IVW3           0x253
116 #define COP2_HSH_IVW3_SET       COP2_HSH_IVW3
117 #define COP2_HSH_IVW4           0x254
118 #define COP2_HSH_IVW4_SET       COP2_HSH_IVW4
119 #define COP2_HSH_IVW5           0x255
120 #define COP2_HSH_IVW5_SET       COP2_HSH_IVW5
121 #define COP2_HSH_IVW6           0x256
122 #define COP2_HSH_IVW6_SET       COP2_HSH_IVW6
123 #define COP2_HSH_IVW7           0x257
124 #define COP2_HSH_IVW7_SET       COP2_HSH_IVW7
125 #define COP2_GFM_MULT0          0x258
126 #define COP2_GFM_MULT0_SET      COP2_GFM_MULT0
127 #define COP2_GFM_MULT1          0x259
128 #define COP2_GFM_MULT1_SET      COP2_GFM_MULT1
129 #define COP2_GFM_POLY           0x25E
130 #define COP2_GFM_POLY_SET       COP2_GFM_POLY
131 #define COP2_GFM_RESULT0        0x25A
132 #define COP2_GFM_RESULT0_SET    COP2_GFM_RESULT0
133 #define COP2_GFM_RESULT1        0x25B
134 #define COP2_GFM_RESULT1_SET    COP2_GFM_RESULT1
135 #define COP2_HSH_DATW0_PASS1    0x040
136 #define COP2_HSH_DATW0_PASS1_SET        COP2_HSH_DATW0_PASS1
137 #define COP2_HSH_DATW1_PASS1    0x041
138 #define COP2_HSH_DATW1_PASS1_SET        COP2_HSH_DATW1_PASS1
139 #define COP2_HSH_DATW2_PASS1    0x042
140 #define COP2_HSH_DATW2_PASS1_SET        COP2_HSH_DATW2_PASS1
141 #define COP2_HSH_DATW3_PASS1    0x043
142 #define COP2_HSH_DATW3_PASS1_SET        COP2_HSH_DATW3_PASS1
143 #define COP2_HSH_DATW4_PASS1    0x044
144 #define COP2_HSH_DATW4_PASS1_SET        COP2_HSH_DATW4_PASS1
145 #define COP2_HSH_DATW5_PASS1    0x045
146 #define COP2_HSH_DATW5_PASS1_SET        COP2_HSH_DATW5_PASS1
147 #define COP2_HSH_DATW6_PASS1    0x046
148 #define COP2_HSH_DATW6_PASS1_SET        COP2_HSH_DATW6_PASS1
149 #define COP2_HSH_IVW0_PASS1     0x048
150 #define COP2_HSH_IVW0_PASS1_SET COP2_HSH_IVW0_PASS1
151 #define COP2_HSH_IVW1_PASS1     0x049
152 #define COP2_HSH_IVW1_PASS1_SET COP2_HSH_IVW1_PASS1
153 #define COP2_HSH_IVW2_PASS1     0x04A
154 #define COP2_HSH_IVW2_PASS1_SET COP2_HSH_IVW2_PASS1
155
156 #ifndef LOCORE
157
158 struct octeon_cop2_state {
159         /* 3DES */
160         /* 0x0084 */
161         unsigned long   _3des_iv;
162         /* 0x0080..0x0082 */
163         unsigned long   _3des_key[3];
164         /* 0x0088, set: 0x0098 */
165         unsigned long   _3des_result;
166
167         /* AES */
168         /* 0x0111 */
169         unsigned long   aes_inp0;
170         /* 0x0102..0x0103 */
171         unsigned long   aes_iv[2];
172         /* 0x0104..0x0107 */
173         unsigned long   aes_key[4];
174         /* 0x0110 */
175         unsigned long   aes_keylen;
176         /* 0x0100..0x0101 */
177         unsigned long   aes_result[2];
178
179         /* CRC */
180         /*  0x0201 */
181         unsigned long   crc_iv;
182         /* 0x0202, set: 0x1202 */
183         unsigned long   crc_length;
184         /* 0x0200, set: 0x4200 */
185         unsigned long   crc_poly;
186
187         /* Low-latency memory stuff */
188         /* 0x0402, 0x040A */
189         unsigned long   llm_dat[2];
190
191         /* SHA & MD5 */
192         /* 0x0240..0x024E */
193         unsigned long   hsh_datw[15];
194         /* 0x0250..0x0257 */
195         unsigned long   hsh_ivw[8];
196
197         /* GFM */
198         /*  0x0258..0x0259 */
199         unsigned long   gfm_mult[2];
200         /* 0x025E */
201         unsigned long   gfm_poly;
202         /* 0x025A..0x025B */
203         unsigned long   gfm_result[2];
204 };
205
206 /* Prototypes */
207
208 struct octeon_cop2_state* octeon_cop2_alloc_ctx(void);
209 void octeon_cop2_free_ctx(struct octeon_cop2_state *);
210 /*
211  * Save/restore part
212  */
213 void octeon_cop2_save(struct octeon_cop2_state *);
214 void octeon_cop2_restore(struct octeon_cop2_state *);
215
216 #endif /* LOCORE */
217 #endif /* __OCTEON_COP2_H__ */