libsa: smbios: probe: BCD revision parsing is v2-only code; Expand comments

The code parsing the BCD revision is only meaningful on v2, so move it
away into the appropriate 'if' branch to ease reading (and to avoid
a useless test).

Expand comments.  In particular, make it clear that setting
'smbios.count' to '-1' removes the limit of the number of structures to
parse.

No functional change.

Reviewed by:    imp, markj
MFC after:      2 weeks
Sponsored by:   The FreeBSD Foundation
Differential Revision:  https://reviews.freebsd.org/D49284
This commit is contained in:
Olivier Certner 2025-03-03 15:30:16 +01:00
parent 3b2303ba3d
commit d1f351fcb2
No known key found for this signature in database
GPG key ID: 8CA13040971E2627

View file

@ -567,9 +567,12 @@ smbios_probe(const caddr_t addr)
smbios.length = SMBIOS_GET32(saddr, 0x0c);
/* Structure Table Address */
paddr = SMBIOS_GET64(saddr, 0x10);
/* not present in V3 */
/* Not present in V3, set it to the maximum value (no limit). */
smbios.count = -1;
/* not present in V3 */
/*
* No BCD revision in V3, we'll determine the version thanks to
* the major and minor fields below.
*/
smbios.ver = 0;
maj_off = 0x07;
min_off = 0x08;
@ -580,22 +583,26 @@ smbios_probe(const caddr_t addr)
smbios.length = SMBIOS_GET16(saddr, 0x16);
/* Structure Table Address */
paddr = SMBIOS_GET32(saddr, 0x18);
/* No of SMBIOS Structures */
/* No. of SMBIOS Structures */
smbios.count = SMBIOS_GET16(saddr, 0x1c);
/* SMBIOS BCD Revision */
smbios.ver = SMBIOS_GET8(saddr, 0x1e);
if (smbios.ver != 0) {
smbios.major = smbios.ver >> 4;
smbios.minor = smbios.ver & 0x0f;
if (smbios.major > 9 || smbios.minor > 9)
smbios.ver = 0;
}
maj_off = 0x06;
min_off = 0x07;
}
if (smbios.ver != 0) {
smbios.major = smbios.ver >> 4;
smbios.minor = smbios.ver & 0x0f;
if (smbios.major > 9 || smbios.minor > 9)
smbios.ver = 0;
}
if (smbios.ver == 0) {
/*
* v3 table, or v2 with BCD revision being 0 or bad. Use the
* major and minor version fields.
*/
smbios.major = SMBIOS_GET8(saddr, maj_off);
smbios.minor = SMBIOS_GET8(saddr, min_off);
}