Merge branch 'master' of /home/trondmy/repositories/git/linux-2.6/
[sfrench/cifs-2.6.git] / include / asm-sparc64 / hypervisor.h
1 #ifndef _SPARC64_HYPERVISOR_H
2 #define _SPARC64_HYPERVISOR_H
3
4 /* Sun4v hypervisor interfaces and defines.
5  *
6  * Hypervisor calls are made via traps to software traps number 0x80
7  * and above.  Registers %o0 to %o5 serve as argument, status, and
8  * return value registers.
9  *
10  * There are two kinds of these traps.  First there are the normal
11  * "fast traps" which use software trap 0x80 and encode the function
12  * to invoke by number in register %o5.  Argument and return value
13  * handling is as follows:
14  *
15  * -----------------------------------------------
16  * |  %o5  | function number |     undefined     |
17  * |  %o0  |   argument 0    |   return status   |
18  * |  %o1  |   argument 1    |   return value 1  |
19  * |  %o2  |   argument 2    |   return value 2  |
20  * |  %o3  |   argument 3    |   return value 3  |
21  * |  %o4  |   argument 4    |   return value 4  |
22  * -----------------------------------------------
23  *
24  * The second type are "hyper-fast traps" which encode the function
25  * number in the software trap number itself.  So these use trap
26  * numbers > 0x80.  The register usage for hyper-fast traps is as
27  * follows:
28  *
29  * -----------------------------------------------
30  * |  %o0  |   argument 0    |   return status   |
31  * |  %o1  |   argument 1    |   return value 1  |
32  * |  %o2  |   argument 2    |   return value 2  |
33  * |  %o3  |   argument 3    |   return value 3  |
34  * |  %o4  |   argument 4    |   return value 4  |
35  * -----------------------------------------------
36  *
37  * Registers providing explicit arguments to the hypervisor calls
38  * are volatile across the call.  Upon return their values are
39  * undefined unless explicitly specified as containing a particular
40  * return value by the specific call.  The return status is always
41  * returned in register %o0, zero indicates a successful execution of
42  * the hypervisor call and other values indicate an error status as
43  * defined below.  So, for example, if a hyper-fast trap takes
44  * arguments 0, 1, and 2, then %o0, %o1, and %o2 are volatile across
45  * the call and %o3, %o4, and %o5 would be preserved.
46  *
47  * If the hypervisor trap is invalid, or the fast trap function number
48  * is invalid, HV_EBADTRAP will be returned in %o0.  Also, all 64-bits
49  * of the argument and return values are significant.
50  */
51
52 /* Trap numbers.  */
53 #define HV_FAST_TRAP            0x80
54 #define HV_MMU_MAP_ADDR_TRAP    0x83
55 #define HV_MMU_UNMAP_ADDR_TRAP  0x84
56 #define HV_TTRACE_ADDENTRY_TRAP 0x85
57 #define HV_CORE_TRAP            0xff
58
59 /* Error codes.  */
60 #define HV_EOK                          0  /* Successful return            */
61 #define HV_ENOCPU                       1  /* Invalid CPU id               */
62 #define HV_ENORADDR                     2  /* Invalid real address         */
63 #define HV_ENOINTR                      3  /* Invalid interrupt id         */
64 #define HV_EBADPGSZ                     4  /* Invalid pagesize encoding    */
65 #define HV_EBADTSB                      5  /* Invalid TSB description      */
66 #define HV_EINVAL                       6  /* Invalid argument             */
67 #define HV_EBADTRAP                     7  /* Invalid function number      */
68 #define HV_EBADALIGN                    8  /* Invalid address alignment    */
69 #define HV_EWOULDBLOCK                  9  /* Cannot complete w/o blocking */
70 #define HV_ENOACCESS                    10 /* No access to resource        */
71 #define HV_EIO                          11 /* I/O error                    */
72 #define HV_ECPUERROR                    12 /* CPU in error state           */
73 #define HV_ENOTSUPPORTED                13 /* Function not supported       */
74 #define HV_ENOMAP                       14 /* No mapping found             */
75 #define HV_ETOOMANY                     15 /* Too many items specified     */
76
77 /* mach_exit()
78  * TRAP:        HV_FAST_TRAP
79  * FUNCTION:    HV_FAST_MACH_EXIT
80  * ARG0:        exit code
81  * ERRORS:      This service does not return.
82  *
83  * Stop all CPUs in the virtual domain and place them into the stopped
84  * state.  The 64-bit exit code may be passed to a service entity as
85  * the domain's exit status.  On systems without a service entity, the
86  * domain will undergo a reset, and the boot firmware will be
87  * reloaded.
88  *
89  * This function will never return to the guest that invokes it.
90  *
91  * Note: By convention an exit code of zero denotes a successful exit by
92  *       the guest code.  A non-zero exit code denotes a guest specific
93  *       error indication.
94  *
95  */
96 #define HV_FAST_MACH_EXIT               0x00
97
98 /* Domain services.  */
99
100 /* mach_desc()
101  * TRAP:        HV_FAST_TRAP
102  * FUNCTION:    HV_FAST_MACH_DESC
103  * ARG0:        buffer
104  * ARG1:        length
105  * RET0:        status
106  * RET1:        length
107  * ERRORS:      HV_EBADALIGN    Buffer is badly aligned
108  *              HV_ENORADDR     Buffer is to an illegal real address.
109  *              HV_EINVAL       Buffer length is too small for complete
110  *                              machine description.
111  *
112  * Copy the most current machine description into the buffer indicated
113  * by the real address in ARG0.  The buffer provided must be 16 byte
114  * aligned.  Upon success or HV_EINVAL, this service returns the
115  * actual size of the machine description in the RET1 return value.
116  *
117  * Note: A method of determining the appropriate buffer size for the
118  *       machine description is to first call this service with a buffer
119  *       length of 0 bytes.
120  */
121 #define HV_FAST_MACH_DESC               0x01
122
123 /* mach_exit()
124  * TRAP:        HV_FAST_TRAP
125  * FUNCTION:    HV_FAST_MACH_SIR
126  * ERRORS:      This service does not return.
127  *
128  * Perform a software initiated reset of the virtual machine domain.
129  * All CPUs are captured as soon as possible, all hardware devices are
130  * returned to the entry default state, and the domain is restarted at
131  * the SIR (trap type 0x04) real trap table (RTBA) entry point on one
132  * of the CPUs.  The single CPU restarted is selected as determined by
133  * platform specific policy.  Memory is preserved across this
134  * operation.
135  */
136 #define HV_FAST_MACH_SIR                0x02
137
138 /* mach_set_soft_state()
139  * TRAP:        HV_FAST_TRAP
140  * FUNCTION:    HV_FAST_MACH_SET_SOFT_STATE
141  * ARG0:        software state
142  * ARG1:        software state description pointer
143  * RET0:        status
144  * ERRORS:      EINVAL          software state not valid or software state
145  *                              description is not NULL terminated
146  *              ENORADDR        software state description pointer is not a
147  *                              valid real address
148  *              EBADALIGNED     software state description is not correctly
149  *                              aligned
150  *
151  * This allows the guest to report it's soft state to the hypervisor.  There
152  * are two primary components to this state.  The first part states whether
153  * the guest software is running or not.  The second containts optional
154  * details specific to the software.
155  *
156  * The software state argument is defined below in HV_SOFT_STATE_*, and
157  * indicates whether the guest is operating normally or in a transitional
158  * state.
159  *
160  * The software state description argument is a real address of a data buffer
161  * of size 32-bytes aligned on a 32-byte boundary.  It is treated as a NULL
162  * terminated 7-bit ASCII string of up to 31 characters not including the
163  * NULL termination.
164  */
165 #define HV_FAST_MACH_SET_SOFT_STATE     0x03
166 #define  HV_SOFT_STATE_NORMAL            0x01
167 #define  HV_SOFT_STATE_TRANSITION        0x02
168
169 /* mach_get_soft_state()
170  * TRAP:        HV_FAST_TRAP
171  * FUNCTION:    HV_FAST_MACH_GET_SOFT_STATE
172  * ARG0:        software state description pointer
173  * RET0:        status
174  * RET1:        software state
175  * ERRORS:      ENORADDR        software state description pointer is not a
176  *                              valid real address
177  *              EBADALIGNED     software state description is not correctly
178  *                              aligned
179  *
180  * Retrieve the current value of the guest's software state.  The rules
181  * for the software state pointer are the same as for mach_set_soft_state()
182  * above.
183  */
184 #define HV_FAST_MACH_GET_SOFT_STATE     0x04
185
186 /* CPU services.
187  *
188  * CPUs represent devices that can execute software threads.  A single
189  * chip that contains multiple cores or strands is represented as
190  * multiple CPUs with unique CPU identifiers.  CPUs are exported to
191  * OBP via the machine description (and to the OS via the OBP device
192  * tree).  CPUs are always in one of three states: stopped, running,
193  * or error.
194  *
195  * A CPU ID is a pre-assigned 16-bit value that uniquely identifies a
196  * CPU within a logical domain.  Operations that are to be performed
197  * on multiple CPUs specify them via a CPU list.  A CPU list is an
198  * array in real memory, of which each 16-bit word is a CPU ID.  CPU
199  * lists are passed through the API as two arguments.  The first is
200  * the number of entries (16-bit words) in the CPU list, and the
201  * second is the (real address) pointer to the CPU ID list.
202  */
203
204 /* cpu_start()
205  * TRAP:        HV_FAST_TRAP
206  * FUNCTION:    HV_FAST_CPU_START
207  * ARG0:        CPU ID
208  * ARG1:        PC
209  * ARG1:        RTBA
210  * ARG1:        target ARG0
211  * RET0:        status
212  * ERRORS:      ENOCPU          Invalid CPU ID
213  *              EINVAL          Target CPU ID is not in the stopped state
214  *              ENORADDR        Invalid PC or RTBA real address
215  *              EBADALIGN       Unaligned PC or unaligned RTBA
216  *              EWOULDBLOCK     Starting resources are not available
217  *
218  * Start CPU with given CPU ID with PC in %pc and with a real trap
219  * base address value of RTBA.  The indicated CPU must be in the
220  * stopped state.  The supplied RTBA must be aligned on a 256 byte
221  * boundary.  On successful completion, the specified CPU will be in
222  * the running state and will be supplied with "target ARG0" in %o0
223  * and RTBA in %tba.
224  */
225 #define HV_FAST_CPU_START               0x10
226
227 /* cpu_stop()
228  * TRAP:        HV_FAST_TRAP
229  * FUNCTION:    HV_FAST_CPU_STOP
230  * ARG0:        CPU ID
231  * RET0:        status
232  * ERRORS:      ENOCPU          Invalid CPU ID
233  *              EINVAL          Target CPU ID is the current cpu
234  *              EINVAL          Target CPU ID is not in the running state
235  *              EWOULDBLOCK     Stopping resources are not available
236  *              ENOTSUPPORTED   Not supported on this platform
237  *
238  * The specified CPU is stopped.  The indicated CPU must be in the
239  * running state.  On completion, it will be in the stopped state.  It
240  * is not legal to stop the current CPU.
241  *
242  * Note: As this service cannot be used to stop the current cpu, this service
243  *       may not be used to stop the last running CPU in a domain.  To stop
244  *       and exit a running domain, a guest must use the mach_exit() service.
245  */
246 #define HV_FAST_CPU_STOP                0x11
247
248 /* cpu_yield()
249  * TRAP:        HV_FAST_TRAP
250  * FUNCTION:    HV_FAST_CPU_YIELD
251  * RET0:        status
252  * ERRORS:      No possible error.
253  *
254  * Suspend execution on the current CPU.  Execution will resume when
255  * an interrupt (device, %stick_compare, or cross-call) is targeted to
256  * the CPU.  On some CPUs, this API may be used by the hypervisor to
257  * save power by disabling hardware strands.
258  */
259 #define HV_FAST_CPU_YIELD               0x12
260
261 #ifndef __ASSEMBLY__
262 extern unsigned long sun4v_cpu_yield(void);
263 #endif
264
265 /* cpu_qconf()
266  * TRAP:        HV_FAST_TRAP
267  * FUNCTION:    HV_FAST_CPU_QCONF
268  * ARG0:        queue
269  * ARG1:        base real address
270  * ARG2:        number of entries
271  * RET0:        status
272  * ERRORS:      ENORADDR        Invalid base real address
273  *              EINVAL          Invalid queue or number of entries is less
274  *                              than 2 or too large.
275  *              EBADALIGN       Base real address is not correctly aligned
276  *                              for size.
277  *
278  * Configure the given queue to be placed at the given base real
279  * address, with the given number of entries.  The number of entries
280  * must be a power of 2.  The base real address must be aligned
281  * exactly to match the queue size.  Each queue entry is 64 bytes
282  * long, so for example a 32 entry queue must be aligned on a 2048
283  * byte real address boundary.
284  *
285  * The specified queue is unconfigured if the number of entries is given
286  * as zero.
287  *
288  * For the current version of this API service, the argument queue is defined
289  * as follows:
290  *
291  *      queue           description
292  *      -----           -------------------------
293  *      0x3c            cpu mondo queue
294  *      0x3d            device mondo queue
295  *      0x3e            resumable error queue
296  *      0x3f            non-resumable error queue
297  *
298  * Note: The maximum number of entries for each queue for a specific cpu may
299  *       be determined from the machine description.
300  */
301 #define HV_FAST_CPU_QCONF               0x14
302 #define  HV_CPU_QUEUE_CPU_MONDO          0x3c
303 #define  HV_CPU_QUEUE_DEVICE_MONDO       0x3d
304 #define  HV_CPU_QUEUE_RES_ERROR          0x3e
305 #define  HV_CPU_QUEUE_NONRES_ERROR       0x3f
306
307 #ifndef __ASSEMBLY__
308 extern unsigned long sun4v_cpu_qconf(unsigned long type,
309                                      unsigned long queue_paddr,
310                                      unsigned long num_queue_entries);
311 #endif
312
313 /* cpu_qinfo()
314  * TRAP:        HV_FAST_TRAP
315  * FUNCTION:    HV_FAST_CPU_QINFO
316  * ARG0:        queue
317  * RET0:        status
318  * RET1:        base real address
319  * RET1:        number of entries
320  * ERRORS:      EINVAL          Invalid queue
321  *
322  * Return the configuration info for the given queue.  The base real
323  * address and number of entries of the defined queue are returned.
324  * The queue argument values are the same as for cpu_qconf() above.
325  *
326  * If the specified queue is a valid queue number, but no queue has
327  * been defined, the number of entries will be set to zero and the
328  * base real address returned is undefined.
329  */
330 #define HV_FAST_CPU_QINFO               0x15
331
332 /* cpu_mondo_send()
333  * TRAP:        HV_FAST_TRAP
334  * FUNCTION:    HV_FAST_CPU_MONDO_SEND
335  * ARG0-1:      CPU list
336  * ARG2:        data real address
337  * RET0:        status
338  * ERRORS:      EBADALIGN       Mondo data is not 64-byte aligned or CPU list
339  *                              is not 2-byte aligned.
340  *              ENORADDR        Invalid data mondo address, or invalid cpu list
341  *                              address.
342  *              ENOCPU          Invalid cpu in CPU list
343  *              EWOULDBLOCK     Some or all of the listed CPUs did not receive
344  *                              the mondo
345  *              ECPUERROR       One or more of the listed CPUs are in error
346  *                              state, use HV_FAST_CPU_STATE to see which ones
347  *              EINVAL          CPU list includes caller's CPU ID
348  *
349  * Send a mondo interrupt to the CPUs in the given CPU list with the
350  * 64-bytes at the given data real address.  The data must be 64-byte
351  * aligned.  The mondo data will be delivered to the cpu_mondo queues
352  * of the recipient CPUs.
353  *
354  * In all cases, error or not, the CPUs in the CPU list to which the
355  * mondo has been successfully delivered will be indicated by having
356  * their entry in CPU list updated with the value 0xffff.
357  */
358 #define HV_FAST_CPU_MONDO_SEND          0x42
359
360 #ifndef __ASSEMBLY__
361 extern unsigned long sun4v_cpu_mondo_send(unsigned long cpu_count, unsigned long cpu_list_pa, unsigned long mondo_block_pa);
362 #endif
363
364 /* cpu_myid()
365  * TRAP:        HV_FAST_TRAP
366  * FUNCTION:    HV_FAST_CPU_MYID
367  * RET0:        status
368  * RET1:        CPU ID
369  * ERRORS:      No errors defined.
370  *
371  * Return the hypervisor ID handle for the current CPU.  Use by a
372  * virtual CPU to discover it's own identity.
373  */
374 #define HV_FAST_CPU_MYID                0x16
375
376 /* cpu_state()
377  * TRAP:        HV_FAST_TRAP
378  * FUNCTION:    HV_FAST_CPU_STATE
379  * ARG0:        CPU ID
380  * RET0:        status
381  * RET1:        state
382  * ERRORS:      ENOCPU          Invalid CPU ID
383  *
384  * Retrieve the current state of the CPU with the given CPU ID.
385  */
386 #define HV_FAST_CPU_STATE               0x17
387 #define  HV_CPU_STATE_STOPPED            0x01
388 #define  HV_CPU_STATE_RUNNING            0x02
389 #define  HV_CPU_STATE_ERROR              0x03
390
391 #ifndef __ASSEMBLY__
392 extern long sun4v_cpu_state(unsigned long cpuid);
393 #endif
394
395 /* cpu_set_rtba()
396  * TRAP:        HV_FAST_TRAP
397  * FUNCTION:    HV_FAST_CPU_SET_RTBA
398  * ARG0:        RTBA
399  * RET0:        status
400  * RET1:        previous RTBA
401  * ERRORS:      ENORADDR        Invalid RTBA real address
402  *              EBADALIGN       RTBA is incorrectly aligned for a trap table
403  *
404  * Set the real trap base address of the local cpu to the given RTBA.
405  * The supplied RTBA must be aligned on a 256 byte boundary.  Upon
406  * success the previous value of the RTBA is returned in RET1.
407  *
408  * Note: This service does not affect %tba
409  */
410 #define HV_FAST_CPU_SET_RTBA            0x18
411
412 /* cpu_set_rtba()
413  * TRAP:        HV_FAST_TRAP
414  * FUNCTION:    HV_FAST_CPU_GET_RTBA
415  * RET0:        status
416  * RET1:        previous RTBA
417  * ERRORS:      No possible error.
418  *
419  * Returns the current value of RTBA in RET1.
420  */
421 #define HV_FAST_CPU_GET_RTBA            0x19
422
423 /* MMU services.
424  *
425  * Layout of a TSB description for mmu_tsb_ctx{,non}0() calls.
426  */
427 #ifndef __ASSEMBLY__
428 struct hv_tsb_descr {
429         unsigned short          pgsz_idx;
430         unsigned short          assoc;
431         unsigned int            num_ttes;       /* in TTEs */
432         unsigned int            ctx_idx;
433         unsigned int            pgsz_mask;
434         unsigned long           tsb_base;
435         unsigned long           resv;
436 };
437 #endif
438 #define HV_TSB_DESCR_PGSZ_IDX_OFFSET    0x00
439 #define HV_TSB_DESCR_ASSOC_OFFSET       0x02
440 #define HV_TSB_DESCR_NUM_TTES_OFFSET    0x04
441 #define HV_TSB_DESCR_CTX_IDX_OFFSET     0x08
442 #define HV_TSB_DESCR_PGSZ_MASK_OFFSET   0x0c
443 #define HV_TSB_DESCR_TSB_BASE_OFFSET    0x10
444 #define HV_TSB_DESCR_RESV_OFFSET        0x18
445
446 /* Page size bitmask.  */
447 #define HV_PGSZ_MASK_8K                 (1 << 0)
448 #define HV_PGSZ_MASK_64K                (1 << 1)
449 #define HV_PGSZ_MASK_512K               (1 << 2)
450 #define HV_PGSZ_MASK_4MB                (1 << 3)
451 #define HV_PGSZ_MASK_32MB               (1 << 4)
452 #define HV_PGSZ_MASK_256MB              (1 << 5)
453 #define HV_PGSZ_MASK_2GB                (1 << 6)
454 #define HV_PGSZ_MASK_16GB               (1 << 7)
455
456 /* Page size index.  The value given in the TSB descriptor must correspond
457  * to the smallest page size specified in the pgsz_mask page size bitmask.
458  */
459 #define HV_PGSZ_IDX_8K                  0
460 #define HV_PGSZ_IDX_64K                 1
461 #define HV_PGSZ_IDX_512K                2
462 #define HV_PGSZ_IDX_4MB                 3
463 #define HV_PGSZ_IDX_32MB                4
464 #define HV_PGSZ_IDX_256MB               5
465 #define HV_PGSZ_IDX_2GB                 6
466 #define HV_PGSZ_IDX_16GB                7
467
468 /* MMU fault status area.
469  *
470  * MMU related faults have their status and fault address information
471  * placed into a memory region made available by privileged code.  Each
472  * virtual processor must make a mmu_fault_area_conf() call to tell the
473  * hypervisor where that processor's fault status should be stored.
474  *
475  * The fault status block is a multiple of 64-bytes and must be aligned
476  * on a 64-byte boundary.
477  */
478 #ifndef __ASSEMBLY__
479 struct hv_fault_status {
480         unsigned long           i_fault_type;
481         unsigned long           i_fault_addr;
482         unsigned long           i_fault_ctx;
483         unsigned long           i_reserved[5];
484         unsigned long           d_fault_type;
485         unsigned long           d_fault_addr;
486         unsigned long           d_fault_ctx;
487         unsigned long           d_reserved[5];
488 };
489 #endif
490 #define HV_FAULT_I_TYPE_OFFSET  0x00
491 #define HV_FAULT_I_ADDR_OFFSET  0x08
492 #define HV_FAULT_I_CTX_OFFSET   0x10
493 #define HV_FAULT_D_TYPE_OFFSET  0x40
494 #define HV_FAULT_D_ADDR_OFFSET  0x48
495 #define HV_FAULT_D_CTX_OFFSET   0x50
496
497 #define HV_FAULT_TYPE_FAST_MISS 1
498 #define HV_FAULT_TYPE_FAST_PROT 2
499 #define HV_FAULT_TYPE_MMU_MISS  3
500 #define HV_FAULT_TYPE_INV_RA    4
501 #define HV_FAULT_TYPE_PRIV_VIOL 5
502 #define HV_FAULT_TYPE_PROT_VIOL 6
503 #define HV_FAULT_TYPE_NFO       7
504 #define HV_FAULT_TYPE_NFO_SEFF  8
505 #define HV_FAULT_TYPE_INV_VA    9
506 #define HV_FAULT_TYPE_INV_ASI   10
507 #define HV_FAULT_TYPE_NC_ATOMIC 11
508 #define HV_FAULT_TYPE_PRIV_ACT  12
509 #define HV_FAULT_TYPE_RESV1     13
510 #define HV_FAULT_TYPE_UNALIGNED 14
511 #define HV_FAULT_TYPE_INV_PGSZ  15
512 /* Values 16 --> -2 are reserved.  */
513 #define HV_FAULT_TYPE_MULTIPLE  -1
514
515 /* Flags argument for mmu_{map,unmap}_addr(), mmu_demap_{page,context,all}(),
516  * and mmu_{map,unmap}_perm_addr().
517  */
518 #define HV_MMU_DMMU                     0x01
519 #define HV_MMU_IMMU                     0x02
520 #define HV_MMU_ALL                      (HV_MMU_DMMU | HV_MMU_IMMU)
521
522 /* mmu_map_addr()
523  * TRAP:        HV_MMU_MAP_ADDR_TRAP
524  * ARG0:        virtual address
525  * ARG1:        mmu context
526  * ARG2:        TTE
527  * ARG3:        flags (HV_MMU_{IMMU,DMMU})
528  * ERRORS:      EINVAL          Invalid virtual address, mmu context, or flags
529  *              EBADPGSZ        Invalid page size value
530  *              ENORADDR        Invalid real address in TTE
531  *
532  * Create a non-permanent mapping using the given TTE, virtual
533  * address, and mmu context.  The flags argument determines which
534  * (data, or instruction, or both) TLB the mapping gets loaded into.
535  *
536  * The behavior is undefined if the valid bit is clear in the TTE.
537  *
538  * Note: This API call is for privileged code to specify temporary translation
539  *       mappings without the need to create and manage a TSB.
540  */
541
542 /* mmu_unmap_addr()
543  * TRAP:        HV_MMU_UNMAP_ADDR_TRAP
544  * ARG0:        virtual address
545  * ARG1:        mmu context
546  * ARG2:        flags (HV_MMU_{IMMU,DMMU})
547  * ERRORS:      EINVAL          Invalid virtual address, mmu context, or flags
548  *
549  * Demaps the given virtual address in the given mmu context on this
550  * CPU.  This function is intended to be used to demap pages mapped
551  * with mmu_map_addr.  This service is equivalent to invoking
552  * mmu_demap_page() with only the current CPU in the CPU list. The
553  * flags argument determines which (data, or instruction, or both) TLB
554  * the mapping gets unmapped from.
555  *
556  * Attempting to perform an unmap operation for a previously defined
557  * permanent mapping will have undefined results.
558  */
559
560 /* mmu_tsb_ctx0()
561  * TRAP:        HV_FAST_TRAP
562  * FUNCTION:    HV_FAST_MMU_TSB_CTX0
563  * ARG0:        number of TSB descriptions
564  * ARG1:        TSB descriptions pointer
565  * RET0:        status
566  * ERRORS:      ENORADDR                Invalid TSB descriptions pointer or
567  *                                      TSB base within a descriptor
568  *              EBADALIGN               TSB descriptions pointer is not aligned
569  *                                      to an 8-byte boundary, or TSB base
570  *                                      within a descriptor is not aligned for
571  *                                      the given TSB size
572  *              EBADPGSZ                Invalid page size in a TSB descriptor
573  *              EBADTSB                 Invalid associativity or size in a TSB
574  *                                      descriptor
575  *              EINVAL                  Invalid number of TSB descriptions, or
576  *                                      invalid context index in a TSB
577  *                                      descriptor, or index page size not
578  *                                      equal to smallest page size in page
579  *                                      size bitmask field.
580  *
581  * Configures the TSBs for the current CPU for virtual addresses with
582  * context zero.  The TSB descriptions pointer is a pointer to an
583  * array of the given number of TSB descriptions.
584  *
585  * Note: The maximum number of TSBs available to a virtual CPU is given by the
586  *       mmu-max-#tsbs property of the cpu's corresponding "cpu" node in the
587  *       machine description.
588  */
589 #define HV_FAST_MMU_TSB_CTX0            0x20
590
591 /* mmu_tsb_ctxnon0()
592  * TRAP:        HV_FAST_TRAP
593  * FUNCTION:    HV_FAST_MMU_TSB_CTXNON0
594  * ARG0:        number of TSB descriptions
595  * ARG1:        TSB descriptions pointer
596  * RET0:        status
597  * ERRORS:      Same as for mmu_tsb_ctx0() above.
598  *
599  * Configures the TSBs for the current CPU for virtual addresses with
600  * non-zero contexts.  The TSB descriptions pointer is a pointer to an
601  * array of the given number of TSB descriptions.
602  *
603  * Note: A maximum of 16 TSBs may be specified in the TSB description list.
604  */
605 #define HV_FAST_MMU_TSB_CTXNON0         0x21
606
607 /* mmu_demap_page()
608  * TRAP:        HV_FAST_TRAP
609  * FUNCTION:    HV_FAST_MMU_DEMAP_PAGE
610  * ARG0:        reserved, must be zero
611  * ARG1:        reserved, must be zero
612  * ARG2:        virtual address
613  * ARG3:        mmu context
614  * ARG4:        flags (HV_MMU_{IMMU,DMMU})
615  * RET0:        status
616  * ERRORS:      EINVAL                  Invalid virutal address, context, or
617  *                                      flags value
618  *              ENOTSUPPORTED           ARG0 or ARG1 is non-zero
619  *
620  * Demaps any page mapping of the given virtual address in the given
621  * mmu context for the current virtual CPU.  Any virtually tagged
622  * caches are guaranteed to be kept consistent.  The flags argument
623  * determines which TLB (instruction, or data, or both) participate in
624  * the operation.
625  *
626  * ARG0 and ARG1 are both reserved and must be set to zero.
627  */
628 #define HV_FAST_MMU_DEMAP_PAGE          0x22
629
630 /* mmu_demap_ctx()
631  * TRAP:        HV_FAST_TRAP
632  * FUNCTION:    HV_FAST_MMU_DEMAP_CTX
633  * ARG0:        reserved, must be zero
634  * ARG1:        reserved, must be zero
635  * ARG2:        mmu context
636  * ARG3:        flags (HV_MMU_{IMMU,DMMU})
637  * RET0:        status
638  * ERRORS:      EINVAL                  Invalid context or flags value
639  *              ENOTSUPPORTED           ARG0 or ARG1 is non-zero
640  *
641  * Demaps all non-permanent virtual page mappings previously specified
642  * for the given context for the current virtual CPU.  Any virtual
643  * tagged caches are guaranteed to be kept consistent.  The flags
644  * argument determines which TLB (instruction, or data, or both)
645  * participate in the operation.
646  *
647  * ARG0 and ARG1 are both reserved and must be set to zero.
648  */
649 #define HV_FAST_MMU_DEMAP_CTX           0x23
650
651 /* mmu_demap_all()
652  * TRAP:        HV_FAST_TRAP
653  * FUNCTION:    HV_FAST_MMU_DEMAP_ALL
654  * ARG0:        reserved, must be zero
655  * ARG1:        reserved, must be zero
656  * ARG2:        flags (HV_MMU_{IMMU,DMMU})
657  * RET0:        status
658  * ERRORS:      EINVAL                  Invalid flags value
659  *              ENOTSUPPORTED           ARG0 or ARG1 is non-zero
660  *
661  * Demaps all non-permanent virtual page mappings previously specified
662  * for the current virtual CPU.  Any virtual tagged caches are
663  * guaranteed to be kept consistent.  The flags argument determines
664  * which TLB (instruction, or data, or both) participate in the
665  * operation.
666  *
667  * ARG0 and ARG1 are both reserved and must be set to zero.
668  */
669 #define HV_FAST_MMU_DEMAP_ALL           0x24
670
671 /* mmu_map_perm_addr()
672  * TRAP:        HV_FAST_TRAP
673  * FUNCTION:    HV_FAST_MMU_MAP_PERM_ADDR
674  * ARG0:        virtual address
675  * ARG1:        reserved, must be zero
676  * ARG2:        TTE
677  * ARG3:        flags (HV_MMU_{IMMU,DMMU})
678  * RET0:        status
679  * ERRORS:      EINVAL                  Invalid virutal address or flags value
680  *              EBADPGSZ                Invalid page size value
681  *              ENORADDR                Invalid real address in TTE
682  *              ETOOMANY                Too many mappings (max of 8 reached)
683  *
684  * Create a permanent mapping using the given TTE and virtual address
685  * for context 0 on the calling virtual CPU.  A maximum of 8 such
686  * permanent mappings may be specified by privileged code.  Mappings
687  * may be removed with mmu_unmap_perm_addr().
688  *
689  * The behavior is undefined if a TTE with the valid bit clear is given.
690  *
691  * Note: This call is used to specify address space mappings for which
692  *       privileged code does not expect to receive misses.  For example,
693  *       this mechanism can be used to map kernel nucleus code and data.
694  */
695 #define HV_FAST_MMU_MAP_PERM_ADDR       0x25
696
697 /* mmu_fault_area_conf()
698  * TRAP:        HV_FAST_TRAP
699  * FUNCTION:    HV_FAST_MMU_FAULT_AREA_CONF
700  * ARG0:        real address
701  * RET0:        status
702  * RET1:        previous mmu fault area real address
703  * ERRORS:      ENORADDR                Invalid real address
704  *              EBADALIGN               Invalid alignment for fault area
705  *
706  * Configure the MMU fault status area for the calling CPU.  A 64-byte
707  * aligned real address specifies where MMU fault status information
708  * is placed.  The return value is the previously specified area, or 0
709  * for the first invocation.  Specifying a fault area at real address
710  * 0 is not allowed.
711  */
712 #define HV_FAST_MMU_FAULT_AREA_CONF     0x26
713
714 /* mmu_enable()
715  * TRAP:        HV_FAST_TRAP
716  * FUNCTION:    HV_FAST_MMU_ENABLE
717  * ARG0:        enable flag
718  * ARG1:        return target address
719  * RET0:        status
720  * ERRORS:      ENORADDR                Invalid real address when disabling
721  *                                      translation.
722  *              EBADALIGN               The return target address is not
723  *                                      aligned to an instruction.
724  *              EINVAL                  The enable flag request the current
725  *                                      operating mode (e.g. disable if already
726  *                                      disabled)
727  *
728  * Enable or disable virtual address translation for the calling CPU
729  * within the virtual machine domain.  If the enable flag is zero,
730  * translation is disabled, any non-zero value will enable
731  * translation.
732  *
733  * When this function returns, the newly selected translation mode
734  * will be active.  If the mmu is being enabled, then the return
735  * target address is a virtual address else it is a real address.
736  *
737  * Upon successful completion, control will be returned to the given
738  * return target address (ie. the cpu will jump to that address).  On
739  * failure, the previous mmu mode remains and the trap simply returns
740  * as normal with the appropriate error code in RET0.
741  */
742 #define HV_FAST_MMU_ENABLE              0x27
743
744 /* mmu_unmap_perm_addr()
745  * TRAP:        HV_FAST_TRAP
746  * FUNCTION:    HV_FAST_MMU_UNMAP_PERM_ADDR
747  * ARG0:        virtual address
748  * ARG1:        reserved, must be zero
749  * ARG2:        flags (HV_MMU_{IMMU,DMMU})
750  * RET0:        status
751  * ERRORS:      EINVAL                  Invalid virutal address or flags value
752  *              ENOMAP                  Specified mapping was not found
753  *
754  * Demaps any permanent page mapping (established via
755  * mmu_map_perm_addr()) at the given virtual address for context 0 on
756  * the current virtual CPU.  Any virtual tagged caches are guaranteed
757  * to be kept consistent.
758  */
759 #define HV_FAST_MMU_UNMAP_PERM_ADDR     0x28
760
761 /* mmu_tsb_ctx0_info()
762  * TRAP:        HV_FAST_TRAP
763  * FUNCTION:    HV_FAST_MMU_TSB_CTX0_INFO
764  * ARG0:        max TSBs
765  * ARG1:        buffer pointer
766  * RET0:        status
767  * RET1:        number of TSBs
768  * ERRORS:      EINVAL                  Supplied buffer is too small
769  *              EBADALIGN               The buffer pointer is badly aligned
770  *              ENORADDR                Invalid real address for buffer pointer
771  *
772  * Return the TSB configuration as previous defined by mmu_tsb_ctx0()
773  * into the provided buffer.  The size of the buffer is given in ARG1
774  * in terms of the number of TSB description entries.
775  *
776  * Upon return, RET1 always contains the number of TSB descriptions
777  * previously configured.  If zero TSBs were configured, EOK is
778  * returned with RET1 containing 0.
779  */
780 #define HV_FAST_MMU_TSB_CTX0_INFO       0x29
781
782 /* mmu_tsb_ctxnon0_info()
783  * TRAP:        HV_FAST_TRAP
784  * FUNCTION:    HV_FAST_MMU_TSB_CTXNON0_INFO
785  * ARG0:        max TSBs
786  * ARG1:        buffer pointer
787  * RET0:        status
788  * RET1:        number of TSBs
789  * ERRORS:      EINVAL                  Supplied buffer is too small
790  *              EBADALIGN               The buffer pointer is badly aligned
791  *              ENORADDR                Invalid real address for buffer pointer
792  *
793  * Return the TSB configuration as previous defined by
794  * mmu_tsb_ctxnon0() into the provided buffer.  The size of the buffer
795  * is given in ARG1 in terms of the number of TSB description entries.
796  *
797  * Upon return, RET1 always contains the number of TSB descriptions
798  * previously configured.  If zero TSBs were configured, EOK is
799  * returned with RET1 containing 0.
800  */
801 #define HV_FAST_MMU_TSB_CTXNON0_INFO    0x2a
802
803 /* mmu_fault_area_info()
804  * TRAP:        HV_FAST_TRAP
805  * FUNCTION:    HV_FAST_MMU_FAULT_AREA_INFO
806  * RET0:        status
807  * RET1:        fault area real address
808  * ERRORS:      No errors defined.
809  *
810  * Return the currently defined MMU fault status area for the current
811  * CPU.  The real address of the fault status area is returned in
812  * RET1, or 0 is returned in RET1 if no fault status area is defined.
813  *
814  * Note: mmu_fault_area_conf() may be called with the return value (RET1)
815  *       from this service if there is a need to save and restore the fault
816  *       area for a cpu.
817  */
818 #define HV_FAST_MMU_FAULT_AREA_INFO     0x2b
819
820 /* Cache and Memory services. */
821
822 /* mem_scrub()
823  * TRAP:        HV_FAST_TRAP
824  * FUNCTION:    HV_FAST_MEM_SCRUB
825  * ARG0:        real address
826  * ARG1:        length
827  * RET0:        status
828  * RET1:        length scrubbed
829  * ERRORS:      ENORADDR        Invalid real address
830  *              EBADALIGN       Start address or length are not correctly
831  *                              aligned
832  *              EINVAL          Length is zero
833  *
834  * Zero the memory contents in the range real address to real address
835  * plus length minus 1.  Also, valid ECC will be generated for that
836  * memory address range.  Scrubbing is started at the given real
837  * address, but may not scrub the entire given length.  The actual
838  * length scrubbed will be returned in RET1.
839  *
840  * The real address and length must be aligned on an 8K boundary, or
841  * contain the start address and length from a sun4v error report.
842  *
843  * Note: There are two uses for this function.  The first use is to block clear
844  *       and initialize memory and the second is to scrub an u ncorrectable
845  *       error reported via a resumable or non-resumable trap.  The second
846  *       use requires the arguments to be equal to the real address and length
847  *       provided in a sun4v memory error report.
848  */
849 #define HV_FAST_MEM_SCRUB               0x31
850
851 /* mem_sync()
852  * TRAP:        HV_FAST_TRAP
853  * FUNCTION:    HV_FAST_MEM_SYNC
854  * ARG0:        real address
855  * ARG1:        length
856  * RET0:        status
857  * RET1:        length synced
858  * ERRORS:      ENORADDR        Invalid real address
859  *              EBADALIGN       Start address or length are not correctly
860  *                              aligned
861  *              EINVAL          Length is zero
862  *
863  * Force the next access within the real address to real address plus
864  * length minus 1 to be fetches from main system memory.  Less than
865  * the given length may be synced, the actual amount synced is
866  * returned in RET1.  The real address and length must be aligned on
867  * an 8K boundary.
868  */
869 #define HV_FAST_MEM_SYNC                0x32
870
871 /* Time of day services.
872  *
873  * The hypervisor maintains the time of day on a per-domain basis.
874  * Changing the time of day in one domain does not affect the time of
875  * day on any other domain.
876  *
877  * Time is described by a single unsigned 64-bit word which is the
878  * number of seconds since the UNIX Epoch (00:00:00 UTC, January 1,
879  * 1970).
880  */
881
882 /* tod_get()
883  * TRAP:        HV_FAST_TRAP
884  * FUNCTION:    HV_FAST_TOD_GET
885  * RET0:        status
886  * RET1:        TOD
887  * ERRORS:      EWOULDBLOCK     TOD resource is temporarily unavailable
888  *              ENOTSUPPORTED   If TOD not supported on this platform
889  *
890  * Return the current time of day.  May block if TOD access is
891  * temporarily not possible.
892  */
893 #define HV_FAST_TOD_GET                 0x50
894
895 /* tod_set()
896  * TRAP:        HV_FAST_TRAP
897  * FUNCTION:    HV_FAST_TOD_SET
898  * ARG0:        TOD
899  * RET0:        status
900  * ERRORS:      EWOULDBLOCK     TOD resource is temporarily unavailable
901  *              ENOTSUPPORTED   If TOD not supported on this platform
902  *
903  * The current time of day is set to the value specified in ARG0.  May
904  * block if TOD access is temporarily not possible.
905  */
906 #define HV_FAST_TOD_SET                 0x51
907
908 /* Console services */
909
910 /* con_getchar()
911  * TRAP:        HV_FAST_TRAP
912  * FUNCTION:    HV_FAST_CONS_GETCHAR
913  * RET0:        status
914  * RET1:        character
915  * ERRORS:      EWOULDBLOCK     No character available.
916  *
917  * Returns a character from the console device.  If no character is
918  * available then an EWOULDBLOCK error is returned.  If a character is
919  * available, then the returned status is EOK and the character value
920  * is in RET1.
921  *
922  * A virtual BREAK is represented by the 64-bit value -1.
923  *
924  * A virtual HUP signal is represented by the 64-bit value -2.
925  */
926 #define HV_FAST_CONS_GETCHAR            0x60
927
928 /* con_putchar()
929  * TRAP:        HV_FAST_TRAP
930  * FUNCTION:    HV_FAST_CONS_PUTCHAR
931  * ARG0:        character
932  * RET0:        status
933  * ERRORS:      EINVAL          Illegal character
934  *              EWOULDBLOCK     Output buffer currently full, would block
935  *
936  * Send a character to the console device.  Only character values
937  * between 0 and 255 may be used.  Values outside this range are
938  * invalid except for the 64-bit value -1 which is used to send a
939  * virtual BREAK.
940  */
941 #define HV_FAST_CONS_PUTCHAR            0x61
942
943 /* con_read()
944  * TRAP:        HV_FAST_TRAP
945  * FUNCTION:    HV_FAST_CONS_READ
946  * ARG0:        buffer real address
947  * ARG1:        buffer size in bytes
948  * RET0:        status
949  * RET1:        bytes read or BREAK or HUP
950  * ERRORS:      EWOULDBLOCK     No character available.
951  *
952  * Reads characters into a buffer from the console device.  If no
953  * character is available then an EWOULDBLOCK error is returned.
954  * If a character is available, then the returned status is EOK
955  * and the number of bytes read into the given buffer is provided
956  * in RET1.
957  *
958  * A virtual BREAK is represented by the 64-bit RET1 value -1.
959  *
960  * A virtual HUP signal is represented by the 64-bit RET1 value -2.
961  *
962  * If BREAK or HUP are indicated, no bytes were read into buffer.
963  */
964 #define HV_FAST_CONS_READ               0x62
965
966 /* con_write()
967  * TRAP:        HV_FAST_TRAP
968  * FUNCTION:    HV_FAST_CONS_WRITE
969  * ARG0:        buffer real address
970  * ARG1:        buffer size in bytes
971  * RET0:        status
972  * RET1:        bytes written
973  * ERRORS:      EWOULDBLOCK     Output buffer currently full, would block
974  *
975  * Send a characters in buffer to the console device.  Breaks must be
976  * sent using con_putchar().
977  */
978 #define HV_FAST_CONS_WRITE              0x63
979
980 #ifndef __ASSEMBLY__
981 extern long sun4v_con_getchar(long *status);
982 extern long sun4v_con_putchar(long c);
983 extern long sun4v_con_read(unsigned long buffer,
984                            unsigned long size,
985                            unsigned long *bytes_read);
986 extern unsigned long sun4v_con_write(unsigned long buffer,
987                                      unsigned long size,
988                                      unsigned long *bytes_written);
989 #endif
990
991 /* Trap trace services.
992  *
993  * The hypervisor provides a trap tracing capability for privileged
994  * code running on each virtual CPU.  Privileged code provides a
995  * round-robin trap trace queue within which the hypervisor writes
996  * 64-byte entries detailing hyperprivileged traps taken n behalf of
997  * privileged code.  This is provided as a debugging capability for
998  * privileged code.
999  *
1000  * The trap trace control structure is 64-bytes long and placed at the
1001  * start (offset 0) of the trap trace buffer, and is described as
1002  * follows:
1003  */
1004 #ifndef __ASSEMBLY__
1005 struct hv_trap_trace_control {
1006         unsigned long           head_offset;
1007         unsigned long           tail_offset;
1008         unsigned long           __reserved[0x30 / sizeof(unsigned long)];
1009 };
1010 #endif
1011 #define HV_TRAP_TRACE_CTRL_HEAD_OFFSET  0x00
1012 #define HV_TRAP_TRACE_CTRL_TAIL_OFFSET  0x08
1013
1014 /* The head offset is the offset of the most recently completed entry
1015  * in the trap-trace buffer.  The tail offset is the offset of the
1016  * next entry to be written.  The control structure is owned and
1017  * modified by the hypervisor.  A guest may not modify the control
1018  * structure contents.  Attempts to do so will result in undefined
1019  * behavior for the guest.
1020  *
1021  * Each trap trace buffer entry is layed out as follows:
1022  */
1023 #ifndef __ASSEMBLY__
1024 struct hv_trap_trace_entry {
1025         unsigned char   type;           /* Hypervisor or guest entry?   */
1026         unsigned char   hpstate;        /* Hyper-privileged state       */
1027         unsigned char   tl;             /* Trap level                   */
1028         unsigned char   gl;             /* Global register level        */
1029         unsigned short  tt;             /* Trap type                    */
1030         unsigned short  tag;            /* Extended trap identifier     */
1031         unsigned long   tstate;         /* Trap state                   */
1032         unsigned long   tick;           /* Tick                         */
1033         unsigned long   tpc;            /* Trap PC                      */
1034         unsigned long   f1;             /* Entry specific               */
1035         unsigned long   f2;             /* Entry specific               */
1036         unsigned long   f3;             /* Entry specific               */
1037         unsigned long   f4;             /* Entry specific               */
1038 };
1039 #endif
1040 #define HV_TRAP_TRACE_ENTRY_TYPE        0x00
1041 #define HV_TRAP_TRACE_ENTRY_HPSTATE     0x01
1042 #define HV_TRAP_TRACE_ENTRY_TL          0x02
1043 #define HV_TRAP_TRACE_ENTRY_GL          0x03
1044 #define HV_TRAP_TRACE_ENTRY_TT          0x04
1045 #define HV_TRAP_TRACE_ENTRY_TAG         0x06
1046 #define HV_TRAP_TRACE_ENTRY_TSTATE      0x08
1047 #define HV_TRAP_TRACE_ENTRY_TICK        0x10
1048 #define HV_TRAP_TRACE_ENTRY_TPC         0x18
1049 #define HV_TRAP_TRACE_ENTRY_F1          0x20
1050 #define HV_TRAP_TRACE_ENTRY_F2          0x28
1051 #define HV_TRAP_TRACE_ENTRY_F3          0x30
1052 #define HV_TRAP_TRACE_ENTRY_F4          0x38
1053
1054 /* The type field is encoded as follows.  */
1055 #define HV_TRAP_TYPE_UNDEF              0x00 /* Entry content undefined     */
1056 #define HV_TRAP_TYPE_HV                 0x01 /* Hypervisor trap entry       */
1057 #define HV_TRAP_TYPE_GUEST              0xff /* Added via ttrace_addentry() */
1058
1059 /* ttrace_buf_conf()
1060  * TRAP:        HV_FAST_TRAP
1061  * FUNCTION:    HV_FAST_TTRACE_BUF_CONF
1062  * ARG0:        real address
1063  * ARG1:        number of entries
1064  * RET0:        status
1065  * RET1:        number of entries
1066  * ERRORS:      ENORADDR        Invalid real address
1067  *              EINVAL          Size is too small
1068  *              EBADALIGN       Real address not aligned on 64-byte boundary
1069  *
1070  * Requests hypervisor trap tracing and declares a virtual CPU's trap
1071  * trace buffer to the hypervisor.  The real address supplies the real
1072  * base address of the trap trace queue and must be 64-byte aligned.
1073  * Specifying a value of 0 for the number of entries disables trap
1074  * tracing for the calling virtual CPU.  The buffer allocated must be
1075  * sized for a power of two number of 64-byte trap trace entries plus
1076  * an initial 64-byte control structure.
1077  * 
1078  * This may be invoked any number of times so that a virtual CPU may
1079  * relocate a trap trace buffer or create "snapshots" of information.
1080  *
1081  * If the real address is illegal or badly aligned, then trap tracing
1082  * is disabled and an error is returned.
1083  *
1084  * Upon failure with EINVAL, this service call returns in RET1 the
1085  * minimum number of buffer entries required.  Upon other failures
1086  * RET1 is undefined.
1087  */
1088 #define HV_FAST_TTRACE_BUF_CONF         0x90
1089
1090 /* ttrace_buf_info()
1091  * TRAP:        HV_FAST_TRAP
1092  * FUNCTION:    HV_FAST_TTRACE_BUF_INFO
1093  * RET0:        status
1094  * RET1:        real address
1095  * RET2:        size
1096  * ERRORS:      None defined.
1097  *
1098  * Returns the size and location of the previously declared trap-trace
1099  * buffer.  In the event that no buffer was previously defined, or the
1100  * buffer is disabled, this call will return a size of zero bytes.
1101  */
1102 #define HV_FAST_TTRACE_BUF_INFO         0x91
1103
1104 /* ttrace_enable()
1105  * TRAP:        HV_FAST_TRAP
1106  * FUNCTION:    HV_FAST_TTRACE_ENABLE
1107  * ARG0:        enable
1108  * RET0:        status
1109  * RET1:        previous enable state
1110  * ERRORS:      EINVAL          No trap trace buffer currently defined
1111  *
1112  * Enable or disable trap tracing, and return the previous enabled
1113  * state in RET1.  Future systems may define various flags for the
1114  * enable argument (ARG0), for the moment a guest should pass
1115  * "(uint64_t) -1" to enable, and "(uint64_t) 0" to disable all
1116  * tracing - which will ensure future compatability.
1117  */
1118 #define HV_FAST_TTRACE_ENABLE           0x92
1119
1120 /* ttrace_freeze()
1121  * TRAP:        HV_FAST_TRAP
1122  * FUNCTION:    HV_FAST_TTRACE_FREEZE
1123  * ARG0:        freeze
1124  * RET0:        status
1125  * RET1:        previous freeze state
1126  * ERRORS:      EINVAL          No trap trace buffer currently defined
1127  *
1128  * Freeze or unfreeze trap tracing, returning the previous freeze
1129  * state in RET1.  A guest should pass a non-zero value to freeze and
1130  * a zero value to unfreeze all tracing.  The returned previous state
1131  * is 0 for not frozen and 1 for frozen.
1132  */
1133 #define HV_FAST_TTRACE_FREEZE           0x93
1134
1135 /* ttrace_addentry()
1136  * TRAP:        HV_TTRACE_ADDENTRY_TRAP
1137  * ARG0:        tag (16-bits)
1138  * ARG1:        data word 0
1139  * ARG2:        data word 1
1140  * ARG3:        data word 2
1141  * ARG4:        data word 3
1142  * RET0:        status
1143  * ERRORS:      EINVAL          No trap trace buffer currently defined
1144  *
1145  * Add an entry to the trap trace buffer.  Upon return only ARG0/RET0
1146  * is modified - none of the other registers holding arguments are
1147  * volatile across this hypervisor service.
1148  */
1149
1150 /* Core dump services.
1151  *
1152  * Since the hypervisor viraulizes and thus obscures a lot of the
1153  * physical machine layout and state, traditional OS crash dumps can
1154  * be difficult to diagnose especially when the problem is a
1155  * configuration error of some sort.
1156  *
1157  * The dump services provide an opaque buffer into which the
1158  * hypervisor can place it's internal state in order to assist in
1159  * debugging such situations.  The contents are opaque and extremely
1160  * platform and hypervisor implementation specific.  The guest, during
1161  * a core dump, requests that the hypervisor update any information in
1162  * the dump buffer in preparation to being dumped as part of the
1163  * domain's memory image.
1164  */
1165
1166 /* dump_buf_update()
1167  * TRAP:        HV_FAST_TRAP
1168  * FUNCTION:    HV_FAST_DUMP_BUF_UPDATE
1169  * ARG0:        real address
1170  * ARG1:        size
1171  * RET0:        status
1172  * RET1:        required size of dump buffer
1173  * ERRORS:      ENORADDR        Invalid real address
1174  *              EBADALIGN       Real address is not aligned on a 64-byte
1175  *                              boundary
1176  *              EINVAL          Size is non-zero but less than minimum size
1177  *                              required
1178  *              ENOTSUPPORTED   Operation not supported on current logical
1179  *                              domain
1180  *
1181  * Declare a domain dump buffer to the hypervisor.  The real address
1182  * provided for the domain dump buffer must be 64-byte aligned.  The
1183  * size specifies the size of the dump buffer and may be larger than
1184  * the minimum size specified in the machine description.  The
1185  * hypervisor will fill the dump buffer with opaque data.
1186  *
1187  * Note: A guest may elect to include dump buffer contents as part of a crash
1188  *       dump to assist with debugging.  This function may be called any number
1189  *       of times so that a guest may relocate a dump buffer, or create
1190  *       "snapshots" of any dump-buffer information.  Each call to
1191  *       dump_buf_update() atomically declares the new dump buffer to the
1192  *       hypervisor.
1193  *
1194  * A specified size of 0 unconfigures the dump buffer.  If the real
1195  * address is illegal or badly aligned, then any currently active dump
1196  * buffer is disabled and an error is returned.
1197  *
1198  * In the event that the call fails with EINVAL, RET1 contains the
1199  * minimum size requires by the hypervisor for a valid dump buffer.
1200  */
1201 #define HV_FAST_DUMP_BUF_UPDATE         0x94
1202
1203 /* dump_buf_info()
1204  * TRAP:        HV_FAST_TRAP
1205  * FUNCTION:    HV_FAST_DUMP_BUF_INFO
1206  * RET0:        status
1207  * RET1:        real address of current dump buffer
1208  * RET2:        size of current dump buffer
1209  * ERRORS:      No errors defined.
1210  *
1211  * Return the currently configures dump buffer description.  A
1212  * returned size of 0 bytes indicates an undefined dump buffer.  In
1213  * this case the return address in RET1 is undefined.
1214  */
1215 #define HV_FAST_DUMP_BUF_INFO           0x95
1216
1217 /* Device interrupt services.
1218  *
1219  * Device interrupts are allocated to system bus bridges by the hypervisor,
1220  * and described to OBP in the machine description.  OBP then describes
1221  * these interrupts to the OS via properties in the device tree.
1222  *
1223  * Terminology:
1224  *
1225  *      cpuid           Unique opaque value which represents a target cpu.
1226  *
1227  *      devhandle       Device handle.  It uniquely identifies a device, and
1228  *                      consistes of the lower 28-bits of the hi-cell of the
1229  *                      first entry of the device's "reg" property in the
1230  *                      OBP device tree.
1231  *
1232  *      devino          Device interrupt number.  Specifies the relative
1233  *                      interrupt number within the device.  The unique
1234  *                      combination of devhandle and devino are used to
1235  *                      identify a specific device interrupt.
1236  *
1237  *                      Note: The devino value is the same as the values in the
1238  *                            "interrupts" property or "interrupt-map" property
1239  *                            in the OBP device tree for that device.
1240  *
1241  *      sysino          System interrupt number.  A 64-bit unsigned interger
1242  *                      representing a unique interrupt within a virtual
1243  *                      machine.
1244  *
1245  *      intr_state      A flag representing the interrupt state for a given
1246  *                      sysino.  The state values are defined below.
1247  *
1248  *      intr_enabled    A flag representing the 'enabled' state for a given
1249  *                      sysino.  The enable values are defined below.
1250  */
1251
1252 #define HV_INTR_STATE_IDLE              0 /* Nothing pending */
1253 #define HV_INTR_STATE_RECEIVED          1 /* Interrupt received by hardware */
1254 #define HV_INTR_STATE_DELIVERED         2 /* Interrupt delivered to queue */
1255
1256 #define HV_INTR_DISABLED                0 /* sysino not enabled */
1257 #define HV_INTR_ENABLED                 1 /* sysino enabled */
1258
1259 /* intr_devino_to_sysino()
1260  * TRAP:        HV_FAST_TRAP
1261  * FUNCTION:    HV_FAST_INTR_DEVINO2SYSINO
1262  * ARG0:        devhandle
1263  * ARG1:        devino
1264  * RET0:        status
1265  * RET1:        sysino
1266  * ERRORS:      EINVAL          Invalid devhandle/devino
1267  *
1268  * Converts a device specific interrupt number of the given
1269  * devhandle/devino into a system specific ino (sysino).
1270  */
1271 #define HV_FAST_INTR_DEVINO2SYSINO      0xa0
1272
1273 #ifndef __ASSEMBLY__
1274 extern unsigned long sun4v_devino_to_sysino(unsigned long devhandle,
1275                                             unsigned long devino);
1276 #endif
1277
1278 /* intr_getenabled()
1279  * TRAP:        HV_FAST_TRAP
1280  * FUNCTION:    HV_FAST_INTR_GETENABLED
1281  * ARG0:        sysino
1282  * RET0:        status
1283  * RET1:        intr_enabled (HV_INTR_{DISABLED,ENABLED})
1284  * ERRORS:      EINVAL          Invalid sysino
1285  *
1286  * Returns interrupt enabled state in RET1 for the interrupt defined
1287  * by the given sysino.
1288  */
1289 #define HV_FAST_INTR_GETENABLED         0xa1
1290
1291 #ifndef __ASSEMBLY__
1292 extern unsigned long sun4v_intr_getenabled(unsigned long sysino);
1293 #endif
1294
1295 /* intr_setenabled()
1296  * TRAP:        HV_FAST_TRAP
1297  * FUNCTION:    HV_FAST_INTR_SETENABLED
1298  * ARG0:        sysino
1299  * ARG1:        intr_enabled (HV_INTR_{DISABLED,ENABLED})
1300  * RET0:        status
1301  * ERRORS:      EINVAL          Invalid sysino or intr_enabled value
1302  *
1303  * Set the 'enabled' state of the interrupt sysino.
1304  */
1305 #define HV_FAST_INTR_SETENABLED         0xa2
1306
1307 #ifndef __ASSEMBLY__
1308 extern unsigned long sun4v_intr_setenabled(unsigned long sysino, unsigned long intr_enabled);
1309 #endif
1310
1311 /* intr_getstate()
1312  * TRAP:        HV_FAST_TRAP
1313  * FUNCTION:    HV_FAST_INTR_GETSTATE
1314  * ARG0:        sysino
1315  * RET0:        status
1316  * RET1:        intr_state (HV_INTR_STATE_*)
1317  * ERRORS:      EINVAL          Invalid sysino
1318  *
1319  * Returns current state of the interrupt defined by the given sysino.
1320  */
1321 #define HV_FAST_INTR_GETSTATE           0xa3
1322
1323 #ifndef __ASSEMBLY__
1324 extern unsigned long sun4v_intr_getstate(unsigned long sysino);
1325 #endif
1326
1327 /* intr_setstate()
1328  * TRAP:        HV_FAST_TRAP
1329  * FUNCTION:    HV_FAST_INTR_SETSTATE
1330  * ARG0:        sysino
1331  * ARG1:        intr_state (HV_INTR_STATE_*)
1332  * RET0:        status
1333  * ERRORS:      EINVAL          Invalid sysino or intr_state value
1334  *
1335  * Sets the current state of the interrupt described by the given sysino
1336  * value.
1337  *
1338  * Note: Setting the state to HV_INTR_STATE_IDLE clears any pending
1339  *       interrupt for sysino.
1340  */
1341 #define HV_FAST_INTR_SETSTATE           0xa4
1342
1343 #ifndef __ASSEMBLY__
1344 extern unsigned long sun4v_intr_setstate(unsigned long sysino, unsigned long intr_state);
1345 #endif
1346
1347 /* intr_gettarget()
1348  * TRAP:        HV_FAST_TRAP
1349  * FUNCTION:    HV_FAST_INTR_GETTARGET
1350  * ARG0:        sysino
1351  * RET0:        status
1352  * RET1:        cpuid
1353  * ERRORS:      EINVAL          Invalid sysino
1354  *
1355  * Returns CPU that is the current target of the interrupt defined by
1356  * the given sysino.  The CPU value returned is undefined if the target
1357  * has not been set via intr_settarget().
1358  */
1359 #define HV_FAST_INTR_GETTARGET          0xa5
1360
1361 #ifndef __ASSEMBLY__
1362 extern unsigned long sun4v_intr_gettarget(unsigned long sysino);
1363 #endif
1364
1365 /* intr_settarget()
1366  * TRAP:        HV_FAST_TRAP
1367  * FUNCTION:    HV_FAST_INTR_SETTARGET
1368  * ARG0:        sysino
1369  * ARG1:        cpuid
1370  * RET0:        status
1371  * ERRORS:      EINVAL          Invalid sysino
1372  *              ENOCPU          Invalid cpuid
1373  *
1374  * Set the target CPU for the interrupt defined by the given sysino.
1375  */
1376 #define HV_FAST_INTR_SETTARGET          0xa6
1377
1378 #ifndef __ASSEMBLY__
1379 extern unsigned long sun4v_intr_settarget(unsigned long sysino, unsigned long cpuid);
1380 #endif
1381
1382 /* PCI IO services.
1383  *
1384  * See the terminology descriptions in the device interrupt services
1385  * section above as those apply here too.  Here are terminology
1386  * definitions specific to these PCI IO services:
1387  *
1388  *      tsbnum          TSB number.  Indentifies which io-tsb is used.
1389  *                      For this version of the specification, tsbnum
1390  *                      must be zero.
1391  *
1392  *      tsbindex        TSB index.  Identifies which entry in the TSB
1393  *                      is used.  The first entry is zero.
1394  *
1395  *      tsbid           A 64-bit aligned data structure which contains
1396  *                      a tsbnum and a tsbindex.  Bits 63:32 contain the
1397  *                      tsbnum and bits 31:00 contain the tsbindex.
1398  *
1399  *                      Use the HV_PCI_TSBID() macro to construct such
1400  *                      values.
1401  *
1402  *      io_attributes   IO attributes for IOMMU mappings.  One of more
1403  *                      of the attritbute bits are stores in a 64-bit
1404  *                      value.  The values are defined below.
1405  *
1406  *      r_addr          64-bit real address
1407  *
1408  *      pci_device      PCI device address.  A PCI device address identifies
1409  *                      a specific device on a specific PCI bus segment.
1410  *                      A PCI device address ia a 32-bit unsigned integer
1411  *                      with the following format:
1412  *
1413  *                              00000000.bbbbbbbb.dddddfff.00000000
1414  *
1415  *                      Use the HV_PCI_DEVICE_BUILD() macro to construct
1416  *                      such values.
1417  *
1418  *      pci_config_offset
1419  *                      PCI configureation space offset.  For conventional
1420  *                      PCI a value between 0 and 255.  For extended
1421  *                      configuration space, a value between 0 and 4095.
1422  *
1423  *                      Note: For PCI configuration space accesses, the offset
1424  *                            must be aligned to the access size.
1425  *
1426  *      error_flag      A return value which specifies if the action succeeded
1427  *                      or failed.  0 means no error, non-0 means some error
1428  *                      occurred while performing the service.
1429  *
1430  *      io_sync_direction
1431  *                      Direction definition for pci_dma_sync(), defined
1432  *                      below in HV_PCI_SYNC_*.
1433  *
1434  *      io_page_list    A list of io_page_addresses, an io_page_address is
1435  *                      a real address.
1436  *
1437  *      io_page_list_p  A pointer to an io_page_list.
1438  *
1439  *      "size based byte swap" - Some functions do size based byte swapping
1440  *                               which allows sw to access pointers and
1441  *                               counters in native form when the processor
1442  *                               operates in a different endianness than the
1443  *                               IO bus.  Size-based byte swapping converts a
1444  *                               multi-byte field between big-endian and
1445  *                               little-endian format.
1446  */
1447
1448 #define HV_PCI_MAP_ATTR_READ            0x01
1449 #define HV_PCI_MAP_ATTR_WRITE           0x02
1450
1451 #define HV_PCI_DEVICE_BUILD(b,d,f)      \
1452         ((((b) & 0xff) << 16) | \
1453          (((d) & 0x1f) << 11) | \
1454          (((f) & 0x07) <<  8))
1455
1456 #define HV_PCI_TSBID(__tsb_num, __tsb_index) \
1457         ((((u64)(__tsb_num)) << 32UL) | ((u64)(__tsb_index)))
1458
1459 #define HV_PCI_SYNC_FOR_DEVICE          0x01
1460 #define HV_PCI_SYNC_FOR_CPU             0x02
1461
1462 /* pci_iommu_map()
1463  * TRAP:        HV_FAST_TRAP
1464  * FUNCTION:    HV_FAST_PCI_IOMMU_MAP
1465  * ARG0:        devhandle
1466  * ARG1:        tsbid
1467  * ARG2:        #ttes
1468  * ARG3:        io_attributes
1469  * ARG4:        io_page_list_p
1470  * RET0:        status
1471  * RET1:        #ttes mapped
1472  * ERRORS:      EINVAL          Invalid devhandle/tsbnum/tsbindex/io_attributes
1473  *              EBADALIGN       Improperly aligned real address
1474  *              ENORADDR        Invalid real address
1475  *
1476  * Create IOMMU mappings in the sun4v device defined by the given
1477  * devhandle.  The mappings are created in the TSB defined by the
1478  * tsbnum component of the given tsbid.  The first mapping is created
1479  * in the TSB i ndex defined by the tsbindex component of the given tsbid.
1480  * The call creates up to #ttes mappings, the first one at tsbnum, tsbindex,
1481  * the second at tsbnum, tsbindex + 1, etc.
1482  *
1483  * All mappings are created with the attributes defined by the io_attributes
1484  * argument.  The page mapping addresses are described in the io_page_list
1485  * defined by the given io_page_list_p, which is a pointer to the io_page_list.
1486  * The first entry in the io_page_list is the address for the first iotte, the
1487  * 2nd for the 2nd iotte, and so on.
1488  *
1489  * Each io_page_address in the io_page_list must be appropriately aligned.
1490  * #ttes must be greater than zero.  For this version of the spec, the tsbnum
1491  * component of the given tsbid must be zero.
1492  *
1493  * Returns the actual number of mappings creates, which may be less than
1494  * or equal to the argument #ttes.  If the function returns a value which
1495  * is less than the #ttes, the caller may continus to call the function with
1496  * an updated tsbid, #ttes, io_page_list_p arguments until all pages are
1497  * mapped.
1498  *
1499  * Note: This function does not imply an iotte cache flush.  The guest must
1500  *       demap an entry before re-mapping it.
1501  */
1502 #define HV_FAST_PCI_IOMMU_MAP           0xb0
1503
1504 /* pci_iommu_demap()
1505  * TRAP:        HV_FAST_TRAP
1506  * FUNCTION:    HV_FAST_PCI_IOMMU_DEMAP
1507  * ARG0:        devhandle
1508  * ARG1:        tsbid
1509  * ARG2:        #ttes
1510  * RET0:        status
1511  * RET1:        #ttes demapped
1512  * ERRORS:      EINVAL          Invalid devhandle/tsbnum/tsbindex
1513  *
1514  * Demap and flush IOMMU mappings in the device defined by the given
1515  * devhandle.  Demaps up to #ttes entries in the TSB defined by the tsbnum
1516  * component of the given tsbid, starting at the TSB index defined by the
1517  * tsbindex component of the given tsbid.
1518  *
1519  * For this version of the spec, the tsbnum of the given tsbid must be zero.
1520  * #ttes must be greater than zero.
1521  *
1522  * Returns the actual number of ttes demapped, which may be less than or equal
1523  * to the argument #ttes.  If #ttes demapped is less than #ttes, the caller
1524  * may continue to call this function with updated tsbid and #ttes arguments
1525  * until all pages are demapped.
1526  *
1527  * Note: Entries do not have to be mapped to be demapped.  A demap of an
1528  *       unmapped page will flush the entry from the tte cache.
1529  */
1530 #define HV_FAST_PCI_IOMMU_DEMAP         0xb1
1531
1532 /* pci_iommu_getmap()
1533  * TRAP:        HV_FAST_TRAP
1534  * FUNCTION:    HV_FAST_PCI_IOMMU_GETMAP
1535  * ARG0:        devhandle
1536  * ARG1:        tsbid
1537  * RET0:        status
1538  * RET1:        io_attributes
1539  * RET2:        real address
1540  * ERRORS:      EINVAL          Invalid devhandle/tsbnum/tsbindex
1541  *              ENOMAP          Mapping is not valid, no translation exists
1542  *
1543  * Read and return the mapping in the device described by the given devhandle
1544  * and tsbid.  If successful, the io_attributes shall be returned in RET1
1545  * and the page address of the mapping shall be returned in RET2.
1546  *
1547  * For this version of the spec, the tsbnum component of the given tsbid
1548  * must be zero.
1549  */
1550 #define HV_FAST_PCI_IOMMU_GETMAP        0xb2
1551
1552 /* pci_iommu_getbypass()
1553  * TRAP:        HV_FAST_TRAP
1554  * FUNCTION:    HV_FAST_PCI_IOMMU_GETBYPASS
1555  * ARG0:        devhandle
1556  * ARG1:        real address
1557  * ARG2:        io_attributes
1558  * RET0:        status
1559  * RET1:        io_addr
1560  * ERRORS:      EINVAL          Invalid devhandle/io_attributes
1561  *              ENORADDR        Invalid real address
1562  *              ENOTSUPPORTED   Function not supported in this implementation.
1563  *
1564  * Create a "special" mapping in the device described by the given devhandle,
1565  * for the given real address and attributes.  Return the IO address in RET1
1566  * if successful.
1567  */
1568 #define HV_FAST_PCI_IOMMU_GETBYPASS     0xb3
1569
1570 /* pci_config_get()
1571  * TRAP:        HV_FAST_TRAP
1572  * FUNCTION:    HV_FAST_PCI_CONFIG_GET
1573  * ARG0:        devhandle
1574  * ARG1:        pci_device
1575  * ARG2:        pci_config_offset
1576  * ARG3:        size
1577  * RET0:        status
1578  * RET1:        error_flag
1579  * RET2:        data
1580  * ERRORS:      EINVAL          Invalid devhandle/pci_device/offset/size
1581  *              EBADALIGN       pci_config_offset not size aligned
1582  *              ENOACCESS       Access to this offset is not permitted
1583  *
1584  * Read PCI configuration space for the adapter described by the given
1585  * devhandle.  Read size (1, 2, or 4) bytes of data from the given
1586  * pci_device, at pci_config_offset from the beginning of the device's
1587  * configuration space.  If there was no error, RET1 is set to zero and
1588  * RET2 is set to the data read.  Insignificant bits in RET2 are not
1589  * guarenteed to have any specific value and therefore must be ignored.
1590  *
1591  * The data returned in RET2 is size based byte swapped.
1592  *
1593  * If an error occurs during the read, set RET1 to a non-zero value.  The
1594  * given pci_config_offset must be 'size' aligned.
1595  */
1596 #define HV_FAST_PCI_CONFIG_GET          0xb4
1597
1598 /* pci_config_put()
1599  * TRAP:        HV_FAST_TRAP
1600  * FUNCTION:    HV_FAST_PCI_CONFIG_PUT
1601  * ARG0:        devhandle
1602  * ARG1:        pci_device
1603  * ARG2:        pci_config_offset
1604  * ARG3:        size
1605  * ARG4:        data
1606  * RET0:        status
1607  * RET1:        error_flag
1608  * ERRORS:      EINVAL          Invalid devhandle/pci_device/offset/size
1609  *              EBADALIGN       pci_config_offset not size aligned
1610  *              ENOACCESS       Access to this offset is not permitted
1611  *
1612  * Write PCI configuration space for the adapter described by the given
1613  * devhandle.  Write size (1, 2, or 4) bytes of data in a single operation,
1614  * at pci_config_offset from the beginning of the device's configuration
1615  * space.  The data argument contains the data to be written to configuration
1616  * space.  Prior to writing, the data is size based byte swapped.
1617  *
1618  * If an error occurs during the write access, do not generate an error
1619  * report, do set RET1 to a non-zero value.  Otherwise RET1 is zero.
1620  * The given pci_config_offset must be 'size' aligned.
1621  *
1622  * This function is permitted to read from offset zero in the configuration
1623  * space described by the given pci_device if necessary to ensure that the
1624  * write access to config space completes.
1625  */
1626 #define HV_FAST_PCI_CONFIG_PUT          0xb5
1627
1628 /* pci_peek()
1629  * TRAP:        HV_FAST_TRAP
1630  * FUNCTION:    HV_FAST_PCI_PEEK
1631  * ARG0:        devhandle
1632  * ARG1:        real address
1633  * ARG2:        size
1634  * RET0:        status
1635  * RET1:        error_flag
1636  * RET2:        data
1637  * ERRORS:      EINVAL          Invalid devhandle or size
1638  *              EBADALIGN       Improperly aligned real address
1639  *              ENORADDR        Bad real address
1640  *              ENOACCESS       Guest access prohibited
1641  *
1642  * Attempt to read the IO address given by the given devhandle, real address,
1643  * and size.  Size must be 1, 2, 4, or 8.  The read is performed as a single
1644  * access operation using the given size.  If an error occurs when reading
1645  * from the given location, do not generate an error report, but return a
1646  * non-zero value in RET1.  If the read was successful, return zero in RET1
1647  * and return the actual data read in RET2.  The data returned is size based
1648  * byte swapped.
1649  *
1650  * Non-significant bits in RET2 are not guarenteed to have any specific value
1651  * and therefore must be ignored.  If RET1 is returned as non-zero, the data 
1652  * value is not guarenteed to have any specific value and should be ignored.
1653  *
1654  * The caller must have permission to read from the given devhandle, real
1655  * address, which must be an IO address.  The argument real address must be a
1656  * size aligned address.
1657  *
1658  * The hypervisor implementation of this function must block access to any
1659  * IO address that the guest does not have explicit permission to access.
1660  */
1661 #define HV_FAST_PCI_PEEK                0xb6
1662
1663 /* pci_poke()
1664  * TRAP:        HV_FAST_TRAP
1665  * FUNCTION:    HV_FAST_PCI_POKE
1666  * ARG0:        devhandle
1667  * ARG1:        real address
1668  * ARG2:        size
1669  * ARG3:        data
1670  * ARG4:        pci_device
1671  * RET0:        status
1672  * RET1:        error_flag
1673  * ERRORS:      EINVAL          Invalid devhandle, size, or pci_device
1674  *              EBADALIGN       Improperly aligned real address
1675  *              ENORADDR        Bad real address
1676  *              ENOACCESS       Guest access prohibited
1677  *              ENOTSUPPORTED   Function is not supported by implementation
1678  *
1679  * Attempt to write data to the IO address given by the given devhandle,
1680  * real address, and size.  Size must be 1, 2, 4, or 8.  The write is
1681  * performed as a single access operation using the given size. Prior to
1682  * writing the data is size based swapped.
1683  *
1684  * If an error occurs when writing to the given location, do not generate an
1685  * error report, but return a non-zero value in RET1.  If the write was
1686  * successful, return zero in RET1.
1687  *
1688  * pci_device describes the configuration address of the device being
1689  * written to.  The implementation may safely read from offset 0 with
1690  * the configuration space of the device described by devhandle and
1691  * pci_device in order to guarantee that the write portion of the operation
1692  * completes
1693  *
1694  * Any error that occurs due to the read shall be reported using the normal
1695  * error reporting mechanisms .. the read error is not suppressed.
1696  *
1697  * The caller must have permission to write to the given devhandle, real
1698  * address, which must be an IO address.  The argument real address must be a
1699  * size aligned address.  The caller must have permission to read from
1700  * the given devhandle, pci_device cofiguration space offset 0.
1701  *
1702  * The hypervisor implementation of this function must block access to any
1703  * IO address that the guest does not have explicit permission to access.
1704  */
1705 #define HV_FAST_PCI_POKE                0xb7
1706
1707 /* pci_dma_sync()
1708  * TRAP:        HV_FAST_TRAP
1709  * FUNCTION:    HV_FAST_PCI_DMA_SYNC
1710  * ARG0:        devhandle
1711  * ARG1:        real address
1712  * ARG2:        size
1713  * ARG3:        io_sync_direction
1714  * RET0:        status
1715  * RET1:        #synced
1716  * ERRORS:      EINVAL          Invalid devhandle or io_sync_direction
1717  *              ENORADDR        Bad real address
1718  *
1719  * Synchronize a memory region described by the given real address and size,
1720  * for the device defined by the given devhandle using the direction(s)
1721  * defined by the given io_sync_direction.  The argument size is the size of
1722  * the memory region in bytes.
1723  *
1724  * Return the actual number of bytes synchronized in the return value #synced,
1725  * which may be less than or equal to the argument size.  If the return
1726  * value #synced is less than size, the caller must continue to call this
1727  * function with updated real address and size arguments until the entire
1728  * memory region is synchronized.
1729  */
1730 #define HV_FAST_PCI_DMA_SYNC            0xb8
1731
1732 /* PCI MSI services.  */
1733
1734 #define HV_MSITYPE_MSI32                0x00
1735 #define HV_MSITYPE_MSI64                0x01
1736
1737 #define HV_MSIQSTATE_IDLE               0x00
1738 #define HV_MSIQSTATE_ERROR              0x01
1739
1740 #define HV_MSIQ_INVALID                 0x00
1741 #define HV_MSIQ_VALID                   0x01
1742
1743 #define HV_MSISTATE_IDLE                0x00
1744 #define HV_MSISTATE_DELIVERED           0x01
1745
1746 #define HV_MSIVALID_INVALID             0x00
1747 #define HV_MSIVALID_VALID               0x01
1748
1749 #define HV_PCIE_MSGTYPE_PME_MSG         0x18
1750 #define HV_PCIE_MSGTYPE_PME_ACK_MSG     0x1b
1751 #define HV_PCIE_MSGTYPE_CORR_MSG        0x30
1752 #define HV_PCIE_MSGTYPE_NONFATAL_MSG    0x31
1753 #define HV_PCIE_MSGTYPE_FATAL_MSG       0x33
1754
1755 #define HV_MSG_INVALID                  0x00
1756 #define HV_MSG_VALID                    0x01
1757
1758 /* pci_msiq_conf()
1759  * TRAP:        HV_FAST_TRAP
1760  * FUNCTION:    HV_FAST_PCI_MSIQ_CONF
1761  * ARG0:        devhandle
1762  * ARG1:        msiqid
1763  * ARG2:        real address
1764  * ARG3:        number of entries
1765  * RET0:        status
1766  * ERRORS:      EINVAL          Invalid devhandle, msiqid or nentries
1767  *              EBADALIGN       Improperly aligned real address
1768  *              ENORADDR        Bad real address
1769  *
1770  * Configure the MSI queue given by the devhandle and msiqid arguments,
1771  * and to be placed at the given real address and be of the given
1772  * number of entries.  The real address must be aligned exactly to match
1773  * the queue size.  Each queue entry is 64-bytes long, so f.e. a 32 entry
1774  * queue must be aligned on a 2048 byte real address boundary.  The MSI-EQ
1775  * Head and Tail are initialized so that the MSI-EQ is 'empty'.
1776  *
1777  * Implementation Note: Certain implementations have fixed sized queues.  In
1778  *                      that case, number of entries must contain the correct
1779  *                      value.
1780  */
1781 #define HV_FAST_PCI_MSIQ_CONF           0xc0
1782
1783 /* pci_msiq_info()
1784  * TRAP:        HV_FAST_TRAP
1785  * FUNCTION:    HV_FAST_PCI_MSIQ_INFO
1786  * ARG0:        devhandle
1787  * ARG1:        msiqid
1788  * RET0:        status
1789  * RET1:        real address
1790  * RET2:        number of entries
1791  * ERRORS:      EINVAL          Invalid devhandle or msiqid
1792  *
1793  * Return the configuration information for the MSI queue described
1794  * by the given devhandle and msiqid.  The base address of the queue
1795  * is returned in ARG1 and the number of entries is returned in ARG2.
1796  * If the queue is unconfigured, the real address is undefined and the
1797  * number of entries will be returned as zero.
1798  */
1799 #define HV_FAST_PCI_MSIQ_INFO           0xc1
1800
1801 /* pci_msiq_getvalid()
1802  * TRAP:        HV_FAST_TRAP
1803  * FUNCTION:    HV_FAST_PCI_MSIQ_GETVALID
1804  * ARG0:        devhandle
1805  * ARG1:        msiqid
1806  * RET0:        status
1807  * RET1:        msiqvalid       (HV_MSIQ_VALID or HV_MSIQ_INVALID)
1808  * ERRORS:      EINVAL          Invalid devhandle or msiqid
1809  *
1810  * Get the valid state of the MSI-EQ described by the given devhandle and
1811  * msiqid.
1812  */
1813 #define HV_FAST_PCI_MSIQ_GETVALID       0xc2
1814
1815 /* pci_msiq_setvalid()
1816  * TRAP:        HV_FAST_TRAP
1817  * FUNCTION:    HV_FAST_PCI_MSIQ_SETVALID
1818  * ARG0:        devhandle
1819  * ARG1:        msiqid
1820  * ARG2:        msiqvalid       (HV_MSIQ_VALID or HV_MSIQ_INVALID)
1821  * RET0:        status
1822  * ERRORS:      EINVAL          Invalid devhandle or msiqid or msiqvalid
1823  *                              value or MSI EQ is uninitialized
1824  *
1825  * Set the valid state of the MSI-EQ described by the given devhandle and
1826  * msiqid to the given msiqvalid.
1827  */
1828 #define HV_FAST_PCI_MSIQ_SETVALID       0xc3
1829
1830 /* pci_msiq_getstate()
1831  * TRAP:        HV_FAST_TRAP
1832  * FUNCTION:    HV_FAST_PCI_MSIQ_GETSTATE
1833  * ARG0:        devhandle
1834  * ARG1:        msiqid
1835  * RET0:        status
1836  * RET1:        msiqstate       (HV_MSIQSTATE_IDLE or HV_MSIQSTATE_ERROR)
1837  * ERRORS:      EINVAL          Invalid devhandle or msiqid
1838  *
1839  * Get the state of the MSI-EQ described by the given devhandle and
1840  * msiqid.
1841  */
1842 #define HV_FAST_PCI_MSIQ_GETSTATE       0xc4
1843
1844 /* pci_msiq_getvalid()
1845  * TRAP:        HV_FAST_TRAP
1846  * FUNCTION:    HV_FAST_PCI_MSIQ_GETVALID
1847  * ARG0:        devhandle
1848  * ARG1:        msiqid
1849  * ARG2:        msiqstate       (HV_MSIQSTATE_IDLE or HV_MSIQSTATE_ERROR)
1850  * RET0:        status
1851  * ERRORS:      EINVAL          Invalid devhandle or msiqid or msiqstate
1852  *                              value or MSI EQ is uninitialized
1853  *
1854  * Set the state of the MSI-EQ described by the given devhandle and
1855  * msiqid to the given msiqvalid.
1856  */
1857 #define HV_FAST_PCI_MSIQ_SETSTATE       0xc5
1858
1859 /* pci_msiq_gethead()
1860  * TRAP:        HV_FAST_TRAP
1861  * FUNCTION:    HV_FAST_PCI_MSIQ_GETHEAD
1862  * ARG0:        devhandle
1863  * ARG1:        msiqid
1864  * RET0:        status
1865  * RET1:        msiqhead
1866  * ERRORS:      EINVAL          Invalid devhandle or msiqid
1867  *
1868  * Get the current MSI EQ queue head for the MSI-EQ described by the
1869  * given devhandle and msiqid.
1870  */
1871 #define HV_FAST_PCI_MSIQ_GETHEAD        0xc6
1872
1873 /* pci_msiq_sethead()
1874  * TRAP:        HV_FAST_TRAP
1875  * FUNCTION:    HV_FAST_PCI_MSIQ_SETHEAD
1876  * ARG0:        devhandle
1877  * ARG1:        msiqid
1878  * ARG2:        msiqhead
1879  * RET0:        status
1880  * ERRORS:      EINVAL          Invalid devhandle or msiqid or msiqhead,
1881  *                              or MSI EQ is uninitialized
1882  *
1883  * Set the current MSI EQ queue head for the MSI-EQ described by the
1884  * given devhandle and msiqid.
1885  */
1886 #define HV_FAST_PCI_MSIQ_SETHEAD        0xc7
1887
1888 /* pci_msiq_gettail()
1889  * TRAP:        HV_FAST_TRAP
1890  * FUNCTION:    HV_FAST_PCI_MSIQ_GETTAIL
1891  * ARG0:        devhandle
1892  * ARG1:        msiqid
1893  * RET0:        status
1894  * RET1:        msiqtail
1895  * ERRORS:      EINVAL          Invalid devhandle or msiqid
1896  *
1897  * Get the current MSI EQ queue tail for the MSI-EQ described by the
1898  * given devhandle and msiqid.
1899  */
1900 #define HV_FAST_PCI_MSIQ_GETTAIL        0xc8
1901
1902 /* pci_msi_getvalid()
1903  * TRAP:        HV_FAST_TRAP
1904  * FUNCTION:    HV_FAST_PCI_MSI_GETVALID
1905  * ARG0:        devhandle
1906  * ARG1:        msinum
1907  * RET0:        status
1908  * RET1:        msivalidstate
1909  * ERRORS:      EINVAL          Invalid devhandle or msinum
1910  *
1911  * Get the current valid/enabled state for the MSI defined by the
1912  * given devhandle and msinum.
1913  */
1914 #define HV_FAST_PCI_MSI_GETVALID        0xc9
1915
1916 /* pci_msi_setvalid()
1917  * TRAP:        HV_FAST_TRAP
1918  * FUNCTION:    HV_FAST_PCI_MSI_SETVALID
1919  * ARG0:        devhandle
1920  * ARG1:        msinum
1921  * ARG2:        msivalidstate
1922  * RET0:        status
1923  * ERRORS:      EINVAL          Invalid devhandle or msinum or msivalidstate
1924  *
1925  * Set the current valid/enabled state for the MSI defined by the
1926  * given devhandle and msinum.
1927  */
1928 #define HV_FAST_PCI_MSI_SETVALID        0xca
1929
1930 /* pci_msi_getmsiq()
1931  * TRAP:        HV_FAST_TRAP
1932  * FUNCTION:    HV_FAST_PCI_MSI_GETMSIQ
1933  * ARG0:        devhandle
1934  * ARG1:        msinum
1935  * RET0:        status
1936  * RET1:        msiqid
1937  * ERRORS:      EINVAL          Invalid devhandle or msinum or MSI is unbound
1938  *
1939  * Get the MSI EQ that the MSI defined by the given devhandle and
1940  * msinum is bound to.
1941  */
1942 #define HV_FAST_PCI_MSI_GETMSIQ         0xcb
1943
1944 /* pci_msi_setmsiq()
1945  * TRAP:        HV_FAST_TRAP
1946  * FUNCTION:    HV_FAST_PCI_MSI_SETMSIQ
1947  * ARG0:        devhandle
1948  * ARG1:        msinum
1949  * ARG2:        msitype
1950  * ARG3:        msiqid
1951  * RET0:        status
1952  * ERRORS:      EINVAL          Invalid devhandle or msinum or msiqid
1953  *
1954  * Set the MSI EQ that the MSI defined by the given devhandle and
1955  * msinum is bound to.
1956  */
1957 #define HV_FAST_PCI_MSI_SETMSIQ         0xcc
1958
1959 /* pci_msi_getstate()
1960  * TRAP:        HV_FAST_TRAP
1961  * FUNCTION:    HV_FAST_PCI_MSI_GETSTATE
1962  * ARG0:        devhandle
1963  * ARG1:        msinum
1964  * RET0:        status
1965  * RET1:        msistate
1966  * ERRORS:      EINVAL          Invalid devhandle or msinum
1967  *
1968  * Get the state of the MSI defined by the given devhandle and msinum.
1969  * If not initialized, return HV_MSISTATE_IDLE.
1970  */
1971 #define HV_FAST_PCI_MSI_GETSTATE        0xcd
1972
1973 /* pci_msi_setstate()
1974  * TRAP:        HV_FAST_TRAP
1975  * FUNCTION:    HV_FAST_PCI_MSI_SETSTATE
1976  * ARG0:        devhandle
1977  * ARG1:        msinum
1978  * ARG2:        msistate
1979  * RET0:        status
1980  * ERRORS:      EINVAL          Invalid devhandle or msinum or msistate
1981  *
1982  * Set the state of the MSI defined by the given devhandle and msinum.
1983  */
1984 #define HV_FAST_PCI_MSI_SETSTATE        0xce
1985
1986 /* pci_msg_getmsiq()
1987  * TRAP:        HV_FAST_TRAP
1988  * FUNCTION:    HV_FAST_PCI_MSG_GETMSIQ
1989  * ARG0:        devhandle
1990  * ARG1:        msgtype
1991  * RET0:        status
1992  * RET1:        msiqid
1993  * ERRORS:      EINVAL          Invalid devhandle or msgtype
1994  *
1995  * Get the MSI EQ of the MSG defined by the given devhandle and msgtype.
1996  */
1997 #define HV_FAST_PCI_MSG_GETMSIQ         0xd0
1998
1999 /* pci_msg_setmsiq()
2000  * TRAP:        HV_FAST_TRAP
2001  * FUNCTION:    HV_FAST_PCI_MSG_SETMSIQ
2002  * ARG0:        devhandle
2003  * ARG1:        msgtype
2004  * ARG2:        msiqid
2005  * RET0:        status
2006  * ERRORS:      EINVAL          Invalid devhandle, msgtype, or msiqid
2007  *
2008  * Set the MSI EQ of the MSG defined by the given devhandle and msgtype.
2009  */
2010 #define HV_FAST_PCI_MSG_SETMSIQ         0xd1
2011
2012 /* pci_msg_getvalid()
2013  * TRAP:        HV_FAST_TRAP
2014  * FUNCTION:    HV_FAST_PCI_MSG_GETVALID
2015  * ARG0:        devhandle
2016  * ARG1:        msgtype
2017  * RET0:        status
2018  * RET1:        msgvalidstate
2019  * ERRORS:      EINVAL          Invalid devhandle or msgtype
2020  *
2021  * Get the valid/enabled state of the MSG defined by the given
2022  * devhandle and msgtype.
2023  */
2024 #define HV_FAST_PCI_MSG_GETVALID        0xd2
2025
2026 /* pci_msg_setvalid()
2027  * TRAP:        HV_FAST_TRAP
2028  * FUNCTION:    HV_FAST_PCI_MSG_SETVALID
2029  * ARG0:        devhandle
2030  * ARG1:        msgtype
2031  * ARG2:        msgvalidstate
2032  * RET0:        status
2033  * ERRORS:      EINVAL          Invalid devhandle or msgtype or msgvalidstate
2034  *
2035  * Set the valid/enabled state of the MSG defined by the given
2036  * devhandle and msgtype.
2037  */
2038 #define HV_FAST_PCI_MSG_SETVALID        0xd3
2039
2040 /* Performance counter services.  */
2041
2042 #define HV_PERF_JBUS_PERF_CTRL_REG      0x00
2043 #define HV_PERF_JBUS_PERF_CNT_REG       0x01
2044 #define HV_PERF_DRAM_PERF_CTRL_REG_0    0x02
2045 #define HV_PERF_DRAM_PERF_CNT_REG_0     0x03
2046 #define HV_PERF_DRAM_PERF_CTRL_REG_1    0x04
2047 #define HV_PERF_DRAM_PERF_CNT_REG_1     0x05
2048 #define HV_PERF_DRAM_PERF_CTRL_REG_2    0x06
2049 #define HV_PERF_DRAM_PERF_CNT_REG_2     0x07
2050 #define HV_PERF_DRAM_PERF_CTRL_REG_3    0x08
2051 #define HV_PERF_DRAM_PERF_CNT_REG_3     0x09
2052
2053 /* get_perfreg()
2054  * TRAP:        HV_FAST_TRAP
2055  * FUNCTION:    HV_FAST_GET_PERFREG
2056  * ARG0:        performance reg number
2057  * RET0:        status
2058  * RET1:        performance reg value
2059  * ERRORS:      EINVAL          Invalid performance register number
2060  *              ENOACCESS       No access allowed to performance counters
2061  *
2062  * Read the value of the given DRAM/JBUS performance counter/control register.
2063  */
2064 #define HV_FAST_GET_PERFREG             0x100
2065
2066 /* set_perfreg()
2067  * TRAP:        HV_FAST_TRAP
2068  * FUNCTION:    HV_FAST_SET_PERFREG
2069  * ARG0:        performance reg number
2070  * ARG1:        performance reg value
2071  * RET0:        status
2072  * ERRORS:      EINVAL          Invalid performance register number
2073  *              ENOACCESS       No access allowed to performance counters
2074  *
2075  * Write the given performance reg value to the given DRAM/JBUS
2076  * performance counter/control register.
2077  */
2078 #define HV_FAST_SET_PERFREG             0x101
2079
2080 /* MMU statistics services.
2081  *
2082  * The hypervisor maintains MMU statistics and privileged code provides
2083  * a buffer where these statistics can be collected.  It is continually
2084  * updated once configured.  The layout is as follows:
2085  */
2086 #ifndef __ASSEMBLY__
2087 struct hv_mmu_statistics {
2088         unsigned long immu_tsb_hits_ctx0_8k_tte;
2089         unsigned long immu_tsb_ticks_ctx0_8k_tte;
2090         unsigned long immu_tsb_hits_ctx0_64k_tte;
2091         unsigned long immu_tsb_ticks_ctx0_64k_tte;
2092         unsigned long __reserved1[2];
2093         unsigned long immu_tsb_hits_ctx0_4mb_tte;
2094         unsigned long immu_tsb_ticks_ctx0_4mb_tte;
2095         unsigned long __reserved2[2];
2096         unsigned long immu_tsb_hits_ctx0_256mb_tte;
2097         unsigned long immu_tsb_ticks_ctx0_256mb_tte;
2098         unsigned long __reserved3[4];
2099         unsigned long immu_tsb_hits_ctxnon0_8k_tte;
2100         unsigned long immu_tsb_ticks_ctxnon0_8k_tte;
2101         unsigned long immu_tsb_hits_ctxnon0_64k_tte;
2102         unsigned long immu_tsb_ticks_ctxnon0_64k_tte;
2103         unsigned long __reserved4[2];
2104         unsigned long immu_tsb_hits_ctxnon0_4mb_tte;
2105         unsigned long immu_tsb_ticks_ctxnon0_4mb_tte;
2106         unsigned long __reserved5[2];
2107         unsigned long immu_tsb_hits_ctxnon0_256mb_tte;
2108         unsigned long immu_tsb_ticks_ctxnon0_256mb_tte;
2109         unsigned long __reserved6[4];
2110         unsigned long dmmu_tsb_hits_ctx0_8k_tte;
2111         unsigned long dmmu_tsb_ticks_ctx0_8k_tte;
2112         unsigned long dmmu_tsb_hits_ctx0_64k_tte;
2113         unsigned long dmmu_tsb_ticks_ctx0_64k_tte;
2114         unsigned long __reserved7[2];
2115         unsigned long dmmu_tsb_hits_ctx0_4mb_tte;
2116         unsigned long dmmu_tsb_ticks_ctx0_4mb_tte;
2117         unsigned long __reserved8[2];
2118         unsigned long dmmu_tsb_hits_ctx0_256mb_tte;
2119         unsigned long dmmu_tsb_ticks_ctx0_256mb_tte;
2120         unsigned long __reserved9[4];
2121         unsigned long dmmu_tsb_hits_ctxnon0_8k_tte;
2122         unsigned long dmmu_tsb_ticks_ctxnon0_8k_tte;
2123         unsigned long dmmu_tsb_hits_ctxnon0_64k_tte;
2124         unsigned long dmmu_tsb_ticks_ctxnon0_64k_tte;
2125         unsigned long __reserved10[2];
2126         unsigned long dmmu_tsb_hits_ctxnon0_4mb_tte;
2127         unsigned long dmmu_tsb_ticks_ctxnon0_4mb_tte;
2128         unsigned long __reserved11[2];
2129         unsigned long dmmu_tsb_hits_ctxnon0_256mb_tte;
2130         unsigned long dmmu_tsb_ticks_ctxnon0_256mb_tte;
2131         unsigned long __reserved12[4];
2132 };
2133 #endif
2134
2135 /* mmustat_conf()
2136  * TRAP:        HV_FAST_TRAP
2137  * FUNCTION:    HV_FAST_MMUSTAT_CONF
2138  * ARG0:        real address
2139  * RET0:        status
2140  * RET1:        real address
2141  * ERRORS:      ENORADDR        Invalid real address
2142  *              EBADALIGN       Real address not aligned on 64-byte boundary
2143  *              EBADTRAP        API not supported on this processor
2144  *
2145  * Enable MMU statistic gathering using the buffer at the given real
2146  * address on the current virtual CPU.  The new buffer real address
2147  * is given in ARG1, and the previously specified buffer real address
2148  * is returned in RET1, or is returned as zero for the first invocation.
2149  *
2150  * If the passed in real address argument is zero, this will disable
2151  * MMU statistic collection on the current virtual CPU.  If an error is
2152  * returned then no statistics are collected.
2153  *
2154  * The buffer contents should be initialized to all zeros before being
2155  * given to the hypervisor or else the statistics will be meaningless.
2156  */
2157 #define HV_FAST_MMUSTAT_CONF            0x102
2158
2159 /* mmustat_info()
2160  * TRAP:        HV_FAST_TRAP
2161  * FUNCTION:    HV_FAST_MMUSTAT_INFO
2162  * RET0:        status
2163  * RET1:        real address
2164  * ERRORS:      EBADTRAP        API not supported on this processor
2165  *
2166  * Return the current state and real address of the currently configured
2167  * MMU statistics buffer on the current virtual CPU.
2168  */
2169 #define HV_FAST_MMUSTAT_INFO            0x103
2170
2171 /* Function numbers for HV_CORE_TRAP.  */
2172 #define HV_CORE_SET_VER                 0x00
2173 #define HV_CORE_PUTCHAR                 0x01
2174 #define HV_CORE_EXIT                    0x02
2175 #define HV_CORE_GET_VER                 0x03
2176
2177 /* Hypervisor API groups for use with HV_CORE_SET_VER and
2178  * HV_CORE_GET_VER.
2179  */
2180 #define HV_GRP_SUN4V                    0x0000
2181 #define HV_GRP_CORE                     0x0001
2182 #define HV_GRP_INTR                     0x0002
2183 #define HV_GRP_SOFT_STATE               0x0003
2184 #define HV_GRP_PCI                      0x0100
2185 #define HV_GRP_LDOM                     0x0101
2186 #define HV_GRP_SVC_CHAN                 0x0102
2187 #define HV_GRP_NCS                      0x0103
2188 #define HV_GRP_NIAG_PERF                0x0200
2189 #define HV_GRP_FIRE_PERF                0x0201
2190 #define HV_GRP_DIAG                     0x0300
2191
2192 #ifndef __ASSEMBLY__
2193 extern unsigned long sun4v_get_version(unsigned long group,
2194                                        unsigned long *major,
2195                                        unsigned long *minor);
2196 extern unsigned long sun4v_set_version(unsigned long group,
2197                                        unsigned long major,
2198                                        unsigned long minor,
2199                                        unsigned long *actual_minor);
2200
2201 extern int sun4v_hvapi_register(unsigned long group, unsigned long major,
2202                                 unsigned long *minor);
2203 extern void sun4v_hvapi_unregister(unsigned long group);
2204 extern int sun4v_hvapi_get(unsigned long group,
2205                            unsigned long *major,
2206                            unsigned long *minor);
2207 #endif
2208
2209 #endif /* !(_SPARC64_HYPERVISOR_H) */