blob: cc029d388e11a6bf3f5f1eda0bf53c91b0925c18 [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
Stephen Rothwell1670b2b2007-10-11 14:53:32 +100024#include <linux/types.h>
25#include <linux/dma-mapping.h>
26
Kelly Daly50592f52005-11-02 11:37:22 +110027#include <asm/iseries/hv_call_sc.h>
Kelly Daly1ec65d72005-11-02 13:46:07 +110028#include <asm/iseries/hv_types.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070029#include <asm/abs_addr.h>
30
31struct HvLpEvent;
32
33typedef u8 HvLpEvent_Type;
34typedef u8 HvLpEvent_AckInd;
35typedef u8 HvLpEvent_AckType;
36
Linus Torvalds1da177e2005-04-16 15:20:36 -070037typedef u8 HvLpDma_Direction;
38typedef u8 HvLpDma_AddressType;
39
Linus Torvalds1da177e2005-04-16 15:20:36 -070040typedef u64 HvLpEvent_Rc;
41typedef u64 HvLpDma_Rc;
42
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
Stephen Rothwell45dc76a2005-06-21 17:15:33 -070048#define HvCallEventDmaToSp HvCallEvent + 5
Linus Torvalds1da177e2005-04-16 15:20:36 -070049#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
59
60static inline void HvCallEvent_getOverflowLpEvents(u8 queueIndex)
61{
Stephen Rothwell45dc76a2005-06-21 17:15:33 -070062 HvCall1(HvCallEventGetOverflowLpEvents, queueIndex);
Linus Torvalds1da177e2005-04-16 15:20:36 -070063}
64
65static inline void HvCallEvent_setInterLpQueueIndex(u8 queueIndex)
66{
Stephen Rothwell45dc76a2005-06-21 17:15:33 -070067 HvCall1(HvCallEventSetInterLpQueueIndex, queueIndex);
Linus Torvalds1da177e2005-04-16 15:20:36 -070068}
69
70static inline void HvCallEvent_setLpEventStack(u8 queueIndex,
71 char *eventStackAddr, u32 eventStackSize)
72{
Stephen Rothwell68143502006-01-12 13:48:52 +110073 HvCall3(HvCallEventSetLpEventStack, queueIndex,
74 virt_to_abs(eventStackAddr), eventStackSize);
Linus Torvalds1da177e2005-04-16 15:20:36 -070075}
76
77static inline void HvCallEvent_setLpEventQueueInterruptProc(u8 queueIndex,
78 u16 lpLogicalProcIndex)
79{
80 HvCall2(HvCallEventSetLpEventQueueInterruptProc, queueIndex,
81 lpLogicalProcIndex);
Linus Torvalds1da177e2005-04-16 15:20:36 -070082}
83
84static inline HvLpEvent_Rc HvCallEvent_signalLpEvent(struct HvLpEvent *event)
85{
Stephen Rothwell68143502006-01-12 13:48:52 +110086 return HvCall1(HvCallEventSignalLpEvent, virt_to_abs(event));
Linus Torvalds1da177e2005-04-16 15:20:36 -070087}
88
89static 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)
95{
Stephen Rothwell45dc76a2005-06-21 17:15:33 -070096 /* Pack the misc bits into a single Dword to pass to PLIC */
Linus Torvalds1da177e2005-04-16 15:20:36 -070097 union {
Stephen Rothwell68143502006-01-12 13:48:52 +110098 struct {
99 u8 ack_and_target;
100 u8 type;
101 u16 subtype;
102 HvLpInstanceId src_inst;
103 HvLpInstanceId target_inst;
104 } parms;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700105 u64 dword;
106 } packed;
Stephen Rothwell68143502006-01-12 13:48:52 +1100107
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;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700113
Stephen Rothwell6b7feec2005-06-21 17:15:35 -0700114 return HvCall7(HvCallEventSignalLpEventParms, packed.dword,
115 correlationToken, eventData1, eventData2,
116 eventData3, eventData4, eventData5);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700117}
118
Stephen Rothwell1670b2b2007-10-11 14:53:32 +1000119extern void *iseries_hv_alloc(size_t size, dma_addr_t *dma_handle, gfp_t flag);
120extern void iseries_hv_free(size_t size, void *vaddr, dma_addr_t dma_handle);
121extern dma_addr_t iseries_hv_map(void *vaddr, size_t size,
122 enum dma_data_direction direction);
123extern void iseries_hv_unmap(dma_addr_t dma_handle, size_t size,
124 enum dma_data_direction direction);
125
Linus Torvalds1da177e2005-04-16 15:20:36 -0700126static inline HvLpEvent_Rc HvCallEvent_ackLpEvent(struct HvLpEvent *event)
127{
Stephen Rothwell68143502006-01-12 13:48:52 +1100128 return HvCall1(HvCallEventAckLpEvent, virt_to_abs(event));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700129}
130
131static inline HvLpEvent_Rc HvCallEvent_cancelLpEvent(struct HvLpEvent *event)
132{
Stephen Rothwell68143502006-01-12 13:48:52 +1100133 return HvCall1(HvCallEventCancelLpEvent, virt_to_abs(event));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700134}
135
136static inline HvLpInstanceId HvCallEvent_getSourceLpInstanceId(
137 HvLpIndex targetLp, HvLpEvent_Type type)
138{
Stephen Rothwell6b7feec2005-06-21 17:15:35 -0700139 return HvCall2(HvCallEventGetSourceLpInstanceId, targetLp, type);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700140}
141
142static inline HvLpInstanceId HvCallEvent_getTargetLpInstanceId(
143 HvLpIndex targetLp, HvLpEvent_Type type)
144{
Stephen Rothwell6b7feec2005-06-21 17:15:35 -0700145 return HvCall2(HvCallEventGetTargetLpInstanceId, targetLp, type);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700146}
147
148static inline void HvCallEvent_openLpEventPath(HvLpIndex targetLp,
149 HvLpEvent_Type type)
150{
151 HvCall2(HvCallEventOpenLpEventPath, targetLp, type);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700152}
153
154static inline void HvCallEvent_closeLpEventPath(HvLpIndex targetLp,
155 HvLpEvent_Type type)
156{
157 HvCall2(HvCallEventCloseLpEventPath, targetLp, type);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700158}
159
160static 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)
168{
Stephen Rothwell45dc76a2005-06-21 17:15:33 -0700169 /* Pack the misc bits into a single Dword to pass to PLIC */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700170 union {
Stephen Rothwell68143502006-01-12 13:48:52 +1100171 struct {
172 u8 flags;
173 HvLpIndex remote;
174 u8 type;
175 u8 reserved;
176 HvLpInstanceId local_inst;
177 HvLpInstanceId remote_inst;
178 } parms;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700179 u64 dword;
180 } packed;
181
Stephen Rothwell68143502006-01-12 13:48:52 +1100182 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;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700189
Stephen Rothwell6b7feec2005-06-21 17:15:35 -0700190 return HvCall4(HvCallEventDmaBufList, packed.dword, localBufList,
191 remoteBufList, transferLength);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700192}
193
Stephen Rothwell45dc76a2005-06-21 17:15:33 -0700194static inline HvLpDma_Rc HvCallEvent_dmaToSp(void *local, u32 remote,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700195 u32 length, HvLpDma_Direction dir)
196{
Stephen Rothwell68143502006-01-12 13:48:52 +1100197 return HvCall4(HvCallEventDmaToSp, virt_to_abs(local), remote,
198 length, dir);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700199}
200
Kelly Dalyecb3ca272005-11-02 15:53:01 +1100201#endif /* _ASM_POWERPC_ISERIES_HV_CALL_EVENT_H */