1 #include <linux/types.h>
2 #include <linux/string.h>
4 #include <linux/module.h>
5 #include <linux/ctype.h>
9 #include <linux/random.h>
17 static char dmi_empty_string[] =
" ";
22 static int dmi_initialized;
30 while (s > 0 && *bp) {
37 size_t cmp_len = len > 8 ? 8 : len;
39 if (!
memcmp(bp, dmi_empty_string, cmp_len))
40 return dmi_empty_string;
50 const char *bp = dmi_string_nosave(dm, s);
54 if (bp == dmi_empty_string)
55 return dmi_empty_string;
71 static void dmi_table(
u8 *
buf,
int len,
int num,
72 void (*decode)(
const struct dmi_header *,
void *),
82 while ((i < num) && (data - buf +
sizeof(
struct dmi_header)) <= len) {
91 while ((data - buf < len - 1) && (data[0] || data[1]))
93 if (data - buf < len - 1)
94 decode(dm, private_data);
113 dmi_table(buf, dmi_len, dmi_num, decode,
NULL);
121 static int __init dmi_checksum(
const u8 *buf)
126 for (a = 0; a < 15; a++)
141 const char *
d = (
const char*) dm;
147 p = dmi_string(dm, d[
string]);
156 const u8 *
d = (
u8*) dm + index;
158 int is_ff = 1, is_00 = 1,
i;
163 for (i = 0; i < 16 && (is_ff || is_00); i++) {
164 if(d[i] != 0x00) is_ff = 0;
165 if(d[i] != 0xFF) is_00 = 0;
180 static void __init dmi_save_type(
const struct dmi_header *dm,
int slot,
int index)
182 const u8 *d = (
u8*) dm + index;
196 static void __init dmi_save_one_device(
int type,
const char *
name)
211 strcpy((
char *)(dev + 1), name);
212 dev->
name = (
char *)(dev + 1);
214 list_add(&dev->
list, &dmi_devices);
221 for (i = 0; i <
count; i++) {
222 const char *d = (
char *)(dm + 1) + (i * 2);
225 if ((*d & 0x80) == 0)
228 dmi_save_one_device(*d & 0x7f, dmi_string_nosave(dm, *(d + 1)));
232 static void __init dmi_save_oem_strings_devices(
const struct dmi_header *dm)
234 int i, count = *(
u8 *)(dm + 1);
237 for (i = 1; i <=
count; i++) {
238 char *devname = dmi_string(dm, i);
240 if (devname == dmi_empty_string)
246 "dmi_save_oem_strings_devices: out of memory.\n");
254 list_add(&dev->
list, &dmi_devices);
278 dev->
name =
"IPMI controller";
285 int devfn,
const char *name)
287 struct dmi_dev_onboard *onboard_dev;
294 onboard_dev->instance = instance;
295 onboard_dev->segment =
segment;
296 onboard_dev->bus =
bus;
297 onboard_dev->devfn =
devfn;
299 strcpy((
char *)&onboard_dev[1], name);
301 onboard_dev->dev.name = (
char *)&onboard_dev[1];
302 onboard_dev->dev.device_data = onboard_dev;
304 list_add(&onboard_dev->dev.list, &dmi_devices);
309 const u8 *d = (
u8*) dm + 5;
312 if ((*d & 0x80) == 0)
315 dmi_save_dev_onboard(*(d+1), *(
u16 *)(d+2), *(d+4), *(d+5),
316 dmi_string_nosave(dm, *(d-1)));
317 dmi_save_one_device(*d & 0x7f, dmi_string_nosave(dm, *(d - 1)));
355 dmi_save_devices(dm);
358 dmi_save_oem_strings_devices(dm);
361 dmi_save_ipmi_device(dm);
364 dmi_save_extended_devices(dm);
368 static void __init print_filtered(
const char *
info)
375 for (p = info; *
p; p++)
382 static void __init dmi_dump_ids(
void)
393 print_filtered(board);
407 if ((
memcmp(buf,
"_DMI_", 5) == 0) && dmi_checksum(buf)) {
408 dmi_num = (buf[13] << 8) | buf[12];
409 dmi_len = (buf[7] << 8) | buf[6];
410 dmi_base = (buf[11] << 24) | (buf[10] << 16) |
411 (buf[9] << 8) | buf[8];
419 buf[14] >> 4, buf[14] & 0xF);
422 if (dmi_walk_early(dmi_decode) == 0) {
447 rc = dmi_present(p + 0x10);
464 for (q = p; q < p + 0x10000; q += 16) {
488 WARN(!dmi_initialized,
KERN_ERR "dmi check: not initialized yet.\n");
507 static bool dmi_is_end_of_table(
const struct dmi_system_id *dmi)
530 for (d = list; !dmi_is_end_of_table(d); d++)
531 if (dmi_matches(d)) {
557 for (d = list; !dmi_is_end_of_table(d); d++)
574 return dmi_ident[
field];
585 if (dmi_ident[f] &&
strstr(dmi_ident[f], str))
598 for (i = 0; fields[
i] !=
DMI_NONE; i++) {
600 if (dmi_ident[f] &&
strstr(dmi_ident[f], str))
625 for(d = head->
next; d != &dmi_devices; d = d->
next) {
680 if (y != e && year < 100) {
690 if (s == e || *e !=
'/' || !
month ||
month > 12) {
697 if (s == y || s == e || *e !=
'/' ||
day > 31)
725 buf =
ioremap(dmi_base, dmi_len);
729 dmi_table(buf, dmi_len, dmi_num, decode, private_data);
750 return !
strcmp(info, str);