x86: unify struct desc_ptr
[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/cache.h>
18 #include <linux/threads.h>
19 #include <asm/percpu.h>
20 #include <linux/cpumask.h>
21 #include <linux/init.h>
22 #include <asm/processor-flags.h>
23 #include <asm/desc_defs.h>
24
25 /* flag for disabling the tsc */
26 extern int tsc_disable;
27
28 static inline int desc_empty(const void *ptr)
29 {
30         const u32 *desc = ptr;
31         return !(desc[0] | desc[1]);
32 }
33
34 /*
35  * Default implementation of macro that returns current
36  * instruction pointer ("program counter").
37  */
38 #define current_text_addr() ({ void *pc; __asm__("movl $1f,%0\n1:":"=g" (pc)); pc; })
39
40 /*
41  *  CPU type and hardware bug flags. Kept separately for each CPU.
42  *  Members of this structure are referenced in head.S, so think twice
43  *  before touching them. [mj]
44  */
45
46 struct cpuinfo_x86 {
47         __u8    x86;            /* CPU family */
48         __u8    x86_vendor;     /* CPU vendor */
49         __u8    x86_model;
50         __u8    x86_mask;
51         char    wp_works_ok;    /* It doesn't on 386's */
52         char    hlt_works_ok;   /* Problems on some 486Dx4's and old 386's */
53         char    hard_math;
54         char    rfu;
55         int     cpuid_level;    /* Maximum supported CPUID level, -1=no CPUID */
56         unsigned long   x86_capability[NCAPINTS];
57         char    x86_vendor_id[16];
58         char    x86_model_id[64];
59         int     x86_cache_size;  /* in KB - valid for CPUS which support this
60                                     call  */
61         int     x86_cache_alignment;    /* In bytes */
62         char    fdiv_bug;
63         char    f00f_bug;
64         char    coma_bug;
65         char    pad0;
66         int     x86_power;
67         unsigned long loops_per_jiffy;
68 #ifdef CONFIG_SMP
69         cpumask_t llc_shared_map;       /* cpus sharing the last level cache */
70 #endif
71         unsigned char x86_max_cores;    /* cpuid returned max cores value */
72         unsigned char apicid;
73         unsigned short x86_clflush_size;
74 #ifdef CONFIG_SMP
75         unsigned char booted_cores;     /* number of cores as seen by OS */
76         __u8 phys_proc_id;              /* Physical processor id. */
77         __u8 cpu_core_id;               /* Core id */
78         __u8 cpu_index;                 /* index into per_cpu list */
79 #endif
80 } __attribute__((__aligned__(SMP_CACHE_BYTES)));
81
82 #define X86_VENDOR_INTEL 0
83 #define X86_VENDOR_CYRIX 1
84 #define X86_VENDOR_AMD 2
85 #define X86_VENDOR_UMC 3
86 #define X86_VENDOR_NEXGEN 4
87 #define X86_VENDOR_CENTAUR 5
88 #define X86_VENDOR_TRANSMETA 7
89 #define X86_VENDOR_NSC 8
90 #define X86_VENDOR_NUM 9
91 #define X86_VENDOR_UNKNOWN 0xff
92
93 /*
94  * capabilities of CPUs
95  */
96
97 extern struct cpuinfo_x86 boot_cpu_data;
98 extern struct cpuinfo_x86 new_cpu_data;
99 extern struct tss_struct doublefault_tss;
100 DECLARE_PER_CPU(struct tss_struct, init_tss);
101
102 #ifdef CONFIG_SMP
103 DECLARE_PER_CPU(struct cpuinfo_x86, cpu_info);
104 #define cpu_data(cpu)           per_cpu(cpu_info, cpu)
105 #define current_cpu_data        cpu_data(smp_processor_id())
106 #else
107 #define cpu_data(cpu)           boot_cpu_data
108 #define current_cpu_data        boot_cpu_data
109 #endif
110
111 /*
112  * the following now lives in the per cpu area:
113  * extern       int cpu_llc_id[NR_CPUS];
114  */
115 DECLARE_PER_CPU(u8, cpu_llc_id);
116 extern char ignore_fpu_irq;
117
118 void __init cpu_detect(struct cpuinfo_x86 *c);
119
120 extern void identify_boot_cpu(void);
121 extern void identify_secondary_cpu(struct cpuinfo_x86 *);
122 extern void print_cpu_info(struct cpuinfo_x86 *);
123 extern void init_scattered_cpuid_features(struct cpuinfo_x86 *c);
124 extern unsigned int init_intel_cacheinfo(struct cpuinfo_x86 *c);
125 extern unsigned short num_cache_leaves;
126
127 #ifdef CONFIG_X86_HT
128 extern void detect_ht(struct cpuinfo_x86 *c);
129 #else
130 static inline void detect_ht(struct cpuinfo_x86 *c) {}
131 #endif
132
133 #define load_cr3(pgdir) write_cr3(__pa(pgdir))
134
135 /*
136  * Save the cr4 feature set we're using (ie
137  * Pentium 4MB enable and PPro Global page
138  * enable), so that any CPU's that boot up
139  * after us can get the correct flags.
140  */
141 extern unsigned long mmu_cr4_features;
142
143 static inline void set_in_cr4 (unsigned long mask)
144 {
145         unsigned cr4;
146         mmu_cr4_features |= mask;
147         cr4 = read_cr4();
148         cr4 |= mask;
149         write_cr4(cr4);
150 }
151
152 static inline void clear_in_cr4 (unsigned long mask)
153 {
154         unsigned cr4;
155         mmu_cr4_features &= ~mask;
156         cr4 = read_cr4();
157         cr4 &= ~mask;
158         write_cr4(cr4);
159 }
160
161 /* Stop speculative execution */
162 static inline void sync_core(void)
163 {
164         int tmp;
165         asm volatile("cpuid" : "=a" (tmp) : "0" (1) : "ebx","ecx","edx","memory");
166 }
167
168 static inline void __monitor(const void *eax, unsigned long ecx,
169                 unsigned long edx)
170 {
171         /* "monitor %eax,%ecx,%edx;" */
172         asm volatile(
173                 ".byte 0x0f,0x01,0xc8;"
174                 : :"a" (eax), "c" (ecx), "d"(edx));
175 }
176
177 static inline void __mwait(unsigned long eax, unsigned long ecx)
178 {
179         /* "mwait %eax,%ecx;" */
180         asm volatile(
181                 ".byte 0x0f,0x01,0xc9;"
182                 : :"a" (eax), "c" (ecx));
183 }
184
185 extern void mwait_idle_with_hints(unsigned long eax, unsigned long ecx);
186
187 /* from system description table in BIOS.  Mostly for MCA use, but
188 others may find it useful. */
189 extern unsigned int machine_id;
190 extern unsigned int machine_submodel_id;
191 extern unsigned int BIOS_revision;
192 extern unsigned int mca_pentium_flag;
193
194 /* Boot loader type from the setup header */
195 extern int bootloader_type;
196
197 /*
198  * User space process size: 3GB (default).
199  */
200 #define TASK_SIZE       (PAGE_OFFSET)
201
202 /* This decides where the kernel will search for a free chunk of vm
203  * space during mmap's.
204  */
205 #define TASK_UNMAPPED_BASE      (PAGE_ALIGN(TASK_SIZE / 3))
206
207 #define HAVE_ARCH_PICK_MMAP_LAYOUT
208
209 extern void hard_disable_TSC(void);
210 extern void disable_TSC(void);
211 extern void hard_enable_TSC(void);
212
213 /*
214  * Size of io_bitmap.
215  */
216 #define IO_BITMAP_BITS  65536
217 #define IO_BITMAP_BYTES (IO_BITMAP_BITS/8)
218 #define IO_BITMAP_LONGS (IO_BITMAP_BYTES/sizeof(long))
219 #define IO_BITMAP_OFFSET offsetof(struct tss_struct,io_bitmap)
220 #define INVALID_IO_BITMAP_OFFSET 0x8000
221 #define INVALID_IO_BITMAP_OFFSET_LAZY 0x9000
222
223 struct i387_fsave_struct {
224         long    cwd;
225         long    swd;
226         long    twd;
227         long    fip;
228         long    fcs;
229         long    foo;
230         long    fos;
231         long    st_space[20];   /* 8*10 bytes for each FP-reg = 80 bytes */
232         long    status;         /* software status information */
233 };
234
235 struct i387_fxsave_struct {
236         unsigned short  cwd;
237         unsigned short  swd;
238         unsigned short  twd;
239         unsigned short  fop;
240         long    fip;
241         long    fcs;
242         long    foo;
243         long    fos;
244         long    mxcsr;
245         long    mxcsr_mask;
246         long    st_space[32];   /* 8*16 bytes for each FP-reg = 128 bytes */
247         long    xmm_space[32];  /* 8*16 bytes for each XMM-reg = 128 bytes */
248         long    padding[56];
249 } __attribute__ ((aligned (16)));
250
251 struct i387_soft_struct {
252         long    cwd;
253         long    swd;
254         long    twd;
255         long    fip;
256         long    fcs;
257         long    foo;
258         long    fos;
259         long    st_space[20];   /* 8*10 bytes for each FP-reg = 80 bytes */
260         unsigned char   ftop, changed, lookahead, no_update, rm, alimit;
261         struct info     *info;
262         unsigned long   entry_eip;
263 };
264
265 union i387_union {
266         struct i387_fsave_struct        fsave;
267         struct i387_fxsave_struct       fxsave;
268         struct i387_soft_struct soft;
269 };
270
271 typedef struct {
272         unsigned long seg;
273 } mm_segment_t;
274
275 struct thread_struct;
276
277 /* This is the TSS defined by the hardware. */
278 struct i386_hw_tss {
279         unsigned short  back_link,__blh;
280         unsigned long   sp0;
281         unsigned short  ss0,__ss0h;
282         unsigned long   sp1;
283         unsigned short  ss1,__ss1h;     /* ss1 is used to cache MSR_IA32_SYSENTER_CS */
284         unsigned long   sp2;
285         unsigned short  ss2,__ss2h;
286         unsigned long   __cr3;
287         unsigned long   ip;
288         unsigned long   flags;
289         unsigned long   ax, cx, dx, bx;
290         unsigned long   sp, bp, si, di;
291         unsigned short  es, __esh;
292         unsigned short  cs, __csh;
293         unsigned short  ss, __ssh;
294         unsigned short  ds, __dsh;
295         unsigned short  fs, __fsh;
296         unsigned short  gs, __gsh;
297         unsigned short  ldt, __ldth;
298         unsigned short  trace, io_bitmap_base;
299 } __attribute__((packed));
300
301 struct tss_struct {
302         struct i386_hw_tss x86_tss;
303
304         /*
305          * The extra 1 is there because the CPU will access an
306          * additional byte beyond the end of the IO permission
307          * bitmap. The extra byte must be all 1 bits, and must
308          * be within the limit.
309          */
310         unsigned long   io_bitmap[IO_BITMAP_LONGS + 1];
311         /*
312          * Cache the current maximum and the last task that used the bitmap:
313          */
314         unsigned long io_bitmap_max;
315         struct thread_struct *io_bitmap_owner;
316         /*
317          * pads the TSS to be cacheline-aligned (size is 0x100)
318          */
319         unsigned long __cacheline_filler[35];
320         /*
321          * .. and then another 0x100 bytes for emergency kernel stack
322          */
323         unsigned long stack[64];
324 } __attribute__((packed));
325
326 #define ARCH_MIN_TASKALIGN      16
327
328 struct thread_struct {
329 /* cached TLS descriptors. */
330         struct desc_struct tls_array[GDT_ENTRY_TLS_ENTRIES];
331         unsigned long   sp0;
332         unsigned long   sysenter_cs;
333         unsigned long   ip;
334         unsigned long   sp;
335         unsigned long   fs;
336         unsigned long   gs;
337 /* Hardware debugging registers */
338         unsigned long   debugreg0;
339         unsigned long   debugreg1;
340         unsigned long   debugreg2;
341         unsigned long   debugreg3;
342         unsigned long   debugreg6;
343         unsigned long   debugreg7;
344 /* fault info */
345         unsigned long   cr2, trap_no, error_code;
346 /* floating point info */
347         union i387_union        i387;
348 /* virtual 86 mode info */
349         struct vm86_struct __user * vm86_info;
350         unsigned long           screen_bitmap;
351         unsigned long           v86flags, v86mask, saved_sp0;
352         unsigned int            saved_fs, saved_gs;
353 /* IO permissions */
354         unsigned long   *io_bitmap_ptr;
355         unsigned long   iopl;
356 /* max allowed port in the bitmap, in bytes: */
357         unsigned long   io_bitmap_max;
358 /* MSR_IA32_DEBUGCTLMSR value to switch in if TIF_DEBUGCTLMSR is set.  */
359         unsigned long   debugctlmsr;
360 /* Debug Store - if not 0 points to a DS Save Area configuration;
361  *               goes into MSR_IA32_DS_AREA */
362         unsigned long   ds_area_msr;
363 };
364
365 #define INIT_THREAD  {                                                  \
366         .sp0 = sizeof(init_stack) + (long)&init_stack,                  \
367         .vm86_info = NULL,                                              \
368         .sysenter_cs = __KERNEL_CS,                                     \
369         .io_bitmap_ptr = NULL,                                          \
370         .fs = __KERNEL_PERCPU,                                          \
371 }
372
373 /*
374  * Note that the .io_bitmap member must be extra-big. This is because
375  * the CPU will access an additional byte beyond the end of the IO
376  * permission bitmap. The extra byte must be all 1 bits, and must
377  * be within the limit.
378  */
379 #define INIT_TSS  {                                                     \
380         .x86_tss = {                                                    \
381                 .sp0            = sizeof(init_stack) + (long)&init_stack, \
382                 .ss0            = __KERNEL_DS,                          \
383                 .ss1            = __KERNEL_CS,                          \
384                 .io_bitmap_base = INVALID_IO_BITMAP_OFFSET,             \
385          },                                                             \
386         .io_bitmap      = { [ 0 ... IO_BITMAP_LONGS] = ~0 },            \
387 }
388
389 #define start_thread(regs, new_eip, new_esp) do {               \
390         __asm__("movl %0,%%gs": :"r" (0));                      \
391         regs->fs = 0;                                           \
392         set_fs(USER_DS);                                        \
393         regs->ds = __USER_DS;                                   \
394         regs->es = __USER_DS;                                   \
395         regs->ss = __USER_DS;                                   \
396         regs->cs = __USER_CS;                                   \
397         regs->ip = new_eip;                                     \
398         regs->sp = new_esp;                                     \
399 } while (0)
400
401 /* Forward declaration, a strange C thing */
402 struct task_struct;
403 struct mm_struct;
404
405 /* Free all resources held by a thread. */
406 extern void release_thread(struct task_struct *);
407
408 /* Prepare to copy thread state - unlazy all lazy status */
409 extern void prepare_to_copy(struct task_struct *tsk);
410
411 /*
412  * create a kernel thread without removing it from tasklists
413  */
414 extern int kernel_thread(int (*fn)(void *), void * arg, unsigned long flags);
415
416 extern unsigned long thread_saved_pc(struct task_struct *tsk);
417
418 unsigned long get_wchan(struct task_struct *p);
419
420 #define THREAD_SIZE_LONGS      (THREAD_SIZE/sizeof(unsigned long))
421 #define KSTK_TOP(info)                                                 \
422 ({                                                                     \
423        unsigned long *__ptr = (unsigned long *)(info);                 \
424        (unsigned long)(&__ptr[THREAD_SIZE_LONGS]);                     \
425 })
426
427 /*
428  * The below -8 is to reserve 8 bytes on top of the ring0 stack.
429  * This is necessary to guarantee that the entire "struct pt_regs"
430  * is accessable even if the CPU haven't stored the SS/ESP registers
431  * on the stack (interrupt gate does not save these registers
432  * when switching to the same priv ring).
433  * Therefore beware: accessing the ss/esp fields of the
434  * "struct pt_regs" is possible, but they may contain the
435  * completely wrong values.
436  */
437 #define task_pt_regs(task)                                             \
438 ({                                                                     \
439        struct pt_regs *__regs__;                                       \
440        __regs__ = (struct pt_regs *)(KSTK_TOP(task_stack_page(task))-8); \
441        __regs__ - 1;                                                   \
442 })
443
444 #define KSTK_EIP(task) (task_pt_regs(task)->ip)
445 #define KSTK_ESP(task) (task_pt_regs(task)->sp)
446
447
448 struct microcode_header {
449         unsigned int hdrver;
450         unsigned int rev;
451         unsigned int date;
452         unsigned int sig;
453         unsigned int cksum;
454         unsigned int ldrver;
455         unsigned int pf;
456         unsigned int datasize;
457         unsigned int totalsize;
458         unsigned int reserved[3];
459 };
460
461 struct microcode {
462         struct microcode_header hdr;
463         unsigned int bits[0];
464 };
465
466 typedef struct microcode microcode_t;
467 typedef struct microcode_header microcode_header_t;
468
469 /* microcode format is extended from prescott processors */
470 struct extended_signature {
471         unsigned int sig;
472         unsigned int pf;
473         unsigned int cksum;
474 };
475
476 struct extended_sigtable {
477         unsigned int count;
478         unsigned int cksum;
479         unsigned int reserved[3];
480         struct extended_signature sigs[0];
481 };
482
483 /* REP NOP (PAUSE) is a good thing to insert into busy-wait loops. */
484 static inline void rep_nop(void)
485 {
486         __asm__ __volatile__("rep;nop": : :"memory");
487 }
488
489 #define cpu_relax()     rep_nop()
490
491 static inline void native_load_sp0(struct tss_struct *tss, struct thread_struct *thread)
492 {
493         tss->x86_tss.sp0 = thread->sp0;
494         /* This can only happen when SEP is enabled, no need to test "SEP"arately */
495         if (unlikely(tss->x86_tss.ss1 != thread->sysenter_cs)) {
496                 tss->x86_tss.ss1 = thread->sysenter_cs;
497                 wrmsr(MSR_IA32_SYSENTER_CS, thread->sysenter_cs, 0);
498         }
499 }
500
501
502 static inline unsigned long native_get_debugreg(int regno)
503 {
504         unsigned long val = 0;  /* Damn you, gcc! */
505
506         switch (regno) {
507         case 0:
508                 asm("movl %%db0, %0" :"=r" (val)); break;
509         case 1:
510                 asm("movl %%db1, %0" :"=r" (val)); break;
511         case 2:
512                 asm("movl %%db2, %0" :"=r" (val)); break;
513         case 3:
514                 asm("movl %%db3, %0" :"=r" (val)); break;
515         case 6:
516                 asm("movl %%db6, %0" :"=r" (val)); break;
517         case 7:
518                 asm("movl %%db7, %0" :"=r" (val)); break;
519         default:
520                 BUG();
521         }
522         return val;
523 }
524
525 static inline void native_set_debugreg(int regno, unsigned long value)
526 {
527         switch (regno) {
528         case 0:
529                 asm("movl %0,%%db0"     : /* no output */ :"r" (value));
530                 break;
531         case 1:
532                 asm("movl %0,%%db1"     : /* no output */ :"r" (value));
533                 break;
534         case 2:
535                 asm("movl %0,%%db2"     : /* no output */ :"r" (value));
536                 break;
537         case 3:
538                 asm("movl %0,%%db3"     : /* no output */ :"r" (value));
539                 break;
540         case 6:
541                 asm("movl %0,%%db6"     : /* no output */ :"r" (value));
542                 break;
543         case 7:
544                 asm("movl %0,%%db7"     : /* no output */ :"r" (value));
545                 break;
546         default:
547                 BUG();
548         }
549 }
550
551 /*
552  * Set IOPL bits in EFLAGS from given mask
553  */
554 static inline void native_set_iopl_mask(unsigned mask)
555 {
556         unsigned int reg;
557         __asm__ __volatile__ ("pushfl;"
558                               "popl %0;"
559                               "andl %1, %0;"
560                               "orl %2, %0;"
561                               "pushl %0;"
562                               "popfl"
563                                 : "=&r" (reg)
564                                 : "i" (~X86_EFLAGS_IOPL), "r" (mask));
565 }
566
567 #ifdef CONFIG_PARAVIRT
568 #include <asm/paravirt.h>
569 #else
570 #define paravirt_enabled() 0
571
572 static inline void load_sp0(struct tss_struct *tss, struct thread_struct *thread)
573 {
574         native_load_sp0(tss, thread);
575 }
576
577 /*
578  * These special macros can be used to get or set a debugging register
579  */
580 #define get_debugreg(var, register)                             \
581         (var) = native_get_debugreg(register)
582 #define set_debugreg(value, register)                           \
583         native_set_debugreg(register, value)
584
585 #define set_iopl_mask native_set_iopl_mask
586 #endif /* CONFIG_PARAVIRT */
587
588 /* generic versions from gas */
589 #define GENERIC_NOP1    ".byte 0x90\n"
590 #define GENERIC_NOP2            ".byte 0x89,0xf6\n"
591 #define GENERIC_NOP3        ".byte 0x8d,0x76,0x00\n"
592 #define GENERIC_NOP4        ".byte 0x8d,0x74,0x26,0x00\n"
593 #define GENERIC_NOP5        GENERIC_NOP1 GENERIC_NOP4
594 #define GENERIC_NOP6    ".byte 0x8d,0xb6,0x00,0x00,0x00,0x00\n"
595 #define GENERIC_NOP7    ".byte 0x8d,0xb4,0x26,0x00,0x00,0x00,0x00\n"
596 #define GENERIC_NOP8    GENERIC_NOP1 GENERIC_NOP7
597
598 /* Opteron nops */
599 #define K8_NOP1 GENERIC_NOP1
600 #define K8_NOP2 ".byte 0x66,0x90\n" 
601 #define K8_NOP3 ".byte 0x66,0x66,0x90\n" 
602 #define K8_NOP4 ".byte 0x66,0x66,0x66,0x90\n" 
603 #define K8_NOP5 K8_NOP3 K8_NOP2 
604 #define K8_NOP6 K8_NOP3 K8_NOP3
605 #define K8_NOP7 K8_NOP4 K8_NOP3
606 #define K8_NOP8 K8_NOP4 K8_NOP4
607
608 /* K7 nops */
609 /* uses eax dependencies (arbitary choice) */
610 #define K7_NOP1  GENERIC_NOP1
611 #define K7_NOP2 ".byte 0x8b,0xc0\n" 
612 #define K7_NOP3 ".byte 0x8d,0x04,0x20\n"
613 #define K7_NOP4 ".byte 0x8d,0x44,0x20,0x00\n"
614 #define K7_NOP5 K7_NOP4 ASM_NOP1
615 #define K7_NOP6 ".byte 0x8d,0x80,0,0,0,0\n"
616 #define K7_NOP7        ".byte 0x8D,0x04,0x05,0,0,0,0\n"
617 #define K7_NOP8        K7_NOP7 ASM_NOP1
618
619 /* P6 nops */
620 /* uses eax dependencies (Intel-recommended choice) */
621 #define P6_NOP1 GENERIC_NOP1
622 #define P6_NOP2 ".byte 0x66,0x90\n"
623 #define P6_NOP3 ".byte 0x0f,0x1f,0x00\n"
624 #define P6_NOP4 ".byte 0x0f,0x1f,0x40,0\n"
625 #define P6_NOP5 ".byte 0x0f,0x1f,0x44,0x00,0\n"
626 #define P6_NOP6 ".byte 0x66,0x0f,0x1f,0x44,0x00,0\n"
627 #define P6_NOP7 ".byte 0x0f,0x1f,0x80,0,0,0,0\n"
628 #define P6_NOP8 ".byte 0x0f,0x1f,0x84,0x00,0,0,0,0\n"
629
630 #ifdef CONFIG_MK8
631 #define ASM_NOP1 K8_NOP1
632 #define ASM_NOP2 K8_NOP2
633 #define ASM_NOP3 K8_NOP3
634 #define ASM_NOP4 K8_NOP4
635 #define ASM_NOP5 K8_NOP5
636 #define ASM_NOP6 K8_NOP6
637 #define ASM_NOP7 K8_NOP7
638 #define ASM_NOP8 K8_NOP8
639 #elif defined(CONFIG_MK7)
640 #define ASM_NOP1 K7_NOP1
641 #define ASM_NOP2 K7_NOP2
642 #define ASM_NOP3 K7_NOP3
643 #define ASM_NOP4 K7_NOP4
644 #define ASM_NOP5 K7_NOP5
645 #define ASM_NOP6 K7_NOP6
646 #define ASM_NOP7 K7_NOP7
647 #define ASM_NOP8 K7_NOP8
648 #elif defined(CONFIG_M686) || defined(CONFIG_MPENTIUMII) || \
649       defined(CONFIG_MPENTIUMIII) || defined(CONFIG_MPENTIUMM) || \
650       defined(CONFIG_MCORE2) || defined(CONFIG_PENTIUM4)
651 #define ASM_NOP1 P6_NOP1
652 #define ASM_NOP2 P6_NOP2
653 #define ASM_NOP3 P6_NOP3
654 #define ASM_NOP4 P6_NOP4
655 #define ASM_NOP5 P6_NOP5
656 #define ASM_NOP6 P6_NOP6
657 #define ASM_NOP7 P6_NOP7
658 #define ASM_NOP8 P6_NOP8
659 #else
660 #define ASM_NOP1 GENERIC_NOP1
661 #define ASM_NOP2 GENERIC_NOP2
662 #define ASM_NOP3 GENERIC_NOP3
663 #define ASM_NOP4 GENERIC_NOP4
664 #define ASM_NOP5 GENERIC_NOP5
665 #define ASM_NOP6 GENERIC_NOP6
666 #define ASM_NOP7 GENERIC_NOP7
667 #define ASM_NOP8 GENERIC_NOP8
668 #endif
669
670 #define ASM_NOP_MAX 8
671
672 /* Prefetch instructions for Pentium III and AMD Athlon */
673 /* It's not worth to care about 3dnow! prefetches for the K6
674    because they are microcoded there and very slow.
675    However we don't do prefetches for pre XP Athlons currently
676    That should be fixed. */
677 #define ARCH_HAS_PREFETCH
678 static inline void prefetch(const void *x)
679 {
680         alternative_input(ASM_NOP4,
681                           "prefetchnta (%1)",
682                           X86_FEATURE_XMM,
683                           "r" (x));
684 }
685
686 #define ARCH_HAS_PREFETCH
687 #define ARCH_HAS_PREFETCHW
688 #define ARCH_HAS_SPINLOCK_PREFETCH
689
690 /* 3dnow! prefetch to get an exclusive cache line. Useful for 
691    spinlocks to avoid one state transition in the cache coherency protocol. */
692 static inline void prefetchw(const void *x)
693 {
694         alternative_input(ASM_NOP4,
695                           "prefetchw (%1)",
696                           X86_FEATURE_3DNOW,
697                           "r" (x));
698 }
699 #define spin_lock_prefetch(x)   prefetchw(x)
700
701 extern void select_idle_routine(const struct cpuinfo_x86 *c);
702
703 #define cache_line_size() (boot_cpu_data.x86_cache_alignment)
704
705 extern unsigned long boot_option_idle_override;
706 extern void enable_sep_cpu(void);
707 extern int sysenter_setup(void);
708
709 /* Defined in head.S */
710 extern struct desc_ptr early_gdt_descr;
711
712 extern void cpu_set_gdt(int);
713 extern void switch_to_new_gdt(void);
714 extern void cpu_init(void);
715 extern void init_gdt(int cpu);
716
717 extern int force_mwait;
718
719 #endif /* __ASM_I386_PROCESSOR_H */