debuggers.hg

view xen/include/public/arch-x86_32.h @ 3686:5c112b235281

bitkeeper revision 1.1159.212.85 (42038b45EjUo-1JiSCHXW0Wav4TZGQ)

x86_64 progress: now entering ring 3. Need a hypercall (SYSCALL)
entry point, and some kind of DOM0 image to test against.
Signed-off-by: keir.fraser@cl.cam.ac.uk
author kaf24@scramble.cl.cam.ac.uk
date Fri Feb 04 14:48:37 2005 +0000 (2005-02-04)
parents 1c55bbe02576
children 393483ae9f62
line source
1 /******************************************************************************
2 * arch-x86_32.h
3 *
4 * Guest OS interface to x86 32-bit Xen.
5 *
6 * Copyright (c) 2004, K A Fraser
7 */
9 #ifndef __XEN_PUBLIC_ARCH_X86_32_H__
10 #define __XEN_PUBLIC_ARCH_X86_32_H__
12 #ifndef PACKED
13 /* GCC-specific way to pack structure definitions (no implicit padding). */
14 #define PACKED __attribute__ ((packed))
15 #endif
17 /*
18 * Pointers and other address fields inside interface structures are padded to
19 * 64 bits. This means that field alignments aren't different between 32- and
20 * 64-bit architectures.
21 */
22 /* NB. Multi-level macro ensures __LINE__ is expanded before concatenation. */
23 #define __MEMORY_PADDING(_X) u32 __pad_ ## _X
24 #define _MEMORY_PADDING(_X) __MEMORY_PADDING(_X)
25 #define MEMORY_PADDING _MEMORY_PADDING(__LINE__)
27 /*
28 * SEGMENT DESCRIPTOR TABLES
29 */
30 /*
31 * A number of GDT entries are reserved by Xen. These are not situated at the
32 * start of the GDT because some stupid OSes export hard-coded selector values
33 * in their ABI. These hard-coded values are always near the start of the GDT,
34 * so Xen places itself out of the way.
35 *
36 * NB. The reserved range is inclusive (that is, both FIRST_RESERVED_GDT_ENTRY
37 * and LAST_RESERVED_GDT_ENTRY are reserved).
38 */
39 #define NR_RESERVED_GDT_ENTRIES 40
40 #define FIRST_RESERVED_GDT_ENTRY 256
41 #define LAST_RESERVED_GDT_ENTRY \
42 (FIRST_RESERVED_GDT_ENTRY + NR_RESERVED_GDT_ENTRIES - 1)
45 /*
46 * These flat segments are in the Xen-private section of every GDT. Since these
47 * are also present in the initial GDT, many OSes will be able to avoid
48 * installing their own GDT.
49 */
50 #define FLAT_RING1_CS 0x0819 /* GDT index 259 */
51 #define FLAT_RING1_DS 0x0821 /* GDT index 260 */
52 #define FLAT_RING1_SS 0x0821 /* GDT index 260 */
53 #define FLAT_RING3_CS 0x082b /* GDT index 261 */
54 #define FLAT_RING3_DS 0x0833 /* GDT index 262 */
55 #define FLAT_RING3_SS 0x0833 /* GDT index 262 */
57 #define FLAT_GUESTOS_CS FLAT_RING1_CS
58 #define FLAT_GUESTOS_DS FLAT_RING1_DS
59 #define FLAT_GUESTOS_SS FLAT_RING1_SS
60 #define FLAT_USER_CS FLAT_RING3_CS
61 #define FLAT_USER_DS FLAT_RING3_DS
62 #define FLAT_USER_SS FLAT_RING3_SS
64 /* And the trap vector is... */
65 #define TRAP_INSTR "int $0x82"
68 /*
69 * Virtual addresses beyond this are not modifiable by guest OSes. The
70 * machine->physical mapping table starts at this address, read-only.
71 */
72 #define HYPERVISOR_VIRT_START (0xFC000000UL)
73 #ifndef machine_to_phys_mapping
74 #define machine_to_phys_mapping ((unsigned long *)HYPERVISOR_VIRT_START)
75 #endif
77 #ifndef __ASSEMBLY__
79 /* NB. Both the following are 32 bits each. */
80 typedef unsigned long memory_t; /* Full-sized pointer/address/memory-size. */
81 typedef unsigned long cpureg_t; /* Full-sized register. */
83 /*
84 * Send an array of these to HYPERVISOR_set_trap_table()
85 */
86 #define TI_GET_DPL(_ti) ((_ti)->flags & 3)
87 #define TI_GET_IF(_ti) ((_ti)->flags & 4)
88 #define TI_SET_DPL(_ti,_dpl) ((_ti)->flags |= (_dpl))
89 #define TI_SET_IF(_ti,_if) ((_ti)->flags |= ((!!(_if))<<2))
90 typedef struct {
91 u8 vector; /* 0: exception vector */
92 u8 flags; /* 1: 0-3: privilege level; 4: clear event enable? */
93 u16 cs; /* 2: code selector */
94 memory_t address; /* 4: code address */
95 } PACKED trap_info_t; /* 8 bytes */
97 typedef struct
98 {
99 unsigned long ebx;
100 unsigned long ecx;
101 unsigned long edx;
102 unsigned long esi;
103 unsigned long edi;
104 unsigned long ebp;
105 unsigned long eax;
106 unsigned long _unused;
107 unsigned long eip;
108 unsigned long cs;
109 unsigned long eflags;
110 unsigned long esp;
111 unsigned long ss;
112 unsigned long es;
113 unsigned long ds;
114 unsigned long fs;
115 unsigned long gs;
116 } PACKED execution_context_t;
118 typedef u64 tsc_timestamp_t; /* RDTSC timestamp */
120 /*
121 * The following is all CPU context. Note that the i387_ctxt block is filled
122 * in by FXSAVE if the CPU has feature FXSR; otherwise FSAVE is used.
123 */
124 typedef struct {
125 #define ECF_I387_VALID (1<<0)
126 #define ECF_VMX_GUEST (2<<0)
127 unsigned long flags;
128 execution_context_t cpu_ctxt; /* User-level CPU registers */
129 char fpu_ctxt[256]; /* User-level FPU registers */
130 trap_info_t trap_ctxt[256]; /* Virtual IDT */
131 unsigned int fast_trap_idx; /* "Fast trap" vector offset */
132 unsigned long ldt_base, ldt_ents; /* LDT (linear address, # ents) */
133 unsigned long gdt_frames[16], gdt_ents; /* GDT (machine frames, # ents) */
134 unsigned long guestos_ss, guestos_esp; /* Virtual TSS (only SS1/ESP1) */
135 unsigned long pt_base; /* CR3 (pagetable base) */
136 unsigned long debugreg[8]; /* DB0-DB7 (debug registers) */
137 unsigned long event_callback_cs; /* CS:EIP of event callback */
138 unsigned long event_callback_eip;
139 unsigned long failsafe_callback_cs; /* CS:EIP of failsafe callback */
140 unsigned long failsafe_callback_eip;
141 } PACKED full_execution_context_t;
143 typedef struct {
144 /* MFN of a table of MFNs that make up p2m table */
145 u64 pfn_to_mfn_frame_list;
146 } PACKED arch_shared_info_t;
148 typedef struct {
149 } PACKED arch_vcpu_info_t;
151 #define ARCH_HAS_FAST_TRAP
153 #endif
155 #endif