2 * Copyright (C) 2001 Mike Corrigan IBM Corporation
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.
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.
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
18 * This file contains the "hypervisor call" interface which is used to
19 * drive the hypervisor from the OS.
21 #ifndef _ASM_POWERPC_ISERIES_HV_CALL_EVENT_H
22 #define _ASM_POWERPC_ISERIES_HV_CALL_EVENT_H
24 #include <linux/types.h>
25 #include <linux/dma-mapping.h>
27 #include <asm/iseries/hv_call_sc.h>
28 #include <asm/iseries/hv_types.h>
29 #include <asm/abs_addr.h>
33 typedef u8 HvLpEvent_Type;
34 typedef u8 HvLpEvent_AckInd;
35 typedef u8 HvLpEvent_AckType;
37 typedef u8 HvLpDma_Direction;
38 typedef u8 HvLpDma_AddressType;
40 typedef u64 HvLpEvent_Rc;
41 typedef u64 HvLpDma_Rc;
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
48 #define HvCallEventDmaToSp HvCallEvent + 5
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
60 static inline void HvCallEvent_getOverflowLpEvents(u8 queueIndex)
62 HvCall1(HvCallEventGetOverflowLpEvents, queueIndex);
65 static inline void HvCallEvent_setInterLpQueueIndex(u8 queueIndex)
67 HvCall1(HvCallEventSetInterLpQueueIndex, queueIndex);
70 static inline void HvCallEvent_setLpEventStack(u8 queueIndex,
71 char *eventStackAddr, u32 eventStackSize)
73 HvCall3(HvCallEventSetLpEventStack, queueIndex,
74 virt_to_abs(eventStackAddr), eventStackSize);
77 static inline void HvCallEvent_setLpEventQueueInterruptProc(u8 queueIndex,
78 u16 lpLogicalProcIndex)
80 HvCall2(HvCallEventSetLpEventQueueInterruptProc, queueIndex,
84 static inline HvLpEvent_Rc HvCallEvent_signalLpEvent(struct HvLpEvent *event)
86 return HvCall1(HvCallEventSignalLpEvent, virt_to_abs(event));
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)
96 /* Pack the misc bits into a single Dword to pass to PLIC */
102 HvLpInstanceId src_inst;
103 HvLpInstanceId target_inst;
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;
114 return HvCall7(HvCallEventSignalLpEventParms, packed.dword,
115 correlationToken, eventData1, eventData2,
116 eventData3, eventData4, eventData5);
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);
126 static inline HvLpEvent_Rc HvCallEvent_ackLpEvent(struct HvLpEvent *event)
128 return HvCall1(HvCallEventAckLpEvent, virt_to_abs(event));
131 static inline HvLpEvent_Rc HvCallEvent_cancelLpEvent(struct HvLpEvent *event)
133 return HvCall1(HvCallEventCancelLpEvent, virt_to_abs(event));
136 static inline HvLpInstanceId HvCallEvent_getSourceLpInstanceId(
137 HvLpIndex targetLp, HvLpEvent_Type type)
139 return HvCall2(HvCallEventGetSourceLpInstanceId, targetLp, type);
142 static inline HvLpInstanceId HvCallEvent_getTargetLpInstanceId(
143 HvLpIndex targetLp, HvLpEvent_Type type)
145 return HvCall2(HvCallEventGetTargetLpInstanceId, targetLp, type);
148 static inline void HvCallEvent_openLpEventPath(HvLpIndex targetLp,
151 HvCall2(HvCallEventOpenLpEventPath, targetLp, type);
154 static inline void HvCallEvent_closeLpEventPath(HvLpIndex targetLp,
157 HvCall2(HvCallEventCloseLpEventPath, targetLp, type);
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)
169 /* Pack the misc bits into a single Dword to pass to PLIC */
176 HvLpInstanceId local_inst;
177 HvLpInstanceId remote_inst;
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;
190 return HvCall4(HvCallEventDmaBufList, packed.dword, localBufList,
191 remoteBufList, transferLength);
194 static inline HvLpDma_Rc HvCallEvent_dmaToSp(void *local, u32 remote,
195 u32 length, HvLpDma_Direction dir)
197 return HvCall4(HvCallEventDmaToSp, virt_to_abs(local), remote,
201 #endif /* _ASM_POWERPC_ISERIES_HV_CALL_EVENT_H */