hv_call_event.h 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201
  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 <linux/types.h>
  24. #include <linux/dma-mapping.h>
  25. #include <asm/iseries/hv_call_sc.h>
  26. #include <asm/iseries/hv_types.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. typedef u8 HvLpDma_Direction;
  33. typedef u8 HvLpDma_AddressType;
  34. typedef u64 HvLpEvent_Rc;
  35. typedef u64 HvLpDma_Rc;
  36. #define HvCallEventAckLpEvent HvCallEvent + 0
  37. #define HvCallEventCancelLpEvent HvCallEvent + 1
  38. #define HvCallEventCloseLpEventPath HvCallEvent + 2
  39. #define HvCallEventDmaBufList HvCallEvent + 3
  40. #define HvCallEventDmaSingle HvCallEvent + 4
  41. #define HvCallEventDmaToSp HvCallEvent + 5
  42. #define HvCallEventGetOverflowLpEvents HvCallEvent + 6
  43. #define HvCallEventGetSourceLpInstanceId HvCallEvent + 7
  44. #define HvCallEventGetTargetLpInstanceId HvCallEvent + 8
  45. #define HvCallEventOpenLpEventPath HvCallEvent + 9
  46. #define HvCallEventSetLpEventStack HvCallEvent + 10
  47. #define HvCallEventSignalLpEvent HvCallEvent + 11
  48. #define HvCallEventSignalLpEventParms HvCallEvent + 12
  49. #define HvCallEventSetInterLpQueueIndex HvCallEvent + 13
  50. #define HvCallEventSetLpEventQueueInterruptProc HvCallEvent + 14
  51. #define HvCallEventRouter15 HvCallEvent + 15
  52. static inline void HvCallEvent_getOverflowLpEvents(u8 queueIndex)
  53. {
  54. HvCall1(HvCallEventGetOverflowLpEvents, queueIndex);
  55. }
  56. static inline void HvCallEvent_setInterLpQueueIndex(u8 queueIndex)
  57. {
  58. HvCall1(HvCallEventSetInterLpQueueIndex, queueIndex);
  59. }
  60. static inline void HvCallEvent_setLpEventStack(u8 queueIndex,
  61. char *eventStackAddr, u32 eventStackSize)
  62. {
  63. HvCall3(HvCallEventSetLpEventStack, queueIndex,
  64. virt_to_abs(eventStackAddr), eventStackSize);
  65. }
  66. static inline void HvCallEvent_setLpEventQueueInterruptProc(u8 queueIndex,
  67. u16 lpLogicalProcIndex)
  68. {
  69. HvCall2(HvCallEventSetLpEventQueueInterruptProc, queueIndex,
  70. lpLogicalProcIndex);
  71. }
  72. static inline HvLpEvent_Rc HvCallEvent_signalLpEvent(struct HvLpEvent *event)
  73. {
  74. return HvCall1(HvCallEventSignalLpEvent, virt_to_abs(event));
  75. }
  76. static inline HvLpEvent_Rc HvCallEvent_signalLpEventFast(HvLpIndex targetLp,
  77. HvLpEvent_Type type, u16 subtype, HvLpEvent_AckInd ackInd,
  78. HvLpEvent_AckType ackType, HvLpInstanceId sourceInstanceId,
  79. HvLpInstanceId targetInstanceId, u64 correlationToken,
  80. u64 eventData1, u64 eventData2, u64 eventData3,
  81. u64 eventData4, u64 eventData5)
  82. {
  83. /* Pack the misc bits into a single Dword to pass to PLIC */
  84. union {
  85. struct {
  86. u8 ack_and_target;
  87. u8 type;
  88. u16 subtype;
  89. HvLpInstanceId src_inst;
  90. HvLpInstanceId target_inst;
  91. } parms;
  92. u64 dword;
  93. } packed;
  94. packed.parms.ack_and_target = (ackType << 7) | (ackInd << 6) | targetLp;
  95. packed.parms.type = type;
  96. packed.parms.subtype = subtype;
  97. packed.parms.src_inst = sourceInstanceId;
  98. packed.parms.target_inst = targetInstanceId;
  99. return HvCall7(HvCallEventSignalLpEventParms, packed.dword,
  100. correlationToken, eventData1, eventData2,
  101. eventData3, eventData4, eventData5);
  102. }
  103. extern void *iseries_hv_alloc(size_t size, dma_addr_t *dma_handle, gfp_t flag);
  104. extern void iseries_hv_free(size_t size, void *vaddr, dma_addr_t dma_handle);
  105. extern dma_addr_t iseries_hv_map(void *vaddr, size_t size,
  106. enum dma_data_direction direction);
  107. extern void iseries_hv_unmap(dma_addr_t dma_handle, size_t size,
  108. enum dma_data_direction direction);
  109. static inline HvLpEvent_Rc HvCallEvent_ackLpEvent(struct HvLpEvent *event)
  110. {
  111. return HvCall1(HvCallEventAckLpEvent, virt_to_abs(event));
  112. }
  113. static inline HvLpEvent_Rc HvCallEvent_cancelLpEvent(struct HvLpEvent *event)
  114. {
  115. return HvCall1(HvCallEventCancelLpEvent, virt_to_abs(event));
  116. }
  117. static inline HvLpInstanceId HvCallEvent_getSourceLpInstanceId(
  118. HvLpIndex targetLp, HvLpEvent_Type type)
  119. {
  120. return HvCall2(HvCallEventGetSourceLpInstanceId, targetLp, type);
  121. }
  122. static inline HvLpInstanceId HvCallEvent_getTargetLpInstanceId(
  123. HvLpIndex targetLp, HvLpEvent_Type type)
  124. {
  125. return HvCall2(HvCallEventGetTargetLpInstanceId, targetLp, type);
  126. }
  127. static inline void HvCallEvent_openLpEventPath(HvLpIndex targetLp,
  128. HvLpEvent_Type type)
  129. {
  130. HvCall2(HvCallEventOpenLpEventPath, targetLp, type);
  131. }
  132. static inline void HvCallEvent_closeLpEventPath(HvLpIndex targetLp,
  133. HvLpEvent_Type type)
  134. {
  135. HvCall2(HvCallEventCloseLpEventPath, targetLp, type);
  136. }
  137. static inline HvLpDma_Rc HvCallEvent_dmaBufList(HvLpEvent_Type type,
  138. HvLpIndex remoteLp, HvLpDma_Direction direction,
  139. HvLpInstanceId localInstanceId,
  140. HvLpInstanceId remoteInstanceId,
  141. HvLpDma_AddressType localAddressType,
  142. HvLpDma_AddressType remoteAddressType,
  143. /* Do these need to be converted to absolute addresses? */
  144. u64 localBufList, u64 remoteBufList, u32 transferLength)
  145. {
  146. /* Pack the misc bits into a single Dword to pass to PLIC */
  147. union {
  148. struct {
  149. u8 flags;
  150. HvLpIndex remote;
  151. u8 type;
  152. u8 reserved;
  153. HvLpInstanceId local_inst;
  154. HvLpInstanceId remote_inst;
  155. } parms;
  156. u64 dword;
  157. } packed;
  158. packed.parms.flags = (direction << 7) |
  159. (localAddressType << 6) | (remoteAddressType << 5);
  160. packed.parms.remote = remoteLp;
  161. packed.parms.type = type;
  162. packed.parms.reserved = 0;
  163. packed.parms.local_inst = localInstanceId;
  164. packed.parms.remote_inst = remoteInstanceId;
  165. return HvCall4(HvCallEventDmaBufList, packed.dword, localBufList,
  166. remoteBufList, transferLength);
  167. }
  168. static inline HvLpDma_Rc HvCallEvent_dmaToSp(void *local, u32 remote,
  169. u32 length, HvLpDma_Direction dir)
  170. {
  171. return HvCall4(HvCallEventDmaToSp, virt_to_abs(local), remote,
  172. length, dir);
  173. }
  174. #endif /* _ASM_POWERPC_ISERIES_HV_CALL_EVENT_H */