The threading model should be set from configure, not config.h.
[maemo-rb.git] / rbutil / ipodpatcher / ipodio.h
blobe08d74a78548435cb01b2aab7cbdc8bc0a2b22c2
1 /***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
10 * Copyright (C) 2006-2007 Dave Chapman
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.
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
20 ****************************************************************************/
22 #ifndef __IPODIO_H
23 #define __IPODIO_H
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
33 #if defined(__WIN32__) || defined(_WIN32)
34 #include <windows.h>
35 #else
36 #define HANDLE int
37 #define O_BINARY 0
38 #endif
40 /* The maximum number of images in a firmware partition - a guess... */
41 #define MAX_IMAGES 10
43 enum firmwaretype_t {
44 FTYPE_OSOS = 0,
45 FTYPE_RSRC,
46 FTYPE_AUPD,
47 FTYPE_HIBE,
48 FTYPE_OSBK
51 struct 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;
63 /* A fake partition type - DOS partition tables can't include HFS partitions */
64 #define PARTTYPE_HFS 0xffff
66 struct partinfo_t {
67 uint32_t start; /* first sector (LBA) */
68 uint32_t size; /* number of sectors */
69 uint32_t type;
72 struct ipod_t {
73 HANDLE dh;
74 char diskname[4096];
75 int sector_size;
76 int sectors_per_track;
77 int num_heads;
78 struct ipod_directory_t ipod_directory[MAX_IMAGES];
79 int nimages;
80 int ososimage;
81 off_t diroffset;
82 off_t start; /* Offset in bytes of firmware partition from start of disk */
83 off_t fwoffset; /* Offset in bytes of start of firmware images from start of disk */
84 struct partinfo_t pinfo[4];
85 int modelnum;
86 char* modelname;
87 char* modelstr;
88 char* targetname;
89 int macpod;
90 char* xmlinfo; /* The XML Device Information (if available) */
91 int xmlinfo_len;
92 int ramsize; /* The amount of RAM in the ipod (if available) */
93 #ifdef WITH_BOOTOBJS
94 unsigned char* bootloader;
95 int bootloader_len;
96 #endif
99 void ipod_print_error(char* msg);
100 int ipod_open(struct ipod_t* ipod, int silent);
101 int ipod_reopen_rw(struct ipod_t* ipod);
102 int ipod_close(struct ipod_t* ipod);
103 int ipod_seek(struct ipod_t* ipod, unsigned long pos);
104 int ipod_scsi_inquiry(struct ipod_t* ipod, int page_code,
105 unsigned char* buf, int bufsize);
106 ssize_t ipod_read(struct ipod_t* ipod, unsigned char* buf, int nbytes);
107 ssize_t ipod_write(struct ipod_t* ipod, unsigned char* buf, int nbytes);
108 int ipod_alloc_buffer(unsigned char** sectorbuf, int bufsize);
110 /* In fat32format.c */
111 int format_partition(struct ipod_t* ipod, int partition);
113 #endif