libefi: make efichar.h more usable in stand code

Use _STANDALONE for guard expression in efichar.[ch] and add efi_char typedef.
clean up boot1.c, and replace for loop in efipart.c with ucs2len().

Reviewed by:	imp
Differential Revision:	https://reviews.freebsd.org/D13488
This commit is contained in:
Toomas Soome 2017-12-14 16:41:52 +00:00
parent afe6f8358e
commit 9f9b430b19
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=326854
5 changed files with 10 additions and 7 deletions

View File

@ -29,7 +29,6 @@ __FBSDID("$FreeBSD$");
#include <efi.h>
#include <eficonsctl.h>
typedef CHAR16 efi_char;
#include <efichar.h>
#include "boot_module.h"

View File

@ -29,6 +29,12 @@
#ifndef _BOOT_EFI_EFICHAR_H_
#define _BOOT_EFI_EFICHAR_H_
#ifdef _STANDALONE
#include <efi.h>
typedef CHAR16 efi_char;
#endif
int ucs2_to_utf8(const efi_char *, char **);
int utf8_to_ucs2(const char *, efi_char **, size_t *);
int ucs2len(const efi_char *);

View File

@ -52,6 +52,4 @@ CFLAGS+= ${FORMAT_EXTENSIONS}
CFLAGS+= -DTERM_EMU
.endif
CFLAGS+= -DLIBEFI
.include <bsd.lib.mk>

View File

@ -29,16 +29,16 @@ __FBSDID("$FreeBSD$");
#include <sys/types.h>
#include <errno.h>
#ifdef LIBEFI
#ifdef _STANDALONE
#include <stand.h>
#else
#include <stddef.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#endif
#include <sys/efi.h>
#include <machine/efi.h>
#endif
#include "efichar.h"

View File

@ -39,6 +39,7 @@ __FBSDID("$FreeBSD$");
#include <efi.h>
#include <efilib.h>
#include <efiprot.h>
#include <efichar.h>
#include <disk.h>
static EFI_GUID blkio_guid = BLOCK_IO_PROTOCOL;
@ -564,8 +565,7 @@ efipart_hdinfo_add_filepath(EFI_HANDLE disk_handle)
unit = 0;
/* FILEPATH_DEVICE_PATH has 0 terminated string */
for (len = 0; node->PathName[len] != 0; len++)
;
len = ucs2len(node->PathName);
if ((pathname = malloc(len + 1)) == NULL) {
printf("Failed to add disk, out of memory\n");
free(pd);