debuggers.hg

view xen/include/public/arch-x86_32.h @ 3515:d331c6994d28

bitkeeper revision 1.1159.223.12 (41f14d3cE4GADmEAEr6XE9nXX4dyGw)

Common-code cleanups. Moved arch-specific code out into arch/x86
and asm-x86.
author kaf24@scramble.cl.cam.ac.uk
date Fri Jan 21 18:43:08 2005 +0000 (2005-01-21)
parents 708bd9c8362b
children 46c14b1a4351 0dc3b8b8c298
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_RING3_CS 0x082b /* GDT index 261 */
53 #define FLAT_RING3_DS 0x0833 /* GDT index 262 */
55 #define FLAT_GUESTOS_CS FLAT_RING1_CS
56 #define FLAT_GUESTOS_DS FLAT_RING1_DS
57 #define FLAT_USER_CS FLAT_RING3_CS
58 #define FLAT_USER_DS FLAT_RING3_DS
60 /* And the trap vector is... */
61 #define TRAP_INSTR "int $0x82"
64 /*
65 * Virtual addresses beyond this are not modifiable by guest OSes. The
66 * machine->physical mapping table starts at this address, read-only.
67 */
68 #define HYPERVISOR_VIRT_START (0xFC000000UL)
69 #ifndef machine_to_phys_mapping
70 #define machine_to_phys_mapping ((unsigned long *)HYPERVISOR_VIRT_START)
71 #endif
73 #ifndef __ASSEMBLY__
75 /* NB. Both the following are 32 bits each. */
76 typedef unsigned long memory_t; /* Full-sized pointer/address/memory-size. */
77 typedef unsigned long cpureg_t; /* Full-sized register. */
79 /*
80 * Send an array of these to HYPERVISOR_set_trap_table()
81 */
82 #define TI_GET_DPL(_ti) ((_ti)->flags & 3)
83 #define TI_GET_IF(_ti) ((_ti)->flags & 4)
84 #define TI_SET_DPL(_ti,_dpl) ((_ti)->flags |= (_dpl))
85 #define TI_SET_IF(_ti,_if) ((_ti)->flags |= ((!!(_if))<<2))
86 typedef struct {
87 u8 vector; /* 0: exception vector */
88 u8 flags; /* 1: 0-3: privilege level; 4: clear event enable? */
89 u16 cs; /* 2: code selector */
90 memory_t address; /* 4: code address */
91 } PACKED trap_info_t; /* 8 bytes */
93 typedef struct
94 {
95 unsigned long ebx;
96 unsigned long ecx;
97 unsigned long edx;
98 unsigned long esi;
99 unsigned long edi;
100 unsigned long ebp;
101 unsigned long eax;
102 unsigned long _unused;
103 unsigned long eip;
104 unsigned long cs;
105 unsigned long eflags;
106 unsigned long esp;
107 unsigned long ss;
108 unsigned long es;
109 unsigned long ds;
110 unsigned long fs;
111 unsigned long gs;
112 } PACKED execution_context_t;
114 typedef u64 tsc_timestamp_t; /* RDTSC timestamp */
116 /*
117 * The following is all CPU context. Note that the i387_ctxt block is filled
118 * in by FXSAVE if the CPU has feature FXSR; otherwise FSAVE is used.
119 */
120 typedef struct {
121 #define ECF_I387_VALID (1<<0)
122 unsigned long flags;
123 execution_context_t cpu_ctxt; /* User-level CPU registers */
124 char fpu_ctxt[256]; /* User-level FPU registers */
125 trap_info_t trap_ctxt[256]; /* Virtual IDT */
126 unsigned int fast_trap_idx; /* "Fast trap" vector offset */
127 unsigned long ldt_base, ldt_ents; /* LDT (linear address, # ents) */
128 unsigned long gdt_frames[16], gdt_ents; /* GDT (machine frames, # ents) */
129 unsigned long guestos_ss, guestos_esp; /* Virtual TSS (only SS1/ESP1) */
130 unsigned long pt_base; /* CR3 (pagetable base) */
131 unsigned long debugreg[8]; /* DB0-DB7 (debug registers) */
132 unsigned long event_callback_cs; /* CS:EIP of event callback */
133 unsigned long event_callback_eip;
134 unsigned long failsafe_callback_cs; /* CS:EIP of failsafe callback */
135 unsigned long failsafe_callback_eip;
136 } PACKED full_execution_context_t;
138 typedef struct {
139 u64 mfn_to_pfn_start; /* MFN of start of m2p table */
140 u64 pfn_to_mfn_frame_list; /* MFN of a table of MFNs that
141 make up p2m table */
142 } PACKED arch_shared_info_t;
144 #define ARCH_HAS_FAST_TRAP
146 #endif
148 #endif