ia64/xen-unstable

view xen/include/public/arch-x86/xen.h @ 15814:0f196e11a143

DEFINE_XEN_GUEST_HANDLE is evaluated by the pre-processor twice. Do this also for XEN_GUEST_HANDLE.

This fixes a build error for PV guests (OpenBSD, NetBSD) where the use
of XEN_GUEST_HANDLE(uint8_t) leads to a build error because uint8_t is
a #define instead a typedef.

Signed-off-by: Christoph Egger <Christoph.Egger@amd.com>
author kfraser@localhost.localdomain
date Fri Aug 31 11:12:57 2007 +0100 (2007-08-31)
parents f3f5f2756d75
children ad0f20f5590a
line source
1 /******************************************************************************
2 * arch-x86/xen.h
3 *
4 * Guest OS interface to x86 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 * Copyright (c) 2004-2006, K A Fraser
25 */
27 #ifndef __XEN_PUBLIC_ARCH_X86_XEN_H__
28 #define __XEN_PUBLIC_ARCH_X86_XEN_H__
30 /* Structural guest handles introduced in 0x00030201. */
31 #if __XEN_INTERFACE_VERSION__ >= 0x00030201
32 #define __DEFINE_XEN_GUEST_HANDLE(name, type) \
33 typedef struct { type *p; } __guest_handle_ ## name
34 #else
35 #define __DEFINE_XEN_GUEST_HANDLE(name, type) \
36 typedef type * __guest_handle_ ## name
37 #endif
39 #define DEFINE_XEN_GUEST_HANDLE(name) __DEFINE_XEN_GUEST_HANDLE(name, name)
40 #define __XEN_GUEST_HANDLE(name) __guest_handle_ ## name
41 #define XEN_GUEST_HANDLE(name) __XEN_GUEST_HANDLE(name)
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 #if defined(__i386__)
48 #include "xen-x86_32.h"
49 #elif defined(__x86_64__)
50 #include "xen-x86_64.h"
51 #endif
53 #ifndef __ASSEMBLY__
54 /* Guest handles for primitive C types. */
55 __DEFINE_XEN_GUEST_HANDLE(uchar, unsigned char);
56 __DEFINE_XEN_GUEST_HANDLE(uint, unsigned int);
57 __DEFINE_XEN_GUEST_HANDLE(ulong, unsigned long);
58 DEFINE_XEN_GUEST_HANDLE(char);
59 DEFINE_XEN_GUEST_HANDLE(int);
60 DEFINE_XEN_GUEST_HANDLE(long);
61 DEFINE_XEN_GUEST_HANDLE(void);
63 typedef unsigned long xen_pfn_t;
64 DEFINE_XEN_GUEST_HANDLE(xen_pfn_t);
65 #define PRI_xen_pfn "lx"
66 #endif
68 /*
69 * SEGMENT DESCRIPTOR TABLES
70 */
71 /*
72 * A number of GDT entries are reserved by Xen. These are not situated at the
73 * start of the GDT because some stupid OSes export hard-coded selector values
74 * in their ABI. These hard-coded values are always near the start of the GDT,
75 * so Xen places itself out of the way, at the far end of the GDT.
76 */
77 #define FIRST_RESERVED_GDT_PAGE 14
78 #define FIRST_RESERVED_GDT_BYTE (FIRST_RESERVED_GDT_PAGE * 4096)
79 #define FIRST_RESERVED_GDT_ENTRY (FIRST_RESERVED_GDT_BYTE / 8)
81 /* Maximum number of virtual CPUs in multi-processor guests. */
82 #define MAX_VIRT_CPUS 32
84 #ifndef __ASSEMBLY__
86 typedef unsigned long xen_ulong_t;
88 /*
89 * Send an array of these to HYPERVISOR_set_trap_table().
90 * The privilege level specifies which modes may enter a trap via a software
91 * interrupt. On x86/64, since rings 1 and 2 are unavailable, we allocate
92 * privilege levels as follows:
93 * Level == 0: Noone may enter
94 * Level == 1: Kernel may enter
95 * Level == 2: Kernel may enter
96 * Level == 3: Everyone may enter
97 */
98 #define TI_GET_DPL(_ti) ((_ti)->flags & 3)
99 #define TI_GET_IF(_ti) ((_ti)->flags & 4)
100 #define TI_SET_DPL(_ti,_dpl) ((_ti)->flags |= (_dpl))
101 #define TI_SET_IF(_ti,_if) ((_ti)->flags |= ((!!(_if))<<2))
102 struct trap_info {
103 uint8_t vector; /* exception vector */
104 uint8_t flags; /* 0-3: privilege level; 4: clear event enable? */
105 uint16_t cs; /* code selector */
106 unsigned long address; /* code offset */
107 };
108 typedef struct trap_info trap_info_t;
109 DEFINE_XEN_GUEST_HANDLE(trap_info_t);
111 typedef uint64_t tsc_timestamp_t; /* RDTSC timestamp */
113 /*
114 * The following is all CPU context. Note that the fpu_ctxt block is filled
115 * in by FXSAVE if the CPU has feature FXSR; otherwise FSAVE is used.
116 */
117 struct vcpu_guest_context {
118 /* FPU registers come first so they can be aligned for FXSAVE/FXRSTOR. */
119 struct { char x[512]; } fpu_ctxt; /* User-level FPU registers */
120 #define VGCF_I387_VALID (1<<0)
121 #define VGCF_IN_KERNEL (1<<2)
122 #define _VGCF_i387_valid 0
123 #define VGCF_i387_valid (1<<_VGCF_i387_valid)
124 #define _VGCF_in_kernel 2
125 #define VGCF_in_kernel (1<<_VGCF_in_kernel)
126 #define _VGCF_failsafe_disables_events 3
127 #define VGCF_failsafe_disables_events (1<<_VGCF_failsafe_disables_events)
128 #define _VGCF_syscall_disables_events 4
129 #define VGCF_syscall_disables_events (1<<_VGCF_syscall_disables_events)
130 #define _VGCF_online 5
131 #define VGCF_online (1<<_VGCF_online)
132 unsigned long flags; /* VGCF_* flags */
133 struct cpu_user_regs user_regs; /* User-level CPU registers */
134 struct trap_info trap_ctxt[256]; /* Virtual IDT */
135 unsigned long ldt_base, ldt_ents; /* LDT (linear address, # ents) */
136 unsigned long gdt_frames[16], gdt_ents; /* GDT (machine frames, # ents) */
137 unsigned long kernel_ss, kernel_sp; /* Virtual TSS (only SS1/SP1) */
138 /* NB. User pagetable on x86/64 is placed in ctrlreg[1]. */
139 unsigned long ctrlreg[8]; /* CR0-CR7 (control registers) */
140 unsigned long debugreg[8]; /* DB0-DB7 (debug registers) */
141 #ifdef __i386__
142 unsigned long event_callback_cs; /* CS:EIP of event callback */
143 unsigned long event_callback_eip;
144 unsigned long failsafe_callback_cs; /* CS:EIP of failsafe callback */
145 unsigned long failsafe_callback_eip;
146 #else
147 unsigned long event_callback_eip;
148 unsigned long failsafe_callback_eip;
149 #ifdef __XEN__
150 union {
151 unsigned long syscall_callback_eip;
152 struct {
153 unsigned int event_callback_cs; /* compat CS of event cb */
154 unsigned int failsafe_callback_cs; /* compat CS of failsafe cb */
155 };
156 };
157 #else
158 unsigned long syscall_callback_eip;
159 #endif
160 #endif
161 unsigned long vm_assist; /* VMASST_TYPE_* bitmap */
162 #ifdef __x86_64__
163 /* Segment base addresses. */
164 uint64_t fs_base;
165 uint64_t gs_base_kernel;
166 uint64_t gs_base_user;
167 #endif
168 };
169 typedef struct vcpu_guest_context vcpu_guest_context_t;
170 DEFINE_XEN_GUEST_HANDLE(vcpu_guest_context_t);
172 struct arch_shared_info {
173 unsigned long max_pfn; /* max pfn that appears in table */
174 /* Frame containing list of mfns containing list of mfns containing p2m. */
175 xen_pfn_t pfn_to_mfn_frame_list_list;
176 unsigned long nmi_reason;
177 uint64_t pad[32];
178 };
179 typedef struct arch_shared_info arch_shared_info_t;
181 #endif /* !__ASSEMBLY__ */
183 /*
184 * Prefix forces emulation of some non-trapping instructions.
185 * Currently only CPUID.
186 */
187 #ifdef __ASSEMBLY__
188 #define XEN_EMULATE_PREFIX .byte 0x0f,0x0b,0x78,0x65,0x6e ;
189 #define XEN_CPUID XEN_EMULATE_PREFIX cpuid
190 #else
191 #define XEN_EMULATE_PREFIX ".byte 0x0f,0x0b,0x78,0x65,0x6e ; "
192 #define XEN_CPUID XEN_EMULATE_PREFIX "cpuid"
193 #endif
195 #endif /* __XEN_PUBLIC_ARCH_X86_XEN_H__ */
197 /*
198 * Local variables:
199 * mode: C
200 * c-set-style: "BSD"
201 * c-basic-offset: 4
202 * tab-width: 4
203 * indent-tabs-mode: nil
204 * End:
205 */