hv_call_event.h 7.5 KB
Newer Older
L
Linus Torvalds 已提交
1 2 3
/*
 * HvCallEvent.h
 * Copyright (C) 2001  Mike Corrigan IBM Corporation
4
 *
L
Linus Torvalds 已提交
5 6 7 8
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
9
 *
L
Linus Torvalds 已提交
10 11 12 13
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
14
 *
L
Linus Torvalds 已提交
15 16 17 18 19
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
 */
/*
20 21
 * This file contains the "hypervisor call" interface which is used to
 * drive the hypervisor from the OS.
L
Linus Torvalds 已提交
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69
 */
#ifndef _HVCALLEVENT_H
#define _HVCALLEVENT_H

#include <asm/iSeries/HvCallSc.h>
#include <asm/iSeries/HvTypes.h>
#include <asm/abs_addr.h>

struct HvLpEvent;

typedef u8 HvLpEvent_Type;
typedef u8 HvLpEvent_AckInd;
typedef u8 HvLpEvent_AckType;

struct	HvCallEvent_PackedParms {
	u8		xAckType:1;
	u8		xAckInd:1;
	u8		xRsvd:1;
	u8		xTargetLp:5;
	u8		xType;
	u16		xSubtype;
	HvLpInstanceId	xSourceInstId;
	HvLpInstanceId	xTargetInstId;
};

typedef u8 HvLpDma_Direction;
typedef u8 HvLpDma_AddressType;

struct	HvCallEvent_PackedDmaParms {
	u8		xDirection:1;
	u8		xLocalAddrType:1;
	u8		xRemoteAddrType:1;
	u8		xRsvd1:5;
	HvLpIndex	xRemoteLp;
	u8		xType;
	u8		xRsvd2;
	HvLpInstanceId	xLocalInstId;
	HvLpInstanceId	xRemoteInstId;
};

typedef u64 HvLpEvent_Rc;
typedef u64 HvLpDma_Rc;

#define HvCallEventAckLpEvent				HvCallEvent +  0
#define HvCallEventCancelLpEvent			HvCallEvent +  1
#define HvCallEventCloseLpEventPath			HvCallEvent +  2
#define HvCallEventDmaBufList				HvCallEvent +  3
#define HvCallEventDmaSingle				HvCallEvent +  4
70
#define HvCallEventDmaToSp				HvCallEvent +  5
L
Linus Torvalds 已提交
71 72 73 74 75 76 77 78 79 80 81 82 83
#define HvCallEventGetOverflowLpEvents			HvCallEvent +  6
#define HvCallEventGetSourceLpInstanceId		HvCallEvent +  7
#define HvCallEventGetTargetLpInstanceId		HvCallEvent +  8
#define HvCallEventOpenLpEventPath			HvCallEvent +  9
#define HvCallEventSetLpEventStack			HvCallEvent + 10
#define HvCallEventSignalLpEvent			HvCallEvent + 11
#define HvCallEventSignalLpEventParms			HvCallEvent + 12
#define HvCallEventSetInterLpQueueIndex			HvCallEvent + 13
#define HvCallEventSetLpEventQueueInterruptProc		HvCallEvent + 14
#define HvCallEventRouter15				HvCallEvent + 15

static inline void HvCallEvent_getOverflowLpEvents(u8 queueIndex)
{
84
	HvCall1(HvCallEventGetOverflowLpEvents, queueIndex);
L
Linus Torvalds 已提交
85 86 87 88
}

static inline void HvCallEvent_setInterLpQueueIndex(u8 queueIndex)
{
89
	HvCall1(HvCallEventSetInterLpQueueIndex, queueIndex);
L
Linus Torvalds 已提交
90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117
}

static inline void HvCallEvent_setLpEventStack(u8 queueIndex,
		char *eventStackAddr, u32 eventStackSize)
{
	u64 abs_addr;

	abs_addr = virt_to_abs(eventStackAddr);
	HvCall3(HvCallEventSetLpEventStack, queueIndex, abs_addr,
			eventStackSize);
}

static inline void HvCallEvent_setLpEventQueueInterruptProc(u8 queueIndex,
		u16 lpLogicalProcIndex)
{
	HvCall2(HvCallEventSetLpEventQueueInterruptProc, queueIndex,
			lpLogicalProcIndex);
}

static inline HvLpEvent_Rc HvCallEvent_signalLpEvent(struct HvLpEvent *event)
{
	u64 abs_addr;

#ifdef DEBUG_SENDEVENT
	printk("HvCallEvent_signalLpEvent: *event = %016lx\n ",
			(unsigned long)event);
#endif
	abs_addr = virt_to_abs(event);
118
	return HvCall1(HvCallEventSignalLpEvent, abs_addr);
L
Linus Torvalds 已提交
119 120 121 122 123 124 125 126 127
}

static inline HvLpEvent_Rc HvCallEvent_signalLpEventFast(HvLpIndex targetLp,
		HvLpEvent_Type type, u16 subtype, HvLpEvent_AckInd ackInd,
		HvLpEvent_AckType ackType, HvLpInstanceId sourceInstanceId,
		HvLpInstanceId targetInstanceId, u64 correlationToken,
		u64 eventData1, u64 eventData2, u64 eventData3,
		u64 eventData4, u64 eventData5)
{
128
	/* Pack the misc bits into a single Dword to pass to PLIC */
L
Linus Torvalds 已提交
129 130 131 132 133 134 135 136 137 138 139 140 141
	union {
		struct HvCallEvent_PackedParms	parms;
		u64		dword;
	} packed;
	packed.parms.xAckType	= ackType;
	packed.parms.xAckInd	= ackInd;
	packed.parms.xRsvd	= 0;
	packed.parms.xTargetLp	= targetLp;
	packed.parms.xType	= type;
	packed.parms.xSubtype	= subtype;
	packed.parms.xSourceInstId	= sourceInstanceId;
	packed.parms.xTargetInstId	= targetInstanceId;

142 143 144
	return HvCall7(HvCallEventSignalLpEventParms, packed.dword,
			correlationToken, eventData1, eventData2,
			eventData3, eventData4, eventData5);
L
Linus Torvalds 已提交
145 146 147 148 149 150 151
}

