From 7ec5fd9e6d413860c8ecf68e5d14111f8e12e434 Mon Sep 17 00:00:00 2001 From: Alessandro Astone Date: Fri, 12 Oct 2018 11:12:22 +0200 Subject: [PATCH] recovery: Move bldrmsg offset symbols to bootloader_message.cpp * bootloader_message.cpp is the only file using BOOTLOADER_MESSAGE_OFFSET_IN_MISC and WIPE_PACKAGE_OFFSET_IN_MISC, so we can move their definitions to the cpp. This prevents the need to set BOARD_RECOVERY_BLDRMSG_OFFSET in every module that includes the header. * Global cflags are no longer supported Oreo and up, so set the BOARD_RECOVERY_BLDRMSG_OFFSET via make variable * Simplify logic, always set BOARD_RECOVERY_BLDRMSG_OFFSET. Change-Id: I2b902bcce7f5ca13472e0ac30ac01b4991294dbe --- bootloader_message_twrp/Android.mk | 5 +++++ bootloader_message_twrp/bootloader_message.cpp | 10 ++++++++++ .../bootloader_message_twrp/bootloader_message.h | 15 --------------- 3 files changed, 15 insertions(+), 15 deletions(-) diff --git a/bootloader_message_twrp/Android.mk b/bootloader_message_twrp/Android.mk index e7a3ea0f..932cd040 100644 --- a/bootloader_message_twrp/Android.mk +++ b/bootloader_message_twrp/Android.mk @@ -31,5 +31,10 @@ LOCAL_CFLAGS := -Werror -std=c++11 ifeq ($(TW_IGNORE_MISC_WIPE_DATA), true) LOCAL_CFLAGS += -DIGNORE_MISC_WIPE_DATA endif +ifeq ($(BOOTLOADER_MESSAGE_OFFSET),) + LOCAL_CFLAGS += -DBOARD_RECOVERY_BLDRMSG_OFFSET=0 +else + LOCAL_CFLAGS += -DBOARD_RECOVERY_BLDRMSG_OFFSET=$(BOOTLOADER_MESSAGE_OFFSET) +endif LOCAL_EXPORT_C_INCLUDE_DIRS := $(LOCAL_PATH)/include include $(BUILD_SHARED_LIBRARY) diff --git a/bootloader_message_twrp/bootloader_message.cpp b/bootloader_message_twrp/bootloader_message.cpp index a06ad9a8..b97f66e3 100644 --- a/bootloader_message_twrp/bootloader_message.cpp +++ b/bootloader_message_twrp/bootloader_message.cpp @@ -28,6 +28,16 @@ #include #include +// Spaces used by misc partition are as below: +// 0 - 2K For bootloader_message +// 2K - 16K Used by Vendor's bootloader (the 2K - 4K range may be optionally used +// as bootloader_message_ab struct) +// 16K - 64K Used by uncrypt and recovery to store wipe_package for A/B devices +// Note that these offsets are admitted by bootloader,recovery and uncrypt, so they +// are not configurable without changing all of them. +static const size_t BOOTLOADER_MESSAGE_OFFSET_IN_MISC = BOARD_RECOVERY_BLDRMSG_OFFSET; +static const size_t WIPE_PACKAGE_OFFSET_IN_MISC = 16 * 1024 + BOOTLOADER_MESSAGE_OFFSET_IN_MISC; + static std::string misc_blkdev; void set_misc_device(const char* name) { diff --git a/bootloader_message_twrp/include/bootloader_message_twrp/bootloader_message.h b/bootloader_message_twrp/include/bootloader_message_twrp/bootloader_message.h index 52c1b86f..d8d955e7 100644 --- a/bootloader_message_twrp/include/bootloader_message_twrp/bootloader_message.h +++ b/bootloader_message_twrp/include/bootloader_message_twrp/bootloader_message.h @@ -21,21 +21,6 @@ #include #include -// Spaces used by misc partition are as below: -// 0 - 2K For bootloader_message -// 2K - 16K Used by Vendor's bootloader (the 2K - 4K range may be optionally used -// as bootloader_message_ab struct) -// 16K - 64K Used by uncrypt and recovery to store wipe_package for A/B devices -// Note that these offsets are admitted by bootloader,recovery and uncrypt, so they -// are not configurable without changing all of them. -#ifdef BOARD_RECOVERY_BLDRMSG_OFFSET -static const size_t BOOTLOADER_MESSAGE_OFFSET_IN_MISC = BOARD_RECOVERY_BLDRMSG_OFFSET; -static const size_t WIPE_PACKAGE_OFFSET_IN_MISC = 16 * 1024 + BOOTLOADER_MESSAGE_OFFSET_IN_MISC; -#else -static const size_t BOOTLOADER_MESSAGE_OFFSET_IN_MISC = 0; -static const size_t WIPE_PACKAGE_OFFSET_IN_MISC = 16 * 1024; -#endif - /* Bootloader Message (2-KiB) * * This structure describes the content of a block in flash