diff options
author | Hiroshi Shimamoto <h-shimamoto@ct.jp.nec.com> | 2008-02-20 13:41:51 -0500 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2008-04-17 11:40:48 -0400 |
commit | 8fa6878ffc6366f490e99a1ab31127fb599657c9 (patch) | |
tree | b8f37975f9690d8f7d831fc4d87623628c141c82 /arch/x86 | |
parent | 637cba02618c1373eb9d2b70a53c17832e27d090 (diff) |
x86: split cpuinfo from setup_64.c into cpu/proc_64.c
x86 /proc/cpuinfo code can be unified.
This is the first step of unification.
Signed-off-by: Hiroshi Shimamoto <h-shimamoto@ct.jp.nec.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'arch/x86')
-rw-r--r-- | arch/x86/kernel/cpu/Makefile | 1 | ||||
-rw-r--r-- | arch/x86/kernel/cpu/proc_64.c | 126 | ||||
-rw-r--r-- | arch/x86/kernel/setup_64.c | 120 |
3 files changed, 127 insertions, 120 deletions
diff --git a/arch/x86/kernel/cpu/Makefile b/arch/x86/kernel/cpu/Makefile index a0c4d7c5dbd7..8ba7d281fbc2 100644 --- a/arch/x86/kernel/cpu/Makefile +++ b/arch/x86/kernel/cpu/Makefile | |||
@@ -13,6 +13,7 @@ obj-$(CONFIG_X86_32) += transmeta.o | |||
13 | obj-$(CONFIG_X86_32) += intel.o | 13 | obj-$(CONFIG_X86_32) += intel.o |
14 | obj-$(CONFIG_X86_32) += nexgen.o | 14 | obj-$(CONFIG_X86_32) += nexgen.o |
15 | obj-$(CONFIG_X86_32) += umc.o | 15 | obj-$(CONFIG_X86_32) += umc.o |
16 | obj-$(CONFIG_X86_64) += proc_64.o | ||
16 | 17 | ||
17 | obj-$(CONFIG_X86_MCE) += mcheck/ | 18 | obj-$(CONFIG_X86_MCE) += mcheck/ |
18 | obj-$(CONFIG_MTRR) += mtrr/ | 19 | obj-$(CONFIG_MTRR) += mtrr/ |
diff --git a/arch/x86/kernel/cpu/proc_64.c b/arch/x86/kernel/cpu/proc_64.c new file mode 100644 index 000000000000..bf4a94b4b0f0 --- /dev/null +++ b/arch/x86/kernel/cpu/proc_64.c | |||
@@ -0,0 +1,126 @@ | |||
1 | #include <linux/smp.h> | ||
2 | #include <linux/timex.h> | ||
3 | #include <linux/string.h> | ||
4 | #include <asm/semaphore.h> | ||
5 | #include <linux/seq_file.h> | ||
6 | #include <linux/cpufreq.h> | ||
7 | |||
8 | /* | ||
9 | * Get CPU information for use by the procfs. | ||
10 | */ | ||
11 | |||
12 | static int show_cpuinfo(struct seq_file *m, void *v) | ||
13 | { | ||
14 | struct cpuinfo_x86 *c = v; | ||
15 | int cpu = 0, i; | ||
16 | |||
17 | #ifdef CONFIG_SMP | ||
18 | cpu = c->cpu_index; | ||
19 | #endif | ||
20 | |||
21 | seq_printf(m, "processor\t: %u\n" | ||
22 | "vendor_id\t: %s\n" | ||
23 | "cpu family\t: %d\n" | ||
24 | "model\t\t: %d\n" | ||
25 | "model name\t: %s\n", | ||
26 | (unsigned)cpu, | ||
27 | c->x86_vendor_id[0] ? c->x86_vendor_id : "unknown", | ||
28 | c->x86, | ||
29 | (int)c->x86_model, | ||
30 | c->x86_model_id[0] ? c->x86_model_id : "unknown"); | ||
31 | |||
32 | if (c->x86_mask || c->cpuid_level >= 0) | ||
33 | seq_printf(m, "stepping\t: %d\n", c->x86_mask); | ||
34 | else | ||
35 | seq_printf(m, "stepping\t: unknown\n"); | ||
36 | |||
37 | if (cpu_has(c, X86_FEATURE_TSC)) { | ||
38 | unsigned int freq = cpufreq_quick_get((unsigned)cpu); | ||
39 | |||
40 | if (!freq) | ||
41 | freq = cpu_khz; | ||
42 | seq_printf(m, "cpu MHz\t\t: %u.%03u\n", | ||
43 | freq / 1000, (freq % 1000)); | ||
44 | } | ||
45 | |||
46 | /* Cache size */ | ||
47 | if (c->x86_cache_size >= 0) | ||
48 | seq_printf(m, "cache size\t: %d KB\n", c->x86_cache_size); | ||
49 | |||
50 | #ifdef CONFIG_SMP | ||
51 | if (smp_num_siblings * c->x86_max_cores > 1) { | ||
52 | seq_printf(m, "physical id\t: %d\n", c->phys_proc_id); | ||
53 | seq_printf(m, "siblings\t: %d\n", | ||
54 | cpus_weight(per_cpu(cpu_core_map, cpu))); | ||
55 | seq_printf(m, "core id\t\t: %d\n", c->cpu_core_id); | ||
56 | seq_printf(m, "cpu cores\t: %d\n", c->booted_cores); | ||
57 | } | ||
58 | #endif | ||
59 | |||
60 | seq_printf(m, | ||
61 | "fpu\t\t: yes\n" | ||
62 | "fpu_exception\t: yes\n" | ||
63 | "cpuid level\t: %d\n" | ||
64 | "wp\t\t: yes\n" | ||
65 | "flags\t\t:", | ||
66 | c->cpuid_level); | ||
67 | |||
68 | for (i = 0; i < 32*NCAPINTS; i++) | ||
69 | if (cpu_has(c, i) && x86_cap_flags[i] != NULL) | ||
70 | seq_printf(m, " %s", x86_cap_flags[i]); | ||
71 | |||
72 | seq_printf(m, "\nbogomips\t: %lu.%02lu\n", | ||
73 | c->loops_per_jiffy/(500000/HZ), | ||
74 | (c->loops_per_jiffy/(5000/HZ)) % 100); | ||
75 | |||
76 | if (c->x86_tlbsize > 0) | ||
77 | seq_printf(m, "TLB size\t: %d 4K pages\n", c->x86_tlbsize); | ||
78 | seq_printf(m, "clflush size\t: %d\n", c->x86_clflush_size); | ||
79 | seq_printf(m, "cache_alignment\t: %d\n", c->x86_cache_alignment); | ||
80 | |||
81 | seq_printf(m, "address sizes\t: %u bits physical, %u bits virtual\n", | ||
82 | c->x86_phys_bits, c->x86_virt_bits); | ||
83 | |||
84 | seq_printf(m, "power management:"); | ||
85 | for (i = 0; i < 32; i++) { | ||
86 | if (c->x86_power & (1 << i)) { | ||
87 | if (i < ARRAY_SIZE(x86_power_flags) && | ||
88 | x86_power_flags[i]) | ||
89 | seq_printf(m, "%s%s", | ||
90 | x86_power_flags[i][0]?" ":"", | ||
91 | x86_power_flags[i]); | ||
92 | else | ||
93 | seq_printf(m, " [%d]", i); | ||
94 | } | ||
95 | } | ||
96 | |||
97 | seq_printf(m, "\n\n"); | ||
98 | |||
99 | return 0; | ||
100 | } | ||
101 | |||
102 | static void *c_start(struct seq_file *m, loff_t *pos) | ||
103 | { | ||
104 | if (*pos == 0) /* just in case, cpu 0 is not the first */ | ||
105 | *pos = first_cpu(cpu_online_map); | ||
106 | if ((*pos) < NR_CPUS && cpu_online(*pos)) | ||
107 | return &cpu_data(*pos); | ||
108 | return NULL; | ||
109 | } | ||
110 | |||
111 | static void *c_next(struct seq_file *m, void *v, loff_t *pos) | ||
112 | { | ||
113 | *pos = next_cpu(*pos, cpu_online_map); | ||
114 | return c_start(m, pos); | ||
115 | } | ||
116 | |||
117 | static void c_stop(struct seq_file *m, void *v) | ||
118 | { | ||
119 | } | ||
120 | |||
121 | const struct seq_operations cpuinfo_op = { | ||
122 | .start = c_start, | ||
123 | .next = c_next, | ||
124 | .stop = c_stop, | ||
125 | .show = show_cpuinfo, | ||
126 | }; | ||
diff --git a/arch/x86/kernel/setup_64.c b/arch/x86/kernel/setup_64.c index e67925674eae..187f084b9491 100644 --- a/arch/x86/kernel/setup_64.c +++ b/arch/x86/kernel/setup_64.c | |||
@@ -1068,123 +1068,3 @@ static __init int setup_disablecpuid(char *arg) | |||
1068 | return 1; | 1068 | return 1; |
1069 | } | 1069 | } |
1070 | __setup("clearcpuid=", setup_disablecpuid); | 1070 | __setup("clearcpuid=", setup_disablecpuid); |
1071 | |||
1072 | /* | ||
1073 | * Get CPU information for use by the procfs. | ||
1074 | */ | ||
1075 | |||
1076 | static int show_cpuinfo(struct seq_file *m, void *v) | ||
1077 | { | ||
1078 | struct cpuinfo_x86 *c = v; | ||
1079 | int cpu = 0, i; | ||
1080 | |||
1081 | #ifdef CONFIG_SMP | ||
1082 | cpu = c->cpu_index; | ||
1083 | #endif | ||
1084 | |||
1085 | seq_printf(m, "processor\t: %u\n" | ||
1086 | "vendor_id\t: %s\n" | ||
1087 | "cpu family\t: %d\n" | ||
1088 | "model\t\t: %d\n" | ||
1089 | "model name\t: %s\n", | ||
1090 | (unsigned)cpu, | ||
1091 | c->x86_vendor_id[0] ? c->x86_vendor_id : "unknown", | ||
1092 | c->x86, | ||
1093 | (int)c->x86_model, | ||
1094 | c->x86_model_id[0] ? c->x86_model_id : "unknown"); | ||
1095 | |||
1096 | if (c->x86_mask || c->cpuid_level >= 0) | ||
1097 | seq_printf(m, "stepping\t: %d\n", c->x86_mask); | ||
1098 | else | ||
1099 | seq_printf(m, "stepping\t: unknown\n"); | ||
1100 | |||
1101 | if (cpu_has(c, X86_FEATURE_TSC)) { | ||
1102 | unsigned int freq = cpufreq_quick_get((unsigned)cpu); | ||
1103 | |||
1104 | if (!freq) | ||
1105 | freq = cpu_khz; | ||
1106 | seq_printf(m, "cpu MHz\t\t: %u.%03u\n", | ||
1107 | freq / 1000, (freq % 1000)); | ||
1108 | } | ||
1109 | |||
1110 | /* Cache size */ | ||
1111 | if (c->x86_cache_size >= 0) | ||
1112 | seq_printf(m, "cache size\t: %d KB\n", c->x86_cache_size); | ||
1113 | |||
1114 | #ifdef CONFIG_SMP | ||
1115 | if (smp_num_siblings * c->x86_max_cores > 1) { | ||
1116 | seq_printf(m, "physical id\t: %d\n", c->phys_proc_id); | ||
1117 | seq_printf(m, "siblings\t: %d\n", | ||
1118 | cpus_weight(per_cpu(cpu_core_map, cpu))); | ||
1119 | seq_printf(m, "core id\t\t: %d\n", c->cpu_core_id); | ||
1120 | seq_printf(m, "cpu cores\t: %d\n", c->booted_cores); | ||
1121 | } | ||
1122 | #endif | ||
1123 | |||
1124 | seq_printf(m, | ||
1125 | "fpu\t\t: yes\n" | ||
1126 | "fpu_exception\t: yes\n" | ||
1127 | "cpuid level\t: %d\n" | ||
1128 | "wp\t\t: yes\n" | ||
1129 | "flags\t\t:", | ||
1130 | c->cpuid_level); | ||
1131 | |||
1132 | for (i = 0; i < 32*NCAPINTS; i++) | ||
1133 | if (cpu_has(c, i) && x86_cap_flags[i] != NULL) | ||
1134 | seq_printf(m, " %s", x86_cap_flags[i]); | ||
1135 | |||
1136 | seq_printf(m, "\nbogomips\t: %lu.%02lu\n", | ||
1137 | c->loops_per_jiffy/(500000/HZ), | ||
1138 | (c->loops_per_jiffy/(5000/HZ)) % 100); | ||
1139 | |||
1140 | if (c->x86_tlbsize > 0) | ||
1141 | seq_printf(m, "TLB size\t: %d 4K pages\n", c->x86_tlbsize); | ||
1142 | seq_printf(m, "clflush size\t: %d\n", c->x86_clflush_size); | ||
1143 | seq_printf(m, "cache_alignment\t: %d\n", c->x86_cache_alignment); | ||
1144 | |||
1145 | seq_printf(m, "address sizes\t: %u bits physical, %u bits virtual\n", | ||
1146 | c->x86_phys_bits, c->x86_virt_bits); | ||
1147 | |||
1148 | seq_printf(m, "power management:"); | ||
1149 | for (i = 0; i < 32; i++) { | ||
1150 | if (c->x86_power & (1 << i)) { | ||
1151 | if (i < ARRAY_SIZE(x86_power_flags) && | ||
1152 | x86_power_flags[i]) | ||
1153 | seq_printf(m, "%s%s", | ||
1154 | x86_power_flags[i][0]?" ":"", | ||
1155 | x86_power_flags[i]); | ||
1156 | else | ||
1157 | seq_printf(m, " [%d]", i); | ||
1158 | } | ||
1159 | } | ||
1160 | |||
1161 | seq_printf(m, "\n\n"); | ||
1162 | |||
1163 | return 0; | ||
1164 | } | ||
1165 | |||
1166 | static void *c_start(struct seq_file *m, loff_t *pos) | ||
1167 | { | ||
1168 | if (*pos == 0) /* just in case, cpu 0 is not the first */ | ||
1169 | *pos = first_cpu(cpu_online_map); | ||
1170 | if ((*pos) < NR_CPUS && cpu_online(*pos)) | ||
1171 | return &cpu_data(*pos); | ||
1172 | return NULL; | ||
1173 | } | ||
1174 | |||
1175 | static void *c_next(struct seq_file *m, void *v, loff_t *pos) | ||
1176 | { | ||
1177 | *pos = next_cpu(*pos, cpu_online_map); | ||
1178 | return c_start(m, pos); | ||
1179 | } | ||
1180 | |||
1181 | static void c_stop(struct seq_file *m, void *v) | ||
1182 | { | ||
1183 | } | ||
1184 | |||
1185 | const struct seq_operations cpuinfo_op = { | ||
1186 | .start = c_start, | ||
1187 | .next = c_next, | ||
1188 | .stop = c_stop, | ||
1189 | .show = show_cpuinfo, | ||
1190 | }; | ||