diff options
author | jkim <jkim@FreeBSD.org> | 2016-01-26 21:35:47 +0000 |
---|---|---|
committer | jkim <jkim@FreeBSD.org> | 2016-01-26 21:35:47 +0000 |
commit | 51e2357571c20f7f9e80efd0e460335bc0b546c6 (patch) | |
tree | 1b85bfa6130925995cc7d8be93a0d78e0ce07501 | |
parent | e79a670f63cdd0be4167db6c94d316d0ceccba5d (diff) | |
download | FreeBSD-src-51e2357571c20f7f9e80efd0e460335bc0b546c6.zip FreeBSD-src-51e2357571c20f7f9e80efd0e460335bc0b546c6.tar.gz |
MFC: r256940
Allow users to set UUID in network byte order regardless of SMBIOS version.
-rw-r--r-- | sys/boot/i386/libi386/Makefile | 3 | ||||
-rw-r--r-- | sys/boot/i386/libi386/smbios.c | 16 |
2 files changed, 13 insertions, 6 deletions
diff --git a/sys/boot/i386/libi386/Makefile b/sys/boot/i386/libi386/Makefile index d4fea80..0f360e9 100644 --- a/sys/boot/i386/libi386/Makefile +++ b/sys/boot/i386/libi386/Makefile @@ -36,6 +36,9 @@ CFLAGS+= -DSMBIOS_SERIAL_NUMBERS .if defined(BOOT_LITTLE_ENDIAN_UUID) # Use little-endian UUID format as defined in SMBIOS 2.6. CFLAGS+= -DSMBIOS_LITTLE_ENDIAN_UUID +.elif defined(BOOT_NETWORK_ENDIAN_UUID) +# Use network-endian UUID format for backward compatibility. +CFLAGS+= -DSMBIOS_NETWORK_ENDIAN_UUID .endif .endif diff --git a/sys/boot/i386/libi386/smbios.c b/sys/boot/i386/libi386/smbios.c index 8e6c790..6e4fb84 100644 --- a/sys/boot/i386/libi386/smbios.c +++ b/sys/boot/i386/libi386/smbios.c @@ -152,7 +152,7 @@ static void smbios_setuuid(const char *name, const caddr_t addr, const int ver) { char uuid[37]; - int i, ones, zeros; + int byteorder, i, ones, zeros; UUID_TYPE n; uint32_t f1; uint16_t f2, f3; @@ -182,14 +182,18 @@ smbios_setuuid(const char *name, const caddr_t addr, const int ver) * Note: We use network byte order for backward compatibility * unless SMBIOS version is 2.6+ or little-endian is forced. */ -#ifndef SMBIOS_LITTLE_ENDIAN_UUID - if (ver < 0x0206) { +#if defined(SMBIOS_LITTLE_ENDIAN_UUID) + byteorder = LITTLE_ENDIAN; +#elif defined(SMBIOS_NETWORK_ENDIAN_UUID) + byteorder = BIG_ENDIAN; +#else + byteorder = ver < 0x0206 ? BIG_ENDIAN : LITTLE_ENDIAN; +#endif + if (byteorder != LITTLE_ENDIAN) { f1 = ntohl(SMBIOS_GET32(addr, 0)); f2 = ntohs(SMBIOS_GET16(addr, 4)); f3 = ntohs(SMBIOS_GET16(addr, 6)); - } else -#endif - { + } else { f1 = le32toh(SMBIOS_GET32(addr, 0)); f2 = le16toh(SMBIOS_GET16(addr, 4)); f3 = le16toh(SMBIOS_GET16(addr, 6)); |