direct-io.hg

view xen/arch/x86/dmi_scan.c @ 15516:fa9fa5f98c91

Simplify Unisys ES7000 code in light of the fact we do not support
legacy boxes with very non-standard APIC setup.
From: Raj Subrahmanian <raj.subrahmanian@unisys.com>
Signed-off-by: Keir Fraser <keir@xensource.com>
author kfraser@localhost.localdomain
date Tue Jul 10 10:07:00 2007 +0100 (2007-07-10)
parents f45de0fe8a15
children
line source
1 #include <xen/config.h>
2 #include <xen/types.h>
3 #include <xen/lib.h>
4 #include <xen/kernel.h>
5 #include <xen/string.h>
6 #include <xen/init.h>
7 #include <xen/cache.h>
8 #include <xen/acpi.h>
9 #include <asm/io.h>
10 #include <asm/system.h>
11 #include <xen/dmi.h>
13 #define bt_ioremap(b,l) ((u8 *)__acpi_map_table(b,l))
14 #define bt_iounmap(b,l) ((void)0)
15 #define memcpy_fromio memcpy
16 #define alloc_bootmem(l) xmalloc_bytes(l)
18 struct dmi_header
19 {
20 u8 type;
21 u8 length;
22 u16 handle;
23 };
25 #undef DMI_DEBUG
27 #ifdef DMI_DEBUG
28 #define dmi_printk(x) printk x
29 #else
30 #define dmi_printk(x)
31 #endif
33 static char * __init dmi_string(struct dmi_header *dm, u8 s)
34 {
35 char *bp=(char *)dm;
36 bp+=dm->length;
37 if(!s)
38 return "";
39 s--;
40 while(s>0 && *bp)
41 {
42 bp+=strlen(bp);
43 bp++;
44 s--;
45 }
46 return bp;
47 }
49 /*
50 * We have to be cautious here. We have seen BIOSes with DMI pointers
51 * pointing to completely the wrong place for example
52 */
54 static int __init dmi_table(u32 base, int len, int num, void (*decode)(struct dmi_header *))
55 {
56 u8 *buf;
57 struct dmi_header *dm;
58 u8 *data;
59 int i=0;
61 buf = bt_ioremap(base, len);
62 if(buf==NULL)
63 return -1;
65 data = buf;
67 /*
68 * Stop when we see all the items the table claimed to have
69 * OR we run off the end of the table (also happens)
70 */
72 while(i<num && data-buf+sizeof(struct dmi_header)<=len)
73 {
74 dm=(struct dmi_header *)data;
75 /*
76 * We want to know the total length (formated area and strings)
77 * before decoding to make sure we won't run off the table in
78 * dmi_decode or dmi_string
79 */
80 data+=dm->length;
81 while(data-buf<len-1 && (data[0] || data[1]))
82 data++;
83 if(data-buf<len-1)
84 decode(dm);
85 data+=2;
86 i++;
87 }
88 bt_iounmap(buf, len);
89 return 0;
90 }
93 inline static int __init dmi_checksum(u8 *buf)
94 {
95 u8 sum=0;
96 int a;
98 for(a=0; a<15; a++)
99 sum+=buf[a];
100 return (sum==0);
101 }
103 static int __init dmi_iterate(void (*decode)(struct dmi_header *))
104 {
105 u8 buf[15];
106 char __iomem *p, *q;
108 /*
109 * no iounmap() for that ioremap(); it would be a no-op, but it's
110 * so early in setup that sucker gets confused into doing what
111 * it shouldn't if we actually call it.
112 */
113 p = ioremap(0xF0000, 0x10000);
114 if (p == NULL)
115 return -1;
116 for (q = p; q < p + 0x10000; q += 16) {
117 memcpy_fromio(buf, q, 15);
118 if(memcmp(buf, "_DMI_", 5)==0 && dmi_checksum(buf))
119 {
120 u16 num=buf[13]<<8|buf[12];
121 u16 len=buf[7]<<8|buf[6];
122 u32 base=buf[11]<<24|buf[10]<<16|buf[9]<<8|buf[8];
124 /*
125 * DMI version 0.0 means that the real version is taken from
126 * the SMBIOS version, which we don't know at this point.
127 */
128 if(buf[14]!=0)
129 printk(KERN_INFO "DMI %d.%d present.\n",
130 buf[14]>>4, buf[14]&0x0F);
131 else
132 printk(KERN_INFO "DMI present.\n");
133 dmi_printk((KERN_INFO "%d structures occupying %d bytes.\n",
134 num, len));
135 dmi_printk((KERN_INFO "DMI table at 0x%08X.\n",
136 base));
137 if(dmi_table(base,len, num, decode)==0)
138 return 0;
139 }
140 }
141 return -1;
142 }
144 static char *dmi_ident[DMI_STRING_MAX];
146 /*
147 * Save a DMI string
148 */
150 static void __init dmi_save_ident(struct dmi_header *dm, int slot, int string)
151 {
152 char *d = (char*)dm;
153 char *p = dmi_string(dm, d[string]);
154 if(p==NULL || *p == 0)
155 return;
156 if (dmi_ident[slot])
157 return;
158 dmi_ident[slot] = alloc_bootmem(strlen(p)+1);
159 if(dmi_ident[slot])
160 strlcpy(dmi_ident[slot], p, strlen(p)+1);
161 else
162 printk(KERN_ERR "dmi_save_ident: out of memory.\n");
163 }
165 /*
166 * Ugly compatibility crap.
167 */
168 #define dmi_blacklist dmi_system_id
169 #define NO_MATCH { DMI_NONE, NULL}
170 #define MATCH DMI_MATCH
172 /*
173 * Toshiba keyboard likes to repeat keys when they are not repeated.
174 */
176 static __init int broken_toshiba_keyboard(struct dmi_blacklist *d)
177 {
178 printk(KERN_WARNING "Toshiba with broken keyboard detected. If your keyboard sometimes generates 3 keypresses instead of one, see http://davyd.ucc.asn.au/projects/toshiba/README\n");
179 return 0;
180 }
183 #ifdef CONFIG_ACPI_SLEEP
184 static __init int reset_videomode_after_s3(struct dmi_blacklist *d)
185 {
186 /* See acpi_wakeup.S */
187 extern long acpi_video_flags;
188 acpi_video_flags |= 2;
189 return 0;
190 }
191 #endif
194 #ifdef CONFIG_ACPI_BOOT
195 extern int acpi_force;
197 static __init __attribute__((unused)) int dmi_disable_acpi(struct dmi_blacklist *d)
198 {
199 if (!acpi_force) {
200 printk(KERN_NOTICE "%s detected: acpi off\n",d->ident);
201 disable_acpi();
202 } else {
203 printk(KERN_NOTICE
204 "Warning: DMI blacklist says broken, but acpi forced\n");
205 }
206 return 0;
207 }
209 /*
210 * Limit ACPI to CPU enumeration for HT
211 */
212 static __init __attribute__((unused)) int force_acpi_ht(struct dmi_blacklist *d)
213 {
214 if (!acpi_force) {
215 printk(KERN_NOTICE "%s detected: force use of acpi=ht\n", d->ident);
216 disable_acpi();
217 acpi_ht = 1;
218 } else {
219 printk(KERN_NOTICE
220 "Warning: acpi=force overrules DMI blacklist: acpi=ht\n");
221 }
222 return 0;
223 }
224 #endif
226 #ifdef CONFIG_ACPI_PCI
227 static __init int disable_acpi_irq(struct dmi_blacklist *d)
228 {
229 if (!acpi_force) {
230 printk(KERN_NOTICE "%s detected: force use of acpi=noirq\n",
231 d->ident);
232 acpi_noirq_set();
233 }
234 return 0;
235 }
236 static __init int disable_acpi_pci(struct dmi_blacklist *d)
237 {
238 if (!acpi_force) {
239 printk(KERN_NOTICE "%s detected: force use of pci=noacpi\n",
240 d->ident);
241 acpi_disable_pci();
242 }
243 return 0;
244 }
245 #endif
247 /*
248 * Process the DMI blacklists
249 */
252 /*
253 * This will be expanded over time to force things like the APM
254 * interrupt mask settings according to the laptop
255 */
257 static __initdata struct dmi_blacklist dmi_blacklist[]={
259 { broken_toshiba_keyboard, "Toshiba Satellite 4030cdt", { /* Keyboard generates spurious repeats */
260 MATCH(DMI_PRODUCT_NAME, "S4030CDT/4.3"),
261 NO_MATCH, NO_MATCH, NO_MATCH
262 } },
263 #ifdef CONFIG_ACPI_SLEEP
264 { reset_videomode_after_s3, "Toshiba Satellite 4030cdt", { /* Reset video mode after returning from ACPI S3 sleep */
265 MATCH(DMI_PRODUCT_NAME, "S4030CDT/4.3"),
266 NO_MATCH, NO_MATCH, NO_MATCH
267 } },
268 #endif
270 #ifdef CONFIG_ACPI_BOOT
271 /*
272 * If your system is blacklisted here, but you find that acpi=force
273 * works for you, please contact acpi-devel@sourceforge.net
274 */
276 /*
277 * Boxes that need ACPI disabled
278 */
280 { dmi_disable_acpi, "IBM Thinkpad", {
281 MATCH(DMI_BOARD_VENDOR, "IBM"),
282 MATCH(DMI_BOARD_NAME, "2629H1G"),
283 NO_MATCH, NO_MATCH }},
285 /*
286 * Boxes that need acpi=ht
287 */
289 { force_acpi_ht, "FSC Primergy T850", {
290 MATCH(DMI_SYS_VENDOR, "FUJITSU SIEMENS"),
291 MATCH(DMI_PRODUCT_NAME, "PRIMERGY T850"),
292 NO_MATCH, NO_MATCH }},
294 { force_acpi_ht, "DELL GX240", {
295 MATCH(DMI_BOARD_VENDOR, "Dell Computer Corporation"),
296 MATCH(DMI_BOARD_NAME, "OptiPlex GX240"),
297 NO_MATCH, NO_MATCH }},
299 { force_acpi_ht, "HP VISUALIZE NT Workstation", {
300 MATCH(DMI_BOARD_VENDOR, "Hewlett-Packard"),
301 MATCH(DMI_PRODUCT_NAME, "HP VISUALIZE NT Workstation"),
302 NO_MATCH, NO_MATCH }},
304 { force_acpi_ht, "Compaq Workstation W8000", {
305 MATCH(DMI_SYS_VENDOR, "Compaq"),
306 MATCH(DMI_PRODUCT_NAME, "Workstation W8000"),
307 NO_MATCH, NO_MATCH }},
309 { force_acpi_ht, "ASUS P4B266", {
310 MATCH(DMI_BOARD_VENDOR, "ASUSTeK Computer INC."),
311 MATCH(DMI_BOARD_NAME, "P4B266"),
312 NO_MATCH, NO_MATCH }},
314 { force_acpi_ht, "ASUS P2B-DS", {
315 MATCH(DMI_BOARD_VENDOR, "ASUSTeK Computer INC."),
316 MATCH(DMI_BOARD_NAME, "P2B-DS"),
317 NO_MATCH, NO_MATCH }},
319 { force_acpi_ht, "ASUS CUR-DLS", {
320 MATCH(DMI_BOARD_VENDOR, "ASUSTeK Computer INC."),
321 MATCH(DMI_BOARD_NAME, "CUR-DLS"),
322 NO_MATCH, NO_MATCH }},
324 { force_acpi_ht, "ABIT i440BX-W83977", {
325 MATCH(DMI_BOARD_VENDOR, "ABIT <http://www.abit.com>"),
326 MATCH(DMI_BOARD_NAME, "i440BX-W83977 (BP6)"),
327 NO_MATCH, NO_MATCH }},
329 { force_acpi_ht, "IBM Bladecenter", {
330 MATCH(DMI_BOARD_VENDOR, "IBM"),
331 MATCH(DMI_BOARD_NAME, "IBM eServer BladeCenter HS20"),
332 NO_MATCH, NO_MATCH }},
334 { force_acpi_ht, "IBM eServer xSeries 360", {
335 MATCH(DMI_BOARD_VENDOR, "IBM"),
336 MATCH(DMI_BOARD_NAME, "eServer xSeries 360"),
337 NO_MATCH, NO_MATCH }},
339 { force_acpi_ht, "IBM eserver xSeries 330", {
340 MATCH(DMI_BOARD_VENDOR, "IBM"),
341 MATCH(DMI_BOARD_NAME, "eserver xSeries 330"),
342 NO_MATCH, NO_MATCH }},
344 { force_acpi_ht, "IBM eserver xSeries 440", {
345 MATCH(DMI_BOARD_VENDOR, "IBM"),
346 MATCH(DMI_PRODUCT_NAME, "eserver xSeries 440"),
347 NO_MATCH, NO_MATCH }},
349 #endif // CONFIG_ACPI_BOOT
351 #ifdef CONFIG_ACPI_PCI
352 /*
353 * Boxes that need ACPI PCI IRQ routing disabled
354 */
356 { disable_acpi_irq, "ASUS A7V", {
357 MATCH(DMI_BOARD_VENDOR, "ASUSTeK Computer INC"),
358 MATCH(DMI_BOARD_NAME, "<A7V>"),
359 /* newer BIOS, Revision 1011, does work */
360 MATCH(DMI_BIOS_VERSION, "ASUS A7V ACPI BIOS Revision 1007"),
361 NO_MATCH }},
363 /*
364 * Boxes that need ACPI PCI IRQ routing and PCI scan disabled
365 */
366 { disable_acpi_pci, "ASUS PR-DLS", { /* _BBN 0 bug */
367 MATCH(DMI_BOARD_VENDOR, "ASUSTeK Computer INC."),
368 MATCH(DMI_BOARD_NAME, "PR-DLS"),
369 MATCH(DMI_BIOS_VERSION, "ASUS PR-DLS ACPI BIOS Revision 1010"),
370 MATCH(DMI_BIOS_DATE, "03/21/2003") }},
372 { disable_acpi_pci, "Acer TravelMate 36x Laptop", {
373 MATCH(DMI_SYS_VENDOR, "Acer"),
374 MATCH(DMI_PRODUCT_NAME, "TravelMate 360"),
375 NO_MATCH, NO_MATCH
376 } },
378 #endif
380 { NULL, }
381 };
383 /*
384 * Process a DMI table entry. Right now all we care about are the BIOS
385 * and machine entries. For 2.5 we should pull the smbus controller info
386 * out of here.
387 */
389 static void __init dmi_decode(struct dmi_header *dm)
390 {
391 #ifdef DMI_DEBUG
392 u8 *data = (u8 *)dm;
393 #endif
395 switch(dm->type)
396 {
397 case 0:
398 dmi_printk(("BIOS Vendor: %s\n",
399 dmi_string(dm, data[4])));
400 dmi_save_ident(dm, DMI_BIOS_VENDOR, 4);
401 dmi_printk(("BIOS Version: %s\n",
402 dmi_string(dm, data[5])));
403 dmi_save_ident(dm, DMI_BIOS_VERSION, 5);
404 dmi_printk(("BIOS Release: %s\n",
405 dmi_string(dm, data[8])));
406 dmi_save_ident(dm, DMI_BIOS_DATE, 8);
407 break;
408 case 1:
409 dmi_printk(("System Vendor: %s\n",
410 dmi_string(dm, data[4])));
411 dmi_save_ident(dm, DMI_SYS_VENDOR, 4);
412 dmi_printk(("Product Name: %s\n",
413 dmi_string(dm, data[5])));
414 dmi_save_ident(dm, DMI_PRODUCT_NAME, 5);
415 dmi_printk(("Version: %s\n",
416 dmi_string(dm, data[6])));
417 dmi_save_ident(dm, DMI_PRODUCT_VERSION, 6);
418 dmi_printk(("Serial Number: %s\n",
419 dmi_string(dm, data[7])));
420 break;
421 case 2:
422 dmi_printk(("Board Vendor: %s\n",
423 dmi_string(dm, data[4])));
424 dmi_save_ident(dm, DMI_BOARD_VENDOR, 4);
425 dmi_printk(("Board Name: %s\n",
426 dmi_string(dm, data[5])));
427 dmi_save_ident(dm, DMI_BOARD_NAME, 5);
428 dmi_printk(("Board Version: %s\n",
429 dmi_string(dm, data[6])));
430 dmi_save_ident(dm, DMI_BOARD_VERSION, 6);
431 break;
432 }
433 }
435 void __init dmi_scan_machine(void)
436 {
437 int err = dmi_iterate(dmi_decode);
438 if(err == 0)
439 dmi_check_system(dmi_blacklist);
440 else
441 printk(KERN_INFO "DMI not present.\n");
442 }
445 /**
446 * dmi_check_system - check system DMI data
447 * @list: array of dmi_system_id structures to match against
448 *
449 * Walk the blacklist table running matching functions until someone
450 * returns non zero or we hit the end. Callback function is called for
451 * each successfull match. Returns the number of matches.
452 */
453 int dmi_check_system(struct dmi_system_id *list)
454 {
455 int i, count = 0;
456 struct dmi_system_id *d = list;
458 while (d->ident) {
459 for (i = 0; i < ARRAY_SIZE(d->matches); i++) {
460 int s = d->matches[i].slot;
461 if (s == DMI_NONE)
462 continue;
463 if (dmi_ident[s] && strstr(dmi_ident[s], d->matches[i].substr))
464 continue;
465 /* No match */
466 goto fail;
467 }
468 if (d->callback && d->callback(d))
469 break;
470 count++;
471 fail: d++;
472 }
474 return count;
475 }
477 EXPORT_SYMBOL(dmi_check_system);
479 /**
480 * dmi_get_system_info - return DMI data value
481 * @field: data index (see enum dmi_filed)
482 *
483 * Returns one DMI data value, can be used to perform
484 * complex DMI data checks.
485 */
486 char * dmi_get_system_info(int field)
487 {
488 return dmi_ident[field];
489 }
491 EXPORT_SYMBOL(dmi_get_system_info);