debuggers.hg

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