summaryrefslogtreecommitdiff
path: root/firmware/export
diff options
context:
space:
mode:
Diffstat (limited to 'firmware/export')
-rw-r--r--firmware/export/ata.h14
-rw-r--r--firmware/export/config-c200.h3
-rw-r--r--firmware/export/config-e200.h3
-rw-r--r--firmware/export/config-e200v2.h3
-rw-r--r--firmware/export/config-fuze.h3
-rw-r--r--firmware/export/config-ondavx747.h6
-rw-r--r--firmware/export/config-ondavx767.h3
-rw-r--r--firmware/export/config-ondiofm.h3
-rw-r--r--firmware/export/config-ondiosp.h3
-rw-r--r--firmware/export/config.h36
-rw-r--r--firmware/export/disk.h2
-rw-r--r--firmware/export/fat.h2
-rw-r--r--firmware/export/mmc.h17
-rw-r--r--firmware/export/mv.h18
-rw-r--r--firmware/export/nand.h18
-rw-r--r--firmware/export/ramdisk.h13
-rw-r--r--firmware/export/sd.h23
-rw-r--r--firmware/export/storage.h270
18 files changed, 254 insertions, 186 deletions
diff --git a/firmware/export/ata.h b/firmware/export/ata.h
index b5e39de3aa..5be32da231 100644
--- a/firmware/export/ata.h
+++ b/firmware/export/ata.h
@@ -39,8 +39,8 @@ bool ata_disk_is_active(void);
39int ata_soft_reset(void); 39int ata_soft_reset(void);
40int ata_init(void); 40int ata_init(void);
41void ata_close(void); 41void ata_close(void);
42int ata_read_sectors(IF_MV2(int drive,) unsigned long start, int count, void* buf); 42int ata_read_sectors(IF_MD2(int drive,) unsigned long start, int count, void* buf);
43int ata_write_sectors(IF_MV2(int drive,) unsigned long start, int count, const void* buf); 43int ata_write_sectors(IF_MD2(int drive,) unsigned long start, int count, const void* buf);
44void ata_spin(void); 44void ata_spin(void);
45#if (CONFIG_LED == LED_REAL) 45#if (CONFIG_LED == LED_REAL)
46void ata_set_led_enabled(bool enabled); 46void ata_set_led_enabled(bool enabled);
@@ -48,14 +48,18 @@ void ata_set_led_enabled(bool enabled);
48unsigned short* ata_get_identify(void); 48unsigned short* ata_get_identify(void);
49 49
50#ifdef STORAGE_GET_INFO 50#ifdef STORAGE_GET_INFO
51void ata_get_info(IF_MV2(int drive,) struct storage_info *info); 51void ata_get_info(IF_MD2(int drive,) struct storage_info *info);
52#endif 52#endif
53#ifdef HAVE_HOTSWAP 53#ifdef HAVE_HOTSWAP
54bool ata_removable(IF_MV_NONVOID(int drive)); 54bool ata_removable(IF_MD_NONVOID(int drive));
55bool ata_present(IF_MV_NONVOID(int drive)); 55bool ata_present(IF_MD_NONVOID(int drive));
56#endif 56#endif
57 57
58 58
59#ifdef CONFIG_STORAGE_MULTI
60int ata_num_drives(int first_drive);
61#endif
62
59 63
60long ata_last_disk_activity(void); 64long ata_last_disk_activity(void);
61int ata_spinup_time(void); /* ticks */ 65int ata_spinup_time(void); /* ticks */
diff --git a/firmware/export/config-c200.h b/firmware/export/config-c200.h
index 9bb8ead4a8..db64e5cacc 100644
--- a/firmware/export/config-c200.h
+++ b/firmware/export/config-c200.h
@@ -177,7 +177,8 @@
177#define FIRMWARE_OFFSET_FILE_DATA 0x8 177#define FIRMWARE_OFFSET_FILE_DATA 0x8
178 178
179#ifndef BOOTLOADER 179#ifndef BOOTLOADER
180#define HAVE_MULTIVOLUME 180#define HAVE_MULTIDRIVE
181#define NUM_DRIVES 2
181#define HAVE_HOTSWAP 182#define HAVE_HOTSWAP
182#endif 183#endif
183 184
diff --git a/firmware/export/config-e200.h b/firmware/export/config-e200.h
index 59ac564c01..adae8a211d 100644
--- a/firmware/export/config-e200.h
+++ b/firmware/export/config-e200.h
@@ -171,7 +171,8 @@
171#define FIRMWARE_OFFSET_FILE_DATA 0x8 171#define FIRMWARE_OFFSET_FILE_DATA 0x8
172 172
173#ifndef BOOTLOADER 173#ifndef BOOTLOADER
174#define HAVE_MULTIVOLUME 174#define HAVE_MULTIDRIVE
175#define NUM_DRIVES 2
175#define HAVE_HOTSWAP 176#define HAVE_HOTSWAP
176#endif 177#endif
177 178
diff --git a/firmware/export/config-e200v2.h b/firmware/export/config-e200v2.h
index a1c41fbe7d..d66bde4943 100644
--- a/firmware/export/config-e200v2.h
+++ b/firmware/export/config-e200v2.h
@@ -180,7 +180,8 @@
180#define FIRMWARE_OFFSET_FILE_DATA 0x8 180#define FIRMWARE_OFFSET_FILE_DATA 0x8
181 181
182#ifndef BOOTLOADER 182#ifndef BOOTLOADER
183#define HAVE_MULTIVOLUME 183#define HAVE_MULTIDRIVE
184#define NUM_DRIVES 2
184#define HAVE_HOTSWAP 185#define HAVE_HOTSWAP
185#endif 186#endif
186 187
diff --git a/firmware/export/config-fuze.h b/firmware/export/config-fuze.h
index b9c5acb9b1..c8d7e2fba9 100644
--- a/firmware/export/config-fuze.h
+++ b/firmware/export/config-fuze.h
@@ -178,7 +178,8 @@
178#define FIRMWARE_OFFSET_FILE_DATA 0x8 178#define FIRMWARE_OFFSET_FILE_DATA 0x8
179 179
180#ifndef BOOTLOADER 180#ifndef BOOTLOADER
181#define HAVE_MULTIVOLUME 181#define HAVE_MULTIDRIVE
182#define NUM_DRIVES 2
182#define HAVE_HOTSWAP 183#define HAVE_HOTSWAP
183#endif 184#endif
184 185
diff --git a/firmware/export/config-ondavx747.h b/firmware/export/config-ondavx747.h
index 1d9a7a8883..dbb37c972d 100644
--- a/firmware/export/config-ondavx747.h
+++ b/firmware/export/config-ondavx747.h
@@ -42,8 +42,7 @@
42//#define HAVE_ATA_SD 42//#define HAVE_ATA_SD
43//#define HAVE_HOTSWAP 43//#define HAVE_HOTSWAP
44 44
45//#define CONFIG_STORAGE (STORAGE_NAND | STORAGE_SD) 45#define CONFIG_STORAGE (STORAGE_NAND | STORAGE_SD)
46#define CONFIG_STORAGE STORAGE_SD
47 46
48/* Support FAT16 for SD cards <= 2GB */ 47/* Support FAT16 for SD cards <= 2GB */
49#define HAVE_FAT16SUPPORT 48#define HAVE_FAT16SUPPORT
@@ -51,6 +50,9 @@
51/* ChinaChip NAND FTL */ 50/* ChinaChip NAND FTL */
52#define CONFIG_NAND NAND_CC 51#define CONFIG_NAND NAND_CC
53 52
53#define HAVE_MULTIDRIVE
54#define NUM_DRIVES 2
55
54/* define this if you have a bitmap LCD display */ 56/* define this if you have a bitmap LCD display */
55#define HAVE_LCD_BITMAP 57#define HAVE_LCD_BITMAP
56 58
diff --git a/firmware/export/config-ondavx767.h b/firmware/export/config-ondavx767.h
index a662fc0da9..d4873370dd 100644
--- a/firmware/export/config-ondavx767.h
+++ b/firmware/export/config-ondavx767.h
@@ -41,7 +41,8 @@
41 41
42#define CONFIG_NAND NAND_CC 42#define CONFIG_NAND NAND_CC
43 43
44#define HAVE_MULTIVOLUME 44#define HAVE_MULTIDRIVE
45#define NUM_DRIVES 2
45 46
46/* define this if you have a bitmap LCD display */ 47/* define this if you have a bitmap LCD display */
47#define HAVE_LCD_BITMAP 48#define HAVE_LCD_BITMAP
diff --git a/firmware/export/config-ondiofm.h b/firmware/export/config-ondiofm.h
index a43810e3ff..a8802dcea8 100644
--- a/firmware/export/config-ondiofm.h
+++ b/firmware/export/config-ondiofm.h
@@ -125,7 +125,8 @@
125#define HAVE_MAS_SIBI_CONTROL 125#define HAVE_MAS_SIBI_CONTROL
126 126
127/* define this if more than one device/partition can be used */ 127/* define this if more than one device/partition can be used */
128#define HAVE_MULTIVOLUME 128#define HAVE_MULTIDRIVE
129#define NUM_DRIVES 2
129 130
130/* define this if media can be exchanged on the fly */ 131/* define this if media can be exchanged on the fly */
131#define HAVE_HOTSWAP 132#define HAVE_HOTSWAP
diff --git a/firmware/export/config-ondiosp.h b/firmware/export/config-ondiosp.h
index 1fcf45b200..ba26713612 100644
--- a/firmware/export/config-ondiosp.h
+++ b/firmware/export/config-ondiosp.h
@@ -106,7 +106,8 @@
106#define HAVE_MAS_SIBI_CONTROL 106#define HAVE_MAS_SIBI_CONTROL
107 107
108/* define this if more than one device/partition can be used */ 108/* define this if more than one device/partition can be used */
109#define HAVE_MULTIVOLUME 109#define HAVE_MULTIDRIVE
110#define NUM_DRIVES 2
110 111
111/* define this if media can be exchanged on the fly */ 112/* define this if media can be exchanged on the fly */
112#define HAVE_HOTSWAP 113#define HAVE_HOTSWAP
diff --git a/firmware/export/config.h b/firmware/export/config.h
index 406ef509c8..092e02f458 100644
--- a/firmware/export/config.h
+++ b/firmware/export/config.h
@@ -539,11 +539,6 @@ Lyre prototype 1*/
539#define CONFIG_TUNER_MULTI 539#define CONFIG_TUNER_MULTI
540#endif 540#endif
541 541
542#if (CONFIG_STORAGE & (CONFIG_STORAGE - 1)) != 0
543/* Multiple storage drivers */
544#define CONFIG_STORAGE_MULTI
545#endif
546
547/* deactivate fading in bootloader/sim */ 542/* deactivate fading in bootloader/sim */
548#if defined(BOOTLOADER) || defined(SIMULATOR) 543#if defined(BOOTLOADER) || defined(SIMULATOR)
549#undef CONFIG_BACKLIGHT_FADING 544#undef CONFIG_BACKLIGHT_FADING
@@ -571,6 +566,37 @@ Lyre prototype 1*/
571 566
572#endif /* CONFIG_BACKLIGHT_FADING */ 567#endif /* CONFIG_BACKLIGHT_FADING */
573 568
569/* Storage related config handling */
570
571#if (CONFIG_STORAGE & (CONFIG_STORAGE - 1)) != 0
572/* Multiple storage drivers */
573#define CONFIG_STORAGE_MULTI
574#endif
575
576/* Explicit HAVE_MULTIVOLUME in the config file. Allow the maximum number */
577#ifdef HAVE_MULTIVOLUME
578#define NUM_VOLUMES_PER_DRIVE 4
579#else
580#define NUM_VOLUMES_PER_DRIVE 1
581#endif
582#if defined(CONFIG_STORAGE_MULTI) && !defined(HAVE_MULTIDRIVE)
583#define HAVE_MULTIDRIVE
584#endif
585
586#if defined(HAVE_MULTIDRIVE) && !defined(HAVE_MULTIVOLUME)
587#define HAVE_MULTIVOLUME
588#endif
589
590#if defined(HAVE_MULTIDRIVE) && !defined(NUM_DRIVES)
591#error HAVE_MULTIDRIVE needs to have an explicit NUM_DRIVES
592#endif
593
594#ifndef NUM_DRIVES
595#define NUM_DRIVES 1
596#endif
597
598#define NUM_VOLUMES (NUM_DRIVES * NUM_VOLUMES_PER_DRIVE)
599
574#if defined(BOOTLOADER) && defined(HAVE_ADJUSTABLE_CPU_FREQ) 600#if defined(BOOTLOADER) && defined(HAVE_ADJUSTABLE_CPU_FREQ)
575/* Bootloaders don't use CPU frequency adjustment */ 601/* Bootloaders don't use CPU frequency adjustment */
576#undef HAVE_ADJUSTABLE_CPU_FREQ 602#undef HAVE_ADJUSTABLE_CPU_FREQ
diff --git a/firmware/export/disk.h b/firmware/export/disk.h
index cec9bfa3fc..cd937fdf66 100644
--- a/firmware/export/disk.h
+++ b/firmware/export/disk.h
@@ -35,7 +35,7 @@ struct partinfo {
35#define PARTITION_TYPE_OS2_HIDDEN_C_DRIVE 0x84 35#define PARTITION_TYPE_OS2_HIDDEN_C_DRIVE 0x84
36 36
37/* returns a pointer to an array of 8 partinfo structs */ 37/* returns a pointer to an array of 8 partinfo structs */
38struct partinfo* disk_init(IF_MV_NONVOID(int volume)); 38struct partinfo* disk_init(IF_MD_NONVOID(int drive));
39struct partinfo* disk_partinfo(int partition); 39struct partinfo* disk_partinfo(int partition);
40int disk_mount_all(void); /* returns the # of successful mounts */ 40int disk_mount_all(void); /* returns the # of successful mounts */
41int disk_mount(int drive); 41int disk_mount(int drive);
diff --git a/firmware/export/fat.h b/firmware/export/fat.h
index c99a1a75f8..d6e753f9cb 100644
--- a/firmware/export/fat.h
+++ b/firmware/export/fat.h
@@ -90,7 +90,7 @@ extern void fat_unlock(void);
90#endif 90#endif
91 91
92extern void fat_init(void); 92extern void fat_init(void);
93extern int fat_mount(IF_MV2(int volume,) IF_MV2(int drive,) long startsector); 93extern int fat_mount(IF_MV2(int volume,) IF_MD2(int drive,) long startsector);
94extern int fat_unmount(int volume, bool flush); 94extern int fat_unmount(int volume, bool flush);
95extern void fat_size(IF_MV2(int volume,) /* public for info */ 95extern void fat_size(IF_MV2(int volume,) /* public for info */
96 unsigned long* size, 96 unsigned long* size,
diff --git a/firmware/export/mmc.h b/firmware/export/mmc.h
index 06d99d219e..f2b0ad3509 100644
--- a/firmware/export/mmc.h
+++ b/firmware/export/mmc.h
@@ -23,7 +23,7 @@
23#define __MMC_H__ 23#define __MMC_H__
24 24
25#include <stdbool.h> 25#include <stdbool.h>
26#include "mv.h" /* for HAVE_MULTIVOLUME or not */ 26#include "mv.h" /* for HAVE_MULTIDRIVE or not */
27 27
28struct storage_info; 28struct storage_info;
29 29
@@ -35,19 +35,24 @@ bool mmc_disk_is_active(void);
35int mmc_soft_reset(void); 35int mmc_soft_reset(void);
36int mmc_init(void); 36int mmc_init(void);
37void mmc_close(void); 37void mmc_close(void);
38int mmc_read_sectors(IF_MV2(int drive,) unsigned long start, int count, void* buf); 38int mmc_read_sectors(IF_MD2(int drive,) unsigned long start, int count, void* buf);
39int mmc_write_sectors(IF_MV2(int drive,) unsigned long start, int count, const void* buf); 39int mmc_write_sectors(IF_MD2(int drive,) unsigned long start, int count, const void* buf);
40void mmc_spin(void); 40void mmc_spin(void);
41int mmc_spinup_time(void); 41int mmc_spinup_time(void);
42 42
43#ifdef STORAGE_GET_INFO 43#ifdef STORAGE_GET_INFO
44void mmc_get_info(IF_MV2(int drive,) struct storage_info *info); 44void mmc_get_info(IF_MD2(int drive,) struct storage_info *info);
45#endif 45#endif
46#ifdef HAVE_HOTSWAP 46#ifdef HAVE_HOTSWAP
47bool mmc_removable(IF_MV_NONVOID(int drive)); 47bool mmc_removable(IF_MD_NONVOID(int drive));
48bool mmc_present(IF_MV_NONVOID(int drive)); 48bool mmc_present(IF_MD_NONVOID(int drive));
49#endif 49#endif
50 50
51long mmc_last_disk_activity(void); 51long mmc_last_disk_activity(void);
52 52
53#ifdef CONFIG_STORAGE_MULTI
54int mmc_num_drives(int first_drive);
55#endif
56
57
53#endif 58#endif
diff --git a/firmware/export/mv.h b/firmware/export/mv.h
index fda650c7e9..b1d16a7267 100644
--- a/firmware/export/mv.h
+++ b/firmware/export/mv.h
@@ -26,16 +26,28 @@
26 26
27/* FixMe: These macros are a bit nasty and perhaps misplaced here. 27/* FixMe: These macros are a bit nasty and perhaps misplaced here.
28 We'll get rid of them once decided on how to proceed with multivolume. */ 28 We'll get rid of them once decided on how to proceed with multivolume. */
29
30/* Drives are things like a disk, a card, a flash chip. They can have volumes on them */
31#ifdef HAVE_MULTIDRIVE
32#define IF_MD(x) x /* optional drive parameter */
33#define IF_MD2(x,y) x,y /* same, for a list of arguments */
34#define IF_MD_NONVOID(x) x /* for prototype with sole volume parameter */
35#else /* empty definitions if no multi-drive */
36#define IF_MD(x)
37#define IF_MD2(x,y)
38#define IF_MD_NONVOID(x) void
39#endif
40
41/* Volumes mean things that have filesystems on them, like partitions */
29#ifdef HAVE_MULTIVOLUME 42#ifdef HAVE_MULTIVOLUME
30#define IF_MV(x) x /* optional volume/drive parameter */ 43#define IF_MV(x) x /* optional volume parameter */
31#define IF_MV2(x,y) x,y /* same, for a list of arguments */ 44#define IF_MV2(x,y) x,y /* same, for a list of arguments */
32#define IF_MV_NONVOID(x) x /* for prototype with sole volume parameter */ 45#define IF_MV_NONVOID(x) x /* for prototype with sole volume parameter */
33#define NUM_VOLUMES 2
34#else /* empty definitions if no multi-volume */ 46#else /* empty definitions if no multi-volume */
35#define IF_MV(x) 47#define IF_MV(x)
36#define IF_MV2(x,y) 48#define IF_MV2(x,y)
37#define IF_MV_NONVOID(x) void 49#define IF_MV_NONVOID(x) void
38#define NUM_VOLUMES 1
39#endif 50#endif
40 51
52
41#endif 53#endif
diff --git a/firmware/export/nand.h b/firmware/export/nand.h
index a5b0a1ceee..67ebe73ddf 100644
--- a/firmware/export/nand.h
+++ b/firmware/export/nand.h
@@ -23,25 +23,31 @@
23#define __NAND_H__ 23#define __NAND_H__
24 24
25#include <stdbool.h> 25#include <stdbool.h>
26#include "mv.h" /* for HAVE_MULTIVOLUME or not */ 26#include "mv.h" /* for HAVE_MULTIDRIVE or not */
27 27
28struct storage_info; 28struct storage_info;
29 29
30void nand_enable(bool on); 30void nand_enable(bool on);
31void nand_spindown(int seconds); 31void nand_spindown(int seconds);
32void nand_sleep(void); 32void nand_sleep(void);
33void nand_sleepnow(void);
33bool nand_disk_is_active(void); 34bool nand_disk_is_active(void);
34int nand_soft_reset(void); 35int nand_soft_reset(void);
35int nand_init(void); 36int nand_init(void);
36void nand_close(void); 37void nand_close(void);
37int nand_read_sectors(IF_MV2(int drive,) unsigned long start, int count, void* buf); 38int nand_read_sectors(IF_MD2(int drive,) unsigned long start, int count, void* buf);
38int nand_write_sectors(IF_MV2(int drive,) unsigned long start, int count, const void* buf); 39int nand_write_sectors(IF_MD2(int drive,) unsigned long start, int count, const void* buf);
39void nand_spin(void); 40void nand_spin(void);
41int nand_spinup_time(void); /* ticks */
40 42
41#ifdef STORAGE_GET_INFO 43#ifdef STORAGE_GET_INFO
42void nand_get_info(IF_MV2(int drive,) struct storage_info *info); 44void nand_get_info(IF_MD2(int drive,) struct storage_info *info);
43#endif 45#endif
44 46
45long nand_last_disk_activity(void); 47long nand_last_disk_activity(void);
46 48
49#ifdef CONFIG_STORAGE_MULTI
50int nand_num_drives(int first_drive);
51#endif
52
47#endif 53#endif
diff --git a/firmware/export/ramdisk.h b/firmware/export/ramdisk.h
index a0c011fadd..79551ca287 100644
--- a/firmware/export/ramdisk.h
+++ b/firmware/export/ramdisk.h
@@ -23,7 +23,7 @@
23#define __RAMDISK_H__ 23#define __RAMDISK_H__
24 24
25#include <stdbool.h> 25#include <stdbool.h>
26#include "mv.h" /* for HAVE_MULTIVOLUME or not */ 26#include "mv.h" /* for HAVE_MULTIDRIVE or not */
27 27
28struct storage_info; 28struct storage_info;
29 29
@@ -34,15 +34,20 @@ bool ramdisk_disk_is_active(void);
34int ramdisk_soft_reset(void); 34int ramdisk_soft_reset(void);
35int ramdisk_init(void); 35int ramdisk_init(void);
36void ramdisk_close(void); 36void ramdisk_close(void);
37int ramdisk_read_sectors(IF_MV2(int drive,) unsigned long start, int count, void* buf); 37int ramdisk_read_sectors(IF_MD2(int drive,) unsigned long start, int count, void* buf);
38int ramdisk_write_sectors(IF_MV2(int drive,) unsigned long start, int count, const void* buf); 38int ramdisk_write_sectors(IF_MD2(int drive,) unsigned long start, int count, const void* buf);
39void ramdisk_spin(void); 39void ramdisk_spin(void);
40void ramdisk_sleepnow(void); 40void ramdisk_sleepnow(void);
41int ramdisk_spinup_time(void);
41 42
42#ifdef STORAGE_GET_INFO 43#ifdef STORAGE_GET_INFO
43void ramdisk_get_info(IF_MV2(int drive,) struct storage_info *info); 44void ramdisk_get_info(IF_MD2(int drive,) struct storage_info *info);
44#endif 45#endif
45 46
46long ramdisk_last_disk_activity(void); 47long ramdisk_last_disk_activity(void);
47 48
49#ifdef CONFIG_STORAGE_MULTI
50int ramdisk_num_drives(int first_drive);
51#endif
52
48#endif 53#endif
diff --git a/firmware/export/sd.h b/firmware/export/sd.h
index d313a4c2e1..0b64bd768d 100644
--- a/firmware/export/sd.h
+++ b/firmware/export/sd.h
@@ -23,7 +23,7 @@
23#define __SD_H__ 23#define __SD_H__
24 24
25#include <stdbool.h> 25#include <stdbool.h>
26#include "mv.h" /* for HAVE_MULTIVOLUME or not */ 26#include "mv.h" /* for HAVE_MULTIDRIVE or not */
27 27
28#define SD_BLOCK_SIZE 512 /* XXX : support other sizes ? */ 28#define SD_BLOCK_SIZE 512 /* XXX : support other sizes ? */
29 29
@@ -32,27 +32,34 @@ struct storage_info;
32void sd_enable(bool on); 32void sd_enable(bool on);
33void sd_spindown(int seconds); 33void sd_spindown(int seconds);
34void sd_sleep(void); 34void sd_sleep(void);
35void sd_sleepnow(void);
35bool sd_disk_is_active(void); 36bool sd_disk_is_active(void);
36int sd_soft_reset(void); 37int sd_soft_reset(void);
37int sd_init(void); 38int sd_init(void);
38void sd_close(void); 39void sd_close(void);
39int sd_read_sectors(IF_MV2(int drive,) unsigned long start, int count, void* buf); 40int sd_read_sectors(IF_MD2(int drive,) unsigned long start, int count, void* buf);
40int sd_write_sectors(IF_MV2(int drive,) unsigned long start, int count, const void* buf); 41int sd_write_sectors(IF_MD2(int drive,) unsigned long start, int count, const void* buf);
41void sd_spin(void); 42void sd_spin(void);
43int sd_spinup_time(void); /* ticks */
42 44
43#ifdef STORAGE_GET_INFO 45#ifdef STORAGE_GET_INFO
44void sd_get_info(IF_MV2(int drive,) struct storage_info *info); 46void sd_get_info(IF_MD2(int drive,) struct storage_info *info);
45#endif 47#endif
46#ifdef HAVE_HOTSWAP 48#ifdef HAVE_HOTSWAP
47bool sd_removable(IF_MV_NONVOID(int drive)); 49bool sd_removable(IF_MV_NONVOID(int drive));
48bool sd_present(IF_MV_NONVOID(int drive)); 50bool sd_present(IF_MV_NONVOID(int drive));
49void card_enable_monitoring_target(bool on); 51void card_enable_monitoring_target(bool on);
50#endif 52#endif
51 53
52bool card_detect_target(void); 54bool card_detect_target(void);
53 55
54long sd_last_disk_activity(void); 56long sd_last_disk_activity(void);
55 57
58#ifdef CONFIG_STORAGE_MULTI
59int sd_num_drives(int first_drive);
60#endif
61
62
56/* SD States */ 63/* SD States */
57#define SD_IDLE 0 64#define SD_IDLE 0
58#define SD_READY 1 65#define SD_READY 1
diff --git a/firmware/export/storage.h b/firmware/export/storage.h
index 47d8abda52..dbcc7a69ab 100644
--- a/firmware/export/storage.h
+++ b/firmware/export/storage.h
@@ -23,7 +23,7 @@
23#define __STORAGE_H__ 23#define __STORAGE_H__
24 24
25#include <stdbool.h> 25#include <stdbool.h>
26#include "config.h" /* for HAVE_MULTIVOLUME or not */ 26#include "config.h" /* for HAVE_MULTIDRIVE or not */
27#include "mv.h" 27#include "mv.h"
28 28
29#if (CONFIG_STORAGE & STORAGE_SD) 29#if (CONFIG_STORAGE & STORAGE_SD)
@@ -51,154 +51,147 @@ struct storage_info
51 char *revision; 51 char *revision;
52}; 52};
53 53
54#ifndef SIMULATOR 54#if !defined(SIMULATOR) && !defined(CONFIG_STORAGE_MULTI)
55 #ifndef CONFIG_STORAGE_MULTI 55/* storage_spindown, storage_sleep and storage_spin are passed as
56 /* storage_spindown, storage_sleep and storage_spin are passed as 56 * pointers, which doesn't work with argument-macros.
57 * pointers, which doesn't work with argument-macros. 57 */
58 */ 58 #define storage_num_drives() NUM_DRIVES
59 #if (CONFIG_STORAGE & STORAGE_ATA) 59 #if (CONFIG_STORAGE & STORAGE_ATA)
60 #define storage_spindown ata_spindown 60 #define storage_spindown ata_spindown
61 #define storage_sleep ata_sleep 61 #define storage_sleep ata_sleep
62 #define storage_spin ata_spin 62 #define storage_spin ata_spin
63 63
64 #define storage_enable(on) ata_enable(on) 64 #define storage_enable(on) ata_enable(on)
65 #define storage_sleepnow() ata_sleepnow() 65 #define storage_sleepnow() ata_sleepnow()
66 #define storage_disk_is_active() ata_disk_is_active() 66 #define storage_disk_is_active() ata_disk_is_active()
67 #define storage_soft_reset() ata_soft_reset() 67 #define storage_soft_reset() ata_soft_reset()
68 #define storage_init() ata_init() 68 #define storage_init() ata_init()
69 #define storage_close() ata_close() 69 #define storage_close() ata_close()
70 #define storage_read_sectors(drive, start, count, buf) ata_read_sectors(IF_MV2(drive,) start, count, buf) 70 #define storage_read_sectors(drive, start, count, buf) ata_read_sectors(IF_MD2(drive,) start, count, buf)
71 #define storage_write_sectors(drive, start, count, buf) ata_write_sectors(IF_MV2(drive,) start, count, buf) 71 #define storage_write_sectors(drive, start, count, buf) ata_write_sectors(IF_MD2(drive,) start, count, buf)
72 #define storage_last_disk_activity() ata_last_disk_activity() 72 #define storage_last_disk_activity() ata_last_disk_activity()
73 #define storage_spinup_time() ata_spinup_time() 73 #define storage_spinup_time() ata_spinup_time()
74 #define storage_get_identify() ata_get_identify() 74 #define storage_get_identify() ata_get_identify()
75 75
76 #ifdef STORAGE_GET_INFO 76 #ifdef STORAGE_GET_INFO
77 #define storage_get_info(drive, info) ata_get_info(IF_MV2(drive,) info) 77 #define storage_get_info(drive, info) ata_get_info(IF_MD2(drive,) info)
78 #endif 78 #endif
79 #ifdef HAVE_HOTSWAP 79 #ifdef HAVE_HOTSWAP
80 #define storage_removable(drive) ata_removable(IF_MV(drive)) 80 #define storage_removable(drive) ata_removable(IF_MD(drive))
81 #define storage_present(drive) ata_present(IF_MV(drive)) 81 #define storage_present(drive) ata_present(IF_MD(drive))
82 #endif 82 #endif
83 #elif (CONFIG_STORAGE & STORAGE_SD) 83 #elif (CONFIG_STORAGE & STORAGE_SD)
84 #define storage_spindown sd_spindown 84 #define storage_spindown sd_spindown
85 #define storage_sleep sd_sleep 85 #define storage_sleep sd_sleep
86 #define storage_spin sd_spin 86 #define storage_spin sd_spin
87 87
88 #define storage_enable(on) sd_enable(on) 88 #define storage_enable(on) sd_enable(on)
89 #define storage_sleepnow() sd_sleepnow() 89 #define storage_sleepnow() sd_sleepnow()
90 #define storage_disk_is_active() 0 90 #define storage_disk_is_active() 0
91 #define storage_soft_reset() (void)0 91 #define storage_soft_reset() (void)0
92 #define storage_init() sd_init() 92 #define storage_init() sd_init()
93 #define storage_close() sd_close() 93 #define storage_read_sectors(drive, start, count, buf) sd_read_sectors(IF_MD2(drive,) start, count, buf)
94 #define storage_read_sectors(drive, start, count, buf) sd_read_sectors(IF_MV2(drive,) start, count, buf) 94 #define storage_write_sectors(drive, start, count, buf) sd_write_sectors(IF_MD2(drive,) start, count, buf)
95 #define storage_write_sectors(drive, start, count, buf) sd_write_sectors(IF_MV2(drive,) start, count, buf) 95 #define storage_last_disk_activity() sd_last_disk_activity()
96 #define storage_last_disk_activity() sd_last_disk_activity() 96 #define storage_spinup_time() 0
97 #define storage_spinup_time() 0 97 #define storage_get_identify() sd_get_identify()
98 #define storage_get_identify() sd_get_identify() 98
99 99 #ifdef STORAGE_GET_INFO
100 #ifdef STORAGE_GET_INFO 100 #define storage_get_info(drive, info) sd_get_info(IF_MD2(drive,) info)
101 #define storage_get_info(drive, info) sd_get_info(IF_MV2(drive,) info) 101 #endif
102 #endif 102 #ifdef HAVE_HOTSWAP
103 #ifdef HAVE_HOTSWAP 103 #define storage_removable(drive) sd_removable(IF_MD(drive))
104 #define storage_removable(drive) sd_removable(IF_MV(drive)) 104 #define storage_present(drive) sd_present(IF_MD(drive))
105 #define storage_present(drive) sd_present(IF_MV(drive)) 105 #endif
106 #endif 106 #elif (CONFIG_STORAGE & STORAGE_MMC)
107 #elif (CONFIG_STORAGE & STORAGE_MMC) 107 #define storage_spindown mmc_spindown
108 #define storage_spindown mmc_spindown 108 #define storage_sleep mmc_sleep
109 #define storage_sleep mmc_sleep 109 #define storage_spin mmc_spin
110 #define storage_spin mmc_spin 110
111 111 #define storage_enable(on) mmc_enable(on)
112 #define storage_enable(on) mmc_enable(on) 112 #define storage_sleepnow() mmc_sleepnow()
113 #define storage_sleepnow() mmc_sleepnow() 113 #define storage_disk_is_active() mmc_disk_is_active()
114 #define storage_disk_is_active() mmc_disk_is_active() 114 #define storage_soft_reset() (void)0
115 #define storage_soft_reset() (void)0 115 #define storage_init() mmc_init()
116 #define storage_init() mmc_init() 116 #define storage_read_sectors(drive, start, count, buf) mmc_read_sectors(IF_MD2(drive,) start, count, buf)
117 #define storage_close() mmc_close() 117 #define storage_write_sectors(drive, start, count, buf) mmc_write_sectors(IF_MD2(drive,) start, count, buf)
118 #define storage_read_sectors(drive, start, count, buf) mmc_read_sectors(IF_MV2(drive,) start, count, buf) 118 #define storage_last_disk_activity() mmc_last_disk_activity()
119 #define storage_write_sectors(drive, start, count, buf) mmc_write_sectors(IF_MV2(drive,) start, count, buf) 119 #define storage_spinup_time() 0
120 #define storage_last_disk_activity() mmc_last_disk_activity() 120 #define storage_get_identify() mmc_get_identify()
121 #define storage_spinup_time() 0 121
122 #define storage_get_identify() mmc_get_identify() 122 #ifdef STORAGE_GET_INFO
123 123 #define storage_get_info(drive, info) mmc_get_info(IF_MD2(drive,) info)
124 #ifdef STORAGE_GET_INFO 124 #endif
125 #define storage_get_info(drive, info) mmc_get_info(IF_MV2(drive,) info) 125 #ifdef HAVE_HOTSWAP
126 #endif 126 #define storage_removable(drive) mmc_removable(IF_MD(drive))
127 #ifdef HAVE_HOTSWAP 127 #define storage_present(drive) mmc_present(IF_MD(drive))
128 #define storage_removable(drive) mmc_removable(IF_MV(drive)) 128 #endif
129 #define storage_present(drive) mmc_present(IF_MV(drive)) 129 #elif (CONFIG_STORAGE & STORAGE_NAND)
130 #endif 130 #define storage_spindown nand_spindown
131 #elif (CONFIG_STORAGE & STORAGE_NAND) 131 #define storage_sleep nand_sleep
132 #define storage_spindown nand_spindown 132 #define storage_spin nand_spin
133 #define storage_sleep nand_sleep 133
134 #define storage_spin nand_spin 134 #define storage_enable(on) (void)0
135 135 #define storage_sleepnow() nand_sleepnow()
136 #define storage_enable(on) (void)0 136 #define storage_disk_is_active() 0
137 #define storage_sleepnow() nand_sleepnow() 137 #define storage_soft_reset() (void)0
138 #define storage_disk_is_active() 0 138 #define storage_init() nand_init()
139 #define storage_soft_reset() (void)0 139 #define storage_read_sectors(drive, start, count, buf) nand_read_sectors(IF_MD2(drive,) start, count, buf)
140 #define storage_init() nand_init() 140 #define storage_write_sectors(drive, start, count, buf) nand_write_sectors(IF_MD2(drive,) start, count, buf)
141 #define storage_close() nand_close() 141 #define storage_last_disk_activity() nand_last_disk_activity()
142 #define storage_read_sectors(drive, start, count, buf) nand_read_sectors(IF_MV2(drive,) start, count, buf) 142 #define storage_spinup_time() 0
143 #define storage_write_sectors(drive, start, count, buf) nand_write_sectors(IF_MV2(drive,) start, count, buf) 143 #define storage_get_identify() nand_get_identify()
144 #define storage_last_disk_activity() nand_last_disk_activity() 144
145 #define storage_spinup_time() 0 145 #ifdef STORAGE_GET_INFO
146 #define storage_get_identify() nand_get_identify() 146 #define storage_get_info(drive, info) nand_get_info(IF_MD2(drive,) info)
147 147 #endif
148 #ifdef STORAGE_GET_INFO 148 #ifdef HAVE_HOTSWAP
149 #define storage_get_info(drive, info) nand_get_info(IF_MV2(drive,) info) 149 #define storage_removable(drive) nand_removable(IF_MD(drive))
150 #endif 150 #define storage_present(drive) nand_present(IF_MD(drive))
151 #ifdef HAVE_HOTSWAP 151 #endif
152 #define storage_removable(drive) nand_removable(IF_MV(drive)) 152 #elif (CONFIG_STORAGE & STORAGE_RAMDISK)
153 #define storage_present(drive) nand_present(IF_MV(drive)) 153 #define storage_spindown ramdisk_spindown
154 #endif 154 #define storage_sleep ramdisk_sleep
155 #elif (CONFIG_STORAGE & STORAGE_RAMDISK) 155 #define storage_spin ramdisk_spin
156 #define storage_spindown ramdisk_spindown 156
157 #define storage_sleep ramdisk_sleep 157 #define storage_enable(on) (void)0
158 #define storage_spin ramdisk_spin 158 #define storage_sleepnow() ramdisk_sleepnow()
159 159 #define storage_disk_is_active() 0
160 #define storage_enable(on) (void)0 160 #define storage_soft_reset() (void)0
161 #define storage_sleepnow() ramdisk_sleepnow() 161 #define storage_init() ramdisk_init()
162 #define storage_disk_is_active() 0 162 #define storage_read_sectors(drive, start, count, buf) ramdisk_read_sectors(IF_MD2(drive,) start, count, buf)
163 #define storage_soft_reset() (void)0 163 #define storage_write_sectors(drive, start, count, buf) ramdisk_write_sectors(IF_MD2(drive,) start, count, buf)
164 #define storage_init() ramdisk_init() 164 #define storage_last_disk_activity() ramdisk_last_disk_activity()
165 #define storage_close() ramdisk_close() 165 #define storage_spinup_time() 0
166 #define storage_read_sectors(drive, start, count, buf) ramdisk_read_sectors(IF_MV2(drive,) start, count, buf) 166 #define storage_get_identify() ramdisk_get_identify()
167 #define storage_write_sectors(drive, start, count, buf) ramdisk_write_sectors(IF_MV2(drive,) start, count, buf) 167
168 #define storage_last_disk_activity() ramdisk_last_disk_activity() 168 #ifdef STORAGE_GET_INFO
169 #define storage_spinup_time() 0 169 #define storage_get_info(drive, info) ramdisk_get_info(IF_MD2(drive,) info)
170 #define storage_get_identify() ramdisk_get_identify() 170 #endif
171 171 #ifdef HAVE_HOTSWAP
172 #ifdef STORAGE_GET_INFO 172 #define storage_removable(drive) ramdisk_removable(IF_MD(drive))
173 #define storage_get_info(drive, info) ramdisk_get_info(IF_MV2(drive,) info) 173 #define storage_present(drive) ramdisk_present(IF_MD(drive))
174 #endif 174 #endif
175 #ifdef HAVE_HOTSWAP 175 #else
176 #define storage_removable(drive) ramdisk_removable(IF_MV(drive)) 176 //#error No storage driver!
177 #define storage_present(drive) ramdisk_present(IF_MV(drive)) 177 #endif
178 #endif 178#else /* NOT CONFIG_STORAGE_MULTI and NOT SIMULATOR*/
179 #else 179
180 //#error No storage driver! 180/* Simulator and multi-driver use normal functions */
181 #endif 181
182 #else /* NOT CONFIG_STORAGE_MULTI */
183
184 /* TODO : implement multi-driver here */
185 #error Multi-driver storage not implemented yet
186
187 #endif /* NOT CONFIG_STORAGE_MULTI */
188#else /*NOT SIMULATOR */
189void storage_enable(bool on); 182void storage_enable(bool on);
190void storage_sleep(void); 183void storage_sleep(void);
191void storage_sleepnow(void); 184void storage_sleepnow(void);
192bool storage_disk_is_active(void); 185bool storage_disk_is_active(void);
193int storage_soft_reset(void); 186int storage_soft_reset(void);
194int storage_init(void); 187int storage_init(void);
195void storage_close(void);
196int storage_read_sectors(int drive, unsigned long start, int count, void* buf); 188int storage_read_sectors(int drive, unsigned long start, int count, void* buf);
197int storage_write_sectors(int drive, unsigned long start, int count, const void* buf); 189int storage_write_sectors(int drive, unsigned long start, int count, const void* buf);
198void storage_spin(void); 190void storage_spin(void);
199void storage_spindown(int seconds); 191void storage_spindown(int seconds);
200long storage_last_disk_activity(void); 192long storage_last_disk_activity(void);
201int storage_spinup_time(void); 193int storage_spinup_time(void);
194int storage_num_drives(void);
202#ifdef STORAGE_GET_INFO 195#ifdef STORAGE_GET_INFO
203void storage_get_info(int drive, struct storage_info *info); 196void storage_get_info(int drive, struct storage_info *info);
204#endif 197#endif
@@ -206,5 +199,6 @@ void storage_get_info(int drive, struct storage_info *info);
206bool storage_removable(int drive); 199bool storage_removable(int drive);
207bool storage_present(int drive); 200bool storage_present(int drive);
208#endif 201#endif
209#endif/*NOT SIMULATOR */ 202
203#endif /* NOT CONFIG_STORAGE_MULTI and NOT SIMULATOR*/
210#endif 204#endif