summaryrefslogtreecommitdiff
path: root/firmware/export/mv.h
diff options
context:
space:
mode:
Diffstat (limited to 'firmware/export/mv.h')
-rw-r--r--firmware/export/mv.h77
1 files changed, 62 insertions, 15 deletions
diff --git a/firmware/export/mv.h b/firmware/export/mv.h
index 1d0a536663..620d77d30d 100644
--- a/firmware/export/mv.h
+++ b/firmware/export/mv.h
@@ -45,23 +45,44 @@
45#define IF_MV(x...) x /* valist contents or empty */ 45#define IF_MV(x...) x /* valist contents or empty */
46#define IF_MV_NONVOID(x...) x /* valist contents or 'void' */ 46#define IF_MV_NONVOID(x...) x /* valist contents or 'void' */
47#define IF_MV_VOL(v) v /* volume argument or '0' */ 47#define IF_MV_VOL(v) v /* volume argument or '0' */
48/* how to name volumes, first char must be outside of legal file names,
49 a number gets appended to enumerate, if applicable */
50#if (CONFIG_STORAGE & STORAGE_MMC)
51#define VOL_NAMES "<MMC%d>"
52#define VOL_ENUM_POS 4 /* position of %d, to avoid runtime calculation */
53#elif (CONFIG_STORAGE & STORAGE_SD)
54#define VOL_NAMES "<microSD%d>"
55#define VOL_ENUM_POS 8 /* position of %d, to avoid runtime calculation */
56#else
57#define VOL_NAMES "<HD%d>"
58#define VOL_ENUM_POS 3
59#endif /* CONFIG_STORAGE */
60 48
61#ifdef HAVE_HOTSWAP 49/* Format: "/<DEC###>/foo/bar"
62bool volume_removable(int volume); 50 * The "DEC" is pure decoration and treated as a comment. Only an unbroken
63bool volume_present(int volume); 51 * trailing string of digits within the brackets is parsed as the volume
52 * number.
53 *
54 * IMPORTANT!: Adjust VOL_DEC_MAX_LEN if needed to the longest of these
55 */
56#define DEFAULT_VOL_DEC "Volume"
57
58#if (CONFIG_STORAGE & STORAGE_ATA)
59#define ATA_VOL_DEC "HDD"
60#endif
61#if (CONFIG_STORAGE & STORAGE_MMC)
62#define MMC_VOL_DEC "MMC"
63#endif
64#if (CONFIG_STORAGE & STORAGE_SD)
65#define SD_VOL_DEC "microSD"
66#endif
67#if (CONFIG_STORAGE & STORAGE_NAND)
68#define NAND_VOL_DEC "NAND"
69#endif
70#if (CONFIG_STORAGE & STORAGE_RAMDISK)
71#define RAMDISK_VOL_DEC "RAMDisk"
72#endif
73#if (CONFIG_STORAGE & STORAGE_HOSTFS)
74#ifndef HOSTFS_VOL_DEC /* overridable */
75#define HOSTFS_VOL_DEC DEFAULT_VOL_DEC
64#endif 76#endif
77#endif
78
79/* Characters that delimit a volume specifier at any root point in the path.
80 The tokens must be outside of legal filename characters */
81#define VOL_START_TOK '<'
82#define VOL_END_TOK '>'
83#define VOL_DEC_MAX_LEN 7 /* biggest of all xxx_VOL_DEC defines */
84#define VOL_MAX_LEN (1 + VOL_DEC_MAX_LEN + 2 + 1)
85#define VOL_NUM_MAX 100
65 86
66#else /* empty definitions if no multi-volume */ 87#else /* empty definitions if no multi-volume */
67#define IF_MV(x...) 88#define IF_MV(x...)
@@ -69,4 +90,30 @@ bool volume_present(int volume);
69#define IF_MV_VOL(v) 0 90#define IF_MV_VOL(v) 0
70#endif /* HAVE_MULTIVOLUME */ 91#endif /* HAVE_MULTIVOLUME */
71 92
93#define CHECK_VOL(volume) \
94 ((unsigned int)IF_MV_VOL(volume) < NUM_VOLUMES)
95
96#define CHECK_DRV(drive) \
97 ((unsigned int)IF_MD_DRV(drive) < NUM_DRIVES)
98
99/* Volume-centric functions (in disk.c) */
100void volume_recalc_free(IF_MV_NONVOID(int volume));
101unsigned int volume_get_cluster_size(IF_MV_NONVOID(int volume));
102void volume_size(IF_MV(int volume,) unsigned long *size, unsigned long *free);
103bool volume_ismounted(IF_MV_NONVOID(int volume));
104#ifdef HAVE_HOTSWAP
105bool volume_removable(int volume);
106bool volume_present(int volume);
107#endif /* HAVE_HOTSWAP */
108
109#ifdef HAVE_MULTIDRIVE
110int volume_drive(int volume);
111#else /* !HAVE_MULTIDRIVE */
112static inline int volume_drive(int volume)
113{
114 return 0;
115 (void)volume;
116}
117#endif /* HAVE_MULTIDRIVE */
118
72#endif /* __MV_H__ */ 119#endif /* __MV_H__ */