1 /* Written 2000 by Andi Kleen */
2 #ifndef ASM_X86__DESC_DEFS_H
3 #define ASM_X86__DESC_DEFS_H
6 * Segment descriptor structure definitions, usable from both x86_64 and i386
12 #include <linux/types.h>
15 * FIXME: Acessing the desc_struct through its fields is more elegant,
16 * and should be the one valid thing to do. However, a lot of open code
17 * still touches the a and b acessors, and doing this allow us to do it
18 * incrementally. We keep the signature as a struct, rather than an union,
19 * so we can get rid of it transparently in the future -- glommer
21 /* 8 byte segment descriptor */
31 unsigned base1: 8, type: 4, s: 1, dpl: 2, p: 1;
32 unsigned limit: 4, avl: 1, l: 1, d: 1, g: 1, base2: 8;
35 } __attribute__((packed));
45 struct gate_struct64 {
48 unsigned ist : 3, zero0 : 5, type : 5, dpl : 2, p : 1;
52 } __attribute__((packed));
54 #define PTR_LOW(x) ((unsigned long long)(x) & 0xFFFF)
55 #define PTR_MIDDLE(x) (((unsigned long long)(x) >> 16) & 0xFFFF)
56 #define PTR_HIGH(x) ((unsigned long long)(x) >> 32)
61 DESCTYPE_S = 0x10, /* !system */
64 /* LDT or TSS descriptor in the GDT. 16 bytes. */
65 struct ldttss_desc64 {
68 unsigned base1 : 8, type : 5, dpl : 2, p : 1;
69 unsigned limit1 : 4, zero0 : 3, g : 1, base2 : 8;
72 } __attribute__((packed));
75 typedef struct gate_struct64 gate_desc;
76 typedef struct ldttss_desc64 ldt_desc;
77 typedef struct ldttss_desc64 tss_desc;
78 #define gate_offset(g) ((g).offset_low | ((unsigned long)(g).offset_middle << 16) | ((unsigned long)(g).offset_high << 32))
79 #define gate_segment(g) ((g).segment)
81 typedef struct desc_struct gate_desc;
82 typedef struct desc_struct ldt_desc;
83 typedef struct desc_struct tss_desc;
84 #define gate_offset(g) (((g).b & 0xffff0000) | ((g).a & 0x0000ffff))
85 #define gate_segment(g) ((g).a >> 16)
90 unsigned long address;
91 } __attribute__((packed)) ;
93 #endif /* !__ASSEMBLY__ */
95 #endif /* ASM_X86__DESC_DEFS_H */