diff options
author | Joshua Hill | 2010-06-05 11:17:05 +0800 |
---|---|---|
committer | rcg4u | 2010-06-09 17:17:28 +0800 |
commit | 7f98089a5e6663be50521063cf7171ab1bbc9fa2 (patch) | |
tree | 73a8cf475e0fb13ba8957fb3a696b7340f5cba9c /src/dfu.c | |
parent | 3761295840ba6c7672aebcb2b084a2dbf7099735 (diff) | |
download | idevicerestore-7f98089a5e6663be50521063cf7171ab1bbc9fa2.tar.gz idevicerestore-7f98089a5e6663be50521063cf7171ab1bbc9fa2.tar.bz2 |
Even more major cleanups and refactoring, this branch is still broken but starting to mature really well
Diffstat (limited to 'src/dfu.c')
-rw-r--r-- | src/dfu.c | 49 |
1 files changed, 40 insertions, 9 deletions
@@ -19,10 +19,13 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -#include <stdint.h> +#include <stdio.h> +#include <stdlib.h> #include <libirecovery.h> #include "dfu.h" +#include "recovery.h" +#include "idevicerestore.h" int dfu_check_mode() { irecv_client_t dfu = NULL; @@ -33,7 +36,7 @@ int dfu_check_mode() { return -1; } - if(dfu->mode != kDfuMode) { + if (dfu->mode != kDfuMode) { irecv_close(dfu); return -1; } @@ -43,14 +46,42 @@ int dfu_check_mode() { return 0; } -int dfu_get_cpid(uint32_t* cpid) { - return 0; -} +int dfu_enter_recovery(const char* ipsw, plist_t tss) { + irecv_client_t dfu = NULL; + const char* component = "iBSS"; + irecv_error_t dfu_error = IRECV_E_SUCCESS; + if (recovery_open_with_timeout(&dfu) < 0 || dfu->mode != kDfuMode) { + error("ERROR: Unable to connect to DFU device\n"); + if (dfu) + irecv_close(dfu); + return -1; + } -int dfu_get_bdid(uint32_t* bdid) { - return 0; -} + if (recovery_send_signed_component(dfu, ipsw, tss, "iBSS") < 0) { + error("ERROR: Unable to send %s to device\n", component); + irecv_close(dfu); + return -1; + } -int dfu_get_ecid(uint64_t* ecid) { + dfu_error = irecv_reset(dfu); + if (dfu_error != IRECV_E_SUCCESS) { + error("ERROR: Unable to reset device\n"); + irecv_close(dfu); + return -1; + } + irecv_close(dfu); + dfu = NULL; + + // Reconnect to device, but this time make sure we're not still in DFU mode + if (recovery_open_with_timeout(&dfu) < 0 || dfu->mode == kDfuMode) { + error("ERROR: Unable to connect to recovery device\n"); + if (dfu) + irecv_close(dfu); + return -1; + } + + idevicerestore_mode = RECOVERY_MODE; + irecv_close(dfu); + dfu = NULL; return 0; } |