| 1 | /* SPDX-License-Identifier: GPL-2.0 */
|
| 2 | /*
|
| 3 | * Copyright (C) 2020-2022 Loongson Technology Corporation Limited
|
| 4 | */
|
| 5 | |
| 6 | |
| 7 | |
| 8 | |
| 9 | |
| 10 | |
| 11 | |
| 12 |
|
| 13 | /*
|
| 14 | * task_struct *__switch_to(task_struct *prev, task_struct *next,
|
| 15 | * void *sched_ra, void *sched_cfa)
|
| 16 | */
|
| 17 | .align 5
|
| 18 | SYM_FUNC_START(__switch_to)
|
| 19 | |
| 20 | PTR_ADDI a0, a0, TASK_STRUCT_OFFSET
|
| 21 | PTR_ADDI a1, a1, TASK_STRUCT_OFFSET
|
| 22 | |
| 23 | csrrd t1, LOONGARCH_CSR_PRMD
|
| 24 | LONG_SPTR t1, a0, (THREAD_CSRPRMD - TASK_STRUCT_OFFSET)
|
| 25 |
|
| 26 | cpu_save_nonscratch a0
|
| 27 | LONG_SPTR a2, a0, (THREAD_SCHED_RA - TASK_STRUCT_OFFSET)
|
| 28 | LONG_SPTR a3, a0, (THREAD_SCHED_CFA - TASK_STRUCT_OFFSET)
|
| 29 |
|
| 30 | |
| 31 | la t7, __stack_chk_guard
|
| 32 | LONG_LPTR t8, a1, (TASK_STACK_CANARY - TASK_STRUCT_OFFSET)
|
| 33 | LONG_SPTR t8, t7, 0
|
| 34 | |
| 35 |
|
| 36 | move tp, a1
|
| 37 | cpu_restore_nonscratch a1
|
| 38 |
|
| 39 | LONG_LPTR t0, a1, (TASK_STACK - TASK_STRUCT_OFFSET)
|
| 40 | PTR_LI t1, _THREAD_SIZE
|
| 41 | PTR_ADD t0, t0, t1
|
| 42 | set_saved_sp t0, t1, t2
|
| 43 |
|
| 44 | LONG_LPTR t1, a1, (THREAD_CSRPRMD - TASK_STRUCT_OFFSET)
|
| 45 | csrwr t1, LOONGARCH_CSR_PRMD
|
| 46 |
|
| 47 | |
| 48 | PTR_ADDI a0, a0, -TASK_STRUCT_OFFSET
|
| 49 | PTR_ADDI tp, tp, -TASK_STRUCT_OFFSET
|
| 50 | |
| 51 | jr ra
|
| 52 | SYM_FUNC_END(__switch_to)
|