blob: 09ea05243497d9bba4e1f567f3dec2ada1c8e3f3 [file] [log] [blame]
Avi Kivity249e83f2006-12-07 02:14:04 +01001/* 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
Glauber de Oliveira Costa6842ef02008-01-30 13:31:11 +010014/*
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 */
Avi Kivity249e83f2006-12-07 02:14:04 +010021// 8 byte segment descriptor
22struct desc_struct {
Glauber de Oliveira Costa6842ef02008-01-30 13:31:11 +010023 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 };
Avi Kivity249e83f2006-12-07 02:14:04 +010031
Glauber de Oliveira Costa6842ef02008-01-30 13:31:11 +010032 };
33} __attribute__((packed));
Avi Kivity249e83f2006-12-07 02:14:04 +010034
35enum {
36 GATE_INTERRUPT = 0xE,
37 GATE_TRAP = 0xF,
38 GATE_CALL = 0xC,
39};
40
41// 16byte gate
Glauber de Oliveira Costa010d4f82008-01-30 13:31:12 +010042struct gate_struct64 {
Avi Kivity249e83f2006-12-07 02:14:04 +010043 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
51#define PTR_LOW(x) ((unsigned long)(x) & 0xFFFF)
52#define PTR_MIDDLE(x) (((unsigned long)(x) >> 16) & 0xFFFF)
53#define PTR_HIGH(x) ((unsigned long)(x) >> 32)
54
55enum {
56 DESC_TSS = 0x9,
57 DESC_LDT = 0x2,
58};
59
60// LDT or TSS descriptor in the GDT. 16 bytes.
Glauber de Oliveira Costa25deca52008-01-30 13:31:13 +010061struct ldttss_desc64 {
Avi Kivity249e83f2006-12-07 02:14:04 +010062 u16 limit0;
63 u16 base0;
64 unsigned base1 : 8, type : 5, dpl : 2, p : 1;
65 unsigned limit1 : 4, zero0 : 3, g : 1, base2 : 8;
66 u32 base3;
67 u32 zero1;
68} __attribute__((packed));
69
Glauber de Oliveira Costa010d4f82008-01-30 13:31:12 +010070#ifdef CONFIG_X86_64
71typedef struct gate_struct64 gate_desc;
Glauber de Oliveira Costa25deca52008-01-30 13:31:13 +010072typedef struct ldttss_desc64 ldt_desc;
Glauber de Oliveira Costa010d4f82008-01-30 13:31:12 +010073#else
74typedef struct desc_struct gate_desc;
Glauber de Oliveira Costa25deca52008-01-30 13:31:13 +010075typedef struct desc_struct ldt_desc;
Glauber de Oliveira Costa010d4f82008-01-30 13:31:12 +010076#endif
77
Avi Kivity249e83f2006-12-07 02:14:04 +010078struct desc_ptr {
79 unsigned short size;
80 unsigned long address;
81} __attribute__((packed)) ;
82
83
84#endif /* !__ASSEMBLY__ */
85
86#endif