summaryrefslogtreecommitdiffstats
path: root/src/idevicerestore.h
diff options
context:
space:
mode:
authorGravatar Joshua Hill2010-06-05 18:09:06 -0400
committerGravatar Joshua Hill2010-06-05 18:09:06 -0400
commit255b285d22056dde283d33511c14387ea92e28c0 (patch)
treec039506ad319c2ec81f5a0aeb5ac4737b10d9389 /src/idevicerestore.h
parent5fe87e252c9c28a67277e21febb19027feb32372 (diff)
downloadidevicerestore-255b285d22056dde283d33511c14387ea92e28c0.tar.gz
idevicerestore-255b285d22056dde283d33511c14387ea92e28c0.tar.bz2
Changed the device type to a structure array for cleaner code and cross state access
Diffstat (limited to 'src/idevicerestore.h')
-rw-r--r--src/idevicerestore.h95
1 files changed, 54 insertions, 41 deletions
diff --git a/src/idevicerestore.h b/src/idevicerestore.h
index adea68e..af66892 100644
--- a/src/idevicerestore.h
+++ b/src/idevicerestore.h
@@ -29,60 +29,66 @@
#define error(...) fprintf(stderr, __VA_ARGS__)
#define debug(...) if(idevicerestore_debug >= 1) fprintf(stderr, __VA_ARGS__)
-#define IPHONE2G_CPID 8900
-#define IPHONE3G_CPID 8900
-#define IPHONE3GS_CPID 8920
-#define IPOD1G_CPID 8900
-#define IPOD2G_CPID 8720
-#define IPOD3G_CPID 8922
-#define IPAD1G_CPID 8930
+#define MODE_UNKNOWN -1
+#define MODE_DFU 0
+#define MODE_RECOVERY 1
+#define MODE_RESTORE 2
+#define MODE_NORMAL 3
-#define IPHONE2G_BDID 0
-#define IPHONE3G_BDID 4
-#define IPHONE3GS_BDID 0
-#define IPOD1G_BDID 2
-#define IPOD2G_BDID 0
-#define IPOD3G_BDID 2
-#define IPAD1G_BDID 2
+#define CPID_UNKNOWN -1
+#define CPID_IPHONE2G 8900
+#define CPID_IPOD1G 8900
+#define CPID_IPHONE3G 8900
+#define CPID_IPOD2G 8720
+#define CPID_IPHONE3GS 8920
+#define CPID_IPOD3G 8922
+#define CPID_IPAD1G 8930
-typedef enum {
- UNKNOWN_MODE = -1,
- DFU_MODE = 0,
- RECOVERY_MODE = 1,
- RESTORE_MODE = 2,
- NORMAL_MODE = 3,
-} idevicerestore_mode_t;
+#define BDID_UNKNOWN -1
+#define BDID_IPHONE2G 0
+#define BDID_IPOD1G 2
+#define BDID_IPHONE3G 4
+#define BDID_IPOD2G 0
+#define BDID_IPHONE3GS 0
+#define BDID_IPOD3G 2
+#define BDID_IPAD1G 2
-typedef enum {
- UNKNOWN_DEVICE = -1,
- IPHONE2G_DEVICE = 0,
- IPHONE3G_DEVICE = 1,
- IPOD1G_DEVICE = 2,
- IPOD2G_DEVICE = 3,
- IPHONE3GS_DEVICE = 4,
- IPOD3G_DEVICE = 5,
- IPAD1G_DEVICE = 6
+#define DEVICE_UNKNOWN -1
+#define DEVICE_IPHONE2G 0
+#define DEVICE_IPOD1G 1
+#define DEVICE_IPHONE3G 2
+#define DEVICE_IPOD2G 3
+#define DEVICE_IPHONE3GS 4
+#define DEVICE_IPOD3G 5
+#define DEVICE_IPAD1G 6
+
+typedef struct {
+ int device_id;
+ const char* product;
+ const char* model;
+ int board_id;
+ int chip_id;
} idevicerestore_device_t;
-static char* idevicerestore_products[] = {
- "iPhone1,1",
- "iPhone1,2",
- "iPhone2,1",
- "iPod1,1",
- "iPod2,1",
- "iPod3,1",
- "iPad1,1",
- NULL
+static idevicerestore_device_t idevicerestore_devices[] = {
+ { 0, "iPhone1,1", "M68AP", 0, 8900 },
+ { 1, "iPod1,1", "N45AP", 2, 8900 },
+ { 2, "iPhone1,2", "N82AP", 4, 8900 },
+ { 3, "iPod2,1", "N72AP", 0, 8720 },
+ { 4, "iPhone2,1", "N88AP", 0, 8920 },
+ { 5, "iPod3,1", "N18AP", 2, 8922 },
+ { 6, "iPad1,1", "K48AP", 2, 8930 },
+ { -1, NULL, NULL, -1, -1 }
};
+extern int idevicerestore_mode;
extern int idevicerestore_quit;
extern int idevicerestore_debug;
extern int idevicerestore_erase;
extern int idevicerestore_custom;
extern int idevicerestore_exclude;
extern int idevicerestore_verbose;
-extern idevicerestore_mode_t idevicerestore_mode;
-extern idevicerestore_device_t idevicerestore_device;
+extern idevicerestore_device_t* idevicerestore_device;
int check_mode(const char* uuid);
int check_device(const char* uuid);
@@ -97,5 +103,12 @@ int get_shsh_blobs(uint64_t ecid, plist_t build_identity, plist_t* tss);
int extract_filesystem(const char* ipsw, plist_t buildmanifest, char** filesystem);
int get_signed_component(char* ipsw, plist_t tss, const char* path, char** data, uint32_t* size);
+inline static void debug_plist(plist_t plist) {
+ int size = 0;
+ char* data = NULL;
+ plist_to_xml(plist, &data, &size);
+ debug("%s", data);
+ free(data);
+}
#endif