Date: Tue, 22 Oct 2013 21:32:29 +0000 (UTC) From: Jung-uk Kim <jkim@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r256940 - head/sys/boot/i386/libi386 Message-ID: <201310222132.r9MLWTGo059142@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: jkim Date: Tue Oct 22 21:32:28 2013 New Revision: 256940 URL: http://svnweb.freebsd.org/changeset/base/256940 Log: Allow users to set UUID in network byte order regardless of SMBIOS version. Define BOOT_NETWORK_ENDIAN_UUID in make.conf(5) to enable this feature. Modified: head/sys/boot/i386/libi386/Makefile head/sys/boot/i386/libi386/smbios.c Modified: head/sys/boot/i386/libi386/Makefile ============================================================================== --- head/sys/boot/i386/libi386/Makefile Tue Oct 22 21:27:22 2013 (r256939) +++ head/sys/boot/i386/libi386/Makefile Tue Oct 22 21:32:28 2013 (r256940) @@ -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 Modified: head/sys/boot/i386/libi386/smbios.c ============================================================================== --- head/sys/boot/i386/libi386/smbios.c Tue Oct 22 21:27:22 2013 (r256939) +++ head/sys/boot/i386/libi386/smbios.c Tue Oct 22 21:32:28 2013 (r256940) @@ -122,7 +122,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; @@ -152,14 +152,18 @@ smbios_setuuid(const char *name, const c * 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));
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201310222132.r9MLWTGo059142>