OSDN Git Service

Android: inital porting of libefivar nougat-x86 android-x86-7.1-r1 android-x86-7.1-r2 android-x86-7.1-r3 android-x86-7.1-r4 android-x86-7.1-r5
authorChih-Wei Huang <cwhuang@linux.org.tw>
Fri, 12 Jan 2018 03:31:18 +0000 (11:31 +0800)
committerChih-Wei Huang <cwhuang@linux.org.tw>
Fri, 12 Jan 2018 03:31:18 +0000 (11:31 +0800)
The static library is linked by efibootmgr.

src/Android.mk [new file with mode: 0644]
src/efivar_endian.h
src/util.h

diff --git a/src/Android.mk b/src/Android.mk
new file mode 100644 (file)
index 0000000..a6a05ad
--- /dev/null
@@ -0,0 +1,59 @@
+#
+# Copyright (C) 2018 The Android-x86 Open Source Project
+#
+# Licensed under the GNU Lesser General Public License Version 2.1.
+# You may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#      https://www.gnu.org/licenses/lgpl-2.1.html
+#
+
+LOCAL_PATH := $(call my-dir)
+
+include $(CLEAR_VARS)
+
+LOCAL_MODULE := makeguids
+LOCAL_C_INCLUDES := $(LOCAL_PATH)/include
+LOCAL_CFLAGS := -DEFIVAR_BUILD_ENVIRONMENT
+LOCAL_SRC_FILES := guid.c makeguids.c
+LOCAL_LDLIBS := -ldl
+include $(BUILD_HOST_EXECUTABLE)
+
+include $(CLEAR_VARS)
+
+LOCAL_MODULE := libefivar
+LOCAL_MODULE_CLASS := STATIC_LIBRARIES
+LIBEFIBOOT_SOURCES := \
+       crc32.c \
+       creator.c \
+       disk.c \
+       gpt.c \
+       linux.c \
+       loadopt.c
+
+LIBEFIVAR_SOURCES := \
+       dp.c \
+       dp-acpi.c \
+       dp-hw.c \
+       dp-media.c \
+       dp-message.c \
+       efivarfs.c \
+       error.c \
+       export.c \
+       guid.c \
+       guids.S \
+       lib.c \
+       vars.c
+
+LOCAL_SRC_FILES := $(LIBEFIBOOT_SOURCES) $(LIBEFIVAR_SOURCES)
+LOCAL_CFLAGS := -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE -std=gnu11
+LOCAL_C_INCLUDES := $(LOCAL_PATH)/include
+LOCAL_EXPORT_C_INCLUDE_DIRS := $(LOCAL_C_INCLUDES) $(LOCAL_C_INCLUDES)/efivar $(local-generated-sources-dir)
+LIBEFIVAR_GUIDS_H := $(local-generated-sources-dir)/efivar/efivar-guids.h
+LOCAL_GENERATED_SOURCES := $(LIBEFIVAR_GUIDS_H) $(local-generated-sources-dir)/guid-symbols.c
+$(LIBEFIVAR_GUIDS_H): PRIVATE_CUSTOM_TOOL = $^ $(addprefix $(dir $(@D)),guids.bin names.bin guid-symbols.c efivar/efivar-guids.h)
+$(LIBEFIVAR_GUIDS_H): $(BUILD_OUT_EXECUTABLES)/makeguids $(LOCAL_PATH)/guids.txt
+       $(transform-generated-source)
+$(lastword $(LOCAL_GENERATED_SOURCES)): $(LIBEFIVAR_GUIDS_H)
+
+include $(BUILD_STATIC_LIBRARY)
index 7d0f63d..160c996 100644 (file)
 
 #include <endian.h>
 
+#ifdef __ANDROID__
+#define __bswap_16 __swap16
+#define __bswap_32 __swap32
+#define __bswap_64 __swap64
+#endif
+
 #if __BYTE_ORDER == __LITTLE_ENDIAN
 #define cpu_to_le16(x) (x)
 #define cpu_to_le32(x) (x)
index 0af7dbe..ec8e8de 100644 (file)
@@ -217,6 +217,29 @@ get_sector_size(int filedes)
        return sector_size;
 }
 
+#ifdef __ANDROID__
+#define strdupa(str)                                                   \
+       ({                                                              \
+               size_t sz = strlen(str) + 1;                            \
+               char *copy = alloca(sz);                                \
+               if (copy != NULL) {                                     \
+                       memcpy(copy, str, sz);                          \
+               }                                                       \
+               copy;                                                   \
+       })
+
+#define strndupa(str, maxlen)                                          \
+       ({                                                              \
+               size_t len = strnlen(str, maxlen);                      \
+               char *copy = alloca(len + 1);                           \
+               if (copy != NULL) {                                     \
+                       memcpy(copy, str, len);                         \
+                       copy[len] = '\0';                               \
+               }                                                       \
+               copy;                                                   \
+       })
+#endif
+
 #define asprintfa(str, fmt, args...)                                   \
        ({                                                              \
                char *_tmp = NULL;                                      \