x86: move load_cr3 to a common place.
[linux-2.6-block.git] / include / asm-x86 / processor.h
CommitLineData
c758ecf6
GOC
1#ifndef __ASM_X86_PROCESSOR_H
2#define __ASM_X86_PROCESSOR_H
3
053de044
GOC
4#include <asm/processor-flags.h>
5
c72dcf83
GOC
6#include <asm/page.h>
7#include <asm/system.h>
8
c758ecf6
GOC
9static 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
c72dcf83
GOC
21static inline void load_cr3(pgd_t *pgdir)
22{
23 write_cr3(__pa(pgdir));
24}
c758ecf6 25
96a388de
TG
26#ifdef CONFIG_X86_32
27# include "processor_32.h"
28#else
29# include "processor_64.h"
30#endif
c758ecf6
GOC
31
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