diff options
author | Huacai Chen <chenhuacai@loongson.cn> | 2022-05-31 12:04:11 +0200 |
---|---|---|
committer | Huacai Chen <chenhuacai@loongson.cn> | 2022-06-03 14:09:28 +0200 |
commit | 803b0fc5c3f2baa6e54978cd576407896f789b08 (patch) | |
tree | 835ad7b550e9ed19c55f84d331e24147a04c3d0c /arch/loongarch/kernel/switch.S | |
parent | LoongArch: Add exception/interrupt handling (diff) | |
download | linux-803b0fc5c3f2baa6e54978cd576407896f789b08.tar.xz linux-803b0fc5c3f2baa6e54978cd576407896f789b08.zip |
LoongArch: Add process management
Add process management support for LoongArch, including: thread info
definition, context switch and process tracing.
Reviewed-by: WANG Xuerui <git@xen0n.name>
Reviewed-by: Jiaxun Yang <jiaxun.yang@flygoat.com>
Signed-off-by: Huacai Chen <chenhuacai@loongson.cn>
Diffstat (limited to 'arch/loongarch/kernel/switch.S')
-rw-r--r-- | arch/loongarch/kernel/switch.S | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/arch/loongarch/kernel/switch.S b/arch/loongarch/kernel/switch.S new file mode 100644 index 000000000000..53e2fa8e580e --- /dev/null +++ b/arch/loongarch/kernel/switch.S @@ -0,0 +1,35 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * Copyright (C) 2020-2022 Loongson Technology Corporation Limited + */ +#include <asm/asm.h> +#include <asm/asmmacro.h> +#include <asm/asm-offsets.h> +#include <asm/loongarch.h> +#include <asm/regdef.h> +#include <asm/stackframe.h> +#include <asm/thread_info.h> + +/* + * task_struct *__switch_to(task_struct *prev, task_struct *next, + * struct thread_info *next_ti) + */ + .align 5 +SYM_FUNC_START(__switch_to) + csrrd t1, LOONGARCH_CSR_PRMD + stptr.d t1, a0, THREAD_CSRPRMD + + cpu_save_nonscratch a0 + stptr.d ra, a0, THREAD_REG01 + move tp, a2 + cpu_restore_nonscratch a1 + + li.w t0, _THREAD_SIZE - 32 + PTR_ADD t0, t0, tp + set_saved_sp t0, t1, t2 + + ldptr.d t1, a1, THREAD_CSRPRMD + csrwr t1, LOONGARCH_CSR_PRMD + + jr ra +SYM_FUNC_END(__switch_to) |