i386: hard_{en,dis}able_TSC can be static
[cascardo/linux.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 disable_TSC(void);
210
211 /*
212  * Size of io_bitmap.
213  */
214 #define IO_BITMAP_BITS  65536
215 #define IO_BITMAP_BYTES (IO_BITMAP_BITS/8)
216 #define IO_BITMAP_LONGS (IO_BITMAP_BYTES/sizeof(long))
217 #define IO_BITMAP_OFFSET offsetof(struct tss_struct,io_bitmap)
218 #define INVALID_IO_BITMAP_OFFSET 0x8000
219 #define INVALID_IO_BITMAP_OFFSET_LAZY 0x9000
220
221 struct i387_fsave_struct {
222         long    cwd;
223         long    swd;
224         long    twd;
225         long    fip;
226         long    fcs;
227         long    foo;
228         long    fos;
229         long    st_space[20];   /* 8*10 bytes for each FP-reg = 80 bytes */
230         long    status;         /* software status information */
231 };
232
233 struct i387_fxsave_struct {
234         unsigned short  cwd;
235         unsigned short  swd;
236         unsigned short  twd;
237         unsigned short  fop;
238         long    fip;
239         long    fcs;
240         long    foo;
241         long    fos;
242         long    mxcsr;
243         long    mxcsr_mask;
244         long    st_space[32];   /* 8*16 bytes for each FP-reg = 128 bytes */
245         long    xmm_space[32];  /* 8*16 bytes for each XMM-reg = 128 bytes */
246         long    padding[56];
247 } __attribute__ ((aligned (16)));
248
249 struct i387_soft_struct {
250         long    cwd;
251         long    swd;
252         long    twd;
253         long    fip;
254         long    fcs;
255         long    foo;
256         long    fos;
257         long    st_space[20];   /* 8*10 bytes for each FP-reg = 80 bytes */
258         unsigned char   ftop, changed, lookahead, no_update, rm, alimit;
259         struct info     *info;
260         unsigned long   entry_eip;
261 };
262
263 union i387_union {
264         struct i387_fsave_struct        fsave;
265         struct i387_fxsave_struct       fxsave;
266         struct i387_soft_struct soft;
267 };
268
269 typedef struct {
270         unsigned long seg;
271 } mm_segment_t;
272
273 struct thread_struct;
274
275 /* This is the TSS defined by the hardware. */
276 struct i386_hw_tss {
277         unsigned short  back_link,__blh;
278         unsigned long   sp0;
279         unsigned short  ss0,__ss0h;
280         unsigned long   sp1;
281         unsigned short  ss1,__ss1h;     /* ss1 is used to cache MSR_IA32_SYSENTER_CS */
282         unsigned long   sp2;
283         unsigned short  ss2,__ss2h;
284         unsigned long   __cr3;
285         unsigned long   ip;
286         unsigned long   flags;
287         unsigned long   ax, cx, dx, bx;
288         unsigned long   sp, bp, si, di;
289         unsigned short  es, __esh;
290         unsigned short  cs, __csh;
291         unsigned short  ss, __ssh;
292         unsigned short  ds, __dsh;
293         unsigned short  fs, __fsh;
294         unsigned short  gs, __gsh;
295         unsigned short  ldt, __ldth;
296         unsigned short  trace, io_bitmap_base;
297 } __attribute__((packed));
298
299 struct tss_struct {
300         struct i386_hw_tss x86_tss;
301
302         /*
303          * The extra 1 is there because the CPU will access an
304          * additional byte beyond the end of the IO permission
305          * bitmap. The extra byte must be all 1 bits, and must
306          * be within the limit.
307          */
308         unsigned long   io_bitmap[IO_BITMAP_LONGS + 1];
309         /*
310          * Cache the current maximum and the last task that used the bitmap:
311          */
312         unsigned long io_bitmap_max;
313         struct thread_struct *io_bitmap_owner;
314         /*
315          * pads the TSS to be cacheline-aligned (size is 0x100)
316          */
317         unsigned long __cacheline_filler[35];
318         /*
319          * .. and then another 0x100 bytes for emergency kernel stack
320          */
321         unsigned long stack[64];
322 } __attribute__((packed));
323
324 #define ARCH_MIN_TASKALIGN      16
325
326 struct thread_struct {
327 /* cached TLS descriptors. */
328         struct desc_struct tls_array[GDT_ENTRY_TLS_ENTRIES];
329         unsigned long   sp0;
330         unsigned long   sysenter_cs;
331         unsigned long   ip;
332         unsigned long   sp;
333         unsigned long   fs;
334         unsigned long   gs;
335 /* Hardware debugging registers */
336         unsigned long   debugreg0;
337         unsigned long   debugreg1;
338         unsigned long   debugreg2;
339         unsigned long   debugreg3;
340         unsigned long   debugreg6;
341         unsigned long   debugreg7;
342 /* fault info */
343         unsigned long   cr2, trap_no, error_code;
344 /* floating point info */
345         union i387_union        i387;
346 /* virtual 86 mode info */
347         struct vm86_struct __user * vm86_info;
348         unsigned long           screen_bitmap;
349         unsigned long           v86flags, v86mask, saved_sp0;
350         unsigned int            saved_fs, saved_gs;
351 /* IO permissions */
352         unsigned long   *io_bitmap_ptr;
353         unsigned long   iopl;
354 /* max allowed port in the bitmap, in bytes: */
355         unsigned long   io_bitmap_max;
356 /* MSR_IA32_DEBUGCTLMSR value to switch in if TIF_DEBUGCTLMSR is set.  */
357         unsigned long   debugctlmsr;
358 /* Debug Store - if not 0 points to a DS Save Area configuration;
359  *               goes into MSR_IA32_DS_AREA */
360         unsigned long   ds_area_msr;
361 };
362
363 #define INIT_THREAD  {                                                  \
364         .sp0 = sizeof(init_stack) + (long)&init_stack,                  \
365         .vm86_info = NULL,                                              \
366         .sysenter_cs = __KERNEL_CS,                                     \
367         .io_bitmap_ptr = NULL,                                          \
368         .fs = __KERNEL_PERCPU,                                          \
369 }
370
371 /*
372  * Note that the .io_bitmap member must be extra-big. This is because
373  * the CPU will access an additional byte beyond the end of the IO
374  * permission bitmap. The extra byte must be all 1 bits, and must
375  * be within the limit.
376  */
377 #define INIT_TSS  {                                                     \
378         .x86_tss = {                                                    \
379                 .sp0            = sizeof(init_stack) + (long)&init_stack, \
380                 .ss0            = __KERNEL_DS,                          \
381                 .ss1            = __KERNEL_CS,                          \
382                 .io_bitmap_base = INVALID_IO_BITMAP_OFFSET,             \
383          },                                                             \
384         .io_bitmap      = { [ 0 ... IO_BITMAP_LONGS] = ~0 },            \
385 }
386
387 #define start_thread(regs, new_eip, new_esp) do {               \
388         __asm__("movl %0,%%gs": :"r" (0));                      \
389         regs->fs = 0;                                           \
390         set_fs(USER_DS);                                        \
391         regs->ds = __USER_DS;                                   \
392         regs->es = __USER_DS;                                   \
393         regs->ss = __USER_DS;                                   \
394         regs->cs = __USER_CS;                                   \
395         regs->ip = new_eip;                                     \
396         regs->sp = new_esp;                                     \
397 } while (0)
398
399 /* Forward declaration, a strange C thing */
400 struct task_struct;
401 struct mm_struct;
402
403 /* Free all resources held by a thread. */
404 extern void release_thread(struct task_struct *);
405
406 /* Prepare to copy thread state - unlazy all lazy status */
407 extern void prepare_to_copy(struct task_struct *tsk);
408
409 /*
410  * create a kernel thread without removing it from tasklists
411  */
412 extern int kernel_thread(int (*fn)(void *), void * arg, unsigned long flags);
413
414 extern unsigned long thread_saved_pc(struct task_struct *tsk);
415
416 unsigned long get_wchan(struct task_struct *p);
417
418 #define THREAD_SIZE_LONGS      (THREAD_SIZE/sizeof(unsigned long))
419 #define KSTK_TOP(info)                                                 \
420 ({                                                                     \
421        unsigned long *__ptr = (unsigned long *)(info);                 \
422        (unsigned long)(&__ptr[THREAD_SIZE_LONGS]);                     \
423 })
424
425 /*
426  * The below -8 is to reserve 8 bytes on top of the ring0 stack.
427  * This is necessary to guarantee that the entire "struct pt_regs"
428  * is accessable even if the CPU haven't stored the SS/ESP registers
429  * on the stack (interrupt gate does not save these registers
430  * when switching to the same priv ring).
431  * Therefore beware: accessing the ss/esp fields of the
432  * "struct pt_regs" is possible, but they may contain the
433  * completely wrong values.
434  */
435 #define task_pt_regs(task)                                             \
436 ({                                                                     \
437        struct pt_regs *__regs__;                                       \
438        __regs__ = (struct pt_regs *)(KSTK_TOP(task_stack_page(task))-8); \
439        __regs__ - 1;                                                   \
440 })
441
442 #define KSTK_EIP(task) (task_pt_regs(task)->ip)
443 #define KSTK_ESP(task) (task_pt_regs(task)->sp)
444
445
446 struct microcode_header {
447         unsigned int hdrver;
448         unsigned int rev;
449         unsigned int date;
450         unsigned int sig;
451         unsigned int cksum;
452         unsigned int ldrver;
453         unsigned int pf;
454         unsigned int datasize;
455         unsigned int totalsize;
456         unsigned int reserved[3];
457 };
458
459 struct microcode {
460         struct microcode_header hdr;
461         unsigned int bits[0];
462 };
463
464 typedef struct microcode microcode_t;
465 typedef struct microcode_header microcode_header_t;
466
467 /* microcode format is extended from prescott processors */
468 struct extended_signature {
469         unsigned int sig;
470         unsigned int pf;
471         unsigned int cksum;
472 };
473
474 struct extended_sigtable {
475         unsigned int count;
476         unsigned int cksum;
477         unsigned int reserved[3];
478         struct extended_signature sigs[0];
479 };
480
481 /* REP NOP (PAUSE) is a good thing to insert into busy-wait loops. */
482 static inline void rep_nop(void)
483 {
484         __asm__ __volatile__("rep;nop": : :"memory");
485 }
486
487 #define cpu_relax()     rep_nop()
488
489 static inline void native_load_sp0(struct tss_struct *tss, struct thread_struct *thread)
490 {
491         tss->x86_tss.sp0 = thread->sp0;
492         /* This can only happen when SEP is enabled, no need to test "SEP"arately */
493         if (unlikely(tss->x86_tss.ss1 != thread->sysenter_cs)) {
494                 tss->x86_tss.ss1 = thread->sysenter_cs;
495                 wrmsr(MSR_IA32_SYSENTER_CS, thread->sysenter_cs, 0);
496         }
497 }
498
499
500 static inline unsigned long native_get_debugreg(int regno)
501 {
502         unsigned long val = 0;  /* Damn you, gcc! */
503
504         switch (regno) {
505         case 0:
506                 asm("movl %%db0, %0" :"=r" (val)); break;
507         case 1:
508                 asm("movl %%db1, %0" :"=r" (val)); break;
509         case 2:
510                 asm("movl %%db2, %0" :"=r" (val)); break;
511         case 3:
512                 asm("movl %%db3, %0" :"=r" (val)); break;
513         case 6:
514                 asm("movl %%db6, %0" :"=r" (val)); break;
515         case 7:
516                 asm("movl %%db7, %0" :"=r" (val)); break;
517         default:
518                 BUG();
519         }
520         return val;
521 }
522
523 static inline void native_set_debugreg(int regno, unsigned long value)
524 {
525         switch (regno) {
526         case 0:
527                 asm("movl %0,%%db0"     : /* no output */ :"r" (value));
528                 break;
529         case 1:
530                 asm("movl %0,%%db1"     : /* no output */ :"r" (value));
531                 break;
532         case 2:
533                 asm("movl %0,%%db2"     : /* no output */ :"r" (value));
534                 break;
535         case 3:
536                 asm("movl %0,%%db3"     : /* no output */ :"r" (value));
537                 break;
538         case 6:
539                 asm("movl %0,%%db6"     : /* no output */ :"r" (value));
540                 break;
541         case 7:
542                 asm("movl %0,%%db7"     : /* no output */ :"r" (value));
543                 break;
544         default:
545                 BUG();
546         }
547 }
548
549 /*
550  * Set IOPL bits in EFLAGS from given mask
551  */
552 static inline void native_set_iopl_mask(unsigned mask)
553 {
554         unsigned int reg;
555         __asm__ __volatile__ ("pushfl;"
556                               "popl %0;"
557                               "andl %1, %0;"
558                               "orl %2, %0;"
559                               "pushl %0;"
560                               "popfl"
561                                 : "=&r" (reg)
562                                 : "i" (~X86_EFLAGS_IOPL), "r" (mask));
563 }
564
565 #ifdef CONFIG_PARAVIRT
566 #include <asm/paravirt.h>
567 #else
568 #define paravirt_enabled() 0
569
570 static inline void load_sp0(struct tss_struct *tss, struct thread_struct *thread)
571 {
572         native_load_sp0(tss, thread);
573 }
574
575 /*
576  * These special macros can be used to get or set a debugging register
577  */
578 #define get_debugreg(var, register)                             \
579         (var) = native_get_debugreg(register)
580 #define set_debugreg(value, register)                           \
581         native_set_debugreg(register, value)
582
583 #define set_iopl_mask native_set_iopl_mask
584 #endif /* CONFIG_PARAVIRT */
585
586 /* generic versions from gas */
587 #define GENERIC_NOP1    ".byte 0x90\n"
588 #define GENERIC_NOP2            ".byte 0x89,0xf6\n"
589 #define GENERIC_NOP3        ".byte 0x8d,0x76,0x00\n"
590 #define GENERIC_NOP4        ".byte 0x8d,0x74,0x26,0x00\n"
591 #define GENERIC_NOP5        GENERIC_NOP1 GENERIC_NOP4
592 #define GENERIC_NOP6    ".byte 0x8d,0xb6,0x00,0x00,0x00,0x00\n"
593 #define GENERIC_NOP7    ".byte 0x8d,0xb4,0x26,0x00,0x00,0x00,0x00\n"
594 #define GENERIC_NOP8    GENERIC_NOP1 GENERIC_NOP7
595
596 /* Opteron nops */
597 #define K8_NOP1 GENERIC_NOP1
598 #define K8_NOP2 ".byte 0x66,0x90\n" 
599 #define K8_NOP3 ".byte 0x66,0x66,0x90\n" 
600 #define K8_NOP4 ".byte 0x66,0x66,0x66,0x90\n" 
601 #define K8_NOP5 K8_NOP3 K8_NOP2 
602 #define K8_NOP6 K8_NOP3 K8_NOP3
603 #define K8_NOP7 K8_NOP4 K8_NOP3
604 #define K8_NOP8 K8_NOP4 K8_NOP4
605
606 /* K7 nops */
607 /* uses eax dependencies (arbitary choice) */
608 #define K7_NOP1  GENERIC_NOP1
609 #define K7_NOP2 ".byte 0x8b,0xc0\n" 
610 #define K7_NOP3 ".byte 0x8d,0x04,0x20\n"
611 #define K7_NOP4 ".byte 0x8d,0x44,0x20,0x00\n"
612 #define K7_NOP5 K7_NOP4 ASM_NOP1
613 #define K7_NOP6 ".byte 0x8d,0x80,0,0,0,0\n"
614 #define K7_NOP7        ".byte 0x8D,0x04,0x05,0,0,0,0\n"
615 #define K7_NOP8        K7_NOP7 ASM_NOP1
616
617 /* P6 nops */
618 /* uses eax dependencies (Intel-recommended choice) */
619 #define P6_NOP1 GENERIC_NOP1
620 #define P6_NOP2 ".byte 0x66,0x90\n"
621 #define P6_NOP3 ".byte 0x0f,0x1f,0x00\n"
622 #define P6_NOP4 ".byte 0x0f,0x1f,0x40,0\n"
623 #define P6_NOP5 ".byte 0x0f,0x1f,0x44,0x00,0\n"
624 #define P6_NOP6 ".byte 0x66,0x0f,0x1f,0x44,0x00,0\n"
625 #define P6_NOP7 ".byte 0x0f,0x1f,0x80,0,0,0,0\n"
626 #define P6_NOP8 ".byte 0x0f,0x1f,0x84,0x00,0,0,0,0\n"
627
628 #ifdef CONFIG_MK8
629 #define ASM_NOP1 K8_NOP1
630 #define ASM_NOP2 K8_NOP2
631 #define ASM_NOP3 K8_NOP3
632 #define ASM_NOP4 K8_NOP4
633 #define ASM_NOP5 K8_NOP5
634 #define ASM_NOP6 K8_NOP6
635 #define ASM_NOP7 K8_NOP7
636 #define ASM_NOP8 K8_NOP8
637 #elif defined(CONFIG_MK7)
638 #define ASM_NOP1 K7_NOP1
639 #define ASM_NOP2 K7_NOP2
640 #define ASM_NOP3 K7_NOP3
641 #define ASM_NOP4 K7_NOP4
642 #define ASM_NOP5 K7_NOP5
643 #define ASM_NOP6 K7_NOP6
644 #define ASM_NOP7 K7_NOP7
645 #define ASM_NOP8 K7_NOP8
646 #elif defined(CONFIG_M686) || defined(CONFIG_MPENTIUMII) || \
647       defined(CONFIG_MPENTIUMIII) || defined(CONFIG_MPENTIUMM) || \
648       defined(CONFIG_MCORE2) || defined(CONFIG_PENTIUM4)
649 #define ASM_NOP1 P6_NOP1
650 #define ASM_NOP2 P6_NOP2
651 #define ASM_NOP3 P6_NOP3
652 #define ASM_NOP4 P6_NOP4
653 #define ASM_NOP5 P6_NOP5
654 #define ASM_NOP6 P6_NOP6
655 #define ASM_NOP7 P6_NOP7
656 #define ASM_NOP8 P6_NOP8
657 #else
658 #define ASM_NOP1 GENERIC_NOP1
659 #define ASM_NOP2 GENERIC_NOP2
660 #define ASM_NOP3 GENERIC_NOP3
661 #define ASM_NOP4 GENERIC_NOP4
662 #define ASM_NOP5 GENERIC_NOP5
663 #define ASM_NOP6 GENERIC_NOP6
664 #define ASM_NOP7 GENERIC_NOP7
665 #define ASM_NOP8 GENERIC_NOP8
666 #endif
667
668 #define ASM_NOP_MAX 8
669
670 /* Prefetch instructions for Pentium III and AMD Athlon */
671 /* It's not worth to care about 3dnow! prefetches for the K6
672    because they are microcoded there and very slow.
673    However we don't do prefetches for pre XP Athlons currently
674    That should be fixed. */
675 #define ARCH_HAS_PREFETCH
676 static inline void prefetch(const void *x)
677 {
678         alternative_input(ASM_NOP4,
679                           "prefetchnta (%1)",
680                           X86_FEATURE_XMM,
681                           "r" (x));
682 }
683
684 #define ARCH_HAS_PREFETCH
685 #define ARCH_HAS_PREFETCHW
686 #define ARCH_HAS_SPINLOCK_PREFETCH
687
688 /* 3dnow! prefetch to get an exclusive cache line. Useful for 
689    spinlocks to avoid one state transition in the cache coherency protocol. */
690 static inline void prefetchw(const void *x)
691 {
692         alternative_input(ASM_NOP4,
693                           "prefetchw (%1)",
694                           X86_FEATURE_3DNOW,
695                           "r" (x));
696 }
697 #define spin_lock_prefetch(x)   prefetchw(x)
698
699 extern void select_idle_routine(const struct cpuinfo_x86 *c);
700
701 #define cache_line_size() (boot_cpu_data.x86_cache_alignment)
702
703 extern unsigned long boot_option_idle_override;
704 extern void enable_sep_cpu(void);
705 extern int sysenter_setup(void);
706
707 /* Defined in head.S */
708 extern struct desc_ptr early_gdt_descr;
709
710 extern void cpu_set_gdt(int);
711 extern void switch_to_new_gdt(void);
712 extern void cpu_init(void);
713 extern void init_gdt(int cpu);
714
715 extern int force_mwait;
716
717 #endif /* __ASM_I386_PROCESSOR_H */