diff options
Diffstat (limited to 'firmware/export/storage.h')
-rw-r--r-- | firmware/export/storage.h | 270 |
1 files changed, 132 insertions, 138 deletions
diff --git a/firmware/export/storage.h b/firmware/export/storage.h index 47d8abda52..dbcc7a69ab 100644 --- a/firmware/export/storage.h +++ b/firmware/export/storage.h | |||
@@ -23,7 +23,7 @@ | |||
23 | #define __STORAGE_H__ | 23 | #define __STORAGE_H__ |
24 | 24 | ||
25 | #include <stdbool.h> | 25 | #include <stdbool.h> |
26 | #include "config.h" /* for HAVE_MULTIVOLUME or not */ | 26 | #include "config.h" /* for HAVE_MULTIDRIVE or not */ |
27 | #include "mv.h" | 27 | #include "mv.h" |
28 | 28 | ||
29 | #if (CONFIG_STORAGE & STORAGE_SD) | 29 | #if (CONFIG_STORAGE & STORAGE_SD) |
@@ -51,154 +51,147 @@ struct storage_info | |||
51 | char *revision; | 51 | char *revision; |
52 | }; | 52 | }; |
53 | 53 | ||
54 | #ifndef SIMULATOR | 54 | #if !defined(SIMULATOR) && !defined(CONFIG_STORAGE_MULTI) |
55 | #ifndef CONFIG_STORAGE_MULTI | 55 | /* storage_spindown, storage_sleep and storage_spin are passed as |
56 | /* storage_spindown, storage_sleep and storage_spin are passed as | 56 | * pointers, which doesn't work with argument-macros. |
57 | * pointers, which doesn't work with argument-macros. | 57 | */ |
58 | */ | 58 | #define storage_num_drives() NUM_DRIVES |
59 | #if (CONFIG_STORAGE & STORAGE_ATA) | 59 | #if (CONFIG_STORAGE & STORAGE_ATA) |
60 | #define storage_spindown ata_spindown | 60 | #define storage_spindown ata_spindown |
61 | #define storage_sleep ata_sleep | 61 | #define storage_sleep ata_sleep |
62 | #define storage_spin ata_spin | 62 | #define storage_spin ata_spin |
63 | 63 | ||
64 | #define storage_enable(on) ata_enable(on) | 64 | #define storage_enable(on) ata_enable(on) |
65 | #define storage_sleepnow() ata_sleepnow() | 65 | #define storage_sleepnow() ata_sleepnow() |
66 | #define storage_disk_is_active() ata_disk_is_active() | 66 | #define storage_disk_is_active() ata_disk_is_active() |
67 | #define storage_soft_reset() ata_soft_reset() | 67 | #define storage_soft_reset() ata_soft_reset() |
68 | #define storage_init() ata_init() | 68 | #define storage_init() ata_init() |
69 | #define storage_close() ata_close() | 69 | #define storage_close() ata_close() |
70 | #define storage_read_sectors(drive, start, count, buf) ata_read_sectors(IF_MV2(drive,) start, count, buf) | 70 | #define storage_read_sectors(drive, start, count, buf) ata_read_sectors(IF_MD2(drive,) start, count, buf) |
71 | #define storage_write_sectors(drive, start, count, buf) ata_write_sectors(IF_MV2(drive,) start, count, buf) | 71 | #define storage_write_sectors(drive, start, count, buf) ata_write_sectors(IF_MD2(drive,) start, count, buf) |
72 | #define storage_last_disk_activity() ata_last_disk_activity() | 72 | #define storage_last_disk_activity() ata_last_disk_activity() |
73 | #define storage_spinup_time() ata_spinup_time() | 73 | #define storage_spinup_time() ata_spinup_time() |
74 | #define storage_get_identify() ata_get_identify() | 74 | #define storage_get_identify() ata_get_identify() |
75 | 75 | ||
76 | #ifdef STORAGE_GET_INFO | 76 | #ifdef STORAGE_GET_INFO |
77 | #define storage_get_info(drive, info) ata_get_info(IF_MV2(drive,) info) | 77 | #define storage_get_info(drive, info) ata_get_info(IF_MD2(drive,) info) |
78 | #endif | 78 | #endif |
79 | #ifdef HAVE_HOTSWAP | 79 | #ifdef HAVE_HOTSWAP |
80 | #define storage_removable(drive) ata_removable(IF_MV(drive)) | 80 | #define storage_removable(drive) ata_removable(IF_MD(drive)) |
81 | #define storage_present(drive) ata_present(IF_MV(drive)) | 81 | #define storage_present(drive) ata_present(IF_MD(drive)) |
82 | #endif | 82 | #endif |
83 | #elif (CONFIG_STORAGE & STORAGE_SD) | 83 | #elif (CONFIG_STORAGE & STORAGE_SD) |
84 | #define storage_spindown sd_spindown | 84 | #define storage_spindown sd_spindown |
85 | #define storage_sleep sd_sleep | 85 | #define storage_sleep sd_sleep |
86 | #define storage_spin sd_spin | 86 | #define storage_spin sd_spin |
87 | 87 | ||
88 | #define storage_enable(on) sd_enable(on) | 88 | #define storage_enable(on) sd_enable(on) |
89 | #define storage_sleepnow() sd_sleepnow() | 89 | #define storage_sleepnow() sd_sleepnow() |
90 | #define storage_disk_is_active() 0 | 90 | #define storage_disk_is_active() 0 |
91 | #define storage_soft_reset() (void)0 | 91 | #define storage_soft_reset() (void)0 |
92 | #define storage_init() sd_init() | 92 | #define storage_init() sd_init() |
93 | #define storage_close() sd_close() | 93 | #define storage_read_sectors(drive, start, count, buf) sd_read_sectors(IF_MD2(drive,) start, count, buf) |
94 | #define storage_read_sectors(drive, start, count, buf) sd_read_sectors(IF_MV2(drive,) start, count, buf) | 94 | #define storage_write_sectors(drive, start, count, buf) sd_write_sectors(IF_MD2(drive,) start, count, buf) |
95 | #define storage_write_sectors(drive, start, count, buf) sd_write_sectors(IF_MV2(drive,) start, count, buf) | 95 | #define storage_last_disk_activity() sd_last_disk_activity() |
96 | #define storage_last_disk_activity() sd_last_disk_activity() | 96 | #define storage_spinup_time() 0 |
97 | #define storage_spinup_time() 0 | 97 | #define storage_get_identify() sd_get_identify() |
98 | #define storage_get_identify() sd_get_identify() | 98 | |
99 | 99 | #ifdef STORAGE_GET_INFO | |
100 | #ifdef STORAGE_GET_INFO | 100 | #define storage_get_info(drive, info) sd_get_info(IF_MD2(drive,) info) |
101 | #define storage_get_info(drive, info) sd_get_info(IF_MV2(drive,) info) | 101 | #endif |
102 | #endif | 102 | #ifdef HAVE_HOTSWAP |
103 | #ifdef HAVE_HOTSWAP | 103 | #define storage_removable(drive) sd_removable(IF_MD(drive)) |
104 | #define storage_removable(drive) sd_removable(IF_MV(drive)) | 104 | #define storage_present(drive) sd_present(IF_MD(drive)) |
105 | #define storage_present(drive) sd_present(IF_MV(drive)) | 105 | #endif |
106 | #endif | 106 | #elif (CONFIG_STORAGE & STORAGE_MMC) |
107 | #elif (CONFIG_STORAGE & STORAGE_MMC) | 107 | #define storage_spindown mmc_spindown |
108 | #define storage_spindown mmc_spindown | 108 | #define storage_sleep mmc_sleep |
109 | #define storage_sleep mmc_sleep | 109 | #define storage_spin mmc_spin |
110 | #define storage_spin mmc_spin | 110 | |
111 | 111 | #define storage_enable(on) mmc_enable(on) | |
112 | #define storage_enable(on) mmc_enable(on) | 112 | #define storage_sleepnow() mmc_sleepnow() |
113 | #define storage_sleepnow() mmc_sleepnow() | 113 | #define storage_disk_is_active() mmc_disk_is_active() |
114 | #define storage_disk_is_active() mmc_disk_is_active() | 114 | #define storage_soft_reset() (void)0 |
115 | #define storage_soft_reset() (void)0 | 115 | #define storage_init() mmc_init() |
116 | #define storage_init() mmc_init() | 116 | #define storage_read_sectors(drive, start, count, buf) mmc_read_sectors(IF_MD2(drive,) start, count, buf) |
117 | #define storage_close() mmc_close() | 117 | #define storage_write_sectors(drive, start, count, buf) mmc_write_sectors(IF_MD2(drive,) start, count, buf) |
118 | #define storage_read_sectors(drive, start, count, buf) mmc_read_sectors(IF_MV2(drive,) start, count, buf) | 118 | #define storage_last_disk_activity() mmc_last_disk_activity() |
119 | #define storage_write_sectors(drive, start, count, buf) mmc_write_sectors(IF_MV2(drive,) start, count, buf) | 119 | #define storage_spinup_time() 0 |
120 | #define storage_last_disk_activity() mmc_last_disk_activity() | 120 | #define storage_get_identify() mmc_get_identify() |
121 | #define storage_spinup_time() 0 | 121 | |
122 | #define storage_get_identify() mmc_get_identify() | 122 | #ifdef STORAGE_GET_INFO |
123 | 123 | #define storage_get_info(drive, info) mmc_get_info(IF_MD2(drive,) info) | |
124 | #ifdef STORAGE_GET_INFO | 124 | #endif |
125 | #define storage_get_info(drive, info) mmc_get_info(IF_MV2(drive,) info) | 125 | #ifdef HAVE_HOTSWAP |
126 | #endif | 126 | #define storage_removable(drive) mmc_removable(IF_MD(drive)) |
127 | #ifdef HAVE_HOTSWAP | 127 | #define storage_present(drive) mmc_present(IF_MD(drive)) |
128 | #define storage_removable(drive) mmc_removable(IF_MV(drive)) | 128 | #endif |
129 | #define storage_present(drive) mmc_present(IF_MV(drive)) | 129 | #elif (CONFIG_STORAGE & STORAGE_NAND) |
130 | #endif | 130 | #define storage_spindown nand_spindown |
131 | #elif (CONFIG_STORAGE & STORAGE_NAND) | 131 | #define storage_sleep nand_sleep |
132 | #define storage_spindown nand_spindown | 132 | #define storage_spin nand_spin |
133 | #define storage_sleep nand_sleep | 133 | |
134 | #define storage_spin nand_spin | 134 | #define storage_enable(on) (void)0 |
135 | 135 | #define storage_sleepnow() nand_sleepnow() | |
136 | #define storage_enable(on) (void)0 | 136 | #define storage_disk_is_active() 0 |
137 | #define storage_sleepnow() nand_sleepnow() | 137 | #define storage_soft_reset() (void)0 |
138 | #define storage_disk_is_active() 0 | 138 | #define storage_init() nand_init() |
139 | #define storage_soft_reset() (void)0 | 139 | #define storage_read_sectors(drive, start, count, buf) nand_read_sectors(IF_MD2(drive,) start, count, buf) |
140 | #define storage_init() nand_init() | 140 | #define storage_write_sectors(drive, start, count, buf) nand_write_sectors(IF_MD2(drive,) start, count, buf) |
141 | #define storage_close() nand_close() | 141 | #define storage_last_disk_activity() nand_last_disk_activity() |
142 | #define storage_read_sectors(drive, start, count, buf) nand_read_sectors(IF_MV2(drive,) start, count, buf) | 142 | #define storage_spinup_time() 0 |
143 | #define storage_write_sectors(drive, start, count, buf) nand_write_sectors(IF_MV2(drive,) start, count, buf) | 143 | #define storage_get_identify() nand_get_identify() |
144 | #define storage_last_disk_activity() nand_last_disk_activity() | 144 | |
145 | #define storage_spinup_time() 0 | 145 | #ifdef STORAGE_GET_INFO |
146 | #define storage_get_identify() nand_get_identify() | 146 | #define storage_get_info(drive, info) nand_get_info(IF_MD2(drive,) info) |
147 | 147 | #endif | |
148 | #ifdef STORAGE_GET_INFO | 148 | #ifdef HAVE_HOTSWAP |
149 | #define storage_get_info(drive, info) nand_get_info(IF_MV2(drive,) info) | 149 | #define storage_removable(drive) nand_removable(IF_MD(drive)) |
150 | #endif | 150 | #define storage_present(drive) nand_present(IF_MD(drive)) |
151 | #ifdef HAVE_HOTSWAP | 151 | #endif |
152 | #define storage_removable(drive) nand_removable(IF_MV(drive)) | 152 | #elif (CONFIG_STORAGE & STORAGE_RAMDISK) |
153 | #define storage_present(drive) nand_present(IF_MV(drive)) | 153 | #define storage_spindown ramdisk_spindown |
154 | #endif | 154 | #define storage_sleep ramdisk_sleep |
155 | #elif (CONFIG_STORAGE & STORAGE_RAMDISK) | 155 | #define storage_spin ramdisk_spin |
156 | #define storage_spindown ramdisk_spindown | 156 | |
157 | #define storage_sleep ramdisk_sleep | 157 | #define storage_enable(on) (void)0 |
158 | #define storage_spin ramdisk_spin | 158 | #define storage_sleepnow() ramdisk_sleepnow() |
159 | 159 | #define storage_disk_is_active() 0 | |
160 | #define storage_enable(on) (void)0 | 160 | #define storage_soft_reset() (void)0 |
161 | #define storage_sleepnow() ramdisk_sleepnow() | 161 | #define storage_init() ramdisk_init() |
162 | #define storage_disk_is_active() 0 | 162 | #define storage_read_sectors(drive, start, count, buf) ramdisk_read_sectors(IF_MD2(drive,) start, count, buf) |
163 | #define storage_soft_reset() (void)0 | 163 | #define storage_write_sectors(drive, start, count, buf) ramdisk_write_sectors(IF_MD2(drive,) start, count, buf) |
164 | #define storage_init() ramdisk_init() | 164 | #define storage_last_disk_activity() ramdisk_last_disk_activity() |
165 | #define storage_close() ramdisk_close() | 165 | #define storage_spinup_time() 0 |
166 | #define storage_read_sectors(drive, start, count, buf) ramdisk_read_sectors(IF_MV2(drive,) start, count, buf) | 166 | #define storage_get_identify() ramdisk_get_identify() |
167 | #define storage_write_sectors(drive, start, count, buf) ramdisk_write_sectors(IF_MV2(drive,) start, count, buf) | 167 | |
168 | #define storage_last_disk_activity() ramdisk_last_disk_activity() | 168 | #ifdef STORAGE_GET_INFO |
169 | #define storage_spinup_time() 0 | 169 | #define storage_get_info(drive, info) ramdisk_get_info(IF_MD2(drive,) info) |
170 | #define storage_get_identify() ramdisk_get_identify() | 170 | #endif |
171 | 171 | #ifdef HAVE_HOTSWAP | |
172 | #ifdef STORAGE_GET_INFO | 172 | #define storage_removable(drive) ramdisk_removable(IF_MD(drive)) |
173 | #define storage_get_info(drive, info) ramdisk_get_info(IF_MV2(drive,) info) | 173 | #define storage_present(drive) ramdisk_present(IF_MD(drive)) |
174 | #endif | 174 | #endif |
175 | #ifdef HAVE_HOTSWAP | 175 | #else |
176 | #define storage_removable(drive) ramdisk_removable(IF_MV(drive)) | 176 | //#error No storage driver! |
177 | #define storage_present(drive) ramdisk_present(IF_MV(drive)) | 177 | #endif |
178 | #endif | 178 | #else /* NOT CONFIG_STORAGE_MULTI and NOT SIMULATOR*/ |
179 | #else | 179 | |
180 | //#error No storage driver! | 180 | /* Simulator and multi-driver use normal functions */ |
181 | #endif | 181 | |
182 | #else /* NOT CONFIG_STORAGE_MULTI */ | ||
183 | |||
184 | /* TODO : implement multi-driver here */ | ||
185 | #error Multi-driver storage not implemented yet | ||
186 | |||
187 | #endif /* NOT CONFIG_STORAGE_MULTI */ | ||
188 | #else /*NOT SIMULATOR */ | ||
189 | void storage_enable(bool on); | 182 | void storage_enable(bool on); |
190 | void storage_sleep(void); | 183 | void storage_sleep(void); |
191 | void storage_sleepnow(void); | 184 | void storage_sleepnow(void); |
192 | bool storage_disk_is_active(void); | 185 | bool storage_disk_is_active(void); |
193 | int storage_soft_reset(void); | 186 | int storage_soft_reset(void); |
194 | int storage_init(void); | 187 | int storage_init(void); |
195 | void storage_close(void); | ||
196 | int storage_read_sectors(int drive, unsigned long start, int count, void* buf); | 188 | int storage_read_sectors(int drive, unsigned long start, int count, void* buf); |
197 | int storage_write_sectors(int drive, unsigned long start, int count, const void* buf); | 189 | int storage_write_sectors(int drive, unsigned long start, int count, const void* buf); |
198 | void storage_spin(void); | 190 | void storage_spin(void); |
199 | void storage_spindown(int seconds); | 191 | void storage_spindown(int seconds); |
200 | long storage_last_disk_activity(void); | 192 | long storage_last_disk_activity(void); |
201 | int storage_spinup_time(void); | 193 | int storage_spinup_time(void); |
194 | int storage_num_drives(void); | ||
202 | #ifdef STORAGE_GET_INFO | 195 | #ifdef STORAGE_GET_INFO |
203 | void storage_get_info(int drive, struct storage_info *info); | 196 | void storage_get_info(int drive, struct storage_info *info); |
204 | #endif | 197 | #endif |
@@ -206,5 +199,6 @@ void storage_get_info(int drive, struct storage_info *info); | |||
206 | bool storage_removable(int drive); | 199 | bool storage_removable(int drive); |
207 | bool storage_present(int drive); | 200 | bool storage_present(int drive); |
208 | #endif | 201 | #endif |
209 | #endif/*NOT SIMULATOR */ | 202 | |
203 | #endif /* NOT CONFIG_STORAGE_MULTI and NOT SIMULATOR*/ | ||
210 | #endif | 204 | #endif |