summaryrefslogtreecommitdiff
path: root/lib/smbios-parser.c
diff options
context:
space:
mode:
authorTom Rini <trini@konsulko.com>2024-01-09 12:50:04 -0500
committerTom Rini <trini@konsulko.com>2024-01-09 12:50:04 -0500
commit344667db6450de838bd83f0f57e177e6d4744d89 (patch)
treeddaf47cefe8467400e4b8eca348265996d61160f /lib/smbios-parser.c
parent0727b10f6bf28b551b1127ea0fb1008abc130bf0 (diff)
parent8aec7031112eba0dbfc8f23f9be11c081ea5cc56 (diff)
Merge tag 'smbios-2024-04-rc1' of https://source.denx.de/u-boot/custodians/u-boot-efi
Pull request smbios-2024-04-rc1 * make table_compute_checksum() arguments const * remove duplicate function verify_checksum() * enable setting processor family > 0xff * set correct SMBIOS processor family value for RISC-V * avoid importing ofnode.h in smbios.h * provide a UEFI tool to dump SMBIOS table
Diffstat (limited to 'lib/smbios-parser.c')
-rw-r--r--lib/smbios-parser.c21
1 files changed, 5 insertions, 16 deletions
diff --git a/lib/smbios-parser.c b/lib/smbios-parser.c
index b578c308408..e1180efae18 100644
--- a/lib/smbios-parser.c
+++ b/lib/smbios-parser.c
@@ -5,22 +5,11 @@
#define LOG_CATEGORY LOGC_BOOT
+#include <errno.h>
#include <smbios.h>
-
-static inline int verify_checksum(const struct smbios_entry *e)
-{
- /*
- * Checksums for SMBIOS tables are calculated to have a value, so that
- * the sum over all bytes yields zero (using unsigned 8 bit arithmetic).
- */
- u8 *byte = (u8 *)e;
- u8 sum = 0;
-
- for (int i = 0; i < e->length; i++)
- sum += byte[i];
-
- return sum;
-}
+#include <string.h>
+#include <tables_csum.h>
+#include <linux/kernel.h>
const struct smbios_entry *smbios_entry(u64 address, u32 size)
{
@@ -32,7 +21,7 @@ const struct smbios_entry *smbios_entry(u64 address, u32 size)
if (memcmp(entry->anchor, "_SM_", 4))
return NULL;
- if (verify_checksum(entry))
+ if (table_compute_checksum(entry, entry->length))
return NULL;
return entry;