From caad82c44ac2c2685b3b064fb8bc0f16e596d0f9 Mon Sep 17 00:00:00 2001 From: yanghongliang Date: Sat, 27 Nov 2021 16:51:09 +0800 Subject: [PATCH] =?UTF-8?q?dayu200=20=E5=A2=9E=E5=8A=A0=E8=BF=9B=E5=85=A5?= =?UTF-8?q?=E4=B8=8B=E8=BD=BD=E6=A8=A1=E5=BC=8F=E5=91=BD=E4=BB=A4(reboot?= =?UTF-8?q?=20loader)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: yanghongliang --- services/cmds/reboot/init_cmd_reboot.c | 2 ++ services/init/standard/init_reboot.c | 9 ++++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/services/cmds/reboot/init_cmd_reboot.c b/services/cmds/reboot/init_cmd_reboot.c index ad3dd2bed..ac018fcf7 100755 --- a/services/cmds/reboot/init_cmd_reboot.c +++ b/services/cmds/reboot/init_cmd_reboot.c @@ -24,6 +24,7 @@ " reboot updater[:options]\n" \ " reboot flashd\n" \ " reboot flashd[:options]\n" \ + " reboot loader\n" \ " reboot\n" int main(int argc, char* argv[]) @@ -36,6 +37,7 @@ int main(int argc, char* argv[]) if (argc == REBOOT_CMD_NUMBER && strcmp(argv[1], "shutdown") != 0 && strcmp(argv[1], "updater") != 0 && strcmp(argv[1], "flashd") != 0 && + strcmp(argv[1], "loader") !=0 && strncmp(argv[1], "updater:", strlen("updater:")) != 0 && strncmp(argv[1], "flashd:", strlen("flashd:")) != 0) { printf("%s", USAGE_INFO); diff --git a/services/init/standard/init_reboot.c b/services/init/standard/init_reboot.c index 8cf702f3f..0dcc4c67a 100755 --- a/services/init/standard/init_reboot.c +++ b/services/init/standard/init_reboot.c @@ -16,6 +16,7 @@ #include #include #include +#include #include "init_log.h" #include "init_service.h" @@ -27,6 +28,10 @@ #define MAX_COMMAND_SIZE 20 #define MAX_UPDATE_SIZE 100 +#define REBOOT_MAGIC1 0xfee1dead +#define REBOOT_MAGIC2 672274793 +#define REBOOT_CMD_RESTART2 0xA1B2C3D4 + struct RBMiscUpdateMessage { char command[MAX_COMMAND_SIZE]; char update[MAX_UPDATE_SIZE]; @@ -137,7 +142,7 @@ static int CheckRebootParam(const char *valueData) return 0; } static const char *cmdParams[] = { - "shutdown", "updater", "updater:", "flash", "flash:", "NoArgument", "bootloader" + "shutdown", "updater", "updater:", "flash", "flash:", "NoArgument", "loader","bootloader" }; size_t i = 0; for (; i < ARRAY_LENGTH(cmdParams); i++) { @@ -188,6 +193,8 @@ void ExecReboot(const char *value) ret = CheckAndRebootToUpdater(valueData, "updater", "updater:", "boot_updater"); } else if (strncmp(valueData, "flash", strlen("flash")) == 0) { ret = CheckAndRebootToUpdater(valueData, "flash", "flash:", "boot_flash"); + } else if (strncmp(valueData, "loader", strlen("loader")) == 0) { + syscall(__NR_reboot, REBOOT_MAGIC1, REBOOT_MAGIC2, REBOOT_CMD_RESTART2, "loader"); } INIT_LOGI("Reboot %s %s.", value, (ret == 0) ? "success" : "fail"); return;