ia64/xen-unstable

view xen-2.4.16/include/hypervisor-ifs/hypervisor-if.h @ 86:4a10fe9b20ec

bitkeeper revision 1.15 (3e24a984iRiWWcgfKCxu2p5q3YbxXw)

Many files:
First half of support for per-domain GDTs and LDTs
author kaf24@labyrinth.cl.cam.ac.uk
date Wed Jan 15 00:21:24 2003 +0000 (2003-01-15)
parents c3e6a52cd801
children 336647fd8f40
line source
1 /******************************************************************************
2 * hypervisor-if.h
3 *
4 * Interface to Xeno hypervisor.
5 */
7 #include "network.h"
8 #include "block.h"
10 #ifndef __HYPERVISOR_IF_H__
11 #define __HYPERVISOR_IF_H__
13 /* Virtual addresses beyond this are inaccessible by guest OSes. */
14 #define HYPERVISOR_VIRT_START (0xFC000000UL)
16 typedef struct trap_info_st
17 {
18 unsigned char vector; /* exception/interrupt vector */
19 unsigned char dpl; /* privilege level */
20 unsigned short cs; /* code selector */
21 unsigned long address; /* code address */
22 } trap_info_t;
25 typedef struct
26 {
27 /*
28 * PGREQ_XXX: specified in least-significant bits of 'ptr' field.
29 * All requests specify relevent PTE or PT address in 'ptr'.
30 * Normal requests specify update value in 'value'.
31 * Extended requests specify command in least 8 bits of 'value'.
32 */
33 /* A normal page-table update request. */
34 #define PGREQ_NORMAL 0
35 /* Make an unchecked update to a base-level pte. */
36 #define PGREQ_UNCHECKED_UPDATE 1
37 /* An extended command. */
38 #define PGREQ_EXTENDED_COMMAND 2
39 unsigned long ptr, val; /* *ptr = val */
40 /* Announce a new top-level page table. */
41 #define PGEXT_PIN_L1_TABLE 0
42 #define PGEXT_PIN_L2_TABLE 1
43 #define PGEXT_PIN_L3_TABLE 2
44 #define PGEXT_PIN_L4_TABLE 3
45 #define PGEXT_UNPIN_TABLE 4
46 #define PGEXT_NEW_BASEPTR 5
47 #define PGEXT_TLB_FLUSH 6
48 #define PGEXT_INVLPG 7
49 #define PGEXT_CMD_MASK 255
50 #define PGEXT_CMD_SHIFT 8
51 } page_update_request_t;
54 /*
55 * Segment descriptor tables.
56 */
57 /* 8 entries, plus a TSS entry for each CPU (up to 32 CPUs). */
58 #define FIRST_DOMAIN_GDT_ENTRY 40
59 /* These are flat segments for domain bootstrap and fallback. */
60 #define FLAT_RING1_CS 0x11
61 #define FLAT_RING1_DS 0x19
62 #define FLAT_RING3_CS 0x23
63 #define FLAT_RING3_DS 0x2b
66 /* EAX = vector; EBX, ECX, EDX, ESI, EDI = args 1, 2, 3, 4, 5. */
68 #define __HYPERVISOR_set_trap_table 0
69 #define __HYPERVISOR_pt_update 1
70 #define __HYPERVISOR_console_write 2
71 #define __HYPERVISOR_set_gdt 3
72 #define __HYPERVISOR_stack_and_ldt_switch 4
73 #define __HYPERVISOR_net_update 5
74 #define __HYPERVISOR_fpu_taskswitch 6
75 #define __HYPERVISOR_yield 7
76 #define __HYPERVISOR_exit 8
77 #define __HYPERVISOR_dom0_op 9
78 #define __HYPERVISOR_network_op 10
79 #define __HYPERVISOR_set_debugreg 11
80 #define __HYPERVISOR_get_debugreg 12
81 #define __HYPERVISOR_update_descriptor 13
83 #define TRAP_INSTR "int $0x82"
86 /* Event message note:
87 *
88 * Here, as in the interrupts to the guestos, additional network interfaces
89 * are defined. These definitions server as placeholders for the event bits,
90 * however, in the code these events will allways be referred to as shifted
91 * offsets from the base NET events.
92 */
94 /* Events that a guest OS may receive from the hypervisor. */
95 #define EVENT_BLK_TX 0x01 /* packets for transmission. */
96 #define EVENT_BLK_RX 0x02 /* empty buffers for receive. */
97 #define EVENT_TIMER 0x04 /* a timeout has been updated. */
98 #define EVENT_DIE 0x08 /* OS is about to be killed. Clean up please! */
99 #define EVENT_NET_TX 0x10 /* packets for transmission. */
100 #define EVENT_NET_RX 0x20 /* empty buffers for receive. */
101 #define EVENT_NET2_TX 0x40 /* packets for transmission. */
102 #define EVENT_NET2_RX 0x80 /* empty buffers for receive. */
104 /* should these macros and the ones below test for range violation? */
105 #define EVENT_NET_TX_FOR_VIF(x) (EVENT_NET_TX << (2 * x))
106 #define EVENT_NET_RX_FOR_VIF(x) (EVENT_NET_RX << (2 * x))
109 /* Bit offsets, as opposed to the above masks. */
110 #define _EVENT_BLK_TX 0
111 #define _EVENT_BLK_RX 1
112 #define _EVENT_TIMER 2
113 #define _EVENT_DIE 3
114 #define _EVENT_NET_TX 4
115 #define _EVENT_NET_RX 5
116 #define _EVENT_NET2_TX 6
117 #define _EVENT_NET2_RX 7
119 #define _EVENT_NET_TX_FOR_VIF(x) (_EVENT_NET_TX + (2 * x))
120 #define _EVENT_NET_RX_FOR_VIF(x) (_EVENT_NET_RX + (2 * x))
122 /*
123 * NB. We expect that this struct is smaller than a page.
124 */
125 typedef struct shared_info_st {
127 /* Bitmask of outstanding event notifications hypervisor -> guest OS. */
128 unsigned long events;
129 /*
130 * Hypervisor will only signal event delivery via the "callback
131 * exception" when this value is non-zero. Hypervisor clears this when
132 * notiying the guest OS -- this prevents unbounded reentrancy and
133 * stack overflow (in this way, acts as an interrupt-enable flag).
134 */
135 unsigned long events_enable;
137 /*
138 * Address for callbacks hypervisor -> guest OS.
139 * Stack frame looks like that of an interrupt.
140 * Code segment is the default flat selector.
141 * This handler will only be called when events_enable is non-zero.
142 */
143 unsigned long event_address;
145 /*
146 * Hypervisor uses this callback when it takes a fault on behalf of
147 * an application. This can happen when returning from interrupts for
148 * example: various faults can occur when reloading the segment
149 * registers, and executing 'iret'.
150 * This callback is provided with an extended stack frame, augmented
151 * with saved values for segment registers %ds and %es:
152 * %ds, %es, %eip, %cs, %eflags [, %oldesp, %oldss]
153 * Code segment is the default flat selector.
154 * FAULTS WHEN CALLING THIS HANDLER WILL TERMINATE THE DOMAIN!!!
155 */
156 unsigned long failsafe_address;
158 /*
159 * CPU ticks since start of day.
160 * `wall_time' counts CPU ticks in real time.
161 * `domain_time' counts CPU ticks during which this domain has run.
162 */
163 unsigned long ticks_per_ms; /* CPU ticks per millisecond */
164 /*
165 * Current wall_time can be found by rdtsc. Only possible use of
166 * variable below is that it provides a timestamp for last update
167 * of domain_time.
168 */
169 unsigned long long wall_time;
170 unsigned long long domain_time;
172 /*
173 * Timeouts for points at which guest OS would like a callback.
174 * This will probably be backed up by a timer heap in the guest OS.
175 * In Linux we use timeouts to update 'jiffies'.
176 */
177 unsigned long long wall_timeout;
178 unsigned long long domain_timeout;
180 /*
181 * Real-Time Clock. This shows time, in seconds, since 1.1.1980.
182 * The timestamp shows the CPU 'wall time' when RTC was last read.
183 * Thus it allows a mapping between 'real time' and 'wall time'.
184 */
185 unsigned long rtc_time;
186 unsigned long long rtc_timestamp;
188 } shared_info_t;
190 /*
191 * NB. We expect that this struct is smaller than a page.
192 */
193 typedef struct start_info_st {
194 unsigned long nr_pages; /* total pages allocated to this domain */
195 shared_info_t *shared_info; /* start address of shared info struct */
196 unsigned long pt_base; /* address of page directory */
197 unsigned long phys_base;
198 unsigned long mod_start; /* start address of pre-loaded module */
199 unsigned long mod_len; /* size (bytes) of pre-loaded module */
200 net_ring_t *net_rings;
201 int num_net_rings;
202 blk_ring_t *blk_ring; /* block io communication rings */
203 unsigned long frame_table; /* mapping of the frame_table for dom0 */
204 unsigned char cmd_line[1]; /* variable-length */
205 } start_info_t;
207 /* For use in guest OSes. */
208 extern shared_info_t *HYPERVISOR_shared_info;
210 #endif /* __HYPERVISOR_IF_H__ */