|
10 | 10 | * Copyright (C) 2000 MIPS Technologies, Inc. |
11 | 11 | * written by Carsten Langgaard, carstenl@mips.com |
12 | 12 | */ |
13 | | -#include <asm/asm.h> |
14 | | -#include <asm/cachectl.h> |
15 | | -#include <asm/fpregdef.h> |
16 | | -#include <asm/mipsregs.h> |
17 | | -#include <asm/asm-offsets.h> |
18 | | -#include <asm/pgtable-bits.h> |
19 | | -#include <asm/regdef.h> |
20 | | -#include <asm/stackframe.h> |
21 | | -#include <asm/thread_info.h> |
22 | | - |
23 | | -#include <asm/asmmacro.h> |
24 | | - |
25 | | -/* |
26 | | - * Offset to the current process status flags, the first 32 bytes of the |
27 | | - * stack are not used. |
28 | | - */ |
29 | | -#define ST_OFF (_THREAD_SIZE - 32 - PT_SIZE + PT_STATUS) |
30 | 13 |
|
| 14 | +#define USE_ALTERNATE_RESUME_IMPL 1 |
| 15 | + .set push |
| 16 | + .set arch=mips64r2 |
| 17 | +#include "r4k_switch.S" |
| 18 | + .set pop |
31 | 19 | /* |
32 | 20 | * task_struct *resume(task_struct *prev, task_struct *next, |
33 | 21 | * struct thread_info *next_ti, int usedfpu) |
|
40 | 28 | cpu_save_nonscratch a0 |
41 | 29 | LONG_S ra, THREAD_REG31(a0) |
42 | 30 |
|
| 31 | + /* |
| 32 | + * check if we need to save FPU registers |
| 33 | + */ |
| 34 | + PTR_L t3, TASK_THREAD_INFO(a0) |
| 35 | + LONG_L t0, TI_FLAGS(t3) |
| 36 | + li t1, _TIF_USEDFPU |
| 37 | + and t2, t0, t1 |
| 38 | + beqz t2, 1f |
| 39 | + nor t1, zero, t1 |
| 40 | + |
| 41 | + and t0, t0, t1 |
| 42 | + LONG_S t0, TI_FLAGS(t3) |
| 43 | + |
| 44 | + /* |
| 45 | + * clear saved user stack CU1 bit |
| 46 | + */ |
| 47 | + LONG_L t0, ST_OFF(t3) |
| 48 | + li t1, ~ST0_CU1 |
| 49 | + and t0, t0, t1 |
| 50 | + LONG_S t0, ST_OFF(t3) |
| 51 | + |
| 52 | + .set push |
| 53 | + .set arch=mips64r2 |
| 54 | + fpu_save_double a0 t0 t1 # c0_status passed in t0 |
| 55 | + # clobbers t1 |
| 56 | + .set pop |
| 57 | +1: |
| 58 | + |
| 59 | + /* check if we need to save COP2 registers */ |
| 60 | + PTR_L t2, TASK_THREAD_INFO(a0) |
| 61 | + LONG_L t0, ST_OFF(t2) |
| 62 | + bbit0 t0, 30, 1f |
| 63 | + |
| 64 | + /* Disable COP2 in the stored process state */ |
| 65 | + li t1, ST0_CU2 |
| 66 | + xor t0, t1 |
| 67 | + LONG_S t0, ST_OFF(t2) |
| 68 | + |
| 69 | + /* Enable COP2 so we can save it */ |
| 70 | + mfc0 t0, CP0_STATUS |
| 71 | + or t0, t1 |
| 72 | + mtc0 t0, CP0_STATUS |
| 73 | + |
| 74 | + /* Save COP2 */ |
| 75 | + daddu a0, THREAD_CP2 |
| 76 | + jal octeon_cop2_save |
| 77 | + dsubu a0, THREAD_CP2 |
| 78 | + |
| 79 | + /* Disable COP2 now that we are done */ |
| 80 | + mfc0 t0, CP0_STATUS |
| 81 | + li t1, ST0_CU2 |
| 82 | + xor t0, t1 |
| 83 | + mtc0 t0, CP0_STATUS |
| 84 | + |
| 85 | +1: |
43 | 86 | #if CONFIG_CAVIUM_OCTEON_CVMSEG_SIZE > 0 |
44 | 87 | /* Check if we need to store CVMSEG state */ |
45 | 88 | mfc0 t0, $11,7 /* CvmMemCtl */ |
|
85 | 128 | move $28, a2 |
86 | 129 | cpu_restore_nonscratch a1 |
87 | 130 |
|
88 | | -#if (_THREAD_SIZE - 32) < 0x8000 |
89 | | - PTR_ADDIU t0, $28, _THREAD_SIZE - 32 |
90 | | -#else |
91 | | - PTR_LI t0, _THREAD_SIZE - 32 |
92 | | - PTR_ADDU t0, $28 |
93 | | -#endif |
| 131 | + PTR_ADDU t0, $28, _THREAD_SIZE - 32 |
94 | 132 | set_saved_sp t0, t1, t2 |
95 | 133 |
|
96 | 134 | mfc0 t1, CP0_STATUS /* Do we really need this? */ |
|
0 commit comments