Commit | Line | Data |
---|---|---|
920dae64 AT |
1 | /* |
2 | * ========== Copyright Header Begin ========================================== | |
3 | * | |
4 | * Hypervisor Software File: svc.h | |
5 | * | |
6 | * Copyright (c) 2006 Sun Microsystems, Inc. All Rights Reserved. | |
7 | * | |
8 | * - Do no alter or remove copyright notices | |
9 | * | |
10 | * - Redistribution and use of this software in source and binary forms, with | |
11 | * or without modification, are permitted provided that the following | |
12 | * conditions are met: | |
13 | * | |
14 | * - Redistribution of source code must retain the above copyright notice, | |
15 | * this list of conditions and the following disclaimer. | |
16 | * | |
17 | * - Redistribution in binary form must reproduce the above copyright notice, | |
18 | * this list of conditions and the following disclaimer in the | |
19 | * documentation and/or other materials provided with the distribution. | |
20 | * | |
21 | * Neither the name of Sun Microsystems, Inc. or the names of contributors | |
22 | * may be used to endorse or promote products derived from this software | |
23 | * without specific prior written permission. | |
24 | * | |
25 | * This software is provided "AS IS," without a warranty of any kind. | |
26 | * ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, | |
27 | * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A | |
28 | * PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN | |
29 | * MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE FOR | |
30 | * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR | |
31 | * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN | |
32 | * OR ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR | |
33 | * FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE | |
34 | * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, | |
35 | * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF | |
36 | * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. | |
37 | * | |
38 | * You acknowledge that this software is not designed, licensed or | |
39 | * intended for use in the design, construction, operation or maintenance of | |
40 | * any nuclear facility. | |
41 | * | |
42 | * ========== Copyright Header End ============================================ | |
43 | */ | |
44 | /* | |
45 | * Copyright 2007 Sun Microsystems, Inc. All rights reserved. | |
46 | * Use is subject to license terms. | |
47 | */ | |
48 | ||
49 | #ifndef _SVC_H_ | |
50 | #define _SVC_H_ | |
51 | ||
52 | #pragma ident "@(#)svc.h 1.10 07/05/30 SMI" | |
53 | ||
54 | #ifdef __cplusplus | |
55 | extern "C" { | |
56 | #endif | |
57 | ||
58 | #ifdef CONFIG_SVC | |
59 | ||
60 | #define XPID_RESET 0 | |
61 | #define XPID_POST 1 | |
62 | #define XPID_HV 2 | |
63 | #define XPID_GUESTBASE 16 | |
64 | #define XPID_GUEST(n) (XPID_GUESTBASE + (n)) | |
65 | ||
66 | #define SID_CONSOLE 0 | |
67 | #define SID_ERROR 2 | |
68 | #define SID_VBSC_CTL 3 | |
69 | #define SID_ECHO 4 | |
70 | #define SID_LOOP1 5 | |
71 | #define SID_LOOP2 6 | |
72 | #define SID_FMA 7 | |
73 | ||
74 | /* the service config bits */ | |
75 | #define SVC_CFG_RX 0x00000001 /* support RECV */ | |
76 | #define SVC_CFG_RE 0x00000002 /* support RECV intr */ | |
77 | #define SVC_CFG_TX 0x00000004 /* support SEND */ | |
78 | #define SVC_CFG_TE 0x00000008 /* support SEND intr */ | |
79 | #define SVC_CFG_GET 0x00000010 /* support GETSTATUS */ | |
80 | #define SVC_CFG_SET 0x00000020 /* support SETSTATUS */ | |
81 | #define SVC_CFG_LINK 0x00000100 /* cross linked svc */ | |
82 | #define SVC_CFG_MAGIC 0x00000200 /* legion magic trap */ | |
83 | #define SVC_CFG_CALLBACK 0x0000800 /* hypervisor callback */ | |
84 | #define SVC_CFG_PRIV 0x80000000 | |
85 | ||
86 | #define ABORT_SHIFT 11 | |
87 | ||
88 | #define SVC_DUPLEX ( \ | |
89 | SVC_CFG_RX | SVC_CFG_RI | \ | |
90 | SVC_CFG_TX | SVC_CFG_TI | \ | |
91 | SVC_CFG_GET | SVC_CFG_SET) | |
92 | ||
93 | /* the service status/flag bits */ | |
94 | #define SVC_FLAGS_RI 0x00000001 /* RECV pending */ | |
95 | #define SVC_FLAGS_RE 0x00000002 /* RECV intr enabled */ | |
96 | #define SVC_FLAGS_TI 0x00000004 /* SEND complete */ | |
97 | #define SVC_FLAGS_TE 0x00000008 /* SEND intr enabled */ | |
98 | #define SVC_FLAGS_TP 0x00000010 /* TX pending (queued) */ | |
99 | #define SVC_FLAG_ABORT (1 << ABORT_SHIFT) /* ABORT XXX interrupt ? */ | |
100 | ||
101 | /* the offsets in the svc register tables */ | |
102 | #define SVC_REG_XID 0x0 | |
103 | #define SVC_REG_SID 0x4 | |
104 | #define SVC_REG_RECV 0x8 | |
105 | #define SVC_REG_SEND 0xC | |
106 | ||
107 | /* fixed services between HV and VBSC */ | |
108 | #define VBSC_HV_ERRORS_SVC_SID 0x2 | |
109 | #define VBSC_HV_ERRORS_SVC_XID 0x2 | |
110 | #define VBSC_HV_ERRORS_SVC_FLAGS 0x35 | |
111 | #define VBSC_HV_ERRORS_SVC_MTU 0x200 | |
112 | ||
113 | #define VBSC_DEBUG_SVC_SID 0x3 | |
114 | #define VBSC_DEBUG_SVC_XID 0x2 | |
115 | #define VBSC_DEBUG_SVC_FLAGS 0x35 | |
116 | #define VBSC_DEBUG_SVC_MTU 0x200 | |
117 | ||
118 | ||
119 | /* May not modify condition codes */ | |
120 | #define LOCK(r_base, offset, r_tmp, r_tmp1) \ | |
121 | .pushlocals ;\ | |
122 | add r_base, offset, r_tmp ;\ | |
123 | sub %g0, 1, r_tmp1 ;\ | |
124 | 1: casx [r_tmp], %g0, r_tmp1 ;\ | |
125 | brlz,pn r_tmp1, 1b ;\ | |
126 | sub %g0, 1, r_tmp1 ;\ | |
127 | .poplocals | |
128 | ||
129 | /* May not modify condition codes */ | |
130 | /* watchout!! the branch will use the delay slot.. */ | |
131 | #define TRYLOCK(r_base, offset, r_tmp0, r_tmp1) \ | |
132 | add r_base, offset, r_tmp0 ;\ | |
133 | sub %g0, 1, r_tmp1 ;\ | |
134 | casx [r_tmp0], %g0, r_tmp1 ;\ | |
135 | brlz,pn r_tmp1, herr_wouldblock ; | |
136 | ||
137 | #ifdef SVCDEBUG | |
138 | #define TRACE(x) PRINT(x); PRINT("\r\n") | |
139 | #define TRACE1(x) PRINT(x); PRINT(": "); PRINTX(%o0); PRINT("\r\n") | |
140 | ||
141 | #define TRACE2(x) \ | |
142 | PRINT(x); PRINT(": ");\ | |
143 | PRINTX(%o0) ;\ | |
144 | PRINT(", ") ;\ | |
145 | PRINTX(%o1) ;\ | |
146 | PRINT("\r\n") ; | |
147 | ||
148 | #define TRACE3(x) \ | |
149 | PRINT(x); PRINT(": ");\ | |
150 | PRINTX(%o0) ;\ | |
151 | PRINT(", ") ;\ | |
152 | PRINTX(%o1) ;\ | |
153 | PRINT(", ") ;\ | |
154 | PRINTX(%o2) ;\ | |
155 | PRINT("\r\n") ; | |
156 | #else | |
157 | #define TRACE(s) | |
158 | #define TRACE1(s) | |
159 | #define TRACE2(s) | |
160 | #define TRACE3(s) | |
161 | #endif | |
162 | ||
163 | #ifdef INTR_DEBUG | |
164 | #define SEND_SVC_TRACE \ | |
165 | PRINT("svc root: "); PRINTX(r_root); \ | |
166 | PRINT(", "); PRINTX(r_svc); PRINT("\r\n"); | |
167 | #else | |
168 | #define SEND_SVC_TRACE | |
169 | #endif | |
170 | ||
171 | #define SEND_SVC_PACKET(r_root, r_svc, sc0, sc1, sc2, sc3) \ | |
172 | SEND_SVC_TRACE ; \ | |
173 | ldx [r_root + HV_SVC_DATA_TXBASE], sc0 ; \ | |
174 | ldx [r_svc + SVC_CTRL_SEND + SVC_LINK_PA], sc1; \ | |
175 | ldx [r_svc + SVC_CTRL_SEND + SVC_LINK_SIZE], sc2; \ | |
176 | SMALL_COPY_MACRO(sc1, sc2, sc0, sc3) ; \ | |
177 | ldx [r_root + HV_SVC_DATA_TXCHANNEL], sc1 ; \ | |
178 | mov 1, sc0; \ | |
179 | ldx [r_svc + SVC_CTRL_SEND + SVC_LINK_SIZE], sc2; \ | |
180 | sth sc2, [sc1 + FPGA_Q_SIZE] ; \ | |
181 | stb sc0, [sc1 + FPGA_Q_SEND] ; | |
182 | ||
183 | #ifdef _ASM | |
184 | ||
185 | #define UNLOCK(r_base, offset) \ | |
186 | stx %g0, [r_base + offset] | |
187 | ||
188 | #endif /* _ASM */ | |
189 | ||
190 | #define SVCCN_TYPE_BREAK 0x80 | |
191 | #define SVCCN_TYPE_HUP 0x81 | |
192 | #define SVCCN_TYPE_CHARS 0x00 | |
193 | ||
194 | #endif /* CONFIG_SVC */ | |
195 | ||
196 | #ifndef _ASM | |
197 | ||
198 | /* | |
199 | * The svc_data blocks are back-to-back in memory (a linear array) | |
200 | * if we get to the end then this is a bad service request. | |
201 | */ | |
202 | struct svc_link { | |
203 | uint64_t size; | |
204 | uint64_t pa; | |
205 | struct svc_ctrl *next; | |
206 | }; | |
207 | ||
208 | struct svc_callback { | |
209 | uint64_t rx; /* called on rx intr */ | |
210 | uint64_t tx; | |
211 | uint64_t cookie; /* your callback cookie */ | |
212 | }; | |
213 | ||
214 | typedef struct svc_ctrl svc_ctrl_t; | |
215 | ||
216 | struct svc_ctrl { | |
217 | uint32_t xid; | |
218 | uint32_t sid; | |
219 | uint32_t ino; /* virtual INO */ | |
220 | uint32_t mtu; | |
221 | uint32_t config; /* API control bits */ | |
222 | uint32_t state; /* device state */ | |
223 | uint32_t dcount; /* defer count */ | |
224 | uint32_t dstate; /* defer state 0=NACK, 1=BUSY */ | |
225 | uint64_t lock; /* simple mutex */ | |
226 | uint64_t intr_cookie; /* intr gen cookie */ | |
227 | struct svc_callback callback; /* HV call backhandle */ | |
228 | struct svc_ctrl *link; /* cross link */ | |
229 | struct svc_link recv; | |
230 | struct svc_link send; | |
231 | }; | |
232 | ||
233 | struct svc_pkt { | |
234 | uint32_t xid; /* service guest ID */ | |
235 | uint16_t sum; /* packet checksum */ | |
236 | uint16_t sid; /* svcid */ | |
237 | }; | |
238 | ||
239 | #define MAX_SVCS 9 | |
240 | ||
241 | typedef struct hv_svc_data hv_svc_data_t; | |
242 | ||
243 | struct hv_svc_data { | |
244 | uint64_t rxbase; /* PA of RX buffer (SRAM) */ | |
245 | uint64_t txbase; /* PA of TX buffer (SRAM) */ | |
246 | uint64_t rxchannel; /* RX channel regs PA */ | |
247 | uint64_t txchannel; /* TX channel regs PA */ | |
248 | uint64_t scr[2]; /* reg scratch */ | |
249 | uint32_t num_svcs; | |
250 | uint32_t sendbusy; | |
251 | struct svc_ctrl *sendh; /* intrs send from here */ | |
252 | struct svc_ctrl *sendt; /* sender adds here */ | |
253 | struct svc_ctrl *senddh; /* holding.. (nack/busy) */ | |
254 | struct svc_ctrl *senddt; | |
255 | uint64_t lock; /* need mutex?? */ | |
256 | struct svc_ctrl svcs[MAX_SVCS]; /* the svc buffers follow */ | |
257 | }; | |
258 | ||
259 | ||
260 | /* | |
261 | * Console protocol packet definition | |
262 | */ | |
263 | struct svccn_packet { | |
264 | uint8_t type; | |
265 | uint8_t len; | |
266 | uint8_t data[1]; | |
267 | }; | |
268 | ||
269 | #endif /* _ASM */ | |
270 | ||
271 | #ifdef __cplusplus | |
272 | } | |
273 | #endif | |
274 | ||
275 | #endif /* _SVC_H_ */ |