summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFrank Gevaerts <frank@gevaerts.be>2008-11-01 16:25:04 +0000
committerFrank Gevaerts <frank@gevaerts.be>2008-11-01 16:25:04 +0000
commitad9db4de3dee9db8f08b5a28f731b066c35e41e6 (patch)
tree266209a72c75a7436b253719408d092477396354
parent2f8a0081c64534da23fc0fa9cc685eb7454fd9c9 (diff)
downloadrockbox-ad9db4de3dee9db8f08b5a28f731b066c35e41e6.tar.gz
rockbox-ad9db4de3dee9db8f08b5a28f731b066c35e41e6.zip
Now also commit added files
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@18961 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--firmware/export/mmc.h55
-rw-r--r--firmware/export/mv.h41
-rw-r--r--firmware/export/nand.h50
-rw-r--r--firmware/export/sd.h54
-rw-r--r--firmware/export/storage.h239
-rw-r--r--firmware/storage.c35
6 files changed, 474 insertions, 0 deletions
diff --git a/firmware/export/mmc.h b/firmware/export/mmc.h
new file mode 100644
index 0000000000..2e7fb2441d
--- /dev/null
+++ b/firmware/export/mmc.h
@@ -0,0 +1,55 @@
+/***************************************************************************
+ * __________ __ ___.
+ * Open \______ \ ____ ____ | | _\_ |__ _______ ___
+ * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
+ * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
+ * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
+ * \/ \/ \/ \/ \/
+ * $Id$
+ *
+ * Copyright (C) 2002 by Alan Korr
+ * Copyright (C) 2008 by Frank Gevaerts
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
+ * KIND, either express or implied.
+ *
+ ****************************************************************************/
+#ifndef __MMC_H__
+#define __MMC_H__
+
+#include <stdbool.h>
+#include "mv.h" /* for HAVE_MULTIVOLUME or not */
+
+struct storage_info;
+
+void mmc_enable(bool on);
+void mmc_spindown(int seconds);
+void mmc_sleep(void);
+void mmc_sleepnow(void);
+bool mmc_disk_is_active(void);
+int mmc_hard_reset(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);
+void mmc_spin(void);
+
+#if (CONFIG_LED == LED_REAL)
+void mmc_set_led_enabled(bool enabled);
+#endif
+
+void mmc_get_info(IF_MV2(int drive,) struct storage_info *info);
+#ifdef HAVE_HOTSWAP
+bool mmc_removable(IF_MV_NONVOID(int drive));
+bool mmc_present(IF_MV_NONVOID(int drive));
+#endif
+
+long mmc_last_disk_activity(void);
+
+#endif
diff --git a/firmware/export/mv.h b/firmware/export/mv.h
new file mode 100644
index 0000000000..fda650c7e9
--- /dev/null
+++ b/firmware/export/mv.h
@@ -0,0 +1,41 @@
+/***************************************************************************
+ * __________ __ ___.
+ * Open \______ \ ____ ____ | | _\_ |__ _______ ___
+ * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
+ * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
+ * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
+ * \/ \/ \/ \/ \/
+ * $Id$
+ *
+ * Copyright (C) 2008 by Frank Gevaerts
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
+ * KIND, either express or implied.
+ *
+ ****************************************************************************/
+
+#ifndef __MV_H__
+#define __MV_H__
+
+#include "config.h"
+
+/* 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. */
+#ifdef HAVE_MULTIVOLUME
+#define IF_MV(x) x /* optional volume/drive 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
new file mode 100644
index 0000000000..3d4d1ce166
--- /dev/null
+++ b/firmware/export/nand.h
@@ -0,0 +1,50 @@
+/***************************************************************************
+ * __________ __ ___.
+ * Open \______ \ ____ ____ | | _\_ |__ _______ ___
+ * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
+ * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
+ * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
+ * \/ \/ \/ \/ \/
+ * $Id$
+ *
+ * Copyright (C) 2002 by Alan Korr
+ * Copyright (C) 2008 by Frank Gevaerts
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
+ * KIND, either express or implied.
+ *
+ ****************************************************************************/
+#ifndef __NAND_H__
+#define __NAND_H__
+
+#include <stdbool.h>
+#include "mv.h" /* for HAVE_MULTIVOLUME or not */
+
+struct storage_info;
+
+void nand_enable(bool on);
+void nand_spindown(int seconds);
+void nand_sleep(void);
+bool nand_disk_is_active(void);
+int nand_hard_reset(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);
+void nand_spin(void);
+
+#if (CONFIG_LED == LED_REAL)
+void nand_set_led_enabled(bool enabled);
+#endif
+
+void nand_get_info(IF_MV2(int drive,) struct storage_info *info);
+
+long nand_last_disk_activity(void);
+
+#endif
diff --git a/firmware/export/sd.h b/firmware/export/sd.h
new file mode 100644
index 0000000000..8e1fa88ceb
--- /dev/null
+++ b/firmware/export/sd.h
@@ -0,0 +1,54 @@
+/***************************************************************************
+ * __________ __ ___.
+ * Open \______ \ ____ ____ | | _\_ |__ _______ ___
+ * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
+ * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
+ * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
+ * \/ \/ \/ \/ \/
+ * $Id$
+ *
+ * Copyright (C) 2002 by Alan Korr
+ * Copyright (C) 2008 by Frank Gevaerts
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
+ * KIND, either express or implied.
+ *
+ ****************************************************************************/
+#ifndef __SD_H__
+#define __SD_H__
+
+#include <stdbool.h>
+#include "mv.h" /* for HAVE_MULTIVOLUME or not */
+
+struct storage_info;
+
+void sd_enable(bool on);
+void sd_spindown(int seconds);
+void sd_sleep(void);
+bool sd_disk_is_active(void);
+int sd_hard_reset(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);
+void sd_spin(void);
+
+#if (CONFIG_LED == LED_REAL)
+void sd_set_led_enabled(bool enabled);
+#endif
+
+void sd_get_info(IF_MV2(int drive,) struct storage_info *info);
+#ifdef HAVE_HOTSWAP
+bool sd_removable(IF_MV_NONVOID(int drive));
+bool sd_present(IF_MV_NONVOID(int drive));
+#endif
+
+long sd_last_disk_activity(void);
+
+#endif
diff --git a/firmware/export/storage.h b/firmware/export/storage.h
new file mode 100644
index 0000000000..95e42f67f4
--- /dev/null
+++ b/firmware/export/storage.h
@@ -0,0 +1,239 @@
+/***************************************************************************
+ * __________ __ ___.
+ * Open \______ \ ____ ____ | | _\_ |__ _______ ___
+ * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
+ * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
+ * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
+ * \/ \/ \/ \/ \/
+ * $Id$
+ *
+ * Copyright (C) 2002 by Alan Korr
+ * Copyright (C) 2008 by Frank Gevaerts
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
+ * KIND, either express or implied.
+ *
+ ****************************************************************************/
+#ifndef __STORAGE_H__
+#define __STORAGE_H__
+
+#include <stdbool.h>
+#include "config.h" /* for HAVE_MULTIVOLUME or not */
+#include "mv.h"
+
+#if (CONFIG_STORAGE & STORAGE_SD)
+#include "sd.h"
+#endif
+#if (CONFIG_STORAGE & STORAGE_MMC)
+#include "mmc.h"
+#endif
+#if (CONFIG_STORAGE & STORAGE_ATA)
+#include "ata.h"
+#endif
+#if (CONFIG_STORAGE & STORAGE_NAND)
+#include "nand.h"
+#endif
+
+struct storage_info
+{
+ unsigned int sector_size;
+ unsigned int num_sectors;
+ char *vendor;
+ char *product;
+ char *revision;
+};
+
+void storage_spindown(int seconds);
+
+static inline void storage_enable(bool on)
+{
+#if (CONFIG_STORAGE & STORAGE_ATA)
+ ata_enable(on);
+#elif (CONFIG_STORAGE & STORAGE_SD)
+ sd_enable(on);
+#elif (CONFIG_STORAGE & STORAGE_MMC)
+ mmc_enable(on);
+#else
+ (void)on;
+#endif
+}
+static inline void storage_sleep(void)
+{
+#if (CONFIG_STORAGE & STORAGE_ATA)
+ ata_sleep();
+#endif
+}
+static inline void storage_sleepnow(void)
+{
+#if (CONFIG_STORAGE & STORAGE_ATA)
+ ata_sleepnow();
+#endif
+}
+static inline bool storage_disk_is_active(void)
+{
+#if (CONFIG_STORAGE & STORAGE_ATA)
+ return ata_disk_is_active();
+#elif (CONFIG_STORAGE & STORAGE_MMC)
+ return mmc_disk_is_active();
+#else
+ return 0;
+#endif
+}
+static inline int storage_hard_reset(void)
+{
+#if (CONFIG_STORAGE & STORAGE_ATA)
+ return ata_hard_reset();
+#else
+ return 0;
+#endif
+}
+static inline int storage_soft_reset(void)
+{
+#if (CONFIG_STORAGE & STORAGE_ATA)
+ return ata_soft_reset();
+#else
+ return 0;
+#endif
+}
+static inline int storage_init(void)
+{
+#if (CONFIG_STORAGE & STORAGE_ATA)
+ return ata_init();
+#elif (CONFIG_STORAGE & STORAGE_SD)
+ return sd_init();
+#elif (CONFIG_STORAGE & STORAGE_NAND)
+ return nand_init();
+#elif (CONFIG_STORAGE & STORAGE_MMC)
+ return mmc_init();
+#else
+ #error No storage driver!
+#endif
+}
+static inline int storage_read_sectors(IF_MV2(int drive,) unsigned long start, int count, void* buf)
+{
+#if (CONFIG_STORAGE & STORAGE_ATA)
+ return ata_read_sectors(IF_MV2(drive,) start, count, buf);
+#elif (CONFIG_STORAGE & STORAGE_SD)
+ return sd_read_sectors(IF_MV2(drive,) start, count, buf);
+#elif (CONFIG_STORAGE & STORAGE_NAND)
+ return nand_read_sectors(IF_MV2(drive,) start, count, buf);
+#elif (CONFIG_STORAGE & STORAGE_MMC)
+ return mmc_read_sectors(IF_MV2(drive,) start, count, buf);
+#else
+ #error No storage driver!
+#endif
+}
+static inline int storage_write_sectors(IF_MV2(int drive,) unsigned long start, int count, const void* buf)
+{
+#if (CONFIG_STORAGE & STORAGE_ATA)
+ return ata_write_sectors(IF_MV2(drive,) start, count, buf);
+#elif (CONFIG_STORAGE & STORAGE_SD)
+ return sd_write_sectors(IF_MV2(drive,) start, count, buf);
+#elif (CONFIG_STORAGE & STORAGE_NAND)
+ return nand_write_sectors(IF_MV2(drive,) start, count, buf);
+#elif (CONFIG_STORAGE & STORAGE_MMC)
+ return mmc_write_sectors(IF_MV2(drive,) start, count, buf);
+#else
+ #error No storage driver!
+#endif
+}
+static inline void storage_spin(void)
+{
+#if (CONFIG_STORAGE & STORAGE_ATA)
+ ata_spin();
+#endif
+}
+
+#if (CONFIG_LED == LED_REAL)
+static inline void storage_set_led_enabled(bool enabled)
+{
+#if (CONFIG_STORAGE & STORAGE_ATA)
+ ata_set_led_enabled(enabled);
+#elif (CONFIG_STORAGE & STORAGE_SD)
+ sd_set_led_enabled(enabled);
+#elif (CONFIG_STORAGE & STORAGE_NAND)
+ nand_set_led_enabled(enabled);
+#elif (CONFIG_STORAGE & STORAGE_MMC)
+ mmc_set_led_enabled(enabled);
+#else
+ #error No storage driver!
+#endif
+}
+#endif
+
+static inline long storage_last_disk_activity(void)
+{
+#if (CONFIG_STORAGE & STORAGE_ATA)
+ return ata_last_disk_activity();
+#elif (CONFIG_STORAGE & STORAGE_SD)
+ return sd_last_disk_activity();
+#elif (CONFIG_STORAGE & STORAGE_NAND)
+ return nand_last_disk_activity();
+#elif (CONFIG_STORAGE & STORAGE_MMC)
+ return mmc_last_disk_activity();
+#else
+ #error No storage driver!
+#endif
+}
+
+static inline int storage_spinup_time(void)
+{
+#if (CONFIG_STORAGE & STORAGE_ATA)
+ return ata_spinup_time();
+#else
+ return 0;
+#endif
+}
+
+static inline void storage_get_info(IF_MV2(int drive,) struct storage_info *info)
+{
+#if (CONFIG_STORAGE & STORAGE_ATA)
+ return ata_get_info(IF_MV2(drive,) info);
+#elif (CONFIG_STORAGE & STORAGE_SD)
+ return sd_get_info(IF_MV2(drive,) info);
+#elif (CONFIG_STORAGE & STORAGE_NAND)
+ return nand_get_info(IF_MV2(drive,) info);
+#elif (CONFIG_STORAGE & STORAGE_MMC)
+ return mmc_get_info(IF_MV2(drive,) info);
+#else
+ #error No storage driver!
+#endif
+}
+
+#ifdef HAVE_HOTSWAP
+static inline bool storage_removable(IF_MV_NONVOID(int drive))
+{
+#if (CONFIG_STORAGE & STORAGE_ATA)
+ return ata_removable(IF_MV(drive));
+#elif (CONFIG_STORAGE & STORAGE_SD)
+ return sd_removable(IF_MV(drive));
+#elif (CONFIG_STORAGE & STORAGE_NAND)
+ return nand_removable(IF_MV(drive));
+#elif (CONFIG_STORAGE & STORAGE_MMC)
+ return mmc_removable(IF_MV(drive));
+#else
+ #error No storage driver!
+#endif
+}
+
+static inline bool storage_present(IF_MV_NONVOID(int drive))
+{
+#if (CONFIG_STORAGE & STORAGE_ATA)
+ return ata_present(IF_MV(drive));
+#elif (CONFIG_STORAGE & STORAGE_SD)
+ return sd_present(IF_MV(drive));
+#elif (CONFIG_STORAGE & STORAGE_NAND)
+ return nand_present(IF_MV(drive));
+#elif (CONFIG_STORAGE & STORAGE_MMC)
+ return mmc_present(IF_MV(drive));
+#else
+ #error No storage driver!
+#endif
+}
+#endif
+#endif
diff --git a/firmware/storage.c b/firmware/storage.c
new file mode 100644
index 0000000000..631fbe6177
--- /dev/null
+++ b/firmware/storage.c
@@ -0,0 +1,35 @@
+/***************************************************************************
+ * __________ __ ___.
+ * Open \______ \ ____ ____ | | _\_ |__ _______ ___
+ * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
+ * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
+ * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
+ * \/ \/ \/ \/ \/
+ * $Id: $
+ *
+ * Copyright (C) 2008 by Frank Gevaerts
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
+ * KIND, either express or implied.
+ *
+ ****************************************************************************/
+#include "config.h" /* for HAVE_MULTIVOLUME or not */
+#include "storage.h"
+
+/* storage_spindown() can't be inlined as it is passed as a function
+ pointer in settings_list.c
+*/
+
+void storage_spindown(int seconds)
+{
+#if (CONFIG_STORAGE & STORAGE_ATA)
+ ata_spindown(seconds);
+#else
+ (void)seconds;
+#endif
+}