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