[PATCH] mm: page fault handlers tidyup
[linux-2.6] / include / asm-ppc64 / iSeries / HvCallEvent.h
1 /*
2  * HvCallEvent.h
3  * Copyright (C) 2001  Mike Corrigan IBM Corporation
4  *
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.
9  *
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.
14  *
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  */
19 /*
20  * This file contains the "hypervisor call" interface which is used to
21  * drive the hypervisor from the OS.
22  */
23 #ifndef _HVCALLEVENT_H
24 #define _HVCALLEVENT_H
25
26 #include <asm/iSeries/HvCallSc.h>
27 #include <asm/iSeries/HvTypes.h>
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
70 #define HvCallEventDmaToSp                              HvCallEvent +  5
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 {
84         HvCall1(HvCallEventGetOverflowLpEvents, queueIndex);
85 }
86
87 static inline void HvCallEvent_setInterLpQueueIndex(u8 queueIndex)
88 {
89         HvCall1(HvCallEventSetInterLpQueueIndex, queueIndex);
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);
100 }
101
102 static inline void HvCallEvent_setLpEventQueueInterruptProc(u8 queueIndex,
103                 u16 lpLogicalProcIndex)
104 {
105         HvCall2(HvCallEventSetLpEventQueueInterruptProc, queueIndex,
106                         lpLogicalProcIndex);
107 }
108
109 static inline HvLpEvent_Rc HvCallEvent_signalLpEvent(struct HvLpEvent *event)
110 {
111         u64 abs_addr;
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);
118         return HvCall1(HvCallEventSignalLpEvent, abs_addr);
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 {
128         /* Pack the misc bits into a single Dword to pass to PLIC */
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
142         return HvCall7(HvCallEventSignalLpEventParms, packed.dword,
143                         correlationToken, eventData1, eventData2,
144                         eventData3, eventData4, eventData5);
145 }
146
147 static inline HvLpEvent_Rc HvCallEvent_ackLpEvent(struct HvLpEvent *event)
148 {
149         u64 abs_addr;
150
151         abs_addr = virt_to_abs(event);
152         return HvCall1(HvCallEventAckLpEvent, abs_addr);
153 }
154
155 static inline HvLpEvent_Rc HvCallEvent_cancelLpEvent(struct HvLpEvent *event)
156 {
157         u64 abs_addr;
158
159         abs_addr = virt_to_abs(event);
160         return HvCall1(HvCallEventCancelLpEvent, abs_addr);
161 }
162
163 static inline HvLpInstanceId HvCallEvent_getSourceLpInstanceId(
164                 HvLpIndex targetLp, HvLpEvent_Type type)
165 {
166         return HvCall2(HvCallEventGetSourceLpInstanceId, targetLp, type);
167 }
168
169 static inline HvLpInstanceId HvCallEvent_getTargetLpInstanceId(
170                 HvLpIndex targetLp, HvLpEvent_Type type)
171 {
172         return HvCall2(HvCallEventGetTargetLpInstanceId, targetLp, type);
173 }
174
175 static inline void HvCallEvent_openLpEventPath(HvLpIndex targetLp,
176                 HvLpEvent_Type type)
177 {
178         HvCall2(HvCallEventOpenLpEventPath, targetLp, type);
179 }
180
181 static inline void HvCallEvent_closeLpEventPath(HvLpIndex targetLp,
182                 HvLpEvent_Type type)
183 {
184         HvCall2(HvCallEventCloseLpEventPath, targetLp, type);
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 {
196         /* Pack the misc bits into a single Dword to pass to PLIC */
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
212         return HvCall4(HvCallEventDmaBufList, packed.dword, localBufList,
213                         remoteBufList, transferLength);
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 {
224         /* Pack the misc bits into a single Dword to pass to PLIC */
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
240         return (HvLpDma_Rc)HvCall4(HvCallEventDmaSingle, packed.dword,
241                         localAddrOrTce, remoteAddrOrTce, transferLength);
242 }
243
244 static inline HvLpDma_Rc HvCallEvent_dmaToSp(void *local, u32 remote,
245                 u32 length, HvLpDma_Direction dir)
246 {
247         u64 abs_addr;
248
249         abs_addr = virt_to_abs(local);
250         return HvCall4(HvCallEventDmaToSp, abs_addr, remote, length, dir);
251 }
252
253 #endif /* _HVCALLEVENT_H */