debuggers.hg

view xen/include/asm-x86/desc.h @ 3183:ddf5b350364f

bitkeeper revision 1.1159.1.454 (41a61ea2XESj-qDfpRLao5W410NKvg)

sync w/ head.
author cl349@arcadians.cl.cam.ac.uk
date Thu Nov 25 18:04:18 2004 +0000 (2004-11-25)
parents 0366608703aa b2e2e9db7739
children ed902e5c4b49 bbe8541361dd
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 unsigned long a,b;
44 };
46 extern struct desc_struct gdt_table[];
47 extern struct desc_struct *idt, *gdt;
49 struct Xgt_desc_struct {
50 unsigned short size;
51 unsigned long address __attribute__((packed));
52 };
54 #define idt_descr (*(struct Xgt_desc_struct *)((char *)&idt - 2))
55 #define gdt_descr (*(struct Xgt_desc_struct *)((char *)&gdt - 2))
57 extern void set_intr_gate(unsigned int irq, void * addr);
58 extern void set_tss_desc(unsigned int n, void *addr);
60 #endif /* !__ASSEMBLY__ */
62 #endif