x86: unify paravirt pieces of descriptor handling
[deliverable/linux.git] / include / asm-x86 / desc_defs.h
CommitLineData
249e83fe
AK
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
6842ef0e
GOC
14/*
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
20 */
249e83fe
AK
21// 8 byte segment descriptor
22struct desc_struct {
6842ef0e
GOC
23 union {
24 struct { unsigned int a, b; };
25 struct {
26 u16 limit0;
27 u16 base0;
28 unsigned base1: 8, type: 4, s: 1, dpl: 2, p: 1;
29 unsigned limit: 4, avl: 1, l: 1, d: 1, g: 1, base2: 8;
30 };
249e83fe 31
6842ef0e
GOC
32 };
33} __attribute__((packed));
249e83fe
AK
34
35enum {
36 GATE_INTERRUPT = 0xE,
37 GATE_TRAP = 0xF,
38 GATE_CALL = 0xC,
39};
40
41// 16byte gate
010d4f82 42struct gate_struct64 {
249e83fe
AK
43 u16 offset_low;
44 u16 segment;
45 unsigned ist : 3, zero0 : 5, type : 5, dpl : 2, p : 1;
46 u16 offset_middle;
47 u32 offset_high;
48 u32 zero1;
49} __attribute__((packed));
50
54cd0eac
GOC
51#define PTR_LOW(x) ((unsigned long long)(x) & 0xFFFF)
52#define PTR_MIDDLE(x) (((unsigned long long)(x) >> 16) & 0xFFFF)
53#define PTR_HIGH(x) ((unsigned long long)(x) >> 32)
249e83fe
AK
54
55enum {
56 DESC_TSS = 0x9,
57 DESC_LDT = 0x2,
59fbed77
GOC
58 DESCTYPE_TASK = 0x85, /* present, system, DPL-0, task gate */
59 DESCTYPE_INT = 0x8e, /* present, system, DPL-0, interrupt gate */
60 DESCTYPE_TRAP = 0x8f, /* present, system, DPL-0, trap gate */
61 DESCTYPE_DPL3 = 0x60, /* DPL-3 */
62 DESCTYPE_S = 0x10, /* !system */
249e83fe
AK
63};
64
65// LDT or TSS descriptor in the GDT. 16 bytes.
25deca53 66struct ldttss_desc64 {
249e83fe
AK
67 u16 limit0;
68 u16 base0;
69 unsigned base1 : 8, type : 5, dpl : 2, p : 1;
70 unsigned limit1 : 4, zero0 : 3, g : 1, base2 : 8;
71 u32 base3;
72 u32 zero1;
73} __attribute__((packed));
74
010d4f82
GOC
75#ifdef CONFIG_X86_64
76typedef struct gate_struct64 gate_desc;
25deca53 77typedef struct ldttss_desc64 ldt_desc;
18245d5b 78typedef struct ldttss_desc64 tss_desc;
010d4f82
GOC
79#else
80typedef struct desc_struct gate_desc;
25deca53 81typedef struct desc_struct ldt_desc;
18245d5b 82typedef struct desc_struct tss_desc;
010d4f82
GOC
83#endif
84
249e83fe
AK
85struct desc_ptr {
86 unsigned short size;
87 unsigned long address;
88} __attribute__((packed)) ;
89
90
91#endif /* !__ASSEMBLY__ */
92
93#endif
This page took 0.253598 seconds and 5 git commands to generate.