From owner-svn-src-head@freebsd.org Thu Mar 9 00:24:03 2017 Return-Path: Delivered-To: svn-src-head@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 67D33D0187A; Thu, 9 Mar 2017 00:24:03 +0000 (UTC) (envelope-from imp@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 426B4791; Thu, 9 Mar 2017 00:24:03 +0000 (UTC) (envelope-from imp@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v290O2ap037656; Thu, 9 Mar 2017 00:24:02 GMT (envelope-from imp@FreeBSD.org) Received: (from imp@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v290O2DI037652; Thu, 9 Mar 2017 00:24:02 GMT (envelope-from imp@FreeBSD.org) Message-Id: <201703090024.v290O2DI037652@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: imp set sender to imp@FreeBSD.org using -f From: Warner Losh Date: Thu, 9 Mar 2017 00:24:02 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r314925 - in head: lib/libefivar sys/boot/efi/include sys/boot/efi/libefi X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 09 Mar 2017 00:24:03 -0000 Author: imp Date: Thu Mar 9 00:24:01 2017 New Revision: 314925 URL: https://svnweb.freebsd.org/changeset/base/314925 Log: Share UCS2/UTF8 routines between boot loader and userland. Move the UCS2 to UTF8 routines over into sys/boot/efi and have libefivar grab them from there. Sponsored by: Netflix Added: head/sys/boot/efi/include/efichar.h - copied, changed from r314924, head/lib/libefivar/libefivar_int.h head/sys/boot/efi/libefi/efichar.c - copied, changed from r314924, head/lib/libefivar/libefivar.c Deleted: head/lib/libefivar/libefivar.c head/lib/libefivar/libefivar_int.h Modified: head/lib/libefivar/Makefile head/lib/libefivar/efivar.c Modified: head/lib/libefivar/Makefile ============================================================================== --- head/lib/libefivar/Makefile Wed Mar 8 23:58:10 2017 (r314924) +++ head/lib/libefivar/Makefile Thu Mar 9 00:24:01 2017 (r314925) @@ -26,13 +26,19 @@ .include +EFIBOOT=${SRCTOP}/sys/boot/efi + +.PATH: ${EFIBOOT}/libefi + PACKAGE=lib${LIB} LIB= efivar -SRCS= efivar.c libefivar.c +SRCS= efivar.c efichar.c INCS= efivar.h SHLIB_MAJOR= 1 MAN= efivar.3 +CFLAGS+= -I${EFIBOOT}/include + MLINKS+=efivar.3 efi_set_variables_supported.3 \ efivar.3 efi_del_variable.3 \ efivar.3 efi_get_variable.3 \ Modified: head/lib/libefivar/efivar.c ============================================================================== --- head/lib/libefivar/efivar.c Wed Mar 8 23:58:10 2017 (r314924) +++ head/lib/libefivar/efivar.c Thu Mar 9 00:24:01 2017 (r314925) @@ -36,8 +36,7 @@ __FBSDID("$FreeBSD$"); #include #include -#include "efivar.h" -#include "libefivar_int.h" +#include "efichar.h" static int efi_fd = -2; @@ -174,7 +173,7 @@ efi_get_variable(efi_guid_t guid, const return -1; efi_var_reset(&var); - rv = libefi_utf8_to_ucs2(name, &var.name, &var.namesize); + rv = utf8_to_ucs2(name, &var.name, &var.namesize); if (rv != 0) goto errout; var.vendor = guid; @@ -237,7 +236,7 @@ again: *buf = 0; /* GUID zeroed in var_reset */ } else { - rv = libefi_utf8_to_ucs2(*name, &var.name, &size); + rv = utf8_to_ucs2(*name, &var.name, &size); if (rv != 0) goto errout; var.vendor = **guid; @@ -261,7 +260,7 @@ again: if (rv == 0) { *name = NULL; /* XXX */ var.name[var.namesize / sizeof(efi_char)] = 0; /* EFI doesn't NUL terminate */ - rv = libefi_ucs2_to_utf8(var.name, name); + rv = ucs2_to_utf8(var.name, name); if (rv != 0) goto errout; retguid = var.vendor; @@ -359,7 +358,7 @@ efi_set_variable(efi_guid_t guid, const return -1; efi_var_reset(&var); - rv = libefi_utf8_to_ucs2(name, &var.name, &var.namesize); + rv = utf8_to_ucs2(name, &var.name, &var.namesize); if (rv != 0) goto errout; var.vendor = guid; Copied and modified: head/sys/boot/efi/include/efichar.h (from r314924, head/lib/libefivar/libefivar_int.h) ============================================================================== --- head/lib/libefivar/libefivar_int.h Wed Mar 8 23:58:10 2017 (r314924, copy source) +++ head/sys/boot/efi/include/efichar.h Thu Mar 9 00:24:01 2017 (r314925) @@ -26,10 +26,10 @@ * $FreeBSD$ */ -#ifndef _LIBEFI_INT_H_ -#define _LIBEFI_INT_H_ +#ifndef _BOOT_EFI_EFICHAR_H_ +#define _BOOT_EFI_EFICHAR_H_ -int libefi_ucs2_to_utf8(const efi_char *, char **); -int libefi_utf8_to_ucs2(const char *, efi_char **, size_t *); +int ucs2_to_utf8(const efi_char *, char **); +int utf8_to_ucs2(const char *, efi_char **, size_t *); -#endif /* _LIBEFI_INT_H_ */ +#endif /* _BOOT_EFI_EFICHAR_H_ */ Copied and modified: head/sys/boot/efi/libefi/efichar.c (from r314924, head/lib/libefivar/libefivar.c) ============================================================================== --- head/lib/libefivar/libefivar.c Wed Mar 8 23:58:10 2017 (r314924, copy source) +++ head/sys/boot/efi/libefi/efichar.c Thu Mar 9 00:24:01 2017 (r314925) @@ -36,9 +36,7 @@ __FBSDID("$FreeBSD$"); #include #include -#include "libefivar_int.h" - -#include +#include "efichar.h" /* * If nm were converted to utf8, what what would strlen @@ -65,7 +63,7 @@ utf8_len_of_ucs2(const efi_char *nm) } int -libefi_ucs2_to_utf8(const efi_char *nm, char **name) +ucs2_to_utf8(const efi_char *nm, char **name) { size_t len, sz; efi_char c; @@ -113,7 +111,7 @@ libefi_ucs2_to_utf8(const efi_char *nm, } int -libefi_utf8_to_ucs2(const char *name, efi_char **nmp, size_t *len) +utf8_to_ucs2(const char *name, efi_char **nmp, size_t *len) { efi_char *nm; size_t sz;