ia64/xen-unstable

view xen/include/asm-i386/desc.h @ 722:7a9d47fea66c

bitkeeper revision 1.428 (3f677454_j81KDQLm_L7AscjYn2nYg)

Merge labyrinth.cl.cam.ac.uk:/auto/groups/xeno/BK/xeno.bk
into labyrinth.cl.cam.ac.uk:/auto/anfs/scratch/labyrinth/iap10/xeno-clone/xeno.bk
author iap10@labyrinth.cl.cam.ac.uk
date Tue Sep 16 20:36:36 2003 +0000 (2003-09-16)
parents 29c5d712802c d0cdb9994a2b
children f4b23abe3038
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.
18 * The RPL must be 1, as we only create bounce frames to ring 1.
19 * Any LDT selector value is okay.
20 */
22 #define VALID_SEL(_s) \
23 (((((_s)>>3) < FIRST_RESERVED_GDT_ENTRY) || \
24 (((_s)>>3) > LAST_RESERVED_GDT_ENTRY) || \
25 ((_s)&4)) && \
26 (((_s)&3) == 1))
28 #define VALID_CODESEL(_s) ((_s) == FLAT_RING1_CS || VALID_SEL(_s))
30 #define VALID_DATASEL(_s) ((_s) == FLAT_RING1_DS || VALID_SEL(_s))
32 /* These are bitmasks for the first 32 bits of a descriptor table entry. */
33 #define _SEGMENT_TYPE (15<< 8)
34 #define _SEGMENT_S ( 1<<12) /* System descriptor (yes iff S==0) */
35 #define _SEGMENT_DPL ( 3<<13) /* Descriptor Privilege Level */
36 #define _SEGMENT_P ( 1<<15) /* Segment Present */
37 #define _SEGMENT_G ( 1<<23) /* Granularity */
39 #ifndef __ASSEMBLY__
40 struct desc_struct {
41 unsigned long a,b;
42 };
44 extern struct desc_struct gdt_table[];
45 extern struct desc_struct *idt, *gdt;
47 struct Xgt_desc_struct {
48 unsigned short size;
49 unsigned long address __attribute__((packed));
50 };
52 #define idt_descr (*(struct Xgt_desc_struct *)((char *)&idt - 2))
53 #define gdt_descr (*(struct Xgt_desc_struct *)((char *)&gdt - 2))
55 extern void set_intr_gate(unsigned int irq, void * addr);
56 extern void set_tss_desc(unsigned int n, void *addr);
58 #endif /* !__ASSEMBLY__ */
60 #endif