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