1 #include <linux/types.h>
2 #include <linux/string.h>
3 #include <linux/init.h>
4 #include <linux/module.h>
5 #include <linux/ctype.h>
8 #include <linux/bootmem.h>
9 #include <linux/random.h>
11 #include <asm/unaligned.h>
14 * DMI stands for "Desktop Management Interface". It is part
15 * of and an antecedent to, SMBIOS, which stands for System
16 * Management BIOS. See further: http://www.dmtf.org/standards
18 static const char dmi_empty_string
[] = " ";
20 static u16 __initdata dmi_ver
;
22 * Catch too early calls to dmi_check_system():
24 static int dmi_initialized
;
26 /* DMI system identification string used during boot */
27 static char dmi_ids_string
[128] __initdata
;
29 static struct dmi_memdev_info
{
34 static int dmi_memdev_nr
;
36 static const char * __init
dmi_string_nosave(const struct dmi_header
*dm
, u8 s
)
38 const u8
*bp
= ((u8
*) dm
) + dm
->length
;
42 while (s
> 0 && *bp
) {
48 size_t len
= strlen(bp
)+1;
49 size_t cmp_len
= len
> 8 ? 8 : len
;
51 if (!memcmp(bp
, dmi_empty_string
, cmp_len
))
52 return dmi_empty_string
;
60 static const char * __init
dmi_string(const struct dmi_header
*dm
, u8 s
)
62 const char *bp
= dmi_string_nosave(dm
, s
);
66 if (bp
== dmi_empty_string
)
67 return dmi_empty_string
;
78 * We have to be cautious here. We have seen BIOSes with DMI pointers
79 * pointing to completely the wrong place for example
81 static void dmi_table(u8
*buf
, u32 len
, int num
,
82 void (*decode
)(const struct dmi_header
*, void *),
89 * Stop when we have seen all the items the table claimed to have
90 * (SMBIOS < 3.0 only) OR we reach an end-of-table marker OR we run
91 * off the end of the table (should never happen but sometimes does
92 * on bogus implementations.)
94 while ((!num
|| i
< num
) &&
95 (data
- buf
+ sizeof(struct dmi_header
)) <= len
) {
96 const struct dmi_header
*dm
= (const struct dmi_header
*)data
;
99 * We want to know the total length (formatted area and
100 * strings) before decoding to make sure we won't run off the
101 * table in dmi_decode or dmi_string
104 while ((data
- buf
< len
- 1) && (data
[0] || data
[1]))
106 if (data
- buf
< len
- 1)
107 decode(dm
, private_data
);
110 * 7.45 End-of-Table (Type 127) [SMBIOS reference spec v3.0.0]
112 if (dm
->type
== DMI_ENTRY_END_OF_TABLE
)
120 static phys_addr_t dmi_base
;
124 static int __init
dmi_walk_early(void (*decode
)(const struct dmi_header
*,
129 buf
= dmi_early_remap(dmi_base
, dmi_len
);
133 dmi_table(buf
, dmi_len
, dmi_num
, decode
, NULL
);
135 add_device_randomness(buf
, dmi_len
);
137 dmi_early_unmap(buf
, dmi_len
);
141 static int __init
dmi_checksum(const u8
*buf
, u8 len
)
146 for (a
= 0; a
< len
; a
++)
152 static const char *dmi_ident
[DMI_STRING_MAX
];
153 static LIST_HEAD(dmi_devices
);
159 static void __init
dmi_save_ident(const struct dmi_header
*dm
, int slot
,
162 const char *d
= (const char *) dm
;
168 p
= dmi_string(dm
, d
[string
]);
175 static void __init
dmi_save_uuid(const struct dmi_header
*dm
, int slot
,
178 const u8
*d
= (u8
*) dm
+ index
;
180 int is_ff
= 1, is_00
= 1, i
;
185 for (i
= 0; i
< 16 && (is_ff
|| is_00
); i
++) {
195 s
= dmi_alloc(16*2+4+1);
200 * As of version 2.6 of the SMBIOS specification, the first 3 fields of
201 * the UUID are supposed to be little-endian encoded. The specification
202 * says that this is the defacto standard.
204 if (dmi_ver
>= 0x0206)
205 sprintf(s
, "%pUL", d
);
207 sprintf(s
, "%pUB", d
);
212 static void __init
dmi_save_type(const struct dmi_header
*dm
, int slot
,
215 const u8
*d
= (u8
*) dm
+ index
;
225 sprintf(s
, "%u", *d
& 0x7F);
229 static void __init
dmi_save_one_device(int type
, const char *name
)
231 struct dmi_device
*dev
;
233 /* No duplicate device */
234 if (dmi_find_device(type
, name
, NULL
))
237 dev
= dmi_alloc(sizeof(*dev
) + strlen(name
) + 1);
242 strcpy((char *)(dev
+ 1), name
);
243 dev
->name
= (char *)(dev
+ 1);
244 dev
->device_data
= NULL
;
245 list_add(&dev
->list
, &dmi_devices
);
248 static void __init
dmi_save_devices(const struct dmi_header
*dm
)
250 int i
, count
= (dm
->length
- sizeof(struct dmi_header
)) / 2;
252 for (i
= 0; i
< count
; i
++) {
253 const char *d
= (char *)(dm
+ 1) + (i
* 2);
255 /* Skip disabled device */
256 if ((*d
& 0x80) == 0)
259 dmi_save_one_device(*d
& 0x7f, dmi_string_nosave(dm
, *(d
+ 1)));
263 static void __init
dmi_save_oem_strings_devices(const struct dmi_header
*dm
)
265 int i
, count
= *(u8
*)(dm
+ 1);
266 struct dmi_device
*dev
;
268 for (i
= 1; i
<= count
; i
++) {
269 const char *devname
= dmi_string(dm
, i
);
271 if (devname
== dmi_empty_string
)
274 dev
= dmi_alloc(sizeof(*dev
));
278 dev
->type
= DMI_DEV_TYPE_OEM_STRING
;
280 dev
->device_data
= NULL
;
282 list_add(&dev
->list
, &dmi_devices
);
286 static void __init
dmi_save_ipmi_device(const struct dmi_header
*dm
)
288 struct dmi_device
*dev
;
291 data
= dmi_alloc(dm
->length
);
295 memcpy(data
, dm
, dm
->length
);
297 dev
= dmi_alloc(sizeof(*dev
));
301 dev
->type
= DMI_DEV_TYPE_IPMI
;
302 dev
->name
= "IPMI controller";
303 dev
->device_data
= data
;
305 list_add_tail(&dev
->list
, &dmi_devices
);
308 static void __init
dmi_save_dev_onboard(int instance
, int segment
, int bus
,
309 int devfn
, const char *name
)
311 struct dmi_dev_onboard
*onboard_dev
;
313 onboard_dev
= dmi_alloc(sizeof(*onboard_dev
) + strlen(name
) + 1);
317 onboard_dev
->instance
= instance
;
318 onboard_dev
->segment
= segment
;
319 onboard_dev
->bus
= bus
;
320 onboard_dev
->devfn
= devfn
;
322 strcpy((char *)&onboard_dev
[1], name
);
323 onboard_dev
->dev
.type
= DMI_DEV_TYPE_DEV_ONBOARD
;
324 onboard_dev
->dev
.name
= (char *)&onboard_dev
[1];
325 onboard_dev
->dev
.device_data
= onboard_dev
;
327 list_add(&onboard_dev
->dev
.list
, &dmi_devices
);
330 static void __init
dmi_save_extended_devices(const struct dmi_header
*dm
)
332 const u8
*d
= (u8
*) dm
+ 5;
334 /* Skip disabled device */
335 if ((*d
& 0x80) == 0)
338 dmi_save_dev_onboard(*(d
+1), *(u16
*)(d
+2), *(d
+4), *(d
+5),
339 dmi_string_nosave(dm
, *(d
-1)));
340 dmi_save_one_device(*d
& 0x7f, dmi_string_nosave(dm
, *(d
- 1)));
343 static void __init
count_mem_devices(const struct dmi_header
*dm
, void *v
)
345 if (dm
->type
!= DMI_ENTRY_MEM_DEVICE
)
350 static void __init
save_mem_devices(const struct dmi_header
*dm
, void *v
)
352 const char *d
= (const char *)dm
;
355 if (dm
->type
!= DMI_ENTRY_MEM_DEVICE
)
357 if (nr
>= dmi_memdev_nr
) {
358 pr_warn(FW_BUG
"Too many DIMM entries in SMBIOS table\n");
361 dmi_memdev
[nr
].handle
= get_unaligned(&dm
->handle
);
362 dmi_memdev
[nr
].device
= dmi_string(dm
, d
[0x10]);
363 dmi_memdev
[nr
].bank
= dmi_string(dm
, d
[0x11]);
367 void __init
dmi_memdev_walk(void)
372 if (dmi_walk_early(count_mem_devices
) == 0 && dmi_memdev_nr
) {
373 dmi_memdev
= dmi_alloc(sizeof(*dmi_memdev
) * dmi_memdev_nr
);
375 dmi_walk_early(save_mem_devices
);
380 * Process a DMI table entry. Right now all we care about are the BIOS
381 * and machine entries. For 2.5 we should pull the smbus controller info
384 static void __init
dmi_decode(const struct dmi_header
*dm
, void *dummy
)
387 case 0: /* BIOS Information */
388 dmi_save_ident(dm
, DMI_BIOS_VENDOR
, 4);
389 dmi_save_ident(dm
, DMI_BIOS_VERSION
, 5);
390 dmi_save_ident(dm
, DMI_BIOS_DATE
, 8);
392 case 1: /* System Information */
393 dmi_save_ident(dm
, DMI_SYS_VENDOR
, 4);
394 dmi_save_ident(dm
, DMI_PRODUCT_NAME
, 5);
395 dmi_save_ident(dm
, DMI_PRODUCT_VERSION
, 6);
396 dmi_save_ident(dm
, DMI_PRODUCT_SERIAL
, 7);
397 dmi_save_uuid(dm
, DMI_PRODUCT_UUID
, 8);
399 case 2: /* Base Board Information */
400 dmi_save_ident(dm
, DMI_BOARD_VENDOR
, 4);
401 dmi_save_ident(dm
, DMI_BOARD_NAME
, 5);
402 dmi_save_ident(dm
, DMI_BOARD_VERSION
, 6);
403 dmi_save_ident(dm
, DMI_BOARD_SERIAL
, 7);
404 dmi_save_ident(dm
, DMI_BOARD_ASSET_TAG
, 8);
406 case 3: /* Chassis Information */
407 dmi_save_ident(dm
, DMI_CHASSIS_VENDOR
, 4);
408 dmi_save_type(dm
, DMI_CHASSIS_TYPE
, 5);
409 dmi_save_ident(dm
, DMI_CHASSIS_VERSION
, 6);
410 dmi_save_ident(dm
, DMI_CHASSIS_SERIAL
, 7);
411 dmi_save_ident(dm
, DMI_CHASSIS_ASSET_TAG
, 8);
413 case 10: /* Onboard Devices Information */
414 dmi_save_devices(dm
);
416 case 11: /* OEM Strings */
417 dmi_save_oem_strings_devices(dm
);
419 case 38: /* IPMI Device Information */
420 dmi_save_ipmi_device(dm
);
422 case 41: /* Onboard Devices Extended Information */
423 dmi_save_extended_devices(dm
);
427 static int __init
print_filtered(char *buf
, size_t len
, const char *info
)
435 for (p
= info
; *p
; p
++)
437 c
+= scnprintf(buf
+ c
, len
- c
, "%c", *p
);
439 c
+= scnprintf(buf
+ c
, len
- c
, "\\x%02x", *p
& 0xff);
443 static void __init
dmi_format_ids(char *buf
, size_t len
)
446 const char *board
; /* Board Name is optional */
448 c
+= print_filtered(buf
+ c
, len
- c
,
449 dmi_get_system_info(DMI_SYS_VENDOR
));
450 c
+= scnprintf(buf
+ c
, len
- c
, " ");
451 c
+= print_filtered(buf
+ c
, len
- c
,
452 dmi_get_system_info(DMI_PRODUCT_NAME
));
454 board
= dmi_get_system_info(DMI_BOARD_NAME
);
456 c
+= scnprintf(buf
+ c
, len
- c
, "/");
457 c
+= print_filtered(buf
+ c
, len
- c
, board
);
459 c
+= scnprintf(buf
+ c
, len
- c
, ", BIOS ");
460 c
+= print_filtered(buf
+ c
, len
- c
,
461 dmi_get_system_info(DMI_BIOS_VERSION
));
462 c
+= scnprintf(buf
+ c
, len
- c
, " ");
463 c
+= print_filtered(buf
+ c
, len
- c
,
464 dmi_get_system_info(DMI_BIOS_DATE
));
468 * Check for DMI/SMBIOS headers in the system firmware image. Any
469 * SMBIOS header must start 16 bytes before the DMI header, so take a
470 * 32 byte buffer and check for DMI at offset 16 and SMBIOS at offset
471 * 0. If the DMI header is present, set dmi_ver accordingly (SMBIOS
472 * takes precedence) and return 0. Otherwise return 1.
474 static int __init
dmi_present(const u8
*buf
)
478 if (memcmp(buf
, "_SM_", 4) == 0 &&
479 buf
[5] < 32 && dmi_checksum(buf
, buf
[5])) {
480 smbios_ver
= get_unaligned_be16(buf
+ 6);
482 /* Some BIOS report weird SMBIOS version, fix that up */
483 switch (smbios_ver
) {
486 pr_debug("SMBIOS version fixup(2.%d->2.%d)\n",
487 smbios_ver
& 0xFF, 3);
491 pr_debug("SMBIOS version fixup(2.%d->2.%d)\n", 51, 6);
501 if (memcmp(buf
, "_DMI_", 5) == 0 && dmi_checksum(buf
, 15)) {
502 dmi_num
= get_unaligned_le16(buf
+ 12);
503 dmi_len
= get_unaligned_le16(buf
+ 6);
504 dmi_base
= get_unaligned_le32(buf
+ 8);
506 if (dmi_walk_early(dmi_decode
) == 0) {
508 dmi_ver
= smbios_ver
;
509 pr_info("SMBIOS %d.%d present.\n",
510 dmi_ver
>> 8, dmi_ver
& 0xFF);
512 dmi_ver
= (buf
[14] & 0xF0) << 4 |
514 pr_info("Legacy DMI %d.%d present.\n",
515 dmi_ver
>> 8, dmi_ver
& 0xFF);
517 dmi_format_ids(dmi_ids_string
, sizeof(dmi_ids_string
));
518 printk(KERN_DEBUG
"DMI: %s\n", dmi_ids_string
);
527 * Check for the SMBIOS 3.0 64-bit entry point signature. Unlike the legacy
528 * 32-bit entry point, there is no embedded DMI header (_DMI_) in here.
530 static int __init
dmi_smbios3_present(const u8
*buf
)
532 if (memcmp(buf
, "_SM3_", 5) == 0 &&
533 buf
[6] < 32 && dmi_checksum(buf
, buf
[6])) {
534 dmi_ver
= get_unaligned_be16(buf
+ 7);
535 dmi_num
= 0; /* No longer specified */
536 dmi_len
= get_unaligned_le32(buf
+ 12);
537 dmi_base
= get_unaligned_le64(buf
+ 16);
539 if (dmi_walk_early(dmi_decode
) == 0) {
540 pr_info("SMBIOS %d.%d present.\n",
541 dmi_ver
>> 8, dmi_ver
& 0xFF);
542 dmi_format_ids(dmi_ids_string
, sizeof(dmi_ids_string
));
543 pr_debug("DMI: %s\n", dmi_ids_string
);
550 void __init
dmi_scan_machine(void)
555 if (efi_enabled(EFI_CONFIG_TABLES
)) {
557 * According to the DMTF SMBIOS reference spec v3.0.0, it is
558 * allowed to define both the 64-bit entry point (smbios3) and
559 * the 32-bit entry point (smbios), in which case they should
560 * either both point to the same SMBIOS structure table, or the
561 * table pointed to by the 64-bit entry point should contain a
562 * superset of the table contents pointed to by the 32-bit entry
563 * point (section 5.2)
564 * This implies that the 64-bit entry point should have
565 * precedence if it is defined and supported by the OS. If we
566 * have the 64-bit entry point, but fail to decode it, fall
567 * back to the legacy one (if available)
569 if (efi
.smbios3
!= EFI_INVALID_TABLE_ADDR
) {
570 p
= dmi_early_remap(efi
.smbios3
, 32);
573 memcpy_fromio(buf
, p
, 32);
574 dmi_early_unmap(p
, 32);
576 if (!dmi_smbios3_present(buf
)) {
581 if (efi
.smbios
== EFI_INVALID_TABLE_ADDR
)
584 /* This is called as a core_initcall() because it isn't
585 * needed during early boot. This also means we can
586 * iounmap the space when we're done with it.
588 p
= dmi_early_remap(efi
.smbios
, 32);
591 memcpy_fromio(buf
, p
, 32);
592 dmi_early_unmap(p
, 32);
594 if (!dmi_present(buf
)) {
598 } else if (IS_ENABLED(CONFIG_DMI_SCAN_MACHINE_NON_EFI_FALLBACK
)) {
599 p
= dmi_early_remap(0xF0000, 0x10000);
604 * Iterate over all possible DMI header addresses q.
605 * Maintain the 32 bytes around q in buf. On the
606 * first iteration, substitute zero for the
607 * out-of-range bytes so there is no chance of falsely
608 * detecting an SMBIOS header.
611 for (q
= p
; q
< p
+ 0x10000; q
+= 16) {
612 memcpy_fromio(buf
+ 16, q
, 16);
613 if (!dmi_smbios3_present(buf
) || !dmi_present(buf
)) {
615 dmi_early_unmap(p
, 0x10000);
618 memcpy(buf
, buf
+ 16, 16);
620 dmi_early_unmap(p
, 0x10000);
623 pr_info("DMI not present or invalid.\n");
629 * dmi_set_dump_stack_arch_desc - set arch description for dump_stack()
631 * Invoke dump_stack_set_arch_desc() with DMI system information so that
632 * DMI identifiers are printed out on task dumps. Arch boot code should
633 * call this function after dmi_scan_machine() if it wants to print out DMI
634 * identifiers on task dumps.
636 void __init
dmi_set_dump_stack_arch_desc(void)
638 dump_stack_set_arch_desc("%s", dmi_ids_string
);
642 * dmi_matches - check if dmi_system_id structure matches system DMI data
643 * @dmi: pointer to the dmi_system_id structure to check
645 static bool dmi_matches(const struct dmi_system_id
*dmi
)
649 WARN(!dmi_initialized
, KERN_ERR
"dmi check: not initialized yet.\n");
651 for (i
= 0; i
< ARRAY_SIZE(dmi
->matches
); i
++) {
652 int s
= dmi
->matches
[i
].slot
;
656 if (!dmi
->matches
[i
].exact_match
&&
657 strstr(dmi_ident
[s
], dmi
->matches
[i
].substr
))
659 else if (dmi
->matches
[i
].exact_match
&&
660 !strcmp(dmi_ident
[s
], dmi
->matches
[i
].substr
))
671 * dmi_is_end_of_table - check for end-of-table marker
672 * @dmi: pointer to the dmi_system_id structure to check
674 static bool dmi_is_end_of_table(const struct dmi_system_id
*dmi
)
676 return dmi
->matches
[0].slot
== DMI_NONE
;
680 * dmi_check_system - check system DMI data
681 * @list: array of dmi_system_id structures to match against
682 * All non-null elements of the list must match
683 * their slot's (field index's) data (i.e., each
684 * list string must be a substring of the specified
685 * DMI slot's string data) to be considered a
688 * Walk the blacklist table running matching functions until someone
689 * returns non zero or we hit the end. Callback function is called for
690 * each successful match. Returns the number of matches.
692 int dmi_check_system(const struct dmi_system_id
*list
)
695 const struct dmi_system_id
*d
;
697 for (d
= list
; !dmi_is_end_of_table(d
); d
++)
698 if (dmi_matches(d
)) {
700 if (d
->callback
&& d
->callback(d
))
706 EXPORT_SYMBOL(dmi_check_system
);
709 * dmi_first_match - find dmi_system_id structure matching system DMI data
710 * @list: array of dmi_system_id structures to match against
711 * All non-null elements of the list must match
712 * their slot's (field index's) data (i.e., each
713 * list string must be a substring of the specified
714 * DMI slot's string data) to be considered a
717 * Walk the blacklist table until the first match is found. Return the
718 * pointer to the matching entry or NULL if there's no match.
720 const struct dmi_system_id
*dmi_first_match(const struct dmi_system_id
*list
)
722 const struct dmi_system_id
*d
;
724 for (d
= list
; !dmi_is_end_of_table(d
); d
++)
730 EXPORT_SYMBOL(dmi_first_match
);
733 * dmi_get_system_info - return DMI data value
734 * @field: data index (see enum dmi_field)
736 * Returns one DMI data value, can be used to perform
737 * complex DMI data checks.
739 const char *dmi_get_system_info(int field
)
741 return dmi_ident
[field
];
743 EXPORT_SYMBOL(dmi_get_system_info
);
746 * dmi_name_in_serial - Check if string is in the DMI product serial information
747 * @str: string to check for
749 int dmi_name_in_serial(const char *str
)
751 int f
= DMI_PRODUCT_SERIAL
;
752 if (dmi_ident
[f
] && strstr(dmi_ident
[f
], str
))
758 * dmi_name_in_vendors - Check if string is in the DMI system or board vendor name
759 * @str: Case sensitive Name
761 int dmi_name_in_vendors(const char *str
)
763 static int fields
[] = { DMI_SYS_VENDOR
, DMI_BOARD_VENDOR
, DMI_NONE
};
765 for (i
= 0; fields
[i
] != DMI_NONE
; i
++) {
767 if (dmi_ident
[f
] && strstr(dmi_ident
[f
], str
))
772 EXPORT_SYMBOL(dmi_name_in_vendors
);
775 * dmi_find_device - find onboard device by type/name
776 * @type: device type or %DMI_DEV_TYPE_ANY to match all device types
777 * @name: device name string or %NULL to match all
778 * @from: previous device found in search, or %NULL for new search.
780 * Iterates through the list of known onboard devices. If a device is
781 * found with a matching @vendor and @device, a pointer to its device
782 * structure is returned. Otherwise, %NULL is returned.
783 * A new search is initiated by passing %NULL as the @from argument.
784 * If @from is not %NULL, searches continue from next device.
786 const struct dmi_device
*dmi_find_device(int type
, const char *name
,
787 const struct dmi_device
*from
)
789 const struct list_head
*head
= from
? &from
->list
: &dmi_devices
;
792 for (d
= head
->next
; d
!= &dmi_devices
; d
= d
->next
) {
793 const struct dmi_device
*dev
=
794 list_entry(d
, struct dmi_device
, list
);
796 if (((type
== DMI_DEV_TYPE_ANY
) || (dev
->type
== type
)) &&
797 ((name
== NULL
) || (strcmp(dev
->name
, name
) == 0)))
803 EXPORT_SYMBOL(dmi_find_device
);
806 * dmi_get_date - parse a DMI date
807 * @field: data index (see enum dmi_field)
808 * @yearp: optional out parameter for the year
809 * @monthp: optional out parameter for the month
810 * @dayp: optional out parameter for the day
812 * The date field is assumed to be in the form resembling
813 * [mm[/dd]]/yy[yy] and the result is stored in the out
814 * parameters any or all of which can be omitted.
816 * If the field doesn't exist, all out parameters are set to zero
817 * and false is returned. Otherwise, true is returned with any
818 * invalid part of date set to zero.
820 * On return, year, month and day are guaranteed to be in the
821 * range of [0,9999], [0,12] and [0,31] respectively.
823 bool dmi_get_date(int field
, int *yearp
, int *monthp
, int *dayp
)
825 int year
= 0, month
= 0, day
= 0;
830 s
= dmi_get_system_info(field
);
836 * Determine year first. We assume the date string resembles
837 * mm/dd/yy[yy] but the original code extracted only the year
838 * from the end. Keep the behavior in the spirit of no
846 year
= simple_strtoul(y
, &e
, 10);
847 if (y
!= e
&& year
< 100) { /* 2-digit year */
849 if (year
< 1996) /* no dates < spec 1.0 */
852 if (year
> 9999) /* year should fit in %04d */
855 /* parse the mm and dd */
856 month
= simple_strtoul(s
, &e
, 10);
857 if (s
== e
|| *e
!= '/' || !month
|| month
> 12) {
863 day
= simple_strtoul(s
, &e
, 10);
864 if (s
== y
|| s
== e
|| *e
!= '/' || day
> 31)
875 EXPORT_SYMBOL(dmi_get_date
);
878 * dmi_walk - Walk the DMI table and get called back for every record
879 * @decode: Callback function
880 * @private_data: Private data to be passed to the callback function
882 * Returns -1 when the DMI table can't be reached, 0 on success.
884 int dmi_walk(void (*decode
)(const struct dmi_header
*, void *),
892 buf
= dmi_remap(dmi_base
, dmi_len
);
896 dmi_table(buf
, dmi_len
, dmi_num
, decode
, private_data
);
901 EXPORT_SYMBOL_GPL(dmi_walk
);
904 * dmi_match - compare a string to the dmi field (if exists)
905 * @f: DMI field identifier
906 * @str: string to compare the DMI field to
908 * Returns true if the requested field equals to the str (including NULL).
910 bool dmi_match(enum dmi_field f
, const char *str
)
912 const char *info
= dmi_get_system_info(f
);
914 if (info
== NULL
|| str
== NULL
)
917 return !strcmp(info
, str
);
919 EXPORT_SYMBOL_GPL(dmi_match
);
921 void dmi_memdev_name(u16 handle
, const char **bank
, const char **device
)
925 if (dmi_memdev
== NULL
)
928 for (n
= 0; n
< dmi_memdev_nr
; n
++) {
929 if (handle
== dmi_memdev
[n
].handle
) {
930 *bank
= dmi_memdev
[n
].bank
;
931 *device
= dmi_memdev
[n
].device
;
936 EXPORT_SYMBOL_GPL(dmi_memdev_name
);