aboutsummaryrefslogtreecommitdiffstats
path: root/include/asm-x86/desc_64.h
diff options
context:
space:
mode:
authorGlauber de Oliveira Costa <gcosta@redhat.com>2007-10-19 14:35:03 -0400
committerThomas Gleixner <tglx@linutronix.de>2007-10-19 14:35:03 -0400
commit9d1c6e7c86ddc366d67f0c5fa77be9b93710037a (patch)
tree2561f09ea7393c04634352808b6cba2195099b73 /include/asm-x86/desc_64.h
parent9d975ebda56699c1b8480e9736caf33a61ccb810 (diff)
x86: use descriptor's functions instead of inline assembly
This patch provides a new set of functions for managing the descriptor tables that can be used instead of putting the raw assembly in .c files. Remodeling of store_tr() suggested by Frederik Deweerdt. [ tglx: arch/x86 adaptation ] Signed-off-by: Glauber de Oliveira Costa <gcosta@redhat.com> Signed-off-by: Andi Kleen <ak@suse.de> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Ingo Molnar <mingo@elte.hu> Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Diffstat (limited to 'include/asm-x86/desc_64.h')
-rw-r--r--include/asm-x86/desc_64.h30
1 files changed, 30 insertions, 0 deletions
diff --git a/include/asm-x86/desc_64.h b/include/asm-x86/desc_64.h
index ac991b5ca0fd..7d9c938e69fd 100644
--- a/include/asm-x86/desc_64.h
+++ b/include/asm-x86/desc_64.h
@@ -20,6 +20,16 @@ extern struct desc_struct cpu_gdt_table[GDT_ENTRIES];
20#define load_LDT_desc() asm volatile("lldt %w0"::"r" (GDT_ENTRY_LDT*8)) 20#define load_LDT_desc() asm volatile("lldt %w0"::"r" (GDT_ENTRY_LDT*8))
21#define clear_LDT() asm volatile("lldt %w0"::"r" (0)) 21#define clear_LDT() asm volatile("lldt %w0"::"r" (0))
22 22
23static inline unsigned long __store_tr(void)
24{
25 unsigned long tr;
26
27 asm volatile ("str %w0":"=r" (tr));
28 return tr;
29}
30
31#define store_tr(tr) (tr) = __store_tr()
32
23/* 33/*
24 * This is the ldt that every process will get unless we need 34 * This is the ldt that every process will get unless we need
25 * something other than this. 35 * something other than this.
@@ -31,6 +41,16 @@ extern struct desc_ptr cpu_gdt_descr[];
31/* the cpu gdt accessor */ 41/* the cpu gdt accessor */
32#define cpu_gdt(_cpu) ((struct desc_struct *)cpu_gdt_descr[_cpu].address) 42#define cpu_gdt(_cpu) ((struct desc_struct *)cpu_gdt_descr[_cpu].address)
33 43
44static inline void load_gdt(const struct desc_ptr *ptr)
45{
46 asm volatile("lgdt %w0"::"m" (*ptr));
47}
48
49static inline void store_gdt(struct desc_ptr *ptr)
50{
51 asm("sgdt %w0":"=m" (*ptr));
52}
53
34static inline void _set_gate(void *adr, unsigned type, unsigned long func, unsigned dpl, unsigned ist) 54static inline void _set_gate(void *adr, unsigned type, unsigned long func, unsigned dpl, unsigned ist)
35{ 55{
36 struct gate_struct s; 56 struct gate_struct s;
@@ -71,6 +91,16 @@ static inline void set_system_gate_ist(int nr, void *func, unsigned ist)
71 _set_gate(&idt_table[nr], GATE_INTERRUPT, (unsigned long) func, 3, ist); 91 _set_gate(&idt_table[nr], GATE_INTERRUPT, (unsigned long) func, 3, ist);
72} 92}
73 93
94static inline void load_idt(const struct desc_ptr *ptr)
95{
96 asm volatile("lidt %w0"::"m" (*ptr));
97}
98
99static inline void store_idt(struct desc_ptr *dtr)
100{
101 asm("sidt %w0":"=m" (*dtr));
102}
103
74static inline void set_tssldt_descriptor(void *ptr, unsigned long tss, unsigned type, 104static inline void set_tssldt_descriptor(void *ptr, unsigned long tss, unsigned type,
75 unsigned size) 105 unsigned size)
76{ 106{