diff options
author | Avi Kivity <avi@qumranet.com> | 2006-12-06 20:14:04 -0500 |
---|---|---|
committer | Andi Kleen <andi@basil.nowhere.org> | 2006-12-06 20:14:04 -0500 |
commit | 249e83fe839a13b5dc94285daeeaf70f6e54d930 (patch) | |
tree | 3bd37f33160916b6eef50624b795748737e2f03d /include/asm-x86_64/desc_defs.h | |
parent | 4c7aa6c3b25ef96bc1b723238041195e3d8bf047 (diff) |
[PATCH] x86-64: Extract segment descriptor definitions for use outside
Code that wants to use struct desc_struct cannot do so on i386 because
desc.h contains other code that will only compile on x86_64.
So extract the structure definitions into a asm-x86_64/desc_defs.h.
Signed-off-by: Avi Kivity <avi@qumranet.com>
Signed-off-by: Andi Kleen <ak@suse.de>
include/asm-x86_64/desc.h | 53 -------------------------------
include/asm-x86_64/desc_defs.h | 69 +++++++++++++++++++++++++++++++++++++++++
2 files changed, 70 insertions(+), 52 deletions(-)
Diffstat (limited to 'include/asm-x86_64/desc_defs.h')
-rw-r--r-- | include/asm-x86_64/desc_defs.h | 69 |
1 files changed, 69 insertions, 0 deletions
diff --git a/include/asm-x86_64/desc_defs.h b/include/asm-x86_64/desc_defs.h new file mode 100644 index 000000000000..089004070099 --- /dev/null +++ b/include/asm-x86_64/desc_defs.h | |||
@@ -0,0 +1,69 @@ | |||
1 | /* Written 2000 by Andi Kleen */ | ||
2 | #ifndef __ARCH_DESC_DEFS_H | ||
3 | #define __ARCH_DESC_DEFS_H | ||
4 | |||
5 | /* | ||
6 | * Segment descriptor structure definitions, usable from both x86_64 and i386 | ||
7 | * archs. | ||
8 | */ | ||
9 | |||
10 | #ifndef __ASSEMBLY__ | ||
11 | |||
12 | #include <linux/types.h> | ||
13 | |||
14 | // 8 byte segment descriptor | ||
15 | struct desc_struct { | ||
16 | u16 limit0; | ||
17 | u16 base0; | ||
18 | unsigned base1 : 8, type : 4, s : 1, dpl : 2, p : 1; | ||
19 | unsigned limit : 4, avl : 1, l : 1, d : 1, g : 1, base2 : 8; | ||
20 | } __attribute__((packed)); | ||
21 | |||
22 | struct n_desc_struct { | ||
23 | unsigned int a,b; | ||
24 | }; | ||
25 | |||
26 | enum { | ||
27 | GATE_INTERRUPT = 0xE, | ||
28 | GATE_TRAP = 0xF, | ||
29 | GATE_CALL = 0xC, | ||
30 | }; | ||
31 | |||
32 | // 16byte gate | ||
33 | struct gate_struct { | ||
34 | u16 offset_low; | ||
35 | u16 segment; | ||
36 | unsigned ist : 3, zero0 : 5, type : 5, dpl : 2, p : 1; | ||
37 | u16 offset_middle; | ||
38 | u32 offset_high; | ||
39 | u32 zero1; | ||
40 | } __attribute__((packed)); | ||
41 | |||
42 | #define PTR_LOW(x) ((unsigned long)(x) & 0xFFFF) | ||
43 | #define PTR_MIDDLE(x) (((unsigned long)(x) >> 16) & 0xFFFF) | ||
44 | #define PTR_HIGH(x) ((unsigned long)(x) >> 32) | ||
45 | |||
46 | enum { | ||
47 | DESC_TSS = 0x9, | ||
48 | DESC_LDT = 0x2, | ||
49 | }; | ||
50 | |||
51 | // LDT or TSS descriptor in the GDT. 16 bytes. | ||
52 | struct ldttss_desc { | ||
53 | u16 limit0; | ||
54 | u16 base0; | ||
55 | unsigned base1 : 8, type : 5, dpl : 2, p : 1; | ||
56 | unsigned limit1 : 4, zero0 : 3, g : 1, base2 : 8; | ||
57 | u32 base3; | ||
58 | u32 zero1; | ||
59 | } __attribute__((packed)); | ||
60 | |||
61 | struct desc_ptr { | ||
62 | unsigned short size; | ||
63 | unsigned long address; | ||
64 | } __attribute__((packed)) ; | ||
65 | |||
66 | |||
67 | #endif /* !__ASSEMBLY__ */ | ||
68 | |||
69 | #endif | ||