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