blob: c2770b056ae89be905433e1e02597c7fb52be51b [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
2 * HvCallEvent.h
3 * Copyright (C) 2001 Mike Corrigan IBM Corporation
Stephen Rothwell45dc76a2005-06-21 17:15:33 -07004 *
Linus Torvalds1da177e2005-04-16 15:20:36 -07005 * 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 Rothwell45dc76a2005-06-21 17:15:33 -07009 *
Linus Torvalds1da177e2005-04-16 15:20:36 -070010 * 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 Rothwell45dc76a2005-06-21 17:15:33 -070014 *
Linus Torvalds1da177e2005-04-16 15:20:36 -070015 * 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 Torvalds1da177e2005-04-16 15:20:36 -070019/*
Stephen Rothwell45dc76a2005-06-21 17:15:33 -070020 * This file contains the "hypervisor call" interface which is used to
21 * drive the hypervisor from the OS.
Linus Torvalds1da177e2005-04-16 15:20:36 -070022 */
23#ifndef _HVCALLEVENT_H
24#define _HVCALLEVENT_H
25
Kelly Daly50592f52005-11-02 11:37:22 +110026#include <asm/iseries/hv_call_sc.h>
Kelly Daly1ec65d72005-11-02 13:46:07 +110027#include <asm/iseries/hv_types.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070028#include <asm/abs_addr.h>
29
30struct HvLpEvent;
31
32typedef u8 HvLpEvent_Type;
33typedef u8 HvLpEvent_AckInd;
34typedef u8 HvLpEvent_AckType;
35
36struct 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
47typedef u8 HvLpDma_Direction;
48typedef u8 HvLpDma_AddressType;
49
50struct 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
62typedef u64 HvLpEvent_Rc;
63typedef 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 Rothwell45dc76a2005-06-21 17:15:33 -070070#define HvCallEventDmaToSp HvCallEvent + 5
Linus Torvalds1da177e2005-04-16 15:20:36 -070071#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
82static inline void HvCallEvent_getOverflowLpEvents(u8 queueIndex)
83{
Stephen Rothwell45dc76a2005-06-21 17:15:33 -070084 HvCall1(HvCallEventGetOverflowLpEvents, queueIndex);
Linus Torvalds1da177e2005-04-16 15:20:36 -070085}
86
87static inline void HvCallEvent_setInterLpQueueIndex(u8 queueIndex)
88{
Stephen Rothwell45dc76a2005-06-21 17:15:33 -070089 HvCall1(HvCallEventSetInterLpQueueIndex, queueIndex);
Linus Torvalds1da177e2005-04-16 15:20:36 -070090}
91
92static 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 Torvalds1da177e2005-04-16 15:20:36 -0700100}
101
102static inline void HvCallEvent_setLpEventQueueInterruptProc(u8 queueIndex,
103 u16 lpLogicalProcIndex)
104{
105 HvCall2(HvCallEventSetLpEventQueueInterruptProc, queueIndex,
106 lpLogicalProcIndex);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700107}
108
109static inline HvLpEvent_Rc HvCallEvent_signalLpEvent(struct HvLpEvent *event)
110{
111 u64 abs_addr;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700112
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 Rothwell6b7feec2005-06-21 17:15:35 -0700118 return HvCall1(HvCallEventSignalLpEvent, abs_addr);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700119}
120
121static 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 Rothwell45dc76a2005-06-21 17:15:33 -0700128 /* Pack the misc bits into a single Dword to pass to PLIC */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700129 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 Rothwell6b7feec2005-06-21 17:15:35 -0700142 return HvCall7(HvCallEventSignalLpEventParms, packed.dword,
143 correlationToken, eventData1, eventData2,
144 eventData3, eventData4, eventData5);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700145}
146
147static inline HvLpEvent_Rc HvCallEvent_ackLpEvent(struct HvLpEvent *event)
148{
149 u64 abs_addr;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700150
151 abs_addr = virt_to_abs(event);
Stephen Rothwell6b7feec2005-06-21 17:15:35 -0700152 return HvCall1(HvCallEventAckLpEvent, abs_addr);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700153}
154
155static inline HvLpEvent_Rc HvCallEvent_cancelLpEvent(struct HvLpEvent *event)
156{
157 u64 abs_addr;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700158
159 abs_addr = virt_to_abs(event);
Stephen Rothwell6b7feec2005-06-21 17:15:35 -0700160 return HvCall1(HvCallEventCancelLpEvent, abs_addr);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700161}
162
163static inline HvLpInstanceId HvCallEvent_getSourceLpInstanceId(
164 HvLpIndex targetLp, HvLpEvent_Type type)
165{
Stephen Rothwell6b7feec2005-06-21 17:15:35 -0700166 return HvCall2(HvCallEventGetSourceLpInstanceId, targetLp, type);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700167}
168
169static inline HvLpInstanceId HvCallEvent_getTargetLpInstanceId(
170 HvLpIndex targetLp, HvLpEvent_Type type)
171{
Stephen Rothwell6b7feec2005-06-21 17:15:35 -0700172 return HvCall2(HvCallEventGetTargetLpInstanceId, targetLp, type);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700173}
174
175static inline void HvCallEvent_openLpEventPath(HvLpIndex targetLp,
176 HvLpEvent_Type type)
177{
178 HvCall2(HvCallEventOpenLpEventPath, targetLp, type);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700179}
180
181static inline void HvCallEvent_closeLpEventPath(HvLpIndex targetLp,
182 HvLpEvent_Type type)
183{
184 HvCall2(HvCallEventCloseLpEventPath, targetLp, type);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700185}
186
187static 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 Rothwell45dc76a2005-06-21 17:15:33 -0700196 /* Pack the misc bits into a single Dword to pass to PLIC */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700197 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 Rothwell6b7feec2005-06-21 17:15:35 -0700212 return HvCall4(HvCallEventDmaBufList, packed.dword, localBufList,
213 remoteBufList, transferLength);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700214}
215
216static 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 Rothwell45dc76a2005-06-21 17:15:33 -0700224 /* Pack the misc bits into a single Dword to pass to PLIC */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700225 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 Rothwell6b7feec2005-06-21 17:15:35 -0700240 return (HvLpDma_Rc)HvCall4(HvCallEventDmaSingle, packed.dword,
241 localAddrOrTce, remoteAddrOrTce, transferLength);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700242}
243
Stephen Rothwell45dc76a2005-06-21 17:15:33 -0700244static inline HvLpDma_Rc HvCallEvent_dmaToSp(void *local, u32 remote,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700245 u32 length, HvLpDma_Direction dir)
246{
247 u64 abs_addr;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700248
249 abs_addr = virt_to_abs(local);
Stephen Rothwell6b7feec2005-06-21 17:15:35 -0700250 return HvCall4(HvCallEventDmaToSp, abs_addr, remote, length, dir);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700251}
252
Linus Torvalds1da177e2005-04-16 15:20:36 -0700253#endif /* _HVCALLEVENT_H */