hv_call_event.h 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191
  1. /*
  2. * Copyright (C) 2001 Mike Corrigan IBM Corporation
  3. *
  4. * This program is free software; you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License as published by
  6. * the Free Software Foundation; either version 2 of the License, or
  7. * (at your option) any later version.
  8. *
  9. * This program is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License
  15. * along with this program; if not, write to the Free Software
  16. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  17. *
  18. * This file contains the "hypervisor call" interface which is used to
  19. * drive the hypervisor from the OS.
  20. */
  21. #ifndef _ASM_POWERPC_ISERIES_HV_CALL_EVENT_H
  22. #define _ASM_POWERPC_ISERIES_HV_CALL_EVENT_H
  23. #include <asm/iseries/hv_call_sc.h>
  24. #include <asm/iseries/hv_types.h>
  25. #include <asm/abs_addr.h>
  26. struct HvLpEvent;
  27. typedef u8 HvLpEvent_Type;
  28. typedef u8 HvLpEvent_AckInd;
  29. typedef u8 HvLpEvent_AckType;
  30. typedef u8 HvLpDma_Direction;
  31. typedef u8 HvLpDma_AddressType;
  32. typedef u64 HvLpEvent_Rc;
  33. typedef u64 HvLpDma_Rc;
  34. #define HvCallEventAckLpEvent HvCallEvent + 0
  35. #define HvCallEventCancelLpEvent HvCallEvent + 1
  36. #define HvCallEventCloseLpEventPath HvCallEvent + 2
  37. #define HvCallEventDmaBufList HvCallEvent + 3
  38. #define HvCallEventDmaSingle HvCallEvent + 4
  39. #define HvCallEventDmaToSp HvCallEvent + 5
  40. #define HvCallEventGetOverflowLpEvents HvCallEvent + 6
  41. #define HvCallEventGetSourceLpInstanceId HvCallEvent + 7
  42. #define HvCallEventGetTargetLpInstanceId HvCallEvent + 8
  43. #define HvCallEventOpenLpEventPath HvCallEvent + 9
  44. #define HvCallEventSetLpEventStack HvCallEvent + 10
  45. #define HvCallEventSignalLpEvent HvCallEvent + 11
  46. #define HvCallEventSignalLpEventParms HvCallEvent + 12
  47. #define HvCallEventSetInterLpQueueIndex HvCallEvent + 13
  48. #define HvCallEventSetLpEventQueueInterruptProc HvCallEvent + 14
  49. #define HvCallEventRouter15 HvCallEvent + 15
  50. static inline void HvCallEvent_getOverflowLpEvents(u8 queueIndex)
  51. {
  52. HvCall1(HvCallEventGetOverflowLpEvents, queueIndex);
  53. }
  54. static inline void HvCallEvent_setInterLpQueueIndex(u8 queueIndex)
  55. {
  56. HvCall1(HvCallEventSetInterLpQueueIndex, queueIndex);
  57. }
  58. static inline void HvCallEvent_setLpEventStack(u8 queueIndex,
  59. char *eventStackAddr, u32 eventStackSize)
  60. {
  61. HvCall3(HvCallEventSetLpEventStack, queueIndex,
  62. virt_to_abs(eventStackAddr), eventStackSize);
  63. }
  64. static inline void HvCallEvent_setLpEventQueueInterruptProc(u8 queueIndex,
  65. u16 lpLogicalProcIndex)
  66. {
  67. HvCall2(HvCallEventSetLpEventQueueInterruptProc, queueIndex,
  68. lpLogicalProcIndex);
  69. }
  70. static inline HvLpEvent_Rc HvCallEvent_signalLpEvent(struct HvLpEvent *event)
  71. {
  72. return HvCall1(HvCallEventSignalLpEvent, virt_to_abs(event));
  73. }
  74. static inline HvLpEvent_Rc HvCallEvent_signalLpEventFast(HvLpIndex targetLp,
  75. HvLpEvent_Type type, u16 subtype, HvLpEvent_AckInd ackInd,
  76. HvLpEvent_AckType ackType, HvLpInstanceId sourceInstanceId,
  77. HvLpInstanceId targetInstanceId, u64 correlationToken,
  78. u64 eventData1, u64 eventData2, u64 eventData3,
  79. u64 eventData4, u64 eventData5)
  80. {
  81. /* Pack the misc bits into a single Dword to pass to PLIC */
  82. union {
  83. struct {
  84. u8 ack_and_target;
  85. u8 type;
  86. u16 subtype;
  87. HvLpInstanceId src_inst;
  88. HvLpInstanceId target_inst;
  89. } parms;
  90. u64 dword;
  91. } packed;
  92. packed.parms.ack_and_target = (ackType << 7) | (ackInd << 6) | targetLp;
  93. packed.parms.type = type;
  94. packed.parms.subtype = subtype;
  95. packed.parms.src_inst = sourceInstanceId;
  96. packed.parms.target_inst = targetInstanceId;
  97. return HvCall7(HvCallEventSignalLpEventParms, packed.dword,
  98. correlationToken, eventData1, eventData2,
  99. eventData3, eventData4, eventData5);
  100. }
  101. static inline HvLpEvent_Rc HvCallEvent_ackLpEvent(struct HvLpEvent *event)
  102. {
  103. return HvCall1(HvCallEventAckLpEvent, virt_to_abs(event));
  104. }
  105. static inline HvLpEvent_Rc HvCallEvent_cancelLpEvent(struct HvLpEvent *event)
  106. {
  107. return HvCall1(HvCallEventCancelLpEvent, virt_to_abs(event));
  108. }
  109. static inline HvLpInstanceId HvCallEvent_getSourceLpInstanceId(
  110. HvLpIndex targetLp, HvLpEvent_Type type)
  111. {
  112. return HvCall2(HvCallEventGetSourceLpInstanceId, targetLp, type);
  113. }
  114. static inline HvLpInstanceId HvCallEvent_getTargetLpInstanceId(
  115. HvLpIndex targetLp, HvLpEvent_Type type)
  116. {
  117. return HvCall2(HvCallEventGetTargetLpInstanceId, targetLp, type);
  118. }
  119. static inline void HvCallEvent_openLpEventPath(HvLpIndex targetLp,
  120. HvLpEvent_Type type)
  121. {
  122. HvCall2(HvCallEventOpenLpEventPath, targetLp, type);
  123. }
  124. static inline void HvCallEvent_closeLpEventPath(HvLpIndex targetLp,
  125. HvLpEvent_Type type)
  126. {
  127. HvCall2(HvCallEventCloseLpEventPath, targetLp, type);
  128. }
  129. static inline HvLpDma_Rc HvCallEvent_dmaBufList(HvLpEvent_Type type,
  130. HvLpIndex remoteLp, HvLpDma_Direction direction,
  131. HvLpInstanceId localInstanceId,
  132. HvLpInstanceId remoteInstanceId,
  133. HvLpDma_AddressType localAddressType,
  134. HvLpDma_AddressType remoteAddressType,
  135. /* Do these need to be converted to absolute addresses? */
  136. u64 localBufList, u64 remoteBufList, u32 transferLength)
  137. {
  138. /* Pack the misc bits into a single Dword to pass to PLIC */
  139. union {
  140. struct {
  141. u8 flags;
  142. HvLpIndex remote;
  143. u8 type;
  144. u8 reserved;
  145. HvLpInstanceId local_inst;
  146. HvLpInstanceId remote_inst;
  147. } parms;
  148. u64 dword;
  149. } packed;
  150. packed.parms.flags = (direction << 7) |
  151. (localAddressType << 6) | (remoteAddressType << 5);
  152. packed.parms.remote = remoteLp;
  153. packed.parms.type = type;
  154. packed.parms.reserved = 0;
  155. packed.parms.local_inst = localInstanceId;
  156. packed.parms.remote_inst = remoteInstanceId;
  157. return HvCall4(HvCallEventDmaBufList, packed.dword, localBufList,
  158. remoteBufList, transferLength);
  159. }
  160. static inline HvLpDma_Rc HvCallEvent_dmaToSp(void *local, u32 remote,
  161. u32 length, HvLpDma_Direction dir)
  162. {
  163. return HvCall4(HvCallEventDmaToSp, virt_to_abs(local), remote,
  164. length, dir);
  165. }
  166. #endif /* _ASM_POWERPC_ISERIES_HV_CALL_EVENT_H */