The branch main has been updated by olce:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=d1f351fcb22f46805ff0a0cecf6ce787f84d31d5

commit d1f351fcb22f46805ff0a0cecf6ce787f84d31d5
Author:     Olivier Certner <o...@freebsd.org>
AuthorDate: 2025-03-03 14:30:16 +0000
Commit:     Olivier Certner <o...@freebsd.org>
CommitDate: 2025-03-11 13:54:08 +0000

    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
---
 stand/libsa/smbios.c | 25 ++++++++++++++++---------
 1 file changed, 16 insertions(+), 9 deletions(-)

diff --git a/stand/libsa/smbios.c b/stand/libsa/smbios.c
index c864dc9cdc5b..e726dfeb7af3 100644
--- a/stand/libsa/smbios.c
+++ b/stand/libsa/smbios.c
@@ -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);
        }

Reply via email to