summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Martin Szulecki2015-01-30 17:08:08 +0100
committerGravatar Martin Szulecki2015-01-30 17:08:08 +0100
commite4f0f29e2673d3523bf411b1efb2fc5ecbf64854 (patch)
treefa2b3fb3f7f43f6988db45f0631a08e924c5001e
parent861f45c04185fac6dbbd2dea76f9e217b39003ff (diff)
downloadidevicerestore-e4f0f29e2673d3523bf411b1efb2fc5ecbf64854.tar.gz
idevicerestore-e4f0f29e2673d3523bf411b1efb2fc5ecbf64854.tar.bz2
restore: Use enum for operations and add missing ones
-rw-r--r--src/restore.c217
1 files changed, 165 insertions, 52 deletions
diff --git a/src/restore.c b/src/restore.c
index 6418497..4e06904 100644
--- a/src/restore.c
+++ b/src/restore.c
@@ -38,25 +38,54 @@
#include "restore.h"
#include "common.h"
-#define WAIT_FOR_STORAGE 11
-#define CREATE_PARTITION_MAP 12
-#define CREATE_FILESYSTEM 13
-#define RESTORE_IMAGE 14
-#define VERIFY_RESTORE 15
-#define CHECK_FILESYSTEM 16
-#define MOUNT_FILESYSTEM 17
-#define FLASH_NOR 19
-#define UPDATE_BASEBAND 20
-#define FINIALIZE_NAND 21
-#define MODIFY_BOOTARGS 26
-#define LOAD_KERNEL_CACHE 27
-#define PARTITION_NAND_DEVICE 28
-#define WAIT_FOR_NAND 29
-#define UNMOUNT_FILESYSTEM 30
-#define WAIT_FOR_DEVICE 33
-#define LOAD_NOR 36
-
-#define CREATE_SYSTEM_KEY_BAG 49
+typedef enum {
+ RESTORE_OP_CONNECTING_TO_DEVICE = 4,
+ RESTORE_OP_CONNECTED_TO_DEVICE = 5,
+ RESTORE_OP_SENDING_RAMDISK = 6,
+ RESTORE_OP_SENDING_DEVICETREE = 7,
+ RESTORE_OP_SENDING_KERNELCACHE = 8,
+ RESTORE_OP_SETTING_RESTORE_BOOTARGS = 9,
+ RESTORE_OP_FLASHING_SYSCFG = 11,
+ RESTORE_OP_CREATE_PARTITION_MAP = 12,
+ RESTORE_OP_CREATE_FILESYSTEM = 13,
+ RESTORE_OP_RESTORE_IMAGE = 14,
+ RESTORE_OP_VERIFY_RESTORE = 15,
+ RESTORE_OP_CHECK_FILESYSTEM = 16,
+ RESTORE_OP_MOUNT_FILESYSTEM = 17,
+ RESTORE_OP_FIX_UP_VAR = 18,
+ RESTORE_OP_FLASH_FIRMWARE = 19,
+ RESTORE_OP_UPDATE_BASEBAND = 20,
+ RESTORE_OP_SET_BOOT_STAGE = 21,
+ RESTORE_OP_REBOOT_DEVICE = 22,
+ RESTORE_OP_SHUTDOWN_DEVICE = 23,
+ RESTORE_OP_TURN_ON_ACCESSORY_POWER = 24,
+ RESTORE_OP_CLEAR_BOOTARGS = 25,
+ RESTORE_OP_MODIFY_BOOTARGS = 26,
+ RESTORE_OP_INSTALL_ROOT = 27,
+ RESTORE_OP_INSTALL_KERNELCACHE = 28,
+ RESTORE_OP_WAIT_FOR_NAND = 29,
+ RESTORE_OP_UNMOUNT_FILESYSTEM = 30,
+ RESTORE_OP_SET_DATE_TIME = 31,
+ RESTORE_OP_EXEC_IBEC_BOOTSTRAP = 32,
+ RESTORE_OP_FINALIZE_NAND = 33,
+ RESTORE_OP_CHECK_PARTITIONS = 34,
+ RESTORE_OP_CREATE_FACTORY_MARKER = 35,
+ RESTORE_OP_LOAD_FIRMWARE_TO_FLASH = 36,
+ RESTORE_OP_CHECK_BATTERY_VOLTAGE = 38,
+ RESTORE_OP_WAIT_BATTERY_CHARGE = 39,
+ RESTORE_OP_CLOSE_MODEM_TICKETS = 40,
+ RESTORE_OP_MIGRATING_DATA = 41,
+ RESTORE_OP_WIPE_STORAGE_DEVICE = 42,
+ RESTORE_OP_SENDING_APPLELOGO = 43,
+ RESTORE_OP_CHECKING_UNCOLLECTED_LOGS = 44,
+ RESTORE_OP_CLEARING_NVRAM = 46,
+ RESTORE_OP_UPDATING_GAS_GAUGE = 47,
+ RESTORE_OP_PREPARE_FOR_BB_UPDATE = 48,
+ RESTORE_OP_BOOTING_BB = 49,
+ RESTORE_OP_CREATING_SYSTEM_KEY_BAG = 50,
+ RESTORE_OP_UPDATING_IR_MCU_FIRMWARE = 51,
+ RESTORE_OP_RESIZING_SYSTEM_PARTITION = 52
+} restore_operation_t;
static int restore_finished = 0;
@@ -447,58 +476,142 @@ int restore_open_with_timeout(struct idevicerestore_client_t* client) {
return 0;
}
-const char* restore_progress_string(unsigned int operation) {
+const char* restore_progress_string(restore_operation_t operation) {
switch (operation) {
- case WAIT_FOR_STORAGE:
- return "Waiting for storage device";
+ case RESTORE_OP_CONNECTING_TO_DEVICE:
+ return "Connecting to device";
- case CREATE_PARTITION_MAP:
+ case RESTORE_OP_CONNECTED_TO_DEVICE:
+ return "Connected to device";
+
+ case RESTORE_OP_SENDING_RAMDISK:
+ return "Sending ramdisk";
+
+ case RESTORE_OP_SENDING_DEVICETREE:
+ return "Sending device tree";
+
+ case RESTORE_OP_SENDING_KERNELCACHE:
+ return "Sending kernel cache";
+
+ case RESTORE_OP_FLASHING_SYSCFG:
+ return "Flashing Syscfg";
+
+ case RESTORE_OP_CREATE_PARTITION_MAP:
return "Creating partition map";
- case CREATE_FILESYSTEM:
+ case RESTORE_OP_CREATE_FILESYSTEM:
return "Creating filesystem";
- case RESTORE_IMAGE:
+ case RESTORE_OP_RESTORE_IMAGE:
return "Restoring image";
- case VERIFY_RESTORE:
+ case RESTORE_OP_VERIFY_RESTORE:
return "Verifying restore";
- case CHECK_FILESYSTEM:
+ case RESTORE_OP_CHECK_FILESYSTEM:
return "Checking filesystems";
- case MOUNT_FILESYSTEM:
+ case RESTORE_OP_MOUNT_FILESYSTEM:
return "Mounting filesystems";
- case FLASH_NOR:
- return "Flashing NOR";
+ case RESTORE_OP_FIX_UP_VAR:
+ return "Fixing up /var";
- case UPDATE_BASEBAND:
+ case RESTORE_OP_FLASH_FIRMWARE:
+ return "Flashing firmware";
+
+ case RESTORE_OP_UPDATE_BASEBAND:
return "Updating baseband";
- case FINIALIZE_NAND:
- return "Finalizing NAND epoch update";
+ case RESTORE_OP_SET_BOOT_STAGE:
+ return "Setting boot stage";
- case MODIFY_BOOTARGS:
- return "Modifying persistent boot-args";
+ case RESTORE_OP_REBOOT_DEVICE:
+ return "Rebooting device";
- case UNMOUNT_FILESYSTEM:
- return "Unmounting filesystems";
+ case RESTORE_OP_SHUTDOWN_DEVICE:
+ return "Shutting down device";
+
+ case RESTORE_OP_TURN_ON_ACCESSORY_POWER:
+ return "Turning on accessory power";
- case PARTITION_NAND_DEVICE:
- return "Partition NAND device";
+ case RESTORE_OP_CLEAR_BOOTARGS:
+ return "Clearing persistent boot-args";
- case WAIT_FOR_NAND:
+ case RESTORE_OP_MODIFY_BOOTARGS:
+ return "Modifing persistent boot-args";
+
+ case RESTORE_OP_INSTALL_ROOT:
+ return "Installing root";
+
+ case RESTORE_OP_INSTALL_KERNELCACHE:
+ return "Installing kernel cache";
+
+ case RESTORE_OP_WAIT_FOR_NAND:
return "Waiting for NAND";
- case WAIT_FOR_DEVICE:
- return "Waiting for device";
+ case RESTORE_OP_UNMOUNT_FILESYSTEM:
+ return "Unmounting filesystems";
+
+ case RESTORE_OP_SET_DATE_TIME:
+ return "Setting date and time on device";
+
+ case RESTORE_OP_EXEC_IBEC_BOOTSTRAP:
+ return "Executing iBEC to bootstrap update";
+
+ case RESTORE_OP_FINALIZE_NAND:
+ return "Finalizing NAND epoch update";
- case LOAD_KERNEL_CACHE:
- return "Loading kernelcache";
+ case RESTORE_OP_CHECK_PARTITIONS:
+ return "Checking for inappropriate bootable partitions";
- case LOAD_NOR:
- return "Loading NOR data to flash";
+ case RESTORE_OP_CREATE_FACTORY_MARKER:
+ return "Creating factory restore marker";
+
+ case RESTORE_OP_LOAD_FIRMWARE_TO_FLASH:
+ return "Loading firmware data to flash";
+
+ case RESTORE_OP_CHECK_BATTERY_VOLTAGE:
+ return "Checking battery voltage";
+
+ case RESTORE_OP_WAIT_BATTERY_CHARGE:
+ return "Waiting for battery to charge";
+
+ case RESTORE_OP_CLOSE_MODEM_TICKETS:
+ return "Closing modem tickets";
+
+ case RESTORE_OP_MIGRATING_DATA:
+ return "Migrating data";
+
+ case RESTORE_OP_WIPE_STORAGE_DEVICE:
+ return "Wiping storage device";
+
+ case RESTORE_OP_SENDING_APPLELOGO:
+ return "Sending Apple logo to device";
+
+ case RESTORE_OP_CHECKING_UNCOLLECTED_LOGS:
+ return "Checking for uncollected logs";
+
+ case RESTORE_OP_CLEARING_NVRAM:
+ return "Clearing NVRAM";
+
+ case RESTORE_OP_UPDATING_GAS_GAUGE:
+ return "Updating gas gauge software";
+
+ case RESTORE_OP_PREPARE_FOR_BB_UPDATE:
+ return "Preparing for baseband update";
+
+ case RESTORE_OP_BOOTING_BB:
+ return "Booting the baseband";
+
+ case RESTORE_OP_CREATING_SYSTEM_KEY_BAG:
+ return "Creating system key bag";
+
+ case RESTORE_OP_UPDATING_IR_MCU_FIRMWARE:
+ return "Updating IR MCU firmware";
+
+ case RESTORE_OP_RESIZING_SYSTEM_PARTITION:
+ return "Resizing system partition";
default:
return "Unknown operation";
@@ -545,16 +658,16 @@ int restore_handle_progress_msg(struct idevicerestore_client_t* client, plist_t
if ((progress > 0) && (progress <= 100)) {
if ((int)operation != lastop) {
- info("%s (%d)\n", restore_progress_string(operation), (int)operation);
+ info("%s (%d)\n", restore_progress_string(operation), (restore_operation_t)operation);
}
- switch ((int)operation) {
- case 14:
+ switch ((restore_operation_t)operation) {
+ case RESTORE_OP_RESTORE_IMAGE:
idevicerestore_progress(client, RESTORE_STEP_FLASH_FS, progress / 100.0);
break;
- case 18:
+ case RESTORE_OP_FLASH_FIRMWARE:
idevicerestore_progress(client, RESTORE_STEP_FLASH_FW, progress / 100.0);
break;
- case 19:
+ case RESTORE_OP_UPDATE_BASEBAND:
idevicerestore_progress(client, RESTORE_STEP_FLASH_BB, progress / 100.0);
break;
default:
@@ -603,7 +716,7 @@ int restore_handle_status_msg(restored_client_t client, plist_t msg) {
info("Status: X-Gold Baseband Update Failed. Defective Unit?\n");
break;
default:
- info("Unhandled status message (" FMT_qu ")\n", (long long unsigned int)value);
+ info("Status: Unhandled message (" FMT_qu ")\n", (long long unsigned int)value);
debug_plist(msg);
break;
}