Use DBOP to check for left button on C200v2 like we are supposed to instead of right...
[kugel-rb.git] / rbutil / ipodpatcher / ipodio.h
blob6aa675535a2b1d8f0caa9547e4a2c18fde76a698
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 #include <unistd.h>
28 #ifdef __WIN32__
29 #include <windows.h>
30 #else
31 #define HANDLE int
32 #define O_BINARY 0
33 #endif
35 /* The maximum number of images in a firmware partition - a guess... */
36 #define MAX_IMAGES 10
38 enum firmwaretype_t {
39 FTYPE_OSOS = 0,
40 FTYPE_RSRC,
41 FTYPE_AUPD,
42 FTYPE_HIBE,
43 FTYPE_OSBK
46 struct ipod_directory_t {
47 enum firmwaretype_t ftype;
48 int id;
49 uint32_t devOffset; /* Offset of image relative to one sector into bootpart*/
50 uint32_t len;
51 uint32_t addr;
52 uint32_t entryOffset;
53 uint32_t chksum;
54 uint32_t vers;
55 uint32_t loadAddr;
58 /* A fake partition type - DOS partition tables can't include HFS partitions */
59 #define PARTTYPE_HFS 0xffff
61 struct partinfo_t {
62 uint32_t start; /* first sector (LBA) */
63 uint32_t size; /* number of sectors */
64 uint32_t type;
67 struct ipod_t {
68 HANDLE dh;
69 char diskname[4096];
70 int sector_size;
71 int sectors_per_track;
72 int num_heads;
73 struct ipod_directory_t ipod_directory[MAX_IMAGES];
74 int nimages;
75 int ososimage;
76 off_t diroffset;
77 off_t start; /* Offset in bytes of firmware partition from start of disk */
78 off_t fwoffset; /* Offset in bytes of start of firmware images from start of disk */
79 struct partinfo_t pinfo[4];
80 int modelnum;
81 char* modelname;
82 char* modelstr;
83 char* targetname;
84 int macpod;
85 char* xmlinfo; /* The XML Device Information (if available) */
86 int xmlinfo_len;
87 int ramsize; /* The amount of RAM in the ipod (if available) */
88 #ifdef WITH_BOOTOBJS
89 unsigned char* bootloader;
90 int bootloader_len;
91 #endif
94 void ipod_print_error(char* msg);
95 int ipod_open(struct ipod_t* ipod, int silent);
96 int ipod_reopen_rw(struct ipod_t* ipod);
97 int ipod_close(struct ipod_t* ipod);
98 int ipod_seek(struct ipod_t* ipod, unsigned long pos);
99 int ipod_scsi_inquiry(struct ipod_t* ipod, int page_code,
100 unsigned char* buf, int bufsize);
101 ssize_t ipod_read(struct ipod_t* ipod, unsigned char* buf, int nbytes);
102 ssize_t ipod_write(struct ipod_t* ipod, unsigned char* buf, int nbytes);
103 int ipod_alloc_buffer(unsigned char** sectorbuf, int bufsize);
105 /* In fat32format.c */
106 int format_partition(struct ipod_t* ipod, int partition);
108 #endif