win-pvdrivers

view common/include/public/arch-ia64.h @ 146:b474e898b409

patches to change 'long' types in the headers to something that is the same as sizeof(void *) under i386 and amd64 architectures
author James Harper <james.harper@bendigoit.com.au>
date Wed Jan 23 13:01:20 2008 +1100 (2008-01-23)
parents 5712dede5a1b
children 268fe1eb3ae2
line source
1 /******************************************************************************
2 * arch-ia64/hypervisor-if.h
3 *
4 * Guest OS interface to IA64 Xen.
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a copy
7 * of this software and associated documentation files (the "Software"), to
8 * deal in the Software without restriction, including without limitation the
9 * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
10 * sell copies of the Software, and to permit persons to whom the Software is
11 * furnished to do so, subject to the following conditions:
12 *
13 * The above copyright notice and this permission notice shall be included in
14 * all copies or substantial portions of the Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22 * DEALINGS IN THE SOFTWARE.
23 *
24 */
26 #ifndef __HYPERVISOR_IF_IA64_H__
27 #define __HYPERVISOR_IF_IA64_H__
29 /* Structural guest handles introduced in 0x00030201. */
30 #if __XEN_INTERFACE_VERSION__ >= 0x00030201
31 #define __DEFINE_XEN_GUEST_HANDLE(name, type) \
32 typedef struct { type *p; } __guest_handle_ ## name
33 #else
34 #define __DEFINE_XEN_GUEST_HANDLE(name, type) \
35 typedef type * __guest_handle_ ## name
36 #endif
38 #define DEFINE_XEN_GUEST_HANDLE(name) __DEFINE_XEN_GUEST_HANDLE(name, name)
39 #define XEN_GUEST_HANDLE(name) __guest_handle_ ## name
40 #define XEN_GUEST_HANDLE_64(name) XEN_GUEST_HANDLE(name)
41 #define uint64_aligned_t uint64_t
42 #define set_xen_guest_handle(hnd, val) do { (hnd).p = val; } while (0)
43 #ifdef __XEN_TOOLS__
44 #define get_xen_guest_handle(val, hnd) do { val = (hnd).p; } while (0)
45 #endif
47 #ifndef __ASSEMBLY__
48 /* Guest handles for primitive C types. */
49 __DEFINE_XEN_GUEST_HANDLE(uchar, unsigned char);
50 __DEFINE_XEN_GUEST_HANDLE(uint, unsigned int);
51 __DEFINE_XEN_GUEST_HANDLE(ulong, xen_ulong_t);
52 __DEFINE_XEN_GUEST_HANDLE(u64, xen_ulong_t);
53 DEFINE_XEN_GUEST_HANDLE(char);
54 DEFINE_XEN_GUEST_HANDLE(int);
55 DEFINE_XEN_GUEST_HANDLE(long);
56 DEFINE_XEN_GUEST_HANDLE(void);
58 typedef xen_ulong_t xen_pfn_t;
59 DEFINE_XEN_GUEST_HANDLE(xen_pfn_t);
60 #define PRI_xen_pfn "lx"
61 #endif
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 #ifndef __ASSEMBLY__
74 typedef xen_ulong_t xen_ulong_t;
76 #define INVALID_MFN (~0UL)
78 #define MEM_G (1UL << 30)
79 #define MEM_M (1UL << 20)
80 #define MEM_K (1UL << 10)
82 #define MMIO_START (3 * MEM_G)
83 #define MMIO_SIZE (512 * MEM_M)
85 #define VGA_IO_START 0xA0000UL
86 #define VGA_IO_SIZE 0x20000
88 #define LEGACY_IO_START (MMIO_START + MMIO_SIZE)
89 #define LEGACY_IO_SIZE (64*MEM_M)
91 #define IO_PAGE_START (LEGACY_IO_START + LEGACY_IO_SIZE)
92 #define IO_PAGE_SIZE PAGE_SIZE
94 #define STORE_PAGE_START (IO_PAGE_START + IO_PAGE_SIZE)
95 #define STORE_PAGE_SIZE PAGE_SIZE
97 #define BUFFER_IO_PAGE_START (STORE_PAGE_START+STORE_PAGE_SIZE)
98 #define BUFFER_IO_PAGE_SIZE PAGE_SIZE
100 #define BUFFER_PIO_PAGE_START (BUFFER_IO_PAGE_START+BUFFER_IO_PAGE_SIZE)
101 #define BUFFER_PIO_PAGE_SIZE PAGE_SIZE
103 #define IO_SAPIC_START 0xfec00000UL
104 #define IO_SAPIC_SIZE 0x100000
106 #define PIB_START 0xfee00000UL
107 #define PIB_SIZE 0x200000
109 #define GFW_START (4*MEM_G -16*MEM_M)
110 #define GFW_SIZE (16*MEM_M)
112 /* Nvram belongs to GFW memory space */
113 #define NVRAM_SIZE (MEM_K * 64)
114 #define NVRAM_START (GFW_START + 10 * MEM_M)
116 #define NVRAM_VALID_SIG 0x4650494e45584948 // "HIXENIPF"
117 struct nvram_save_addr {
118 xen_ulong_t addr;
119 xen_ulong_t signature;
120 };
122 struct pt_fpreg {
123 union {
124 xen_ulong_t bits[2];
125 long double __dummy; /* force 16-byte alignment */
126 } u;
127 };
129 struct cpu_user_regs {
130 /* The following registers are saved by SAVE_MIN: */
131 xen_ulong_t b6; /* scratch */
132 xen_ulong_t b7; /* scratch */
134 xen_ulong_t ar_csd; /* used by cmp8xchg16 (scratch) */
135 xen_ulong_t ar_ssd; /* reserved for future use (scratch) */
137 xen_ulong_t r8; /* scratch (return value register 0) */
138 xen_ulong_t r9; /* scratch (return value register 1) */
139 xen_ulong_t r10; /* scratch (return value register 2) */
140 xen_ulong_t r11; /* scratch (return value register 3) */
142 xen_ulong_t cr_ipsr; /* interrupted task's psr */
143 xen_ulong_t cr_iip; /* interrupted task's instruction pointer */
144 xen_ulong_t cr_ifs; /* interrupted task's function state */
146 xen_ulong_t ar_unat; /* interrupted task's NaT register (preserved) */
147 xen_ulong_t ar_pfs; /* prev function state */
148 xen_ulong_t ar_rsc; /* RSE configuration */
149 /* The following two are valid only if cr_ipsr.cpl > 0: */
150 xen_ulong_t ar_rnat; /* RSE NaT */
151 xen_ulong_t ar_bspstore; /* RSE bspstore */
153 xen_ulong_t pr; /* 64 predicate registers (1 bit each) */
154 xen_ulong_t b0; /* return pointer (bp) */
155 xen_ulong_t loadrs; /* size of dirty partition << 16 */
157 xen_ulong_t r1; /* the gp pointer */
158 xen_ulong_t r12; /* interrupted task's memory stack pointer */
159 xen_ulong_t r13; /* thread pointer */
161 xen_ulong_t ar_fpsr; /* floating point status (preserved) */
162 xen_ulong_t r15; /* scratch */
164 /* The remaining registers are NOT saved for system calls. */
166 xen_ulong_t r14; /* scratch */
167 xen_ulong_t r2; /* scratch */
168 xen_ulong_t r3; /* scratch */
169 xen_ulong_t r16; /* scratch */
170 xen_ulong_t r17; /* scratch */
171 xen_ulong_t r18; /* scratch */
172 xen_ulong_t r19; /* scratch */
173 xen_ulong_t r20; /* scratch */
174 xen_ulong_t r21; /* scratch */
175 xen_ulong_t r22; /* scratch */
176 xen_ulong_t r23; /* scratch */
177 xen_ulong_t r24; /* scratch */
178 xen_ulong_t r25; /* scratch */
179 xen_ulong_t r26; /* scratch */
180 xen_ulong_t r27; /* scratch */
181 xen_ulong_t r28; /* scratch */
182 xen_ulong_t r29; /* scratch */
183 xen_ulong_t r30; /* scratch */
184 xen_ulong_t r31; /* scratch */
185 xen_ulong_t ar_ccv; /* compare/exchange value (scratch) */
187 /*
188 * Floating point registers that the kernel considers scratch:
189 */
190 struct pt_fpreg f6; /* scratch */
191 struct pt_fpreg f7; /* scratch */
192 struct pt_fpreg f8; /* scratch */
193 struct pt_fpreg f9; /* scratch */
194 struct pt_fpreg f10; /* scratch */
195 struct pt_fpreg f11; /* scratch */
196 xen_ulong_t r4; /* preserved */
197 xen_ulong_t r5; /* preserved */
198 xen_ulong_t r6; /* preserved */
199 xen_ulong_t r7; /* preserved */
200 xen_ulong_t eml_unat; /* used for emulating instruction */
201 xen_ulong_t pad0; /* alignment pad */
203 };
204 typedef struct cpu_user_regs cpu_user_regs_t;
206 union vac {
207 xen_ulong_t value;
208 struct {
209 int a_int:1;
210 int a_from_int_cr:1;
211 int a_to_int_cr:1;
212 int a_from_psr:1;
213 int a_from_cpuid:1;
214 int a_cover:1;
215 int a_bsw:1;
216 long reserved:57;
217 };
218 };
219 typedef union vac vac_t;
221 union vdc {
222 xen_ulong_t value;
223 struct {
224 int d_vmsw:1;
225 int d_extint:1;
226 int d_ibr_dbr:1;
227 int d_pmc:1;
228 int d_to_pmd:1;
229 int d_itm:1;
230 long reserved:58;
231 };
232 };
233 typedef union vdc vdc_t;
235 struct mapped_regs {
236 union vac vac;
237 union vdc vdc;
238 xen_ulong_t virt_env_vaddr;
239 xen_ulong_t reserved1[29];
240 xen_ulong_t vhpi;
241 xen_ulong_t reserved2[95];
242 union {
243 xen_ulong_t vgr[16];
244 xen_ulong_t bank1_regs[16]; // bank1 regs (r16-r31) when bank0 active
245 };
246 union {
247 xen_ulong_t vbgr[16];
248 xen_ulong_t bank0_regs[16]; // bank0 regs (r16-r31) when bank1 active
249 };
250 xen_ulong_t vnat;
251 xen_ulong_t vbnat;
252 xen_ulong_t vcpuid[5];
253 xen_ulong_t reserved3[11];
254 xen_ulong_t vpsr;
255 xen_ulong_t vpr;
256 xen_ulong_t reserved4[76];
257 union {
258 xen_ulong_t vcr[128];
259 struct {
260 xen_ulong_t dcr; // CR0
261 xen_ulong_t itm;
262 xen_ulong_t iva;
263 xen_ulong_t rsv1[5];
264 xen_ulong_t pta; // CR8
265 xen_ulong_t rsv2[7];
266 xen_ulong_t ipsr; // CR16
267 xen_ulong_t isr;
268 xen_ulong_t rsv3;
269 xen_ulong_t iip;
270 xen_ulong_t ifa;
271 xen_ulong_t itir;
272 xen_ulong_t iipa;
273 xen_ulong_t ifs;
274 xen_ulong_t iim; // CR24
275 xen_ulong_t iha;
276 xen_ulong_t rsv4[38];
277 xen_ulong_t lid; // CR64
278 xen_ulong_t ivr;
279 xen_ulong_t tpr;
280 xen_ulong_t eoi;
281 xen_ulong_t irr[4];
282 xen_ulong_t itv; // CR72
283 xen_ulong_t pmv;
284 xen_ulong_t cmcv;
285 xen_ulong_t rsv5[5];
286 xen_ulong_t lrr0; // CR80
287 xen_ulong_t lrr1;
288 xen_ulong_t rsv6[46];
289 };
290 };
291 union {
292 xen_ulong_t reserved5[128];
293 struct {
294 xen_ulong_t precover_ifs;
295 xen_ulong_t unat; // not sure if this is needed until NaT arch is done
296 int interrupt_collection_enabled; // virtual psr.ic
297 /* virtual interrupt deliverable flag is evtchn_upcall_mask in
298 * shared info area now. interrupt_mask_addr is the address
299 * of evtchn_upcall_mask for current vcpu
300 */
301 unsigned char *interrupt_mask_addr;
302 int pending_interruption;
303 unsigned char vpsr_pp;
304 unsigned char vpsr_dfh;
305 unsigned char hpsr_dfh;
306 unsigned char hpsr_mfh;
307 xen_ulong_t reserved5_1[4];
308 int metaphysical_mode; // 1 = use metaphys mapping, 0 = use virtual
309 int banknum; // 0 or 1, which virtual register bank is active
310 xen_ulong_t rrs[8]; // region registers
311 xen_ulong_t krs[8]; // kernel registers
312 xen_ulong_t pkrs[8]; // protection key registers
313 xen_ulong_t tmp[8]; // temp registers (e.g. for hyperprivops)
314 };
315 };
316 };
317 typedef struct mapped_regs mapped_regs_t;
319 struct vpd {
320 struct mapped_regs vpd_low;
321 xen_ulong_t reserved6[3456];
322 xen_ulong_t vmm_avail[128];
323 xen_ulong_t reserved7[4096];
324 };
325 typedef struct vpd vpd_t;
327 struct arch_vcpu_info {
328 };
329 typedef struct arch_vcpu_info arch_vcpu_info_t;
331 struct arch_shared_info {
332 /* PFN of the start_info page. */
333 xen_ulong_t start_info_pfn;
335 /* Interrupt vector for event channel. */
336 int evtchn_vector;
338 uint64_t pad[32];
339 };
340 typedef struct arch_shared_info arch_shared_info_t;
342 typedef xen_ulong_t xen_callback_t;
344 struct ia64_tr_entry {
345 xen_ulong_t pte;
346 xen_ulong_t itir;
347 xen_ulong_t vadr;
348 xen_ulong_t rid;
349 };
351 struct vcpu_extra_regs {
352 struct ia64_tr_entry itrs[8];
353 struct ia64_tr_entry dtrs[8];
354 xen_ulong_t iva;
355 xen_ulong_t dcr;
356 xen_ulong_t event_callback_ip;
357 };
359 struct vcpu_guest_context {
360 #define VGCF_EXTRA_REGS (1<<1) /* Get/Set extra regs. */
361 xen_ulong_t flags; /* VGCF_* flags */
363 struct cpu_user_regs user_regs;
364 struct vcpu_extra_regs extra_regs;
365 xen_ulong_t privregs_pfn;
366 };
367 typedef struct vcpu_guest_context vcpu_guest_context_t;
368 DEFINE_XEN_GUEST_HANDLE(vcpu_guest_context_t);
370 /* dom0 vp op */
371 #define __HYPERVISOR_ia64_dom0vp_op __HYPERVISOR_arch_0
372 /* Map io space in machine address to dom0 physical address space.
373 Currently physical assigned address equals to machine address. */
374 #define IA64_DOM0VP_ioremap 0
376 /* Convert a pseudo physical page frame number to the corresponding
377 machine page frame number. If no page is assigned, INVALID_MFN or
378 GPFN_INV_MASK is returned depending on domain's non-vti/vti mode. */
379 #define IA64_DOM0VP_phystomach 1
381 /* Convert a machine page frame number to the corresponding pseudo physical
382 page frame number of the caller domain. */
383 #define IA64_DOM0VP_machtophys 3
385 /* Reserved for future use. */
386 #define IA64_DOM0VP_iounmap 4
388 /* Unmap and free pages contained in the specified pseudo physical region. */
389 #define IA64_DOM0VP_zap_physmap 5
391 /* Assign machine page frame to dom0's pseudo physical address space. */
392 #define IA64_DOM0VP_add_physmap 6
394 /* expose the p2m table into domain */
395 #define IA64_DOM0VP_expose_p2m 7
397 /* xen perfmon */
398 #define IA64_DOM0VP_perfmon 8
400 /* gmfn version of IA64_DOM0VP_add_physmap */
401 #define IA64_DOM0VP_add_physmap_with_gmfn 9
403 /* Add an I/O port space range */
404 #define IA64_DOM0VP_add_io_space 11
406 // flags for page assignement to pseudo physical address space
407 #define _ASSIGN_readonly 0
408 #define ASSIGN_readonly (1UL << _ASSIGN_readonly)
409 #define ASSIGN_writable (0UL << _ASSIGN_readonly) // dummy flag
410 /* Internal only: memory attribute must be WC/UC/UCE. */
411 #define _ASSIGN_nocache 1
412 #define ASSIGN_nocache (1UL << _ASSIGN_nocache)
413 // tlb tracking
414 #define _ASSIGN_tlb_track 2
415 #define ASSIGN_tlb_track (1UL << _ASSIGN_tlb_track)
416 /* Internal only: associated with PGC_allocated bit */
417 #define _ASSIGN_pgc_allocated 3
418 #define ASSIGN_pgc_allocated (1UL << _ASSIGN_pgc_allocated)
420 /* This structure has the same layout of struct ia64_boot_param, defined in
421 <asm/system.h>. It is redefined here to ease use. */
422 struct xen_ia64_boot_param {
423 xen_ulong_t command_line; /* physical address of cmd line args */
424 xen_ulong_t efi_systab; /* physical address of EFI system table */
425 xen_ulong_t efi_memmap; /* physical address of EFI memory map */
426 xen_ulong_t efi_memmap_size; /* size of EFI memory map */
427 xen_ulong_t efi_memdesc_size; /* size of an EFI memory map descriptor */
428 unsigned int efi_memdesc_version; /* memory descriptor version */
429 struct {
430 unsigned short num_cols; /* number of columns on console. */
431 unsigned short num_rows; /* number of rows on console. */
432 unsigned short orig_x; /* cursor's x position */
433 unsigned short orig_y; /* cursor's y position */
434 } console_info;
435 xen_ulong_t fpswa; /* physical address of the fpswa interface */
436 xen_ulong_t initrd_start;
437 xen_ulong_t initrd_size;
438 xen_ulong_t domain_start; /* va where the boot time domain begins */
439 xen_ulong_t domain_size; /* how big is the boot domain */
440 };
442 #endif /* !__ASSEMBLY__ */
444 /* Size of the shared_info area (this is not related to page size). */
445 #define XSI_SHIFT 14
446 #define XSI_SIZE (1 << XSI_SHIFT)
447 /* Log size of mapped_regs area (64 KB - only 4KB is used). */
448 #define XMAPPEDREGS_SHIFT 12
449 #define XMAPPEDREGS_SIZE (1 << XMAPPEDREGS_SHIFT)
450 /* Offset of XASI (Xen arch shared info) wrt XSI_BASE. */
451 #define XMAPPEDREGS_OFS XSI_SIZE
453 /* Hyperprivops. */
454 #define HYPERPRIVOP_START 0x1
455 #define HYPERPRIVOP_RFI (HYPERPRIVOP_START + 0x0)
456 #define HYPERPRIVOP_RSM_DT (HYPERPRIVOP_START + 0x1)
457 #define HYPERPRIVOP_SSM_DT (HYPERPRIVOP_START + 0x2)
458 #define HYPERPRIVOP_COVER (HYPERPRIVOP_START + 0x3)
459 #define HYPERPRIVOP_ITC_D (HYPERPRIVOP_START + 0x4)
460 #define HYPERPRIVOP_ITC_I (HYPERPRIVOP_START + 0x5)
461 #define HYPERPRIVOP_SSM_I (HYPERPRIVOP_START + 0x6)
462 #define HYPERPRIVOP_GET_IVR (HYPERPRIVOP_START + 0x7)
463 #define HYPERPRIVOP_GET_TPR (HYPERPRIVOP_START + 0x8)
464 #define HYPERPRIVOP_SET_TPR (HYPERPRIVOP_START + 0x9)
465 #define HYPERPRIVOP_EOI (HYPERPRIVOP_START + 0xa)
466 #define HYPERPRIVOP_SET_ITM (HYPERPRIVOP_START + 0xb)
467 #define HYPERPRIVOP_THASH (HYPERPRIVOP_START + 0xc)
468 #define HYPERPRIVOP_PTC_GA (HYPERPRIVOP_START + 0xd)
469 #define HYPERPRIVOP_ITR_D (HYPERPRIVOP_START + 0xe)
470 #define HYPERPRIVOP_GET_RR (HYPERPRIVOP_START + 0xf)
471 #define HYPERPRIVOP_SET_RR (HYPERPRIVOP_START + 0x10)
472 #define HYPERPRIVOP_SET_KR (HYPERPRIVOP_START + 0x11)
473 #define HYPERPRIVOP_FC (HYPERPRIVOP_START + 0x12)
474 #define HYPERPRIVOP_GET_CPUID (HYPERPRIVOP_START + 0x13)
475 #define HYPERPRIVOP_GET_PMD (HYPERPRIVOP_START + 0x14)
476 #define HYPERPRIVOP_GET_EFLAG (HYPERPRIVOP_START + 0x15)
477 #define HYPERPRIVOP_SET_EFLAG (HYPERPRIVOP_START + 0x16)
478 #define HYPERPRIVOP_RSM_BE (HYPERPRIVOP_START + 0x17)
479 #define HYPERPRIVOP_GET_PSR (HYPERPRIVOP_START + 0x18)
480 #define HYPERPRIVOP_MAX (0x19)
482 /* Fast and light hypercalls. */
483 #define __HYPERVISOR_ia64_fast_eoi __HYPERVISOR_arch_1
485 /* Xencomm macros. */
486 #define XENCOMM_INLINE_MASK 0xf800000000000000UL
487 #define XENCOMM_INLINE_FLAG 0x8000000000000000UL
489 #define XENCOMM_IS_INLINE(addr) \
490 (((xen_ulong_t)(addr) & XENCOMM_INLINE_MASK) == XENCOMM_INLINE_FLAG)
491 #define XENCOMM_INLINE_ADDR(addr) \
492 ((xen_ulong_t)(addr) & ~XENCOMM_INLINE_MASK)
494 /* xen perfmon */
495 #ifdef XEN
496 #ifndef __ASSEMBLY__
497 #ifndef _ASM_IA64_PERFMON_H
499 #include <xen/list.h> // asm/perfmon.h requires struct list_head
500 #include <asm/perfmon.h>
501 // for PFM_xxx and pfarg_features_t, pfarg_context_t, pfarg_reg_t, pfarg_load_t
503 #endif /* _ASM_IA64_PERFMON_H */
505 DEFINE_XEN_GUEST_HANDLE(pfarg_features_t);
506 DEFINE_XEN_GUEST_HANDLE(pfarg_context_t);
507 DEFINE_XEN_GUEST_HANDLE(pfarg_reg_t);
508 DEFINE_XEN_GUEST_HANDLE(pfarg_load_t);
509 #endif /* __ASSEMBLY__ */
510 #endif /* XEN */
512 #endif /* __HYPERVISOR_IF_IA64_H__ */
514 /*
515 * Local variables:
516 * mode: C
517 * c-set-style: "BSD"
518 * c-basic-offset: 4
519 * tab-width: 4
520 * indent-tabs-mode: nil
521 * End:
522 */