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