diff options
| author | Greg V <greg@unrelenting.technology> | 2021-04-07 20:05:49 +0000 |
|---|---|---|
| committer | Eric van Gyzen <vangyzen@FreeBSD.org> | 2021-04-07 20:05:49 +0000 |
| commit | f689cb23b2782d0d0f586bcfabbad68f728ed1df (patch) | |
| tree | 26fc8e87abb0405b056163c7937b9f20640ab46f /sys/dev/smbios | |
| parent | a29bff7a5216bd5f4a76228788e7eacf235004de (diff) | |
Diffstat (limited to 'sys/dev/smbios')
| -rw-r--r-- | sys/dev/smbios/smbios.h | 31 |
1 files changed, 29 insertions, 2 deletions
diff --git a/sys/dev/smbios/smbios.h b/sys/dev/smbios/smbios.h index 6503cdb73c4c..ec216b676f2b 100644 --- a/sys/dev/smbios/smbios.h +++ b/sys/dev/smbios/smbios.h @@ -56,12 +56,39 @@ struct smbios_eps { uint32_t structure_table_address; uint16_t number_structures; uint8_t BCD_revision; -}; +} __packed; struct smbios_structure_header { uint8_t type; uint8_t length; uint16_t handle; -}; +} __packed; + +typedef void (*smbios_callback_t)(struct smbios_structure_header *, void *); + +static inline void +smbios_walk_table(uint8_t *p, int entries, smbios_callback_t cb, void *arg) +{ + struct smbios_structure_header *s; + + while (entries--) { + s = (struct smbios_structure_header *)p; + cb(s, arg); + + /* + * Look for a double-nul after the end of the + * formatted area of this structure. + */ + p += s->length; + while (!(p[0] == 0 && p[1] == 0)) + p++; + + /* + * Skip over the double-nul to the start of the next + * structure. + */ + p += 2; + } +} #endif /* _SMBIOS_H_ */ |
