Define a USB storage type, and hook it up for hosted targets

Change-Id: I56363c989139c7edf0b2c67b0aac9ef1adfacba2
This commit is contained in:
Solomon Peachy 2020-10-17 16:57:51 -04:00
parent 0a4a920029
commit d8d37ffdb8
7 changed files with 35 additions and 4 deletions

View File

@ -45,6 +45,9 @@ enum storage_name_dec_indexes
#if (CONFIG_STORAGE & STORAGE_RAMDISK)
STORAGE_DEC_IDX_RAMDISK,
#endif
#if (CONFIG_STORAGE & STORAGE_USB)
STORAGE_DEC_IDX_USB,
#endif
#if (CONFIG_STORAGE & STORAGE_HOSTFS)
STORAGE_DEC_IDX_HOSTFS,
#endif
@ -68,6 +71,9 @@ static const char * const storage_dec_names[STORAGE_NUM_DEC_IDX+1] =
#if (CONFIG_STORAGE & STORAGE_RAMDISK)
[STORAGE_DEC_IDX_RAMDISK] = RAMDISK_VOL_DEC,
#endif
#if (CONFIG_STORAGE & STORAGE_USB)
[STORAGE_DEC_IDX_USB] = USB_VOL_DEC,
#endif
#if (CONFIG_STORAGE & STORAGE_HOSTFS)
[STORAGE_DEC_IDX_HOSTFS] = HOSTFS_VOL_DEC,
#endif
@ -92,6 +98,9 @@ static const unsigned char storage_dec_indexes[STORAGE_NUM_TYPES+1] =
#if (CONFIG_STORAGE & STORAGE_RAMDISK)
[STORAGE_RAMDISK_NUM] = STORAGE_DEC_IDX_RAMDISK,
#endif
#if (CONFIG_STORAGE & STORAGE_USB)
[STORAGE_USB_NUM] = STORAGE_DEC_IDX_USB,
#endif
#if (CONFIG_STORAGE & STORAGE_HOSTFS)
[STORAGE_HOSTFS_NUM] = STORAGE_DEC_IDX_HOSTFS,
#endif

View File

@ -32,14 +32,16 @@
#define STORAGE_SD_NUM 2
#define STORAGE_NAND_NUM 3
#define STORAGE_RAMDISK_NUM 4
#define STORAGE_HOSTFS_NUM 5
#define STORAGE_NUM_TYPES 6
#define STORAGE_USB_NUM 5
#define STORAGE_HOSTFS_NUM 6
#define STORAGE_NUM_TYPES 7
#define STORAGE_ATA (1 << STORAGE_ATA_NUM)
#define STORAGE_MMC (1 << STORAGE_MMC_NUM)
#define STORAGE_SD (1 << STORAGE_SD_NUM)
#define STORAGE_NAND (1 << STORAGE_NAND_NUM)
#define STORAGE_RAMDISK (1 << STORAGE_RAMDISK_NUM)
#define STORAGE_USB (1 << STORAGE_USB_NUM)
/* meant for APPLICATION targets (implicit for SIMULATOR) */
#define STORAGE_HOSTFS (1 << STORAGE_HOSTFS_NUM)

View File

@ -54,6 +54,8 @@ extern int hostfs_driver_type(int drive);
# define hostfs_driver_type(drive) (STORAGE_ATA_NUM)
# elif (CONFIG_STORAGE & STORAGE_SD)
# define hostfs_driver_type(drive) (STORAGE_SD_NUM)
# elif (CONFIG_STORAGE & STORAGE_USB)
# define hostfs_driver_type(drive) (STORAGE_USB_NUM)
# elif (CONFIG_STORAGE & STORAGE_MMC)
# define hostfs_driver_type(drive) (STORAGE_MMC_NUM)
# elif (CONFIG_STORAGE & STORAGE_NAND)

View File

@ -70,6 +70,9 @@
#if (CONFIG_STORAGE & STORAGE_RAMDISK)
#define RAMDISK_VOL_DEC "RAMDisk"
#endif
#if (CONFIG_STORAGE & STORAGE_USB)
#define USB_VOL_DEC "USB"
#endif
#if (CONFIG_STORAGE & STORAGE_HOSTFS)
#ifndef HOSTFS_VOL_DEC /* overridable */
#define HOSTFS_VOL_DEC DEFAULT_VOL_DEC

View File

@ -34,6 +34,9 @@
#if (CONFIG_STORAGE & STORAGE_SD)
#include "sd.h"
#endif
#if (CONFIG_STORAGE & STORAGE_USB)
// TODO: Doesn't matter until we're native
#endif
#if (CONFIG_STORAGE & STORAGE_MMC)
#include "mmc.h"
#endif
@ -97,6 +100,9 @@ int nand_event(long id, intptr_t data);
#if (CONFIG_STORAGE & STORAGE_RAMDISK)
int ramdisk_event(long id, intptr_t data);
#endif
#if (CONFIG_STORAGE & STORAGE_USB)
// int usb_event(long id, intptr_t data); // TODO: Implement
#endif
struct storage_info
{
@ -278,6 +284,8 @@ static inline void storage_sleep(void) {};
#define storage_present(drive) ramdisk_present(IF_MD(drive))
#endif
#define storage_driver_type(drive) (STORAGE_RAMDISK_NUM)
#elif (CONFIG_STORAGE & STORAGE_USB)
// TODO: Eventually fix me
#else
//#error No storage driver!
#endif

View File

@ -174,7 +174,11 @@ int volume_drive(int drive)
#ifdef CONFIG_STORAGE_MULTI
int hostfs_driver_type(int drive)
{
#if (CONFIG_STORAGE & STORAGE_USB)
return drive > 0 ? STORAGE_USB_NUM : STORAGE_HOSTFS_NUM;
#else
return drive > 0 ? STORAGE_SD_NUM : STORAGE_HOSTFS_NUM;
#endif
}
#endif /* CONFIG_STORAGE_MULTI */

View File

@ -130,7 +130,7 @@ void system_exception_wait(void)
bool hostfs_removable(IF_MD_NONVOID(int drive))
{
#ifdef HAVE_MULTIDRIVE
if (drive > 0) /* Active LOW */
if (drive > 0)
return true;
else
#endif
@ -157,7 +157,11 @@ int volume_drive(int drive)
#ifdef CONFIG_STORAGE_MULTI
int hostfs_driver_type(int drive)
{
#if (CONFIG_STORAGE & STORAGE_USB)
return drive > 0 ? STORAGE_USB_NUM : STORAGE_HOSTFS_NUM;
#else
return drive > 0 ? STORAGE_SD_NUM : STORAGE_HOSTFS_NUM;
#endif
}
#endif /* CONFIG_STORAGE_MULTI */
@ -185,4 +189,3 @@ bool volume_present(int volume)
return hostfs_present(volume);
}
#endif