summaryrefslogtreecommitdiffstats
path: root/firmware/export
diff options
context:
space:
mode:
authorFrank Gevaerts <frank@gevaerts.be>2009-07-17 22:28:49 +0000
committerFrank Gevaerts <frank@gevaerts.be>2009-07-17 22:28:49 +0000
commitc0a5a67387c4eec3db3bad4da77ba5126faf03c4 (patch)
treed7e61f6287c5fcdce903489b6b72d474225b98a7 /firmware/export
parentbb3b57f64594ba517e06add4cfeff72b2b06e65b (diff)
downloadrockbox-c0a5a67387c4eec3db3bad4da77ba5126faf03c4.tar.gz
rockbox-c0a5a67387c4eec3db3bad4da77ba5126faf03c4.zip
Commit FS#9545, storage cleanup and multi-driver support
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@21933 a1c6a512-1295-4272-9138-f99709370657
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);
int ata_soft_reset(void);
int ata_init(void);
void ata_close(void);
-int ata_read_sectors(IF_MV2(int drive,) unsigned long start, int count, void* buf);
-int ata_write_sectors(IF_MV2(int drive,) unsigned long start, int count, const void* buf);
+int ata_read_sectors(IF_MD2(int drive,) unsigned long start, int count, void* buf);
+int ata_write_sectors(IF_MD2(int drive,) unsigned long start, int count, const void* buf);
void ata_spin(void);
#if (CONFIG_LED == LED_REAL)
void ata_set_led_enabled(bool enabled);
@@ -48,14 +48,18 @@ void ata_set_led_enabled(bool enabled);
unsigned short* ata_get_identify(void);
#ifdef STORAGE_GET_INFO
-void ata_get_info(IF_MV2(int drive,) struct storage_info *info);
+void ata_get_info(IF_MD2(int drive,) struct storage_info *info);
#endif
#ifdef HAVE_HOTSWAP
-bool ata_removable(IF_MV_NONVOID(int drive));
-bool ata_present(IF_MV_NONVOID(int drive));
+bool ata_removable(IF_MD_NONVOID(int drive));
+bool ata_present(IF_MD_NONVOID(int drive));
#endif
+#ifdef CONFIG_STORAGE_MULTI
+int ata_num_drives(int first_drive);
+#endif
+
long ata_last_disk_activity(void);
int 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 @@
#define FIRMWARE_OFFSET_FILE_DATA 0x8
#ifndef BOOTLOADER
-#define HAVE_MULTIVOLUME
+#define HAVE_MULTIDRIVE
+#define NUM_DRIVES 2
#define HAVE_HOTSWAP
#endif
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 @@
#define FIRMWARE_OFFSET_FILE_DATA 0x8
#ifndef BOOTLOADER
-#define HAVE_MULTIVOLUME
+#define HAVE_MULTIDRIVE
+#define NUM_DRIVES 2
#define HAVE_HOTSWAP
#endif
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 @@
#define FIRMWARE_OFFSET_FILE_DATA 0x8
#ifndef BOOTLOADER
-#define HAVE_MULTIVOLUME
+#define HAVE_MULTIDRIVE
+#define NUM_DRIVES 2
#define HAVE_HOTSWAP
#endif
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 @@
#define FIRMWARE_OFFSET_FILE_DATA 0x8
#ifndef BOOTLOADER
-#define HAVE_MULTIVOLUME
+#define HAVE_MULTIDRIVE
+#define NUM_DRIVES 2
#define HAVE_HOTSWAP
#endif
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 @@
//#define HAVE_ATA_SD
//#define HAVE_HOTSWAP
-//#define CONFIG_STORAGE (STORAGE_NAND | STORAGE_SD)
-#define CONFIG_STORAGE STORAGE_SD
+#define CONFIG_STORAGE (STORAGE_NAND | STORAGE_SD)
/* Support FAT16 for SD cards <= 2GB */
#define HAVE_FAT16SUPPORT
@@ -51,6 +50,9 @@
/* ChinaChip NAND FTL */
#define CONFIG_NAND NAND_CC
+#define HAVE_MULTIDRIVE
+#define NUM_DRIVES 2
+
/* define this if you have a bitmap LCD display */
#define HAVE_LCD_BITMAP
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 @@
#define CONFIG_NAND NAND_CC
-#define HAVE_MULTIVOLUME
+#define HAVE_MULTIDRIVE
+#define NUM_DRIVES 2
/* define this if you have a bitmap LCD display */
#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 @@
#define HAVE_MAS_SIBI_CONTROL
/* define this if more than one device/partition can be used */
-#define HAVE_MULTIVOLUME
+#define HAVE_MULTIDRIVE
+#define NUM_DRIVES 2
/* define this if media can be exchanged on the fly */
#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 @@
#define HAVE_MAS_SIBI_CONTROL
/* define this if more than one device/partition can be used */
-#define HAVE_MULTIVOLUME
+#define HAVE_MULTIDRIVE
+#define NUM_DRIVES 2
/* define this if media can be exchanged on the fly */
#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*/
#define CONFIG_TUNER_MULTI
#endif
-#if (CONFIG_STORAGE & (CONFIG_STORAGE - 1)) != 0
-/* Multiple storage drivers */
-#define CONFIG_STORAGE_MULTI
-#endif
-
/* deactivate fading in bootloader/sim */
#if defined(BOOTLOADER) || defined(SIMULATOR)
#undef CONFIG_BACKLIGHT_FADING
@@ -571,6 +566,37 @@ Lyre prototype 1*/
#endif /* CONFIG_BACKLIGHT_FADING */
+/* Storage related config handling */
+
+#if (CONFIG_STORAGE & (CONFIG_STORAGE - 1)) != 0
+/* Multiple storage drivers */
+#define CONFIG_STORAGE_MULTI
+#endif
+
+/* Explicit HAVE_MULTIVOLUME in the config file. Allow the maximum number */
+#ifdef HAVE_MULTIVOLUME
+#define NUM_VOLUMES_PER_DRIVE 4
+#else
+#define NUM_VOLUMES_PER_DRIVE 1
+#endif
+#if defined(CONFIG_STORAGE_MULTI) && !defined(HAVE_MULTIDRIVE)
+#define HAVE_MULTIDRIVE
+#endif
+
+#if defined(HAVE_MULTIDRIVE) && !defined(HAVE_MULTIVOLUME)
+#define HAVE_MULTIVOLUME
+#endif
+
+#if defined(HAVE_MULTIDRIVE) && !defined(NUM_DRIVES)
+#error HAVE_MULTIDRIVE needs to have an explicit NUM_DRIVES
+#endif
+
+#ifndef NUM_DRIVES
+#define NUM_DRIVES 1
+#endif
+
+#define NUM_VOLUMES (NUM_DRIVES * NUM_VOLUMES_PER_DRIVE)
+
#if defined(BOOTLOADER) && defined(HAVE_ADJUSTABLE_CPU_FREQ)
/* Bootloaders don't use CPU frequency adjustment */
#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 {
#define PARTITION_TYPE_OS2_HIDDEN_C_DRIVE 0x84
/* returns a pointer to an array of 8 partinfo structs */
-struct partinfo* disk_init(IF_MV_NONVOID(int volume));
+struct partinfo* disk_init(IF_MD_NONVOID(int drive));
struct partinfo* disk_partinfo(int partition);
int disk_mount_all(void); /* returns the # of successful mounts */
int 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);
#endif
extern void fat_init(void);
-extern int fat_mount(IF_MV2(int volume,) IF_MV2(int drive,) long startsector);
+extern int fat_mount(IF_MV2(int volume,) IF_MD2(int drive,) long startsector);
extern int fat_unmount(int volume, bool flush);
extern void fat_size(IF_MV2(int volume,) /* public for info */
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 @@
#define __MMC_H__
#include <stdbool.h>
-#include "mv.h" /* for HAVE_MULTIVOLUME or not */
+#include "mv.h" /* for HAVE_MULTIDRIVE or not */
struct storage_info;
@@ -35,19 +35,24 @@ bool mmc_disk_is_active(void);
int mmc_soft_reset(void);
int mmc_init(void);
void mmc_close(void);
-int mmc_read_sectors(IF_MV2(int drive,) unsigned long start, int count, void* buf);
-int mmc_write_sectors(IF_MV2(int drive,) unsigned long start, int count, const void* buf);
+int mmc_read_sectors(IF_MD2(int drive,) unsigned long start, int count, void* buf);
+int mmc_write_sectors(IF_MD2(int drive,) unsigned long start, int count, const void* buf);
void mmc_spin(void);
int mmc_spinup_time(void);
#ifdef STORAGE_GET_INFO
-void mmc_get_info(IF_MV2(int drive,) struct storage_info *info);
+void mmc_get_info(IF_MD2(int drive,) struct storage_info *info);
#endif
#ifdef HAVE_HOTSWAP
-bool mmc_removable(IF_MV_NONVOID(int drive));
-bool mmc_present(IF_MV_NONVOID(int drive));
+bool mmc_removable(IF_MD_NONVOID(int drive));
+bool mmc_present(IF_MD_NONVOID(int drive));
#endif
long mmc_last_disk_activity(void);
+#ifdef CONFIG_STORAGE_MULTI
+int mmc_num_drives(int first_drive);
+#endif
+
+
#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 @@
/* FixMe: These macros are a bit nasty and perhaps misplaced here.
We'll get rid of them once decided on how to proceed with multivolume. */
+
+/* Drives are things like a disk, a card, a flash chip. They can have volumes on them */
+#ifdef HAVE_MULTIDRIVE
+#define IF_MD(x) x /* optional drive parameter */
+#define IF_MD2(x,y) x,y /* same, for a list of arguments */
+#define IF_MD_NONVOID(x) x /* for prototype with sole volume parameter */
+#else /* empty definitions if no multi-drive */
+#define IF_MD(x)
+#define IF_MD2(x,y)
+#define IF_MD_NONVOID(x) void
+#endif
+
+/* Volumes mean things that have filesystems on them, like partitions */
#ifdef HAVE_MULTIVOLUME
-#define IF_MV(x) x /* optional volume/drive parameter */
+#define IF_MV(x) x /* optional volume parameter */
#define IF_MV2(x,y) x,y /* same, for a list of arguments */
#define IF_MV_NONVOID(x) x /* for prototype with sole volume parameter */
-#define NUM_VOLUMES 2
#else /* empty definitions if no multi-volume */
#define IF_MV(x)
#define IF_MV2(x,y)
#define IF_MV_NONVOID(x) void
-#define NUM_VOLUMES 1
#endif
+
#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 @@
#define __NAND_H__
#include <stdbool.h>
-#include "mv.h" /* for HAVE_MULTIVOLUME or not */
+#include "mv.h" /* for HAVE_MULTIDRIVE or not */
struct storage_info;
void nand_enable(bool on);
void nand_spindown(int seconds);
void nand_sleep(void);
+void nand_sleepnow(void);
bool nand_disk_is_active(void);
-int nand_soft_reset(void);
-int nand_init(void);
+int nand_soft_reset(void);
+int nand_init(void);
void nand_close(void);
-int nand_read_sectors(IF_MV2(int drive,) unsigned long start, int count, void* buf);
-int nand_write_sectors(IF_MV2(int drive,) unsigned long start, int count, const void* buf);
+int nand_read_sectors(IF_MD2(int drive,) unsigned long start, int count, void* buf);
+int nand_write_sectors(IF_MD2(int drive,) unsigned long start, int count, const void* buf);
void nand_spin(void);
+int nand_spinup_time(void); /* ticks */
#ifdef STORAGE_GET_INFO
-void nand_get_info(IF_MV2(int drive,) struct storage_info *info);
+void nand_get_info(IF_MD2(int drive,) struct storage_info *info);
#endif
long nand_last_disk_activity(void);
+#ifdef CONFIG_STORAGE_MULTI
+int nand_num_drives(int first_drive);
+#endif
+
#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 @@
#define __RAMDISK_H__
#include <stdbool.h>
-#include "mv.h" /* for HAVE_MULTIVOLUME or not */
+#include "mv.h" /* for HAVE_MULTIDRIVE or not */
struct storage_info;
@@ -34,15 +34,20 @@ bool ramdisk_disk_is_active(void);
int ramdisk_soft_reset(void);
int ramdisk_init(void);
void ramdisk_close(void);
-int ramdisk_read_sectors(IF_MV2(int drive,) unsigned long start, int count, void* buf);
-int ramdisk_write_sectors(IF_MV2(int drive,) unsigned long start, int count, const void* buf);
+int ramdisk_read_sectors(IF_MD2(int drive,) unsigned long start, int count, void* buf);
+int ramdisk_write_sectors(IF_MD2(int drive,) unsigned long start, int count, const void* buf);
void ramdisk_spin(void);
void ramdisk_sleepnow(void);
+int ramdisk_spinup_time(void);
#ifdef STORAGE_GET_INFO
-void ramdisk_get_info(IF_MV2(int drive,) struct storage_info *info);
+void ramdisk_get_info(IF_MD2(int drive,) struct storage_info *info);
#endif
long ramdisk_last_disk_activity(void);
+#ifdef CONFIG_STORAGE_MULTI
+int ramdisk_num_drives(int first_drive);
+#endif
+
#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 @@
#define __SD_H__
#include <stdbool.h>
-#include "mv.h" /* for HAVE_MULTIVOLUME or not */
+#include "mv.h" /* for HAVE_MULTIDRIVE or not */
#define SD_BLOCK_SIZE 512 /* XXX : support other sizes ? */
@@ -32,27 +32,34 @@ struct storage_info;
void sd_enable(bool on);
void sd_spindown(int seconds);
void sd_sleep(void);
+void sd_sleepnow(void);
bool sd_disk_is_active(void);
-int sd_soft_reset(void);
-int sd_init(void);
+int sd_soft_reset(void);
+int sd_init(void);
void sd_close(void);
-int sd_read_sectors(IF_MV2(int drive,) unsigned long start, int count, void* buf);
-int sd_write_sectors(IF_MV2(int drive,) unsigned long start, int count, const void* buf);
+int sd_read_sectors(IF_MD2(int drive,) unsigned long start, int count, void* buf);
+int sd_write_sectors(IF_MD2(int drive,) unsigned long start, int count, const void* buf);
void sd_spin(void);
+int sd_spinup_time(void); /* ticks */
#ifdef STORAGE_GET_INFO
-void sd_get_info(IF_MV2(int drive,) struct storage_info *info);
+void sd_get_info(IF_MD2(int drive,) struct storage_info *info);
#endif
#ifdef HAVE_HOTSWAP
bool sd_removable(IF_MV_NONVOID(int drive));
bool sd_present(IF_MV_NONVOID(int drive));
-void card_enable_monitoring_target(bool on);
+void card_enable_monitoring_target(bool on);
#endif
-bool card_detect_target(void);
+bool card_detect_target(void);
long sd_last_disk_activity(void);
+#ifdef CONFIG_STORAGE_MULTI
+int sd_num_drives(int first_drive);
+#endif
+
+
/* SD States */
#define SD_IDLE 0
#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 @@
#define __STORAGE_H__
#include <stdbool.h>
-#include "config.h" /* for HAVE_MULTIVOLUME or not */
+#include "config.h" /* for HAVE_MULTIDRIVE or not */
#include "mv.h"
#if (CONFIG_STORAGE & STORAGE_SD)
@@ -51,154 +51,147 @@ struct storage_info
char *revision;
};
-#ifndef SIMULATOR
- #ifndef CONFIG_STORAGE_MULTI
- /* storage_spindown, storage_sleep and storage_spin are passed as
- * pointers, which doesn't work with argument-macros.
- */
- #if (CONFIG_STORAGE & STORAGE_ATA)
- #define storage_spindown ata_spindown
- #define storage_sleep ata_sleep
- #define storage_spin ata_spin
-
- #define storage_enable(on) ata_enable(on)
- #define storage_sleepnow() ata_sleepnow()
- #define storage_disk_is_active() ata_disk_is_active()
- #define storage_soft_reset() ata_soft_reset()
- #define storage_init() ata_init()
- #define storage_close() ata_close()
- #define storage_read_sectors(drive, start, count, buf) ata_read_sectors(IF_MV2(drive,) start, count, buf)
- #define storage_write_sectors(drive, start, count, buf) ata_write_sectors(IF_MV2(drive,) start, count, buf)
- #define storage_last_disk_activity() ata_last_disk_activity()
- #define storage_spinup_time() ata_spinup_time()
- #define storage_get_identify() ata_get_identify()
-
- #ifdef STORAGE_GET_INFO
- #define storage_get_info(drive, info) ata_get_info(IF_MV2(drive,) info)
- #endif
- #ifdef HAVE_HOTSWAP
- #define storage_removable(drive) ata_removable(IF_MV(drive))
- #define storage_present(drive) ata_present(IF_MV(drive))
- #endif
- #elif (CONFIG_STORAGE & STORAGE_SD)
- #define storage_spindown sd_spindown
- #define storage_sleep sd_sleep
- #define storage_spin sd_spin
-
- #define storage_enable(on) sd_enable(on)
- #define storage_sleepnow() sd_sleepnow()
- #define storage_disk_is_active() 0
- #define storage_soft_reset() (void)0
- #define storage_init() sd_init()
- #define storage_close() sd_close()
- #define storage_read_sectors(drive, start, count, buf) sd_read_sectors(IF_MV2(drive,) start, count, buf)
- #define storage_write_sectors(drive, start, count, buf) sd_write_sectors(IF_MV2(drive,) start, count, buf)
- #define storage_last_disk_activity() sd_last_disk_activity()
- #define storage_spinup_time() 0
- #define storage_get_identify() sd_get_identify()
-
- #ifdef STORAGE_GET_INFO
- #define storage_get_info(drive, info) sd_get_info(IF_MV2(drive,) info)
- #endif
- #ifdef HAVE_HOTSWAP
- #define storage_removable(drive) sd_removable(IF_MV(drive))
- #define storage_present(drive) sd_present(IF_MV(drive))
- #endif
- #elif (CONFIG_STORAGE & STORAGE_MMC)
- #define storage_spindown mmc_spindown
- #define storage_sleep mmc_sleep
- #define storage_spin mmc_spin
-
- #define storage_enable(on) mmc_enable(on)
- #define storage_sleepnow() mmc_sleepnow()
- #define storage_disk_is_active() mmc_disk_is_active()
- #define storage_soft_reset() (void)0
- #define storage_init() mmc_init()
- #define storage_close() mmc_close()
- #define storage_read_sectors(drive, start, count, buf) mmc_read_sectors(IF_MV2(drive,) start, count, buf)
- #define storage_write_sectors(drive, start, count, buf) mmc_write_sectors(IF_MV2(drive,) start, count, buf)
- #define storage_last_disk_activity() mmc_last_disk_activity()
- #define storage_spinup_time() 0
- #define storage_get_identify() mmc_get_identify()
-
- #ifdef STORAGE_GET_INFO
- #define storage_get_info(drive, info) mmc_get_info(IF_MV2(drive,) info)
- #endif
- #ifdef HAVE_HOTSWAP
- #define storage_removable(drive) mmc_removable(IF_MV(drive))
- #define storage_present(drive) mmc_present(IF_MV(drive))
- #endif
- #elif (CONFIG_STORAGE & STORAGE_NAND)
- #define storage_spindown nand_spindown
- #define storage_sleep nand_sleep
- #define storage_spin nand_spin
-
- #define storage_enable(on) (void)0
- #define storage_sleepnow() nand_sleepnow()
- #define storage_disk_is_active() 0
- #define storage_soft_reset() (void)0
- #define storage_init() nand_init()
- #define storage_close() nand_close()
- #define storage_read_sectors(drive, start, count, buf) nand_read_sectors(IF_MV2(drive,) start, count, buf)
- #define storage_write_sectors(drive, start, count, buf) nand_write_sectors(IF_MV2(drive,) start, count, buf)
- #define storage_last_disk_activity() nand_last_disk_activity()
- #define storage_spinup_time() 0
- #define storage_get_identify() nand_get_identify()
-
- #ifdef STORAGE_GET_INFO
- #define storage_get_info(drive, info) nand_get_info(IF_MV2(drive,) info)
- #endif
- #ifdef HAVE_HOTSWAP
- #define storage_removable(drive) nand_removable(IF_MV(drive))
- #define storage_present(drive) nand_present(IF_MV(drive))
- #endif
- #elif (CONFIG_STORAGE & STORAGE_RAMDISK)
- #define storage_spindown ramdisk_spindown
- #define storage_sleep ramdisk_sleep
- #define storage_spin ramdisk_spin
-
- #define storage_enable(on) (void)0
- #define storage_sleepnow() ramdisk_sleepnow()
- #define storage_disk_is_active() 0
- #define storage_soft_reset() (void)0
- #define storage_init() ramdisk_init()
- #define storage_close() ramdisk_close()
- #define storage_read_sectors(drive, start, count, buf) ramdisk_read_sectors(IF_MV2(drive,) start, count, buf)
- #define storage_write_sectors(drive, start, count, buf) ramdisk_write_sectors(IF_MV2(drive,) start, count, buf)
- #define storage_last_disk_activity() ramdisk_last_disk_activity()
- #define storage_spinup_time() 0
- #define storage_get_identify() ramdisk_get_identify()
-
- #ifdef STORAGE_GET_INFO
- #define storage_get_info(drive, info) ramdisk_get_info(IF_MV2(drive,) info)
- #endif
- #ifdef HAVE_HOTSWAP
- #define storage_removable(drive) ramdisk_removable(IF_MV(drive))
- #define storage_present(drive) ramdisk_present(IF_MV(drive))
- #endif
- #else
- //#error No storage driver!
- #endif
- #else /* NOT CONFIG_STORAGE_MULTI */
-
- /* TODO : implement multi-driver here */
- #error Multi-driver storage not implemented yet
-
- #endif /* NOT CONFIG_STORAGE_MULTI */
-#else /*NOT SIMULATOR */
+#if !defined(SIMULATOR) && !defined(CONFIG_STORAGE_MULTI)
+/* storage_spindown, storage_sleep and storage_spin are passed as
+ * pointers, which doesn't work with argument-macros.
+ */
+ #define storage_num_drives() NUM_DRIVES
+ #if (CONFIG_STORAGE & STORAGE_ATA)
+ #define storage_spindown ata_spindown
+ #define storage_sleep ata_sleep
+ #define storage_spin ata_spin
+
+ #define storage_enable(on) ata_enable(on)
+ #define storage_sleepnow() ata_sleepnow()
+ #define storage_disk_is_active() ata_disk_is_active()
+ #define storage_soft_reset() ata_soft_reset()
+ #define storage_init() ata_init()
+ #define storage_close() ata_close()
+ #define storage_read_sectors(drive, start, count, buf) ata_read_sectors(IF_MD2(drive,) start, count, buf)
+ #define storage_write_sectors(drive, start, count, buf) ata_write_sectors(IF_MD2(drive,) start, count, buf)
+ #define storage_last_disk_activity() ata_last_disk_activity()
+ #define storage_spinup_time() ata_spinup_time()
+ #define storage_get_identify() ata_get_identify()
+
+ #ifdef STORAGE_GET_INFO
+ #define storage_get_info(drive, info) ata_get_info(IF_MD2(drive,) info)
+ #endif
+ #ifdef HAVE_HOTSWAP
+ #define storage_removable(drive) ata_removable(IF_MD(drive))
+ #define storage_present(drive) ata_present(IF_MD(drive))
+ #endif
+ #elif (CONFIG_STORAGE & STORAGE_SD)
+ #define storage_spindown sd_spindown
+ #define storage_sleep sd_sleep
+ #define storage_spin sd_spin
+
+ #define storage_enable(on) sd_enable(on)
+ #define storage_sleepnow() sd_sleepnow()
+ #define storage_disk_is_active() 0
+ #define storage_soft_reset() (void)0
+ #define storage_init() sd_init()
+ #define storage_read_sectors(drive, start, count, buf) sd_read_sectors(IF_MD2(drive,) start, count, buf)
+ #define storage_write_sectors(drive, start, count, buf) sd_write_sectors(IF_MD2(drive,) start, count, buf)
+ #define storage_last_disk_activity() sd_last_disk_activity()
+ #define storage_spinup_time() 0
+ #define storage_get_identify() sd_get_identify()
+
+ #ifdef STORAGE_GET_INFO
+ #define storage_get_info(drive, info) sd_get_info(IF_MD2(drive,) info)
+ #endif
+ #ifdef HAVE_HOTSWAP
+ #define storage_removable(drive) sd_removable(IF_MD(drive))
+ #define storage_present(drive) sd_present(IF_MD(drive))
+ #endif
+ #elif (CONFIG_STORAGE & STORAGE_MMC)
+ #define storage_spindown mmc_spindown
+ #define storage_sleep mmc_sleep
+ #define storage_spin mmc_spin
+
+ #define storage_enable(on) mmc_enable(on)
+ #define storage_sleepnow() mmc_sleepnow()
+ #define storage_disk_is_active() mmc_disk_is_active()
+ #define storage_soft_reset() (void)0
+ #define storage_init() mmc_init()
+ #define storage_read_sectors(drive, start, count, buf) mmc_read_sectors(IF_MD2(drive,) start, count, buf)
+ #define storage_write_sectors(drive, start, count, buf) mmc_write_sectors(IF_MD2(drive,) start, count, buf)
+ #define storage_last_disk_activity() mmc_last_disk_activity()
+ #define storage_spinup_time() 0
+ #define storage_get_identify() mmc_get_identify()
+
+ #ifdef STORAGE_GET_INFO
+ #define storage_get_info(drive, info) mmc_get_info(IF_MD2(drive,) info)
+ #endif
+ #ifdef HAVE_HOTSWAP
+ #define storage_removable(drive) mmc_removable(IF_MD(drive))
+ #define storage_present(drive) mmc_present(IF_MD(drive))
+ #endif
+ #elif (CONFIG_STORAGE & STORAGE_NAND)
+ #define storage_spindown nand_spindown
+ #define storage_sleep nand_sleep
+ #define storage_spin nand_spin
+
+ #define storage_enable(on) (void)0
+ #define storage_sleepnow() nand_sleepnow()
+ #define storage_disk_is_active() 0
+ #define storage_soft_reset() (void)0
+ #define storage_init() nand_init()
+ #define storage_read_sectors(drive, start, count, buf) nand_read_sectors(IF_MD2(drive,) start, count, buf)
+ #define storage_write_sectors(drive, start, count, buf) nand_write_sectors(IF_MD2(drive,) start, count, buf)
+ #define storage_last_disk_activity() nand_last_disk_activity()
+ #define storage_spinup_time() 0
+ #define storage_get_identify() nand_get_identify()
+
+ #ifdef STORAGE_GET_INFO
+ #define storage_get_info(drive, info) nand_get_info(IF_MD2(drive,) info)
+ #endif
+ #ifdef HAVE_HOTSWAP
+ #define storage_removable(drive) nand_removable(IF_MD(drive))
+ #define storage_present(drive) nand_present(IF_MD(drive))
+ #endif
+ #elif (CONFIG_STORAGE & STORAGE_RAMDISK)
+ #define storage_spindown ramdisk_spindown
+ #define storage_sleep ramdisk_sleep
+ #define storage_spin ramdisk_spin
+
+ #define storage_enable(on) (void)0
+ #define storage_sleepnow() ramdisk_sleepnow()
+ #define storage_disk_is_active() 0
+ #define storage_soft_reset() (void)0
+ #define storage_init() ramdisk_init()
+ #define storage_read_sectors(drive, start, count, buf) ramdisk_read_sectors(IF_MD2(drive,) start, count, buf)
+ #define storage_write_sectors(drive, start, count, buf) ramdisk_write_sectors(IF_MD2(drive,) start, count, buf)
+ #define storage_last_disk_activity() ramdisk_last_disk_activity()
+ #define storage_spinup_time() 0
+ #define storage_get_identify() ramdisk_get_identify()
+
+ #ifdef STORAGE_GET_INFO
+ #define storage_get_info(drive, info) ramdisk_get_info(IF_MD2(drive,) info)
+ #endif
+ #ifdef HAVE_HOTSWAP
+ #define storage_removable(drive) ramdisk_removable(IF_MD(drive))
+ #define storage_present(drive) ramdisk_present(IF_MD(drive))
+ #endif
+ #else
+ //#error No storage driver!
+ #endif
+#else /* NOT CONFIG_STORAGE_MULTI and NOT SIMULATOR*/
+
+/* Simulator and multi-driver use normal functions */
+
void storage_enable(bool on);
void storage_sleep(void);
void storage_sleepnow(void);
bool storage_disk_is_active(void);
int storage_soft_reset(void);
int storage_init(void);
-void storage_close(void);
int storage_read_sectors(int drive, unsigned long start, int count, void* buf);
int storage_write_sectors(int drive, unsigned long start, int count, const void* buf);
void storage_spin(void);
void storage_spindown(int seconds);
long storage_last_disk_activity(void);
int storage_spinup_time(void);
+int storage_num_drives(void);
#ifdef STORAGE_GET_INFO
void storage_get_info(int drive, struct storage_info *info);
#endif
@@ -206,5 +199,6 @@ void storage_get_info(int drive, struct storage_info *info);
bool storage_removable(int drive);
bool storage_present(int drive);
#endif
-#endif/*NOT SIMULATOR */
+
+#endif /* NOT CONFIG_STORAGE_MULTI and NOT SIMULATOR*/
#endif