summaryrefslogtreecommitdiff
path: root/firmware
diff options
context:
space:
mode:
authorSolomon Peachy <pizza@shaftnet.org>2020-10-17 16:57:51 -0400
committerSolomon Peachy <pizza@shaftnet.org>2020-10-17 18:38:49 -0400
commitd8d37ffdb8bed39df5d021afa9e09bf087b45d0d (patch)
treeeaea28432d9a76c98d69470c3c8a8bd0b4e17282 /firmware
parent0a4a920029bfb8194c37870b7e6d8e60cd7c8ef9 (diff)
downloadrockbox-d8d37ffdb8bed39df5d021afa9e09bf087b45d0d.tar.gz
rockbox-d8d37ffdb8bed39df5d021afa9e09bf087b45d0d.zip
Define a USB storage type, and hook it up for hosted targets
Change-Id: I56363c989139c7edf0b2c67b0aac9ef1adfacba2
Diffstat (limited to 'firmware')
-rw-r--r--firmware/common/pathfuncs.c9
-rw-r--r--firmware/export/config.h6
-rw-r--r--firmware/export/hostfs.h2
-rw-r--r--firmware/export/mv.h3
-rw-r--r--firmware/export/storage.h8
-rw-r--r--firmware/target/hosted/fiio/system-fiio.c4
-rw-r--r--firmware/target/hosted/system-hosted.c7
7 files changed, 35 insertions, 4 deletions
diff --git a/firmware/common/pathfuncs.c b/firmware/common/pathfuncs.c
index 0935a9a6e3..1c48a54972 100644
--- a/firmware/common/pathfuncs.c
+++ b/firmware/common/pathfuncs.c
@@ -45,6 +45,9 @@ enum storage_name_dec_indexes
45#if (CONFIG_STORAGE & STORAGE_RAMDISK) 45#if (CONFIG_STORAGE & STORAGE_RAMDISK)
46 STORAGE_DEC_IDX_RAMDISK, 46 STORAGE_DEC_IDX_RAMDISK,
47#endif 47#endif
48#if (CONFIG_STORAGE & STORAGE_USB)
49 STORAGE_DEC_IDX_USB,
50#endif
48#if (CONFIG_STORAGE & STORAGE_HOSTFS) 51#if (CONFIG_STORAGE & STORAGE_HOSTFS)
49 STORAGE_DEC_IDX_HOSTFS, 52 STORAGE_DEC_IDX_HOSTFS,
50#endif 53#endif
@@ -68,6 +71,9 @@ static const char * const storage_dec_names[STORAGE_NUM_DEC_IDX+1] =
68#if (CONFIG_STORAGE & STORAGE_RAMDISK) 71#if (CONFIG_STORAGE & STORAGE_RAMDISK)
69 [STORAGE_DEC_IDX_RAMDISK] = RAMDISK_VOL_DEC, 72 [STORAGE_DEC_IDX_RAMDISK] = RAMDISK_VOL_DEC,
70#endif 73#endif
74#if (CONFIG_STORAGE & STORAGE_USB)
75 [STORAGE_DEC_IDX_USB] = USB_VOL_DEC,
76#endif
71#if (CONFIG_STORAGE & STORAGE_HOSTFS) 77#if (CONFIG_STORAGE & STORAGE_HOSTFS)
72 [STORAGE_DEC_IDX_HOSTFS] = HOSTFS_VOL_DEC, 78 [STORAGE_DEC_IDX_HOSTFS] = HOSTFS_VOL_DEC,
73#endif 79#endif
@@ -92,6 +98,9 @@ static const unsigned char storage_dec_indexes[STORAGE_NUM_TYPES+1] =
92#if (CONFIG_STORAGE & STORAGE_RAMDISK) 98#if (CONFIG_STORAGE & STORAGE_RAMDISK)
93 [STORAGE_RAMDISK_NUM] = STORAGE_DEC_IDX_RAMDISK, 99 [STORAGE_RAMDISK_NUM] = STORAGE_DEC_IDX_RAMDISK,
94#endif 100#endif
101#if (CONFIG_STORAGE & STORAGE_USB)
102 [STORAGE_USB_NUM] = STORAGE_DEC_IDX_USB,
103#endif
95#if (CONFIG_STORAGE & STORAGE_HOSTFS) 104#if (CONFIG_STORAGE & STORAGE_HOSTFS)
96 [STORAGE_HOSTFS_NUM] = STORAGE_DEC_IDX_HOSTFS, 105 [STORAGE_HOSTFS_NUM] = STORAGE_DEC_IDX_HOSTFS,
97#endif 106#endif
diff --git a/firmware/export/config.h b/firmware/export/config.h
index 7e8d751090..547c359d8d 100644
--- a/firmware/export/config.h
+++ b/firmware/export/config.h
@@ -32,14 +32,16 @@
32#define STORAGE_SD_NUM 2 32#define STORAGE_SD_NUM 2
33#define STORAGE_NAND_NUM 3 33#define STORAGE_NAND_NUM 3
34#define STORAGE_RAMDISK_NUM 4 34#define STORAGE_RAMDISK_NUM 4
35#define STORAGE_HOSTFS_NUM 5 35#define STORAGE_USB_NUM 5
36#define STORAGE_NUM_TYPES 6 36#define STORAGE_HOSTFS_NUM 6
37#define STORAGE_NUM_TYPES 7
37 38
38#define STORAGE_ATA (1 << STORAGE_ATA_NUM) 39#define STORAGE_ATA (1 << STORAGE_ATA_NUM)
39#define STORAGE_MMC (1 << STORAGE_MMC_NUM) 40#define STORAGE_MMC (1 << STORAGE_MMC_NUM)
40#define STORAGE_SD (1 << STORAGE_SD_NUM) 41#define STORAGE_SD (1 << STORAGE_SD_NUM)
41#define STORAGE_NAND (1 << STORAGE_NAND_NUM) 42#define STORAGE_NAND (1 << STORAGE_NAND_NUM)
42#define STORAGE_RAMDISK (1 << STORAGE_RAMDISK_NUM) 43#define STORAGE_RAMDISK (1 << STORAGE_RAMDISK_NUM)
44#define STORAGE_USB (1 << STORAGE_USB_NUM)
43 /* meant for APPLICATION targets (implicit for SIMULATOR) */ 45 /* meant for APPLICATION targets (implicit for SIMULATOR) */
44#define STORAGE_HOSTFS (1 << STORAGE_HOSTFS_NUM) 46#define STORAGE_HOSTFS (1 << STORAGE_HOSTFS_NUM)
45 47
diff --git a/firmware/export/hostfs.h b/firmware/export/hostfs.h
index fa916870f3..c0fe85236e 100644
--- a/firmware/export/hostfs.h
+++ b/firmware/export/hostfs.h
@@ -54,6 +54,8 @@ extern int hostfs_driver_type(int drive);
54# define hostfs_driver_type(drive) (STORAGE_ATA_NUM) 54# define hostfs_driver_type(drive) (STORAGE_ATA_NUM)
55# elif (CONFIG_STORAGE & STORAGE_SD) 55# elif (CONFIG_STORAGE & STORAGE_SD)
56# define hostfs_driver_type(drive) (STORAGE_SD_NUM) 56# define hostfs_driver_type(drive) (STORAGE_SD_NUM)
57# elif (CONFIG_STORAGE & STORAGE_USB)
58# define hostfs_driver_type(drive) (STORAGE_USB_NUM)
57# elif (CONFIG_STORAGE & STORAGE_MMC) 59# elif (CONFIG_STORAGE & STORAGE_MMC)
58# define hostfs_driver_type(drive) (STORAGE_MMC_NUM) 60# define hostfs_driver_type(drive) (STORAGE_MMC_NUM)
59# elif (CONFIG_STORAGE & STORAGE_NAND) 61# elif (CONFIG_STORAGE & STORAGE_NAND)
diff --git a/firmware/export/mv.h b/firmware/export/mv.h
index ec7b2efdbd..3657ef6c98 100644
--- a/firmware/export/mv.h
+++ b/firmware/export/mv.h
@@ -70,6 +70,9 @@
70#if (CONFIG_STORAGE & STORAGE_RAMDISK) 70#if (CONFIG_STORAGE & STORAGE_RAMDISK)
71#define RAMDISK_VOL_DEC "RAMDisk" 71#define RAMDISK_VOL_DEC "RAMDisk"
72#endif 72#endif
73#if (CONFIG_STORAGE & STORAGE_USB)
74#define USB_VOL_DEC "USB"
75#endif
73#if (CONFIG_STORAGE & STORAGE_HOSTFS) 76#if (CONFIG_STORAGE & STORAGE_HOSTFS)
74#ifndef HOSTFS_VOL_DEC /* overridable */ 77#ifndef HOSTFS_VOL_DEC /* overridable */
75#define HOSTFS_VOL_DEC DEFAULT_VOL_DEC 78#define HOSTFS_VOL_DEC DEFAULT_VOL_DEC
diff --git a/firmware/export/storage.h b/firmware/export/storage.h
index e6424f7b03..ee1423c93a 100644
--- a/firmware/export/storage.h
+++ b/firmware/export/storage.h
@@ -34,6 +34,9 @@
34#if (CONFIG_STORAGE & STORAGE_SD) 34#if (CONFIG_STORAGE & STORAGE_SD)
35#include "sd.h" 35#include "sd.h"
36#endif 36#endif
37#if (CONFIG_STORAGE & STORAGE_USB)
38// TODO: Doesn't matter until we're native
39#endif
37#if (CONFIG_STORAGE & STORAGE_MMC) 40#if (CONFIG_STORAGE & STORAGE_MMC)
38#include "mmc.h" 41#include "mmc.h"
39#endif 42#endif
@@ -97,6 +100,9 @@ int nand_event(long id, intptr_t data);
97#if (CONFIG_STORAGE & STORAGE_RAMDISK) 100#if (CONFIG_STORAGE & STORAGE_RAMDISK)
98int ramdisk_event(long id, intptr_t data); 101int ramdisk_event(long id, intptr_t data);
99#endif 102#endif
103#if (CONFIG_STORAGE & STORAGE_USB)
104// int usb_event(long id, intptr_t data); // TODO: Implement
105#endif
100 106
101struct storage_info 107struct storage_info
102{ 108{
@@ -278,6 +284,8 @@ static inline void storage_sleep(void) {};
278 #define storage_present(drive) ramdisk_present(IF_MD(drive)) 284 #define storage_present(drive) ramdisk_present(IF_MD(drive))
279 #endif 285 #endif
280 #define storage_driver_type(drive) (STORAGE_RAMDISK_NUM) 286 #define storage_driver_type(drive) (STORAGE_RAMDISK_NUM)
287 #elif (CONFIG_STORAGE & STORAGE_USB)
288 // TODO: Eventually fix me
281 #else 289 #else
282 //#error No storage driver! 290 //#error No storage driver!
283 #endif 291 #endif
diff --git a/firmware/target/hosted/fiio/system-fiio.c b/firmware/target/hosted/fiio/system-fiio.c
index f011ceea75..46a4d0f835 100644
--- a/firmware/target/hosted/fiio/system-fiio.c
+++ b/firmware/target/hosted/fiio/system-fiio.c
@@ -174,7 +174,11 @@ int volume_drive(int drive)
174#ifdef CONFIG_STORAGE_MULTI 174#ifdef CONFIG_STORAGE_MULTI
175int hostfs_driver_type(int drive) 175int hostfs_driver_type(int drive)
176{ 176{
177#if (CONFIG_STORAGE & STORAGE_USB)
178 return drive > 0 ? STORAGE_USB_NUM : STORAGE_HOSTFS_NUM;
179#else
177 return drive > 0 ? STORAGE_SD_NUM : STORAGE_HOSTFS_NUM; 180 return drive > 0 ? STORAGE_SD_NUM : STORAGE_HOSTFS_NUM;
181#endif
178} 182}
179#endif /* CONFIG_STORAGE_MULTI */ 183#endif /* CONFIG_STORAGE_MULTI */
180 184
diff --git a/firmware/target/hosted/system-hosted.c b/firmware/target/hosted/system-hosted.c
index cad84ac868..f485dc4c15 100644
--- a/firmware/target/hosted/system-hosted.c
+++ b/firmware/target/hosted/system-hosted.c
@@ -130,7 +130,7 @@ void system_exception_wait(void)
130bool hostfs_removable(IF_MD_NONVOID(int drive)) 130bool hostfs_removable(IF_MD_NONVOID(int drive))
131{ 131{
132#ifdef HAVE_MULTIDRIVE 132#ifdef HAVE_MULTIDRIVE
133 if (drive > 0) /* Active LOW */ 133 if (drive > 0)
134 return true; 134 return true;
135 else 135 else
136#endif 136#endif
@@ -157,7 +157,11 @@ int volume_drive(int drive)
157#ifdef CONFIG_STORAGE_MULTI 157#ifdef CONFIG_STORAGE_MULTI
158int hostfs_driver_type(int drive) 158int hostfs_driver_type(int drive)
159{ 159{
160#if (CONFIG_STORAGE & STORAGE_USB)
161 return drive > 0 ? STORAGE_USB_NUM : STORAGE_HOSTFS_NUM;
162#else
160 return drive > 0 ? STORAGE_SD_NUM : STORAGE_HOSTFS_NUM; 163 return drive > 0 ? STORAGE_SD_NUM : STORAGE_HOSTFS_NUM;
164#endif
161} 165}
162#endif /* CONFIG_STORAGE_MULTI */ 166#endif /* CONFIG_STORAGE_MULTI */
163 167
@@ -185,4 +189,3 @@ bool volume_present(int volume)
185 return hostfs_present(volume); 189 return hostfs_present(volume);
186} 190}
187#endif 191#endif
188