summaryrefslogtreecommitdiff
path: root/firmware/common/disk.c
diff options
context:
space:
mode:
authorJörg Hohensohn <hohensoh@rockbox.org>2004-12-29 22:10:24 +0000
committerJörg Hohensohn <hohensoh@rockbox.org>2004-12-29 22:10:24 +0000
commit1a5962f2be995b669f2cc3a49be33b3ecd8dede0 (patch)
treedd9f407265826fa02ed08cc12f9fd54a093e4ad8 /firmware/common/disk.c
parent5c631a1222c81bb075ec241621aa3626bd44c31a (diff)
downloadrockbox-1a5962f2be995b669f2cc3a49be33b3ecd8dede0.zip
rockbox-1a5962f2be995b669f2cc3a49be33b3ecd8dede0.tar.gz
rockbox-1a5962f2be995b669f2cc3a49be33b3ecd8dede0.tar.bz2
rockbox-1a5962f2be995b669f2cc3a49be33b3ecd8dede0.tar.xz
Shared mounting code, also more general. It will mount multiple HD partitions, too, once HAVE_MULTIVOLUME is enabled.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@5518 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware/common/disk.c')
-rw-r--r--firmware/common/disk.c51
1 files changed, 50 insertions, 1 deletions
diff --git a/firmware/common/disk.c b/firmware/common/disk.c
index cfe1598..aa42f07 100644
--- a/firmware/common/disk.c
+++ b/firmware/common/disk.c
@@ -19,6 +19,10 @@
#include <stdio.h>
#include "ata.h"
#include "debug.h"
+#include "fat.h"
+#ifdef HAVE_MMC
+#include "ata_mmc.h"
+#endif
#include "disk.h"
/* Partition table entry layout:
@@ -39,7 +43,7 @@
(array[pos] | (array[pos+1] << 8 ) | \
(array[pos+2] << 16 ) | (array[pos+3] << 24 ))
-static struct partinfo part[8];
+static struct partinfo part[8]; /* space for 4 partitions on 2 drives */
struct partinfo* disk_init(IF_MV_NONVOID(int drive))
{
@@ -89,3 +93,48 @@ struct partinfo* disk_partinfo(int partition)
return &part[partition];
}
+int disk_mount_all(void)
+{
+ struct partinfo* pinfo;
+ int i,j;
+ int mounted = 0;
+ bool found;
+ int drives = 1;
+#ifdef HAVE_MMC
+ if (mmc_detect()) /* for Ondio, only if card detected */
+ {
+ drives = 2; /* in such case we have two drives to try */
+ }
+#endif
+
+ fat_init(); /* reset all mounted partitions */
+ for (j=0; j<drives; j++)
+ {
+ found = false; /* reset partition-on-drive flag */
+ pinfo = disk_init(IF_MV(j));
+ if (pinfo == NULL)
+ {
+ continue;
+ }
+ for (i=0; mounted<NUM_VOLUMES && i<4; i++)
+ {
+ if (!fat_mount(IF_MV2(mounted,) IF_MV2(j,) pinfo[i].start))
+ {
+ mounted++;
+ found = true; /* at least one valid entry */
+ }
+ }
+
+ if (!found && mounted<NUM_VOLUMES) /* none of the 4 entries worked? */
+ { /* try "superfloppy" mode */
+ DEBUGF("No partition found, trying to mount sector 0.\n");
+ if (!fat_mount(IF_MV2(mounted,) IF_MV2(j,) 0))
+ {
+ mounted++;
+ }
+ }
+ }
+
+ return mounted;
+}
+