From 3d57c84476ce542a7d8d623cf1f208efc1a20026 Mon Sep 17 00:00:00 2001 From: Tianjie Xu Date: Sat, 9 Nov 2019 22:07:20 -0800 Subject: Consolidate the vendor space misc usage for Pixels The layout of the vendor space /misc partition was pretty confusing and lead to some usage conflicts. To formalize the layout, we create a pixel specific library with the definition & offset of various flags. The new library also handles the R/W. As a result, we will leave system domain /misc definitions in the libbootloader_message. We also switch the misc_writer binary to use more specific options instead of writing an arbitrary hex string. So we can avoid redefining the string & offset in both init script and recovery ui. Bug: 131775112 Test: unit tests pass, run misc_writer and check contents of /misc Change-Id: I00f8842a81d1929e31a1de4d5eb09575ffad47c0 --- .../include/bootloader_message/bootloader_message.h | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) (limited to 'bootloader_message/include') diff --git a/bootloader_message/include/bootloader_message/bootloader_message.h b/bootloader_message/include/bootloader_message/bootloader_message.h index 3a3b862aa..a27e80bcc 100644 --- a/bootloader_message/include/bootloader_message/bootloader_message.h +++ b/bootloader_message/include/bootloader_message/bootloader_message.h @@ -212,11 +212,18 @@ struct misc_system_space_layout { #include #include +// Gets the block device name of /misc partition. +std::string get_misc_blk_device(std::string* err); // Return the block device name for the bootloader message partition and waits // for the device for up to 10 seconds. In case of error returns the empty // string. std::string get_bootloader_message_blk_device(std::string* err); +// Writes |size| bytes of data from buffer |p| to |misc_blk_device| at |offset|. If the write fails, +// sets the error message in |err|. +bool write_misc_partition(const void* p, size_t size, const std::string& misc_blk_device, + size_t offset, std::string* err); + // Read bootloader message into boot. Error message will be set in err. bool read_bootloader_message(bootloader_message* boot, std::string* err); @@ -261,14 +268,6 @@ bool read_wipe_package(std::string* package_data, size_t size, std::string* err) // Write the wipe package into BCB (to offset WIPE_PACKAGE_OFFSET_IN_MISC). bool write_wipe_package(const std::string& package_data, std::string* err); -// Reads data from the vendor space in /misc partition, with the given offset and size. Note that -// offset is in relative to the start of vendor space. -bool ReadMiscPartitionVendorSpace(void* data, size_t size, size_t offset, std::string* err); - -// Writes the given data to the vendor space in /misc partition, at the given offset. Note that -// offset is in relative to the start of the vendor space. -bool WriteMiscPartitionVendorSpace(const void* data, size_t size, size_t offset, std::string* err); - // Read or write the Virtual A/B message from system space in /misc. bool ReadMiscVirtualAbMessage(misc_virtual_ab_message* message, std::string* err); bool WriteMiscVirtualAbMessage(const misc_virtual_ab_message& message, std::string* err); -- cgit v1.2.3