提交 d5b85d88 编写于 作者: H He Sheng 提交者: guzitao

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: NHe Sheng <hesheng@wxiat.com>
Reviewed-by: NCui Wei <cuiwei@wxiat.com>
Signed-off-by: NGu Zitao <guzitao@wxiat.com>
上级 d81202bc
...@@ -55,16 +55,14 @@ ...@@ -55,16 +55,14 @@
extern void __init fixup_hmcall(void); extern void __init fixup_hmcall(void);
extern void halt(void) __attribute__((noreturn)); 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) \ #define __CALL_HMC_R0(NAME, TYPE) \
static inline TYPE NAME(void) \ static inline TYPE NAME(void) \
{ \ { \
...@@ -142,10 +140,14 @@ static inline RTYPE NAME(TYPE0 arg0, TYPE1 arg1, TYPE2 arg2) \ ...@@ -142,10 +140,14 @@ static inline RTYPE NAME(TYPE0 arg0, TYPE1 arg1, TYPE2 arg2) \
return __r0; \ return __r0; \
} }
#define sflush() \
{ \ __CALL_HMC_VOID(imb);
__asm__ __volatile__("sys_call 0x2f"); \ __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); __CALL_HMC_R0(rdps, unsigned long);
...@@ -164,8 +166,6 @@ __CALL_HMC_RW1(swpipl, unsigned long, unsigned long); ...@@ -164,8 +166,6 @@ __CALL_HMC_RW1(swpipl, unsigned long, unsigned long);
__CALL_HMC_R0(whami, unsigned long); __CALL_HMC_R0(whami, unsigned long);
__CALL_HMC_RW1(rdio64, unsigned long, unsigned long); __CALL_HMC_RW1(rdio64, unsigned long, unsigned long);
__CALL_HMC_RW1(rdio32, unsigned int, 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(wrent, void*, unsigned long);
__CALL_HMC_W2(tbisasn, unsigned long, unsigned long); __CALL_HMC_W2(tbisasn, unsigned long, unsigned long);
__CALL_HMC_W1(wrkgp, unsigned long); __CALL_HMC_W1(wrkgp, unsigned long);
......
...@@ -34,7 +34,7 @@ ...@@ -34,7 +34,7 @@
static inline void arch_kgdb_breakpoint(void) 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); void sw64_task_to_gdb_regs(struct task_struct *task, unsigned long *regs);
......
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
#include <asm/unistd.h> #include <asm/unistd.h>
#include <asm/vdso.h> #include <asm/vdso.h>
#include <asm/hmcall.h>
static __always_inline int syscall_fallback(clockid_t clkid, struct timespec64 *ts) 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 * ...@@ -25,8 +26,8 @@ static __always_inline int syscall_fallback(clockid_t clkid, struct timespec64 *
" mov %0, $16\n" " mov %0, $16\n"
" mov %1, $17\n" " mov %1, $17\n"
" ldi $0, %2\n" " ldi $0, %2\n"
" sys_call 0x83\n" " sys_call %3\n"
:: "r"(clkid), "r"(ts), "i"(__NR_clock_gettime) :: "r"(clkid), "r"(ts), "i"(__NR_clock_gettime), "i"(HMC_callsys)
: "$0", "$16", "$17", "$19"); : "$0", "$16", "$17", "$19");
if (unlikely(r19)) if (unlikely(r19))
return -r0; return -r0;
...@@ -78,9 +79,7 @@ static __always_inline u64 read_longtime(void) ...@@ -78,9 +79,7 @@ static __always_inline u64 read_longtime(void)
register unsigned long __r0 __asm__("$0"); register unsigned long __r0 __asm__("$0");
__asm__ __volatile__( __asm__ __volatile__(
"sys_call 0xB1" "sys_call %1" : "=r"(__r0) : "i" (HMC_longtime));
: "=r"(__r0)
::"memory");
return __r0; return __r0;
} }
......
...@@ -19,6 +19,7 @@ ...@@ -19,6 +19,7 @@
#include <linux/linkage.h> #include <linux/linkage.h>
#include <asm/unistd.h> #include <asm/unistd.h>
#include <uapi/asm/hmcall.h>
#define RT_SIGFRAME_SIZE 1600 #define RT_SIGFRAME_SIZE 1600
#define RT_SIGFRAME_MCTX 176 #define RT_SIGFRAME_MCTX 176
...@@ -64,6 +65,6 @@ ...@@ -64,6 +65,6 @@
ENTRY(__vdso_rt_sigreturn) ENTRY(__vdso_rt_sigreturn)
mov $sp, $16 mov $sp, $16
ldi $0, __NR_rt_sigreturn ldi $0, __NR_rt_sigreturn
sys_call 0x83 sys_call HMC_callsys
ENDPROC(__vdso_rt_sigreturn) ENDPROC(__vdso_rt_sigreturn)
.cfi_endproc .cfi_endproc
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册