ia64/xen-unstable

view xen/include/hypervisor-ifs/hypervisor-if.h @ 877:d1833d5b387b

bitkeeper revision 1.546.1.1 (3fa3e1b4UwJQtnD-lZcvMsbqR-XhSA)

sched hypercall unification -- tidying things up in
anticipation of suspend/resume
author akw27@labyrinth.cl.cam.ac.uk
date Sat Nov 01 16:39:16 2003 +0000 (2003-11-01)
parents 02306208d767
children 61c3759bc7be
line source
1 /******************************************************************************
2 * hypervisor-if.h
3 *
4 * Interface to Xeno hypervisor.
5 */
7 #ifndef __HYPERVISOR_IF_H__
8 #define __HYPERVISOR_IF_H__
10 /*
11 * SEGMENT DESCRIPTOR TABLES
12 */
13 /*
14 * A number of GDT entries are reserved by Xen. These are not situated at the
15 * start of the GDT because some stupid OSes export hard-coded selector values
16 * in their ABI. These hard-coded values are always near the start of the GDT,
17 * so Xen places itself out of the way.
18 *
19 * NB. The reserved range is inclusive (that is, both FIRST_RESERVED_GDT_ENTRY
20 * and LAST_RESERVED_GDT_ENTRY are reserved).
21 */
22 #define NR_RESERVED_GDT_ENTRIES 40
23 #define FIRST_RESERVED_GDT_ENTRY 256
24 #define LAST_RESERVED_GDT_ENTRY \
25 (FIRST_RESERVED_GDT_ENTRY + NR_RESERVED_GDT_ENTRIES - 1)
27 /*
28 * These flat segments are in the Xen-private section of every GDT. Since these
29 * are also present in the initial GDT, many OSes will be able to avoid
30 * installing their own GDT.
31 */
32 #define FLAT_RING1_CS 0x0819
33 #define FLAT_RING1_DS 0x0821
34 #define FLAT_RING3_CS 0x082b
35 #define FLAT_RING3_DS 0x0833
38 /*
39 * HYPERVISOR "SYSTEM CALLS"
40 */
42 /* EAX = vector; EBX, ECX, EDX, ESI, EDI = args 1, 2, 3, 4, 5. */
43 #define __HYPERVISOR_set_trap_table 0
44 #define __HYPERVISOR_mmu_update 1
45 #define __HYPERVISOR_console_write 2
46 #define __HYPERVISOR_set_gdt 3
47 #define __HYPERVISOR_stack_switch 4
48 #define __HYPERVISOR_set_callbacks 5
49 #define __HYPERVISOR_net_io_op 6
50 #define __HYPERVISOR_fpu_taskswitch 7
51 #define __HYPERVISOR_sched_op 8
52 #define __HYPERVISOR_dom0_op 9
53 #define __HYPERVISOR_network_op 10
54 #define __HYPERVISOR_block_io_op 11
55 #define __HYPERVISOR_set_debugreg 12
56 #define __HYPERVISOR_get_debugreg 13
57 #define __HYPERVISOR_update_descriptor 14
58 #define __HYPERVISOR_set_fast_trap 15
59 #define __HYPERVISOR_dom_mem_op 16
60 #define __HYPERVISOR_multicall 17
61 #define __HYPERVISOR_kbd_op 18
62 #define __HYPERVISOR_update_va_mapping 19
64 /* And the trap vector is... */
65 #define TRAP_INSTR "int $0x82"
68 /*
69 * MULTICALLS
70 *
71 * Multicalls are listed in an array, with each element being a fixed size
72 * (BYTES_PER_MULTICALL_ENTRY). Each is of the form (op, arg1, ..., argN)
73 * where each element of the tuple is a machine word.
74 */
75 #define BYTES_PER_MULTICALL_ENTRY 32
78 /* EVENT MESSAGES
79 *
80 * Here, as in the interrupts to the guestos, additional network interfaces
81 * are defined. These definitions server as placeholders for the event bits,
82 * however, in the code these events will allways be referred to as shifted
83 * offsets from the base NET events.
84 */
86 /* Events that a guest OS may receive from the hypervisor. */
87 #define EVENT_BLKDEV 0x01 /* A block device response has been queued. */
88 #define EVENT_TIMER 0x02 /* A timeout has been updated. */
89 #define EVENT_DIE 0x04 /* OS is about to be killed. Clean up please! */
90 #define EVENT_DEBUG 0x08 /* Request guest to dump debug info (gross!) */
91 #define EVENT_NET 0x10 /* There are packets for transmission. */
92 #define EVENT_PS2 0x20 /* PS/2 keyboard or mouse event(s) */
94 /* Bit offsets, as opposed to the above masks. */
95 #define _EVENT_BLKDEV 0
96 #define _EVENT_TIMER 1
97 #define _EVENT_DIE 2
98 #define _EVENT_DEBUG 3
99 #define _EVENT_NET 4
100 #define _EVENT_PS2 5
102 /*
103 * Virtual addresses beyond this are not modifiable by guest OSes. The
104 * machine->physical mapping table starts at this address, read-only.
105 */
106 #define HYPERVISOR_VIRT_START (0xFC000000UL)
107 #ifndef machine_to_phys_mapping
108 #define machine_to_phys_mapping ((unsigned long *)HYPERVISOR_VIRT_START)
109 #endif
112 /*
113 * MMU_XXX: specified in least 2 bits of 'ptr' field. These bits are masked
114 * off to get the real 'ptr' value.
115 * All requests specify relevent address in 'ptr'. This is either a
116 * machine/physical address (MA), or linear/virtual address (VA).
117 * Normal requests specify update value in 'value'.
118 * Extended requests specify command in least 8 bits of 'value'. These bits
119 * are masked off to get the real 'val' value. Except for MMUEXT_SET_LDT
120 * which shifts the least bits out.
121 */
122 /* A normal page-table update request. */
123 #define MMU_NORMAL_PT_UPDATE 0 /* checked '*ptr = val'. ptr is VA. */
124 /* DOM0 can make entirely unchecked updates which do not affect refcnts. */
125 #define MMU_UNCHECKED_PT_UPDATE 1 /* unchecked '*ptr = val'. ptr is VA. */
126 /* Update an entry in the machine->physical mapping table. */
127 #define MMU_MACHPHYS_UPDATE 2 /* ptr = MA of frame to modify entry for */
128 /* An extended command. */
129 #define MMU_EXTENDED_COMMAND 3 /* least 8 bits of val demux further */
130 /* Extended commands: */
131 #define MMUEXT_PIN_L1_TABLE 0 /* ptr = MA of frame to pin */
132 #define MMUEXT_PIN_L2_TABLE 1 /* ptr = MA of frame to pin */
133 #define MMUEXT_PIN_L3_TABLE 2 /* ptr = MA of frame to pin */
134 #define MMUEXT_PIN_L4_TABLE 3 /* ptr = MA of frame to pin */
135 #define MMUEXT_UNPIN_TABLE 4 /* ptr = MA of frame to unpin */
136 #define MMUEXT_NEW_BASEPTR 5 /* ptr = MA of new pagetable base */
137 #define MMUEXT_TLB_FLUSH 6 /* ptr = NULL */
138 #define MMUEXT_INVLPG 7 /* ptr = NULL ; val = VA to invalidate */
139 #define MMUEXT_SET_LDT 8 /* ptr = VA of table; val = # entries */
140 #define MMUEXT_CMD_MASK 255
141 #define MMUEXT_CMD_SHIFT 8
143 /* These are passed as 'flags' to update_va_mapping. They can be ORed. */
144 #define UVMF_FLUSH_TLB 1 /* Flush entire TLB. */
145 #define UVMF_INVLPG 2 /* Flush the VA mapping being updated. */
147 /*
148 * Master "switch" for enabling/disabling event delivery.
149 */
150 #define EVENTS_MASTER_ENABLE_MASK 0x80000000UL
151 #define EVENTS_MASTER_ENABLE_BIT 31
154 /*
155 * SCHEDOP_* - Scheduler hypercall operations.
156 */
157 #define SCHEDOP_yield 0
158 #define SCHEDOP_exit 1
162 #ifndef __ASSEMBLY__
164 #include "network.h"
165 #include "block.h"
167 /*
168 * Send an array of these to HYPERVISOR_set_trap_table()
169 */
170 #define TI_GET_DPL(_ti) ((_ti)->flags & 3)
171 #define TI_GET_IF(_ti) ((_ti)->flags & 4)
172 #define TI_SET_DPL(_ti,_dpl) ((_ti)->flags |= (_dpl))
173 #define TI_SET_IF(_ti,_if) ((_ti)->flags |= ((!!(_if))<<2))
174 typedef struct trap_info_st
175 {
176 unsigned char vector; /* exception vector */
177 unsigned char flags; /* 0-3: privilege level; 4: clear event enable? */
178 unsigned short cs; /* code selector */
179 unsigned long address; /* code address */
180 } trap_info_t;
182 /*
183 * Send an array of these to HYPERVISOR_mmu_update()
184 */
185 typedef struct
186 {
187 unsigned long ptr, val; /* *ptr = val */
188 } mmu_update_t;
190 /*
191 * Send an array of these to HYPERVISOR_multicall()
192 */
193 typedef struct
194 {
195 unsigned long op;
196 unsigned long args[7];
197 } multicall_entry_t;
199 typedef struct
200 {
201 unsigned long ebx;
202 unsigned long ecx;
203 unsigned long edx;
204 unsigned long esi;
205 unsigned long edi;
206 unsigned long ebp;
207 unsigned long eax;
208 unsigned long ds;
209 unsigned long es;
210 unsigned long fs;
211 unsigned long gs;
212 unsigned long _unused;
213 unsigned long eip;
214 unsigned long cs;
215 unsigned long eflags;
216 unsigned long esp;
217 unsigned long ss;
218 } execution_context_t;
220 /*
221 * Xen/guestos shared data -- pointer provided in start_info.
222 * NB. We expect that this struct is smaller than a page.
223 */
224 typedef struct shared_info_st {
226 /* Bitmask of outstanding event notifications hypervisor -> guest OS. */
227 unsigned long events;
228 /*
229 * Hypervisor will only signal event delivery via the "callback exception"
230 * when a pending event is not masked. The mask also contains a "master
231 * enable" which prevents any event delivery. This mask can be used to
232 * prevent unbounded reentrancy and stack overflow (in this way, acts as a
233 * kind of interrupt-enable flag).
234 */
235 unsigned long events_mask;
237 /*
238 * Time: The following abstractions are exposed: System Time, Clock Time,
239 * Domain Virtual Time. Domains can access Cycle counter time directly.
240 */
242 unsigned int rdtsc_bitshift; /* tsc_timestamp uses N:N+31 of TSC. */
243 u64 cpu_freq; /* CPU frequency (Hz). */
245 /*
246 * The following values are updated periodically (and not necessarily
247 * atomically!). The guest OS detects this because 'time_version1' is
248 * incremented just before updating these values, and 'time_version2' is
249 * incremented immediately after. See Xenolinux code for an example of how
250 * to read these values safely (arch/xeno/kernel/time.c).
251 */
252 unsigned long time_version1; /* A version number for info below. */
253 unsigned long time_version2; /* A version number for info below. */
254 unsigned long tsc_timestamp; /* TSC at last update of time vals. */
255 u64 system_time; /* Time, in nanosecs, since boot. */
256 unsigned long wc_sec; /* Secs 00:00:00 UTC, Jan 1, 1970. */
257 unsigned long wc_usec; /* Usecs 00:00:00 UTC, Jan 1, 1970. */
259 /* Domain Virtual Time */
260 u64 domain_time;
262 /*
263 * Timeout values:
264 * Allow a domain to specify a timeout value in system time and
265 * domain virtual time.
266 */
267 u64 wall_timeout;
268 u64 domain_timeout;
270 /*
271 * The index structures are all stored here for convenience. The rings
272 * themselves are allocated by Xen but the guestos must create its own
273 * mapping -- the machine address is given in the startinfo structure to
274 * allow this to happen.
275 */
276 net_idx_t net_idx[MAX_DOMAIN_VIFS];
278 execution_context_t execution_context;
280 } shared_info_t;
282 /*
283 * NB. We expect that this struct is smaller than a page.
284 */
285 typedef struct start_info_st {
286 /* THE FOLLOWING ARE ONLY FILLED IN ON INITIAL BOOT (NOT RESUME). */
287 unsigned long pt_base; /* VIRTUAL address of page directory. */
288 unsigned long mod_start; /* VIRTUAL address of pre-loaded module. */
289 unsigned long mod_len; /* Size (bytes) of pre-loaded module. */
290 /* THE FOLLOWING ARE FILLED IN BOTH ON INITIAL BOOT AND ON RESUME. */
291 unsigned long nr_pages; /* total pages allocated to this domain. */
292 unsigned long shared_info; /* MACHINE address of shared info struct.*/
293 unsigned int dom_id; /* Domain identifier. */
294 unsigned long flags; /* SIF_xxx flags. */
295 unsigned long net_rings[MAX_DOMAIN_VIFS]; /* MACHINE address of ring.*/
296 unsigned char net_vmac[MAX_DOMAIN_VIFS][6]; /* MAC address of VIF. */
297 unsigned long blk_ring; /* MACHINE address of blkdev ring. */
298 unsigned char cmd_line[1]; /* Variable-length options. */
299 } start_info_t;
301 /* These flags are passed in the 'flags' field of start_info_t. */
302 #define SIF_PRIVILEGED 1 /* Is the domain privileged? */
303 #define SIF_CONSOLE 2 /* Does the domain own the physical console? */
305 /* For use in guest OSes. */
306 extern shared_info_t *HYPERVISOR_shared_info;
308 #endif /* !__ASSEMBLY__ */
310 #endif /* __HYPERVISOR_IF_H__ */