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