From cba7fa88d8b982a65f0e27babd0d6ffe82634409 Mon Sep 17 00:00:00 2001 From: Vineela Tummalapalli Date: Fri, 28 Oct 2016 19:44:40 -0700 Subject: Add 'reboot bootloader' to bootloader_message. Add 'reboot bootloader' capability to the bootloader_message. BUG: https://issuetracker.google.com/issues/32474515 Change-Id: I01e8b2fad978bf7c8fc96ff6b08ad3e52533f504 Author: Vineela Tummalapalli Signed-off-by: Vineela Tummalapalli Signed-off-by: Bruce Beare Reviewed-on: https://android.intel.com/548519 --- bootloader_message/bootloader_message.cpp | 18 ++++++++++++++++++ .../include/bootloader_message/bootloader_message.h | 4 ++++ 2 files changed, 22 insertions(+) diff --git a/bootloader_message/bootloader_message.cpp b/bootloader_message/bootloader_message.cpp index 59c2b2e01..f6f8005f6 100644 --- a/bootloader_message/bootloader_message.cpp +++ b/bootloader_message/bootloader_message.cpp @@ -163,6 +163,19 @@ bool write_bootloader_message(const std::vector& options, std::stri return write_bootloader_message(boot, err); } +bool write_reboot_bootloader(std::string* err) { + bootloader_message boot; + if (!read_bootloader_message(&boot, err)) { + return false; + } + if (boot.command[0] != '\0') { + *err = "Bootloader command pending."; + return false; + } + strlcpy(boot.command, "bootonce-bootloader", sizeof(boot.command)); + return write_bootloader_message(boot, err); +} + bool read_wipe_package(std::string* package_data, size_t size, std::string* err) { package_data->resize(size); return read_misc_partition(&(*package_data)[0], size, WIPE_PACKAGE_OFFSET_IN_MISC, err); @@ -173,6 +186,11 @@ bool write_wipe_package(const std::string& package_data, std::string* err) { WIPE_PACKAGE_OFFSET_IN_MISC, err); } +extern "C" bool write_reboot_bootloader(void) { + std::string err; + return write_reboot_bootloader(&err); +} + extern "C" bool write_bootloader_message(const char* options) { std::string err; return write_bootloader_message({options}, &err); diff --git a/bootloader_message/include/bootloader_message/bootloader_message.h b/bootloader_message/include/bootloader_message/bootloader_message.h index 07ecf8576..5a5dd8793 100644 --- a/bootloader_message/include/bootloader_message/bootloader_message.h +++ b/bootloader_message/include/bootloader_message/bootloader_message.h @@ -183,6 +183,9 @@ bool write_bootloader_message(const bootloader_message& boot, std::string* err); bool write_bootloader_message(const std::vector& options, std::string* err); bool clear_bootloader_message(std::string* err); +// Writes the reboot-bootloader reboot reason to the bootloader_message. +bool write_reboot_bootloader(std::string* err); + bool read_wipe_package(std::string* package_data, size_t size, std::string* err); bool write_wipe_package(const std::string& package_data, std::string* err); @@ -192,6 +195,7 @@ bool write_wipe_package(const std::string& package_data, std::string* err); // C Interface. bool write_bootloader_message(const char* options); +bool write_reboot_bootloader(void); #endif // ifdef __cplusplus -- cgit v1.2.3