pal.h 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187
  1. #ifndef __ALPHA_PAL_H
  2. #define __ALPHA_PAL_H
  3. #include <uapi/asm/pal.h>
  4. #ifndef __ASSEMBLY__
  5. extern void halt(void) __attribute__((noreturn));
  6. #define __halt() __asm__ __volatile__ ("call_pal %0 #halt" : : "i" (PAL_halt))
  7. #define imb() \
  8. __asm__ __volatile__ ("call_pal %0 #imb" : : "i" (PAL_imb) : "memory")
  9. #define draina() \
  10. __asm__ __volatile__ ("call_pal %0 #draina" : : "i" (PAL_draina) : "memory")
  11. #define __CALL_PAL_R0(NAME, TYPE) \
  12. extern inline TYPE NAME(void) \
  13. { \
  14. register TYPE __r0 __asm__("$0"); \
  15. __asm__ __volatile__( \
  16. "call_pal %1 # " #NAME \
  17. :"=r" (__r0) \
  18. :"i" (PAL_ ## NAME) \
  19. :"$1", "$16", "$22", "$23", "$24", "$25"); \
  20. return __r0; \
  21. }
  22. #define __CALL_PAL_W1(NAME, TYPE0) \
  23. extern inline void NAME(TYPE0 arg0) \
  24. { \
  25. register TYPE0 __r16 __asm__("$16") = arg0; \
  26. __asm__ __volatile__( \
  27. "call_pal %1 # "#NAME \
  28. : "=r"(__r16) \
  29. : "i"(PAL_ ## NAME), "0"(__r16) \
  30. : "$1", "$22", "$23", "$24", "$25"); \
  31. }
  32. #define __CALL_PAL_W2(NAME, TYPE0, TYPE1) \
  33. extern inline void NAME(TYPE0 arg0, TYPE1 arg1) \
  34. { \
  35. register TYPE0 __r16 __asm__("$16") = arg0; \
  36. register TYPE1 __r17 __asm__("$17") = arg1; \
  37. __asm__ __volatile__( \
  38. "call_pal %2 # "#NAME \
  39. : "=r"(__r16), "=r"(__r17) \
  40. : "i"(PAL_ ## NAME), "0"(__r16), "1"(__r17) \
  41. : "$1", "$22", "$23", "$24", "$25"); \
  42. }
  43. #define __CALL_PAL_RW1(NAME, RTYPE, TYPE0) \
  44. extern inline RTYPE NAME(TYPE0 arg0) \
  45. { \
  46. register RTYPE __r0 __asm__("$0"); \
  47. register TYPE0 __r16 __asm__("$16") = arg0; \
  48. __asm__ __volatile__( \
  49. "call_pal %2 # "#NAME \
  50. : "=r"(__r16), "=r"(__r0) \
  51. : "i"(PAL_ ## NAME), "0"(__r16) \
  52. : "$1", "$22", "$23", "$24", "$25"); \
  53. return __r0; \
  54. }
  55. #define __CALL_PAL_RW2(NAME, RTYPE, TYPE0, TYPE1) \
  56. extern inline RTYPE NAME(TYPE0 arg0, TYPE1 arg1) \
  57. { \
  58. register RTYPE __r0 __asm__("$0"); \
  59. register TYPE0 __r16 __asm__("$16") = arg0; \
  60. register TYPE1 __r17 __asm__("$17") = arg1; \
  61. __asm__ __volatile__( \
  62. "call_pal %3 # "#NAME \
  63. : "=r"(__r16), "=r"(__r17), "=r"(__r0) \
  64. : "i"(PAL_ ## NAME), "0"(__r16), "1"(__r17) \
  65. : "$1", "$22", "$23", "$24", "$25"); \
  66. return __r0; \
  67. }
  68. __CALL_PAL_W1(cflush, unsigned long);
  69. __CALL_PAL_R0(rdmces, unsigned long);
  70. __CALL_PAL_R0(rdps, unsigned long);
  71. __CALL_PAL_R0(rdusp, unsigned long);
  72. __CALL_PAL_RW1(swpipl, unsigned long, unsigned long);
  73. __CALL_PAL_R0(whami, unsigned long);
  74. __CALL_PAL_W2(wrent, void*, unsigned long);
  75. __CALL_PAL_W1(wripir, unsigned long);
  76. __CALL_PAL_W1(wrkgp, unsigned long);
  77. __CALL_PAL_W1(wrmces, unsigned long);
  78. __CALL_PAL_RW2(wrperfmon, unsigned long, unsigned long, unsigned long);
  79. __CALL_PAL_W1(wrusp, unsigned long);
  80. __CALL_PAL_W1(wrvptptr, unsigned long);
  81. __CALL_PAL_RW1(wtint, unsigned long, unsigned long);
  82. /*
  83. * TB routines..
  84. */
  85. #define __tbi(nr,arg,arg1...) \
  86. ({ \
  87. register unsigned long __r16 __asm__("$16") = (nr); \
  88. register unsigned long __r17 __asm__("$17"); arg; \
  89. __asm__ __volatile__( \
  90. "call_pal %3 #__tbi" \
  91. :"=r" (__r16),"=r" (__r17) \
  92. :"0" (__r16),"i" (PAL_tbi) ,##arg1 \
  93. :"$0", "$1", "$22", "$23", "$24", "$25"); \
  94. })
  95. #define tbi(x,y) __tbi(x,__r17=(y),"1" (__r17))
  96. #define tbisi(x) __tbi(1,__r17=(x),"1" (__r17))
  97. #define tbisd(x) __tbi(2,__r17=(x),"1" (__r17))
  98. #define tbis(x) __tbi(3,__r17=(x),"1" (__r17))
  99. #define tbiap() __tbi(-1, /* no second argument */)
  100. #define tbia() __tbi(-2, /* no second argument */)
  101. /*
  102. * QEMU Cserv routines..
  103. */
  104. static inline unsigned long
  105. qemu_get_walltime(void)
  106. {
  107. register unsigned long v0 __asm__("$0");
  108. register unsigned long a0 __asm__("$16") = 3;
  109. asm("call_pal %2 # cserve get_time"
  110. : "=r"(v0), "+r"(a0)
  111. : "i"(PAL_cserve)
  112. : "$17", "$18", "$19", "$20", "$21");
  113. return v0;
  114. }
  115. static inline unsigned long
  116. qemu_get_alarm(void)
  117. {
  118. register unsigned long v0 __asm__("$0");
  119. register unsigned long a0 __asm__("$16") = 4;
  120. asm("call_pal %2 # cserve get_alarm"
  121. : "=r"(v0), "+r"(a0)
  122. : "i"(PAL_cserve)
  123. : "$17", "$18", "$19", "$20", "$21");
  124. return v0;
  125. }
  126. static inline void
  127. qemu_set_alarm_rel(unsigned long expire)
  128. {
  129. register unsigned long a0 __asm__("$16") = 5;
  130. register unsigned long a1 __asm__("$17") = expire;
  131. asm volatile("call_pal %2 # cserve set_alarm_rel"
  132. : "+r"(a0), "+r"(a1)
  133. : "i"(PAL_cserve)
  134. : "$0", "$18", "$19", "$20", "$21");
  135. }
  136. static inline void
  137. qemu_set_alarm_abs(unsigned long expire)
  138. {
  139. register unsigned long a0 __asm__("$16") = 6;
  140. register unsigned long a1 __asm__("$17") = expire;
  141. asm volatile("call_pal %2 # cserve set_alarm_abs"
  142. : "+r"(a0), "+r"(a1)
  143. : "i"(PAL_cserve)
  144. : "$0", "$18", "$19", "$20", "$21");
  145. }
  146. static inline unsigned long
  147. qemu_get_vmtime(void)
  148. {
  149. register unsigned long v0 __asm__("$0");
  150. register unsigned long a0 __asm__("$16") = 7;
  151. asm("call_pal %2 # cserve get_time"
  152. : "=r"(v0), "+r"(a0)
  153. : "i"(PAL_cserve)
  154. : "$17", "$18", "$19", "$20", "$21");
  155. return v0;
  156. }
  157. #endif /* !__ASSEMBLY__ */
  158. #endif /* __ALPHA_PAL_H */