Date: Thu, 9 Mar 2017 00:24:02 +0000 (UTC) From: Warner Losh <imp@FreeBSD.org> 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 Message-ID: <201703090024.v290O2DI037652@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
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 <src.opts.mk> +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 <stdlib.h> #include <string.h> -#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 <sys/efi.h> #include <machine/efi.h> -#include "libefivar_int.h" - -#include <stdio.h> +#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;
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201703090024.v290O2DI037652>