1 /* SPDX-License-Identifier: GPL-2.0 */
5 #include <uapi/asm/pal.h>
9 extern void halt(void) __attribute__((noreturn
));
10 #define __halt() __asm__ __volatile__ ("call_pal %0 #halt" : : "i" (PAL_halt))
13 __asm__ __volatile__ ("call_pal %0 #imb" : : "i" (PAL_imb) : "memory")
16 __asm__ __volatile__ ("call_pal %0 #draina" : : "i" (PAL_draina) : "memory")
18 #define __CALL_PAL_R0(NAME, TYPE) \
19 extern inline TYPE NAME(void) \
21 register TYPE __r0 __asm__("$0"); \
22 __asm__ __volatile__( \
23 "call_pal %1 # " #NAME \
26 :"$1", "$16", "$22", "$23", "$24", "$25"); \
30 #define __CALL_PAL_W1(NAME, TYPE0) \
31 extern inline void NAME(TYPE0 arg0) \
33 register TYPE0 __r16 __asm__("$16") = arg0; \
34 __asm__ __volatile__( \
35 "call_pal %1 # "#NAME \
37 : "i"(PAL_ ## NAME), "0"(__r16) \
38 : "$1", "$22", "$23", "$24", "$25"); \
41 #define __CALL_PAL_W2(NAME, TYPE0, TYPE1) \
42 extern inline void NAME(TYPE0 arg0, TYPE1 arg1) \
44 register TYPE0 __r16 __asm__("$16") = arg0; \
45 register TYPE1 __r17 __asm__("$17") = arg1; \
46 __asm__ __volatile__( \
47 "call_pal %2 # "#NAME \
48 : "=r"(__r16), "=r"(__r17) \
49 : "i"(PAL_ ## NAME), "0"(__r16), "1"(__r17) \
50 : "$1", "$22", "$23", "$24", "$25"); \
53 #define __CALL_PAL_RW1(NAME, RTYPE, TYPE0) \
54 extern inline RTYPE NAME(TYPE0 arg0) \
56 register RTYPE __r0 __asm__("$0"); \
57 register TYPE0 __r16 __asm__("$16") = arg0; \
58 __asm__ __volatile__( \
59 "call_pal %2 # "#NAME \
60 : "=r"(__r16), "=r"(__r0) \
61 : "i"(PAL_ ## NAME), "0"(__r16) \
62 : "$1", "$22", "$23", "$24", "$25"); \
66 #define __CALL_PAL_RW2(NAME, RTYPE, TYPE0, TYPE1) \
67 extern inline RTYPE NAME(TYPE0 arg0, TYPE1 arg1) \
69 register RTYPE __r0 __asm__("$0"); \
70 register TYPE0 __r16 __asm__("$16") = arg0; \
71 register TYPE1 __r17 __asm__("$17") = arg1; \
72 __asm__ __volatile__( \
73 "call_pal %3 # "#NAME \
74 : "=r"(__r16), "=r"(__r17), "=r"(__r0) \
75 : "i"(PAL_ ## NAME), "0"(__r16), "1"(__r17) \
76 : "$1", "$22", "$23", "$24", "$25"); \
80 __CALL_PAL_W1(cflush
, unsigned long);
81 __CALL_PAL_R0(rdmces
, unsigned long);
82 __CALL_PAL_R0(rdps
, unsigned long);
83 __CALL_PAL_R0(rdusp
, unsigned long);
84 __CALL_PAL_RW1(swpipl
, unsigned long, unsigned long);
85 __CALL_PAL_R0(whami
, unsigned long);
86 __CALL_PAL_W2(wrent
, void*, unsigned long);
87 __CALL_PAL_W1(wripir
, unsigned long);
88 __CALL_PAL_W1(wrkgp
, unsigned long);
89 __CALL_PAL_W1(wrmces
, unsigned long);
90 __CALL_PAL_RW2(wrperfmon
, unsigned long, unsigned long, unsigned long);
91 __CALL_PAL_W1(wrusp
, unsigned long);
92 __CALL_PAL_W1(wrvptptr
, unsigned long);
93 __CALL_PAL_RW1(wtint
, unsigned long, unsigned long);
98 #define __tbi(nr,arg,arg1...) \
100 register unsigned long __r16 __asm__("$16") = (nr); \
101 register unsigned long __r17 __asm__("$17"); arg; \
102 __asm__ __volatile__( \
103 "call_pal %3 #__tbi" \
104 :"=r" (__r16),"=r" (__r17) \
105 :"0" (__r16),"i" (PAL_tbi) ,##arg1 \
106 :"$0", "$1", "$22", "$23", "$24", "$25"); \
109 #define tbi(x,y) __tbi(x,__r17=(y),"1" (__r17))
110 #define tbisi(x) __tbi(1,__r17=(x),"1" (__r17))
111 #define tbisd(x) __tbi(2,__r17=(x),"1" (__r17))
112 #define tbis(x) __tbi(3,__r17=(x),"1" (__r17))
113 #define tbiap() __tbi(-1, /* no second argument */)
114 #define tbia() __tbi(-2, /* no second argument */)
117 * QEMU Cserv routines..
120 static inline unsigned long
121 qemu_get_walltime(void)
123 register unsigned long v0
__asm__("$0");
124 register unsigned long a0
__asm__("$16") = 3;
126 asm("call_pal %2 # cserve get_time"
129 : "$17", "$18", "$19", "$20", "$21");
134 static inline unsigned long
137 register unsigned long v0
__asm__("$0");
138 register unsigned long a0
__asm__("$16") = 4;
140 asm("call_pal %2 # cserve get_alarm"
143 : "$17", "$18", "$19", "$20", "$21");
149 qemu_set_alarm_rel(unsigned long expire
)
151 register unsigned long a0
__asm__("$16") = 5;
152 register unsigned long a1
__asm__("$17") = expire
;
154 asm volatile("call_pal %2 # cserve set_alarm_rel"
157 : "$0", "$18", "$19", "$20", "$21");
161 qemu_set_alarm_abs(unsigned long expire
)
163 register unsigned long a0
__asm__("$16") = 6;
164 register unsigned long a1
__asm__("$17") = expire
;
166 asm volatile("call_pal %2 # cserve set_alarm_abs"
169 : "$0", "$18", "$19", "$20", "$21");
172 static inline unsigned long
173 qemu_get_vmtime(void)
175 register unsigned long v0
__asm__("$0");
176 register unsigned long a0
__asm__("$16") = 7;
178 asm("call_pal %2 # cserve get_time"
181 : "$17", "$18", "$19", "$20", "$21");
186 #endif /* !__ASSEMBLY__ */
187 #endif /* __ALPHA_PAL_H */