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:
parent
5c3755a444
commit
9e63f130a7
@ -29,7 +29,6 @@ __FBSDID("$FreeBSD$");
|
||||
|
||||
#include <efi.h>
|
||||
#include <eficonsctl.h>
|
||||
typedef CHAR16 efi_char;
|
||||
#include <efichar.h>
|
||||
|
||||
#include "boot_module.h"
|
||||
|
@ -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 *);
|
||||
|
@ -52,6 +52,4 @@ CFLAGS+= ${FORMAT_EXTENSIONS}
|
||||
CFLAGS+= -DTERM_EMU
|
||||
.endif
|
||||
|
||||
CFLAGS+= -DLIBEFI
|
||||
|
||||
.include <bsd.lib.mk>
|
||||
|
@ -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"
|
||||
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user