summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSolomon Peachy <pizza@shaftnet.org>2021-04-11 09:10:55 -0400
committerSolomon Peachy <pizza@shaftnet.org>2021-04-12 18:19:06 +0000
commitb6fce99046a3677f27373f8c701e6f200e290236 (patch)
tree9ea27b619af5962e415a52ceffaffc35aabd3c47
parente4345f2db8771fb773e07daf1a9f7bfac961c6bd (diff)
downloadrockbox-b6fce99046a3677f27373f8c701e6f200e290236.tar.gz
rockbox-b6fce99046a3677f27373f8c701e6f200e290236.tar.bz2
rockbox-b6fce99046a3677f27373f8c701e6f200e290236.zip
ibasso: Implement proper PIVOT_ROOT filesystem access
Including direct use of the external SD card mount Known issue: If SD card is inserted at startup, it must be ejected and reinserted to be registered. Change-Id: I5f420160bda32135cbb088c1e8b04b6e3a73018e
-rw-r--r--firmware/export/config/ibassodx50.h9
-rw-r--r--firmware/export/config/ibassodx90.h9
-rw-r--r--firmware/target/hosted/ibasso/system-ibasso.c55
-rw-r--r--firmware/target/hosted/ibasso/vold-ibasso.c5
-rw-r--r--firmware/target/hosted/ibasso/vold-ibasso.h2
5 files changed, 75 insertions, 5 deletions
diff --git a/firmware/export/config/ibassodx50.h b/firmware/export/config/ibassodx50.h
index 6bebf5a278..bb4b2809e5 100644
--- a/firmware/export/config/ibassodx50.h
+++ b/firmware/export/config/ibassodx50.h
@@ -140,9 +140,14 @@
/* Define this if a programmable hotkey is mapped */
#define HAVE_HOTKEY
-/* No special storage */
-#define CONFIG_STORAGE STORAGE_HOSTFS
+/* Supports internal and microSD storage */
+#define CONFIG_STORAGE (STORAGE_HOSTFS|STORAGE_SD)
+#define HOSTFS_VOL_DEC "Internal"
#define HAVE_STORAGE_FLUSH
+#define HAVE_MULTIDRIVE /* But _not_ CONFIG_STORAGE_MULTI */
+#define NUM_DRIVES 2
+#define HAVE_HOTSWAP
+#define MULTIDRIVE_DIR "/mnt/external_sd"
/* More common stuff */
#define BATTERY_DEV_NAME "battery"
diff --git a/firmware/export/config/ibassodx90.h b/firmware/export/config/ibassodx90.h
index 0b33665eb4..cd7ddf78cd 100644
--- a/firmware/export/config/ibassodx90.h
+++ b/firmware/export/config/ibassodx90.h
@@ -137,9 +137,14 @@
/* Define this if a programmable hotkey is mapped */
#define HAVE_HOTKEY
-/* No special storage */
-#define CONFIG_STORAGE STORAGE_HOSTFS
+/* Supports internal and microSD storage */
+#define CONFIG_STORAGE (STORAGE_HOSTFS|STORAGE_SD)
+#define HOSTFS_VOL_DEC "Internal"
#define HAVE_STORAGE_FLUSH
+#define HAVE_MULTIDRIVE /* But _not_ CONFIG_STORAGE_MULTI */
+#define NUM_DRIVES 2
+#define HAVE_HOTSWAP
+#define MULTIDRIVE_DIR "/mnt/external_sd"
/* More common stuff */
#define BATTERY_DEV_NAME "battery"
diff --git a/firmware/target/hosted/ibasso/system-ibasso.c b/firmware/target/hosted/ibasso/system-ibasso.c
index 45a6514aa2..401bb3c442 100644
--- a/firmware/target/hosted/ibasso/system-ibasso.c
+++ b/firmware/target/hosted/ibasso/system-ibasso.c
@@ -28,6 +28,7 @@
#include "config.h"
#include "debug.h"
+#include "mv.h"
#include "button-ibasso.h"
#include "debug-ibasso.h"
@@ -39,6 +40,8 @@
uintptr_t* stackbegin;
uintptr_t* stackend;
+/* forward-declare */
+bool os_file_exists(const char *ospath);
void system_init(void)
{
@@ -95,3 +98,55 @@ void system_exception_wait(void)
while(1) {};
}
+
+bool hostfs_removable(IF_MD_NONVOID(int drive))
+{
+#ifdef HAVE_MULTIDRIVE
+ if (drive > 0)
+ return true;
+ else
+#endif
+ return false; /* internal: always present */
+}
+
+#ifdef HAVE_MULTIDRIVE
+int volume_drive(int drive)
+{
+ return drive;
+}
+#endif /* HAVE_MULTIDRIVE */
+
+#ifdef CONFIG_STORAGE_MULTI
+int hostfs_driver_type(int drive)
+{
+ return drive > 0 ? STORAGE_SD_NUM : STORAGE_HOSTFS_NUM;
+}
+#endif /* CONFIG_STORAGE_MULTI */
+
+bool hostfs_present(IF_MD_NONVOID(int drive))
+{
+#ifdef HAVE_MULTIDRIVE
+ if (drive > 0)
+#if defined(MULTIDRIVE_DEV)
+ return os_file_exists(MULTIDRIVE_DEV);
+#else
+ return extsd_present;
+#endif
+ else
+#endif
+ return true; /* internal: always present */
+}
+
+#ifdef HAVE_HOTSWAP
+bool volume_removable(int volume)
+{
+ /* don't support more than one partition yet, so volume == drive */
+ return hostfs_removable(volume);
+}
+
+bool volume_present(int volume)
+{
+ /* don't support more than one partition yet, so volume == drive */
+ return hostfs_present(volume);
+}
+#endif
diff --git a/firmware/target/hosted/ibasso/vold-ibasso.c b/firmware/target/hosted/ibasso/vold-ibasso.c
index c92b86d364..f56bd683d3 100644
--- a/firmware/target/hosted/ibasso/vold-ibasso.c
+++ b/firmware/target/hosted/ibasso/vold-ibasso.c
@@ -45,7 +45,6 @@
static const char VOLD_MONITOR_SOCKET_NAME[] = "UNIX_domain";
static int _vold_monitor_socket_fd = -1;
-
static void vold_monitor_open_socket(void)
{
TRACE;
@@ -82,6 +81,8 @@ static void vold_monitor_open_socket(void)
}
}
+/* Track state of external SD */
+bool extsd_present = false;
/*
bionic does not have pthread_cancel.
@@ -161,10 +162,12 @@ static void* vold_monitor_run(void* nothing)
else if(strcmp(msg, "Volume sdcard /mnt/external_sd state changed from 4 (Mounted) to 5 (Unmounting)") == 0)
{
/* We are loosing the external sdcard, inform Rockbox. */
+ extsd_present = false;
}
else if(strcmp(msg, "Volume sdcard /mnt/external_sd state changed from 3 (Checking) to 4 (Mounted)") == 0)
{
/* The external sdcard is back, inform Rockbox. */
+ extsd_present = true;
}
}
}
diff --git a/firmware/target/hosted/ibasso/vold-ibasso.h b/firmware/target/hosted/ibasso/vold-ibasso.h
index 18012b7e16..8c9fd06b99 100644
--- a/firmware/target/hosted/ibasso/vold-ibasso.h
+++ b/firmware/target/hosted/ibasso/vold-ibasso.h
@@ -38,5 +38,7 @@ void vold_monitor_start(void);
*/
bool vold_monitor_forced_close_imminent(void);
+/* Track the state of the SD card */
+extern bool extsd_present;
#endif