5 #include <asm/segment.h>
9 #include <linux/preempt.h>
10 #include <linux/smp.h>
14 extern struct desc_struct cpu_gdt_table[NR_CPUS][GDT_ENTRIES];
16 struct Xgt_desc_struct {
18 unsigned long address __attribute__((packed));
20 } __attribute__ ((packed));
22 extern struct Xgt_desc_struct idt_descr, cpu_gdt_descr[NR_CPUS];
24 extern void trap_init_virtual_IDT(void);
25 extern void trap_init_virtual_GDT(void);
27 asmlinkage int system_call(void);
28 asmlinkage void lcall7(void);
29 asmlinkage void lcall27(void);
31 #define load_TR_desc() __asm__ __volatile__("ltr %%ax"::"a" (GDT_ENTRY_TSS*8))
32 #define load_LDT_desc() __asm__ __volatile__("lldt %%ax"::"a" (GDT_ENTRY_LDT*8))
35 * This is the ldt that every process will get unless we need
36 * something other than this.
38 extern struct desc_struct default_ldt[];
39 extern void set_intr_gate(unsigned int irq, void * addr);
40 extern void set_trap_gate(unsigned int n, void *addr);
42 #define _set_tssldt_desc(n,addr,limit,type) \
43 __asm__ __volatile__ ("movw %w3,0(%2)\n\t" \
44 "movw %%ax,2(%2)\n\t" \
45 "rorl $16,%%eax\n\t" \
46 "movb %%al,4(%2)\n\t" \
49 "movb %%ah,7(%2)\n\t" \
51 : "=m"(*(n)) : "a" (addr), "r"(n), "ir"(limit), "i"(type))
53 static inline void __set_tss_desc(unsigned int cpu, unsigned int entry, void *addr)
55 _set_tssldt_desc(&cpu_gdt_table[cpu][entry], (int)addr, 235, 0x89);
58 #define set_tss_desc(cpu,addr) __set_tss_desc(cpu, GDT_ENTRY_TSS, addr)
60 static inline void set_ldt_desc(unsigned int cpu, void *addr, unsigned int size)
62 _set_tssldt_desc(&cpu_gdt_table[cpu][GDT_ENTRY_LDT], (int)addr, ((size << 3)-1), 0x82);
65 #define LDT_entry_a(info) \
66 ((((info)->base_addr & 0x0000ffff) << 16) | ((info)->limit & 0x0ffff))
68 #define LDT_entry_b(info) \
69 (((info)->base_addr & 0xff000000) | \
70 (((info)->base_addr & 0x00ff0000) >> 16) | \
71 ((info)->limit & 0xf0000) | \
72 (((info)->read_exec_only ^ 1) << 9) | \
73 ((info)->contents << 10) | \
74 (((info)->seg_not_present ^ 1) << 15) | \
75 ((info)->seg_32bit << 22) | \
76 ((info)->limit_in_pages << 23) | \
77 ((info)->useable << 20) | \
80 #define LDT_empty(info) (\
81 (info)->base_addr == 0 && \
82 (info)->limit == 0 && \
83 (info)->contents == 0 && \
84 (info)->read_exec_only == 1 && \
85 (info)->seg_32bit == 0 && \
86 (info)->limit_in_pages == 0 && \
87 (info)->seg_not_present == 1 && \
88 (info)->useable == 0 )
91 # error update this code.
94 static inline void load_TLS(struct thread_struct *t, unsigned int cpu)
96 #define C(i) cpu_gdt_table[cpu][GDT_ENTRY_TLS_MIN + i] = t->tls_array[i]
101 extern struct page *default_ldt_page;
102 extern void load_LDT_nolock(mm_context_t *pc, int cpu);
104 static inline void load_LDT(mm_context_t *pc)
107 load_LDT_nolock(pc, cpu);
111 static inline void set_user_cs(struct desc_struct *desc, unsigned long limit)
113 limit = (limit - 1) / PAGE_SIZE;
114 desc->a = limit & 0xffff;
115 desc->b = (limit & 0xf0000) | 0x00c0fb00;
118 #define load_user_cs_desc(cpu, mm) \
119 cpu_gdt_table[(cpu)][GDT_ENTRY_DEFAULT_USER_CS] = (mm)->context.user_cs
121 extern void arch_add_exec_range(struct mm_struct *mm, unsigned long limit);
122 extern void arch_remove_exec_range(struct mm_struct *mm, unsigned long limit);
123 extern void arch_flush_exec_range(struct mm_struct *mm);
126 #endif /* !__ASSEMBLY__ */