debuggers.hg

view xen/include/asm-x86/desc.h @ 3635:ed902e5c4b49

bitkeeper revision 1.1159.212.62 (41fff40aESe4aWS82z_rLHeonXpxuQ)

More x86/64 stuff.
Signed-off-by: keir.fraser@cl.cam.ac.uk
author kaf24@scramble.cl.cam.ac.uk
date Tue Feb 01 21:26:34 2005 +0000 (2005-02-01)
parents ddf5b350364f
children 9a9c5a491401 e6af5d8f8b39 fd1dd0663b09
line source
1 #ifndef __ARCH_DESC_H
2 #define __ARCH_DESC_H
4 #define LDT_ENTRY_SIZE 8
6 #define __DOUBLEFAULT_TSS_ENTRY FIRST_RESERVED_GDT_ENTRY
8 #define __FIRST_TSS_ENTRY (FIRST_RESERVED_GDT_ENTRY + 8)
9 #define __FIRST_LDT_ENTRY (__FIRST_TSS_ENTRY + 1)
11 #define __TSS(n) (((n)<<1) + __FIRST_TSS_ENTRY)
12 #define __LDT(n) (((n)<<1) + __FIRST_LDT_ENTRY)
14 #define load_TR(n) __asm__ __volatile__ ("ltr %%ax" : : "a" (__TSS(n)<<3) )
16 /*
17 * Guest OS must provide its own code selectors, or use the one we provide. The
18 * RPL must be 1, as we only create bounce frames to ring 1. Any LDT selector
19 * value is okay. Note that checking only the RPL is insufficient: if the
20 * selector is poked into an interrupt, trap or call gate then the RPL is
21 * ignored when the gate is accessed.
22 */
23 #define VALID_SEL(_s) \
24 (((((_s)>>3) < FIRST_RESERVED_GDT_ENTRY) || \
25 (((_s)>>3) > LAST_RESERVED_GDT_ENTRY) || \
26 ((_s)&4)) && \
27 (((_s)&3) == 1))
28 #define VALID_CODESEL(_s) ((_s) == FLAT_RING1_CS || VALID_SEL(_s))
30 /* These are bitmasks for the high 32 bits of a descriptor table entry. */
31 #define _SEGMENT_TYPE (15<< 8)
32 #define _SEGMENT_EC ( 1<<10) /* Expand-down or Conforming segment */
33 #define _SEGMENT_CODE ( 1<<11) /* Code (vs data) segment for non-system
34 segments */
35 #define _SEGMENT_S ( 1<<12) /* System descriptor (yes iff S==0) */
36 #define _SEGMENT_DPL ( 3<<13) /* Descriptor Privilege Level */
37 #define _SEGMENT_P ( 1<<15) /* Segment Present */
38 #define _SEGMENT_DB ( 1<<22) /* 16- or 32-bit segment */
39 #define _SEGMENT_G ( 1<<23) /* Granularity */
41 #ifndef __ASSEMBLY__
42 struct desc_struct {
43 u32 a, b;
44 };
46 #if defined(__x86_64__)
47 typedef struct {
48 u64 a, b;
49 } idt_entry_t;
50 #elif defined(__i386__)
51 typedef struct desc_struct idt_entry_t;
52 #endif
54 extern struct desc_struct gdt_table[];
55 extern struct desc_struct *gdt;
56 extern idt_entry_t *idt;
58 struct Xgt_desc_struct {
59 unsigned short size;
60 unsigned long address __attribute__((packed));
61 };
63 #define idt_descr (*(struct Xgt_desc_struct *)((char *)&idt - 2))
64 #define gdt_descr (*(struct Xgt_desc_struct *)((char *)&gdt - 2))
66 extern void set_intr_gate(unsigned int irq, void * addr);
67 extern void set_tss_desc(unsigned int n, void *addr);
69 #endif /* !__ASSEMBLY__ */
71 #endif