summaryrefslogtreecommitdiff
path: root/rbutil/sansapatcher
diff options
context:
space:
mode:
authorDominik Wenger <domonoky@googlemail.com>2007-05-03 20:07:57 +0000
committerDominik Wenger <domonoky@googlemail.com>2007-05-03 20:07:57 +0000
commitdde262b58a8bb908278179e916e0d91068d6987f (patch)
tree659519211ddb52e4dfd40d71187fbeb171313aa7 /rbutil/sansapatcher
parent39939bb137bea1c149db5ff0edb1dd0dd1d3d596 (diff)
downloadrockbox-dde262b58a8bb908278179e916e0d91068d6987f.tar.gz
rockbox-dde262b58a8bb908278179e916e0d91068d6987f.zip
Support for Sansa E200 in rbutil
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@13315 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'rbutil/sansapatcher')
-rw-r--r--rbutil/sansapatcher/sansaio-posix.c2
-rw-r--r--rbutil/sansapatcher/sansaio-win32.c17
-rw-r--r--rbutil/sansapatcher/sansaio.h4
-rw-r--r--rbutil/sansapatcher/sansapatcher.c18
4 files changed, 25 insertions, 16 deletions
diff --git a/rbutil/sansapatcher/sansaio-posix.c b/rbutil/sansapatcher/sansaio-posix.c
index e2b5496b32..bf72718d64 100644
--- a/rbutil/sansapatcher/sansaio-posix.c
+++ b/rbutil/sansapatcher/sansaio-posix.c
@@ -42,10 +42,12 @@
42 42
43#include "sansaio.h" 43#include "sansaio.h"
44 44
45#ifndef RBUTIL
45void print_error(char* msg) 46void print_error(char* msg)
46{ 47{
47 perror(msg); 48 perror(msg);
48} 49}
50#endif
49 51
50int sansa_open(struct sansa_t* sansa, int silent) 52int sansa_open(struct sansa_t* sansa, int silent)
51{ 53{
diff --git a/rbutil/sansapatcher/sansaio-win32.c b/rbutil/sansapatcher/sansaio-win32.c
index 7335ab614c..e9b8819f19 100644
--- a/rbutil/sansapatcher/sansaio-win32.c
+++ b/rbutil/sansapatcher/sansaio-win32.c
@@ -37,22 +37,23 @@
37 37
38#include "sansaio.h" 38#include "sansaio.h"
39 39
40static int lock_volume(HANDLE hDisk) 40static int lock_volume(HANDLE hDisk)
41{ 41{
42 DWORD dummy; 42 DWORD dummy;
43 43
44 return DeviceIoControl(hDisk, FSCTL_LOCK_VOLUME, NULL, 0, NULL, 0, 44 return DeviceIoControl(hDisk, FSCTL_LOCK_VOLUME, NULL, 0, NULL, 0,
45 &dummy, NULL); 45 &dummy, NULL);
46} 46}
47 47
48static int unlock_volume(HANDLE hDisk) 48static int unlock_volume(HANDLE hDisk)
49{ 49{
50 DWORD dummy; 50 DWORD dummy;
51 51
52 return DeviceIoControl(hDisk, FSCTL_UNLOCK_VOLUME, NULL, 0, NULL, 0, 52 return DeviceIoControl(hDisk, FSCTL_UNLOCK_VOLUME, NULL, 0, NULL, 0,
53 &dummy, NULL); 53 &dummy, NULL);
54} 54}
55 55
56#ifndef RBUTIL
56void print_error(char* msg) 57void print_error(char* msg)
57{ 58{
58 char* pMsgBuf; 59 char* pMsgBuf;
@@ -65,7 +66,7 @@ void print_error(char* msg)
65 printf(pMsgBuf); 66 printf(pMsgBuf);
66 LocalFree(pMsgBuf); 67 LocalFree(pMsgBuf);
67} 68}
68 69#endif
69int sansa_open(struct sansa_t* sansa, int silent) 70int sansa_open(struct sansa_t* sansa, int silent)
70{ 71{
71 DISK_GEOMETRY_EX diskgeometry_ex; 72 DISK_GEOMETRY_EX diskgeometry_ex;
diff --git a/rbutil/sansapatcher/sansaio.h b/rbutil/sansapatcher/sansaio.h
index f30884887c..2ef88fd384 100644
--- a/rbutil/sansapatcher/sansaio.h
+++ b/rbutil/sansapatcher/sansaio.h
@@ -38,7 +38,7 @@
38 38
39#endif 39#endif
40 40
41struct partinfo_t { 41struct sansa_partinfo_t {
42 unsigned long start; /* first sector (LBA) */ 42 unsigned long start; /* first sector (LBA) */
43 unsigned long size; /* number of sectors */ 43 unsigned long size; /* number of sectors */
44 int type; 44 int type;
@@ -57,7 +57,7 @@ struct sansa_t {
57 HANDLE dh; 57 HANDLE dh;
58 char diskname[4096]; 58 char diskname[4096];
59 int sector_size; 59 int sector_size;
60 struct partinfo_t pinfo[4]; 60 struct sansa_partinfo_t pinfo[4];
61 int hasoldbootloader; 61 int hasoldbootloader;
62 loff_t start; /* Offset in bytes of firmware partition from start of disk */ 62 loff_t start; /* Offset in bytes of firmware partition from start of disk */
63}; 63};
diff --git a/rbutil/sansapatcher/sansapatcher.c b/rbutil/sansapatcher/sansapatcher.c
index 2081e396c2..310f312052 100644
--- a/rbutil/sansapatcher/sansapatcher.c
+++ b/rbutil/sansapatcher/sansapatcher.c
@@ -28,14 +28,16 @@
28 28
29#include "sansaio.h" 29#include "sansaio.h"
30#include "sansapatcher.h" 30#include "sansapatcher.h"
31#include "bootimg.h"
32 31
32#ifndef RBUTIL
33 #include "bootimg.h"
34#endif
33/* The offset of the MI4 image header in the firmware partition */ 35/* The offset of the MI4 image header in the firmware partition */
34#define PPMI_OFFSET 0x80000 36#define PPMI_OFFSET 0x80000
35 37
36extern int verbose; 38extern int verbose;
37 39
38/* Windows requires the buffer for disk I/O to be aligned in memory on a 40/* Windows requires the buffer for disk I/O to be aligned in memory on a
39 multiple of the disk volume size - so we use a single global variable 41 multiple of the disk volume size - so we use a single global variable
40 and initialise it with sansa_alloc_buf() in main(). 42 and initialise it with sansa_alloc_buf() in main().
41*/ 43*/
@@ -369,8 +371,8 @@ int is_e200(struct sansa_t* sansa)
369 sansa->hasoldbootloader = 0; 371 sansa->hasoldbootloader = 0;
370 if (memcmp(sectorbuf+0x1f8,"RBBL",4)==0) { 372 if (memcmp(sectorbuf+0x1f8,"RBBL",4)==0) {
371 /* Look for an original firmware after the first image */ 373 /* Look for an original firmware after the first image */
372 if (sansa_seek_and_read(sansa, 374 if (sansa_seek_and_read(sansa,
373 sansa->start + PPMI_OFFSET + 0x200 + ppmi_length, 375 sansa->start + PPMI_OFFSET + 0x200 + ppmi_length,
374 sectorbuf, 512) < 0) { 376 sectorbuf, 512) < 0) {
375 return -7; 377 return -7;
376 } 378 }
@@ -461,14 +463,14 @@ static int load_original_firmware(struct sansa_t* sansa, unsigned char* buf, str
461 463
462 if (get_mi4header(buf,mi4header)==0) { 464 if (get_mi4header(buf,mi4header)==0) {
463 /* We have a valid MI4 file after a bootloader, so we use this. */ 465 /* We have a valid MI4 file after a bootloader, so we use this. */
464 if ((n = sansa_seek_and_read(sansa, 466 if ((n = sansa_seek_and_read(sansa,
465 sansa->start + PPMI_OFFSET + 0x200 + ppmi_length, 467 sansa->start + PPMI_OFFSET + 0x200 + ppmi_length,
466 buf, mi4header->mi4size)) < 0) { 468 buf, mi4header->mi4size)) < 0) {
467 return -1; 469 return -1;
468 } 470 }
469 } else { 471 } else {
470 /* No valid MI4 file, so read the first image. */ 472 /* No valid MI4 file, so read the first image. */
471 if ((n = sansa_seek_and_read(sansa, 473 if ((n = sansa_seek_and_read(sansa,
472 sansa->start + PPMI_OFFSET + 0x200, 474 sansa->start + PPMI_OFFSET + 0x200,
473 buf, ppmi_length)) < 0) { 475 buf, ppmi_length)) < 0) {
474 return -1; 476 return -1;
@@ -571,7 +573,9 @@ int sansa_add_bootloader(struct sansa_t* sansa, char* filename, int type)
571 573
572 bl_length = filesize(infile); 574 bl_length = filesize(infile);
573 } else { 575 } else {
576 #ifndef RBUTIL
574 bl_length = LEN_bootimg; 577 bl_length = LEN_bootimg;
578 #endif
575 } 579 }
576 580
577 /* Create PPMI header */ 581 /* Create PPMI header */
@@ -595,7 +599,9 @@ int sansa_add_bootloader(struct sansa_t* sansa, char* filename, int type)
595 return -1; 599 return -1;
596 } 600 }
597 } else { 601 } else {
602 #ifndef RBUTIL
598 memcpy(sectorbuf+0x200,bootimg,LEN_bootimg); 603 memcpy(sectorbuf+0x200,bootimg,LEN_bootimg);
604 #endif
599 } 605 }
600 606
601 /* Load original firmware from Sansa to the space after the bootloader */ 607 /* Load original firmware from Sansa to the space after the bootloader */