x86: move i387 definitions to processor.h
[sfrench/cifs-2.6.git] / include / asm-x86 / processor_32.h
1 /*
2  * Copyright (C) 1994 Linus Torvalds
3  */
4
5 #ifndef __ASM_I386_PROCESSOR_H
6 #define __ASM_I386_PROCESSOR_H
7
8 #include <asm/vm86.h>
9 #include <asm/math_emu.h>
10 #include <asm/segment.h>
11 #include <asm/page.h>
12 #include <asm/types.h>
13 #include <asm/sigcontext.h>
14 #include <asm/cpufeature.h>
15 #include <asm/msr.h>
16 #include <asm/system.h>
17 #include <linux/threads.h>
18 #include <linux/init.h>
19 #include <asm/desc_defs.h>
20
21 /*
22  * the following now lives in the per cpu area:
23  * extern       int cpu_llc_id[NR_CPUS];
24  */
25 DECLARE_PER_CPU(u8, cpu_llc_id);
26
27 /*
28  * User space process size: 3GB (default).
29  */
30 #define TASK_SIZE       (PAGE_OFFSET)
31
32 #define INIT_THREAD  {                                                  \
33         .sp0 = sizeof(init_stack) + (long)&init_stack,                  \
34         .vm86_info = NULL,                                              \
35         .sysenter_cs = __KERNEL_CS,                                     \
36         .io_bitmap_ptr = NULL,                                          \
37         .fs = __KERNEL_PERCPU,                                          \
38 }
39
40 /*
41  * Note that the .io_bitmap member must be extra-big. This is because
42  * the CPU will access an additional byte beyond the end of the IO
43  * permission bitmap. The extra byte must be all 1 bits, and must
44  * be within the limit.
45  */
46 #define INIT_TSS  {                                                     \
47         .x86_tss = {                                                    \
48                 .sp0            = sizeof(init_stack) + (long)&init_stack, \
49                 .ss0            = __KERNEL_DS,                          \
50                 .ss1            = __KERNEL_CS,                          \
51                 .io_bitmap_base = INVALID_IO_BITMAP_OFFSET,             \
52          },                                                             \
53         .io_bitmap      = { [ 0 ... IO_BITMAP_LONGS] = ~0 },            \
54 }
55
56 #define start_thread(regs, new_eip, new_esp) do {               \
57         __asm__("movl %0,%%gs": :"r" (0));                      \
58         regs->fs = 0;                                           \
59         set_fs(USER_DS);                                        \
60         regs->ds = __USER_DS;                                   \
61         regs->es = __USER_DS;                                   \
62         regs->ss = __USER_DS;                                   \
63         regs->cs = __USER_CS;                                   \
64         regs->ip = new_eip;                                     \
65         regs->sp = new_esp;                                     \
66 } while (0)
67
68
69 extern unsigned long thread_saved_pc(struct task_struct *tsk);
70
71 #define THREAD_SIZE_LONGS      (THREAD_SIZE/sizeof(unsigned long))
72 #define KSTK_TOP(info)                                                 \
73 ({                                                                     \
74        unsigned long *__ptr = (unsigned long *)(info);                 \
75        (unsigned long)(&__ptr[THREAD_SIZE_LONGS]);                     \
76 })
77
78 /*
79  * The below -8 is to reserve 8 bytes on top of the ring0 stack.
80  * This is necessary to guarantee that the entire "struct pt_regs"
81  * is accessable even if the CPU haven't stored the SS/ESP registers
82  * on the stack (interrupt gate does not save these registers
83  * when switching to the same priv ring).
84  * Therefore beware: accessing the ss/esp fields of the
85  * "struct pt_regs" is possible, but they may contain the
86  * completely wrong values.
87  */
88 #define task_pt_regs(task)                                             \
89 ({                                                                     \
90        struct pt_regs *__regs__;                                       \
91        __regs__ = (struct pt_regs *)(KSTK_TOP(task_stack_page(task))-8); \
92        __regs__ - 1;                                                   \
93 })
94
95 #define KSTK_ESP(task) (task_pt_regs(task)->sp)
96
97 #endif /* __ASM_I386_PROCESSOR_H */