00001
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047 #ifndef _MEM_CTRL_H_
00048 #define _MEM_CTRL_H_
00049
00050 #include "conf/conf_access.h"
00051 #include "ctrl_status.h"
00052
00053
00054 #ifndef ACCESS_MEM_TO_RAM
00055 # define ACCESS_MEM_TO_RAM DISABLE
00056 #endif
00057
00058
00059 #ifndef LUN_0
00060 # define LUN_0 DISABLE
00061 #endif
00062 #ifndef LUN_1
00063 # define LUN_1 DISABLE
00064 #endif
00065 #ifndef LUN_2
00066 # define LUN_2 DISABLE
00067 #endif
00068 #ifndef LUN_3
00069 # define LUN_3 DISABLE
00070 #endif
00071 #ifndef LUN_4
00072 # define LUN_4 DISABLE
00073 #endif
00074 #ifndef LUN_5
00075 # define LUN_5 DISABLE
00076 #endif
00077 #ifndef LUN_6
00078 # define LUN_6 DISABLE
00079 #endif
00080 #ifndef LUN_7
00081 # define LUN_7 DISABLE
00082 #endif
00083 #ifndef LUN_USB
00084 # define LUN_USB DISABLE
00085 #endif
00086
00087
00088 #define LUN_ID_VIRTUAL LUN_ID_0
00089 #define LUN_0_INCLUDE "lib_mem\virtual_mem\virtual_mem.h"
00090 #define Lun_0_test_unit_ready() virtual_test_unit_ready()
00091 #define Lun_0_read_capacity(nb_sect) virtual_read_capacity(nb_sect)
00092 #define Lun_0_wr_protect() virtual_wr_protect()
00093 #define Lun_0_removal() virtual_removal()
00094 #define Lun_0_read_10(ad, sec) virtual_read_10(ad, sec)
00095 #define Lun_0_write_10(ad, sec) virtual_write_10(ad, sec)
00096 #define Lun_0_ram_2_mem(addr , ram) virtual_ram_2_mem(addr, ram)
00097 #define Lun_0_mem_2_ram(addr , ram) virtual_mem_2_ram(addr, ram)
00098 #define LUN_0_NAME "VIRTUAL_MEM_ON_CHIP"
00099
00100
00101 #define LUN_ID_NF LUN_ID_1
00102 #define LUN_1_INCLUDE "lib_mem\nf\nf_mngt.h"
00103 #define Lun_1_test_unit_ready() nf_test_unit_ready()
00104 #define Lun_1_read_capacity(nb_sect) nf_read_capacity(nb_sect)
00105 #define Lun_1_wr_protect() nf_wr_protect()
00106 #define Lun_1_removal() nf_removal()
00107 #define Lun_1_read_10(ad, sec) nf_read_10(ad, sec)
00108 #define Lun_1_write_10(ad, sec) nf_write_10(ad, sec)
00109 #define Lun_1_ram_2_mem(addr , ram) nf_ram_2_nf(addr, ram)
00110 #define Lun_1_mem_2_ram(addr , ram) nf_nf_2_ram(addr, ram)
00111 #define LUN_1_NAME "\"NAND Flash\""
00112
00113
00114 #define LUN_ID_DF LUN_ID_2
00115 #define LUN_2_INCLUDE "lib_mem\df\df_mem.h"
00116 #define Lun_2_test_unit_ready() df_test_unit_ready()
00117 #define Lun_2_read_capacity(nb_sect) df_read_capacity(nb_sect)
00118 #define Lun_2_wr_protect() df_wr_protect()
00119 #define Lun_2_removal() df_removal()
00120 #define Lun_2_read_10(ad, sec) df_read_10(ad, sec)
00121 #define Lun_2_write_10(ad, sec) df_write_10(ad, sec)
00122 #define Lun_2_ram_2_mem(addr , ram) df_ram_2_df(addr, ram)
00123 #define Lun_2_mem_2_ram(addr , ram) df_df_2_ram(addr, ram)
00124 #define LUN_2_NAME "\"On board data flash\""
00125
00126
00127 #define LUN_ID_MMC_SD LUN_ID_3
00128 #define LUN_3_INCLUDE "lib_mem\mmc_sd\mmc_sd_mem.h"
00129 #define Lun_3_test_unit_ready() mmc_sd_test_unit_ready()
00130 #define Lun_3_read_capacity(nb_sect) mmc_sd_read_capacity(nb_sect)
00131 #define Lun_3_wr_protect() mmc_sd_wr_protect()
00132 #define Lun_3_removal() mmc_sd_removal()
00133 #define Lun_3_read_10(ad, sec) mmc_sd_read_10(ad, sec)
00134 #define Lun_3_write_10(ad, sec) mmc_sd_write_10(ad, sec)
00135 #define Lun_3_ram_2_mem(addr , ram) mmc_ram_2_mmc(addr, ram)
00136 #define Lun_3_mem_2_ram(addr , ram) mmc_mmc_2_ram(addr, ram)
00137 #define LUN_3_NAME "\"MMC\""
00138
00139
00140 #define LUN_USB_INCLUDE "lib_mem\host_mem\host_mem.h"
00141 #define Lun_usb_get_lun() host_mem_get_lun()
00142 #define Lun_usb_test_unit_ready(lun) host_mem_test_unit_ready(lun)
00143 #define Lun_usb_read_capacity(lun,nb_sect) host_mem_read_capacity(lun,nb_sect)
00144 #define Lun_usb_read_sector_size(lun) host_mem_read_sector_size(lun)
00145 #define Lun_usb_wr_protect(lun) host_mem_wr_protect_cache(lun)
00146 #define Lun_usb_removal() host_mem_removal()
00147 #define Lun_usb_ram_2_mem(lun, addr , ram) host_mem_ram_2_mem(lun,addr,ram)
00148 #define Lun_usb_mem_2_ram(lun, addr , ram) host_mem_mem_2_ram(lun,addr,ram)
00149 #define LUN_USB_NAME "\"USB Remote memory\""
00150
00151
00152
00153 #if (LUN_0 == ENABLE)
00154 #include LUN_0_INCLUDE
00155 #endif
00156 #if (LUN_1 == ENABLE)
00157 #include LUN_1_INCLUDE
00158 #endif
00159 #if (LUN_2 == ENABLE)
00160 #include LUN_2_INCLUDE
00161 #endif
00162 #if (LUN_3 == ENABLE)
00163 #include LUN_3_INCLUDE
00164 #endif
00165 #if (LUN_4 == ENABLE)
00166 #include LUN_4_INCLUDE
00167 #endif
00168 #if (LUN_5 == ENABLE)
00169 #include LUN_5_INCLUDE
00170 #endif
00171 #if (LUN_6 == ENABLE)
00172 #include LUN_6_INCLUDE
00173 #endif
00174 #if (LUN_7 == ENABLE)
00175 #include LUN_7_INCLUDE
00176 #endif
00177 #if (LUN_USB == ENABLE)
00178 #include LUN_USB_INCLUDE
00179 #endif
00180
00181
00182
00183
00185
00186
00187
00188
00189 #ifndef LUN_0
00190 # error LUN_0 must be defined with ENABLE or DISABLE in conf_access.h
00191 #endif
00192 #ifndef LUN_1
00193 # error LUN_1 must be defined with ENABLE or DISABLE in conf_access.h
00194 #endif
00195 #ifndef LUN_2
00196 # error LUN_2 must be defined with ENABLE or DISABLE in conf_access.h
00197 #endif
00198 #ifndef LUN_3
00199 # error LUN_3 must be defined with ENABLE or DISABLE in conf_access.h
00200 #endif
00201 #ifndef LUN_4
00202 # error LUN_4 must be defined with ENABLE or DISABLE in conf_access.h
00203 #endif
00204 #ifndef LUN_5
00205 # error LUN_5 must be defined with ENABLE or DISABLE in conf_access.h
00206 #endif
00207 #ifndef LUN_6
00208 # error LUN_6 must be defined with ENABLE or DISABLE in conf_access.h
00209 #endif
00210 #ifndef LUN_7
00211 # error LUN_7 must be defined with ENABLE or DISABLE in conf_access.h
00212 #endif
00213 #ifndef LUN_USB
00214 # error LUN_USB must be defined with ENABLE or DISABLE in conf_access.h
00215 #endif
00216
00217
00218 #if (LUN_0 == ENABLE)
00219 #define LUN_0_EN 1
00220 #else
00221 #define LUN_0_EN 0
00222 #endif
00223 #if (LUN_1 == ENABLE)
00224 #define LUN_1_EN 1
00225 #else
00226 #define LUN_1_EN 0
00227 #endif
00228 #if (LUN_2 == ENABLE)
00229 #define LUN_2_EN 1
00230 #else
00231 #define LUN_2_EN 0
00232 #endif
00233 #if (LUN_3 == ENABLE)
00234 #define LUN_3_EN 1
00235 #else
00236 #define LUN_3_EN 0
00237 #endif
00238 #if (LUN_4 == ENABLE)
00239 #define LUN_4_EN 1
00240 #else
00241 #define LUN_4_EN 0
00242 #endif
00243 #if (LUN_5 == ENABLE)
00244 #define LUN_5_EN 1
00245 #else
00246 #define LUN_5_EN 0
00247 #endif
00248 #if (LUN_6 == ENABLE)
00249 #define LUN_6_EN 1
00250 #else
00251 #define LUN_6_EN 0
00252 #endif
00253 #if (LUN_7 == ENABLE)
00254 #define LUN_7_EN 1
00255 #else
00256 #define LUN_7_EN 0
00257 #endif
00258 #if (LUN_USB == ENABLE)
00259 #define LUN_USB_EN 1
00260 #else
00261 #define LUN_USB_EN 0
00262 #endif
00263
00264
00265 #define LUN_ID_0 (0)
00266 #define LUN_ID_1 (LUN_0_EN)
00267 #define LUN_ID_2 (LUN_0_EN+LUN_1_EN)
00268 #define LUN_ID_3 (LUN_0_EN+LUN_1_EN+LUN_2_EN)
00269 #define LUN_ID_4 (LUN_0_EN+LUN_1_EN+LUN_2_EN+LUN_3_EN)
00270 #define LUN_ID_5 (LUN_0_EN+LUN_1_EN+LUN_2_EN+LUN_3_EN+LUN_4_EN)
00271 #define LUN_ID_6 (LUN_0_EN+LUN_1_EN+LUN_2_EN+LUN_3_EN+LUN_4_EN+LUN_5_EN)
00272 #define LUN_ID_7 (LUN_0_EN+LUN_1_EN+LUN_2_EN+LUN_3_EN+LUN_4_EN+LUN_5_EN+LUN_6_EN)
00273 #define MAX_LUN (LUN_0_EN+LUN_1_EN+LUN_2_EN+LUN_3_EN+LUN_4_EN+LUN_5_EN+LUN_6_EN+LUN_7_EN)
00274 #define LUN_ID_USB (MAX_LUN)
00275
00276
00277 #if (MAX_LUN == 0 && LUN_USB ==DISABLE )
00278 #error No memory is active in conf_access.h
00279 #endif
00280
00281
00282
00283
00284
00285
00286 U8 get_nb_lun();
00287 U8 get_cur_lun();
00288 Ctrl_status mem_test_unit_ready( U8 lun );
00289 Ctrl_status mem_read_capacity( U8 lun , U32 _MEM_TYPE_SLOW_ *u32_nb_sector );
00290 U8 mem_sector_size( U8 lun );
00291 Bool mem_wr_protect( U8 lun );
00292 Bool mem_removal( U8 lun );
00293 U8 code* mem_name( U8 lun );
00294
00295
00296
00297
00298
00299 Ctrl_status memory_2_usb( U8 lun , U32 addr , U16 nb_sector );
00300 Ctrl_status usb_2_memory( U8 lun , U32 addr , U16 nb_sector );
00301
00302
00303 Ctrl_status memory_2_ram( U8 lun , const U32 _MEM_TYPE_SLOW_ addr , U8 _MEM_TYPE_SLOW_ *ram );
00304 Ctrl_status ram_2_memory( U8 lun , const U32 _MEM_TYPE_SLOW_ addr , U8 _MEM_TYPE_SLOW_ * ram );
00305
00306 #define ID_STREAM_ERR 0xFF
00307 U8 stream_mem_to_mem( U8 src_lun , U32 src_addr , U8 dest_lun , U32 dest_addr , U16 nb_sector );
00308 Ctrl_status stream_state( U8 Id );
00309 U16 stream_stop( U8 Id );
00310
00311 #endif // _MEM_CTRL_H_
00312