HvCallEvent.h 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253
  1. /*
  2. * HvCallEvent.h
  3. * Copyright (C) 2001 Mike Corrigan IBM Corporation
  4. *
  5. * This program is free software; you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License as published by
  7. * the Free Software Foundation; either version 2 of the License, or
  8. * (at your option) any later version.
  9. *
  10. * This program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License
  16. * along with this program; if not, write to the Free Software
  17. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  18. */
  19. /*
  20. * This file contains the "hypervisor call" interface which is used to
  21. * drive the hypervisor from the OS.
  22. */
  23. #ifndef _HVCALLEVENT_H
  24. #define _HVCALLEVENT_H
  25. #include <asm/iSeries/HvCallSc.h>
  26. #include <asm/iSeries/HvTypes.h>
  27. #include <asm/abs_addr.h>
  28. struct HvLpEvent;
  29. typedef u8 HvLpEvent_Type;
  30. typedef u8 HvLpEvent_AckInd;
  31. typedef u8 HvLpEvent_AckType;
  32. struct HvCallEvent_PackedParms {
  33. u8 xAckType:1;
  34. u8 xAckInd:1;
  35. u8 xRsvd:1;
  36. u8 xTargetLp:5;
  37. u8 xType;
  38. u16 xSubtype;
  39. HvLpInstanceId xSourceInstId;
  40. HvLpInstanceId xTargetInstId;
  41. };
  42. typedef u8 HvLpDma_Direction;
  43. typedef u8 HvLpDma_AddressType;
  44. struct HvCallEvent_PackedDmaParms {
  45. u8 xDirection:1;
  46. u8 xLocalAddrType:1;
  47. u8 xRemoteAddrType:1;
  48. u8 xRsvd1:5;
  49. HvLpIndex xRemoteLp;
  50. u8 xType;
  51. u8 xRsvd2;
  52. HvLpInstanceId xLocalInstId;
  53. HvLpInstanceId xRemoteInstId;
  54. };
  55. typedef u64 HvLpEvent_Rc;
  56. typedef u64 HvLpDma_Rc;
  57. #define HvCallEventAckLpEvent HvCallEvent + 0
  58. #define HvCallEventCancelLpEvent HvCallEvent + 1
  59. #define HvCallEventCloseLpEventPath HvCallEvent + 2
  60. #define HvCallEventDmaBufList HvCallEvent + 3
  61. #define HvCallEventDmaSingle HvCallEvent + 4
  62. #define HvCallEventDmaToSp HvCallEvent + 5
  63. #define HvCallEventGetOverflowLpEvents HvCallEvent + 6
  64. #define HvCallEventGetSourceLpInstanceId HvCallEvent + 7
  65. #define HvCallEventGetTargetLpInstanceId HvCallEvent + 8
  66. #define HvCallEventOpenLpEventPath HvCallEvent + 9
  67. #define HvCallEventSetLpEventStack HvCallEvent + 10
  68. #define HvCallEventSignalLpEvent HvCallEvent + 11
  69. #define HvCallEventSignalLpEventParms HvCallEvent + 12
  70. #define HvCallEventSetInterLpQueueIndex HvCallEvent + 13
  71. #define HvCallEventSetLpEventQueueInterruptProc HvCallEvent + 14
  72. #define HvCallEventRouter15 HvCallEvent + 15
  73. static inline void HvCallEvent_getOverflowLpEvents(u8 queueIndex)
  74. {
  75. HvCall1(HvCallEventGetOverflowLpEvents, queueIndex);
  76. }
  77. static inline void HvCallEvent_setInterLpQueueIndex(u8 queueIndex)
  78. {
  79. HvCall1(HvCallEventSetInterLpQueueIndex, queueIndex);
  80. }
  81. static inline void HvCallEvent_setLpEventStack(u8 queueIndex,
  82. char *eventStackAddr, u32 eventStackSize)
  83. {
  84. u64 abs_addr;
  85. abs_addr = virt_to_abs(eventStackAddr);
  86. HvCall3(HvCallEventSetLpEventStack, queueIndex, abs_addr,
  87. eventStackSize);
  88. }
  89. static inline void HvCallEvent_setLpEventQueueInterruptProc(u8 queueIndex,
  90. u16 lpLogicalProcIndex)
  91. {
  92. HvCall2(HvCallEventSetLpEventQueueInterruptProc, queueIndex,
  93. lpLogicalProcIndex);
  94. }
  95. static inline HvLpEvent_Rc HvCallEvent_signalLpEvent(struct HvLpEvent *event)
  96. {
  97. u64 abs_addr;
  98. #ifdef DEBUG_SENDEVENT
  99. printk("HvCallEvent_signalLpEvent: *event = %016lx\n ",
  100. (unsigned long)event);
  101. #endif
  102. abs_addr = virt_to_abs(event);
  103. return HvCall1(HvCallEventSignalLpEvent, abs_addr);
  104. }
  105. static inline HvLpEvent_Rc HvCallEvent_signalLpEventFast(HvLpIndex targetLp,
  106. HvLpEvent_Type type, u16 subtype, HvLpEvent_AckInd ackInd,
  107. HvLpEvent_AckType ackType, HvLpInstanceId sourceInstanceId,
  108. HvLpInstanceId targetInstanceId, u64 correlationToken,
  109. u64 eventData1, u64 eventData2, u64 eventData3,
  110. u64 eventData4, u64 eventData5)
  111. {
  112. /* Pack the misc bits into a single Dword to pass to PLIC */
  113. union {
  114. struct HvCallEvent_PackedParms parms;
  115. u64 dword;
  116. } packed;
  117. packed.parms.xAckType = ackType;
  118. packed.parms.xAckInd = ackInd;
  119. packed.parms.xRsvd = 0;
  120. packed.parms.xTargetLp = targetLp;
  121. packed.parms.xType = type;
  122. packed.parms.xSubtype = subtype;
  123. packed.parms.xSourceInstId = sourceInstanceId;
  124. packed.parms.xTargetInstId = targetInstanceId;
  125. return HvCall7(HvCallEventSignalLpEventParms, packed.dword,
  126. correlationToken, eventData1, eventData2,
  127. eventData3, eventData4, eventData5);
  128. }
  129. static inline HvLpEvent_Rc HvCallEvent_ackLpEvent(struct HvLpEvent *event)
  130. {
  131. u64 abs_addr;
  132. abs_addr = virt_to_abs(event);
  133. return HvCall1(HvCallEventAckLpEvent, abs_addr);
  134. }
  135. static inline HvLpEvent_Rc HvCallEvent_cancelLpEvent(struct HvLpEvent *event)
  136. {
  137. u64 abs_addr;
  138. abs_addr = virt_to_abs(event);
  139. return HvCall1(HvCallEventCancelLpEvent, abs_addr);
  140. }
  141. static inline HvLpInstanceId HvCallEvent_getSourceLpInstanceId(
  142. HvLpIndex targetLp, HvLpEvent_Type type)
  143. {
  144. return HvCall2(HvCallEventGetSourceLpInstanceId, targetLp, type);
  145. }
  146. static inline HvLpInstanceId HvCallEvent_getTargetLpInstanceId(
  147. HvLpIndex targetLp, HvLpEvent_Type type)
  148. {
  149. return HvCall2(HvCallEventGetTargetLpInstanceId, targetLp, type);
  150. }
  151. static inline void HvCallEvent_openLpEventPath(HvLpIndex targetLp,
  152. HvLpEvent_Type type)
  153. {
  154. HvCall2(HvCallEventOpenLpEventPath, targetLp, type);
  155. }
  156. static inline void HvCallEvent_closeLpEventPath(HvLpIndex targetLp,
  157. HvLpEvent_Type type)
  158. {
  159. HvCall2(HvCallEventCloseLpEventPath, targetLp, type);
  160. }
  161. static inline HvLpDma_Rc HvCallEvent_dmaBufList(HvLpEvent_Type type,
  162. HvLpIndex remoteLp, HvLpDma_Direction direction,
  163. HvLpInstanceId localInstanceId,
  164. HvLpInstanceId remoteInstanceId,
  165. HvLpDma_AddressType localAddressType,
  166. HvLpDma_AddressType remoteAddressType,
  167. /* Do these need to be converted to absolute addresses? */
  168. u64 localBufList, u64 remoteBufList, u32 transferLength)
  169. {
  170. /* Pack the misc bits into a single Dword to pass to PLIC */
  171. union {
  172. struct HvCallEvent_PackedDmaParms parms;
  173. u64 dword;
  174. } packed;
  175. packed.parms.xDirection = direction;
  176. packed.parms.xLocalAddrType = localAddressType;
  177. packed.parms.xRemoteAddrType = remoteAddressType;
  178. packed.parms.xRsvd1 = 0;
  179. packed.parms.xRemoteLp = remoteLp;
  180. packed.parms.xType = type;
  181. packed.parms.xRsvd2 = 0;
  182. packed.parms.xLocalInstId = localInstanceId;
  183. packed.parms.xRemoteInstId = remoteInstanceId;
  184. return HvCall4(HvCallEventDmaBufList, packed.dword, localBufList,
  185. remoteBufList, transferLength);
  186. }
  187. static inline HvLpDma_Rc HvCallEvent_dmaSingle(HvLpEvent_Type type,
  188. HvLpIndex remoteLp, HvLpDma_Direction direction,
  189. HvLpInstanceId localInstanceId,
  190. HvLpInstanceId remoteInstanceId,
  191. HvLpDma_AddressType localAddressType,
  192. HvLpDma_AddressType remoteAddressType,
  193. u64 localAddrOrTce, u64 remoteAddrOrTce, u32 transferLength)
  194. {
  195. /* Pack the misc bits into a single Dword to pass to PLIC */
  196. union {
  197. struct HvCallEvent_PackedDmaParms parms;
  198. u64 dword;
  199. } packed;
  200. packed.parms.xDirection = direction;
  201. packed.parms.xLocalAddrType = localAddressType;
  202. packed.parms.xRemoteAddrType = remoteAddressType;
  203. packed.parms.xRsvd1 = 0;
  204. packed.parms.xRemoteLp = remoteLp;
  205. packed.parms.xType = type;
  206. packed.parms.xRsvd2 = 0;
  207. packed.parms.xLocalInstId = localInstanceId;
  208. packed.parms.xRemoteInstId = remoteInstanceId;
  209. return (HvLpDma_Rc)HvCall4(HvCallEventDmaSingle, packed.dword,
  210. localAddrOrTce, remoteAddrOrTce, transferLength);
  211. }
  212. static inline HvLpDma_Rc HvCallEvent_dmaToSp(void *local, u32 remote,
  213. u32 length, HvLpDma_Direction dir)
  214. {
  215. u64 abs_addr;
  216. abs_addr = virt_to_abs(local);
  217. return HvCall4(HvCallEventDmaToSp, abs_addr, remote, length, dir);
  218. }
  219. #endif /* _HVCALLEVENT_H */