static inline HvLpEvent_Rc HvCallEvent_ackLpEvent(struct HvLpEvent *event)
{
	u64 abs_addr;

	abs_addr = virt_to_abs(event);
152
	return HvCall1(HvCallEventAckLpEvent, abs_addr);
L
Linus Torvalds 已提交
153 154 155 156 157 158 159
}

static inline HvLpEvent_Rc HvCallEvent_cancelLpEvent(struct HvLpEvent *event)
{
	u64 abs_addr;

	abs_addr = virt_to_abs(event);
160
	return HvCall1(HvCallEventCancelLpEvent, abs_addr);
L
Linus Torvalds 已提交
161 162 163 164 165
}

static inline HvLpInstanceId HvCallEvent_getSourceLpInstanceId(
		HvLpIndex targetLp, HvLpEvent_Type type)
{
166
	return HvCall2(HvCallEventGetSourceLpInstanceId, targetLp, type);
L
Linus Torvalds 已提交
167 168 169 170 171
}

static inline HvLpInstanceId HvCallEvent_getTargetLpInstanceId(
		HvLpIndex targetLp, HvLpEvent_Type type)
{
172
	return HvCall2(HvCallEventGetTargetLpInstanceId, targetLp, type);
L
Linus Torvalds 已提交
173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195
}

static inline void HvCallEvent_openLpEventPath(HvLpIndex targetLp,
		HvLpEvent_Type type)
{
	HvCall2(HvCallEventOpenLpEventPath, targetLp, type);
}

static inline void HvCallEvent_closeLpEventPath(HvLpIndex targetLp,
		HvLpEvent_Type type)
{
	HvCall2(HvCallEventCloseLpEventPath, targetLp, type);
}

static inline HvLpDma_Rc HvCallEvent_dmaBufList(HvLpEvent_Type type,
		HvLpIndex remoteLp, HvLpDma_Direction direction,
		HvLpInstanceId localInstanceId,
		HvLpInstanceId remoteInstanceId,
		HvLpDma_AddressType localAddressType,
		HvLpDma_AddressType remoteAddressType,
		/* Do these need to be converted to absolute addresses? */
		u64 localBufList, u64 remoteBufList, u32 transferLength)
{
196
	/* Pack the misc bits into a single Dword to pass to PLIC */
L
Linus Torvalds 已提交
197 198 199 200 201 202 203 204 205 206 207 208 209 210 211
	union {
		struct HvCallEvent_PackedDmaParms	parms;
		u64		dword;
	} packed;

	packed.parms.xDirection		= direction;
	packed.parms.xLocalAddrType	= localAddressType;
	packed.parms.xRemoteAddrType	= remoteAddressType;
	packed.parms.xRsvd1		= 0;
	packed.parms.xRemoteLp		= remoteLp;
	packed.parms.xType		= type;
	packed.parms.xRsvd2		= 0;
	packed.parms.xLocalInstId	= localInstanceId;
	packed.parms.xRemoteInstId	= remoteInstanceId;

212 213
	return HvCall4(HvCallEventDmaBufList, packed.dword, localBufList,
			remoteBufList, transferLength);
L
Linus Torvalds 已提交
214 215 216 217 218 219 220 221 222 223
}

static inline HvLpDma_Rc HvCallEvent_dmaSingle(HvLpEvent_Type type,
		HvLpIndex remoteLp, HvLpDma_Direction direction,
		HvLpInstanceId localInstanceId,
		HvLpInstanceId remoteInstanceId,
		HvLpDma_AddressType localAddressType,
		HvLpDma_AddressType remoteAddressType,
		u64 localAddrOrTce, u64 remoteAddrOrTce, u32 transferLength)
{
224
	/* Pack the misc bits into a single Dword to pass to PLIC */
L
Linus Torvalds 已提交
225 226 227 228 229 230 231 232 233 234 235 236 237 238 239
	union {
		struct HvCallEvent_PackedDmaParms	parms;
		u64		dword;
	} packed;

	packed.parms.xDirection		= direction;
	packed.parms.xLocalAddrType	= localAddressType;
	packed.parms.xRemoteAddrType	= remoteAddressType;
	packed.parms.xRsvd1		= 0;
	packed.parms.xRemoteLp		= remoteLp;
	packed.parms.xType		= type;
	packed.parms.xRsvd2		= 0;
	packed.parms.xLocalInstId	= localInstanceId;
	packed.parms.xRemoteInstId	= remoteInstanceId;

240 241
	return (HvLpDma_Rc)HvCall4(HvCallEventDmaSingle, packed.dword,
			localAddrOrTce, remoteAddrOrTce, transferLength);
L
Linus Torvalds 已提交
242 243
}

244
static inline HvLpDma_Rc HvCallEvent_dmaToSp(void *local, u32 remote,
L
Linus Torvalds 已提交
245 246 247 248 249
		u32 length, HvLpDma_Direction dir)
{
	u64 abs_addr;

	abs_addr = virt_to_abs(local);
250
	return HvCall4(HvCallEventDmaToSp, abs_addr, remote, length, dir);
L
Linus Torvalds 已提交
251 252 253
}

#endif /* _HVCALLEVENT_H */