summaryrefslogtreecommitdiff
path: root/utils/ipodpatcher/ipodio.h
diff options
context:
space:
mode:
Diffstat (limited to 'utils/ipodpatcher/ipodio.h')
-rw-r--r--utils/ipodpatcher/ipodio.h115
1 files changed, 115 insertions, 0 deletions
diff --git a/utils/ipodpatcher/ipodio.h b/utils/ipodpatcher/ipodio.h
new file mode 100644
index 0000000000..4f1a35dd09
--- /dev/null
+++ b/utils/ipodpatcher/ipodio.h
@@ -0,0 +1,115 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2006-2007 Dave Chapman
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
16 *
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
19 *
20 ****************************************************************************/
21
22#ifndef __IPODIO_H
23#define __IPODIO_H
24
25#include <stdint.h>
26#if !defined(_WIN32)
27#include <unistd.h>
28#elif defined(_MSC_VER)
29/* MSVC uses a different name for ssize_t */
30#define ssize_t SSIZE_T
31#endif
32
33#if defined(__WIN32__) || defined(_WIN32)
34#include <windows.h>
35#else
36#define HANDLE int
37#define O_BINARY 0
38#endif
39
40/* The maximum number of images in a firmware partition - a guess... */
41#define MAX_IMAGES 10
42
43enum firmwaretype_t {
44 FTYPE_OSOS = 0,
45 FTYPE_RSRC,
46 FTYPE_AUPD,
47 FTYPE_HIBE,
48 FTYPE_OSBK
49};
50
51struct ipod_directory_t {
52 enum firmwaretype_t ftype;
53 int id;
54 uint32_t devOffset; /* Offset of image relative to one sector into bootpart*/
55 uint32_t len;
56 uint32_t addr;
57 uint32_t entryOffset;
58 uint32_t chksum;
59 uint32_t vers;
60 uint32_t loadAddr;
61};
62
63/* A fake partition type - DOS partition tables can't include HFS partitions */
64#define PARTTYPE_HFS 0xffff
65
66struct partinfo_t {
67 uint32_t start; /* first sector (LBA) */
68 uint32_t size; /* number of sectors */
69 uint32_t type;
70};
71
72struct ipod_t {
73 unsigned char* sectorbuf;
74 HANDLE dh;
75 char diskname[4096];
76 int sector_size;
77 int sectors_per_track;
78 int num_heads;
79 struct ipod_directory_t ipod_directory[MAX_IMAGES];
80 int nimages;
81 int ososimage;
82 off_t diroffset;
83 off_t start; /* Offset in bytes of firmware partition from start of disk */
84 off_t fwoffset; /* Offset in bytes of start of firmware images from start of disk */
85 struct partinfo_t pinfo[4];
86 int modelnum;
87 char* modelname;
88 char* modelstr;
89 char* targetname;
90 int macpod;
91 char* xmlinfo; /* The XML Device Information (if available) */
92 int xmlinfo_len;
93 int ramsize; /* The amount of RAM in the ipod (if available) */
94#ifdef WITH_BOOTOBJS
95 unsigned char* bootloader;
96 int bootloader_len;
97#endif
98};
99
100void ipod_print_error(char* msg);
101int ipod_open(struct ipod_t* ipod, int silent);
102int ipod_reopen_rw(struct ipod_t* ipod);
103int ipod_close(struct ipod_t* ipod);
104int ipod_seek(struct ipod_t* ipod, unsigned long pos);
105int ipod_scsi_inquiry(struct ipod_t* ipod, int page_code,
106 unsigned char* buf, int bufsize);
107ssize_t ipod_read(struct ipod_t* ipod, int nbytes);
108ssize_t ipod_write(struct ipod_t* ipod, int nbytes);
109int ipod_alloc_buffer(struct ipod_t* ipod, int bufsize);
110int ipod_dealloc_buffer(struct ipod_t* ipod);
111
112/* In fat32format.c */
113int format_partition(struct ipod_t* ipod, int partition);
114
115#endif