kernel_optimize_test/arch/csky/kernel/atomic.S
Guo Ren bf24168293 csky: Reconstruct signal processing
Linux kernel has provided some apis for arch signal's implementation.
For example:
	restore_saved_sigmask()
	set_current_blocked()
	restore_altstack()

But in last version of csky signal.c didn't use them and some codes are
confusing, so reconstruct signal.c with reference to riscv's code.

Now csky signal.c implementation are very close to riscv and we can
get the following benefits:
 - Clear code structure
 - The signal code of riscv and csky can be reviewed together
 - Promoting the unification of arch's signal implementation

Also modified the related code in entry.S

Signed-off-by: Guo Ren <ren_guo@c-sky.com>
Cc: Arnd Bergmann <arnd@arndb.de>
2019-04-22 13:44:57 +08:00

70 lines
985 B
ArmAsm

/* SPDX-License-Identifier: GPL-2.0 */
// Copyright (C) 2018 Hangzhou C-SKY Microsystems co.,ltd.
#include <linux/linkage.h>
#include <abi/entry.h>
.text
/*
* int csky_cmpxchg(int oldval, int newval, int *ptr)
*
* If *ptr != oldval && return 1,
* else *ptr = newval return 0.
*/
ENTRY(csky_cmpxchg)
USPTOKSP
mfcr a3, epc
addi a3, TRAP0_SIZE
subi sp, 8
stw a3, (sp, 0)
mfcr a3, epsr
stw a3, (sp, 4)
psrset ee
#ifdef CONFIG_CPU_HAS_LDSTEX
1:
ldex a3, (a2)
cmpne a0, a3
bt16 2f
mov a3, a1
stex a3, (a2)
bez a3, 1b
2:
sync.is
#else
1:
ldw a3, (a2)
cmpne a0, a3
bt16 3f
2:
stw a1, (a2)
3:
#endif
mvc a0
ldw a3, (sp, 0)
mtcr a3, epc
ldw a3, (sp, 4)
mtcr a3, epsr
addi sp, 8
KSPTOUSP
rte
END(csky_cmpxchg)
#ifndef CONFIG_CPU_HAS_LDSTEX
/*
* Called from tlbmodified exception
*/
ENTRY(csky_cmpxchg_fixup)
mfcr a0, epc
lrw a1, 2b
cmpne a1, a0
bt 1f
subi a1, (2b - 1b)
stw a1, (sp, LSAVE_PC)
1:
rts
END(csky_cmpxchg_fixup)
#endif