diff options
author | Jörg Hohensohn <hohensoh@rockbox.org> | 2004-12-29 22:10:24 +0000 |
---|---|---|
committer | Jörg Hohensohn <hohensoh@rockbox.org> | 2004-12-29 22:10:24 +0000 |
commit | 1a5962f2be995b669f2cc3a49be33b3ecd8dede0 (patch) | |
tree | dd9f407265826fa02ed08cc12f9fd54a093e4ad8 /firmware/common/disk.c | |
parent | 5c631a1222c81bb075ec241621aa3626bd44c31a (diff) | |
download | rockbox-1a5962f2be995b669f2cc3a49be33b3ecd8dede0.tar.gz rockbox-1a5962f2be995b669f2cc3a49be33b3ecd8dede0.zip |
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.c | 51 |
1 files changed, 50 insertions, 1 deletions
diff --git a/firmware/common/disk.c b/firmware/common/disk.c index cfe15984f9..aa42f0793f 100644 --- a/firmware/common/disk.c +++ b/firmware/common/disk.c | |||
@@ -19,6 +19,10 @@ | |||
19 | #include <stdio.h> | 19 | #include <stdio.h> |
20 | #include "ata.h" | 20 | #include "ata.h" |
21 | #include "debug.h" | 21 | #include "debug.h" |
22 | #include "fat.h" | ||
23 | #ifdef HAVE_MMC | ||
24 | #include "ata_mmc.h" | ||
25 | #endif | ||
22 | #include "disk.h" | 26 | #include "disk.h" |
23 | 27 | ||
24 | /* Partition table entry layout: | 28 | /* Partition table entry layout: |
@@ -39,7 +43,7 @@ | |||
39 | (array[pos] | (array[pos+1] << 8 ) | \ | 43 | (array[pos] | (array[pos+1] << 8 ) | \ |
40 | (array[pos+2] << 16 ) | (array[pos+3] << 24 )) | 44 | (array[pos+2] << 16 ) | (array[pos+3] << 24 )) |
41 | 45 | ||
42 | static struct partinfo part[8]; | 46 | static struct partinfo part[8]; /* space for 4 partitions on 2 drives */ |
43 | 47 | ||
44 | struct partinfo* disk_init(IF_MV_NONVOID(int drive)) | 48 | struct partinfo* disk_init(IF_MV_NONVOID(int drive)) |
45 | { | 49 | { |
@@ -89,3 +93,48 @@ struct partinfo* disk_partinfo(int partition) | |||
89 | return &part[partition]; | 93 | return &part[partition]; |
90 | } | 94 | } |
91 | 95 | ||
96 | int disk_mount_all(void) | ||
97 | { | ||
98 | struct partinfo* pinfo; | ||
99 | int i,j; | ||
100 | int mounted = 0; | ||
101 | bool found; | ||
102 | int drives = 1; | ||
103 | #ifdef HAVE_MMC | ||
104 | if (mmc_detect()) /* for Ondio, only if card detected */ | ||
105 | { | ||
106 | drives = 2; /* in such case we have two drives to try */ | ||
107 | } | ||
108 | #endif | ||
109 | |||
110 | fat_init(); /* reset all mounted partitions */ | ||
111 | for (j=0; j<drives; j++) | ||
112 | { | ||
113 | found = false; /* reset partition-on-drive flag */ | ||
114 | pinfo = disk_init(IF_MV(j)); | ||
115 | if (pinfo == NULL) | ||
116 | { | ||
117 | continue; | ||
118 | } | ||
119 | for (i=0; mounted<NUM_VOLUMES && i<4; i++) | ||
120 | { | ||
121 | if (!fat_mount(IF_MV2(mounted,) IF_MV2(j,) pinfo[i].start)) | ||
122 | { | ||
123 | mounted++; | ||
124 | found = true; /* at least one valid entry */ | ||
125 | } | ||
126 | } | ||
127 | |||
128 | if (!found && mounted<NUM_VOLUMES) /* none of the 4 entries worked? */ | ||
129 | { /* try "superfloppy" mode */ | ||
130 | DEBUGF("No partition found, trying to mount sector 0.\n"); | ||
131 | if (!fat_mount(IF_MV2(mounted,) IF_MV2(j,) 0)) | ||
132 | { | ||
133 | mounted++; | ||
134 | } | ||
135 | } | ||
136 | } | ||
137 | |||
138 | return mounted; | ||
139 | } | ||
140 | |||