This source file includes following definitions.
- setup_arch
- i486model
- i586model
- getmodel
- get_cpuinfo
1
2
3
4
5
6
7
8
9
10
11 #include <linux/errno.h>
12 #include <linux/sched.h>
13 #include <linux/kernel.h>
14 #include <linux/mm.h>
15 #include <linux/stddef.h>
16 #include <linux/unistd.h>
17 #include <linux/ptrace.h>
18 #include <linux/malloc.h>
19 #include <linux/ldt.h>
20 #include <linux/user.h>
21 #include <linux/a.out.h>
22 #include <linux/tty.h>
23 #include <linux/ioport.h>
24 #include <linux/delay.h>
25 #include <linux/config.h>
26 #ifdef CONFIG_APM
27 #include <linux/apm_bios.h>
28 #endif
29
30 #include <asm/segment.h>
31 #include <asm/system.h>
32 #include <asm/smp.h>
33
34
35
36
37 char hard_math = 0;
38 char x86 = 0;
39 char x86_model = 0;
40 char x86_mask = 0;
41 int x86_capability = 0;
42 int fdiv_bug = 0;
43
44 char x86_vendor_id[13] = "Unknown";
45
46 char ignore_irq13 = 0;
47 char wp_works_ok = -1;
48 char hlt_works_ok = 1;
49
50
51
52
53 int EISA_bus = 0;
54
55
56
57
58 struct drive_info_struct { char dummy[32]; } drive_info;
59 struct screen_info screen_info;
60 #ifdef CONFIG_APM
61 struct apm_bios_info apm_bios_info;
62 #endif
63
64 unsigned char aux_device_present;
65 extern int rd_doload;
66 extern int rd_prompt;
67 extern int rd_image_start;
68 extern int root_mountflags;
69 extern int _etext, _edata, _end;
70
71 extern char empty_zero_page[PAGE_SIZE];
72
73
74
75
76 #define PARAM empty_zero_page
77 #define EXT_MEM_K (*(unsigned short *) (PARAM+2))
78 #ifdef CONFIG_APM
79 #define APM_BIOS_INFO (*(struct apm_bios_info *) (PARAM+64))
80 #endif
81 #define DRIVE_INFO (*(struct drive_info_struct *) (PARAM+0x80))
82 #define SCREEN_INFO (*(struct screen_info *) (PARAM+0))
83 #define MOUNT_ROOT_RDONLY (*(unsigned short *) (PARAM+0x1F2))
84 #define RAMDISK_FLAGS (*(unsigned short *) (PARAM+0x1F8))
85 #define ORIG_ROOT_DEV (*(unsigned short *) (PARAM+0x1FC))
86 #define AUX_DEVICE_INFO (*(unsigned char *) (PARAM+0x1FF))
87 #define COMMAND_LINE ((char *) (PARAM+2048))
88 #define COMMAND_LINE_SIZE 256
89
90 #define RAMDISK_IMAGE_START_MASK 0x07FF
91 #define RAMDISK_PROMPT_FLAG 0x8000
92 #define RAMDISK_LOAD_FLAG 0x4000
93
94 static char command_line[COMMAND_LINE_SIZE] = { 0, };
95
96 void setup_arch(char **cmdline_p,
97 unsigned long * memory_start_p, unsigned long * memory_end_p)
98 {
99 unsigned long memory_start, memory_end;
100 char c = ' ', *to = command_line, *from = COMMAND_LINE;
101 int len = 0;
102 static unsigned char smptrap=0;
103
104 if(smptrap==1)
105 {
106 return;
107 }
108 smptrap=1;
109
110 ROOT_DEV = to_kdev_t(ORIG_ROOT_DEV);
111 drive_info = DRIVE_INFO;
112 screen_info = SCREEN_INFO;
113 #ifdef CONFIG_APM
114 apm_bios_info = APM_BIOS_INFO;
115 #endif
116 aux_device_present = AUX_DEVICE_INFO;
117 memory_end = (1<<20) + (EXT_MEM_K<<10);
118 memory_end &= PAGE_MASK;
119 rd_image_start = RAMDISK_FLAGS & RAMDISK_IMAGE_START_MASK;
120 rd_prompt = ((RAMDISK_FLAGS & RAMDISK_PROMPT_FLAG) != 0);
121 rd_doload = ((RAMDISK_FLAGS & RAMDISK_LOAD_FLAG) != 0);
122 #ifdef CONFIG_MAX_16M
123 if (memory_end > 16*1024*1024)
124 memory_end = 16*1024*1024;
125 #endif
126 if (!MOUNT_ROOT_RDONLY)
127 root_mountflags &= ~MS_RDONLY;
128 memory_start = (unsigned long) &_end;
129 init_task.mm->start_code = TASK_SIZE;
130 init_task.mm->end_code = TASK_SIZE + (unsigned long) &_etext;
131 init_task.mm->end_data = TASK_SIZE + (unsigned long) &_edata;
132 init_task.mm->brk = TASK_SIZE + (unsigned long) &_end;
133
134 for (;;) {
135
136
137
138
139
140 if (c == ' ' && *(const unsigned long *)from == *(const unsigned long *)"mem=") {
141 if (!memcmp(from+4, "nopentium", 9)) {
142 from += 9+4;
143 x86_capability &= ~8;
144 } else {
145 memory_end = simple_strtoul(from+4, &from, 0);
146 if ( *from == 'K' || *from == 'k' ) {
147 memory_end = memory_end << 10;
148 from++;
149 } else if ( *from == 'M' || *from == 'm' ) {
150 memory_end = memory_end << 20;
151 from++;
152 }
153 }
154 }
155 c = *(from++);
156 if (!c)
157 break;
158 if (COMMAND_LINE_SIZE <= ++len)
159 break;
160 *(to++) = c;
161 }
162 *to = '\0';
163 *cmdline_p = command_line;
164 *memory_start_p = memory_start;
165 *memory_end_p = memory_end;
166
167 request_region(0x00,0x20,"dma1");
168 request_region(0x40,0x20,"timer");
169 request_region(0x70,0x10,"rtc");
170 request_region(0x80,0x20,"dma page reg");
171 request_region(0xc0,0x20,"dma2");
172 request_region(0xf0,0x10,"npu");
173 }
174
175 static const char * i486model(unsigned int nr)
176 {
177 static const char *model[] = {
178 "0", "DX","SX","DX/2","4","SX/2","6","DX/2-WB","DX/4"
179 };
180 if (nr < sizeof(model)/sizeof(char *))
181 return model[nr];
182 return "Unknown";
183 }
184
185 static const char * i586model(unsigned int nr)
186 {
187 static const char *model[] = {
188 "0", "Pentium 60/66","Pentium 75+"
189 };
190 if (nr < sizeof(model)/sizeof(char *))
191 return model[nr];
192 return "Unknown";
193 }
194
195 static const char * getmodel(int x86, int model)
196 {
197 switch (x86) {
198 case 4:
199 return i486model(model);
200 case 5:
201 return i586model(model);
202 }
203 return "Unknown";
204 }
205
206 int get_cpuinfo(char * buffer)
207 {
208 char mask[2];
209 #ifndef __SMP__
210 mask[0] = x86_mask+'@';
211 mask[1] = '\0';
212 return sprintf(buffer,"cpu\t\t: %c86\n"
213 "model\t\t: %s\n"
214 "mask\t\t: %s\n"
215 "vid\t\t: %s\n"
216 "fdiv_bug\t: %s\n"
217 "math\t\t: %s\n"
218 "hlt\t\t: %s\n"
219 "wp\t\t: %s\n"
220 "Integrated NPU\t: %s\n"
221 "Enhanced VM86\t: %s\n"
222 "IO Breakpoints\t: %s\n"
223 "4MB Pages\t: %s\n"
224 "TS Counters\t: %s\n"
225 "Pentium MSR\t: %s\n"
226 "Mach. Ch. Exep.\t: %s\n"
227 "CMPXCHGB8B\t: %s\n"
228 "BogoMips\t: %lu.%02lu\n",
229 x86+'0',
230 getmodel(x86, x86_model),
231 x86_mask ? mask : "Unknown",
232 x86_vendor_id,
233 fdiv_bug ? "yes" : "no",
234 hard_math ? "yes" : "no",
235 hlt_works_ok ? "yes" : "no",
236 wp_works_ok ? "yes" : "no",
237 x86_capability & 1 ? "yes" : "no",
238 x86_capability & 2 ? "yes" : "no",
239 x86_capability & 4 ? "yes" : "no",
240 x86_capability & 8 ? "yes" : "no",
241 x86_capability & 16 ? "yes" : "no",
242 x86_capability & 32 ? "yes" : "no",
243 x86_capability & 128 ? "yes" : "no",
244 x86_capability & 256 ? "yes" : "no",
245 loops_per_sec/500000, (loops_per_sec/5000) % 100
246 );
247 #else
248 char *bp=buffer;
249 int i;
250 bp+=sprintf(bp,"cpu\t\t: ");
251 for(i=0;i<32;i++)
252 if(cpu_present_map&(1<<i))
253 bp+=sprintf(bp,"%c86 ",cpu_data[i].x86+'0');
254 bp+=sprintf(bp,"\nmodel\t\t: ");
255 for(i=0;i<32;i++)
256 if(cpu_present_map&(1<<i))
257 bp+=sprintf(bp,"%-16s",getmodel(cpu_data[i].x86,cpu_data[i].x86_model));
258 bp+=sprintf(bp,"\nmask\t\t: ");
259 for(i=0;i<32;i++)
260 if(cpu_present_map&(1<<i))
261 {
262 mask[0] = cpu_data[i].x86_mask+'@';
263 mask[1] = '\0';
264 bp+=sprintf(bp,"%-16s", cpu_data[i].x86_mask ? mask : "Unknown");
265 }
266 bp+=sprintf(bp,"\nvid\t\t: ");
267 for(i=0;i<32;i++)
268 if(cpu_present_map&(1<<i))
269 bp+=sprintf(bp,"%-16s", cpu_data[i].x86_vendor_id);
270 bp+=sprintf(bp,"\nfdiv_bug\t: ");
271 for(i=0;i<32;i++)
272 if(cpu_present_map&(1<<i))
273 bp+=sprintf(bp,"%-16s", cpu_data[i].fdiv_bug?"yes":"no");
274 bp+=sprintf(bp,"\nmath\t\t: ");
275 for(i=0;i<32;i++)
276 if(cpu_present_map&(1<<i))
277 bp+=sprintf(bp,"%-16s", cpu_data[i].hard_math?"yes":"no");
278 bp+=sprintf(bp,"\nhlt\t\t: ");
279 for(i=0;i<32;i++)
280 if(cpu_present_map&(1<<i))
281 bp+=sprintf(bp,"%-16s", cpu_data[i].hlt_works_ok?"yes":"no");
282 bp+=sprintf(bp,"\nwp\t\t: ");
283 for(i=0;i<32;i++)
284 if(cpu_present_map&(1<<i))
285 bp+=sprintf(bp,"%-16s", cpu_data[i].wp_works_ok?"yes":"no");
286 bp+=sprintf(bp,"\nIntegrated NPU\t: ");
287 for(i=0;i<32;i++)
288 if(cpu_present_map&(1<<i))
289 bp+=sprintf(bp,"%-16s", cpu_data[i].x86_capability&1?"yes":"no");
290 bp+=sprintf(bp,"\nEnhanced VM86\t: ");
291 for(i=0;i<32;i++)
292 if(cpu_present_map&(1<<i))
293 bp+=sprintf(bp,"%-16s", cpu_data[i].x86_capability&2?"yes":"no");
294 bp+=sprintf(bp,"\nIO Breakpoints\t: ");
295 for(i=0;i<32;i++)
296 if(cpu_present_map&(1<<i))
297 bp+=sprintf(bp,"%-16s", (cpu_data[i].x86_capability&4)?"yes":"no");
298 bp+=sprintf(bp,"\n4MB Pages\t: ");
299 for(i=0;i<32;i++)
300 if(cpu_present_map&(1<<i))
301 bp+=sprintf(bp,"%-16s", (cpu_data[i].x86_capability)&8?"yes":"no");
302 bp+=sprintf(bp,"\nTS Counters\t: ");
303 for(i=0;i<32;i++)
304 if(cpu_present_map&(1<<i))
305 bp+=sprintf(bp,"%-16s", (cpu_data[i].x86_capability&16)?"yes":"no");
306 bp+=sprintf(bp,"\nPentium MSR\t: ");
307 for(i=0;i<32;i++)
308 if(cpu_present_map&(1<<i))
309 bp+=sprintf(bp,"%-16s", (cpu_data[i].x86_capability&32)?"yes":"no");
310 bp+=sprintf(bp,"\nMach. Ch. Exep.\t: ");
311 for(i=0;i<32;i++)
312 if(cpu_present_map&(1<<i))
313 bp+=sprintf(bp,"%-16s", (cpu_data[i].x86_capability&128)?"yes":"no");
314 bp+=sprintf(bp,"\nCMPXCHG8B\t: ");
315 for(i=0;i<32;i++)
316 if(cpu_present_map&(1<<i))
317 bp+=sprintf(bp,"%-16s", (cpu_data[i].x86_capability&256)?"yes":"no");
318 bp+=sprintf(bp,"\nBogoMips\t: ");
319 for(i=0;i<32;i++)
320 {
321 char tmp[17];
322 if(cpu_present_map&(1<<i))
323 {
324 sprintf(tmp,"%lu.%02lu",cpu_data[i].udelay_val/500000L,
325 (cpu_data[i].udelay_val/5000L)%100);
326 bp+=sprintf(bp,"%-16s",tmp);
327 }
328 }
329 *bp++='\n';
330 return bp-buffer;
331 #endif
332 }