summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Martitz <kugel@rockbox.org>2014-02-07 18:12:31 +0100
committerThomas Martitz <kugel@rockbox.org>2014-02-23 20:23:51 +0100
commit77f19f75eb3661b3e3966da20effa2631ed380f1 (patch)
tree1e29f482e6de115cf6cdbf9958cba3d7ce8dc6af
parent706e6b7a75339cadc7b8a856a2eace68f89bb168 (diff)
downloadrockbox-77f19f75eb3661b3e3966da20effa2631ed380f1.tar.gz
rockbox-77f19f75eb3661b3e3966da20effa2631ed380f1.tar.bz2
rockbox-77f19f75eb3661b3e3966da20effa2631ed380f1.zip
storage: Add STORAGE_HOSTFS
CONFIG_STORAGE & STORAGE_HOSTFS allows to use parts of the storage_* API to be compiled for application targets without compiling storage.c or performing actually raw storage access. This is primarily to enable application targets to implement HAVE_MULTIVOMULE/HAVE_HOTSWAP (in a later commit). SIMULATOR uses the same mechanism without explicitely defining STORAGE_HOSTFS (how to add a bit to an existing preprocessor token?). Change-Id: Ib3f8ee0d5231e2ed21ff00842d51e32bc4fc7292
-rw-r--r--apps/debug_menu.c2
-rw-r--r--firmware/export/config.h2
-rw-r--r--firmware/export/config/android.h4
-rw-r--r--firmware/export/config/nokian8xx.h4
-rw-r--r--firmware/export/config/nokian900.h4
-rw-r--r--firmware/export/config/pandora.h4
-rw-r--r--firmware/export/config/samsungypr0.h4
-rw-r--r--firmware/export/config/samsungypr1.h4
-rw-r--r--firmware/export/config/sdlapp.h4
-rw-r--r--firmware/export/config/sim.h2
-rw-r--r--firmware/export/storage.h32
-rw-r--r--firmware/target/hosted/android/system-android.c12
-rw-r--r--firmware/target/hosted/samsungypr/ypr0/system-ypr0.c14
-rw-r--r--firmware/target/hosted/samsungypr/ypr1/system-ypr1.c14
-rw-r--r--firmware/target/hosted/sdl/button-sdl.c1
-rw-r--r--firmware/target/hosted/sdl/system-sdl.c18
-rw-r--r--uisimulator/common/stubs.c7
17 files changed, 122 insertions, 10 deletions
diff --git a/apps/debug_menu.c b/apps/debug_menu.c
index 1007c97414..bc2a73fc9c 100644
--- a/apps/debug_menu.c
+++ b/apps/debug_menu.c
@@ -75,7 +75,7 @@
#include "tuner.h"
#include "radio.h"
#endif
-#endif
+#endif /* CONFIG_PLATFORM & PLATFORM_NATIVE */
#include "power.h"
#if (defined(SAMSUNG_YPR0) || defined(SAMSUNG_YPR1)) && defined(CONFIG_TUNER)
diff --git a/firmware/export/config.h b/firmware/export/config.h
index d2e1f6b830..f896fd68b5 100644
--- a/firmware/export/config.h
+++ b/firmware/export/config.h
@@ -32,6 +32,7 @@
#define STORAGE_SD 0x04
#define STORAGE_NAND 0x08
#define STORAGE_RAMDISK 0x10
+#define STORAGE_HOSTFS 0x20 /* meant for APPLICATION targets (implicit for SIMULATOR) */
/* CONFIG_TUNER (note these are combineable bit-flags) */
#define S1A0903X01 0x01 /* Samsung */
@@ -574,7 +575,6 @@ Lyre prototype 1 */
#ifdef APPLICATION
#define CONFIG_CPU 0
-#define CONFIG_STORAGE 0
#endif
/* keep this include after the target configs */
diff --git a/firmware/export/config/android.h b/firmware/export/config/android.h
index 2bc11c3051..2aee700f08 100644
--- a/firmware/export/config/android.h
+++ b/firmware/export/config/android.h
@@ -103,3 +103,7 @@
#define HAVE_HOTKEY
#define BOOTDIR "/.rockbox"
+
+/* No special storage */
+#define CONFIG_STORAGE STORAGE_HOSTFS
+#define HAVE_STORAGE_FLUSH
diff --git a/firmware/export/config/nokian8xx.h b/firmware/export/config/nokian8xx.h
index c8d87838e7..566683c760 100644
--- a/firmware/export/config/nokian8xx.h
+++ b/firmware/export/config/nokian8xx.h
@@ -94,3 +94,7 @@
#define HAVE_HOTKEY
#define BOOTDIR "/.rockbox"
+
+/* No special storage */
+#define CONFIG_STORAGE STORAGE_HOSTFS
+#define HAVE_STORAGE_FLUSH
diff --git a/firmware/export/config/nokian900.h b/firmware/export/config/nokian900.h
index 9c1c1a4dff..c6d6eb8205 100644
--- a/firmware/export/config/nokian900.h
+++ b/firmware/export/config/nokian900.h
@@ -92,3 +92,7 @@
#define HAVE_HOTKEY
#define BOOTDIR "/.rockbox"
+
+/* No special storage */
+#define CONFIG_STORAGE STORAGE_HOSTFS
+#define HAVE_STORAGE_FLUSH
diff --git a/firmware/export/config/pandora.h b/firmware/export/config/pandora.h
index 40320f5382..bd11441dd7 100644
--- a/firmware/export/config/pandora.h
+++ b/firmware/export/config/pandora.h
@@ -94,3 +94,7 @@
#define HAVE_HOTKEY
#define BOOTDIR "/.rockbox"
+
+/* No special storage */
+#define CONFIG_STORAGE STORAGE_HOSTFS
+#define HAVE_STORAGE_FLUSH
diff --git a/firmware/export/config/samsungypr0.h b/firmware/export/config/samsungypr0.h
index c1266f4732..361c9697c5 100644
--- a/firmware/export/config/samsungypr0.h
+++ b/firmware/export/config/samsungypr0.h
@@ -160,3 +160,7 @@
/* This folder resides in the ReadOnly CRAMFS. It is binded to /mnt/media0/.rockbox */
#define BOOTDIR "/.rockbox"
+
+/* No special storage */
+#define CONFIG_STORAGE STORAGE_HOSTFS
+#define HAVE_STORAGE_FLUSH
diff --git a/firmware/export/config/samsungypr1.h b/firmware/export/config/samsungypr1.h
index a590dd553d..1aaf85dcb5 100644
--- a/firmware/export/config/samsungypr1.h
+++ b/firmware/export/config/samsungypr1.h
@@ -150,3 +150,7 @@
/* This mount point resides in the rootfs, binded to /mnt/media0/.rockbox */
#define BOOTDIR "/.rockbox"
+
+/* No special storage */
+#define CONFIG_STORAGE STORAGE_HOSTFS
+#define HAVE_STORAGE_FLUSH
diff --git a/firmware/export/config/sdlapp.h b/firmware/export/config/sdlapp.h
index 856244c6ab..cd973fcf73 100644
--- a/firmware/export/config/sdlapp.h
+++ b/firmware/export/config/sdlapp.h
@@ -94,3 +94,7 @@
#define HAVE_HOTKEY
#define BOOTDIR "/.rockbox"
+
+/* No special storage */
+#define CONFIG_STORAGE STORAGE_HOSTFS
+#define HAVE_STORAGE_FLUSH
diff --git a/firmware/export/config/sim.h b/firmware/export/config/sim.h
index 1b69f6d15c..cec500e75d 100644
--- a/firmware/export/config/sim.h
+++ b/firmware/export/config/sim.h
@@ -35,7 +35,7 @@
#undef HAVE_HOTSWAP_STORAGE_AS_MAIN
#undef HAVE_STORAGE_FLUSH
-#undef CONFIG_STORAGE
+#undef CONFIG_NAND
#if defined(CONFIG_CHARGING) && CONFIG_CHARGING > CHARGING_MONITOR
#undef CONFIG_CHARGING
diff --git a/firmware/export/storage.h b/firmware/export/storage.h
index 1793e385df..8e7281d523 100644
--- a/firmware/export/storage.h
+++ b/firmware/export/storage.h
@@ -26,6 +26,10 @@
#include "config.h" /* for HAVE_MULTIDRIVE or not */
#include "mv.h"
+#if (CONFIG_STORAGE & STORAGE_HOSTFS) || defined(SIMULATOR)
+#define HAVE_HOSTFS
+#endif
+
#if (CONFIG_STORAGE & STORAGE_SD)
#include "sd.h"
#endif
@@ -51,19 +55,20 @@ struct storage_info
char *revision;
};
-#if (CONFIG_STORAGE == 0)
+#ifdef HAVE_HOSTFS
+#include "hostfs.h"
/* stubs for the plugin api */
static inline void stub_storage_sleep(void) {}
static inline void stub_storage_spin(void) {}
static inline void stub_storage_spindown(int timeout) { (void)timeout; }
#endif
-#if defined(CONFIG_STORAGE) && !defined(CONFIG_STORAGE_MULTI)
+#if !defined(CONFIG_STORAGE_MULTI) || defined(HAVE_HOSTFS)
/* 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 == 0) /* application */
+ #if defined(HAVE_HOSTFS)
#define STORAGE_FUNCTION(NAME) (stub_## NAME)
#define storage_spindown stub_storage_spindown
#define storage_sleep stub_storage_sleep
@@ -73,8 +78,21 @@ static inline void stub_storage_spindown(int timeout) { (void)timeout; }
#define storage_sleepnow()
#define storage_disk_is_active() 0
#define storage_soft_reset()
- #define storage_init()
- #define storage_close()
+ #define storage_init() hostfs_init()
+ #ifdef HAVE_STORAGE_FLUSH
+ #define storage_flush() hostfs_flush()
+ #endif
+ #define storage_last_disk_activity() (-1)
+ #define storage_spinup_time() 0
+ #define storage_get_identify() (NULL) /* not actually called anywher */
+
+ #ifdef STORAGE_GET_INFO
+ #error storage_get_info not implemented
+ #endif
+ #ifdef HAVE_HOTSWAP
+ #define storage_removable(drive) hostfs_removable(IF_MD(drive))
+ #define storage_present(drive) hostfs_present(IF_MD(drive))
+ #endif
#elif (CONFIG_STORAGE & STORAGE_ATA)
#define STORAGE_FUNCTION(NAME) (ata_## NAME)
#define storage_spindown ata_spindown
@@ -205,9 +223,9 @@ static inline void stub_storage_spindown(int timeout) { (void)timeout; }
#else
//#error No storage driver!
#endif
-#else /* NOT CONFIG_STORAGE_MULTI and PLATFORM_NATIVE*/
+#else /* CONFIG_STORAGE_MULTI || !HAVE_HOSTFS */
-/* Simulator and multi-driver use normal functions */
+/* Multi-driver use normal functions */
void storage_enable(bool on);
void storage_sleep(void);
diff --git a/firmware/target/hosted/android/system-android.c b/firmware/target/hosted/android/system-android.c
index d96edcd637..313bfbcd62 100644
--- a/firmware/target/hosted/android/system-android.c
+++ b/firmware/target/hosted/android/system-android.c
@@ -23,6 +23,7 @@
#include <setjmp.h>
#include <jni.h>
#include <pthread.h>
+#include <unistd.h>
#include "config.h"
#include "system.h"
#include "power.h"
@@ -66,6 +67,17 @@ void system_init(void)
telephony_init_device();
}
+void hostfs_init(void)
+{
+ /* stub */
+}
+
+int hostfs_flush(void)
+{
+ sync();
+ return 0;
+}
+
JNIEXPORT jint JNICALL
JNI_OnLoad(JavaVM *vm, void* reserved)
{
diff --git a/firmware/target/hosted/samsungypr/ypr0/system-ypr0.c b/firmware/target/hosted/samsungypr/ypr0/system-ypr0.c
index 6232df4a22..477b71c6a2 100644
--- a/firmware/target/hosted/samsungypr/ypr0/system-ypr0.c
+++ b/firmware/target/hosted/samsungypr/ypr0/system-ypr0.c
@@ -21,9 +21,11 @@
#include <stdlib.h>
#include <string.h>
#include <inttypes.h>
+#include <unistd.h>
#include "system.h"
#include "panic.h"
#include "debug.h"
+#include "hostfs.h"
#include "ascodec.h"
#include "gpio-ypr.h"
@@ -59,6 +61,18 @@ void system_exception_wait(void)
system_reboot();
}
+void hostfs_init(void)
+{
+ /* stub */
+}
+
+int hostfs_flush(void)
+{
+ sync();
+
+ return 0;
+}
+
#ifdef HAVE_ADJUSTABLE_CPU_FREQ
#include <stdio.h>
#include "file.h"
diff --git a/firmware/target/hosted/samsungypr/ypr1/system-ypr1.c b/firmware/target/hosted/samsungypr/ypr1/system-ypr1.c
index 9aa49786f1..7efa73b273 100644
--- a/firmware/target/hosted/samsungypr/ypr1/system-ypr1.c
+++ b/firmware/target/hosted/samsungypr/ypr1/system-ypr1.c
@@ -21,9 +21,11 @@
#include <stdlib.h>
#include <string.h>
#include <inttypes.h>
+#include <unistd.h>
#include "system.h"
#include "panic.h"
#include "debug.h"
+#include "hostfs.h"
#include "gpio-ypr.h"
#include "pmu-ypr1.h"
@@ -65,3 +67,15 @@ void system_exception_wait(void)
{
system_reboot();
}
+
+void hostfs_init()
+{
+ /* stub */
+}
+
+int hostfs_flush(void)
+{
+ sync();
+
+ return 0;
+}
diff --git a/firmware/target/hosted/sdl/button-sdl.c b/firmware/target/hosted/sdl/button-sdl.c
index 91338bb0d5..1ed07c153c 100644
--- a/firmware/target/hosted/sdl/button-sdl.c
+++ b/firmware/target/hosted/sdl/button-sdl.c
@@ -36,6 +36,7 @@
#include "buttonmap.h"
#include "debug.h"
#include "powermgmt.h"
+#include "storage.h"
#ifdef HAVE_TOUCHSCREEN
#include "touchscreen.h"
diff --git a/firmware/target/hosted/sdl/system-sdl.c b/firmware/target/hosted/sdl/system-sdl.c
index 572d6d570a..25e77c22a2 100644
--- a/firmware/target/hosted/sdl/system-sdl.c
+++ b/firmware/target/hosted/sdl/system-sdl.c
@@ -24,6 +24,9 @@
#include <stdlib.h>
#include <string.h>
#include <inttypes.h>
+#ifdef __unix__
+#include <unistd.h>
+#endif
#include "system.h"
#include "kernel.h"
#include "thread-sdl.h"
@@ -286,6 +289,21 @@ void system_exception_wait(void)
system_reboot();
}
+void hostfs_init(void)
+{
+ /* stub */
+}
+
+#ifdef HAVE_STORAGE_FLUSH
+int hostfs_flush(void)
+{
+#ifdef __unix__
+ sync();
+#endif
+ return 0;
+}
+#endif /* HAVE_STORAGE_FLUSH */
+
void sys_handle_argv(int argc, char *argv[])
{
if (argc >= 1)
diff --git a/uisimulator/common/stubs.c b/uisimulator/common/stubs.c
index 18f60ce6b3..480c2a90d8 100644
--- a/uisimulator/common/stubs.c
+++ b/uisimulator/common/stubs.c
@@ -395,3 +395,10 @@ void touchpad_enable_device(bool en)
(void)en;
}
#endif
+
+#if (CONFIG_STORAGE & STORAGE_MMC)
+bool mmc_touched(void)
+{
+ return false;
+}
+#endif