Increase MAXTHREADS
[Rockbox.git] / rbutil / ipodpatcher / ipodio.h
blob2f106df5219b79e59ffc5d6903541ae009f0a5f8
1 /***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
10 * Copyright (C) 2006-2007 Dave Chapman
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.
15 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
16 * KIND, either express or implied.
18 ****************************************************************************/
20 #ifndef __IPODIO_H
21 #define __IPODIO_H
23 #include <stdint.h>
24 #include <unistd.h>
26 #ifdef __WIN32__
27 #include <windows.h>
28 #else
29 #define HANDLE int
30 #define O_BINARY 0
31 #endif
33 /* The maximum number of images in a firmware partition - a guess... */
34 #define MAX_IMAGES 10
36 enum firmwaretype_t {
37 FTYPE_OSOS = 0,
38 FTYPE_RSRC,
39 FTYPE_AUPD,
40 FTYPE_HIBE
43 struct ipod_directory_t {
44 enum firmwaretype_t ftype;
45 int id;
46 uint32_t devOffset; /* Offset of image relative to one sector into bootpart*/
47 uint32_t len;
48 uint32_t addr;
49 uint32_t entryOffset;
50 uint32_t chksum;
51 uint32_t vers;
52 uint32_t loadAddr;
55 /* A fake partition type - DOS partition tables can't include HFS partitions */
56 #define PARTTYPE_HFS 0xffff
58 struct partinfo_t {
59 uint32_t start; /* first sector (LBA) */
60 uint32_t size; /* number of sectors */
61 uint32_t type;
64 struct ipod_t {
65 HANDLE dh;
66 char diskname[4096];
67 int sector_size;
68 int sectors_per_track;
69 int num_heads;
70 struct ipod_directory_t ipod_directory[MAX_IMAGES];
71 int nimages;
72 off_t diroffset;
73 off_t start; /* Offset in bytes of firmware partition from start of disk */
74 off_t fwoffset; /* Offset in bytes of start of firmware images from start of disk */
75 struct partinfo_t pinfo[4];
76 int modelnum;
77 char* modelname;
78 char* modelstr;
79 char* targetname;
80 int macpod;
81 #ifdef WITH_BOOTOBJS
82 unsigned char* bootloader;
83 int bootloader_len;
84 #endif
87 void print_error(char* msg);
88 int ipod_open(struct ipod_t* ipod, int silent);
89 int ipod_reopen_rw(struct ipod_t* ipod);
90 int ipod_close(struct ipod_t* ipod);
91 int ipod_seek(struct ipod_t* ipod, unsigned long pos);
92 ssize_t ipod_read(struct ipod_t* ipod, unsigned char* buf, int nbytes);
93 ssize_t ipod_write(struct ipod_t* ipod, unsigned char* buf, int nbytes);
94 int ipod_alloc_buffer(unsigned char** sectorbuf, int bufsize);
96 /* In fat32format.c */
97 int format_partition(struct ipod_t* ipod, int partition);
99 #endif