blob: 4cec4762076dffa99ce78ddc86401f2721af0ede [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
Linus Torvalds1da177e2005-04-16 15:20:36 -07002 * Copyright (C) 2001 Mike Corrigan IBM Corporation
Stephen Rothwell45dc76a2005-06-21 17:15:33 -07003 *
Linus Torvalds1da177e2005-04-16 15:20:36 -07004 * 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 Rothwell45dc76a2005-06-21 17:15:33 -07008 *
Linus Torvalds1da177e2005-04-16 15:20:36 -07009 * 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 Rothwell45dc76a2005-06-21 17:15:33 -070013 *
Linus Torvalds1da177e2005-04-16 15:20:36 -070014 * 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 Rothwell68143502006-01-12 13:48:52 +110017 *
Stephen Rothwell45dc76a2005-06-21 17:15:33 -070018 * This file contains the "hypervisor call" interface which is used to
19 * drive the hypervisor from the OS.
Linus Torvalds1da177e2005-04-16 15:20:36 -070020 */
Kelly Dalyecb3ca272005-11-02 15:53:01 +110021#ifndef _ASM_POWERPC_ISERIES_HV_CALL_EVENT_H
22#define _ASM_POWERPC_ISERIES_HV_CALL_EVENT_H
Linus Torvalds1da177e2005-04-16 15:20:36 -070023
Kelly Daly50592f52005-11-02 11:37:22 +110024#include <asm/iseries/hv_call_sc.h>
Kelly Daly1ec65d72005-11-02 13:46:07 +110025#include <asm/iseries/hv_types.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070026#include <asm/abs_addr.h>
27
28struct HvLpEvent;
29
30typedef u8 HvLpEvent_Type;
31typedef u8 HvLpEvent_AckInd;
32typedef u8 HvLpEvent_AckType;
33
Linus Torvalds1da177e2005-04-16 15:20:36 -070034typedef u8 HvLpDma_Direction;
35typedef u8 HvLpDma_AddressType;
36
Linus Torvalds1da177e2005-04-16 15:20:36 -070037typedef u64 HvLpEvent_Rc;
38typedef u64 HvLpDma_Rc;
39
40#define HvCallEventAckLpEvent HvCallEvent + 0
41#define HvCallEventCancelLpEvent HvCallEvent + 1
42#define HvCallEventCloseLpEventPath HvCallEvent + 2
43#define HvCallEventDmaBufList HvCallEvent + 3
44#define HvCallEventDmaSingle HvCallEvent + 4
Stephen Rothwell45dc76a2005-06-21 17:15:33 -070045#define HvCallEventDmaToSp HvCallEvent + 5
Linus Torvalds1da177e2005-04-16 15:20:36 -070046#define HvCallEventGetOverflowLpEvents HvCallEvent + 6
47#define HvCallEventGetSourceLpInstanceId HvCallEvent + 7
48#define HvCallEventGetTargetLpInstanceId HvCallEvent + 8
49#define HvCallEventOpenLpEventPath HvCallEvent + 9
50#define HvCallEventSetLpEventStack HvCallEvent + 10
51#define HvCallEventSignalLpEvent HvCallEvent + 11
52#define HvCallEventSignalLpEventParms HvCallEvent + 12
53#define HvCallEventSetInterLpQueueIndex HvCallEvent + 13
54#define HvCallEventSetLpEventQueueInterruptProc HvCallEvent + 14
55#define HvCallEventRouter15 HvCallEvent + 15
56
57static inline void HvCallEvent_getOverflowLpEvents(u8 queueIndex)
58{
Stephen Rothwell45dc76a2005-06-21 17:15:33 -070059 HvCall1(HvCallEventGetOverflowLpEvents, queueIndex);
Linus Torvalds1da177e2005-04-16 15:20:36 -070060}
61
62static inline void HvCallEvent_setInterLpQueueIndex(u8 queueIndex)
63{
Stephen Rothwell45dc76a2005-06-21 17:15:33 -070064 HvCall1(HvCallEventSetInterLpQueueIndex, queueIndex);
Linus Torvalds1da177e2005-04-16 15:20:36 -070065}
66
67static inline void HvCallEvent_setLpEventStack(u8 queueIndex,
68 char *eventStackAddr, u32 eventStackSize)
69{
Stephen Rothwell68143502006-01-12 13:48:52 +110070 HvCall3(HvCallEventSetLpEventStack, queueIndex,
71 virt_to_abs(eventStackAddr), eventStackSize);
Linus Torvalds1da177e2005-04-16 15:20:36 -070072}
73
74static inline void HvCallEvent_setLpEventQueueInterruptProc(u8 queueIndex,
75 u16 lpLogicalProcIndex)
76{
77 HvCall2(HvCallEventSetLpEventQueueInterruptProc, queueIndex,
78 lpLogicalProcIndex);
Linus Torvalds1da177e2005-04-16 15:20:36 -070079}
80
81static inline HvLpEvent_Rc HvCallEvent_signalLpEvent(struct HvLpEvent *event)
82{
Stephen Rothwell68143502006-01-12 13:48:52 +110083 return HvCall1(HvCallEventSignalLpEvent, virt_to_abs(event));
Linus Torvalds1da177e2005-04-16 15:20:36 -070084}
85
86static inline HvLpEvent_Rc HvCallEvent_signalLpEventFast(HvLpIndex targetLp,
87 HvLpEvent_Type type, u16 subtype, HvLpEvent_AckInd ackInd,
88 HvLpEvent_AckType ackType, HvLpInstanceId sourceInstanceId,
89 HvLpInstanceId targetInstanceId, u64 correlationToken,
90 u64 eventData1, u64 eventData2, u64 eventData3,
91 u64 eventData4, u64 eventData5)
92{
Stephen Rothwell45dc76a2005-06-21 17:15:33 -070093 /* Pack the misc bits into a single Dword to pass to PLIC */
Linus Torvalds1da177e2005-04-16 15:20:36 -070094 union {
Stephen Rothwell68143502006-01-12 13:48:52 +110095 struct {
96 u8 ack_and_target;
97 u8 type;
98 u16 subtype;
99 HvLpInstanceId src_inst;
100 HvLpInstanceId target_inst;
101 } parms;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700102 u64 dword;
103 } packed;
Stephen Rothwell68143502006-01-12 13:48:52 +1100104
105 packed.parms.ack_and_target = (ackType << 7) | (ackInd << 6) | targetLp;
106 packed.parms.type = type;
107 packed.parms.subtype = subtype;
108 packed.parms.src_inst = sourceInstanceId;
109 packed.parms.target_inst = targetInstanceId;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700110
Stephen Rothwell6b7feec2005-06-21 17:15:35 -0700111 return HvCall7(HvCallEventSignalLpEventParms, packed.dword,
112 correlationToken, eventData1, eventData2,
113 eventData3, eventData4, eventData5);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700114}
115
116static inline HvLpEvent_Rc HvCallEvent_ackLpEvent(struct HvLpEvent *event)
117{
Stephen Rothwell68143502006-01-12 13:48:52 +1100118 return HvCall1(HvCallEventAckLpEvent, virt_to_abs(event));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700119}
120
121static inline HvLpEvent_Rc HvCallEvent_cancelLpEvent(struct HvLpEvent *event)
122{
Stephen Rothwell68143502006-01-12 13:48:52 +1100123 return HvCall1(HvCallEventCancelLpEvent, virt_to_abs(event));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700124}
125
126static inline HvLpInstanceId HvCallEvent_getSourceLpInstanceId(
127 HvLpIndex targetLp, HvLpEvent_Type type)
128{
Stephen Rothwell6b7feec2005-06-21 17:15:35 -0700129 return HvCall2(HvCallEventGetSourceLpInstanceId, targetLp, type);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700130}
131
132static inline HvLpInstanceId HvCallEvent_getTargetLpInstanceId(
133 HvLpIndex targetLp, HvLpEvent_Type type)
134{
Stephen Rothwell6b7feec2005-06-21 17:15:35 -0700135 return HvCall2(HvCallEventGetTargetLpInstanceId, targetLp, type);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700136}
137
138static inline void HvCallEvent_openLpEventPath(HvLpIndex targetLp,
139 HvLpEvent_Type type)
140{
141 HvCall2(HvCallEventOpenLpEventPath, targetLp, type);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700142}
143
144static inline void HvCallEvent_closeLpEventPath(HvLpIndex targetLp,
145 HvLpEvent_Type type)
146{
147 HvCall2(HvCallEventCloseLpEventPath, targetLp, type);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700148}
149
150static inline HvLpDma_Rc HvCallEvent_dmaBufList(HvLpEvent_Type type,
151 HvLpIndex remoteLp, HvLpDma_Direction direction,
152 HvLpInstanceId localInstanceId,
153 HvLpInstanceId remoteInstanceId,
154 HvLpDma_AddressType localAddressType,
155 HvLpDma_AddressType remoteAddressType,
156 /* Do these need to be converted to absolute addresses? */
157 u64 localBufList, u64 remoteBufList, u32 transferLength)
158{
Stephen Rothwell45dc76a2005-06-21 17:15:33 -0700159 /* Pack the misc bits into a single Dword to pass to PLIC */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700160 union {
Stephen Rothwell68143502006-01-12 13:48:52 +1100161 struct {
162 u8 flags;
163 HvLpIndex remote;
164 u8 type;
165 u8 reserved;
166 HvLpInstanceId local_inst;
167 HvLpInstanceId remote_inst;
168 } parms;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700169 u64 dword;
170 } packed;
171
Stephen Rothwell68143502006-01-12 13:48:52 +1100172 packed.parms.flags = (direction << 7) |
173 (localAddressType << 6) | (remoteAddressType << 5);
174 packed.parms.remote = remoteLp;
175 packed.parms.type = type;
176 packed.parms.reserved = 0;
177 packed.parms.local_inst = localInstanceId;
178 packed.parms.remote_inst = remoteInstanceId;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700179
Stephen Rothwell6b7feec2005-06-21 17:15:35 -0700180 return HvCall4(HvCallEventDmaBufList, packed.dword, localBufList,
181 remoteBufList, transferLength);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700182}
183
Stephen Rothwell45dc76a2005-06-21 17:15:33 -0700184static inline HvLpDma_Rc HvCallEvent_dmaToSp(void *local, u32 remote,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700185 u32 length, HvLpDma_Direction dir)
186{
Stephen Rothwell68143502006-01-12 13:48:52 +1100187 return HvCall4(HvCallEventDmaToSp, virt_to_abs(local), remote,
188 length, dir);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700189}
190
Kelly Dalyecb3ca272005-11-02 15:53:01 +1100191#endif /* _ASM_POWERPC_ISERIES_HV_CALL_EVENT_H */