ia64/xen-unstable

view xen/include/hypervisor-ifs/hypervisor-if.h @ 763:57eb11234d3b

bitkeeper revision 1.461 (3f721182M0chx1rTeocidCx3jjFA6g)

hypervisor-if.h:
Fix a comment.
author kaf24@scramble.cl.cam.ac.uk
date Wed Sep 24 21:49:54 2003 +0000 (2003-09-24)
parents 29c5d712802c
children b45bc774c22c
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_pt_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_update 6
50 #define __HYPERVISOR_fpu_taskswitch 7
51 #define __HYPERVISOR_yield 8
52 #define __HYPERVISOR_exit 9
53 #define __HYPERVISOR_dom0_op 10
54 #define __HYPERVISOR_network_op 11
55 #define __HYPERVISOR_block_io_op 12
56 #define __HYPERVISOR_set_debugreg 13
57 #define __HYPERVISOR_get_debugreg 14
58 #define __HYPERVISOR_update_descriptor 15
59 #define __HYPERVISOR_set_fast_trap 16
60 #define __HYPERVISOR_dom_mem_op 17
61 #define __HYPERVISOR_multicall 18
62 #define __HYPERVISOR_kbd_op 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 * PAGE UPDATE COMMANDS AND FLAGS
114 *
115 * PGREQ_XXX: specified in least 2 bits of 'ptr' field. These bits are masked
116 * off to get the real 'ptr' value.
117 * All requests specify relevent machine address in 'ptr'.
118 * Normal requests specify update value in 'value'.
119 * Extended requests specify command in least 8 bits of 'value'. These bits
120 * are masked off to get the real 'val' value. Except for PGEXT_SET_LDT
121 * which shifts the least bits out.
122 */
123 /* A normal page-table update request. */
124 #define PGREQ_NORMAL 0 /* does a checked form of '*ptr = val' */
125 /* Update an entry in the machine->physical mapping table. */
126 #define PGREQ_MPT_UPDATE 1 /* ptr = frame to modify table entry for */
127 /* An extended command. */
128 #define PGREQ_EXTENDED_COMMAND 2 /* least 8 bits of val demux further */
129 /* DOM0 can make entirely unchecked updates which do not affect refcnts. */
130 #define PGREQ_UNCHECKED_UPDATE 3 /* does an unchecked '*ptr = val' */
131 /* Extended commands: */
132 #define PGEXT_PIN_L1_TABLE 0 /* ptr = frame to pin */
133 #define PGEXT_PIN_L2_TABLE 1 /* ptr = frame to pin */
134 #define PGEXT_PIN_L3_TABLE 2 /* ptr = frame to pin */
135 #define PGEXT_PIN_L4_TABLE 3 /* ptr = frame to pin */
136 #define PGEXT_UNPIN_TABLE 4 /* ptr = frame to unpin */
137 #define PGEXT_NEW_BASEPTR 5 /* ptr = new pagetable base to install */
138 #define PGEXT_TLB_FLUSH 6 /* ptr = NULL */
139 #define PGEXT_INVLPG 7 /* ptr = NULL ; val = page to invalidate */
140 #define PGEXT_SET_LDT 8 /* ptr = linear address; val = # entries */
141 #define PGEXT_CMD_MASK 255
142 #define PGEXT_CMD_SHIFT 8
145 /*
146 * Master "switch" for enabling/disabling event delivery.
147 */
148 #define EVENTS_MASTER_ENABLE_MASK 0x80000000UL
149 #define EVENTS_MASTER_ENABLE_BIT 31
152 #ifndef __ASSEMBLY__
154 #include "network.h"
155 #include "block.h"
157 /*
158 * Send an array of these to HYPERVISOR_set_trap_table()
159 */
160 #define TI_GET_DPL(_ti) ((_ti)->flags & 3)
161 #define TI_GET_IF(_ti) ((_ti)->flags & 4)
162 #define TI_SET_DPL(_ti,_dpl) ((_ti)->flags |= (_dpl))
163 #define TI_SET_IF(_ti,_if) ((_ti)->flags |= ((!!(_if))<<2))
164 typedef struct trap_info_st
165 {
166 unsigned char vector; /* exception vector */
167 unsigned char flags; /* 0-3: privilege level; 4: clear event enable? */
168 unsigned short cs; /* code selector */
169 unsigned long address; /* code address */
170 } trap_info_t;
172 /*
173 * Send an array of these to HYPERVISOR_pt_update()
174 */
175 typedef struct
176 {
177 unsigned long ptr, val; /* *ptr = val */
178 } page_update_request_t;
180 /*
181 * Send an array of these to HYPERVISOR_multicall()
182 */
183 typedef struct
184 {
185 unsigned long op;
186 unsigned long args[7];
187 } multicall_entry_t;
189 /*
190 * Xen/guestos shared data -- pointer provided in start_info.
191 * NB. We expect that this struct is smaller than a page.
192 */
193 typedef struct shared_info_st {
195 /* Bitmask of outstanding event notifications hypervisor -> guest OS. */
196 unsigned long events;
197 /*
198 * Hypervisor will only signal event delivery via the "callback exception"
199 * when a pending event is not masked. The mask also contains a "master
200 * enable" which prevents any event delivery. This mask can be used to
201 * prevent unbounded reentrancy and stack overflow (in this way, acts as a
202 * kind of interrupt-enable flag).
203 */
204 unsigned long events_mask;
206 /*
207 * Time: The following abstractions are exposed: System Time, Clock Time,
208 * Domain Virtual Time. Domains can access Cycle counter time directly.
209 *
210 * The following values are updated periodically (and atomically, from the
211 * p.o.v. of the guest OS). Th eguest OS detects this because the wc_version
212 * is incremented.
213 */
214 u32 wc_version; /* a version number for info below */
215 unsigned int rdtsc_bitshift; /* use bits N:N+31 of TSC */
216 u64 cpu_freq; /* to calculate ticks -> real time */
217 /* System Time */
218 long long system_time; /* in ns */
219 unsigned long st_timestamp; /* cyclecounter at last update */
220 /* Wall Clock Time */
221 long tv_sec; /* essentially a struct timeval */
222 long tv_usec;
223 long long wc_timestamp; /* system time at last update */
225 /* Domain Virtual Time */
226 unsigned long long domain_time;
228 /*
229 * Timeout values:
230 * Allow a domain to specify a timeout value in system time and
231 * domain virtual time.
232 */
233 unsigned long long wall_timeout;
234 unsigned long long domain_timeout;
236 /*
237 * The index structures are all stored here for convenience. The rings
238 * themselves are allocated by Xen but the guestos must create its own
239 * mapping -- the machine address is given in the startinfo structure to
240 * allow this to happen.
241 */
242 net_idx_t net_idx[MAX_DOMAIN_VIFS];
244 } shared_info_t;
246 /*
247 * NB. We expect that this struct is smaller than a page.
248 */
249 typedef struct start_info_st {
250 unsigned long nr_pages; /* total pages allocated to this domain */
251 shared_info_t *shared_info; /* VIRTUAL address of shared info struct */
252 unsigned long pt_base; /* VIRTUAL address of page directory */
253 unsigned long mod_start; /* VIRTUAL address of pre-loaded module */
254 unsigned long mod_len; /* size (bytes) of pre-loaded module */
255 /* Machine address of net rings for each VIF. Will be page aligned. */
256 unsigned long net_rings[MAX_DOMAIN_VIFS];
257 unsigned char net_vmac[MAX_DOMAIN_VIFS][6];
258 /* Machine address of block-device ring. Will be page aligned. */
259 unsigned long blk_ring;
260 unsigned int dom_id;
261 unsigned long flags;
262 unsigned char cmd_line[1]; /* variable-length */
263 } start_info_t;
265 /* These flags are passed in the 'flags' field of start_info_t. */
266 #define SIF_PRIVILEGED 1 /* Is the domain privileged? */
267 #define SIF_CONSOLE 2 /* Does the domain own the physical console? */
269 /* For use in guest OSes. */
270 extern shared_info_t *HYPERVISOR_shared_info;
272 #endif /* !__ASSEMBLY__ */
274 #endif /* __HYPERVISOR_IF_H__ */