summaryrefslogtreecommitdiff
path: root/rbutil/ipodpatcher/ipodio.h
diff options
context:
space:
mode:
Diffstat (limited to 'rbutil/ipodpatcher/ipodio.h')
-rw-r--r--rbutil/ipodpatcher/ipodio.h89
1 files changed, 89 insertions, 0 deletions
diff --git a/rbutil/ipodpatcher/ipodio.h b/rbutil/ipodpatcher/ipodio.h
new file mode 100644
index 0000000000..d0641faa2b
--- /dev/null
+++ b/rbutil/ipodpatcher/ipodio.h
@@ -0,0 +1,89 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2006-2007 Dave Chapman
11 *
12 * All files in this archive are subject to the GNU General Public License.
13 * See the file COPYING in the source tree root for full license agreement.
14 *
15 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
16 * KIND, either express or implied.
17 *
18 ****************************************************************************/
19
20#ifndef __IPODIO_H
21#define __IPODIO_H
22
23#include <stdint.h>
24
25#ifdef __WIN32__
26#include <windows.h>
27#else
28#define HANDLE int
29#define O_BINARY 0
30#endif
31
32/* The maximum number of images in a firmware partition - a guess... */
33#define MAX_IMAGES 10
34
35enum firmwaretype_t {
36 FTYPE_OSOS = 0,
37 FTYPE_RSRC,
38 FTYPE_AUPD,
39 FTYPE_HIBE
40};
41
42struct ipod_directory_t {
43 enum firmwaretype_t ftype;
44 int id;
45 uint32_t devOffset; /* Offset of image relative to one sector into bootpart*/
46 uint32_t len;
47 uint32_t addr;
48 uint32_t entryOffset;
49 uint32_t chksum;
50 uint32_t vers;
51 uint32_t loadAddr;
52};
53
54struct partinfo_t {
55 unsigned long start; /* first sector (LBA) */
56 unsigned long size; /* number of sectors */
57 int type;
58};
59
60struct ipod_t {
61 HANDLE dh;
62 char diskname[4096];
63 int sector_size;
64 struct ipod_directory_t ipod_directory[MAX_IMAGES];
65 int nimages;
66 off_t diroffset;
67 off_t start; /* Offset in bytes of firmware partition from start of disk */
68 off_t fwoffset; /* Offset in bytes of start of firmware images from start of disk */
69 struct partinfo_t pinfo[4];
70 int modelnum;
71 char* modelname;
72 char* modelstr;
73 int macpod;
74#ifdef WITH_BOOTOBJS
75 unsigned char* bootloader;
76 int bootloader_len;
77#endif
78};
79
80void print_error(char* msg);
81int ipod_open(struct ipod_t* ipod, int silent);
82int ipod_reopen_rw(struct ipod_t* ipod);
83int ipod_close(struct ipod_t* ipod);
84int ipod_seek(struct ipod_t* ipod, unsigned long pos);
85int ipod_read(struct ipod_t* ipod, unsigned char* buf, int nbytes);
86int ipod_write(struct ipod_t* ipod, unsigned char* buf, int nbytes);
87int ipod_alloc_buffer(unsigned char** sectorbuf, int bufsize);
88
89#endif