summaryrefslogtreecommitdiffstats
path: root/rbutil/sansapatcher/sansaio.h
diff options
context:
space:
mode:
authorDave Chapman <dave@dchapman.com>2007-03-15 22:55:36 +0000
committerDave Chapman <dave@dchapman.com>2007-03-15 22:55:36 +0000
commite17043ead72180ffa18a3b926cbabe09b5e3f903 (patch)
tree02f708ccb7a417c3f6d1a99bd9fdd3ea2941d6c5 /rbutil/sansapatcher/sansaio.h
parenta42070df8566baa4a95fc04f2205a1e0aa240e00 (diff)
downloadrockbox-e17043ead72180ffa18a3b926cbabe09b5e3f903.tar.gz
rockbox-e17043ead72180ffa18a3b926cbabe09b5e3f903.tar.bz2
rockbox-e17043ead72180ffa18a3b926cbabe09b5e3f903.zip
Initial commit of sansapatcher - an installation tool for the Sansa E200.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@12792 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'rbutil/sansapatcher/sansaio.h')
-rw-r--r--rbutil/sansapatcher/sansaio.h74
1 files changed, 74 insertions, 0 deletions
diff --git a/rbutil/sansapatcher/sansaio.h b/rbutil/sansapatcher/sansaio.h
new file mode 100644
index 0000000000..246400c51c
--- /dev/null
+++ b/rbutil/sansapatcher/sansaio.h
@@ -0,0 +1,74 @@
+/***************************************************************************
+ * __________ __ ___.
+ * Open \______ \ ____ ____ | | _\_ |__ _______ ___
+ * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
+ * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
+ * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
+ * \/ \/ \/ \/ \/
+ * $Id: ipodio.h 12339 2007-02-16 20:45:00Z dave $
+ *
+ * Copyright (C) 2006-2007 Dave Chapman
+ *
+ * All files in this archive are subject to the GNU General Public License.
+ * See the file COPYING in the source tree root for full license agreement.
+ *
+ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
+ * KIND, either express or implied.
+ *
+ ****************************************************************************/
+
+#ifndef __SANSAIO_H
+#define __SANSAIO_H
+
+#include <stdint.h>
+#include <unistd.h>
+
+#ifdef __WIN32__
+#include <windows.h>
+#define loff_t int64_t
+#else
+#define HANDLE int
+#define O_BINARY 0
+
+/* Only Linux seems to need lseek64 and loff_t */
+#if !defined(linux) && defined (__linux)
+#define loff_t off_t
+#define lseek64 lseek
+#endif
+
+#endif
+
+struct partinfo_t {
+ unsigned long start; /* first sector (LBA) */
+ unsigned long size; /* number of sectors */
+ int type;
+};
+
+struct mi4header_t {
+ uint32_t version;
+ uint32_t length;
+ uint32_t crc32;
+ uint32_t enctype;
+ uint32_t mi4size;
+ uint32_t plaintext;
+};
+
+struct sansa_t {
+ HANDLE dh;
+ char diskname[4096];
+ int sector_size;
+ struct partinfo_t pinfo[4];
+ int hasoldbootloader;
+ loff_t start; /* Offset in bytes of firmware partition from start of disk */
+};
+
+void print_error(char* msg);
+int sansa_open(struct sansa_t* sansa, int silent);
+int sansa_reopen_rw(struct sansa_t* sansa);
+int sansa_close(struct sansa_t* sansa);
+int sansa_seek(struct sansa_t* sansa, loff_t pos);
+int sansa_read(struct sansa_t* sansa, unsigned char* buf, int nbytes);
+int sansa_write(struct sansa_t* sansa, unsigned char* buf, int nbytes);
+int sansa_alloc_buffer(unsigned char** sectorbuf, int bufsize);
+
+#endif