1*5b3b1688SDavid Daney/* 2*5b3b1688SDavid Daney * This file is subject to the terms and conditions of the GNU General Public 3*5b3b1688SDavid Daney * License. See the file "COPYING" in the main directory of this archive 4*5b3b1688SDavid Daney * for more details. 5*5b3b1688SDavid Daney * 6*5b3b1688SDavid Daney * Copyright (C) 1994, 1995, 1996, 1998, 1999, 2002, 2003 Ralf Baechle 7*5b3b1688SDavid Daney * Copyright (C) 1996 David S. Miller (dm@engr.sgi.com) 8*5b3b1688SDavid Daney * Copyright (C) 1994, 1995, 1996, by Andreas Busse 9*5b3b1688SDavid Daney * Copyright (C) 1999 Silicon Graphics, Inc. 10*5b3b1688SDavid Daney * Copyright (C) 2000 MIPS Technologies, Inc. 11*5b3b1688SDavid Daney * written by Carsten Langgaard, carstenl@mips.com 12*5b3b1688SDavid Daney */ 13*5b3b1688SDavid Daney#include <asm/asm.h> 14*5b3b1688SDavid Daney#include <asm/cachectl.h> 15*5b3b1688SDavid Daney#include <asm/fpregdef.h> 16*5b3b1688SDavid Daney#include <asm/mipsregs.h> 17*5b3b1688SDavid Daney#include <asm/asm-offsets.h> 18*5b3b1688SDavid Daney#include <asm/page.h> 19*5b3b1688SDavid Daney#include <asm/pgtable-bits.h> 20*5b3b1688SDavid Daney#include <asm/regdef.h> 21*5b3b1688SDavid Daney#include <asm/stackframe.h> 22*5b3b1688SDavid Daney#include <asm/thread_info.h> 23*5b3b1688SDavid Daney 24*5b3b1688SDavid Daney#include <asm/asmmacro.h> 25*5b3b1688SDavid Daney 26*5b3b1688SDavid Daney/* 27*5b3b1688SDavid Daney * Offset to the current process status flags, the first 32 bytes of the 28*5b3b1688SDavid Daney * stack are not used. 29*5b3b1688SDavid Daney */ 30*5b3b1688SDavid Daney#define ST_OFF (_THREAD_SIZE - 32 - PT_SIZE + PT_STATUS) 31*5b3b1688SDavid Daney 32*5b3b1688SDavid Daney/* 33*5b3b1688SDavid Daney * task_struct *resume(task_struct *prev, task_struct *next, 34*5b3b1688SDavid Daney * struct thread_info *next_ti) 35*5b3b1688SDavid Daney */ 36*5b3b1688SDavid Daney .align 7 37*5b3b1688SDavid Daney LEAF(resume) 38*5b3b1688SDavid Daney .set arch=octeon 39*5b3b1688SDavid Daney#ifndef CONFIG_CPU_HAS_LLSC 40*5b3b1688SDavid Daney sw zero, ll_bit 41*5b3b1688SDavid Daney#endif 42*5b3b1688SDavid Daney mfc0 t1, CP0_STATUS 43*5b3b1688SDavid Daney LONG_S t1, THREAD_STATUS(a0) 44*5b3b1688SDavid Daney cpu_save_nonscratch a0 45*5b3b1688SDavid Daney LONG_S ra, THREAD_REG31(a0) 46*5b3b1688SDavid Daney 47*5b3b1688SDavid Daney /* check if we need to save COP2 registers */ 48*5b3b1688SDavid Daney PTR_L t2, TASK_THREAD_INFO(a0) 49*5b3b1688SDavid Daney LONG_L t0, ST_OFF(t2) 50*5b3b1688SDavid Daney bbit0 t0, 30, 1f 51*5b3b1688SDavid Daney 52*5b3b1688SDavid Daney /* Disable COP2 in the stored process state */ 53*5b3b1688SDavid Daney li t1, ST0_CU2 54*5b3b1688SDavid Daney xor t0, t1 55*5b3b1688SDavid Daney LONG_S t0, ST_OFF(t2) 56*5b3b1688SDavid Daney 57*5b3b1688SDavid Daney /* Enable COP2 so we can save it */ 58*5b3b1688SDavid Daney mfc0 t0, CP0_STATUS 59*5b3b1688SDavid Daney or t0, t1 60*5b3b1688SDavid Daney mtc0 t0, CP0_STATUS 61*5b3b1688SDavid Daney 62*5b3b1688SDavid Daney /* Save COP2 */ 63*5b3b1688SDavid Daney daddu a0, THREAD_CP2 64*5b3b1688SDavid Daney jal octeon_cop2_save 65*5b3b1688SDavid Daney dsubu a0, THREAD_CP2 66*5b3b1688SDavid Daney 67*5b3b1688SDavid Daney /* Disable COP2 now that we are done */ 68*5b3b1688SDavid Daney mfc0 t0, CP0_STATUS 69*5b3b1688SDavid Daney li t1, ST0_CU2 70*5b3b1688SDavid Daney xor t0, t1 71*5b3b1688SDavid Daney mtc0 t0, CP0_STATUS 72*5b3b1688SDavid Daney 73*5b3b1688SDavid Daney1: 74*5b3b1688SDavid Daney#if CONFIG_CAVIUM_OCTEON_CVMSEG_SIZE > 0 75*5b3b1688SDavid Daney /* Check if we need to store CVMSEG state */ 76*5b3b1688SDavid Daney mfc0 t0, $11,7 /* CvmMemCtl */ 77*5b3b1688SDavid Daney bbit0 t0, 6, 3f /* Is user access enabled? */ 78*5b3b1688SDavid Daney 79*5b3b1688SDavid Daney /* Store the CVMSEG state */ 80*5b3b1688SDavid Daney /* Extract the size of CVMSEG */ 81*5b3b1688SDavid Daney andi t0, 0x3f 82*5b3b1688SDavid Daney /* Multiply * (cache line size/sizeof(long)/2) */ 83*5b3b1688SDavid Daney sll t0, 7-LONGLOG-1 84*5b3b1688SDavid Daney li t1, -32768 /* Base address of CVMSEG */ 85*5b3b1688SDavid Daney LONG_ADDI t2, a0, THREAD_CVMSEG /* Where to store CVMSEG to */ 86*5b3b1688SDavid Daney synciobdma 87*5b3b1688SDavid Daney2: 88*5b3b1688SDavid Daney .set noreorder 89*5b3b1688SDavid Daney LONG_L t8, 0(t1) /* Load from CVMSEG */ 90*5b3b1688SDavid Daney subu t0, 1 /* Decrement loop var */ 91*5b3b1688SDavid Daney LONG_L t9, LONGSIZE(t1)/* Load from CVMSEG */ 92*5b3b1688SDavid Daney LONG_ADDU t1, LONGSIZE*2 /* Increment loc in CVMSEG */ 93*5b3b1688SDavid Daney LONG_S t8, 0(t2) /* Store CVMSEG to thread storage */ 94*5b3b1688SDavid Daney LONG_ADDU t2, LONGSIZE*2 /* Increment loc in thread storage */ 95*5b3b1688SDavid Daney bnez t0, 2b /* Loop until we've copied it all */ 96*5b3b1688SDavid Daney LONG_S t9, -LONGSIZE(t2)/* Store CVMSEG to thread storage */ 97*5b3b1688SDavid Daney .set reorder 98*5b3b1688SDavid Daney 99*5b3b1688SDavid Daney /* Disable access to CVMSEG */ 100*5b3b1688SDavid Daney mfc0 t0, $11,7 /* CvmMemCtl */ 101*5b3b1688SDavid Daney xori t0, t0, 0x40 /* Bit 6 is CVMSEG user enable */ 102*5b3b1688SDavid Daney mtc0 t0, $11,7 /* CvmMemCtl */ 103*5b3b1688SDavid Daney#endif 104*5b3b1688SDavid Daney3: 105*5b3b1688SDavid Daney /* 106*5b3b1688SDavid Daney * The order of restoring the registers takes care of the race 107*5b3b1688SDavid Daney * updating $28, $29 and kernelsp without disabling ints. 108*5b3b1688SDavid Daney */ 109*5b3b1688SDavid Daney move $28, a2 110*5b3b1688SDavid Daney cpu_restore_nonscratch a1 111*5b3b1688SDavid Daney 112*5b3b1688SDavid Daney#if (_THREAD_SIZE - 32) < 0x8000 113*5b3b1688SDavid Daney PTR_ADDIU t0, $28, _THREAD_SIZE - 32 114*5b3b1688SDavid Daney#else 115*5b3b1688SDavid Daney PTR_LI t0, _THREAD_SIZE - 32 116*5b3b1688SDavid Daney PTR_ADDU t0, $28 117*5b3b1688SDavid Daney#endif 118*5b3b1688SDavid Daney set_saved_sp t0, t1, t2 119*5b3b1688SDavid Daney 120*5b3b1688SDavid Daney mfc0 t1, CP0_STATUS /* Do we really need this? */ 121*5b3b1688SDavid Daney li a3, 0xff01 122*5b3b1688SDavid Daney and t1, a3 123*5b3b1688SDavid Daney LONG_L a2, THREAD_STATUS(a1) 124*5b3b1688SDavid Daney nor a3, $0, a3 125*5b3b1688SDavid Daney and a2, a3 126*5b3b1688SDavid Daney or a2, t1 127*5b3b1688SDavid Daney mtc0 a2, CP0_STATUS 128*5b3b1688SDavid Daney move v0, a0 129*5b3b1688SDavid Daney jr ra 130*5b3b1688SDavid Daney END(resume) 131*5b3b1688SDavid Daney 132*5b3b1688SDavid Daney/* 133*5b3b1688SDavid Daney * void octeon_cop2_save(struct octeon_cop2_state *a0) 134*5b3b1688SDavid Daney */ 135*5b3b1688SDavid Daney .align 7 136*5b3b1688SDavid Daney LEAF(octeon_cop2_save) 137*5b3b1688SDavid Daney 138*5b3b1688SDavid Daney dmfc0 t9, $9,7 /* CvmCtl register. */ 139*5b3b1688SDavid Daney 140*5b3b1688SDavid Daney /* Save the COP2 CRC state */ 141*5b3b1688SDavid Daney dmfc2 t0, 0x0201 142*5b3b1688SDavid Daney dmfc2 t1, 0x0202 143*5b3b1688SDavid Daney dmfc2 t2, 0x0200 144*5b3b1688SDavid Daney sd t0, OCTEON_CP2_CRC_IV(a0) 145*5b3b1688SDavid Daney sd t1, OCTEON_CP2_CRC_LENGTH(a0) 146*5b3b1688SDavid Daney sd t2, OCTEON_CP2_CRC_POLY(a0) 147*5b3b1688SDavid Daney /* Skip next instructions if CvmCtl[NODFA_CP2] set */ 148*5b3b1688SDavid Daney bbit1 t9, 28, 1f 149*5b3b1688SDavid Daney 150*5b3b1688SDavid Daney /* Save the LLM state */ 151*5b3b1688SDavid Daney dmfc2 t0, 0x0402 152*5b3b1688SDavid Daney dmfc2 t1, 0x040A 153*5b3b1688SDavid Daney sd t0, OCTEON_CP2_LLM_DAT(a0) 154*5b3b1688SDavid Daney sd t1, OCTEON_CP2_LLM_DAT+8(a0) 155*5b3b1688SDavid Daney 156*5b3b1688SDavid Daney1: bbit1 t9, 26, 3f /* done if CvmCtl[NOCRYPTO] set */ 157*5b3b1688SDavid Daney 158*5b3b1688SDavid Daney /* Save the COP2 crypto state */ 159*5b3b1688SDavid Daney /* this part is mostly common to both pass 1 and later revisions */ 160*5b3b1688SDavid Daney dmfc2 t0, 0x0084 161*5b3b1688SDavid Daney dmfc2 t1, 0x0080 162*5b3b1688SDavid Daney dmfc2 t2, 0x0081 163*5b3b1688SDavid Daney dmfc2 t3, 0x0082 164*5b3b1688SDavid Daney sd t0, OCTEON_CP2_3DES_IV(a0) 165*5b3b1688SDavid Daney dmfc2 t0, 0x0088 166*5b3b1688SDavid Daney sd t1, OCTEON_CP2_3DES_KEY(a0) 167*5b3b1688SDavid Daney dmfc2 t1, 0x0111 /* only necessary for pass 1 */ 168*5b3b1688SDavid Daney sd t2, OCTEON_CP2_3DES_KEY+8(a0) 169*5b3b1688SDavid Daney dmfc2 t2, 0x0102 170*5b3b1688SDavid Daney sd t3, OCTEON_CP2_3DES_KEY+16(a0) 171*5b3b1688SDavid Daney dmfc2 t3, 0x0103 172*5b3b1688SDavid Daney sd t0, OCTEON_CP2_3DES_RESULT(a0) 173*5b3b1688SDavid Daney dmfc2 t0, 0x0104 174*5b3b1688SDavid Daney sd t1, OCTEON_CP2_AES_INP0(a0) /* only necessary for pass 1 */ 175*5b3b1688SDavid Daney dmfc2 t1, 0x0105 176*5b3b1688SDavid Daney sd t2, OCTEON_CP2_AES_IV(a0) 177*5b3b1688SDavid Daney dmfc2 t2, 0x0106 178*5b3b1688SDavid Daney sd t3, OCTEON_CP2_AES_IV+8(a0) 179*5b3b1688SDavid Daney dmfc2 t3, 0x0107 180*5b3b1688SDavid Daney sd t0, OCTEON_CP2_AES_KEY(a0) 181*5b3b1688SDavid Daney dmfc2 t0, 0x0110 182*5b3b1688SDavid Daney sd t1, OCTEON_CP2_AES_KEY+8(a0) 183*5b3b1688SDavid Daney dmfc2 t1, 0x0100 184*5b3b1688SDavid Daney sd t2, OCTEON_CP2_AES_KEY+16(a0) 185*5b3b1688SDavid Daney dmfc2 t2, 0x0101 186*5b3b1688SDavid Daney sd t3, OCTEON_CP2_AES_KEY+24(a0) 187*5b3b1688SDavid Daney mfc0 t3, $15,0 /* Get the processor ID register */ 188*5b3b1688SDavid Daney sd t0, OCTEON_CP2_AES_KEYLEN(a0) 189*5b3b1688SDavid Daney li t0, 0x000d0000 /* This is the processor ID of Octeon Pass1 */ 190*5b3b1688SDavid Daney sd t1, OCTEON_CP2_AES_RESULT(a0) 191*5b3b1688SDavid Daney sd t2, OCTEON_CP2_AES_RESULT+8(a0) 192*5b3b1688SDavid Daney /* Skip to the Pass1 version of the remainder of the COP2 state */ 193*5b3b1688SDavid Daney beq t3, t0, 2f 194*5b3b1688SDavid Daney 195*5b3b1688SDavid Daney /* the non-pass1 state when !CvmCtl[NOCRYPTO] */ 196*5b3b1688SDavid Daney dmfc2 t1, 0x0240 197*5b3b1688SDavid Daney dmfc2 t2, 0x0241 198*5b3b1688SDavid Daney dmfc2 t3, 0x0242 199*5b3b1688SDavid Daney dmfc2 t0, 0x0243 200*5b3b1688SDavid Daney sd t1, OCTEON_CP2_HSH_DATW(a0) 201*5b3b1688SDavid Daney dmfc2 t1, 0x0244 202*5b3b1688SDavid Daney sd t2, OCTEON_CP2_HSH_DATW+8(a0) 203*5b3b1688SDavid Daney dmfc2 t2, 0x0245 204*5b3b1688SDavid Daney sd t3, OCTEON_CP2_HSH_DATW+16(a0) 205*5b3b1688SDavid Daney dmfc2 t3, 0x0246 206*5b3b1688SDavid Daney sd t0, OCTEON_CP2_HSH_DATW+24(a0) 207*5b3b1688SDavid Daney dmfc2 t0, 0x0247 208*5b3b1688SDavid Daney sd t1, OCTEON_CP2_HSH_DATW+32(a0) 209*5b3b1688SDavid Daney dmfc2 t1, 0x0248 210*5b3b1688SDavid Daney sd t2, OCTEON_CP2_HSH_DATW+40(a0) 211*5b3b1688SDavid Daney dmfc2 t2, 0x0249 212*5b3b1688SDavid Daney sd t3, OCTEON_CP2_HSH_DATW+48(a0) 213*5b3b1688SDavid Daney dmfc2 t3, 0x024A 214*5b3b1688SDavid Daney sd t0, OCTEON_CP2_HSH_DATW+56(a0) 215*5b3b1688SDavid Daney dmfc2 t0, 0x024B 216*5b3b1688SDavid Daney sd t1, OCTEON_CP2_HSH_DATW+64(a0) 217*5b3b1688SDavid Daney dmfc2 t1, 0x024C 218*5b3b1688SDavid Daney sd t2, OCTEON_CP2_HSH_DATW+72(a0) 219*5b3b1688SDavid Daney dmfc2 t2, 0x024D 220*5b3b1688SDavid Daney sd t3, OCTEON_CP2_HSH_DATW+80(a0) 221*5b3b1688SDavid Daney dmfc2 t3, 0x024E 222*5b3b1688SDavid Daney sd t0, OCTEON_CP2_HSH_DATW+88(a0) 223*5b3b1688SDavid Daney dmfc2 t0, 0x0250 224*5b3b1688SDavid Daney sd t1, OCTEON_CP2_HSH_DATW+96(a0) 225*5b3b1688SDavid Daney dmfc2 t1, 0x0251 226*5b3b1688SDavid Daney sd t2, OCTEON_CP2_HSH_DATW+104(a0) 227*5b3b1688SDavid Daney dmfc2 t2, 0x0252 228*5b3b1688SDavid Daney sd t3, OCTEON_CP2_HSH_DATW+112(a0) 229*5b3b1688SDavid Daney dmfc2 t3, 0x0253 230*5b3b1688SDavid Daney sd t0, OCTEON_CP2_HSH_IVW(a0) 231*5b3b1688SDavid Daney dmfc2 t0, 0x0254 232*5b3b1688SDavid Daney sd t1, OCTEON_CP2_HSH_IVW+8(a0) 233*5b3b1688SDavid Daney dmfc2 t1, 0x0255 234*5b3b1688SDavid Daney sd t2, OCTEON_CP2_HSH_IVW+16(a0) 235*5b3b1688SDavid Daney dmfc2 t2, 0x0256 236*5b3b1688SDavid Daney sd t3, OCTEON_CP2_HSH_IVW+24(a0) 237*5b3b1688SDavid Daney dmfc2 t3, 0x0257 238*5b3b1688SDavid Daney sd t0, OCTEON_CP2_HSH_IVW+32(a0) 239*5b3b1688SDavid Daney dmfc2 t0, 0x0258 240*5b3b1688SDavid Daney sd t1, OCTEON_CP2_HSH_IVW+40(a0) 241*5b3b1688SDavid Daney dmfc2 t1, 0x0259 242*5b3b1688SDavid Daney sd t2, OCTEON_CP2_HSH_IVW+48(a0) 243*5b3b1688SDavid Daney dmfc2 t2, 0x025E 244*5b3b1688SDavid Daney sd t3, OCTEON_CP2_HSH_IVW+56(a0) 245*5b3b1688SDavid Daney dmfc2 t3, 0x025A 246*5b3b1688SDavid Daney sd t0, OCTEON_CP2_GFM_MULT(a0) 247*5b3b1688SDavid Daney dmfc2 t0, 0x025B 248*5b3b1688SDavid Daney sd t1, OCTEON_CP2_GFM_MULT+8(a0) 249*5b3b1688SDavid Daney sd t2, OCTEON_CP2_GFM_POLY(a0) 250*5b3b1688SDavid Daney sd t3, OCTEON_CP2_GFM_RESULT(a0) 251*5b3b1688SDavid Daney sd t0, OCTEON_CP2_GFM_RESULT+8(a0) 252*5b3b1688SDavid Daney jr ra 253*5b3b1688SDavid Daney 254*5b3b1688SDavid Daney2: /* pass 1 special stuff when !CvmCtl[NOCRYPTO] */ 255*5b3b1688SDavid Daney dmfc2 t3, 0x0040 256*5b3b1688SDavid Daney dmfc2 t0, 0x0041 257*5b3b1688SDavid Daney dmfc2 t1, 0x0042 258*5b3b1688SDavid Daney dmfc2 t2, 0x0043 259*5b3b1688SDavid Daney sd t3, OCTEON_CP2_HSH_DATW(a0) 260*5b3b1688SDavid Daney dmfc2 t3, 0x0044 261*5b3b1688SDavid Daney sd t0, OCTEON_CP2_HSH_DATW+8(a0) 262*5b3b1688SDavid Daney dmfc2 t0, 0x0045 263*5b3b1688SDavid Daney sd t1, OCTEON_CP2_HSH_DATW+16(a0) 264*5b3b1688SDavid Daney dmfc2 t1, 0x0046 265*5b3b1688SDavid Daney sd t2, OCTEON_CP2_HSH_DATW+24(a0) 266*5b3b1688SDavid Daney dmfc2 t2, 0x0048 267*5b3b1688SDavid Daney sd t3, OCTEON_CP2_HSH_DATW+32(a0) 268*5b3b1688SDavid Daney dmfc2 t3, 0x0049 269*5b3b1688SDavid Daney sd t0, OCTEON_CP2_HSH_DATW+40(a0) 270*5b3b1688SDavid Daney dmfc2 t0, 0x004A 271*5b3b1688SDavid Daney sd t1, OCTEON_CP2_HSH_DATW+48(a0) 272*5b3b1688SDavid Daney sd t2, OCTEON_CP2_HSH_IVW(a0) 273*5b3b1688SDavid Daney sd t3, OCTEON_CP2_HSH_IVW+8(a0) 274*5b3b1688SDavid Daney sd t0, OCTEON_CP2_HSH_IVW+16(a0) 275*5b3b1688SDavid Daney 276*5b3b1688SDavid Daney3: /* pass 1 or CvmCtl[NOCRYPTO] set */ 277*5b3b1688SDavid Daney jr ra 278*5b3b1688SDavid Daney END(octeon_cop2_save) 279*5b3b1688SDavid Daney 280*5b3b1688SDavid Daney/* 281*5b3b1688SDavid Daney * void octeon_cop2_restore(struct octeon_cop2_state *a0) 282*5b3b1688SDavid Daney */ 283*5b3b1688SDavid Daney .align 7 284*5b3b1688SDavid Daney .set push 285*5b3b1688SDavid Daney .set noreorder 286*5b3b1688SDavid Daney LEAF(octeon_cop2_restore) 287*5b3b1688SDavid Daney /* First cache line was prefetched before the call */ 288*5b3b1688SDavid Daney pref 4, 128(a0) 289*5b3b1688SDavid Daney dmfc0 t9, $9,7 /* CvmCtl register. */ 290*5b3b1688SDavid Daney 291*5b3b1688SDavid Daney pref 4, 256(a0) 292*5b3b1688SDavid Daney ld t0, OCTEON_CP2_CRC_IV(a0) 293*5b3b1688SDavid Daney pref 4, 384(a0) 294*5b3b1688SDavid Daney ld t1, OCTEON_CP2_CRC_LENGTH(a0) 295*5b3b1688SDavid Daney ld t2, OCTEON_CP2_CRC_POLY(a0) 296*5b3b1688SDavid Daney 297*5b3b1688SDavid Daney /* Restore the COP2 CRC state */ 298*5b3b1688SDavid Daney dmtc2 t0, 0x0201 299*5b3b1688SDavid Daney dmtc2 t1, 0x1202 300*5b3b1688SDavid Daney bbit1 t9, 28, 2f /* Skip LLM if CvmCtl[NODFA_CP2] is set */ 301*5b3b1688SDavid Daney dmtc2 t2, 0x4200 302*5b3b1688SDavid Daney 303*5b3b1688SDavid Daney /* Restore the LLM state */ 304*5b3b1688SDavid Daney ld t0, OCTEON_CP2_LLM_DAT(a0) 305*5b3b1688SDavid Daney ld t1, OCTEON_CP2_LLM_DAT+8(a0) 306*5b3b1688SDavid Daney dmtc2 t0, 0x0402 307*5b3b1688SDavid Daney dmtc2 t1, 0x040A 308*5b3b1688SDavid Daney 309*5b3b1688SDavid Daney2: 310*5b3b1688SDavid Daney bbit1 t9, 26, done_restore /* done if CvmCtl[NOCRYPTO] set */ 311*5b3b1688SDavid Daney nop 312*5b3b1688SDavid Daney 313*5b3b1688SDavid Daney /* Restore the COP2 crypto state common to pass 1 and pass 2 */ 314*5b3b1688SDavid Daney ld t0, OCTEON_CP2_3DES_IV(a0) 315*5b3b1688SDavid Daney ld t1, OCTEON_CP2_3DES_KEY(a0) 316*5b3b1688SDavid Daney ld t2, OCTEON_CP2_3DES_KEY+8(a0) 317*5b3b1688SDavid Daney dmtc2 t0, 0x0084 318*5b3b1688SDavid Daney ld t0, OCTEON_CP2_3DES_KEY+16(a0) 319*5b3b1688SDavid Daney dmtc2 t1, 0x0080 320*5b3b1688SDavid Daney ld t1, OCTEON_CP2_3DES_RESULT(a0) 321*5b3b1688SDavid Daney dmtc2 t2, 0x0081 322*5b3b1688SDavid Daney ld t2, OCTEON_CP2_AES_INP0(a0) /* only really needed for pass 1 */ 323*5b3b1688SDavid Daney dmtc2 t0, 0x0082 324*5b3b1688SDavid Daney ld t0, OCTEON_CP2_AES_IV(a0) 325*5b3b1688SDavid Daney dmtc2 t1, 0x0098 326*5b3b1688SDavid Daney ld t1, OCTEON_CP2_AES_IV+8(a0) 327*5b3b1688SDavid Daney dmtc2 t2, 0x010A /* only really needed for pass 1 */ 328*5b3b1688SDavid Daney ld t2, OCTEON_CP2_AES_KEY(a0) 329*5b3b1688SDavid Daney dmtc2 t0, 0x0102 330*5b3b1688SDavid Daney ld t0, OCTEON_CP2_AES_KEY+8(a0) 331*5b3b1688SDavid Daney dmtc2 t1, 0x0103 332*5b3b1688SDavid Daney ld t1, OCTEON_CP2_AES_KEY+16(a0) 333*5b3b1688SDavid Daney dmtc2 t2, 0x0104 334*5b3b1688SDavid Daney ld t2, OCTEON_CP2_AES_KEY+24(a0) 335*5b3b1688SDavid Daney dmtc2 t0, 0x0105 336*5b3b1688SDavid Daney ld t0, OCTEON_CP2_AES_KEYLEN(a0) 337*5b3b1688SDavid Daney dmtc2 t1, 0x0106 338*5b3b1688SDavid Daney ld t1, OCTEON_CP2_AES_RESULT(a0) 339*5b3b1688SDavid Daney dmtc2 t2, 0x0107 340*5b3b1688SDavid Daney ld t2, OCTEON_CP2_AES_RESULT+8(a0) 341*5b3b1688SDavid Daney mfc0 t3, $15,0 /* Get the processor ID register */ 342*5b3b1688SDavid Daney dmtc2 t0, 0x0110 343*5b3b1688SDavid Daney li t0, 0x000d0000 /* This is the processor ID of Octeon Pass1 */ 344*5b3b1688SDavid Daney dmtc2 t1, 0x0100 345*5b3b1688SDavid Daney bne t0, t3, 3f /* Skip the next stuff for non-pass1 */ 346*5b3b1688SDavid Daney dmtc2 t2, 0x0101 347*5b3b1688SDavid Daney 348*5b3b1688SDavid Daney /* this code is specific for pass 1 */ 349*5b3b1688SDavid Daney ld t0, OCTEON_CP2_HSH_DATW(a0) 350*5b3b1688SDavid Daney ld t1, OCTEON_CP2_HSH_DATW+8(a0) 351*5b3b1688SDavid Daney ld t2, OCTEON_CP2_HSH_DATW+16(a0) 352*5b3b1688SDavid Daney dmtc2 t0, 0x0040 353*5b3b1688SDavid Daney ld t0, OCTEON_CP2_HSH_DATW+24(a0) 354*5b3b1688SDavid Daney dmtc2 t1, 0x0041 355*5b3b1688SDavid Daney ld t1, OCTEON_CP2_HSH_DATW+32(a0) 356*5b3b1688SDavid Daney dmtc2 t2, 0x0042 357*5b3b1688SDavid Daney ld t2, OCTEON_CP2_HSH_DATW+40(a0) 358*5b3b1688SDavid Daney dmtc2 t0, 0x0043 359*5b3b1688SDavid Daney ld t0, OCTEON_CP2_HSH_DATW+48(a0) 360*5b3b1688SDavid Daney dmtc2 t1, 0x0044 361*5b3b1688SDavid Daney ld t1, OCTEON_CP2_HSH_IVW(a0) 362*5b3b1688SDavid Daney dmtc2 t2, 0x0045 363*5b3b1688SDavid Daney ld t2, OCTEON_CP2_HSH_IVW+8(a0) 364*5b3b1688SDavid Daney dmtc2 t0, 0x0046 365*5b3b1688SDavid Daney ld t0, OCTEON_CP2_HSH_IVW+16(a0) 366*5b3b1688SDavid Daney dmtc2 t1, 0x0048 367*5b3b1688SDavid Daney dmtc2 t2, 0x0049 368*5b3b1688SDavid Daney b done_restore /* unconditional branch */ 369*5b3b1688SDavid Daney dmtc2 t0, 0x004A 370*5b3b1688SDavid Daney 371*5b3b1688SDavid Daney3: /* this is post-pass1 code */ 372*5b3b1688SDavid Daney ld t2, OCTEON_CP2_HSH_DATW(a0) 373*5b3b1688SDavid Daney ld t0, OCTEON_CP2_HSH_DATW+8(a0) 374*5b3b1688SDavid Daney ld t1, OCTEON_CP2_HSH_DATW+16(a0) 375*5b3b1688SDavid Daney dmtc2 t2, 0x0240 376*5b3b1688SDavid Daney ld t2, OCTEON_CP2_HSH_DATW+24(a0) 377*5b3b1688SDavid Daney dmtc2 t0, 0x0241 378*5b3b1688SDavid Daney ld t0, OCTEON_CP2_HSH_DATW+32(a0) 379*5b3b1688SDavid Daney dmtc2 t1, 0x0242 380*5b3b1688SDavid Daney ld t1, OCTEON_CP2_HSH_DATW+40(a0) 381*5b3b1688SDavid Daney dmtc2 t2, 0x0243 382*5b3b1688SDavid Daney ld t2, OCTEON_CP2_HSH_DATW+48(a0) 383*5b3b1688SDavid Daney dmtc2 t0, 0x0244 384*5b3b1688SDavid Daney ld t0, OCTEON_CP2_HSH_DATW+56(a0) 385*5b3b1688SDavid Daney dmtc2 t1, 0x0245 386*5b3b1688SDavid Daney ld t1, OCTEON_CP2_HSH_DATW+64(a0) 387*5b3b1688SDavid Daney dmtc2 t2, 0x0246 388*5b3b1688SDavid Daney ld t2, OCTEON_CP2_HSH_DATW+72(a0) 389*5b3b1688SDavid Daney dmtc2 t0, 0x0247 390*5b3b1688SDavid Daney ld t0, OCTEON_CP2_HSH_DATW+80(a0) 391*5b3b1688SDavid Daney dmtc2 t1, 0x0248 392*5b3b1688SDavid Daney ld t1, OCTEON_CP2_HSH_DATW+88(a0) 393*5b3b1688SDavid Daney dmtc2 t2, 0x0249 394*5b3b1688SDavid Daney ld t2, OCTEON_CP2_HSH_DATW+96(a0) 395*5b3b1688SDavid Daney dmtc2 t0, 0x024A 396*5b3b1688SDavid Daney ld t0, OCTEON_CP2_HSH_DATW+104(a0) 397*5b3b1688SDavid Daney dmtc2 t1, 0x024B 398*5b3b1688SDavid Daney ld t1, OCTEON_CP2_HSH_DATW+112(a0) 399*5b3b1688SDavid Daney dmtc2 t2, 0x024C 400*5b3b1688SDavid Daney ld t2, OCTEON_CP2_HSH_IVW(a0) 401*5b3b1688SDavid Daney dmtc2 t0, 0x024D 402*5b3b1688SDavid Daney ld t0, OCTEON_CP2_HSH_IVW+8(a0) 403*5b3b1688SDavid Daney dmtc2 t1, 0x024E 404*5b3b1688SDavid Daney ld t1, OCTEON_CP2_HSH_IVW+16(a0) 405*5b3b1688SDavid Daney dmtc2 t2, 0x0250 406*5b3b1688SDavid Daney ld t2, OCTEON_CP2_HSH_IVW+24(a0) 407*5b3b1688SDavid Daney dmtc2 t0, 0x0251 408*5b3b1688SDavid Daney ld t0, OCTEON_CP2_HSH_IVW+32(a0) 409*5b3b1688SDavid Daney dmtc2 t1, 0x0252 410*5b3b1688SDavid Daney ld t1, OCTEON_CP2_HSH_IVW+40(a0) 411*5b3b1688SDavid Daney dmtc2 t2, 0x0253 412*5b3b1688SDavid Daney ld t2, OCTEON_CP2_HSH_IVW+48(a0) 413*5b3b1688SDavid Daney dmtc2 t0, 0x0254 414*5b3b1688SDavid Daney ld t0, OCTEON_CP2_HSH_IVW+56(a0) 415*5b3b1688SDavid Daney dmtc2 t1, 0x0255 416*5b3b1688SDavid Daney ld t1, OCTEON_CP2_GFM_MULT(a0) 417*5b3b1688SDavid Daney dmtc2 t2, 0x0256 418*5b3b1688SDavid Daney ld t2, OCTEON_CP2_GFM_MULT+8(a0) 419*5b3b1688SDavid Daney dmtc2 t0, 0x0257 420*5b3b1688SDavid Daney ld t0, OCTEON_CP2_GFM_POLY(a0) 421*5b3b1688SDavid Daney dmtc2 t1, 0x0258 422*5b3b1688SDavid Daney ld t1, OCTEON_CP2_GFM_RESULT(a0) 423*5b3b1688SDavid Daney dmtc2 t2, 0x0259 424*5b3b1688SDavid Daney ld t2, OCTEON_CP2_GFM_RESULT+8(a0) 425*5b3b1688SDavid Daney dmtc2 t0, 0x025E 426*5b3b1688SDavid Daney dmtc2 t1, 0x025A 427*5b3b1688SDavid Daney dmtc2 t2, 0x025B 428*5b3b1688SDavid Daney 429*5b3b1688SDavid Daneydone_restore: 430*5b3b1688SDavid Daney jr ra 431*5b3b1688SDavid Daney nop 432*5b3b1688SDavid Daney END(octeon_cop2_restore) 433*5b3b1688SDavid Daney .set pop 434*5b3b1688SDavid Daney 435*5b3b1688SDavid Daney/* 436*5b3b1688SDavid Daney * void octeon_mult_save() 437*5b3b1688SDavid Daney * sp is assumed to point to a struct pt_regs 438*5b3b1688SDavid Daney * 439*5b3b1688SDavid Daney * NOTE: This is called in SAVE_SOME in stackframe.h. It can only 440*5b3b1688SDavid Daney * safely modify k0 and k1. 441*5b3b1688SDavid Daney */ 442*5b3b1688SDavid Daney .align 7 443*5b3b1688SDavid Daney .set push 444*5b3b1688SDavid Daney .set noreorder 445*5b3b1688SDavid Daney LEAF(octeon_mult_save) 446*5b3b1688SDavid Daney dmfc0 k0, $9,7 /* CvmCtl register. */ 447*5b3b1688SDavid Daney bbit1 k0, 27, 1f /* Skip CvmCtl[NOMUL] */ 448*5b3b1688SDavid Daney nop 449*5b3b1688SDavid Daney 450*5b3b1688SDavid Daney /* Save the multiplier state */ 451*5b3b1688SDavid Daney v3mulu k0, $0, $0 452*5b3b1688SDavid Daney v3mulu k1, $0, $0 453*5b3b1688SDavid Daney sd k0, PT_MTP(sp) /* PT_MTP has P0 */ 454*5b3b1688SDavid Daney v3mulu k0, $0, $0 455*5b3b1688SDavid Daney sd k1, PT_MTP+8(sp) /* PT_MTP+8 has P1 */ 456*5b3b1688SDavid Daney ori k1, $0, 1 457*5b3b1688SDavid Daney v3mulu k1, k1, $0 458*5b3b1688SDavid Daney sd k0, PT_MTP+16(sp) /* PT_MTP+16 has P2 */ 459*5b3b1688SDavid Daney v3mulu k0, $0, $0 460*5b3b1688SDavid Daney sd k1, PT_MPL(sp) /* PT_MPL has MPL0 */ 461*5b3b1688SDavid Daney v3mulu k1, $0, $0 462*5b3b1688SDavid Daney sd k0, PT_MPL+8(sp) /* PT_MPL+8 has MPL1 */ 463*5b3b1688SDavid Daney jr ra 464*5b3b1688SDavid Daney sd k1, PT_MPL+16(sp) /* PT_MPL+16 has MPL2 */ 465*5b3b1688SDavid Daney 466*5b3b1688SDavid Daney1: /* Resume here if CvmCtl[NOMUL] */ 467*5b3b1688SDavid Daney jr ra 468*5b3b1688SDavid Daney END(octeon_mult_save) 469*5b3b1688SDavid Daney .set pop 470*5b3b1688SDavid Daney 471*5b3b1688SDavid Daney/* 472*5b3b1688SDavid Daney * void octeon_mult_restore() 473*5b3b1688SDavid Daney * sp is assumed to point to a struct pt_regs 474*5b3b1688SDavid Daney * 475*5b3b1688SDavid Daney * NOTE: This is called in RESTORE_SOME in stackframe.h. 476*5b3b1688SDavid Daney */ 477*5b3b1688SDavid Daney .align 7 478*5b3b1688SDavid Daney .set push 479*5b3b1688SDavid Daney .set noreorder 480*5b3b1688SDavid Daney LEAF(octeon_mult_restore) 481*5b3b1688SDavid Daney dmfc0 k1, $9,7 /* CvmCtl register. */ 482*5b3b1688SDavid Daney ld v0, PT_MPL(sp) /* MPL0 */ 483*5b3b1688SDavid Daney ld v1, PT_MPL+8(sp) /* MPL1 */ 484*5b3b1688SDavid Daney ld k0, PT_MPL+16(sp) /* MPL2 */ 485*5b3b1688SDavid Daney bbit1 k1, 27, 1f /* Skip CvmCtl[NOMUL] */ 486*5b3b1688SDavid Daney /* Normally falls through, so no time wasted here */ 487*5b3b1688SDavid Daney nop 488*5b3b1688SDavid Daney 489*5b3b1688SDavid Daney /* Restore the multiplier state */ 490*5b3b1688SDavid Daney ld k1, PT_MTP+16(sp) /* P2 */ 491*5b3b1688SDavid Daney MTM0 v0 /* MPL0 */ 492*5b3b1688SDavid Daney ld v0, PT_MTP+8(sp) /* P1 */ 493*5b3b1688SDavid Daney MTM1 v1 /* MPL1 */ 494*5b3b1688SDavid Daney ld v1, PT_MTP(sp) /* P0 */ 495*5b3b1688SDavid Daney MTM2 k0 /* MPL2 */ 496*5b3b1688SDavid Daney MTP2 k1 /* P2 */ 497*5b3b1688SDavid Daney MTP1 v0 /* P1 */ 498*5b3b1688SDavid Daney jr ra 499*5b3b1688SDavid Daney MTP0 v1 /* P0 */ 500*5b3b1688SDavid Daney 501*5b3b1688SDavid Daney1: /* Resume here if CvmCtl[NOMUL] */ 502*5b3b1688SDavid Daney jr ra 503*5b3b1688SDavid Daney nop 504*5b3b1688SDavid Daney END(octeon_mult_restore) 505*5b3b1688SDavid Daney .set pop 506*5b3b1688SDavid Daney 507