HvCallEvent.h
上传用户:jlfgdled
上传日期:2013-04-10
资源大小:33168k
文件大小:11k
源码类别:

Linux/Unix编程

开发平台:

Unix_Linux

  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. //
  21. // This file contains the "hypervisor call" interface which is used to
  22. // drive the hypervisor from the OS.
  23. //
  24. //==================================================================
  25. //-------------------------------------------------------------------
  26. // Standard Includes
  27. //-------------------------------------------------------------------
  28. #ifndef  _HVCALLSC_H
  29. #include <asm/iSeries/HvCallSc.h>
  30. #endif
  31. #ifndef  _HVTYPES_H
  32. #include <asm/iSeries/HvTypes.h>
  33. #endif
  34. #include <asm/abs_addr.h>
  35. //-------------------------------------------------------------------
  36. // Other Includes
  37. //-------------------------------------------------------------------
  38. //-------------------------------------------------------------------
  39. // Constants
  40. //-------------------------------------------------------------------
  41. #ifndef _HVCALLEVENT_H
  42. #define _HVCALLEVENT_H
  43. struct HvLpEvent;
  44. typedef u8 HvLpEvent_Type;
  45. typedef u8 HvLpEvent_AckInd;
  46. typedef u8 HvLpEvent_AckType;
  47. struct HvCallEvent_PackedParms
  48. {
  49. u8 xAckType:1;
  50. u8 xAckInd:1;
  51. u8 xRsvd:1;
  52. u8 xTargetLp:5;
  53. u8 xType;
  54. u16 xSubtype;
  55. HvLpInstanceId xSourceInstId;
  56. HvLpInstanceId xTargetInstId;
  57. };
  58. typedef u8 HvLpDma_Direction;
  59. typedef u8 HvLpDma_AddressType;
  60. struct HvCallEvent_PackedDmaParms
  61. {
  62. u8 xDirection:1;
  63. u8 xLocalAddrType:1;
  64. u8 xRemoteAddrType:1;
  65. u8 xRsvd1:5;
  66. HvLpIndex xRemoteLp;
  67. u8 xType;
  68. u8 xRsvd2;
  69. HvLpInstanceId xLocalInstId;
  70. HvLpInstanceId xRemoteInstId;
  71. };
  72. typedef u64 HvLpEvent_Rc;
  73. typedef u64 HvLpDma_Rc;
  74. #define HvCallEventAckLpEvent HvCallEvent +  0
  75. #define HvCallEventCancelLpEvent HvCallEvent +  1
  76. #define HvCallEventCloseLpEventPath HvCallEvent +  2
  77. #define HvCallEventDmaBufList HvCallEvent +  3
  78. #define HvCallEventDmaSingle HvCallEvent +  4
  79. #define HvCallEventDmaToSp HvCallEvent +  5 
  80. #define HvCallEventGetOverflowLpEvents HvCallEvent +  6
  81. #define HvCallEventGetSourceLpInstanceId HvCallEvent +  7
  82. #define HvCallEventGetTargetLpInstanceId HvCallEvent +  8
  83. #define HvCallEventOpenLpEventPath HvCallEvent +  9
  84. #define HvCallEventSetLpEventStack HvCallEvent + 10
  85. #define HvCallEventSignalLpEvent HvCallEvent + 11
  86. #define HvCallEventSignalLpEventParms HvCallEvent + 12
  87. #define HvCallEventSetInterLpQueueIndex HvCallEvent + 13
  88. #define HvCallEventSetLpEventQueueInterruptProc HvCallEvent + 14
  89. #define HvCallEventRouter15 HvCallEvent + 15
  90. //======================================================================
  91. static inline void HvCallEvent_getOverflowLpEvents(u8 queueIndex)
  92. {
  93. HvCall1(HvCallEventGetOverflowLpEvents,queueIndex);
  94. // getPaca()->adjustHmtForNoOfSpinLocksHeld();
  95. }
  96. //======================================================================
  97. static inline void HvCallEvent_setInterLpQueueIndex(u8 queueIndex)
  98. {
  99. HvCall1(HvCallEventSetInterLpQueueIndex,queueIndex);
  100. // getPaca()->adjustHmtForNoOfSpinLocksHeld();
  101. }
  102. //======================================================================
  103. static inline void HvCallEvent_setLpEventStack(u8 queueIndex,
  104.      char * eventStackAddr,
  105.      u32 eventStackSize)
  106. {
  107. u64 abs_addr;
  108. abs_addr = virt_to_absolute( (unsigned long) eventStackAddr );
  109. HvCall3(HvCallEventSetLpEventStack, queueIndex, abs_addr, eventStackSize);
  110. // getPaca()->adjustHmtForNoOfSpinLocksHeld();
  111. }
  112. //======================================================================
  113. static inline void HvCallEvent_setLpEventQueueInterruptProc(u8 queueIndex,
  114.   u16 lpLogicalProcIndex)
  115. {
  116. HvCall2(HvCallEventSetLpEventQueueInterruptProc,queueIndex,lpLogicalProcIndex);
  117. // getPaca()->adjustHmtForNoOfSpinLocksHeld();
  118. }
  119. //=====================================================================
  120. static inline HvLpEvent_Rc HvCallEvent_signalLpEvent(struct HvLpEvent* event)
  121. {
  122. u64 abs_addr;
  123. HvLpEvent_Rc retVal;
  124. #ifdef DEBUG_SENDEVENT
  125. printk("HvCallEvent_signalLpEvent: *event = %016lxn ", (unsigned long)event);
  126. #endif
  127. abs_addr = virt_to_absolute( (unsigned long) event );
  128. retVal = (HvLpEvent_Rc)HvCall1(HvCallEventSignalLpEvent, abs_addr);
  129. // getPaca()->adjustHmtForNoOfSpinLocksHeld();
  130. return retVal;
  131. }
  132. //=====================================================================
  133. static inline HvLpEvent_Rc  HvCallEvent_signalLpEventFast(HvLpIndex targetLp,
  134.    HvLpEvent_Type type,
  135.    u16 subtype,
  136.    HvLpEvent_AckInd ackInd,
  137.    HvLpEvent_AckType ackType,
  138.    HvLpInstanceId sourceInstanceId,
  139.    HvLpInstanceId targetInstanceId,
  140.    u64 correlationToken,
  141.    u64 eventData1,
  142.    u64 eventData2,
  143.    u64 eventData3,
  144.    u64 eventData4,
  145.    u64 eventData5)
  146. {
  147. HvLpEvent_Rc retVal;
  148. // Pack the misc bits into a single Dword to pass to PLIC
  149. union
  150. {
  151. struct HvCallEvent_PackedParms parms;
  152. u64 dword;
  153. } packed;
  154. packed.parms.xAckType = ackType;
  155. packed.parms.xAckInd = ackInd;
  156. packed.parms.xRsvd = 0;
  157. packed.parms.xTargetLp = targetLp;
  158. packed.parms.xType = type;
  159. packed.parms.xSubtype = subtype;
  160. packed.parms.xSourceInstId = sourceInstanceId;
  161. packed.parms.xTargetInstId = targetInstanceId;
  162. retVal = (HvLpEvent_Rc)HvCall7(HvCallEventSignalLpEventParms,
  163.        packed.dword,
  164.        correlationToken,
  165.        eventData1,eventData2,
  166.        eventData3,eventData4,
  167.        eventData5);
  168. // getPaca()->adjustHmtForNoOfSpinLocksHeld();
  169. return retVal;
  170. }
  171. //====================================================================
  172. static inline HvLpEvent_Rc HvCallEvent_ackLpEvent(struct HvLpEvent* event)
  173. {
  174. u64 abs_addr;
  175. HvLpEvent_Rc retVal;
  176. abs_addr = virt_to_absolute( (unsigned long) event );
  177. retVal = (HvLpEvent_Rc)HvCall1(HvCallEventAckLpEvent, abs_addr);
  178. // getPaca()->adjustHmtForNoOfSpinLocksHeld();
  179. return retVal;
  180. }
  181. //====================================================================
  182. static inline HvLpEvent_Rc   HvCallEvent_cancelLpEvent(struct HvLpEvent* event)
  183. {
  184. u64 abs_addr;
  185. HvLpEvent_Rc retVal;
  186. abs_addr = virt_to_absolute( (unsigned long) event );
  187. retVal = (HvLpEvent_Rc)HvCall1(HvCallEventCancelLpEvent, abs_addr);
  188. // getPaca()->adjustHmtForNoOfSpinLocksHeld();
  189. return retVal;
  190. }
  191. //===================================================================
  192. static inline HvLpInstanceId HvCallEvent_getSourceLpInstanceId(HvLpIndex targetLp, HvLpEvent_Type type)
  193. {
  194. HvLpInstanceId retVal;
  195. retVal = HvCall2(HvCallEventGetSourceLpInstanceId,targetLp,type);
  196. // getPaca()->adjustHmtForNoOfSpinLocksHeld();
  197. return retVal;
  198. }
  199. //===================================================================
  200. static inline HvLpInstanceId HvCallEvent_getTargetLpInstanceId(HvLpIndex targetLp, HvLpEvent_Type type)
  201. {
  202. HvLpInstanceId retVal;
  203. retVal = HvCall2(HvCallEventGetTargetLpInstanceId,targetLp,type);
  204. // getPaca()->adjustHmtForNoOfSpinLocksHeld();
  205. return retVal;
  206. }
  207. //===================================================================
  208. static inline void HvCallEvent_openLpEventPath(HvLpIndex targetLp,
  209.      HvLpEvent_Type type)
  210. {
  211. HvCall2(HvCallEventOpenLpEventPath,targetLp,type);
  212. // getPaca()->adjustHmtForNoOfSpinLocksHeld();
  213. }
  214. //===================================================================
  215. static inline void HvCallEvent_closeLpEventPath(HvLpIndex targetLp,
  216.       HvLpEvent_Type type)
  217. {
  218. HvCall2(HvCallEventCloseLpEventPath,targetLp,type);
  219. // getPaca()->adjustHmtForNoOfSpinLocksHeld();
  220. }
  221. //===================================================================
  222. static inline HvLpDma_Rc HvCallEvent_dmaBufList(HvLpEvent_Type type,
  223. HvLpIndex remoteLp,
  224. HvLpDma_Direction direction,
  225. HvLpInstanceId localInstanceId,
  226. HvLpInstanceId remoteInstanceId,
  227. HvLpDma_AddressType localAddressType,
  228. HvLpDma_AddressType remoteAddressType,
  229. // Do these need to be converted to
  230. // absolute addresses?
  231. u64 localBufList,
  232. u64 remoteBufList,
  233. u32 transferLength)
  234. {
  235. HvLpDma_Rc retVal;
  236. // Pack the misc bits into a single Dword to pass to PLIC
  237. union
  238. {
  239. struct HvCallEvent_PackedDmaParms parms;
  240. u64 dword;
  241. } packed;
  242. packed.parms.xDirection = direction;
  243. packed.parms.xLocalAddrType = localAddressType;
  244. packed.parms.xRemoteAddrType = remoteAddressType;
  245. packed.parms.xRsvd1 = 0;
  246. packed.parms.xRemoteLp = remoteLp;
  247. packed.parms.xType = type;
  248. packed.parms.xRsvd2 = 0;
  249. packed.parms.xLocalInstId = localInstanceId;
  250. packed.parms.xRemoteInstId = remoteInstanceId;
  251. retVal = (HvLpDma_Rc)HvCall4(HvCallEventDmaBufList,
  252.      packed.dword,
  253.      localBufList,
  254.      remoteBufList,
  255.      transferLength);
  256. // getPaca()->adjustHmtForNoOfSpinLocksHeld();
  257. return retVal;
  258. }
  259. //=================================================================
  260. static inline HvLpDma_Rc HvCallEvent_dmaSingle(HvLpEvent_Type type,
  261.        HvLpIndex remoteLp,
  262.        HvLpDma_Direction direction,
  263.        HvLpInstanceId localInstanceId,
  264.        HvLpInstanceId remoteInstanceId,
  265.        HvLpDma_AddressType localAddressType,
  266.        HvLpDma_AddressType remoteAddressType,
  267.        u64 localAddrOrTce,
  268.        u64 remoteAddrOrTce,
  269.        u32 transferLength)
  270. {
  271. HvLpDma_Rc retVal;
  272. // Pack the misc bits into a single Dword to pass to PLIC
  273. union
  274. {
  275. struct HvCallEvent_PackedDmaParms parms;
  276. u64 dword;
  277. } packed;
  278. packed.parms.xDirection = direction;
  279. packed.parms.xLocalAddrType = localAddressType;
  280. packed.parms.xRemoteAddrType = remoteAddressType;
  281. packed.parms.xRsvd1 = 0;
  282. packed.parms.xRemoteLp = remoteLp;
  283. packed.parms.xType = type;
  284. packed.parms.xRsvd2 = 0;
  285. packed.parms.xLocalInstId = localInstanceId;
  286. packed.parms.xRemoteInstId = remoteInstanceId;
  287. retVal = (HvLpDma_Rc)HvCall4(HvCallEventDmaSingle,
  288.      packed.dword,
  289.      localAddrOrTce,
  290.      remoteAddrOrTce,
  291.      transferLength);
  292. // getPaca()->adjustHmtForNoOfSpinLocksHeld();
  293. return retVal;
  294. }
  295. //=================================================================
  296. static inline HvLpDma_Rc HvCallEvent_dmaToSp(void* local, u32 remote, u32 length, HvLpDma_Direction dir)
  297. {
  298. u64 abs_addr;
  299. HvLpDma_Rc retVal;
  300. abs_addr = virt_to_absolute( (unsigned long) local );
  301.     
  302. retVal = (HvLpDma_Rc)HvCall4(HvCallEventDmaToSp, 
  303.      abs_addr,
  304.      remote,
  305.      length,
  306.      dir);
  307. // getPaca()->adjustHmtForNoOfSpinLocksHeld();
  308. return retVal;
  309. }
  310. //================================================================
  311. #endif // _HVCALLEVENT_H