65 #if (ACCESS_MEM_TO_MEM == ENABLED)
66 #include "modules/file_system/fat.h"
67 U8 buf_sector[FS_SIZE_OF_SECTOR];
78 # error LUN_0 must be defined with ENABLE or DISABLE in conf_access.h
81 # error LUN_1 must be defined with ENABLE or DISABLE in conf_access.h
84 # error LUN_2 must be defined with ENABLE or DISABLE in conf_access.h
87 # error LUN_3 must be defined with ENABLE or DISABLE in conf_access.h
90 # error LUN_4 must be defined with ENABLE or DISABLE in conf_access.h
93 # error LUN_5 must be defined with ENABLE or DISABLE in conf_access.h
96 # error LUN_6 must be defined with ENABLE or DISABLE in conf_access.h
99 # error LUN_7 must be defined with ENABLE or DISABLE in conf_access.h
102 # error LUN_USB must be defined with ENABLE or DISABLE in conf_access.h
107 #if (LUN_0 == ENABLE)
109 U8 FLASH lun0_name[]=LUN_0_NAME;
113 #if (LUN_1 == ENABLE)
115 U8 FLASH lun1_name[]=LUN_1_NAME;
119 #if (LUN_2 == ENABLE)
121 U8 FLASH lun2_name[]=LUN_2_NAME;
125 #if (LUN_3 == ENABLE)
127 U8 FLASH lun3_name[]=LUN_3_NAME;
131 #if (LUN_4 == ENABLE)
133 U8 FLASH lun4_name[]=LUN_4_NAME;
137 #if (LUN_5 == ENABLE)
139 U8 FLASH lun5_name[]=LUN_5_NAME;
143 #if (LUN_6 == ENABLE)
145 U8 FLASH lun6_name[]=LUN_6_NAME;
149 #if (LUN_7 == ENABLE)
151 U8 FLASH lun7_name[]=LUN_7_NAME;
155 #if (LUN_USB == ENABLE)
157 U8 FLASH lunusb_name[]=LUN_USB_NAME;
164 #define LUN_ID_1 (LUN_0_EN)
165 #define LUN_ID_2 (LUN_0_EN+LUN_1_EN)
166 #define LUN_ID_3 (LUN_0_EN+LUN_1_EN+LUN_2_EN)
167 #define LUN_ID_4 (LUN_0_EN+LUN_1_EN+LUN_2_EN+LUN_3_EN)
168 #define LUN_ID_5 (LUN_0_EN+LUN_1_EN+LUN_2_EN+LUN_3_EN+LUN_4_EN)
169 #define LUN_ID_6 (LUN_0_EN+LUN_1_EN+LUN_2_EN+LUN_3_EN+LUN_4_EN+LUN_5_EN)
170 #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)
171 #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)
172 #define LUN_ID_USB (MAX_LUN)
176 #error No memory is active in conf_access.h
180 #if (GLOBAL_WR_PROTECT == ENABLED)
181 static U8 g_u8_wr_protect;
194 #if (MEM_USB == ENABLED)
195 return (MAX_LUN + Host_getlun());
229 # if (LUN_0 == ENABLE)
231 return Lun_0_test_unit_ready();
234 # if (LUN_1 == ENABLE)
236 return Lun_1_test_unit_ready();
239 # if (LUN_2 == ENABLE)
241 return Lun_2_test_unit_ready();
244 # if (LUN_3 == ENABLE)
246 return Lun_3_test_unit_ready();
249 # if (LUN_4 == ENABLE)
251 return Lun_4_test_unit_ready();
254 # if (LUN_5 == ENABLE)
256 return Lun_5_test_unit_ready();
259 # if (LUN_6 == ENABLE)
261 return Lun_6_test_unit_ready();
264 # if (LUN_7 == ENABLE)
266 return Lun_7_test_unit_ready();
269 # if (LUN_USB == ENABLE)
271 return Lun_usb_test_unit_ready(lun - LUN_ID_USB);
292 # if (LUN_0 == ENABLE)
294 return Lun_0_read_capacity( u32_nb_sector );
297 # if (LUN_1 == ENABLE)
299 return Lun_1_read_capacity( u32_nb_sector );
302 # if (LUN_2 == ENABLE)
304 return Lun_2_read_capacity( u32_nb_sector );
307 # if (LUN_3 == ENABLE)
309 return Lun_3_read_capacity( u32_nb_sector );
312 # if (LUN_4 == ENABLE)
314 return Lun_4_read_capacity( u32_nb_sector );
317 # if (LUN_5 == ENABLE)
319 return Lun_5_read_capacity( u32_nb_sector );
322 # if (LUN_6 == ENABLE)
324 return Lun_6_read_capacity( u32_nb_sector );
327 # if (LUN_7 == ENABLE)
329 return Lun_7_read_capacity( u32_nb_sector );
332 # if (LUN_USB == ENABLE)
334 return Lun_usb_read_capacity( lun - LUN_ID_USB,u32_nb_sector );
354 # if (LUN_0 == ENABLE)
356 return Lun_0_wr_protect();
359 # if (LUN_1 == ENABLE)
361 return Lun_1_wr_protect();
364 # if (LUN_2 == ENABLE)
366 return Lun_2_wr_protect();
369 # if (LUN_3 == ENABLE)
371 return Lun_3_wr_protect();
374 # if (LUN_4 == ENABLE)
376 return Lun_4_wr_protect();
379 # if (LUN_5 == ENABLE)
381 return Lun_5_wr_protect();
384 # if (LUN_6 == ENABLE)
386 return Lun_6_wr_protect();
389 # if (LUN_7 == ENABLE)
391 return Lun_7_wr_protect();
394 # if (LUN_USB == ENABLE)
396 return Lun_usb_wr_protect(lun - LUN_ID_USB);
414 # if (LUN_0 == ENABLE)
416 return Lun_0_removal();
419 # if (LUN_1 == ENABLE)
421 return Lun_1_removal();
424 # if (LUN_2 == ENABLE)
426 return Lun_2_removal();
429 # if (LUN_3 == ENABLE)
431 return Lun_3_removal();
434 # if (LUN_4 == ENABLE)
436 return Lun_4_removal();
439 # if (LUN_5 == ENABLE)
441 return Lun_5_removal();
444 # if (LUN_6 == ENABLE)
446 return Lun_6_removal();
449 # if (LUN_7 == ENABLE)
451 return Lun_7_removal();
454 # if (LUN_USB == ENABLE)
456 return Lun_usb_removal();
469 #if 0 //not used anywhere and the FLASH attribute causes a compilation warning - dak
470 U8 FLASH* mem_name( U8 lun )
474 # if (LUN_0 == ENABLE)
476 return (U8 FLASH*)lun0_name;
479 # if (LUN_1 == ENABLE)
481 return (U8 FLASH*)lun1_name;
484 # if (LUN_2 == ENABLE)
486 return (U8 FLASH*)lun2_name;
489 # if (LUN_3 == ENABLE)
491 return (U8 FLASH*)lun3_name;
494 # if (LUN_4 == ENABLE)
496 return (U8 FLASH*)lun4_name;
499 # if (LUN_5 == ENABLE)
501 return (U8 FLASH*)lun5_name;
504 # if (LUN_6 == ENABLE)
506 return (U8 FLASH*)lun6_name;
509 # if (LUN_7 == ENABLE)
511 return (U8 FLASH*)lun7_name;
514 # if (LUN_USB == ENABLE)
516 return (U8 FLASH*)lunusb_name;
546 # if (LUN_0 == ENABLE)
548 status = Lun_0_read_10(addr , nb_sector);
549 if (CTRL_GOOD == status)
551 status = Lun_0_usb_read();
555 # if (LUN_1 == ENABLE)
557 status = Lun_1_read_10(addr , nb_sector);
558 if (CTRL_GOOD == status)
560 status = Lun_1_usb_read();
564 # if (LUN_2 == ENABLE)
566 status = Lun_2_read_10(addr , nb_sector);
567 if (CTRL_GOOD == status)
569 status = Lun_2_usb_read();
573 # if (LUN_3 == ENABLE)
575 status = Lun_3_read_10(addr , nb_sector);
576 if (CTRL_GOOD == status)
578 status = Lun_3_usb_read();
582 # if (LUN_4 == ENABLE)
584 status = Lun_4_read_10(addr , nb_sector);
585 if (CTRL_GOOD == status)
587 status = Lun_4_usb_read();
591 # if (LUN_5 == ENABLE)
593 status = Lun_5_read_10(addr , nb_sector);
594 if (CTRL_GOOD == status)
596 status = Lun_5_usb_read();
600 # if (LUN_6 == ENABLE)
602 status = Lun_6_read_10(addr , nb_sector);
603 if (CTRL_GOOD == status)
605 status = Lun_6_usb_read();
609 # if (LUN_7 == ENABLE)
611 status = Lun_7_read_10(addr , nb_sector);
612 if (CTRL_GOOD == status)
614 status = Lun_7_usb_read();
639 # if (LUN_0 == ENABLE)
641 status = Lun_0_write_10(addr , nb_sector);
642 if (CTRL_GOOD == status)
644 status = Lun_0_usb_write();
648 # if (LUN_1 == ENABLE)
650 status = Lun_1_write_10(addr , nb_sector);
651 if (CTRL_GOOD == status)
653 status = Lun_1_usb_write();
657 # if (LUN_2 == ENABLE)
659 status = Lun_2_write_10(addr , nb_sector);
660 if (CTRL_GOOD == status)
662 status = Lun_2_usb_write();
666 # if (LUN_3 == ENABLE)
668 status = Lun_3_write_10(addr , nb_sector);
669 if (CTRL_GOOD == status)
671 status = Lun_3_usb_write();
675 # if (LUN_4 == ENABLE)
677 status = Lun_4_write_10(addr , nb_sector);
678 if (CTRL_GOOD == status)
680 status = Lun_4_usb_write();
684 # if (LUN_5 == ENABLE)
686 status = Lun_5_write_10(addr , nb_sector);
687 if (CTRL_GOOD == status)
689 status = Lun_5_usb_write();
693 # if (LUN_6 == ENABLE)
695 status = Lun_6_write_10(addr , nb_sector);
696 if (CTRL_GOOD == status)
698 status = Lun_6_usb_write();
702 # if (LUN_7 == ENABLE)
704 status = Lun_7_write_10(addr , nb_sector);
705 if (CTRL_GOOD == status)
707 status = Lun_7_usb_write();
716 #if (ACCESS_MEM_TO_RAM == ENABLED)
733 # if (LUN_0 == ENABLE)
735 status = Lun_0_mem_2_ram(*addr , ram);
736 if (CTRL_GOOD == status)
738 status = Lun_0_mem_2_ram_read();
742 # if (LUN_1 == ENABLE)
744 status = Lun_1_mem_2_ram(*addr , ram);
745 if (CTRL_GOOD == status)
747 status = Lun_1_mem_2_ram_read();
751 # if (LUN_2 == ENABLE)
753 status = Lun_2_mem_2_ram(*addr , ram);
754 if (CTRL_GOOD == status)
756 status = Lun_2_mem_2_ram_read();
760 # if (LUN_3 == ENABLE)
762 status = Lun_3_mem_2_ram(*addr , ram);
763 if (CTRL_GOOD == status)
765 status = Lun_3_mem_2_ram_read();
769 # if (LUN_4 == ENABLE)
771 status = Lun_4_mem_2_ram(*addr , ram);
772 if (CTRL_GOOD == status)
774 status = Lun_4_mem_2_ram_read();
778 # if (LUN_5 == ENABLE)
780 status = Lun_5_mem_2_ram(*addr , ram);
781 if (CTRL_GOOD == status)
783 status = Lun_5_mem_2_ram_read();
787 # if (LUN_6 == ENABLE)
789 status = Lun_6_mem_2_ram(*addr , ram);
790 if (CTRL_GOOD == status)
792 status = Lun_6_mem_2_ram_read();
796 # if (LUN_7 == ENABLE)
798 status = Lun_7_mem_2_ram(*addr , ram);
799 if (CTRL_GOOD == status)
801 status = Lun_7_mem_2_ram_read();
805 # if (LUN_USB == ENABLE)
807 return Lun_usb_mem_2_ram(*addr , ram);
812 #endif // ACCESS_MEM_TO_RAM == ENABLED
816 #if (ACCESS_MEM_TO_RAM==ENABLE)
832 # if (LUN_0 == ENABLE)
834 status = Lun_0_ram_2_mem(*addr , ram);
835 if (CTRL_GOOD == status)
837 status = Lun_0_ram_2_mem_write();
841 # if (LUN_1 == ENABLE)
843 status = Lun_1_ram_2_mem(*addr , ram);
844 if (CTRL_GOOD == status)
846 status = Lun_1_ram_2_mem_write();
850 # if (LUN_2 == ENABLE)
852 status = Lun_2_ram_2_mem(*addr , ram);
853 if (CTRL_GOOD == status)
855 status = Lun_2_ram_2_mem_write();
859 # if (LUN_3 == ENABLE)
861 status = Lun_3_ram_2_mem(*addr , ram);
862 if (CTRL_GOOD == status)
864 status = Lun_3_ram_2_mem_write();
868 # if (LUN_4 == ENABLE)
870 status = Lun_4_ram_2_mem(*addr , ram);
871 if (CTRL_GOOD == status)
873 status = Lun_4_ram_2_mem_write();
877 # if (LUN_5 == ENABLE)
879 status = Lun_5_ram_2_mem(*addr , ram);
880 if (CTRL_GOOD == status)
882 status = Lun_5_ram_2_mem_write();
886 # if (LUN_6 == ENABLE)
888 status = Lun_6_ram_2_mem(*addr , ram);
889 if (CTRL_GOOD == status)
891 status = Lun_6_ram_2_mem_write();
895 # if (LUN_7 == ENABLE)
897 status = Lun_7_ram_2_mem(*addr , ram);
898 if (CTRL_GOOD == status)
900 status = Lun_7_ram_2_mem_write();
904 # if (LUN_USB == ENABLE)
906 return Lun_usb_ram_2_mem(*addr , ram);
912 #endif // ACCESS_RAM_TO_MEM == ENABLED
917 #if (ACCESS_STREAM == ENABLED)
922 # if (ACCESS_MEM_TO_MEM == ENABLED)
943 # endif // ACCESS_MEM_TO_MEM == ENABLED
974 #endif // ACCESS_STREAM == ENABLED