debuggers.hg

view xen/include/public/arch-x86_64.h @ 3661:060c1ea52343

bitkeeper revision 1.1159.212.73 (420154ceFUvIANCrxSTgPyOjFi1Pag)

More x86_64 work. Interrupts and exceptions are now working. Next step is
DOM0 construction. First part of that is to map rest of physical memory,
allocate and map the mach_to_phys table, and fix arch_init_memory().
Signed-off-by: keir.fraser@cl.cam.ac.uk
author kaf24@viper.(none)
date Wed Feb 02 22:31:42 2005 +0000 (2005-02-02)
parents eef1949801b8
children d55d523078f7
line source
1 /******************************************************************************
2 * arch-x86_64.h
3 *
4 * Guest OS interface to x86 64-bit Xen.
5 *
6 * Copyright (c) 2004, K A Fraser
7 */
9 #ifndef __XEN_PUBLIC_ARCH_X86_64_H__
10 #define __XEN_PUBLIC_ARCH_X86_64_H__
12 #ifndef PACKED
13 /* GCC-specific way to pack structure definitions (no implicit padding). */
14 #define PACKED __attribute__ ((packed))
15 #endif
17 /* Pointers are naturally 64 bits in this architecture; no padding needed. */
18 #define _MEMORY_PADDING(_X)
19 #define MEMORY_PADDING
21 /*
22 * SEGMENT DESCRIPTOR TABLES
23 */
24 /*
25 * A number of GDT entries are reserved by Xen. These are not situated at the
26 * start of the GDT because some stupid OSes export hard-coded selector values
27 * in their ABI. These hard-coded values are always near the start of the GDT,
28 * so Xen places itself out of the way.
29 *
30 * NB. The reserved range is inclusive (that is, both FIRST_RESERVED_GDT_ENTRY
31 * and LAST_RESERVED_GDT_ENTRY are reserved).
32 */
33 #define NR_RESERVED_GDT_ENTRIES 72
34 #define FIRST_RESERVED_GDT_ENTRY 256
35 #define LAST_RESERVED_GDT_ENTRY \
36 (FIRST_RESERVED_GDT_ENTRY + NR_RESERVED_GDT_ENTRIES - 1)
38 /*
39 * 64-bit segment selectors
40 * These flat segments are in the Xen-private section of every GDT. Since these
41 * are also present in the initial GDT, many OSes will be able to avoid
42 * installing their own GDT.
43 */
45 #define FLAT_RING3_CS32 0x0823 /* GDT index 260 */
46 #define FLAT_RING3_CS64 0x082b /* GDT index 261 */
47 #define FLAT_RING3_DS 0x0833 /* GDT index 262 */
49 #define FLAT_GUESTOS_DS FLAT_RING3_DS
50 #define FLAT_GUESTOS_CS FLAT_RING3_CS64
51 #define FLAT_GUESTOS_CS32 FLAT_RING3_CS32
53 #define FLAT_USER_DS FLAT_RING3_DS
54 #define FLAT_USER_CS FLAT_RING3_CS64
55 #define FLAT_USER_CS32 FLAT_RING3_CS32
57 /* And the trap vector is... */
58 #define TRAP_INSTR "syscall"
60 /* The machine->physical mapping table starts at this address, read-only. */
61 #ifndef machine_to_phys_mapping
62 #define machine_to_phys_mapping ((unsigned long *)0xffff810000000000ULL)
63 #endif
65 #ifndef __ASSEMBLY__
67 /* NB. Both the following are 64 bits each. */
68 typedef unsigned long memory_t; /* Full-sized pointer/address/memory-size. */
69 typedef unsigned long cpureg_t; /* Full-sized register. */
71 /*
72 * Send an array of these to HYPERVISOR_set_trap_table()
73 */
74 #define TI_GET_DPL(_ti) ((_ti)->flags & 3)
75 #define TI_GET_IF(_ti) ((_ti)->flags & 4)
76 #define TI_SET_DPL(_ti,_dpl) ((_ti)->flags |= (_dpl))
77 #define TI_SET_IF(_ti,_if) ((_ti)->flags |= ((!!(_if))<<2))
78 typedef struct {
79 u8 vector; /* 0: exception vector */
80 u8 flags; /* 1: 0-3: privilege level; 4: clear event enable? */
81 u16 cs; /* 2: code selector */
82 u32 __pad; /* 4 */
83 memory_t address; /* 8: code address */
84 } PACKED trap_info_t; /* 16 bytes */
86 typedef struct
87 {
88 unsigned long r15;
89 unsigned long r14;
90 unsigned long r13;
91 unsigned long r12;
92 unsigned long rbp;
93 unsigned long rbx;
94 unsigned long r11;
95 unsigned long r10;
96 unsigned long r9;
97 unsigned long r8;
98 unsigned long rax;
99 unsigned long rcx;
100 unsigned long rdx;
101 unsigned long rsi;
102 unsigned long rdi;
103 unsigned long rip;
104 unsigned long cs;
105 unsigned long eflags;
106 unsigned long rsp;
107 unsigned long ss;
108 } PACKED execution_context_t;
110 typedef u64 tsc_timestamp_t; /* RDTSC timestamp */
112 /*
113 * The following is all CPU context. Note that the i387_ctxt block is filled
114 * in by FXSAVE if the CPU has feature FXSR; otherwise FSAVE is used.
115 */
116 typedef struct {
117 #define ECF_I387_VALID (1<<0)
118 #define ECF_VMX_GUEST (2<<0)
119 unsigned long flags;
120 execution_context_t cpu_ctxt; /* User-level CPU registers */
121 char fpu_ctxt[512]; /* User-level FPU registers */
122 trap_info_t trap_ctxt[256]; /* Virtual IDT */
123 unsigned long ldt_base, ldt_ents; /* LDT (linear address, # ents) */
124 unsigned long gdt_frames[16], gdt_ents; /* GDT (machine frames, # ents) */
125 unsigned long guestos_ss, guestos_esp; /* Virtual TSS (only SS1/ESP1) */
126 unsigned long pt_base; /* CR3 (pagetable base) */
127 unsigned long debugreg[8]; /* DB0-DB7 (debug registers) */
128 unsigned long event_callback_cs; /* CS:EIP of event callback */
129 unsigned long event_callback_eip;
130 unsigned long failsafe_callback_cs; /* CS:EIP of failsafe callback */
131 unsigned long failsafe_callback_eip;
132 } PACKED full_execution_context_t;
134 typedef struct {
135 u64 mfn_to_pfn_start; /* MFN of start of m2p table */
136 u64 pfn_to_mfn_frame_list; /* MFN of a table of MFNs that
137 make up p2m table */
138 } PACKED arch_shared_info_t;
140 #endif /* !__ASSEMBLY__ */
142 #endif