1 #include <linux/types.h>
2 #include <linux/kernel.h>
3 #include <linux/string.h>
4 #include <linux/init.h>
5 #include <linux/module.h>
6 #include <linux/slab.h>
7 #include <linux/acpi.h>
10 #include <asm/system.h>
11 #include <linux/dmi.h>
12 #include <linux/bootmem.h>
25 #define dmi_printk(x) printk x
30 static char * __init
dmi_string(struct dmi_header
*dm
, u8 s
)
47 * We have to be cautious here. We have seen BIOSes with DMI pointers
48 * pointing to completely the wrong place for example
51 static int __init
dmi_table(u32 base
, int len
, int num
, void (*decode
)(struct dmi_header
*))
54 struct dmi_header
*dm
;
58 buf
= bt_ioremap(base
, len
);
65 * Stop when we see all the items the table claimed to have
66 * OR we run off the end of the table (also happens)
69 while(i
<num
&& data
-buf
+sizeof(struct dmi_header
)<=len
)
71 dm
=(struct dmi_header
*)data
;
73 * We want to know the total length (formated area and strings)
74 * before decoding to make sure we won't run off the table in
75 * dmi_decode or dmi_string
78 while(data
-buf
<len
-1 && (data
[0] || data
[1]))
90 inline static int __init
dmi_checksum(u8
*buf
)
100 static int __init
dmi_iterate(void (*decode
)(struct dmi_header
*))
106 * no iounmap() for that ioremap(); it would be a no-op, but it's
107 * so early in setup that sucker gets confused into doing what
108 * it shouldn't if we actually call it.
110 p
= ioremap(0xF0000, 0x10000);
113 for (q
= p
; q
< p
+ 0x10000; q
+= 16) {
114 memcpy_fromio(buf
, q
, 15);
115 if(memcmp(buf
, "_DMI_", 5)==0 && dmi_checksum(buf
))
117 u16 num
=buf
[13]<<8|buf
[12];
118 u16 len
=buf
[7]<<8|buf
[6];
119 u32 base
=buf
[11]<<24|buf
[10]<<16|buf
[9]<<8|buf
[8];
122 * DMI version 0.0 means that the real version is taken from
123 * the SMBIOS version, which we don't know at this point.
126 printk(KERN_INFO
"DMI %d.%d present.\n",
127 buf
[14]>>4, buf
[14]&0x0F);
129 printk(KERN_INFO
"DMI present.\n");
130 dmi_printk((KERN_INFO
"%d structures occupying %d bytes.\n",
132 dmi_printk((KERN_INFO
"DMI table at 0x%08X.\n",
134 if(dmi_table(base
,len
, num
, decode
)==0)
141 static char *dmi_ident
[DMI_STRING_MAX
];
147 static void __init
dmi_save_ident(struct dmi_header
*dm
, int slot
, int string
)
150 char *p
= dmi_string(dm
, d
[string
]);
151 if(p
==NULL
|| *p
== 0)
155 dmi_ident
[slot
] = alloc_bootmem(strlen(p
)+1);
157 strcpy(dmi_ident
[slot
], p
);
159 printk(KERN_ERR
"dmi_save_ident: out of memory.\n");
163 * Ugly compatibility crap.
165 #define dmi_blacklist dmi_system_id
166 #define NO_MATCH { DMI_NONE, NULL}
167 #define MATCH DMI_MATCH
170 * Toshiba keyboard likes to repeat keys when they are not repeated.
173 static __init
int broken_toshiba_keyboard(struct dmi_blacklist
*d
)
175 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");
182 * Process the DMI blacklists
187 * This will be expanded over time to force things like the APM
188 * interrupt mask settings according to the laptop
191 static __initdata
struct dmi_blacklist dmi_blacklist
[]={
193 { broken_toshiba_keyboard
, "Toshiba Satellite 4030cdt", { /* Keyboard generates spurious repeats */
194 MATCH(DMI_PRODUCT_NAME
, "S4030CDT/4.3"),
195 NO_MATCH
, NO_MATCH
, NO_MATCH
202 * Process a DMI table entry. Right now all we care about are the BIOS
203 * and machine entries. For 2.5 we should pull the smbus controller info
207 static void __init
dmi_decode(struct dmi_header
*dm
)
216 dmi_printk(("BIOS Vendor: %s\n",
217 dmi_string(dm
, data
[4])));
218 dmi_save_ident(dm
, DMI_BIOS_VENDOR
, 4);
219 dmi_printk(("BIOS Version: %s\n",
220 dmi_string(dm
, data
[5])));
221 dmi_save_ident(dm
, DMI_BIOS_VERSION
, 5);
222 dmi_printk(("BIOS Release: %s\n",
223 dmi_string(dm
, data
[8])));
224 dmi_save_ident(dm
, DMI_BIOS_DATE
, 8);
227 dmi_printk(("System Vendor: %s\n",
228 dmi_string(dm
, data
[4])));
229 dmi_save_ident(dm
, DMI_SYS_VENDOR
, 4);
230 dmi_printk(("Product Name: %s\n",
231 dmi_string(dm
, data
[5])));
232 dmi_save_ident(dm
, DMI_PRODUCT_NAME
, 5);
233 dmi_printk(("Version: %s\n",
234 dmi_string(dm
, data
[6])));
235 dmi_save_ident(dm
, DMI_PRODUCT_VERSION
, 6);
236 dmi_printk(("Serial Number: %s\n",
237 dmi_string(dm
, data
[7])));
238 dmi_save_ident(dm
, DMI_PRODUCT_SERIAL
, 7);
241 dmi_printk(("Board Vendor: %s\n",
242 dmi_string(dm
, data
[4])));
243 dmi_save_ident(dm
, DMI_BOARD_VENDOR
, 4);
244 dmi_printk(("Board Name: %s\n",
245 dmi_string(dm
, data
[5])));
246 dmi_save_ident(dm
, DMI_BOARD_NAME
, 5);
247 dmi_printk(("Board Version: %s\n",
248 dmi_string(dm
, data
[6])));
249 dmi_save_ident(dm
, DMI_BOARD_VERSION
, 6);
254 void __init
dmi_scan_machine(void)
256 int err
= dmi_iterate(dmi_decode
);
258 dmi_check_system(dmi_blacklist
);
260 printk(KERN_INFO
"DMI not present.\n");
265 * dmi_check_system - check system DMI data
266 * @list: array of dmi_system_id structures to match against
268 * Walk the blacklist table running matching functions until someone
269 * returns non zero or we hit the end. Callback function is called for
270 * each successfull match. Returns the number of matches.
272 int dmi_check_system(struct dmi_system_id
*list
)
275 struct dmi_system_id
*d
= list
;
278 for (i
= 0; i
< ARRAY_SIZE(d
->matches
); i
++) {
279 int s
= d
->matches
[i
].slot
;
282 if (dmi_ident
[s
] && strstr(dmi_ident
[s
], d
->matches
[i
].substr
))
287 if (d
->callback
&& d
->callback(d
))
295 EXPORT_SYMBOL(dmi_check_system
);
298 * dmi_get_system_info - return DMI data value
299 * @field: data index (see enum dmi_filed)
301 * Returns one DMI data value, can be used to perform
302 * complex DMI data checks.
304 char *dmi_get_system_info(int field
)
306 return dmi_ident
[field
];
308 EXPORT_SYMBOL(dmi_get_system_info
);