]> CyberLeo.Net >> Repos - FreeBSD/releng/8.1.git/blob - sys/sun4v/include/hypervisorvar.h
Copy stable/8 to releng/8.1 in preparation for 8.1-RC1.
[FreeBSD/releng/8.1.git] / sys / sun4v / include / hypervisorvar.h
1 /*-
2  * Copyright (c) 2006 Kip Macy
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  * 1. Redistributions of source code must retain the above copyright
9  *    notice, this list of conditions and the following disclaimer.
10  * 2. Redistributions in binary form must reproduce the above copyright
11  *    notice, this list of conditions and the following disclaimer in the
12  *    documentation and/or other materials provided with the distribution.
13  *
14  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24  * SUCH DAMAGE.
25  *
26  * $FreeBSD$
27  */
28
29
30 #ifndef _MACHINE_HYPERVISORVAR_H_
31 #define _MACHINE_HYPERVISORVAR_H_
32 /*
33  * Trap types
34  */
35 #define FAST_TRAP               0x80    /* Function # in %o5 */
36 #define CPU_TICK_NPT            0x81
37 #define CPU_STICK_NPT           0x82
38 #define MMU_MAP_ADDR            0x83
39 #define MMU_UNMAP_ADDR          0x84
40 #define TTRACE_ADDENTRY         0x85
41
42 #define CORE_TRAP               0xff
43
44 /*
45  * Status returns in %o0.
46  */
47 #define H_EOK                   0       /* Successful return */
48 #define H_ENOCPU                1       /* Invalid CPU id */
49 #define H_ENORADDR              2       /* Invalid real address */
50 #define H_ENOINTR               3       /* Invalid interrupt id */
51 #define H_EBADPGSZ              4       /* Invalid pagesize encoding */
52 #define H_EBADTSB               5       /* Invalid TSB description */
53 #define H_EINVAL                6       /* Invalid argument */
54 #define H_EBADTRAP              7       /* Invalid function number */
55 #define H_EBADALIGN             8       /* Invalid address alignment */
56 #define H_EWOULDBLOCK           9       /* Cannot complete operation */
57                                         /* without blocking */
58 #define H_ENOACCESS             10      /* No access to resource */
59 #define H_EIO                   11      /* I/O error */
60 #define H_ECPUERROR             12      /* CPU is in error state */
61 #define H_ENOTSUPPORTED         13      /* Function not supported */
62 #define H_ENOMAP                14      /* Mapping is not valid, */
63                                         /* no translation exists */
64 #define H_ETOOMANY              15      /* Too many items specified / limit reached */
65 #define H_ECHANNEL              16      /* Invalid LDC channel */
66
67 #define H_BREAK                 -1      /* Console Break */
68 #define H_HUP                   -2      /* Console Break */
69
70 /*
71  * Mondo CPU ID argument processing.
72  */
73 #define HV_SEND_MONDO_ENTRYDONE 0xffff
74
75 /*
76  * Function numbers for CORE_TRAP.
77  */
78 #define API_SET_VERSION         0x00
79 #define API_PUTCHAR             0x01
80 #define API_EXIT                0x02
81 #define API_GET_VERSION         0x03
82
83 /*
84  * Function numbers for FAST_TRAP.
85  */
86 #define MACH_EXIT               0x00
87 #define MACH_DESC               0x01
88 #define MACH_SIR                0x02
89 #define MACH_SET_SOFT_STATE     0x03
90 #define MACH_GET_SOFT_STATE     0x04
91 #define MACH_WATCHDOG           0x05
92
93 #define CPU_START               0x10
94 #define CPU_STOP                0x11
95 #define CPU_YIELD               0x12
96 #define CPU_QCONF               0x14
97 #define CPU_QINFO               0x15
98 #define CPU_MYID                0x16
99 #define CPU_STATE               0x17
100 #define CPU_SET_RTBA            0x18
101 #define CPU_GET_RTBA            0x19
102
103
104 #define MMU_TSB_CTX0            0x20
105 #define MMU_TSB_CTXNON0         0x21
106 #define MMU_DEMAP_PAGE          0x22
107 #define MMU_DEMAP_CTX           0x23
108 #define MMU_DEMAP_ALL           0x24
109 #define MMU_MAP_PERM_ADDR       0x25
110 #define MMU_FAULT_AREA_CONF     0x26
111 #define MMU_ENABLE              0x27
112 #define MMU_UNMAP_PERM_ADDR     0x28
113 #define MMU_TSB_CTX0_INFO       0x29
114 #define MMU_TSB_CTXNON0_INFO    0x2a
115 #define MMU_FAULT_AREA_INFO     0x2b
116
117 /*
118  * Bits for MMU functions flags argument:
119  *      arg3 of MMU_MAP_ADDR
120  *      arg3 of MMU_DEMAP_CTX
121  *      arg2 of MMU_DEMAP_ALL
122  */
123 #define MAP_DTLB                0x1
124 #define MAP_ITLB                0x2
125
126
127
128
129 #define MEM_SCRUB               0x31
130 #define MEM_SYNC                0x32
131 #define CPU_MONDO_SEND          0x42
132 #define TOD_GET                 0x50
133 #define TOD_SET                 0x51
134 #define CONS_GETCHAR            0x60
135 #define CONS_PUTCHAR            0x61
136 #define CONS_READ               0x62
137 #define CONS_WRITE              0x63
138
139 #define SVC_SEND                0x80
140 #define SVC_RECV                0x81
141 #define SVC_GETSTATUS           0x82
142 #define SVC_SETSTATUS           0x83
143 #define SVC_CLRSTATUS           0x84
144
145 #define TTRACE_BUF_CONF         0x90
146 #define TTRACE_BUF_INFO         0x91
147 #define TTRACE_ENABLE           0x92
148 #define TTRACE_FREEZE           0x93
149
150 #define DUMP_BUF_UPDATE         0x94
151 #define DUMP_BUF_INFO           0x95
152
153 #define INTR_DEVINO2SYSINO      0xa0
154 #define INTR_GETENABLED         0xa1
155 #define INTR_SETENABLED         0xa2
156 #define INTR_GETSTATE           0xa3
157 #define INTR_SETSTATE           0xa4
158 #define INTR_GETTARGET          0xa5
159 #define INTR_SETTARGET          0xa6
160
161 #define VINTR_GETCOOKIE         0xa7 
162 #define VINTR_SETCOOKIE         0xa8 
163 #define VINTR_GETENABLED        0xa9 
164 #define VINTR_SETENABLED        0xaa 
165 #define VINTR_GETSTATE          0xab 
166 #define VINTR_SETSTATE          0xac 
167 #define VINTR_GETTARGET         0xad 
168 #define VINTR_SETTARGET         0xae 
169
170
171 #define PCI_IOMMU_MAP           0xb0
172 #define PCI_IOMMU_DEMAP         0xb1
173 #define PCI_IOMMU_GETMAP        0xb2
174 #define PCI_IOMMU_GETBYPASS     0xb3
175
176 #define PCI_CONFIG_GET          0xb4
177 #define PCI_CONFIG_PUT          0xb5
178
179 #define PCI_PEEK                0xb6
180 #define PCI_POKE                0xb7
181
182 #define PCI_DMA_SYNC            0xb8
183
184 #define PCI_MSIQ_CONF           0xc0
185 #define PCI_MSIQ_INFO           0xc1
186 #define PCI_MSIQ_GETVALID       0xc2
187 #define PCI_MSIQ_SETVALID       0xc3
188 #define PCI_MSIQ_GETSTATE       0xc4
189 #define PCI_MSIQ_SETSTATE       0xc5
190 #define PCI_MSIQ_GETHEAD        0xc6
191 #define PCI_MSIQ_SETHEAD        0xc7
192 #define PCI_MSIQ_GETTAIL        0xc8
193
194 #define PCI_MSI_GETVALID        0xc9
195 #define PCI_MSI_SETVALID        0xca
196 #define PCI_MSI_GETMSIQ         0xcb
197 #define PCI_MSI_SETMSIQ         0xcc
198 #define PCI_MSI_GETSTATE        0xcd
199 #define PCI_MSI_SETSTATE        0xce
200
201 #define PCI_MSG_GETMSIQ         0xd0
202 #define PCI_MSG_SETMSIQ         0xd1
203 #define PCI_MSG_GETVALID        0xd2
204 #define PCI_MSG_SETVALID        0xd3
205
206 #define LDC_TX_QCONF            0xe0
207 #define LDC_TX_QINFO            0xe1
208 #define LDC_TX_GET_STATE        0xe2
209 #define LDC_TX_SET_QTAIL        0xe3
210 #define LDC_RX_QCONF            0xe4
211 #define LDC_RX_QINFO            0xe5
212 #define LDC_RX_GET_STATE        0xe6
213 #define LDC_RX_SET_QHEAD        0xe7
214
215 #define LDC_SET_MAPTABLE        0xea
216 #define LDC_GET_MAPTABLE        0xeb
217 #define LDC_COPY                0xec
218 #define LDC_MAPIN               0xed
219 #define LDC_UNMAP               0xee
220 #define LDC_REVOKE              0xef
221
222
223 #define SIM_READ                0xf0
224 #define SIM_WRITE               0xf1
225
226
227 #define NIAGARA_GET_PERFREG     0x100
228 #define NIAGARA_SET_PERFREG     0x101
229
230 #define NIAGARA_MMUSTAT_CONF    0x102
231 #define NIAGARA_MMUSTAT_INFO    0x103
232
233 /*
234  * Interrupt state manipulation definitions.
235  */
236
237 #define HV_INTR_IDLE_STATE      0
238 #define HV_INTR_RECEIVED_STATE  1
239 #define HV_INTR_DELIVERED_STATE 2
240
241 #define HV_INTR_DISABLED        0
242 #define HV_INTR_ENABLED         1
243
244 #ifndef LOCORE
245
246
247 #ifdef SET_MMU_STATS
248 #ifndef TTE4V_NPGSZ
249 #define TTE4V_NPGSZ     8
250 #endif /* TTE4V_NPGSZ */
251 /*
252  * MMU statistics structure for MMU_STAT_AREA
253  */
254 struct mmu_stat_one {
255         uint64_t        hit_ctx0[TTE4V_NPGSZ];
256         uint64_t        hit_ctxn0[TTE4V_NPGSZ];
257         uint64_t        tsb_miss;
258         uint64_t        tlb_miss;       /* miss, no TSB set */
259         uint64_t        map_ctx0[TTE4V_NPGSZ];
260         uint64_t        map_ctxn0[TTE4V_NPGSZ];
261 };
262
263 struct mmu_stat {
264         struct mmu_stat_one     immu_stat;
265         struct mmu_stat_one     dmmu_stat;
266         uint64_t                set_ctx0;
267         uint64_t                set_ctxn0;
268 };
269 #endif /* SET_MMU_STATS */
270
271 #endif /* _ASM */
272
273 /*
274  * CPU States
275  */
276 #define CPU_STATE_INVALID       0x0
277 #define CPU_STATE_IDLE          0x1     /* cpu not started */
278 #define CPU_STATE_GUEST         0x2     /* cpu running guest code */
279 #define CPU_STATE_ERROR         0x3     /* cpu is in the error state */
280 #define CPU_STATE_LAST_PUBLIC   CPU_STATE_ERROR /* last valid state */
281
282 /*
283  * MMU fault status area
284  */
285
286 #define MMFSA_TYPE_     0x00    /* fault type */
287 #define MMFSA_ADDR_     0x08    /* fault address */
288 #define MMFSA_CTX_      0x10    /* fault context */
289
290 #define MMFSA_I_        0x00            /* start of fields for I */
291 #define MMFSA_I_TYPE    (MMFSA_I_ + MMFSA_TYPE_) /* instruction fault type */
292 #define MMFSA_I_ADDR    (MMFSA_I_ + MMFSA_ADDR_) /* instruction fault address */
293 #define MMFSA_I_CTX     (MMFSA_I_ + MMFSA_CTX_) /* instruction fault context */
294
295 #define MMFSA_D_        0x40            /* start of fields for D */
296 #define MMFSA_D_TYPE    (MMFSA_D_ + MMFSA_TYPE_) /* data fault type */
297 #define MMFSA_D_ADDR    (MMFSA_D_ + MMFSA_ADDR_) /* data fault address */
298 #define MMFSA_D_CTX     (MMFSA_D_ + MMFSA_CTX_) /* data fault context */
299
300 #define MMFSA_F_FMISS   1       /* fast miss */
301 #define MMFSA_F_FPROT   2       /* fast protection */
302 #define MMFSA_F_MISS    3       /* mmu miss */
303 #define MMFSA_F_INVRA   4       /* invalid RA */
304 #define MMFSA_F_PRIV    5       /* privilege violation */
305 #define MMFSA_F_PROT    6       /* protection violation */
306 #define MMFSA_F_NFO     7       /* NFO access */
307 #define MMFSA_F_SOPG    8       /* so page */
308 #define MMFSA_F_INVVA   9       /* invalid VA */
309 #define MMFSA_F_INVASI  10      /* invalid ASI */
310 #define MMFSA_F_NCATM   11      /* non-cacheable atomic */
311 #define MMFSA_F_PRVACT  12      /* privileged action */
312 #define MMFSA_F_WPT     13      /* watchpoint hit */
313 #define MMFSA_F_UNALIGN 14      /* unaligned access */
314 #define MMFSA_F_INVPGSZ 15      /* invalid page size */
315
316 #define MMFSA_SIZE      0x80    /* in bytes, 64 byte aligned */
317
318 /*
319  * MMU fault status - MMFSA_IFS and MMFSA_DFS
320  */
321 #define MMFS_FV         0x00000001
322 #define MMFS_OW         0x00000002
323 #define MMFS_W          0x00000004
324 #define MMFS_PR         0x00000008
325 #define MMFS_CT         0x00000030
326 #define MMFS_E          0x00000040
327 #define MMFS_FT         0x00003f80
328 #define MMFS_ME         0x00004000
329 #define MMFS_TM         0x00008000
330 #define MMFS_ASI        0x00ff0000
331 #define MMFS_NF         0x01000000
332
333 /*
334  * DMA sync parameter definitions
335  */
336 #define HVIO_DMA_SYNC_DIR_TO_DEV        0x01
337 #define HVIO_DMA_SYNC_DIR_FROM_DEV      0x02
338
339 #ifdef SIMULATOR
340 #define MAGIC_TRAP_ON   ta      0x77
341 #define MAGIC_TRAP_OFF  ta      0x78
342 #define MAGIC_EXIT      ta      0x71
343 #else
344 #define MAGIC_TRAP_ON   nop
345 #define MAGIC_TRAP_OFF  nop
346 #define MAGIC_EXIT      nop
347 #endif
348
349
350 #endif  /*_MACHINE_HYPERVISORVAR_H_ */