diff options
Diffstat (limited to 'firmware/export')
-rw-r--r-- | firmware/export/config.h | 5 | ||||
-rw-r--r-- | firmware/export/mmc.h | 1 | ||||
-rw-r--r-- | firmware/export/storage.h | 356 |
3 files changed, 152 insertions, 210 deletions
diff --git a/firmware/export/config.h b/firmware/export/config.h index 22a0bd2244..1574d40040 100644 --- a/firmware/export/config.h +++ b/firmware/export/config.h | |||
@@ -383,6 +383,11 @@ | |||
383 | #define CONFIG_TUNER_MULTI | 383 | #define CONFIG_TUNER_MULTI |
384 | #endif | 384 | #endif |
385 | 385 | ||
386 | #if (CONFIG_STORAGE & (CONFIG_STORAGE - 1)) != 0 | ||
387 | /* Multiple storage drivers */ | ||
388 | #define CONFIG_STORAGE_MULTI | ||
389 | #endif | ||
390 | |||
386 | #if defined(BOOTLOADER) && defined(HAVE_ADJUSTABLE_CPU_FREQ) | 391 | #if defined(BOOTLOADER) && defined(HAVE_ADJUSTABLE_CPU_FREQ) |
387 | /* Bootloaders don't use CPU frequency adjustment */ | 392 | /* Bootloaders don't use CPU frequency adjustment */ |
388 | #undef HAVE_ADJUSTABLE_CPU_FREQ | 393 | #undef HAVE_ADJUSTABLE_CPU_FREQ |
diff --git a/firmware/export/mmc.h b/firmware/export/mmc.h index 271d910763..5d6438ec28 100644 --- a/firmware/export/mmc.h +++ b/firmware/export/mmc.h | |||
@@ -39,6 +39,7 @@ void mmc_close(void); | |||
39 | int mmc_read_sectors(IF_MV2(int drive,) unsigned long start, int count, void* buf); | 39 | int mmc_read_sectors(IF_MV2(int drive,) unsigned long start, int count, void* buf); |
40 | int mmc_write_sectors(IF_MV2(int drive,) unsigned long start, int count, const void* buf); | 40 | int mmc_write_sectors(IF_MV2(int drive,) unsigned long start, int count, const void* buf); |
41 | void mmc_spin(void); | 41 | void mmc_spin(void); |
42 | int mmc_spinup_time(void); | ||
42 | 43 | ||
43 | #if (CONFIG_LED == LED_REAL) | 44 | #if (CONFIG_LED == LED_REAL) |
44 | void mmc_set_led_enabled(bool enabled); | 45 | void mmc_set_led_enabled(bool enabled); |
diff --git a/firmware/export/storage.h b/firmware/export/storage.h index 52c6f2bed1..3c2a0e858e 100644 --- a/firmware/export/storage.h +++ b/firmware/export/storage.h | |||
@@ -48,204 +48,133 @@ struct storage_info | |||
48 | char *revision; | 48 | char *revision; |
49 | }; | 49 | }; |
50 | 50 | ||
51 | void storage_spindown(int seconds); | ||
52 | |||
53 | #ifndef SIMULATOR | 51 | #ifndef SIMULATOR |
54 | static inline void storage_enable(bool on) | 52 | #ifndef CONFIG_STORAGE_MULTI |
55 | { | 53 | /* storage_spindown, storage_sleep and storage_spin are passed as |
56 | #if (CONFIG_STORAGE & STORAGE_ATA) | 54 | * pointers, which doesn't work with argument-macros. |
57 | ata_enable(on); | 55 | */ |
58 | #elif (CONFIG_STORAGE & STORAGE_SD) | 56 | #if (CONFIG_STORAGE & STORAGE_ATA) |
59 | sd_enable(on); | 57 | #define storage_spindown ata_spindown |
60 | #elif (CONFIG_STORAGE & STORAGE_MMC) | 58 | #define storage_sleep ata_sleep |
61 | mmc_enable(on); | 59 | #define storage_spin ata_spin |
62 | #else | 60 | |
63 | (void)on; | 61 | #define storage_enable(on) ata_enable(on) |
64 | #endif | 62 | #define storage_sleepnow() ata_sleepnow() |
65 | } | 63 | #define storage_disk_is_active() ata_disk_is_active() |
66 | static inline void storage_sleep(void) | 64 | #define storage_hard_reset() ata_hard_reset() |
67 | { | 65 | #define storage_soft_reset() ata_soft_reset() |
68 | #if (CONFIG_STORAGE & STORAGE_ATA) | 66 | #define storage_init() ata_init() |
69 | ata_sleep(); | 67 | #define storage_close() ata_close() |
70 | #endif | 68 | #define storage_read_sectors(drive, start, count, buf) ata_read_sectors(IF_MV2(drive,) start, count, buf) |
71 | } | 69 | #define storage_write_sectors(drive, start, count, buf) ata_write_sectors(IF_MV2(drive,) start, count, buf) |
72 | static inline void storage_sleepnow(void) | 70 | #define storage_last_disk_activity() ata_last_disk_activity() |
73 | { | 71 | #define storage_spinup_time() ata_spinup_time() |
74 | #if (CONFIG_STORAGE & STORAGE_ATA) | 72 | #define storage_get_identify() ata_get_identify() |
75 | ata_sleepnow(); | 73 | |
76 | #endif | 74 | #if (CONFIG_LED == LED_REAL) |
77 | } | 75 | #define storage_set_led_enabled(enabled) ata_set_led_enabled(enabled) |
78 | static inline bool storage_disk_is_active(void) | 76 | #endif |
79 | { | 77 | #ifdef STORAGE_GET_INFO |
80 | #if (CONFIG_STORAGE & STORAGE_ATA) | 78 | #define storage_get_info(drive, info) ata_get_info(IF_MV2(drive,) info) |
81 | return ata_disk_is_active(); | 79 | #endif |
82 | #elif (CONFIG_STORAGE & STORAGE_MMC) | 80 | #ifdef HAVE_HOTSWAP |
83 | return mmc_disk_is_active(); | 81 | #define storage_removable(drive) ata_removable(IF_MV(drive)) |
84 | #else | 82 | #define storage_present(drive) ata_present(IF_MV(drive)) |
85 | return 0; | 83 | #endif |
86 | #endif | 84 | #elif (CONFIG_STORAGE & STORAGE_SD) |
87 | } | 85 | #define storage_spindown sd_spindown |
88 | static inline int storage_hard_reset(void) | 86 | #define storage_sleep sd_sleep |
89 | { | 87 | #define storage_spin sd_spin |
90 | #if (CONFIG_STORAGE & STORAGE_ATA) | 88 | |
91 | return ata_hard_reset(); | 89 | #define storage_enable(on) sd_enable(on) |
92 | #else | 90 | #define storage_sleepnow() sd_sleepnow() |
93 | return 0; | 91 | #define storage_disk_is_active() 0 |
94 | #endif | 92 | #define storage_hard_reset() (void)0 |
95 | } | 93 | #define storage_soft_reset() (void)0 |
96 | static inline int storage_soft_reset(void) | 94 | #define storage_init() sd_init() |
97 | { | 95 | #define storage_close() sd_close() |
98 | #if (CONFIG_STORAGE & STORAGE_ATA) | 96 | #define storage_read_sectors(drive, start, count, buf) sd_read_sectors(IF_MV2(drive,) start, count, buf) |
99 | return ata_soft_reset(); | 97 | #define storage_write_sectors(drive, start, count, buf) sd_write_sectors(IF_MV2(drive,) start, count, buf) |
100 | #else | 98 | #define storage_last_disk_activity() sd_last_disk_activity() |
101 | return 0; | 99 | #define storage_spinup_time() 0 |
102 | #endif | 100 | #define storage_get_identify() sd_get_identify() |
103 | } | 101 | |
104 | static inline int storage_init(void) | 102 | #if (CONFIG_LED == LED_REAL) |
105 | { | 103 | #define storage_set_led_enabled(enabled) sd_set_led_enabled(enabled) |
106 | #if (CONFIG_STORAGE & STORAGE_ATA) | 104 | #endif |
107 | return ata_init(); | 105 | #ifdef STORAGE_GET_INFO |
108 | #elif (CONFIG_STORAGE & STORAGE_SD) | 106 | #define storage_get_info(drive, info) sd_get_info(IF_MV2(drive,) info) |
109 | return sd_init(); | 107 | #endif |
110 | #elif (CONFIG_STORAGE & STORAGE_NAND) | 108 | #ifdef HAVE_HOTSWAP |
111 | return nand_init(); | 109 | #define storage_removable(drive) sd_removable(IF_MV(drive)) |
112 | #elif (CONFIG_STORAGE & STORAGE_MMC) | 110 | #define storage_present(drive) sd_present(IF_MV(drive)) |
113 | return mmc_init(); | 111 | #endif |
114 | #else | 112 | #elif (CONFIG_STORAGE & STORAGE_MMC) |
115 | #error No storage driver! | 113 | #define storage_spindown mmc_spindown |
116 | #endif | 114 | #define storage_sleep mmc_sleep |
117 | } | 115 | #define storage_spin mmc_spin |
118 | static inline void storage_close(void) | 116 | |
119 | { | 117 | #define storage_enable(on) mmc_enable(on) |
120 | #if (CONFIG_STORAGE & STORAGE_ATA) | 118 | #define storage_sleepnow() mmc_sleepnow() |
121 | ata_close(); | 119 | #define storage_disk_is_active() mmc_disk_is_active() |
122 | #endif | 120 | #define storage_hard_reset() (void)0 |
123 | } | 121 | #define storage_soft_reset() (void)0 |
124 | static inline int storage_read_sectors(IF_MV2(int drive,) unsigned long start, int count, void* buf) | 122 | #define storage_init() mmc_init() |
125 | { | 123 | #define storage_close() mmc_close() |
126 | #if (CONFIG_STORAGE & STORAGE_ATA) | 124 | #define storage_read_sectors(drive, start, count, buf) mmc_read_sectors(IF_MV2(drive,) start, count, buf) |
127 | return ata_read_sectors(IF_MV2(drive,) start, count, buf); | 125 | #define storage_write_sectors(drive, start, count, buf) mmc_write_sectors(IF_MV2(drive,) start, count, buf) |
128 | #elif (CONFIG_STORAGE & STORAGE_SD) | 126 | #define storage_last_disk_activity() mmc_last_disk_activity() |
129 | return sd_read_sectors(IF_MV2(drive,) start, count, buf); | 127 | #define storage_spinup_time() 0 |
130 | #elif (CONFIG_STORAGE & STORAGE_NAND) | 128 | #define storage_get_identify() mmc_get_identify() |
131 | return nand_read_sectors(IF_MV2(drive,) start, count, buf); | 129 | |
132 | #elif (CONFIG_STORAGE & STORAGE_MMC) | 130 | #if (CONFIG_LED == LED_REAL) |
133 | return mmc_read_sectors(IF_MV2(drive,) start, count, buf); | 131 | #define storage_set_led_enabled(enabled) mmc_set_led_enabled(enabled) |
134 | #else | 132 | #endif |
135 | #error No storage driver! | 133 | #ifdef STORAGE_GET_INFO |
136 | #endif | 134 | #define storage_get_info(drive, info) mmc_get_info(IF_MV2(drive,) info) |
137 | } | 135 | #endif |
138 | static inline int storage_write_sectors(IF_MV2(int drive,) unsigned long start, int count, const void* buf) | 136 | #ifdef HAVE_HOTSWAP |
139 | { | 137 | #define storage_removable(drive) mmc_removable(IF_MV(drive)) |
140 | #if (CONFIG_STORAGE & STORAGE_ATA) | 138 | #define storage_present(drive) mmc_present(IF_MV(drive)) |
141 | return ata_write_sectors(IF_MV2(drive,) start, count, buf); | 139 | #endif |
142 | #elif (CONFIG_STORAGE & STORAGE_SD) | 140 | #elif (CONFIG_STORAGE & STORAGE_NAND) |
143 | return sd_write_sectors(IF_MV2(drive,) start, count, buf); | 141 | #define storage_spindown nand_spindown |
144 | #elif (CONFIG_STORAGE & STORAGE_NAND) | 142 | #define storage_sleep nand_sleep |
145 | return nand_write_sectors(IF_MV2(drive,) start, count, buf); | 143 | #define storage_spin nand_spin |
146 | #elif (CONFIG_STORAGE & STORAGE_MMC) | 144 | |
147 | return mmc_write_sectors(IF_MV2(drive,) start, count, buf); | 145 | #define storage_enable(on) (void)0 |
148 | #else | 146 | #define storage_sleepnow() nand_sleepnow() |
149 | #error No storage driver! | 147 | #define storage_disk_is_active() 0 |
150 | #endif | 148 | #define storage_hard_reset() (void)0 |
151 | } | 149 | #define storage_soft_reset() (void)0 |
152 | static inline void storage_spin(void) | 150 | #define storage_init() nand_init() |
153 | { | 151 | #define storage_close() nand_close() |
154 | #if (CONFIG_STORAGE & STORAGE_ATA) | 152 | #define storage_read_sectors(drive, start, count, buf) nand_read_sectors(IF_MV2(drive,) start, count, buf) |
155 | ata_spin(); | 153 | #define storage_write_sectors(drive, start, count, buf) nand_write_sectors(IF_MV2(drive,) start, count, buf) |
156 | #endif | 154 | #define storage_last_disk_activity() nand_last_disk_activity() |
157 | } | 155 | #define storage_spinup_time() 0 |
158 | 156 | #define storage_get_identify() nand_get_identify() | |
159 | #if (CONFIG_LED == LED_REAL) | 157 | |
160 | static inline void storage_set_led_enabled(bool enabled) | 158 | #if (CONFIG_LED == LED_REAL) |
161 | { | 159 | #define storage_set_led_enabled(enabled) nand_set_led_enabled(enabled) |
162 | #if (CONFIG_STORAGE & STORAGE_ATA) | 160 | #endif |
163 | ata_set_led_enabled(enabled); | 161 | #ifdef STORAGE_GET_INFO |
164 | #elif (CONFIG_STORAGE & STORAGE_SD) | 162 | #define storage_get_info(drive, info) nand_get_info(IF_MV2(drive,) info) |
165 | sd_set_led_enabled(enabled); | 163 | #endif |
166 | #elif (CONFIG_STORAGE & STORAGE_NAND) | 164 | #ifdef HAVE_HOTSWAP |
167 | nand_set_led_enabled(enabled); | 165 | #define storage_removable(drive) nand_removable(IF_MV(drive)) |
168 | #elif (CONFIG_STORAGE & STORAGE_MMC) | 166 | #define storage_present(drive) nand_present(IF_MV(drive)) |
169 | mmc_set_led_enabled(enabled); | 167 | #endif |
170 | #else | 168 | #else |
171 | #error No storage driver! | 169 | //#error No storage driver! |
172 | #endif | 170 | #endif |
173 | } | 171 | #else /* NOT CONFIG_STORAGE_MULTI */ |
174 | #endif /*LED*/ | 172 | |
175 | 173 | /* TODO : implement multi-driver here */ | |
176 | static inline long storage_last_disk_activity(void) | 174 | #error Multi-driver storage not implemented yet |
177 | { | 175 | |
178 | #if (CONFIG_STORAGE & STORAGE_ATA) | 176 | #endif /* NOT CONFIG_STORAGE_MULTI */ |
179 | return ata_last_disk_activity(); | 177 | #else /*NOT SIMULATOR */ |
180 | #elif (CONFIG_STORAGE & STORAGE_SD) | ||
181 | return sd_last_disk_activity(); | ||
182 | #elif (CONFIG_STORAGE & STORAGE_NAND) | ||
183 | return nand_last_disk_activity(); | ||
184 | #elif (CONFIG_STORAGE & STORAGE_MMC) | ||
185 | return mmc_last_disk_activity(); | ||
186 | #else | ||
187 | #error No storage driver! | ||
188 | #endif | ||
189 | } | ||
190 | |||
191 | static inline int storage_spinup_time(void) | ||
192 | { | ||
193 | #if (CONFIG_STORAGE & STORAGE_ATA) | ||
194 | return ata_spinup_time(); | ||
195 | #else | ||
196 | return 0; | ||
197 | #endif | ||
198 | } | ||
199 | |||
200 | #ifdef STORAGE_GET_INFO | ||
201 | static inline void storage_get_info(IF_MV2(int drive,) struct storage_info *info) | ||
202 | { | ||
203 | #if (CONFIG_STORAGE & STORAGE_ATA) | ||
204 | return ata_get_info(IF_MV2(drive,) info); | ||
205 | #elif (CONFIG_STORAGE & STORAGE_SD) | ||
206 | return sd_get_info(IF_MV2(drive,) info); | ||
207 | #elif (CONFIG_STORAGE & STORAGE_NAND) | ||
208 | return nand_get_info(IF_MV2(drive,) info); | ||
209 | #elif (CONFIG_STORAGE & STORAGE_MMC) | ||
210 | return mmc_get_info(IF_MV2(drive,) info); | ||
211 | #else | ||
212 | #error No storage driver! | ||
213 | #endif | ||
214 | } | ||
215 | #endif | ||
216 | |||
217 | #ifdef HAVE_HOTSWAP | ||
218 | static inline bool storage_removable(IF_MV_NONVOID(int drive)) | ||
219 | { | ||
220 | #if (CONFIG_STORAGE & STORAGE_ATA) | ||
221 | return ata_removable(IF_MV(drive)); | ||
222 | #elif (CONFIG_STORAGE & STORAGE_SD) | ||
223 | return sd_removable(IF_MV(drive)); | ||
224 | #elif (CONFIG_STORAGE & STORAGE_NAND) | ||
225 | return nand_removable(IF_MV(drive)); | ||
226 | #elif (CONFIG_STORAGE & STORAGE_MMC) | ||
227 | return mmc_removable(IF_MV(drive)); | ||
228 | #else | ||
229 | #error No storage driver! | ||
230 | #endif | ||
231 | } | ||
232 | |||
233 | static inline bool storage_present(IF_MV_NONVOID(int drive)) | ||
234 | { | ||
235 | #if (CONFIG_STORAGE & STORAGE_ATA) | ||
236 | return ata_present(IF_MV(drive)); | ||
237 | #elif (CONFIG_STORAGE & STORAGE_SD) | ||
238 | return sd_present(IF_MV(drive)); | ||
239 | #elif (CONFIG_STORAGE & STORAGE_NAND) | ||
240 | return nand_present(IF_MV(drive)); | ||
241 | #elif (CONFIG_STORAGE & STORAGE_MMC) | ||
242 | return mmc_present(IF_MV(drive)); | ||
243 | #else | ||
244 | #error No storage driver! | ||
245 | #endif | ||
246 | } | ||
247 | #endif /* HOTSWAP */ | ||
248 | #else /* SIMULATOR */ | ||
249 | static inline void storage_enable(bool on) | 178 | static inline void storage_enable(bool on) |
250 | { | 179 | { |
251 | (void)on; | 180 | (void)on; |
@@ -275,26 +204,31 @@ static inline int storage_init(void) | |||
275 | static inline void storage_close(void) | 204 | static inline void storage_close(void) |
276 | { | 205 | { |
277 | } | 206 | } |
278 | static inline int storage_read_sectors(IF_MV2(int drive,) unsigned long start, int count, void* buf) | 207 | static inline int storage_read_sectors(int drive, unsigned long start, int count, void* buf) |
279 | { | 208 | { |
280 | IF_MV((void)drive;) | 209 | (void)drive; |
281 | (void)start; | 210 | (void)start; |
282 | (void)count; | 211 | (void)count; |
283 | (void)buf; | 212 | (void)buf; |
284 | return 0; | 213 | return 0; |
285 | } | 214 | } |
286 | static inline int storage_write_sectors(IF_MV2(int drive,) unsigned long start, int count, const void* buf) | 215 | static inline int storage_write_sectors(int drive, unsigned long start, int count, const void* buf) |
287 | { | 216 | { |
288 | IF_MV((void)drive;) | 217 | (void)drive; |
289 | (void)start; | 218 | (void)start; |
290 | (void)count; | 219 | (void)count; |
291 | (void)buf; | 220 | (void)buf; |
292 | return 0; | 221 | return 0; |
293 | } | 222 | } |
223 | |||
294 | static inline void storage_spin(void) | 224 | static inline void storage_spin(void) |
295 | { | 225 | { |
296 | } | 226 | } |
297 | 227 | static inline void storage_spindown(int seconds) | |
228 | { | ||
229 | (void)seconds; | ||
230 | } | ||
231 | |||
298 | #if (CONFIG_LED == LED_REAL) | 232 | #if (CONFIG_LED == LED_REAL) |
299 | static inline void storage_set_led_enabled(bool enabled) | 233 | static inline void storage_set_led_enabled(bool enabled) |
300 | { | 234 | { |
@@ -313,25 +247,27 @@ static inline int storage_spinup_time(void) | |||
313 | } | 247 | } |
314 | 248 | ||
315 | #ifdef STORAGE_GET_INFO | 249 | #ifdef STORAGE_GET_INFO |
316 | static inline void storage_get_info(IF_MV2(int drive,) struct storage_info *info) | 250 | static inline void storage_get_info(int drive, struct storage_info *info) |
317 | { | 251 | { |
318 | IF_MV((void)drive;) | 252 | (void)drive; |
319 | (void)info; | 253 | (void)info; |
320 | } | 254 | } |
321 | #endif | 255 | +#endif /* NOT CONFIG_STORAGE_MULTI */ |
256 | #endif | ||
322 | 257 | ||
323 | #ifdef HAVE_HOTSWAP | 258 | #ifdef HAVE_HOTSWAP |
324 | static inline bool storage_removable(IF_MV_NONVOID(int drive)) | 259 | static inline bool storage_removable(int drive) |
325 | { | 260 | { |
326 | IF_MV((void)drive;) | 261 | (void)drive; |
327 | return 0; | 262 | return 0; |
328 | } | 263 | } |
329 | 264 | ||
330 | static inline bool storage_present(IF_MV_NONVOID(int drive)) | 265 | static inline bool storage_present(int drive) |
331 | { | 266 | { |
332 | IF_MV((void)drive;) | 267 | (void)drive; |
333 | return 0; | 268 | return 0; |
334 | } | 269 | } |
335 | #endif /* HOTSWAP */ | 270 | #endif /* HOTSWAP */ |
336 | #endif /* SIMULATOR */ | 271 | |
272 | #endif/*NOT SIMULATOR */ | ||
337 | #endif | 273 | #endif |