Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2 | * Copyright (C) 2001 Mike Corrigan IBM Corporation |
Stephen Rothwell | 45dc76a | 2005-06-21 17:15:33 -0700 | [diff] [blame] | 3 | * |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 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. |
Stephen Rothwell | 45dc76a | 2005-06-21 17:15:33 -0700 | [diff] [blame] | 8 | * |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 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. |
Stephen Rothwell | 45dc76a | 2005-06-21 17:15:33 -0700 | [diff] [blame] | 13 | * |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 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 |
Stephen Rothwell | 6814350 | 2006-01-12 13:48:52 +1100 | [diff] [blame] | 17 | * |
Stephen Rothwell | 45dc76a | 2005-06-21 17:15:33 -0700 | [diff] [blame] | 18 | * This file contains the "hypervisor call" interface which is used to |
| 19 | * drive the hypervisor from the OS. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 20 | */ |
Kelly Daly | ecb3ca2 | 2005-11-02 15:53:01 +1100 | [diff] [blame] | 21 | #ifndef _ASM_POWERPC_ISERIES_HV_CALL_EVENT_H |
| 22 | #define _ASM_POWERPC_ISERIES_HV_CALL_EVENT_H |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 23 | |
Kelly Daly | 50592f5 | 2005-11-02 11:37:22 +1100 | [diff] [blame] | 24 | #include <asm/iseries/hv_call_sc.h> |
Kelly Daly | 1ec65d7 | 2005-11-02 13:46:07 +1100 | [diff] [blame] | 25 | #include <asm/iseries/hv_types.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 26 | #include <asm/abs_addr.h> |
| 27 | |
| 28 | struct HvLpEvent; |
| 29 | |
| 30 | typedef u8 HvLpEvent_Type; |
| 31 | typedef u8 HvLpEvent_AckInd; |
| 32 | typedef u8 HvLpEvent_AckType; |
| 33 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 34 | typedef u8 HvLpDma_Direction; |
| 35 | typedef u8 HvLpDma_AddressType; |
| 36 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 37 | typedef u64 HvLpEvent_Rc; |
| 38 | typedef u64 HvLpDma_Rc; |
| 39 | |
| 40 | #define HvCallEventAckLpEvent HvCallEvent + 0 |
| 41 | #define HvCallEventCancelLpEvent HvCallEvent + 1 |
| 42 | #define HvCallEventCloseLpEventPath HvCallEvent + 2 |
| 43 | #define HvCallEventDmaBufList HvCallEvent + 3 |
| 44 | #define HvCallEventDmaSingle HvCallEvent + 4 |
Stephen Rothwell | 45dc76a | 2005-06-21 17:15:33 -0700 | [diff] [blame] | 45 | #define HvCallEventDmaToSp HvCallEvent + 5 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 46 | #define HvCallEventGetOverflowLpEvents HvCallEvent + 6 |
| 47 | #define HvCallEventGetSourceLpInstanceId HvCallEvent + 7 |
| 48 | #define HvCallEventGetTargetLpInstanceId HvCallEvent + 8 |
| 49 | #define HvCallEventOpenLpEventPath HvCallEvent + 9 |
| 50 | #define HvCallEventSetLpEventStack HvCallEvent + 10 |
| 51 | #define HvCallEventSignalLpEvent HvCallEvent + 11 |
| 52 | #define HvCallEventSignalLpEventParms HvCallEvent + 12 |
| 53 | #define HvCallEventSetInterLpQueueIndex HvCallEvent + 13 |
| 54 | #define HvCallEventSetLpEventQueueInterruptProc HvCallEvent + 14 |
| 55 | #define HvCallEventRouter15 HvCallEvent + 15 |
| 56 | |
| 57 | static inline void HvCallEvent_getOverflowLpEvents(u8 queueIndex) |
| 58 | { |
Stephen Rothwell | 45dc76a | 2005-06-21 17:15:33 -0700 | [diff] [blame] | 59 | HvCall1(HvCallEventGetOverflowLpEvents, queueIndex); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 60 | } |
| 61 | |
| 62 | static inline void HvCallEvent_setInterLpQueueIndex(u8 queueIndex) |
| 63 | { |
Stephen Rothwell | 45dc76a | 2005-06-21 17:15:33 -0700 | [diff] [blame] | 64 | HvCall1(HvCallEventSetInterLpQueueIndex, queueIndex); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 65 | } |
| 66 | |
| 67 | static inline void HvCallEvent_setLpEventStack(u8 queueIndex, |
| 68 | char *eventStackAddr, u32 eventStackSize) |
| 69 | { |
Stephen Rothwell | 6814350 | 2006-01-12 13:48:52 +1100 | [diff] [blame] | 70 | HvCall3(HvCallEventSetLpEventStack, queueIndex, |
| 71 | virt_to_abs(eventStackAddr), eventStackSize); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 72 | } |
| 73 | |
| 74 | static inline void HvCallEvent_setLpEventQueueInterruptProc(u8 queueIndex, |
| 75 | u16 lpLogicalProcIndex) |
| 76 | { |
| 77 | HvCall2(HvCallEventSetLpEventQueueInterruptProc, queueIndex, |
| 78 | lpLogicalProcIndex); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 79 | } |
| 80 | |
| 81 | static inline HvLpEvent_Rc HvCallEvent_signalLpEvent(struct HvLpEvent *event) |
| 82 | { |
Stephen Rothwell | 6814350 | 2006-01-12 13:48:52 +1100 | [diff] [blame] | 83 | return HvCall1(HvCallEventSignalLpEvent, virt_to_abs(event)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 84 | } |
| 85 | |
| 86 | static inline HvLpEvent_Rc HvCallEvent_signalLpEventFast(HvLpIndex targetLp, |
| 87 | HvLpEvent_Type type, u16 subtype, HvLpEvent_AckInd ackInd, |
| 88 | HvLpEvent_AckType ackType, HvLpInstanceId sourceInstanceId, |
| 89 | HvLpInstanceId targetInstanceId, u64 correlationToken, |
| 90 | u64 eventData1, u64 eventData2, u64 eventData3, |
| 91 | u64 eventData4, u64 eventData5) |
| 92 | { |
Stephen Rothwell | 45dc76a | 2005-06-21 17:15:33 -0700 | [diff] [blame] | 93 | /* Pack the misc bits into a single Dword to pass to PLIC */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 94 | union { |
Stephen Rothwell | 6814350 | 2006-01-12 13:48:52 +1100 | [diff] [blame] | 95 | struct { |
| 96 | u8 ack_and_target; |
| 97 | u8 type; |
| 98 | u16 subtype; |
| 99 | HvLpInstanceId src_inst; |
| 100 | HvLpInstanceId target_inst; |
| 101 | } parms; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 102 | u64 dword; |
| 103 | } packed; |
Stephen Rothwell | 6814350 | 2006-01-12 13:48:52 +1100 | [diff] [blame] | 104 | |
| 105 | packed.parms.ack_and_target = (ackType << 7) | (ackInd << 6) | targetLp; |
| 106 | packed.parms.type = type; |
| 107 | packed.parms.subtype = subtype; |
| 108 | packed.parms.src_inst = sourceInstanceId; |
| 109 | packed.parms.target_inst = targetInstanceId; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 110 | |
Stephen Rothwell | 6b7feec | 2005-06-21 17:15:35 -0700 | [diff] [blame] | 111 | return HvCall7(HvCallEventSignalLpEventParms, packed.dword, |
| 112 | correlationToken, eventData1, eventData2, |
| 113 | eventData3, eventData4, eventData5); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 114 | } |
| 115 | |
| 116 | static inline HvLpEvent_Rc HvCallEvent_ackLpEvent(struct HvLpEvent *event) |
| 117 | { |
Stephen Rothwell | 6814350 | 2006-01-12 13:48:52 +1100 | [diff] [blame] | 118 | return HvCall1(HvCallEventAckLpEvent, virt_to_abs(event)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 119 | } |
| 120 | |
| 121 | static inline HvLpEvent_Rc HvCallEvent_cancelLpEvent(struct HvLpEvent *event) |
| 122 | { |
Stephen Rothwell | 6814350 | 2006-01-12 13:48:52 +1100 | [diff] [blame] | 123 | return HvCall1(HvCallEventCancelLpEvent, virt_to_abs(event)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 124 | } |
| 125 | |
| 126 | static inline HvLpInstanceId HvCallEvent_getSourceLpInstanceId( |
| 127 | HvLpIndex targetLp, HvLpEvent_Type type) |
| 128 | { |
Stephen Rothwell | 6b7feec | 2005-06-21 17:15:35 -0700 | [diff] [blame] | 129 | return HvCall2(HvCallEventGetSourceLpInstanceId, targetLp, type); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 130 | } |
| 131 | |
| 132 | static inline HvLpInstanceId HvCallEvent_getTargetLpInstanceId( |
| 133 | HvLpIndex targetLp, HvLpEvent_Type type) |
| 134 | { |
Stephen Rothwell | 6b7feec | 2005-06-21 17:15:35 -0700 | [diff] [blame] | 135 | return HvCall2(HvCallEventGetTargetLpInstanceId, targetLp, type); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 136 | } |
| 137 | |
| 138 | static inline void HvCallEvent_openLpEventPath(HvLpIndex targetLp, |
| 139 | HvLpEvent_Type type) |
| 140 | { |
| 141 | HvCall2(HvCallEventOpenLpEventPath, targetLp, type); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 142 | } |
| 143 | |
| 144 | static inline void HvCallEvent_closeLpEventPath(HvLpIndex targetLp, |
| 145 | HvLpEvent_Type type) |
| 146 | { |
| 147 | HvCall2(HvCallEventCloseLpEventPath, targetLp, type); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 148 | } |
| 149 | |
| 150 | static inline HvLpDma_Rc HvCallEvent_dmaBufList(HvLpEvent_Type type, |
| 151 | HvLpIndex remoteLp, HvLpDma_Direction direction, |
| 152 | HvLpInstanceId localInstanceId, |
| 153 | HvLpInstanceId remoteInstanceId, |
| 154 | HvLpDma_AddressType localAddressType, |
| 155 | HvLpDma_AddressType remoteAddressType, |
| 156 | /* Do these need to be converted to absolute addresses? */ |
| 157 | u64 localBufList, u64 remoteBufList, u32 transferLength) |
| 158 | { |
Stephen Rothwell | 45dc76a | 2005-06-21 17:15:33 -0700 | [diff] [blame] | 159 | /* Pack the misc bits into a single Dword to pass to PLIC */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 160 | union { |
Stephen Rothwell | 6814350 | 2006-01-12 13:48:52 +1100 | [diff] [blame] | 161 | struct { |
| 162 | u8 flags; |
| 163 | HvLpIndex remote; |
| 164 | u8 type; |
| 165 | u8 reserved; |
| 166 | HvLpInstanceId local_inst; |
| 167 | HvLpInstanceId remote_inst; |
| 168 | } parms; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 169 | u64 dword; |
| 170 | } packed; |
| 171 | |
Stephen Rothwell | 6814350 | 2006-01-12 13:48:52 +1100 | [diff] [blame] | 172 | packed.parms.flags = (direction << 7) | |
| 173 | (localAddressType << 6) | (remoteAddressType << 5); |
| 174 | packed.parms.remote = remoteLp; |
| 175 | packed.parms.type = type; |
| 176 | packed.parms.reserved = 0; |
| 177 | packed.parms.local_inst = localInstanceId; |
| 178 | packed.parms.remote_inst = remoteInstanceId; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 179 | |
Stephen Rothwell | 6b7feec | 2005-06-21 17:15:35 -0700 | [diff] [blame] | 180 | return HvCall4(HvCallEventDmaBufList, packed.dword, localBufList, |
| 181 | remoteBufList, transferLength); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 182 | } |
| 183 | |
Stephen Rothwell | 45dc76a | 2005-06-21 17:15:33 -0700 | [diff] [blame] | 184 | static inline HvLpDma_Rc HvCallEvent_dmaToSp(void *local, u32 remote, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 185 | u32 length, HvLpDma_Direction dir) |
| 186 | { |
Stephen Rothwell | 6814350 | 2006-01-12 13:48:52 +1100 | [diff] [blame] | 187 | return HvCall4(HvCallEventDmaToSp, virt_to_abs(local), remote, |
| 188 | length, dir); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 189 | } |
| 190 | |
Kelly Daly | ecb3ca2 | 2005-11-02 15:53:01 +1100 | [diff] [blame] | 191 | #endif /* _ASM_POWERPC_ISERIES_HV_CALL_EVENT_H */ |