Commit 4a20297e authored by He Sheng's avatar He Sheng Committed by guzitao
Browse files

sw64: invoke hmcall with HMC_* macros

Sunway inclusion
category: feature
bugzilla: https://gitee.com/openeuler/kernel/issues/I56OLG



--------------------------------

It's better to use HMC_* macro instead of numberic constant.

This patch also adds __CALL_HMC_VOID to define hmcalls with no
return value including sflush().

Signed-off-by: default avatarHe Sheng <hesheng@wxiat.com>
Reviewed-by: default avatarCui Wei <cuiwei@wxiat.com>
Signed-off-by: default avatarGu Zitao <guzitao@wxiat.com>
parent c1c6a273
Loading
Loading
Loading
Loading
+12 −12
Original line number Diff line number Diff line
@@ -55,16 +55,14 @@
extern void __init fixup_hmcall(void);

extern void halt(void) __attribute__((noreturn));
#define __halt() __asm__ __volatile__ ("sys_call %0 #halt" : : "i" (HMC_halt))

#define fpu_enable()						\
#define __CALL_HMC_VOID(NAME)					\
static inline void NAME(void)					\
{								\
	__asm__ __volatile__("sys_call %0" : : "i" (HMC_wrfen));\
	__asm__ __volatile__(					\
		"sys_call %0 ": : "i" (HMC_ ## NAME));		\
}

#define imb() \
	__asm__ __volatile__ ("sys_call %0 #imb" : : "i" (HMC_imb) : "memory")

#define __CALL_HMC_R0(NAME, TYPE)				\
static inline TYPE NAME(void)					\
{								\
@@ -142,10 +140,14 @@ static inline RTYPE NAME(TYPE0 arg0, TYPE1 arg1, TYPE2 arg2) \
	return __r0;							\
}

#define sflush()						\
{								\
	__asm__ __volatile__("sys_call 0x2f");			\
}

__CALL_HMC_VOID(imb);
__CALL_HMC_VOID(sflush);
__CALL_HMC_VOID(wrfen);
#define fpu_enable()	wrfen()

__CALL_HMC_VOID(sleepen);
__CALL_HMC_VOID(mtinten);

__CALL_HMC_R0(rdps, unsigned long);

@@ -164,8 +166,6 @@ __CALL_HMC_RW1(swpipl, unsigned long, unsigned long);
__CALL_HMC_R0(whami, unsigned long);
__CALL_HMC_RW1(rdio64, unsigned long, unsigned long);
__CALL_HMC_RW1(rdio32, unsigned int, unsigned long);
__CALL_HMC_R0(sleepen, unsigned long);
__CALL_HMC_R0(mtinten, unsigned long);
__CALL_HMC_W2(wrent, void*, unsigned long);
__CALL_HMC_W2(tbisasn, unsigned long, unsigned long);
__CALL_HMC_W1(wrkgp, unsigned long);
+1 −1
Original line number Diff line number Diff line
@@ -34,7 +34,7 @@

static inline void arch_kgdb_breakpoint(void)
{
	asm __volatile__ ("sys_call/b 0x80");
	asm __volatile__ ("sys_call %0" : : "i"(HMC_bpt) );
}

void sw64_task_to_gdb_regs(struct task_struct *task, unsigned long *regs);
+4 −5
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@

#include <asm/unistd.h>
#include <asm/vdso.h>
#include <asm/hmcall.h>

static __always_inline int syscall_fallback(clockid_t clkid, struct timespec64 *ts)
{
@@ -25,8 +26,8 @@ static __always_inline int syscall_fallback(clockid_t clkid, struct timespec64 *
	"	mov		%0, $16\n"
	"	mov		%1, $17\n"
	"	ldi		$0, %2\n"
	"	sys_call	0x83\n"
	:: "r"(clkid), "r"(ts), "i"(__NR_clock_gettime)
	"	sys_call	%3\n"
	:: "r"(clkid), "r"(ts), "i"(__NR_clock_gettime), "i"(HMC_callsys)
	: "$0", "$16", "$17", "$19");
	if (unlikely(r19))
		return -r0;
@@ -78,9 +79,7 @@ static __always_inline u64 read_longtime(void)
	register unsigned long __r0 __asm__("$0");

	__asm__ __volatile__(
		"sys_call 0xB1"
		: "=r"(__r0)
		::"memory");
		"sys_call %1" : "=r"(__r0) : "i" (HMC_longtime));

	return __r0;
}
+2 −1
Original line number Diff line number Diff line
@@ -19,6 +19,7 @@

#include <linux/linkage.h>
#include <asm/unistd.h>
#include <uapi/asm/hmcall.h>

#define RT_SIGFRAME_SIZE	1600
#define RT_SIGFRAME_MCTX	176
@@ -64,6 +65,6 @@
ENTRY(__vdso_rt_sigreturn)
	mov		$sp, $16
	ldi		$0, __NR_rt_sigreturn
	sys_call	0x83
	sys_call	HMC_callsys
ENDPROC(__vdso_rt_sigreturn)
	.cfi_endproc