summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSangYoun Kwak <sy.kwak@samsung.com>2024-06-04 19:23:59 +0900
committerSangYoun Kwak <sy.kwak@samsung.com>2024-06-14 15:32:11 +0900
commit1f86a0fa6f7641a865b09412c278312e755b7155 (patch)
tree688afd3507a6c51518be93ea684812344bf0195b
parent2e2255b053329e6df3bc77640e4e62caeb09c91c (diff)
downloaddevice-rpi-1f86a0fa6f7641a865b09412c278312e755b7155.tar.gz
device-rpi-1f86a0fa6f7641a865b09412c278312e755b7155.tar.bz2
device-rpi-1f86a0fa6f7641a865b09412c278312e755b7155.zip
To clarify the states of upgrade process, "upgrade state" feature is added. It is different from the "upgrade status", which looks similar but only shows the progress(-1 and 0~100) of RO and RW upgrades. The "upgrade state" shows the upgrade processes by multiple steps. (Steps follow the definition of the platform) Since the names "upgrade status" and "upgrade state" are similar, to distinguish them, "upgrade status" is renamed as "upgrade progress status". Change-Id: I7881ade876fa733f1c74ac1017df63d3c0ab31e8 Signed-off-by: SangYoun Kwak <sy.kwak@samsung.com>
-rw-r--r--hw/board/board.c66
1 files changed, 51 insertions, 15 deletions
diff --git a/hw/board/board.c b/hw/board/board.c
index b8b57d9..91616cf 100644
--- a/hw/board/board.c
+++ b/hw/board/board.c
@@ -28,14 +28,15 @@
#include </hal/include/device/hal-backend-common.h>
#include <libsyscommon/file.h>
-#define INFORM_MNT_PATH "/mnt/inform"
-#define PARTITION_AB_PATH INFORM_MNT_PATH"/partition-ab.info"
-#define PARTITION_AB_CLONED_PATH INFORM_MNT_PATH"/partition-ab-cloned.info"
-#define UPGRADE_STATUS_PATH INFORM_MNT_PATH"/upgrade-status.info"
-#define PARTITION_A_STATUS_PATH INFORM_MNT_PATH"/partition-a-status.info"
-#define PARTITION_B_STATUS_PATH INFORM_MNT_PATH"/partition-b-status.info"
-#define REBOOT_PARAM_PATH INFORM_MNT_PATH"/reboot-param.bin"
-#define SERIAL_FILE_PATH "/sys/firmware/devicetree/base/serial-number"
+#define INFORM_MNT_PATH "/mnt/inform"
+#define PARTITION_AB_PATH INFORM_MNT_PATH"/partition-ab.info"
+#define PARTITION_AB_CLONED_PATH INFORM_MNT_PATH"/partition-ab-cloned.info"
+#define UPGRADE_PROGRESS_STATUS_PATH INFORM_MNT_PATH"/upgrade-progress-status.info"
+#define PARTITION_A_STATUS_PATH INFORM_MNT_PATH"/partition-a-status.info"
+#define PARTITION_B_STATUS_PATH INFORM_MNT_PATH"/partition-b-status.info"
+#define REBOOT_PARAM_PATH INFORM_MNT_PATH"/reboot-param.bin"
+#define UPGRADE_STATE_PATH INFORM_MNT_PATH"/upgrade-state.info"
+#define SERIAL_FILE_PATH "/sys/firmware/devicetree/base/serial-number"
#define PARTITION_STATUS_OK "ok"
#define PARTITION_STATUS_CORRUPTED "corrupted"
@@ -242,7 +243,7 @@ static int get_partition_status(char partition_ab, char *buffer, const int max_l
return 0;
}
-static int set_upgrade_status(int status)
+static int set_upgrade_progress_status(int status)
{
/* status: -1 if upgrade fail, otherwise 0~100 */
if (status < -1 || status > 100) {
@@ -250,18 +251,18 @@ static int set_upgrade_status(int status)
}
/* clear contents of the file first */
- if (truncate(UPGRADE_STATUS_PATH, 0) == -1) {
+ if (truncate(UPGRADE_PROGRESS_STATUS_PATH, 0) == -1) {
int ferror = errno;
errno = 0;
return -ferror;
}
- return sys_set_int(UPGRADE_STATUS_PATH, status);
+ return sys_set_int(UPGRADE_PROGRESS_STATUS_PATH, status);
}
-static int get_upgrade_status(int *status)
+static int get_upgrade_progress_status(int *status)
{
- int ret_get_int = sys_get_int(UPGRADE_STATUS_PATH, status);
+ int ret_get_int = sys_get_int(UPGRADE_PROGRESS_STATUS_PATH, status);
if (ret_get_int < 0) {
return ret_get_int;
@@ -275,6 +276,38 @@ static int get_upgrade_status(int *status)
return 0;
}
+static int set_upgrade_state(char *state)
+{
+ if (state == NULL)
+ return -EINVAL;
+
+ /* clear contents of the file first */
+ if (truncate(UPGRADE_STATE_PATH, 0) == -1) {
+ int ferror = errno;
+ errno = 0;
+ return -ferror;
+ }
+
+ return sys_set_str(UPGRADE_STATE_PATH, state);
+}
+
+static int get_upgrade_state(char *buffer, const int max_len)
+{
+ int ret = 0;
+
+ if (buffer == NULL)
+ return -EINVAL;
+
+ if (max_len < 1)
+ return -EINVAL;
+
+ ret = sys_get_str(UPGRADE_STATE_PATH, buffer, max_len - 1);
+ if (ret < 0)
+ return ret;
+
+ return 0;
+}
+
static int board_init(void **data)
{
hal_backend_board_funcs *board_funcs;
@@ -296,8 +329,11 @@ static int board_init(void **data)
board_funcs->set_partition_status = set_partition_status;
board_funcs->get_partition_status = get_partition_status;
- board_funcs->set_upgrade_status = set_upgrade_status;
- board_funcs->get_upgrade_status = get_upgrade_status;
+ board_funcs->set_upgrade_progress_status = set_upgrade_progress_status;
+ board_funcs->get_upgrade_progress_status = get_upgrade_progress_status;
+
+ board_funcs->set_upgrade_state = set_upgrade_state;
+ board_funcs->get_upgrade_state = get_upgrade_state;
*data = (void *)board_funcs;