1 /* $NetBSD: arch-ia64.h,v 1.6 2008/05/04 19:56:28 cegger Exp $ */
2 /******************************************************************************
3 * arch-ia64/hypervisor-if.h
5 * Guest OS interface to IA64 Xen.
7 * Permission is hereby granted, free of charge, to any person obtaining a copy
8 * of this software and associated documentation files (the "Software"), to
9 * deal in the Software without restriction, including without limitation the
10 * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
11 * sell copies of the Software, and to permit persons to whom the Software is
12 * furnished to do so, subject to the following conditions:
14 * The above copyright notice and this permission notice shall be included in
15 * all copies or substantial portions of the Software.
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
22 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
23 * DEALINGS IN THE SOFTWARE.
29 #ifndef __HYPERVISOR_IF_IA64_H__
30 #define __HYPERVISOR_IF_IA64_H__
32 #if !defined(__GNUC__) || defined(__STRICT_ANSI__)
33 #error "Anonymous structs/unions are a GNU extension."
36 /* Structural guest handles introduced in 0x00030201. */
37 #if __XEN_INTERFACE_VERSION__ >= 0x00030201
38 #define ___DEFINE_XEN_GUEST_HANDLE(name, type) \
39 typedef struct { type *p; } __guest_handle_ ## name
41 #define ___DEFINE_XEN_GUEST_HANDLE(name, type) \
42 typedef type * __guest_handle_ ## name
45 #define __DEFINE_XEN_GUEST_HANDLE(name, type) \
46 ___DEFINE_XEN_GUEST_HANDLE(name, type); \
47 ___DEFINE_XEN_GUEST_HANDLE(const_##name, const type)
49 #define DEFINE_XEN_GUEST_HANDLE(name) __DEFINE_XEN_GUEST_HANDLE(name, name)
50 #define XEN_GUEST_HANDLE(name) __guest_handle_ ## name
51 #define XEN_GUEST_HANDLE_64(name) XEN_GUEST_HANDLE(name)
52 #define uint64_aligned_t uint64_t
53 #define set_xen_guest_handle(hnd, val) do { (hnd).p = val; } while (0)
55 #define get_xen_guest_handle(val, hnd) do { val = (hnd).p; } while (0)
59 typedef unsigned long xen_pfn_t
;
60 #define PRI_xen_pfn "lx"
63 /* Arch specific VIRQs definition */
64 #define VIRQ_ITC VIRQ_ARCH_0 /* V. Virtual itc timer */
65 #define VIRQ_MCA_CMC VIRQ_ARCH_1 /* MCA cmc interrupt */
66 #define VIRQ_MCA_CPE VIRQ_ARCH_2 /* MCA cpe interrupt */
68 /* Maximum number of virtual CPUs in multi-processor guests. */
69 /* WARNING: before changing this, check that shared_info fits on a page */
70 #define MAX_VIRT_CPUS 64
72 /* IO ports location for PV. */
73 #define IO_PORTS_PADDR 0x00000ffffc000000UL
74 #define IO_PORTS_SIZE 0x0000000004000000UL
78 typedef unsigned long xen_ulong_t
;
81 #define XEN_PAGE_SIZE XC_PAGE_SIZE
83 #define XEN_PAGE_SIZE PAGE_SIZE
86 #define INVALID_MFN (~0UL)
90 unsigned long bits
[2];
91 long double __dummy
; /* force 16-byte alignment */
108 typedef union vac vac_t
;
122 typedef union vdc vdc_t
;
127 unsigned long virt_env_vaddr
;
128 unsigned long reserved1
[29];
130 unsigned long reserved2
[95];
132 unsigned long vgr
[16];
133 unsigned long bank1_regs
[16]; // bank1 regs (r16-r31) when bank0 active
136 unsigned long vbgr
[16];
137 unsigned long bank0_regs
[16]; // bank0 regs (r16-r31) when bank1 active
141 unsigned long vcpuid
[5];
142 unsigned long reserved3
[11];
145 unsigned long reserved4
[76];
147 unsigned long vcr
[128];
149 unsigned long dcr
; // CR0
152 unsigned long rsv1
[5];
153 unsigned long pta
; // CR8
154 unsigned long rsv2
[7];
155 unsigned long ipsr
; // CR16
163 unsigned long iim
; // CR24
165 unsigned long rsv4
[38];
166 unsigned long lid
; // CR64
170 unsigned long irr
[4];
171 unsigned long itv
; // CR72
174 unsigned long rsv5
[5];
175 unsigned long lrr0
; // CR80
177 unsigned long rsv6
[46];
181 unsigned long reserved5
[128];
183 unsigned long precover_ifs
;
184 unsigned long unat
; // not sure if this is needed until NaT arch is done
185 int interrupt_collection_enabled
; // virtual psr.ic
186 /* virtual interrupt deliverable flag is evtchn_upcall_mask in
187 * shared info area now. interrupt_mask_addr is the address
188 * of evtchn_upcall_mask for current vcpu
190 unsigned char *interrupt_mask_addr
;
191 int pending_interruption
;
192 unsigned char vpsr_pp
;
193 unsigned char vpsr_dfh
;
194 unsigned char hpsr_dfh
;
195 unsigned char hpsr_mfh
;
196 unsigned long reserved5_1
[4];
197 int metaphysical_mode
; // 1 = use metaphys mapping, 0 = use virtual
198 int banknum
; // 0 or 1, which virtual register bank is active
199 unsigned long rrs
[8]; // region registers
200 unsigned long krs
[8]; // kernel registers
201 unsigned long tmp
[16]; // temp registers (e.g. for hyperprivops)
205 typedef struct mapped_regs mapped_regs_t
;
208 struct mapped_regs vpd_low
;
209 unsigned long reserved6
[3456];
210 unsigned long vmm_avail
[128];
211 unsigned long reserved7
[4096];
213 typedef struct vpd vpd_t
;
215 struct arch_vcpu_info
{
217 typedef struct arch_vcpu_info arch_vcpu_info_t
;
220 * This structure is used for magic page in domain pseudo physical address
221 * space and the result of XENMEM_machine_memory_map.
222 * As the XENMEM_machine_memory_map result,
223 * xen_memory_map::nr_entries indicates the size in bytes
224 * including struct xen_ia64_memmap_info. Not the number of entries.
226 struct xen_ia64_memmap_info
{
227 uint64_t efi_memmap_size
; /* size of EFI memory map */
228 uint64_t efi_memdesc_size
; /* size of an EFI memory map descriptor */
229 uint32_t efi_memdesc_version
; /* memory descriptor version */
230 void *memdesc
[0]; /* array of efi_memory_desc_t */
232 typedef struct xen_ia64_memmap_info xen_ia64_memmap_info_t
;
234 struct arch_shared_info
{
235 /* PFN of the start_info page. */
236 unsigned long start_info_pfn
;
238 /* Interrupt vector for event channel. */
241 /* PFN of memmap_info page */
242 unsigned int memmap_info_num_pages
;/* currently only = 1 case is
244 unsigned long memmap_info_pfn
;
248 typedef struct arch_shared_info arch_shared_info_t
;
250 typedef unsigned long xen_callback_t
;
252 struct ia64_tr_entry
{
258 typedef struct ia64_tr_entry ia64_tr_entry_t
;
259 DEFINE_XEN_GUEST_HANDLE(ia64_tr_entry_t
);
261 struct vcpu_tr_regs
{
262 struct ia64_tr_entry itrs
[12];
263 struct ia64_tr_entry dtrs
[12];
267 unsigned long ar
[128];
270 unsigned long rsv1
[8];
273 unsigned long bspstore
;
277 unsigned long rsv3
[2];
286 unsigned long ccv
; /* 32 */
287 unsigned long rsv5
[3];
289 unsigned long rsv6
[3];
291 unsigned long rsv7
[3];
293 unsigned long rsv8
[3];
294 unsigned long ign1
[16];
295 unsigned long pfs
; /* 64 */
298 unsigned long rsv9
[45];
299 unsigned long ign2
[16];
304 unsigned long cr
[128];
306 unsigned long dcr
; // CR0
309 unsigned long rsv1
[5];
310 unsigned long pta
; // CR8
311 unsigned long rsv2
[7];
312 unsigned long ipsr
; // CR16
320 unsigned long iim
; // CR24
322 unsigned long rsv4
[38];
323 unsigned long lid
; // CR64
327 unsigned long irr
[4];
328 unsigned long itv
; // CR72
331 unsigned long rsv5
[5];
332 unsigned long lrr0
; // CR80
334 unsigned long rsv6
[46];
338 struct vcpu_guest_context_regs
{
341 unsigned long bank
[16];
346 unsigned int nats
; /* NaT bits for r1-r31. */
347 unsigned int bnats
; /* Nat bits for banked registers. */
348 union vcpu_ar_regs ar
;
349 union vcpu_cr_regs cr
;
350 struct pt_fpreg f
[128];
351 unsigned long dbr
[8];
352 unsigned long ibr
[8];
354 unsigned long pkr
[16];
356 /* FIXME: cpuid,pmd,pmc */
363 struct vcpu_tr_regs tr
;
365 /* Physical registers in case of debug event. */
366 unsigned long excp_iipa
;
367 unsigned long excp_ifa
;
368 unsigned long excp_isr
;
369 unsigned int excp_vector
;
372 * The rbs is intended to be the image of the stacked registers still
373 * in the cpu (not yet stored in memory). It is laid out as if it
374 * were written in memory at a 512 (64*8) aligned address + offset.
375 * rbs_voff is (offset / 8). rbs_nat contains NaT bits for the
376 * remaining rbs registers. rbs_rnat contains NaT bits for in memory
378 * Note: loadrs is 2**14 bytes == 2**11 slots.
380 unsigned int rbs_voff
;
381 unsigned long rbs
[2048];
382 unsigned long rbs_rnat
;
385 * RSE.N_STACKED_PHYS via PAL_RSE_INFO
386 * Strictly this isn't cpu context, but this value is necessary
387 * for domain save/restore. So is here.
389 unsigned long num_phys_stacked
;
392 struct vcpu_guest_context
{
393 #define VGCF_EXTRA_REGS (1UL << 1) /* Set extra regs. */
394 #define VGCF_SET_CR_IRR (1UL << 2) /* Set cr_irr[0:3]. */
395 #define VGCF_online (1UL << 3) /* make this vcpu online */
396 unsigned long flags
; /* VGCF_* flags */
398 struct vcpu_guest_context_regs regs
;
400 unsigned long event_callback_ip
;
402 /* xen doesn't share privregs pages with hvm domain so that this member
403 * doesn't make sense for hvm domain.
404 * ~0UL is already used for INVALID_P2M_ENTRY. */
405 #define VGC_PRIVREGS_HVM (~(-2UL))
406 unsigned long privregs_pfn
;
408 typedef struct vcpu_guest_context vcpu_guest_context_t
;
409 DEFINE_XEN_GUEST_HANDLE(vcpu_guest_context_t
);
412 #define __HYPERVISOR_ia64_dom0vp_op __HYPERVISOR_arch_0
413 /* Map io space in machine address to dom0 physical address space.
414 Currently physical assigned address equals to machine address. */
415 #define IA64_DOM0VP_ioremap 0
417 /* Convert a pseudo physical page frame number to the corresponding
418 machine page frame number. If no page is assigned, INVALID_MFN or
419 GPFN_INV_MASK is returned depending on domain's non-vti/vti mode. */
420 #define IA64_DOM0VP_phystomach 1
422 /* Convert a machine page frame number to the corresponding pseudo physical
423 page frame number of the caller domain. */
424 #define IA64_DOM0VP_machtophys 3
426 /* Reserved for future use. */
427 #define IA64_DOM0VP_iounmap 4
429 /* Unmap and free pages contained in the specified pseudo physical region. */
430 #define IA64_DOM0VP_zap_physmap 5
432 /* Assign machine page frame to dom0's pseudo physical address space. */
433 #define IA64_DOM0VP_add_physmap 6
435 /* expose the p2m table into domain */
436 #define IA64_DOM0VP_expose_p2m 7
439 #define IA64_DOM0VP_perfmon 8
441 /* gmfn version of IA64_DOM0VP_add_physmap */
442 #define IA64_DOM0VP_add_physmap_with_gmfn 9
444 /* get fpswa revision */
445 #define IA64_DOM0VP_fpswa_revision 10
447 /* Add an I/O port space range */
448 #define IA64_DOM0VP_add_io_space 11
450 /* expose the foreign domain's p2m table into privileged domain */
451 #define IA64_DOM0VP_expose_foreign_p2m 12
452 #define IA64_DOM0VP_EFP_ALLOC_PTE 0x1 /* allocate p2m table */
454 /* unexpose the foreign domain's p2m table into privileged domain */
455 #define IA64_DOM0VP_unexpose_foreign_p2m 13
457 // flags for page assignement to pseudo physical address space
458 #define _ASSIGN_readonly 0
459 #define ASSIGN_readonly (1UL << _ASSIGN_readonly)
460 #define ASSIGN_writable (0UL << _ASSIGN_readonly) // dummy flag
461 /* Internal only: memory attribute must be WC/UC/UCE. */
462 #define _ASSIGN_nocache 1
463 #define ASSIGN_nocache (1UL << _ASSIGN_nocache)
465 #define _ASSIGN_tlb_track 2
466 #define ASSIGN_tlb_track (1UL << _ASSIGN_tlb_track)
467 /* Internal only: associated with PGC_allocated bit */
468 #define _ASSIGN_pgc_allocated 3
469 #define ASSIGN_pgc_allocated (1UL << _ASSIGN_pgc_allocated)
470 /* Page is an IO page. */
472 #define ASSIGN_io (1UL << _ASSIGN_io)
474 /* This structure has the same layout of struct ia64_boot_param, defined in
475 <asm/system.h>. It is redefined here to ease use. */
476 struct xen_ia64_boot_param
{
477 unsigned long command_line
; /* physical address of cmd line args */
478 unsigned long efi_systab
; /* physical address of EFI system table */
479 unsigned long efi_memmap
; /* physical address of EFI memory map */
480 unsigned long efi_memmap_size
; /* size of EFI memory map */
481 unsigned long efi_memdesc_size
; /* size of an EFI memory map descriptor */
482 unsigned int efi_memdesc_version
; /* memory descriptor version */
484 unsigned short num_cols
; /* number of columns on console. */
485 unsigned short num_rows
; /* number of rows on console. */
486 unsigned short orig_x
; /* cursor's x position */
487 unsigned short orig_y
; /* cursor's y position */
489 unsigned long fpswa
; /* physical address of the fpswa interface */
490 unsigned long initrd_start
;
491 unsigned long initrd_size
;
492 unsigned long domain_start
; /* va where the boot time domain begins */
493 unsigned long domain_size
; /* how big is the boot domain */
496 #endif /* !__ASSEMBLY__ */
498 /* Size of the shared_info area (this is not related to page size). */
500 #define XSI_SIZE (1 << XSI_SHIFT)
501 /* Log size of mapped_regs area (64 KB - only 4KB is used). */
502 #define XMAPPEDREGS_SHIFT 12
503 #define XMAPPEDREGS_SIZE (1 << XMAPPEDREGS_SHIFT)
504 /* Offset of XASI (Xen arch shared info) wrt XSI_BASE. */
505 #define XMAPPEDREGS_OFS XSI_SIZE
508 #define HYPERPRIVOP_START 0x1
509 #define HYPERPRIVOP_RFI (HYPERPRIVOP_START + 0x0)
510 #define HYPERPRIVOP_RSM_DT (HYPERPRIVOP_START + 0x1)
511 #define HYPERPRIVOP_SSM_DT (HYPERPRIVOP_START + 0x2)
512 #define HYPERPRIVOP_COVER (HYPERPRIVOP_START + 0x3)
513 #define HYPERPRIVOP_ITC_D (HYPERPRIVOP_START + 0x4)
514 #define HYPERPRIVOP_ITC_I (HYPERPRIVOP_START + 0x5)
515 #define HYPERPRIVOP_SSM_I (HYPERPRIVOP_START + 0x6)
516 #define HYPERPRIVOP_GET_IVR (HYPERPRIVOP_START + 0x7)
517 #define HYPERPRIVOP_GET_TPR (HYPERPRIVOP_START + 0x8)
518 #define HYPERPRIVOP_SET_TPR (HYPERPRIVOP_START + 0x9)
519 #define HYPERPRIVOP_EOI (HYPERPRIVOP_START + 0xa)
520 #define HYPERPRIVOP_SET_ITM (HYPERPRIVOP_START + 0xb)
521 #define HYPERPRIVOP_THASH (HYPERPRIVOP_START + 0xc)
522 #define HYPERPRIVOP_PTC_GA (HYPERPRIVOP_START + 0xd)
523 #define HYPERPRIVOP_ITR_D (HYPERPRIVOP_START + 0xe)
524 #define HYPERPRIVOP_GET_RR (HYPERPRIVOP_START + 0xf)
525 #define HYPERPRIVOP_SET_RR (HYPERPRIVOP_START + 0x10)
526 #define HYPERPRIVOP_SET_KR (HYPERPRIVOP_START + 0x11)
527 #define HYPERPRIVOP_FC (HYPERPRIVOP_START + 0x12)
528 #define HYPERPRIVOP_GET_CPUID (HYPERPRIVOP_START + 0x13)
529 #define HYPERPRIVOP_GET_PMD (HYPERPRIVOP_START + 0x14)
530 #define HYPERPRIVOP_GET_EFLAG (HYPERPRIVOP_START + 0x15)
531 #define HYPERPRIVOP_SET_EFLAG (HYPERPRIVOP_START + 0x16)
532 #define HYPERPRIVOP_RSM_BE (HYPERPRIVOP_START + 0x17)
533 #define HYPERPRIVOP_GET_PSR (HYPERPRIVOP_START + 0x18)
534 #define HYPERPRIVOP_SET_RR0_TO_RR4 (HYPERPRIVOP_START + 0x19)
535 #define HYPERPRIVOP_MAX (0x1a)
537 /* Fast and light hypercalls. */
538 #define __HYPERVISOR_ia64_fast_eoi __HYPERVISOR_arch_1
540 /* Extra debug features. */
541 #define __HYPERVISOR_ia64_debug_op __HYPERVISOR_arch_2
543 /* Xencomm macros. */
544 #define XENCOMM_INLINE_MASK 0xf800000000000000UL
545 #define XENCOMM_INLINE_FLAG 0x8000000000000000UL
550 * Optimization features.
551 * The hypervisor may do some special optimizations for guests. This hypercall
552 * can be used to switch on/of these special optimizations.
554 #define __HYPERVISOR_opt_feature 0x700UL
556 #define XEN_IA64_OPTF_OFF 0x0
557 #define XEN_IA64_OPTF_ON 0x1
560 * If this feature is switched on, the hypervisor inserts the
561 * tlb entries without calling the guests traphandler.
562 * This is useful in guests using region 7 for identity mapping
563 * like the linux kernel does.
565 #define XEN_IA64_OPTF_IDENT_MAP_REG7 1
567 /* Identity mapping of region 4 addresses in HVM. */
568 #define XEN_IA64_OPTF_IDENT_MAP_REG4 2
570 /* Identity mapping of region 5 addresses in HVM. */
571 #define XEN_IA64_OPTF_IDENT_MAP_REG5 3
573 #define XEN_IA64_OPTF_IDENT_MAP_NOT_SET (0)
575 struct xen_ia64_opt_feature
{
576 unsigned long cmd
; /* Which feature */
577 unsigned char on
; /* Switch feature on/off */
580 /* The page protection bit mask of the pte.
581 * This will be or'ed with the pte. */
582 unsigned long pgprot
;
583 unsigned long key
; /* A protection key for itir. */
588 #endif /* __ASSEMBLY__ */
593 #ifndef _ASM_IA64_PERFMON_H
595 #include <xen/list.h> // asm/perfmon.h requires struct list_head
596 #include <asm/perfmon.h>
597 // for PFM_xxx and pfarg_features_t, pfarg_context_t, pfarg_reg_t, pfarg_load_t
599 #endif /* _ASM_IA64_PERFMON_H */
601 DEFINE_XEN_GUEST_HANDLE(pfarg_features_t
);
602 DEFINE_XEN_GUEST_HANDLE(pfarg_context_t
);
603 DEFINE_XEN_GUEST_HANDLE(pfarg_reg_t
);
604 DEFINE_XEN_GUEST_HANDLE(pfarg_load_t
);
605 #endif /* __ASSEMBLY__ */
609 #include "arch-ia64/hvm/memmap.h"
612 #endif /* __HYPERVISOR_IF_IA64_H__ */
620 * indent-tabs-mode: nil