blob: 36ee9881b74f1570cf3b3046986e600e47755ab6 [file] [log] [blame]
Glauber de Oliveira Costac758ecf2008-01-30 13:31:03 +01001#ifndef __ASM_X86_PROCESSOR_H
2#define __ASM_X86_PROCESSOR_H
3
Glauber de Oliveira Costa053de042008-01-30 13:31:27 +01004#include <asm/processor-flags.h>
5
Glauber de Oliveira Costac72dcf82008-01-30 13:31:27 +01006#include <asm/page.h>
7#include <asm/system.h>
8
Glauber de Oliveira Costac758ecf2008-01-30 13:31:03 +01009static inline void native_cpuid(unsigned int *eax, unsigned int *ebx,
10 unsigned int *ecx, unsigned int *edx)
11{
12 /* ecx is often an input as well as an output. */
13 __asm__("cpuid"
14 : "=a" (*eax),
15 "=b" (*ebx),
16 "=c" (*ecx),
17 "=d" (*edx)
18 : "0" (*eax), "2" (*ecx));
19}
20
Glauber de Oliveira Costac72dcf82008-01-30 13:31:27 +010021static inline void load_cr3(pgd_t *pgdir)
22{
23 write_cr3(__pa(pgdir));
24}
Glauber de Oliveira Costac758ecf2008-01-30 13:31:03 +010025
Thomas Gleixner96a388d2007-10-11 11:20:03 +020026#ifdef CONFIG_X86_32
27# include "processor_32.h"
28#else
29# include "processor_64.h"
30#endif
Glauber de Oliveira Costac758ecf2008-01-30 13:31:03 +010031
32#ifndef CONFIG_PARAVIRT
33#define __cpuid native_cpuid
34#endif
35
36/*
37 * Generic CPUID function
38 * clear %ecx since some cpus (Cyrix MII) do not set or clear %ecx
39 * resulting in stale register contents being returned.
40 */
41static inline void cpuid(unsigned int op,
42 unsigned int *eax, unsigned int *ebx,
43 unsigned int *ecx, unsigned int *edx)
44{
45 *eax = op;
46 *ecx = 0;
47 __cpuid(eax, ebx, ecx, edx);
48}
49
50/* Some CPUID calls want 'count' to be placed in ecx */
51static inline void cpuid_count(unsigned int op, int count,
52 unsigned int *eax, unsigned int *ebx,
53 unsigned int *ecx, unsigned int *edx)
54{
55 *eax = op;
56 *ecx = count;
57 __cpuid(eax, ebx, ecx, edx);
58}
59
60/*
61 * CPUID functions returning a single datum
62 */
63static inline unsigned int cpuid_eax(unsigned int op)
64{
65 unsigned int eax, ebx, ecx, edx;
66
67 cpuid(op, &eax, &ebx, &ecx, &edx);
68 return eax;
69}
70static inline unsigned int cpuid_ebx(unsigned int op)
71{
72 unsigned int eax, ebx, ecx, edx;
73
74 cpuid(op, &eax, &ebx, &ecx, &edx);
75 return ebx;
76}
77static inline unsigned int cpuid_ecx(unsigned int op)
78{
79 unsigned int eax, ebx, ecx, edx;
80
81 cpuid(op, &eax, &ebx, &ecx, &edx);
82 return ecx;
83}
84static inline unsigned int cpuid_edx(unsigned int op)
85{
86 unsigned int eax, ebx, ecx, edx;
87
88 cpuid(op, &eax, &ebx, &ecx, &edx);
89 return edx;
90}
91
92#endif