summaryrefslogtreecommitdiff
path: root/firmware/common/disk.c
diff options
context:
space:
mode:
authorMaurus Cuelenaere <mcuelenaere@gmail.com>2008-04-24 20:08:28 +0000
committerMaurus Cuelenaere <mcuelenaere@gmail.com>2008-04-24 20:08:28 +0000
commit95167e01773dcfe8e5c1b356cfa1ea4b3a55441b (patch)
tree8b5312c5f1d1ecc8231bf8e14a1eb1678474bf8a /firmware/common/disk.c
parent46b492861152af9b91d3ab65ef0e5e14c876c3fc (diff)
downloadrockbox-95167e01773dcfe8e5c1b356cfa1ea4b3a55441b.zip
rockbox-95167e01773dcfe8e5c1b356cfa1ea4b3a55441b.tar.gz
rockbox-95167e01773dcfe8e5c1b356cfa1ea4b3a55441b.tar.bz2
rockbox-95167e01773dcfe8e5c1b356cfa1ea4b3a55441b.tar.xz
Commit whole Creative Zen Vision:M target tree + all related firmware/
changes. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@17241 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware/common/disk.c')
-rw-r--r--firmware/common/disk.c48
1 files changed, 44 insertions, 4 deletions
diff --git a/firmware/common/disk.c b/firmware/common/disk.c
index d4cfbc1..a81d57d 100644
--- a/firmware/common/disk.c
+++ b/firmware/common/disk.c
@@ -26,6 +26,7 @@
#include "file.h" /* for release_files() */
#endif
#include "disk.h"
+#include <string.h>
/* Partition table entry layout:
-----------------------
@@ -66,8 +67,8 @@ struct partinfo* disk_init(IF_MV_NONVOID(int drive))
struct partinfo* pinfo = part;
#endif
- ata_read_sectors(IF_MV2(drive,) 0,1,&sector);
-
+ ata_read_sectors(IF_MV2(drive,) 0,1, &sector);
+#ifndef CREATIVE_ZVM
/* check that the boot sector is initialized */
if ( (sector[510] != 0x55) ||
(sector[511] != 0xaa)) {
@@ -90,7 +91,46 @@ struct partinfo* disk_init(IF_MV_NONVOID(int drive))
/* not handled yet */
}
}
-
+#else
+ struct partition_struct
+ {
+ unsigned int end;
+ unsigned int start;
+ char name[8];
+ };
+ struct hdd_struct
+ {
+ unsigned char MBLK[4];
+ int sector_size;
+ long long total_disk_size;
+ struct partition_struct partitions[4];
+ };
+ struct hdd_struct* hdd_struct = (struct hdd_struct*)sector;
+
+ if(hdd_struct->MBLK[0] != 0x4B ||
+ hdd_struct->MBLK[1] != 0x4C ||
+ hdd_struct->MBLK[2] != 0x42 ||
+ hdd_struct->MBLK[3] != 0x4D) /* 0x4B4C424D = KLBM */
+ {
+ DEBUGF("Bad boot sector signature\n");
+ return NULL;
+ }
+ else
+ {
+ /* parse partitions */
+ for ( i=0; i<4; i++ ) {
+ if(hdd_struct->partitions[i].name[0] != 0)
+ {
+ pinfo[i].type = ( strcmp(hdd_struct->partitions[i].name, "cfs") == 0 ? PARTITION_TYPE_FAT32_LBA : 0);
+ pinfo[i].start = hdd_struct->partitions[i].start;
+ pinfo[i].size = (hdd_struct->partitions[i].end - hdd_struct->partitions[i].start);
+
+ DEBUGF("Part%d: Type %02x, start: %08lx size: %08lx\n",
+ i,pinfo[i].type,pinfo[i].start,pinfo[i].size);
+ }
+ }
+ }
+#endif
return pinfo;
}
@@ -147,7 +187,7 @@ int disk_mount(int drive)
{
return 0;
}
-#ifdef TOSHIBA_GIGABEAT_S
+#if defined(TOSHIBA_GIGABEAT_S) ||defined(CREATIVE_ZVM)
int i = 1; /* For the Gigabeat S, we mount the second partition */
#else
int i = 0;