• Home
  • History
  • Annotate
  • Line#
  • Navigate
  • Raw
  • Download
  • only in /asuswrt-rt-n18u-9.0.0.4.380.2695/release/src-rt-6.x.4708/linux/linux-2.6.36/arch/x86/include/asm/
1/* Written 2000 by Andi Kleen */
2#ifndef _ASM_X86_DESC_DEFS_H
3#define _ASM_X86_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 */
15struct desc_struct {
16	union {
17		struct {
18			unsigned int a;
19			unsigned int b;
20		};
21		struct {
22			u16 limit0;
23			u16 base0;
24			unsigned base1: 8, type: 4, s: 1, dpl: 2, p: 1;
25			unsigned limit: 4, avl: 1, l: 1, d: 1, g: 1, base2: 8;
26		};
27	};
28} __attribute__((packed));
29
30#define GDT_ENTRY_INIT(flags, base, limit) { { { \
31		.a = ((limit) & 0xffff) | (((base) & 0xffff) << 16), \
32		.b = (((base) & 0xff0000) >> 16) | (((flags) & 0xf0ff) << 8) | \
33			((limit) & 0xf0000) | ((base) & 0xff000000), \
34	} } }
35
36enum {
37	GATE_INTERRUPT = 0xE,
38	GATE_TRAP = 0xF,
39	GATE_CALL = 0xC,
40	GATE_TASK = 0x5,
41};
42
43/* 16byte gate */
44struct gate_struct64 {
45	u16 offset_low;
46	u16 segment;
47	unsigned ist : 3, zero0 : 5, type : 5, dpl : 2, p : 1;
48	u16 offset_middle;
49	u32 offset_high;
50	u32 zero1;
51} __attribute__((packed));
52
53#define PTR_LOW(x) ((unsigned long long)(x) & 0xFFFF)
54#define PTR_MIDDLE(x) (((unsigned long long)(x) >> 16) & 0xFFFF)
55#define PTR_HIGH(x) ((unsigned long long)(x) >> 32)
56
57enum {
58	DESC_TSS = 0x9,
59	DESC_LDT = 0x2,
60	DESCTYPE_S = 0x10,	/* !system */
61};
62
63/* LDT or TSS descriptor in the GDT. 16 bytes. */
64struct ldttss_desc64 {
65	u16 limit0;
66	u16 base0;
67	unsigned base1 : 8, type : 5, dpl : 2, p : 1;
68	unsigned limit1 : 4, zero0 : 3, g : 1, base2 : 8;
69	u32 base3;
70	u32 zero1;
71} __attribute__((packed));
72
73#ifdef CONFIG_X86_64
74typedef struct gate_struct64 gate_desc;
75typedef struct ldttss_desc64 ldt_desc;
76typedef struct ldttss_desc64 tss_desc;
77#define gate_offset(g) ((g).offset_low | ((unsigned long)(g).offset_middle << 16) | ((unsigned long)(g).offset_high << 32))
78#define gate_segment(g) ((g).segment)
79#else
80typedef struct desc_struct gate_desc;
81typedef struct desc_struct ldt_desc;
82typedef struct desc_struct tss_desc;
83#define gate_offset(g)		(((g).b & 0xffff0000) | ((g).a & 0x0000ffff))
84#define gate_segment(g)		((g).a >> 16)
85#endif
86
87struct desc_ptr {
88	unsigned short size;
89	unsigned long address;
90} __attribute__((packed)) ;
91
92#endif /* !__ASSEMBLY__ */
93
94#endif /* _ASM_X86_DESC_DEFS_H */
95