From owner-svn-src-all@freebsd.org Tue Jan 26 21:35:48 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 98FEDA6FC83; Tue, 26 Jan 2016 21:35:48 +0000 (UTC) (envelope-from jkim@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 502BC175A; Tue, 26 Jan 2016 21:35:48 +0000 (UTC) (envelope-from jkim@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u0QLZl2i075102; Tue, 26 Jan 2016 21:35:47 GMT (envelope-from jkim@FreeBSD.org) Received: (from jkim@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u0QLZlDn075100; Tue, 26 Jan 2016 21:35:47 GMT (envelope-from jkim@FreeBSD.org) Message-Id: <201601262135.u0QLZlDn075100@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: jkim set sender to jkim@FreeBSD.org using -f From: Jung-uk Kim Date: Tue, 26 Jan 2016 21:35:47 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r294852 - in stable: 10/sys/boot/i386/libi386 9/sys/boot/i386/libi386 X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 26 Jan 2016 21:35:48 -0000 Author: jkim Date: Tue Jan 26 21:35:47 2016 New Revision: 294852 URL: https://svnweb.freebsd.org/changeset/base/294852 Log: MFC: r256940 Allow users to set UUID in network byte order regardless of SMBIOS version. Modified: stable/10/sys/boot/i386/libi386/Makefile stable/10/sys/boot/i386/libi386/smbios.c Directory Properties: stable/10/ (props changed) Changes in other areas also in this revision: Modified: stable/9/sys/boot/i386/libi386/Makefile stable/9/sys/boot/i386/libi386/smbios.c Directory Properties: stable/9/sys/ (props changed) stable/9/sys/boot/ (props changed) Modified: stable/10/sys/boot/i386/libi386/Makefile ============================================================================== --- stable/10/sys/boot/i386/libi386/Makefile Tue Jan 26 21:24:49 2016 (r294851) +++ stable/10/sys/boot/i386/libi386/Makefile Tue Jan 26 21:35:47 2016 (r294852) @@ -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: stable/10/sys/boot/i386/libi386/smbios.c ============================================================================== --- stable/10/sys/boot/i386/libi386/smbios.c Tue Jan 26 21:24:49 2016 (r294851) +++ stable/10/sys/boot/i386/libi386/smbios.c Tue Jan 26 21:35:47 2016 (r294852) @@ -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 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));