diff options
64 files changed, 541 insertions, 554 deletions
diff --git a/apps/buffering.c b/apps/buffering.c index d963a983a6..534a82d7b9 100644 --- a/apps/buffering.c +++ b/apps/buffering.c | |||
@@ -26,7 +26,7 @@ | |||
26 | #include <ctype.h> | 26 | #include <ctype.h> |
27 | #include "buffering.h" | 27 | #include "buffering.h" |
28 | 28 | ||
29 | #include "ata.h" | 29 | #include "storage.h" |
30 | #include "system.h" | 30 | #include "system.h" |
31 | #include "thread.h" | 31 | #include "thread.h" |
32 | #include "file.h" | 32 | #include "file.h" |
@@ -832,7 +832,7 @@ static bool fill_buffer(void) | |||
832 | { | 832 | { |
833 | /* only spin the disk down if the filling wasn't interrupted by an | 833 | /* only spin the disk down if the filling wasn't interrupted by an |
834 | event arriving in the queue. */ | 834 | event arriving in the queue. */ |
835 | ata_sleep(); | 835 | storage_sleep(); |
836 | return false; | 836 | return false; |
837 | } | 837 | } |
838 | } | 838 | } |
@@ -1408,7 +1408,7 @@ void buffering_thread(void) | |||
1408 | * for simplicity until its done right */ | 1408 | * for simplicity until its done right */ |
1409 | #if MEM > 8 | 1409 | #if MEM > 8 |
1410 | /* If the disk is spinning, take advantage by filling the buffer */ | 1410 | /* If the disk is spinning, take advantage by filling the buffer */ |
1411 | else if (ata_disk_is_active() && queue_empty(&buffering_queue)) | 1411 | else if (storage_disk_is_active() && queue_empty(&buffering_queue)) |
1412 | { | 1412 | { |
1413 | if (num_handles > 0 && data_counters.useful <= high_watermark) | 1413 | if (num_handles > 0 && data_counters.useful <= high_watermark) |
1414 | send_event(BUFFER_EVENT_BUFFER_LOW, 0); | 1414 | send_event(BUFFER_EVENT_BUFFER_LOW, 0); |
diff --git a/apps/codecs.c b/apps/codecs.c index 53fa6755a8..8f5a0e36fd 100644 --- a/apps/codecs.c +++ b/apps/codecs.c | |||
@@ -43,7 +43,7 @@ | |||
43 | #include "buffering.h" | 43 | #include "buffering.h" |
44 | #include "mp3_playback.h" | 44 | #include "mp3_playback.h" |
45 | #include "backlight.h" | 45 | #include "backlight.h" |
46 | #include "ata.h" | 46 | #include "storage.h" |
47 | #include "talk.h" | 47 | #include "talk.h" |
48 | #include "mp3data.h" | 48 | #include "mp3data.h" |
49 | #include "powermgmt.h" | 49 | #include "powermgmt.h" |
diff --git a/apps/debug_menu.c b/apps/debug_menu.c index 26534cc101..b6038e7c89 100644 --- a/apps/debug_menu.c +++ b/apps/debug_menu.c | |||
@@ -59,13 +59,16 @@ | |||
59 | #include "power.h" | 59 | #include "power.h" |
60 | #include "usb.h" | 60 | #include "usb.h" |
61 | #include "rtc.h" | 61 | #include "rtc.h" |
62 | #include "ata.h" | 62 | #include "storage.h" |
63 | #include "fat.h" | 63 | #include "fat.h" |
64 | #include "mas.h" | 64 | #include "mas.h" |
65 | #include "eeprom_24cxx.h" | 65 | #include "eeprom_24cxx.h" |
66 | #if (CONFIG_STORAGE & STORAGE_MMC) || (CONFIG_STORAGE & STORAGE_SD) | 66 | #if (CONFIG_STORAGE & STORAGE_MMC) || (CONFIG_STORAGE & STORAGE_SD) |
67 | #include "hotswap.h" | 67 | #include "hotswap.h" |
68 | #endif | 68 | #endif |
69 | #if (CONFIG_STORAGE & STORAGE_ATA) | ||
70 | #include "ata.h" | ||
71 | #endif | ||
69 | #if CONFIG_TUNER | 72 | #if CONFIG_TUNER |
70 | #include "tuner.h" | 73 | #include "tuner.h" |
71 | #include "radio.h" | 74 | #include "radio.h" |
@@ -1731,11 +1734,13 @@ static bool view_battery(void) | |||
1731 | 1734 | ||
1732 | #ifndef SIMULATOR | 1735 | #ifndef SIMULATOR |
1733 | #if (CONFIG_STORAGE & STORAGE_MMC) || (CONFIG_STORAGE & STORAGE_SD) | 1736 | #if (CONFIG_STORAGE & STORAGE_MMC) || (CONFIG_STORAGE & STORAGE_SD) |
1737 | |||
1734 | #if (CONFIG_STORAGE & STORAGE_MMC) | 1738 | #if (CONFIG_STORAGE & STORAGE_MMC) |
1735 | #define CARDTYPE "MMC" | 1739 | #define CARDTYPE "MMC" |
1736 | #else | 1740 | #elif (CONFIG_STORAGE & STORAGE_SD) |
1737 | #define CARDTYPE "microSD" | 1741 | #define CARDTYPE "microSD" |
1738 | #endif | 1742 | #endif |
1743 | |||
1739 | static int disk_callback(int btn, struct gui_synclist *lists) | 1744 | static int disk_callback(int btn, struct gui_synclist *lists) |
1740 | { | 1745 | { |
1741 | tCardInfo *card; | 1746 | tCardInfo *card; |
@@ -1826,7 +1831,7 @@ static int disk_callback(int btn, struct gui_synclist *lists) | |||
1826 | } | 1831 | } |
1827 | return btn; | 1832 | return btn; |
1828 | } | 1833 | } |
1829 | #else /* !(CONFIG_STORAGE & STORAGE_MMC) && !(CONFIG_STORAGE & STORAGE_SD) */ | 1834 | #elif (CONFIG_STORAGE & STORAGE_ATA) |
1830 | static int disk_callback(int btn, struct gui_synclist *lists) | 1835 | static int disk_callback(int btn, struct gui_synclist *lists) |
1831 | { | 1836 | { |
1832 | (void)lists; | 1837 | (void)lists; |
@@ -1860,7 +1865,7 @@ static int disk_callback(int btn, struct gui_synclist *lists) | |||
1860 | simplelist_addline(SIMPLELIST_ADD_LINE, | 1865 | simplelist_addline(SIMPLELIST_ADD_LINE, |
1861 | "Free: %ld MB", free / 1024); | 1866 | "Free: %ld MB", free / 1024); |
1862 | simplelist_addline(SIMPLELIST_ADD_LINE, | 1867 | simplelist_addline(SIMPLELIST_ADD_LINE, |
1863 | "Spinup time: %d ms", ata_spinup_time * (1000/HZ)); | 1868 | "Spinup time: %d ms", storage_spinup_time() * (1000/HZ)); |
1864 | i = identify_info[83] & (1<<3); | 1869 | i = identify_info[83] & (1<<3); |
1865 | simplelist_addline(SIMPLELIST_ADD_LINE, | 1870 | simplelist_addline(SIMPLELIST_ADD_LINE, |
1866 | "Power mgmt: %s", i ? "enabled" : "unsupported"); | 1871 | "Power mgmt: %s", i ? "enabled" : "unsupported"); |
@@ -1945,7 +1950,29 @@ static int disk_callback(int btn, struct gui_synclist *lists) | |||
1945 | "Cluster size: %d bytes", fat_get_cluster_size(IF_MV(0))); | 1950 | "Cluster size: %d bytes", fat_get_cluster_size(IF_MV(0))); |
1946 | return btn; | 1951 | return btn; |
1947 | } | 1952 | } |
1953 | #else /* No SD, MMC or ATA */ | ||
1954 | static int disk_callback(int btn, struct gui_synclist *lists) | ||
1955 | { | ||
1956 | (void)btn; | ||
1957 | (void)lists; | ||
1958 | struct storage_info info; | ||
1959 | storage_get_info(IF_MV2(0,)&info); | ||
1960 | simplelist_addline(SIMPLELIST_ADD_LINE, "Vendor: %s", info.vendor); | ||
1961 | simplelist_addline(SIMPLELIST_ADD_LINE, "Model: %s", info.product); | ||
1962 | simplelist_addline(SIMPLELIST_ADD_LINE, "Firmware: %s", info.revision); | ||
1963 | simplelist_addline(SIMPLELIST_ADD_LINE, | ||
1964 | "Size: %ld MB", info.num_sectors*(info.sector_size/512)/2024); | ||
1965 | unsigned long free; | ||
1966 | fat_size( IF_MV2(0,) NULL, &free ); | ||
1967 | simplelist_addline(SIMPLELIST_ADD_LINE, | ||
1968 | "Free: %ld MB", free / 1024); | ||
1969 | simplelist_addline(SIMPLELIST_ADD_LINE, | ||
1970 | "Cluster size: %d bytes", fat_get_cluster_size(IF_MV(0))); | ||
1971 | return btn; | ||
1972 | } | ||
1973 | #endif | ||
1948 | 1974 | ||
1975 | #if (CONFIG_STORAGE & STORAGE_ATA) | ||
1949 | static bool dbg_identify_info(void) | 1976 | static bool dbg_identify_info(void) |
1950 | { | 1977 | { |
1951 | int fd = creat("/identify_info.bin"); | 1978 | int fd = creat("/identify_info.bin"); |
@@ -1960,7 +1987,7 @@ static bool dbg_identify_info(void) | |||
1960 | } | 1987 | } |
1961 | return false; | 1988 | return false; |
1962 | } | 1989 | } |
1963 | #endif /* !(CONFIG_STORAGE & STORAGE_MMC) && !(CONFIG_STORAGE & STORAGE_SD) */ | 1990 | #endif |
1964 | 1991 | ||
1965 | static bool dbg_disk_info(void) | 1992 | static bool dbg_disk_info(void) |
1966 | { | 1993 | { |
@@ -2504,7 +2531,7 @@ static const struct the_menu_item menuitems[] = { | |||
2504 | #endif | 2531 | #endif |
2505 | #ifndef SIMULATOR | 2532 | #ifndef SIMULATOR |
2506 | { "View disk info", dbg_disk_info }, | 2533 | { "View disk info", dbg_disk_info }, |
2507 | #if !(CONFIG_STORAGE & STORAGE_MMC) && !(CONFIG_STORAGE & STORAGE_SD) | 2534 | #if (CONFIG_STORAGE & STORAGE_ATA) |
2508 | { "Dump ATA identify info", dbg_identify_info}, | 2535 | { "Dump ATA identify info", dbg_identify_info}, |
2509 | #endif | 2536 | #endif |
2510 | #endif | 2537 | #endif |
diff --git a/apps/gui/gwps.c b/apps/gui/gwps.c index 4d50740182..9b6d6b5558 100644 --- a/apps/gui/gwps.c +++ b/apps/gui/gwps.c | |||
@@ -39,7 +39,7 @@ | |||
39 | #include "audio.h" | 39 | #include "audio.h" |
40 | #include "usb.h" | 40 | #include "usb.h" |
41 | #include "status.h" | 41 | #include "status.h" |
42 | #include "ata.h" | 42 | #include "storage.h" |
43 | #include "screens.h" | 43 | #include "screens.h" |
44 | #include "playlist.h" | 44 | #include "playlist.h" |
45 | #ifdef HAVE_LCD_BITMAP | 45 | #ifdef HAVE_LCD_BITMAP |
@@ -184,7 +184,7 @@ long gui_wps_show(void) | |||
184 | if (wps_state.paused) { | 184 | if (wps_state.paused) { |
185 | settings_save(); | 185 | settings_save(); |
186 | #if !defined(HAVE_RTC_RAM) && !defined(HAVE_SW_POWEROFF) | 186 | #if !defined(HAVE_RTC_RAM) && !defined(HAVE_SW_POWEROFF) |
187 | call_ata_idle_notifys(true); | 187 | call_storage_idle_notifys(true); |
188 | #endif | 188 | #endif |
189 | } | 189 | } |
190 | } | 190 | } |
@@ -322,7 +322,7 @@ long gui_wps_show(void) | |||
322 | audio_pause(); | 322 | audio_pause(); |
323 | settings_save(); | 323 | settings_save(); |
324 | #if !defined(HAVE_RTC_RAM) && !defined(HAVE_SW_POWEROFF) | 324 | #if !defined(HAVE_RTC_RAM) && !defined(HAVE_SW_POWEROFF) |
325 | call_ata_idle_notifys(true); /* make sure resume info is saved */ | 325 | call_storage_idle_notifys(true); /* make sure resume info is saved */ |
326 | #endif | 326 | #endif |
327 | } | 327 | } |
328 | break; | 328 | break; |
@@ -701,7 +701,7 @@ long gui_wps_show(void) | |||
701 | } | 701 | } |
702 | 702 | ||
703 | if ( button ) | 703 | if ( button ) |
704 | ata_spin(); | 704 | storage_spin(); |
705 | } | 705 | } |
706 | return GO_TO_ROOT; /* unreachable - just to reduce compiler warnings */ | 706 | return GO_TO_ROOT; /* unreachable - just to reduce compiler warnings */ |
707 | } | 707 | } |
diff --git a/apps/main.c b/apps/main.c index 50597699c5..111c5d1e78 100644 --- a/apps/main.c +++ b/apps/main.c | |||
@@ -20,7 +20,7 @@ | |||
20 | ****************************************************************************/ | 20 | ****************************************************************************/ |
21 | #include "config.h" | 21 | #include "config.h" |
22 | 22 | ||
23 | #include "ata.h" | 23 | #include "storage.h" |
24 | #include "disk.h" | 24 | #include "disk.h" |
25 | #include "fat.h" | 25 | #include "fat.h" |
26 | #include "lcd.h" | 26 | #include "lcd.h" |
@@ -289,7 +289,7 @@ static void init(void) | |||
289 | #endif | 289 | #endif |
290 | /* Must be done before any code uses the multi-screen APi */ | 290 | /* Must be done before any code uses the multi-screen APi */ |
291 | gui_syncstatusbar_init(&statusbars); | 291 | gui_syncstatusbar_init(&statusbars); |
292 | ata_init(); | 292 | storage_init(); |
293 | settings_reset(); | 293 | settings_reset(); |
294 | settings_load(SETTINGS_ALL); | 294 | settings_load(SETTINGS_ALL); |
295 | gui_sync_wps_init(); | 295 | gui_sync_wps_init(); |
@@ -427,7 +427,7 @@ static void init(void) | |||
427 | } | 427 | } |
428 | #endif | 428 | #endif |
429 | 429 | ||
430 | rc = ata_init(); | 430 | rc = storage_init(); |
431 | if(rc) | 431 | if(rc) |
432 | { | 432 | { |
433 | #ifdef HAVE_LCD_BITMAP | 433 | #ifdef HAVE_LCD_BITMAP |
diff --git a/apps/misc.c b/apps/misc.c index 7c8ff0fbd8..02d8bed2d8 100644 --- a/apps/misc.c +++ b/apps/misc.c | |||
@@ -46,7 +46,7 @@ | |||
46 | #include "audio.h" | 46 | #include "audio.h" |
47 | #include "mp3_playback.h" | 47 | #include "mp3_playback.h" |
48 | #include "settings.h" | 48 | #include "settings.h" |
49 | #include "ata.h" | 49 | #include "storage.h" |
50 | #include "ata_idle_notify.h" | 50 | #include "ata_idle_notify.h" |
51 | #include "kernel.h" | 51 | #include "kernel.h" |
52 | #include "power.h" | 52 | #include "power.h" |
@@ -621,7 +621,7 @@ bool settings_parseline(char* line, char** name, char** value) | |||
621 | static void system_flush(void) | 621 | static void system_flush(void) |
622 | { | 622 | { |
623 | tree_flush(); | 623 | tree_flush(); |
624 | call_ata_idle_notifys(true); /*doesnt work on usb and shutdown from ata thread */ | 624 | call_storage_idle_notifys(true); /*doesnt work on usb and shutdown from ata thread */ |
625 | } | 625 | } |
626 | 626 | ||
627 | static void system_restore(void) | 627 | static void system_restore(void) |
@@ -635,7 +635,7 @@ static bool clean_shutdown(void (*callback)(void *), void *parameter) | |||
635 | (void)callback; | 635 | (void)callback; |
636 | (void)parameter; | 636 | (void)parameter; |
637 | bookmark_autobookmark(); | 637 | bookmark_autobookmark(); |
638 | call_ata_idle_notifys(true); | 638 | call_storage_idle_notifys(true); |
639 | exit(0); | 639 | exit(0); |
640 | #else | 640 | #else |
641 | long msg_id = -1; | 641 | long msg_id = -1; |
diff --git a/apps/mpeg.c b/apps/mpeg.c index 3c37a6b22f..f6d48bf42c 100644 --- a/apps/mpeg.c +++ b/apps/mpeg.c | |||
@@ -29,7 +29,7 @@ | |||
29 | #include "metadata.h" | 29 | #include "metadata.h" |
30 | #include "mpeg.h" | 30 | #include "mpeg.h" |
31 | #include "audio.h" | 31 | #include "audio.h" |
32 | #include "ata.h" | 32 | #include "storage.h" |
33 | #include "string.h" | 33 | #include "string.h" |
34 | #include <kernel.h> | 34 | #include <kernel.h> |
35 | #include "thread.h" | 35 | #include "thread.h" |
@@ -509,7 +509,7 @@ static void generate_postbuffer_events(void) | |||
509 | static void recalculate_watermark(int bitrate) | 509 | static void recalculate_watermark(int bitrate) |
510 | { | 510 | { |
511 | int bytes_per_sec; | 511 | int bytes_per_sec; |
512 | int time = ata_spinup_time; | 512 | int time = storage_spinup_time(); |
513 | 513 | ||
514 | /* A bitrate of 0 probably means empty VBR header. We play safe | 514 | /* A bitrate of 0 probably means empty VBR header. We play safe |
515 | and set a high threshold */ | 515 | and set a high threshold */ |
@@ -1589,7 +1589,7 @@ static void mpeg_thread(void) | |||
1589 | DEBUGF("0\n"); | 1589 | DEBUGF("0\n"); |
1590 | filling = false; | 1590 | filling = false; |
1591 | generate_postbuffer_events(); | 1591 | generate_postbuffer_events(); |
1592 | ata_sleep(); | 1592 | storage_sleep(); |
1593 | break; | 1593 | break; |
1594 | } | 1594 | } |
1595 | 1595 | ||
@@ -1947,7 +1947,7 @@ static void mpeg_thread(void) | |||
1947 | rc = fsync(mpeg_file); | 1947 | rc = fsync(mpeg_file); |
1948 | if (rc < 0) | 1948 | if (rc < 0) |
1949 | panicf("rec fls: %d", rc); | 1949 | panicf("rec fls: %d", rc); |
1950 | ata_sleep(); | 1950 | storage_sleep(); |
1951 | break; | 1951 | break; |
1952 | 1952 | ||
1953 | case NEW_FILE: | 1953 | case NEW_FILE: |
@@ -1957,7 +1957,7 @@ static void mpeg_thread(void) | |||
1957 | panicf("rec cls: %d", rc); | 1957 | panicf("rec cls: %d", rc); |
1958 | mpeg_file = -1; | 1958 | mpeg_file = -1; |
1959 | update_header(); | 1959 | update_header(); |
1960 | ata_sleep(); | 1960 | storage_sleep(); |
1961 | 1961 | ||
1962 | /* copy new filename */ | 1962 | /* copy new filename */ |
1963 | strcpy(delayed_filename, recording_filename); | 1963 | strcpy(delayed_filename, recording_filename); |
diff --git a/apps/playback.c b/apps/playback.c index b2305949ac..ec4f4197a4 100644 --- a/apps/playback.c +++ b/apps/playback.c | |||
@@ -49,7 +49,7 @@ | |||
49 | #include "mp3_playback.h" | 49 | #include "mp3_playback.h" |
50 | #include "usb.h" | 50 | #include "usb.h" |
51 | #include "status.h" | 51 | #include "status.h" |
52 | #include "ata.h" | 52 | #include "storage.h" |
53 | #include "screens.h" | 53 | #include "screens.h" |
54 | #include "playlist.h" | 54 | #include "playlist.h" |
55 | #include "playback.h" | 55 | #include "playback.h" |
diff --git a/apps/playlist.c b/apps/playlist.c index cdcc0594c2..95e1b8262c 100644 --- a/apps/playlist.c +++ b/apps/playlist.c | |||
@@ -1266,7 +1266,7 @@ static void playlist_thread(void) | |||
1266 | if (playlist->control_fd >= 0) | 1266 | if (playlist->control_fd >= 0) |
1267 | { | 1267 | { |
1268 | if (playlist->num_cached > 0) | 1268 | if (playlist->num_cached > 0) |
1269 | register_ata_idle_func(playlist_flush_callback); | 1269 | register_storage_idle_func(playlist_flush_callback); |
1270 | } | 1270 | } |
1271 | 1271 | ||
1272 | if (!dirty_pointers) | 1272 | if (!dirty_pointers) |
diff --git a/apps/plugin.c b/apps/plugin.c index 86e5c51128..e46e193129 100644 --- a/apps/plugin.c +++ b/apps/plugin.c | |||
@@ -38,6 +38,7 @@ | |||
38 | #include "option_select.h" | 38 | #include "option_select.h" |
39 | #include "talk.h" | 39 | #include "talk.h" |
40 | #include "version.h" | 40 | #include "version.h" |
41 | #include "storage.h" | ||
41 | 42 | ||
42 | #if CONFIG_CHARGING | 43 | #if CONFIG_CHARGING |
43 | #include "power.h" | 44 | #include "power.h" |
@@ -265,13 +266,13 @@ static const struct plugin_api rockbox_api = { | |||
265 | fdprintf, | 266 | fdprintf, |
266 | read_line, | 267 | read_line, |
267 | settings_parseline, | 268 | settings_parseline, |
268 | ata_sleep, | 269 | storage_sleep, |
269 | ata_spin, | 270 | storage_spin, |
270 | ata_spindown, | 271 | storage_spindown, |
271 | #if USING_ATA_CALLBACK | 272 | #if USING_STORAGE_CALLBACK |
272 | register_ata_idle_func, | 273 | register_storage_idle_func, |
273 | unregister_ata_idle_func, | 274 | unregister_storage_idle_func, |
274 | #endif /* USING_ATA_CALLBACK */ | 275 | #endif /* USING_STORAGE_CALLBACK */ |
275 | reload_directory, | 276 | reload_directory, |
276 | create_numbered_filename, | 277 | create_numbered_filename, |
277 | file_exists, | 278 | file_exists, |
diff --git a/apps/plugin.h b/apps/plugin.h index 08d0b603ac..464614dcf9 100644 --- a/apps/plugin.h +++ b/apps/plugin.h | |||
@@ -379,13 +379,13 @@ struct plugin_api { | |||
379 | int (*fdprintf)(int fd, const char *fmt, ...) ATTRIBUTE_PRINTF(2, 3); | 379 | int (*fdprintf)(int fd, const char *fmt, ...) ATTRIBUTE_PRINTF(2, 3); |
380 | int (*read_line)(int fd, char* buffer, int buffer_size); | 380 | int (*read_line)(int fd, char* buffer, int buffer_size); |
381 | bool (*settings_parseline)(char* line, char** name, char** value); | 381 | bool (*settings_parseline)(char* line, char** name, char** value); |
382 | void (*ata_sleep)(void); | 382 | void (*storage_sleep)(void); |
383 | void (*ata_spin)(void); | 383 | void (*storage_spin)(void); |
384 | void (*ata_spindown)(int seconds); | 384 | void (*storage_spindown)(int seconds); |
385 | #if USING_ATA_CALLBACK | 385 | #if USING_STORAGE_CALLBACK |
386 | void (*register_ata_idle_func)(ata_idle_notify function); | 386 | void (*register_storage_idle_func)(storage_idle_notify function); |
387 | void (*unregister_ata_idle_func)(ata_idle_notify function, bool run); | 387 | void (*unregister_storage_idle_func)(storage_idle_notify function, bool run); |
388 | #endif /* USING_ATA_CALLBACK */ | 388 | #endif /* USING_STORAGE_CALLBACK */ |
389 | void (*reload_directory)(void); | 389 | void (*reload_directory)(void); |
390 | char *(*create_numbered_filename)(char *buffer, const char *path, | 390 | char *(*create_numbered_filename)(char *buffer, const char *path, |
391 | const char *prefix, const char *suffix, | 391 | const char *prefix, const char *suffix, |
diff --git a/apps/plugins/battery_bench.c b/apps/plugins/battery_bench.c index ef4795a0e1..fff93b2a3a 100644 --- a/apps/plugins/battery_bench.c +++ b/apps/plugins/battery_bench.c | |||
@@ -344,7 +344,7 @@ void thread(void) | |||
344 | bat[buf_idx].flags = charge_state(); | 344 | bat[buf_idx].flags = charge_state(); |
345 | #endif | 345 | #endif |
346 | buf_idx++; | 346 | buf_idx++; |
347 | rb->register_ata_idle_func(flush_buffer); | 347 | rb->register_storage_idle_func(flush_buffer); |
348 | } | 348 | } |
349 | 349 | ||
350 | /* What to do when the measurement buffer is full: | 350 | /* What to do when the measurement buffer is full: |
@@ -386,7 +386,7 @@ void thread(void) | |||
386 | } | 386 | } |
387 | 387 | ||
388 | /* unregister flush callback and flush to disk */ | 388 | /* unregister flush callback and flush to disk */ |
389 | rb->unregister_ata_idle_func(flush_buffer, true); | 389 | rb->unregister_storage_idle_func(flush_buffer, true); |
390 | 390 | ||
391 | /* log end of bench and exit reason */ | 391 | /* log end of bench and exit reason */ |
392 | fd = rb->open(BATTERY_LOG, O_RDWR | O_CREAT | O_APPEND); | 392 | fd = rb->open(BATTERY_LOG, O_RDWR | O_CREAT | O_APPEND); |
diff --git a/apps/plugins/clock/clock_settings.c b/apps/plugins/clock/clock_settings.c index 44a6f164a7..1147055ce5 100644 --- a/apps/plugins/clock/clock_settings.c +++ b/apps/plugins/clock/clock_settings.c | |||
@@ -173,7 +173,7 @@ void load_settings(void){ | |||
173 | draw_message(display, MESSAGE_ERRLOAD, 1); | 173 | draw_message(display, MESSAGE_ERRLOAD, 1); |
174 | display->update(); | 174 | display->update(); |
175 | } | 175 | } |
176 | rb->ata_sleep(); | 176 | rb->storage_sleep(); |
177 | rb->sleep(HZ); | 177 | rb->sleep(HZ); |
178 | } | 178 | } |
179 | 179 | ||
diff --git a/apps/plugins/jpeg/jpeg.c b/apps/plugins/jpeg/jpeg.c index ed1b181e92..d8775dd176 100644 --- a/apps/plugins/jpeg/jpeg.c +++ b/apps/plugins/jpeg/jpeg.c | |||
@@ -438,14 +438,14 @@ int show_menu(void) /* return 1 to quit */ | |||
438 | #if !defined(SIMULATOR) && defined(HAVE_DISK_STORAGE) | 438 | #if !defined(SIMULATOR) && defined(HAVE_DISK_STORAGE) |
439 | /* change ata spindown time based on slideshow time setting */ | 439 | /* change ata spindown time based on slideshow time setting */ |
440 | immediate_ata_off = false; | 440 | immediate_ata_off = false; |
441 | rb->ata_spindown(rb->global_settings->disk_spindown); | 441 | rb->storage_spindown(rb->global_settings->disk_spindown); |
442 | 442 | ||
443 | if (slideshow_enabled) | 443 | if (slideshow_enabled) |
444 | { | 444 | { |
445 | if(jpeg_settings.ss_timeout < 10) | 445 | if(jpeg_settings.ss_timeout < 10) |
446 | { | 446 | { |
447 | /* slideshow times < 10s keep disk spinning */ | 447 | /* slideshow times < 10s keep disk spinning */ |
448 | rb->ata_spindown(0); | 448 | rb->storage_spindown(0); |
449 | } | 449 | } |
450 | else if (!rb->mp3_is_playing()) | 450 | else if (!rb->mp3_is_playing()) |
451 | { | 451 | { |
@@ -1057,7 +1057,7 @@ int load_and_show(char* filename) | |||
1057 | else if(immediate_ata_off) | 1057 | else if(immediate_ata_off) |
1058 | { | 1058 | { |
1059 | /* running slideshow and time is long enough: power down disk */ | 1059 | /* running slideshow and time is long enough: power down disk */ |
1060 | rb->ata_sleep(); | 1060 | rb->storage_sleep(); |
1061 | } | 1061 | } |
1062 | #endif | 1062 | #endif |
1063 | 1063 | ||
@@ -1259,7 +1259,7 @@ enum plugin_status plugin_start(const struct plugin_api* api, const void* parame | |||
1259 | 1259 | ||
1260 | #if !defined(SIMULATOR) && defined(HAVE_DISK_STORAGE) | 1260 | #if !defined(SIMULATOR) && defined(HAVE_DISK_STORAGE) |
1261 | /* set back ata spindown time in case we changed it */ | 1261 | /* set back ata spindown time in case we changed it */ |
1262 | rb->ata_spindown(rb->global_settings->disk_spindown); | 1262 | rb->storage_spindown(rb->global_settings->disk_spindown); |
1263 | #endif | 1263 | #endif |
1264 | 1264 | ||
1265 | /* Turn on backlight timeout (revert to settings) */ | 1265 | /* Turn on backlight timeout (revert to settings) */ |
diff --git a/apps/plugins/mpegplayer/disk_buf.c b/apps/plugins/mpegplayer/disk_buf.c index 7ba4025f1e..df5e005b50 100644 --- a/apps/plugins/mpegplayer/disk_buf.c +++ b/apps/plugins/mpegplayer/disk_buf.c | |||
@@ -171,7 +171,7 @@ static inline void disk_buf_buffer(void) | |||
171 | if (!stream_get_window(&sw)) | 171 | if (!stream_get_window(&sw)) |
172 | { | 172 | { |
173 | disk_buf.state = TSTATE_DATA; | 173 | disk_buf.state = TSTATE_DATA; |
174 | rb->ata_sleep(); | 174 | rb->storage_sleep(); |
175 | break; | 175 | break; |
176 | } | 176 | } |
177 | 177 | ||
@@ -186,7 +186,7 @@ static inline void disk_buf_buffer(void) | |||
186 | /* Free space is less than one page */ | 186 | /* Free space is less than one page */ |
187 | disk_buf.state = TSTATE_DATA; | 187 | disk_buf.state = TSTATE_DATA; |
188 | disk_buf.low_wm = DISK_BUF_LOW_WATERMARK; | 188 | disk_buf.low_wm = DISK_BUF_LOW_WATERMARK; |
189 | rb->ata_sleep(); | 189 | rb->storage_sleep(); |
190 | break; | 190 | break; |
191 | } | 191 | } |
192 | 192 | ||
@@ -208,7 +208,7 @@ static inline void disk_buf_buffer(void) | |||
208 | { | 208 | { |
209 | /* Error or end of stream */ | 209 | /* Error or end of stream */ |
210 | disk_buf.state = TSTATE_EOS; | 210 | disk_buf.state = TSTATE_EOS; |
211 | rb->ata_sleep(); | 211 | rb->storage_sleep(); |
212 | break; | 212 | break; |
213 | } | 213 | } |
214 | 214 | ||
diff --git a/apps/plugins/mpegplayer/stream_mgr.h b/apps/plugins/mpegplayer/stream_mgr.h index c94fa84089..e3ea9207e6 100644 --- a/apps/plugins/mpegplayer/stream_mgr.h +++ b/apps/plugins/mpegplayer/stream_mgr.h | |||
@@ -153,7 +153,7 @@ static inline bool stream_can_seek(void) | |||
153 | static inline void stream_keep_disk_active(void) | 153 | static inline void stream_keep_disk_active(void) |
154 | { | 154 | { |
155 | #ifdef HAVE_DISK_STORAGE | 155 | #ifdef HAVE_DISK_STORAGE |
156 | rb->ata_spin(); | 156 | rb->storage_spin(); |
157 | #endif | 157 | #endif |
158 | } | 158 | } |
159 | 159 | ||
diff --git a/apps/plugins/video.c b/apps/plugins/video.c index 6a380b8e3c..1ba2b89e37 100644 --- a/apps/plugins/video.c +++ b/apps/plugins/video.c | |||
@@ -661,7 +661,7 @@ int PlayTick(int fd) | |||
661 | #endif | 661 | #endif |
662 | ) | 662 | ) |
663 | { | 663 | { |
664 | rb->ata_sleep(); /* no point in leaving the disk run til timeout */ | 664 | rb->storage_sleep(); /* no point in leaving the disk run til timeout */ |
665 | gPlay.bDiskSleep = true; | 665 | gPlay.bDiskSleep = true; |
666 | } | 666 | } |
667 | 667 | ||
diff --git a/apps/plugins/wavplay.c b/apps/plugins/wavplay.c index c37b656d1c..dc0992abac 100644 --- a/apps/plugins/wavplay.c +++ b/apps/plugins/wavplay.c | |||
@@ -3598,7 +3598,7 @@ int play_file(char* filename) | |||
3598 | if (free_space <= 0) | 3598 | if (free_space <= 0) |
3599 | { | 3599 | { |
3600 | filling = false; | 3600 | filling = false; |
3601 | rb->ata_sleep(); | 3601 | rb->storage_sleep(); |
3602 | } | 3602 | } |
3603 | else | 3603 | else |
3604 | { | 3604 | { |
diff --git a/apps/recorder/pcm_record.c b/apps/recorder/pcm_record.c index da4e9b7255..dbbc6901ec 100644 --- a/apps/recorder/pcm_record.c +++ b/apps/recorder/pcm_record.c | |||
@@ -24,7 +24,7 @@ | |||
24 | #include "logf.h" | 24 | #include "logf.h" |
25 | #include "thread.h" | 25 | #include "thread.h" |
26 | #include <string.h> | 26 | #include <string.h> |
27 | #include "ata.h" | 27 | #include "storage.h" |
28 | #include "usb.h" | 28 | #include "usb.h" |
29 | #include "buffer.h" | 29 | #include "buffer.h" |
30 | #include "general.h" | 30 | #include "general.h" |
@@ -162,7 +162,7 @@ static bool pcm_buffer_empty; /* all pcm chunks processed? */ | |||
162 | static int low_watermark; /* Low watermark to stop flush */ | 162 | static int low_watermark; /* Low watermark to stop flush */ |
163 | static int high_watermark; /* max chunk limit for data flush */ | 163 | static int high_watermark; /* max chunk limit for data flush */ |
164 | static unsigned long spinup_time = 35*HZ/10; /* Fudged spinup time */ | 164 | static unsigned long spinup_time = 35*HZ/10; /* Fudged spinup time */ |
165 | static int last_ata_spinup_time = -1;/* previous spin time used */ | 165 | static int last_storage_spinup_time = -1;/* previous spin time used */ |
166 | #ifdef HAVE_PRIORITY_SCHEDULING | 166 | #ifdef HAVE_PRIORITY_SCHEDULING |
167 | static int flood_watermark; /* boost thread priority when here */ | 167 | static int flood_watermark; /* boost thread priority when here */ |
168 | #endif | 168 | #endif |
@@ -731,7 +731,7 @@ static void pcmrec_end_file(void) | |||
731 | */ | 731 | */ |
732 | static void pcmrec_refresh_watermarks(void) | 732 | static void pcmrec_refresh_watermarks(void) |
733 | { | 733 | { |
734 | logf("ata spinup: %d", ata_spinup_time); | 734 | logf("ata spinup: %d", storage_spinup_time()); |
735 | 735 | ||
736 | /* set the low mark for when flushing stops if automatic */ | 736 | /* set the low mark for when flushing stops if automatic */ |
737 | low_watermark = (LOW_SECONDS*4*sample_rate + (enc_chunk_size-1)) | 737 | low_watermark = (LOW_SECONDS*4*sample_rate + (enc_chunk_size-1)) |
@@ -755,7 +755,7 @@ static void pcmrec_refresh_watermarks(void) | |||
755 | 755 | ||
756 | logf("flood at: %d", flood_watermark); | 756 | logf("flood at: %d", flood_watermark); |
757 | #endif | 757 | #endif |
758 | spinup_time = last_ata_spinup_time = ata_spinup_time; | 758 | spinup_time = last_storage_spinup_time = storage_spinup_time(); |
759 | 759 | ||
760 | /* write at 8s + st remaining in enc_buffer - range 12s to | 760 | /* write at 8s + st remaining in enc_buffer - range 12s to |
761 | 20s total - default to 3.5s spinup. */ | 761 | 20s total - default to 3.5s spinup. */ |
@@ -816,7 +816,7 @@ static void pcmrec_flush(unsigned flush_num) | |||
816 | if (!is_recording) | 816 | if (!is_recording) |
817 | return; | 817 | return; |
818 | 818 | ||
819 | if (ata_spinup_time != last_ata_spinup_time) | 819 | if (storage_spinup_time() != last_storage_spinup_time) |
820 | pcmrec_refresh_watermarks(); | 820 | pcmrec_refresh_watermarks(); |
821 | 821 | ||
822 | /* enough available? no? then leave */ | 822 | /* enough available? no? then leave */ |
diff --git a/apps/recorder/peakmeter.c b/apps/recorder/peakmeter.c index ce0974a084..422b138020 100644 --- a/apps/recorder/peakmeter.c +++ b/apps/recorder/peakmeter.c | |||
@@ -26,7 +26,7 @@ | |||
26 | #include "thread.h" | 26 | #include "thread.h" |
27 | #include "kernel.h" | 27 | #include "kernel.h" |
28 | #include "settings.h" | 28 | #include "settings.h" |
29 | #include "ata.h" | 29 | #include "storage.h" |
30 | #include "lcd.h" | 30 | #include "lcd.h" |
31 | #include "scrollbar.h" | 31 | #include "scrollbar.h" |
32 | #include "gwps.h" | 32 | #include "gwps.h" |
@@ -1343,7 +1343,7 @@ int peak_meter_draw_get_btn(int action_context, int x[], int y[], | |||
1343 | * is active, it must not draw too much CPU power or a buffer overrun can | 1343 | * is active, it must not draw too much CPU power or a buffer overrun can |
1344 | * happen when saving a recording. As a compromise, poll only once per tick | 1344 | * happen when saving a recording. As a compromise, poll only once per tick |
1345 | * when the disk is active, otherwise spin around as fast as possible. */ | 1345 | * when the disk is active, otherwise spin around as fast as possible. */ |
1346 | bool highperf = !ata_disk_is_active(); | 1346 | bool highperf = !storage_disk_is_active(); |
1347 | #endif | 1347 | #endif |
1348 | bool dopeek = true; | 1348 | bool dopeek = true; |
1349 | 1349 | ||
diff --git a/apps/recorder/recording.c b/apps/recorder/recording.c index d29db390c7..5a2aa096db 100644 --- a/apps/recorder/recording.c +++ b/apps/recorder/recording.c | |||
@@ -65,7 +65,7 @@ | |||
65 | #include "errno.h" | 65 | #include "errno.h" |
66 | #include "talk.h" | 66 | #include "talk.h" |
67 | #include "sound.h" | 67 | #include "sound.h" |
68 | #include "ata.h" | 68 | #include "storage.h" |
69 | #include "splash.h" | 69 | #include "splash.h" |
70 | #include "screen_access.h" | 70 | #include "screen_access.h" |
71 | #include "action.h" | 71 | #include "action.h" |
@@ -298,7 +298,7 @@ static bool read_peak_levels(int *peak_l, int *peak_r, int *balance) | |||
298 | peak_valid_mem[peak_time % 3] = *peak_l; | 298 | peak_valid_mem[peak_time % 3] = *peak_l; |
299 | if (((peak_valid_mem[0] == peak_valid_mem[1]) && | 299 | if (((peak_valid_mem[0] == peak_valid_mem[1]) && |
300 | (peak_valid_mem[1] == peak_valid_mem[2])) && | 300 | (peak_valid_mem[1] == peak_valid_mem[2])) && |
301 | ((*peak_l < 32767) || ata_disk_is_active())) | 301 | ((*peak_l < 32767) || storage_disk_is_active())) |
302 | return false; | 302 | return false; |
303 | 303 | ||
304 | if (*peak_r > *peak_l) | 304 | if (*peak_r > *peak_l) |
@@ -1034,7 +1034,7 @@ bool recording_screen(bool no_source) | |||
1034 | rec_status = RCSTAT_IN_RECSCREEN; | 1034 | rec_status = RCSTAT_IN_RECSCREEN; |
1035 | 1035 | ||
1036 | #if (CONFIG_LED == LED_REAL) && !defined(SIMULATOR) | 1036 | #if (CONFIG_LED == LED_REAL) && !defined(SIMULATOR) |
1037 | ata_set_led_enabled(false); | 1037 | storage_set_led_enabled(false); |
1038 | #endif | 1038 | #endif |
1039 | 1039 | ||
1040 | #if CONFIG_CODEC == SWCODEC | 1040 | #if CONFIG_CODEC == SWCODEC |
@@ -1905,7 +1905,7 @@ rec_abort: | |||
1905 | reload_directory(); | 1905 | reload_directory(); |
1906 | 1906 | ||
1907 | #if (CONFIG_LED == LED_REAL) && !defined(SIMULATOR) | 1907 | #if (CONFIG_LED == LED_REAL) && !defined(SIMULATOR) |
1908 | ata_set_led_enabled(true); | 1908 | storage_set_led_enabled(true); |
1909 | #endif | 1909 | #endif |
1910 | 1910 | ||
1911 | #if CONFIG_TUNER | 1911 | #if CONFIG_TUNER |
diff --git a/apps/scrobbler.c b/apps/scrobbler.c index acf1e9e4b0..b0f65158e8 100644 --- a/apps/scrobbler.c +++ b/apps/scrobbler.c | |||
@@ -180,7 +180,7 @@ static void add_to_cache(unsigned long play_length) | |||
180 | logf("SCROBBLER: %s", scrobbler_entry.path); | 180 | logf("SCROBBLER: %s", scrobbler_entry.path); |
181 | } else { | 181 | } else { |
182 | cache_pos++; | 182 | cache_pos++; |
183 | register_ata_idle_func(scrobbler_flush_callback); | 183 | register_storage_idle_func(scrobbler_flush_callback); |
184 | } | 184 | } |
185 | 185 | ||
186 | } | 186 | } |
diff --git a/apps/settings.c b/apps/settings.c index 709e05e086..e15bfc8638 100644 --- a/apps/settings.c +++ b/apps/settings.c | |||
@@ -38,6 +38,7 @@ | |||
38 | #include "rtc.h" | 38 | #include "rtc.h" |
39 | #include "power.h" | 39 | #include "power.h" |
40 | #include "ata_idle_notify.h" | 40 | #include "ata_idle_notify.h" |
41 | #include "storage.h" | ||
41 | #include "screens.h" | 42 | #include "screens.h" |
42 | #include "ctype.h" | 43 | #include "ctype.h" |
43 | #include "file.h" | 44 | #include "file.h" |
@@ -582,11 +583,11 @@ void status_save(void) | |||
582 | { | 583 | { |
583 | update_runtime(); | 584 | update_runtime(); |
584 | #ifdef HAVE_RTC_RAM | 585 | #ifdef HAVE_RTC_RAM |
585 | /* this will be done in the ata_callback if | 586 | /* this will be done in the storage_callback if |
586 | target doesnt have rtc ram */ | 587 | target doesnt have rtc ram */ |
587 | write_nvram_data(nvram_buffer,NVRAM_BLOCK_SIZE); | 588 | write_nvram_data(nvram_buffer,NVRAM_BLOCK_SIZE); |
588 | #else | 589 | #else |
589 | register_ata_idle_func(flush_global_status_callback); | 590 | register_storage_idle_func(flush_global_status_callback); |
590 | #endif | 591 | #endif |
591 | } | 592 | } |
592 | 593 | ||
@@ -594,11 +595,11 @@ int settings_save(void) | |||
594 | { | 595 | { |
595 | update_runtime(); | 596 | update_runtime(); |
596 | #ifdef HAVE_RTC_RAM | 597 | #ifdef HAVE_RTC_RAM |
597 | /* this will be done in the ata_callback if | 598 | /* this will be done in the storage_callback if |
598 | target doesnt have rtc ram */ | 599 | target doesnt have rtc ram */ |
599 | write_nvram_data(nvram_buffer,NVRAM_BLOCK_SIZE); | 600 | write_nvram_data(nvram_buffer,NVRAM_BLOCK_SIZE); |
600 | #endif | 601 | #endif |
601 | register_ata_idle_func(flush_config_block_callback); | 602 | register_storage_idle_func(flush_config_block_callback); |
602 | return 0; | 603 | return 0; |
603 | } | 604 | } |
604 | 605 | ||
@@ -768,7 +769,7 @@ void settings_apply(bool read_disk) | |||
768 | buttonlight_set_timeout(global_settings.buttonlight_timeout); | 769 | buttonlight_set_timeout(global_settings.buttonlight_timeout); |
769 | #endif | 770 | #endif |
770 | #ifdef HAVE_DISK_STORAGE | 771 | #ifdef HAVE_DISK_STORAGE |
771 | ata_spindown(global_settings.disk_spindown); | 772 | storage_spindown(global_settings.disk_spindown); |
772 | #endif | 773 | #endif |
773 | #if (CONFIG_CODEC == MAS3507D) && !defined(SIMULATOR) | 774 | #if (CONFIG_CODEC == MAS3507D) && !defined(SIMULATOR) |
774 | dac_line_in(global_settings.line_in); | 775 | dac_line_in(global_settings.line_in); |
diff --git a/apps/settings_list.c b/apps/settings_list.c index 7f870b442e..3eeeffd8fd 100644 --- a/apps/settings_list.c +++ b/apps/settings_list.c | |||
@@ -23,7 +23,7 @@ | |||
23 | #include <stdbool.h> | 23 | #include <stdbool.h> |
24 | #include <string.h> | 24 | #include <string.h> |
25 | #include "system.h" | 25 | #include "system.h" |
26 | #include "ata.h" | 26 | #include "storage.h" |
27 | #include "lang.h" | 27 | #include "lang.h" |
28 | #include "talk.h" | 28 | #include "talk.h" |
29 | #include "lcd.h" | 29 | #include "lcd.h" |
@@ -714,7 +714,7 @@ const struct settings_list settings[] = { | |||
714 | /* disk */ | 714 | /* disk */ |
715 | #ifdef HAVE_DISK_STORAGE | 715 | #ifdef HAVE_DISK_STORAGE |
716 | INT_SETTING(0, disk_spindown, LANG_SPINDOWN, 5, "disk spindown", | 716 | INT_SETTING(0, disk_spindown, LANG_SPINDOWN, 5, "disk spindown", |
717 | UNIT_SEC, 3, 254, 1, NULL, NULL, ata_spindown), | 717 | UNIT_SEC, 3, 254, 1, NULL, NULL, storage_spindown), |
718 | #endif /* HAVE_DISK_STORAGE */ | 718 | #endif /* HAVE_DISK_STORAGE */ |
719 | /* browser */ | 719 | /* browser */ |
720 | CHOICE_SETTING(0, dirfilter, LANG_FILTER, SHOW_SUPPORTED, "show files", | 720 | CHOICE_SETTING(0, dirfilter, LANG_FILTER, SHOW_SUPPORTED, "show files", |
diff --git a/apps/tagcache.c b/apps/tagcache.c index 19469cde1a..b6cfcd5ef5 100644 --- a/apps/tagcache.c +++ b/apps/tagcache.c | |||
@@ -3094,7 +3094,7 @@ static void run_command_queue(bool force) | |||
3094 | if (force || command_queue_is_full()) | 3094 | if (force || command_queue_is_full()) |
3095 | command_queue_sync_callback(); | 3095 | command_queue_sync_callback(); |
3096 | else | 3096 | else |
3097 | register_ata_idle_func(command_queue_sync_callback); | 3097 | register_storage_idle_func(command_queue_sync_callback); |
3098 | } | 3098 | } |
3099 | 3099 | ||
3100 | static void queue_command(int cmd, long idx_id, int tag, long data) | 3100 | static void queue_command(int cmd, long idx_id, int tag, long data) |
diff --git a/apps/tagtree.c b/apps/tagtree.c index 7b05391640..7777a9f16d 100644 --- a/apps/tagtree.c +++ b/apps/tagtree.c | |||
@@ -48,6 +48,7 @@ | |||
48 | #include "filetypes.h" | 48 | #include "filetypes.h" |
49 | #include "audio.h" | 49 | #include "audio.h" |
50 | #include "appevents.h" | 50 | #include "appevents.h" |
51 | #include "storage.h" | ||
51 | 52 | ||
52 | #define FILE_SEARCH_INSTRUCTIONS ROCKBOX_DIR "/tagnavi.config" | 53 | #define FILE_SEARCH_INSTRUCTIONS ROCKBOX_DIR "/tagnavi.config" |
53 | 54 | ||
@@ -1057,7 +1058,7 @@ static int retrieve_entries(struct tree_context *c, struct tagcache_search *tcs, | |||
1057 | otherwise show it after the normal 1/2 second delay */ | 1058 | otherwise show it after the normal 1/2 second delay */ |
1058 | show_search_progress( | 1059 | show_search_progress( |
1059 | #ifdef HAVE_DISK_STORAGE | 1060 | #ifdef HAVE_DISK_STORAGE |
1060 | ata_disk_is_active() | 1061 | storage_disk_is_active() |
1061 | #else | 1062 | #else |
1062 | true | 1063 | true |
1063 | #endif | 1064 | #endif |
diff --git a/apps/tree.c b/apps/tree.c index 768223ec4d..dbc47e31b6 100644 --- a/apps/tree.c +++ b/apps/tree.c | |||
@@ -41,7 +41,7 @@ | |||
41 | #include "settings.h" | 41 | #include "settings.h" |
42 | #include "status.h" | 42 | #include "status.h" |
43 | #include "debug.h" | 43 | #include "debug.h" |
44 | #include "ata.h" | 44 | #include "storage.h" |
45 | #include "rolo.h" | 45 | #include "rolo.h" |
46 | #include "icons.h" | 46 | #include "icons.h" |
47 | #include "lang.h" | 47 | #include "lang.h" |
@@ -828,7 +828,7 @@ static int dirbrowse() | |||
828 | return GO_TO_WPS; | 828 | return GO_TO_WPS; |
829 | if (button) | 829 | if (button) |
830 | { | 830 | { |
831 | ata_spin(); | 831 | storage_spin(); |
832 | } | 832 | } |
833 | 833 | ||
834 | 834 | ||
diff --git a/bootloader/creativezvm.c b/bootloader/creativezvm.c index bd8050b22a..403a8bbdc4 100644 --- a/bootloader/creativezvm.c +++ b/bootloader/creativezvm.c | |||
@@ -21,7 +21,7 @@ | |||
21 | #include "lcd.h" | 21 | #include "lcd.h" |
22 | #include "kernel.h" | 22 | #include "kernel.h" |
23 | #include "thread.h" | 23 | #include "thread.h" |
24 | #include "ata.h" | 24 | #include "storage.h" |
25 | #include "ata-target.h" | 25 | #include "ata-target.h" |
26 | #include "disk.h" | 26 | #include "disk.h" |
27 | #include "font.h" | 27 | #include "font.h" |
@@ -64,7 +64,7 @@ void main(void) | |||
64 | printf("Rockbox boot loader"); | 64 | printf("Rockbox boot loader"); |
65 | printf("Version %s", APPSVERSION); | 65 | printf("Version %s", APPSVERSION); |
66 | 66 | ||
67 | ret = ata_init(); | 67 | ret = storage_init(); |
68 | if(ret) | 68 | if(ret) |
69 | printf("ATA error: %d", ret); | 69 | printf("ATA error: %d", ret); |
70 | 70 | ||
diff --git a/bootloader/gigabeat-s.c b/bootloader/gigabeat-s.c index 089d0f7890..e1e293fb55 100644 --- a/bootloader/gigabeat-s.c +++ b/bootloader/gigabeat-s.c | |||
@@ -25,7 +25,7 @@ | |||
25 | #include "string.h" | 25 | #include "string.h" |
26 | #include "adc.h" | 26 | #include "adc.h" |
27 | #include "powermgmt.h" | 27 | #include "powermgmt.h" |
28 | #include "ata.h" | 28 | #include "storage.h" |
29 | #include "dir.h" | 29 | #include "dir.h" |
30 | #include "disk.h" | 30 | #include "disk.h" |
31 | #include "common.h" | 31 | #include "common.h" |
@@ -81,7 +81,7 @@ static bool pause_if_button_pressed(bool pre_usb) | |||
81 | sleep(HZ/5); | 81 | sleep(HZ/5); |
82 | 82 | ||
83 | /* If the disk powers off, the firmware will lock at startup */ | 83 | /* If the disk powers off, the firmware will lock at startup */ |
84 | ata_spin(); | 84 | storage_spin(); |
85 | } | 85 | } |
86 | } | 86 | } |
87 | 87 | ||
@@ -310,7 +310,7 @@ static void __attribute__((noreturn)) handle_firmware_load(void) | |||
310 | 310 | ||
311 | /* Put drivers into a known state */ | 311 | /* Put drivers into a known state */ |
312 | button_close_device(); | 312 | button_close_device(); |
313 | ata_close(); | 313 | storage_close(); |
314 | system_prepare_fw_start(); | 314 | system_prepare_fw_start(); |
315 | 315 | ||
316 | if (rc == EOK) | 316 | if (rc == EOK) |
@@ -353,7 +353,7 @@ void main(void) | |||
353 | 353 | ||
354 | check_battery(); | 354 | check_battery(); |
355 | 355 | ||
356 | rc = ata_init(); | 356 | rc = storage_init(); |
357 | if(rc) | 357 | if(rc) |
358 | { | 358 | { |
359 | reset_screen(); | 359 | reset_screen(); |
diff --git a/bootloader/gigabeat.c b/bootloader/gigabeat.c index 117dacc2b2..6b3a68be6e 100644 --- a/bootloader/gigabeat.c +++ b/bootloader/gigabeat.c | |||
@@ -29,7 +29,7 @@ | |||
29 | #include "lcd.h" | 29 | #include "lcd.h" |
30 | #include "kernel.h" | 30 | #include "kernel.h" |
31 | #include "thread.h" | 31 | #include "thread.h" |
32 | #include "ata.h" | 32 | #include "storage.h" |
33 | #include "fat.h" | 33 | #include "fat.h" |
34 | #include "disk.h" | 34 | #include "disk.h" |
35 | #include "font.h" | 35 | #include "font.h" |
@@ -75,7 +75,7 @@ void main(void) | |||
75 | (LCD_HEIGHT - SYSFONT_HEIGHT) / 2, msg); | 75 | (LCD_HEIGHT - SYSFONT_HEIGHT) / 2, msg); |
76 | lcd_update(); | 76 | lcd_update(); |
77 | 77 | ||
78 | ata_enable(false); | 78 | storage_enable(false); |
79 | sleep(HZ/20); | 79 | sleep(HZ/20); |
80 | usb_enable(true); | 80 | usb_enable(true); |
81 | 81 | ||
@@ -101,7 +101,7 @@ void main(void) | |||
101 | 101 | ||
102 | sleep(50); /* ATA seems to error without this pause */ | 102 | sleep(50); /* ATA seems to error without this pause */ |
103 | 103 | ||
104 | rc = ata_init(); | 104 | rc = storage_init(); |
105 | if(rc) | 105 | if(rc) |
106 | { | 106 | { |
107 | reset_screen(); | 107 | reset_screen(); |
diff --git a/bootloader/iaudio_coldfire.c b/bootloader/iaudio_coldfire.c index 8e85dc9deb..0af2f25256 100644 --- a/bootloader/iaudio_coldfire.c +++ b/bootloader/iaudio_coldfire.c | |||
@@ -30,7 +30,7 @@ | |||
30 | #include "lcd-remote.h" | 30 | #include "lcd-remote.h" |
31 | #include "kernel.h" | 31 | #include "kernel.h" |
32 | #include "thread.h" | 32 | #include "thread.h" |
33 | #include "ata.h" | 33 | #include "storage.h" |
34 | #include "usb.h" | 34 | #include "usb.h" |
35 | #include "disk.h" | 35 | #include "disk.h" |
36 | #include "font.h" | 36 | #include "font.h" |
@@ -87,10 +87,10 @@ void shutdown(void) | |||
87 | if (ide_powered()) | 87 | if (ide_powered()) |
88 | { | 88 | { |
89 | /* Make sure ATA has been initialized. */ | 89 | /* Make sure ATA has been initialized. */ |
90 | ata_init(); | 90 | storage_init(); |
91 | 91 | ||
92 | /* And put the disk into sleep immediately. */ | 92 | /* And put the disk into sleep immediately. */ |
93 | ata_sleepnow(); | 93 | storage_sleepnow(); |
94 | } | 94 | } |
95 | 95 | ||
96 | sleep(HZ*2); | 96 | sleep(HZ*2); |
@@ -192,7 +192,7 @@ void main(void) | |||
192 | 192 | ||
193 | check_battery(); | 193 | check_battery(); |
194 | 194 | ||
195 | rc = ata_init(); | 195 | rc = storage_init(); |
196 | if(rc) | 196 | if(rc) |
197 | { | 197 | { |
198 | printf("ATA error: %d", rc); | 198 | printf("ATA error: %d", rc); |
diff --git a/bootloader/iriver_h1x0.c b/bootloader/iriver_h1x0.c index 7f051bccb5..83e545540b 100644 --- a/bootloader/iriver_h1x0.c +++ b/bootloader/iriver_h1x0.c | |||
@@ -31,7 +31,7 @@ | |||
31 | #include "scroll_engine.h" | 31 | #include "scroll_engine.h" |
32 | #include "kernel.h" | 32 | #include "kernel.h" |
33 | #include "thread.h" | 33 | #include "thread.h" |
34 | #include "ata.h" | 34 | #include "storage.h" |
35 | #include "usb.h" | 35 | #include "usb.h" |
36 | #include "disk.h" | 36 | #include "disk.h" |
37 | #include "font.h" | 37 | #include "font.h" |
@@ -148,10 +148,10 @@ void shutdown(void) | |||
148 | if (ide_powered()) | 148 | if (ide_powered()) |
149 | { | 149 | { |
150 | /* Make sure ATA has been initialized. */ | 150 | /* Make sure ATA has been initialized. */ |
151 | ata_init(); | 151 | storage_init(); |
152 | 152 | ||
153 | /* And put the disk into sleep immediately. */ | 153 | /* And put the disk into sleep immediately. */ |
154 | ata_sleepnow(); | 154 | storage_sleepnow(); |
155 | } | 155 | } |
156 | 156 | ||
157 | sleep(HZ*2); | 157 | sleep(HZ*2); |
@@ -560,7 +560,7 @@ void main(void) | |||
560 | } | 560 | } |
561 | #endif | 561 | #endif |
562 | ide_power_enable(true); | 562 | ide_power_enable(true); |
563 | ata_enable(false); | 563 | storage_enable(false); |
564 | sleep(HZ/20); | 564 | sleep(HZ/20); |
565 | usb_enable(true); | 565 | usb_enable(true); |
566 | cpu_idle_mode(true); | 566 | cpu_idle_mode(true); |
@@ -571,7 +571,7 @@ void main(void) | |||
571 | remote_line = 0; | 571 | remote_line = 0; |
572 | check_battery(); | 572 | check_battery(); |
573 | 573 | ||
574 | ata_spin(); /* Prevent the drive from spinning down */ | 574 | storage_spin(); /* Prevent the drive from spinning down */ |
575 | sleep(HZ); | 575 | sleep(HZ); |
576 | 576 | ||
577 | /* Backlight OFF */ | 577 | /* Backlight OFF */ |
@@ -585,7 +585,7 @@ void main(void) | |||
585 | lcd_update(); | 585 | lcd_update(); |
586 | } | 586 | } |
587 | 587 | ||
588 | rc = ata_init(); | 588 | rc = storage_init(); |
589 | if(rc) | 589 | if(rc) |
590 | { | 590 | { |
591 | reset_screen(); | 591 | reset_screen(); |
diff --git a/bootloader/iriver_h300.c b/bootloader/iriver_h300.c index 9d839aed29..d15efb9b72 100644 --- a/bootloader/iriver_h300.c +++ b/bootloader/iriver_h300.c | |||
@@ -31,7 +31,7 @@ | |||
31 | #include "scroll_engine.h" | 31 | #include "scroll_engine.h" |
32 | #include "kernel.h" | 32 | #include "kernel.h" |
33 | #include "thread.h" | 33 | #include "thread.h" |
34 | #include "ata.h" | 34 | #include "storage.h" |
35 | #include "usb.h" | 35 | #include "usb.h" |
36 | #include "disk.h" | 36 | #include "disk.h" |
37 | #include "font.h" | 37 | #include "font.h" |
@@ -93,10 +93,10 @@ void shutdown(void) | |||
93 | if (ide_powered()) | 93 | if (ide_powered()) |
94 | { | 94 | { |
95 | /* Make sure ATA has been initialized. */ | 95 | /* Make sure ATA has been initialized. */ |
96 | ata_init(); | 96 | storage_init(); |
97 | 97 | ||
98 | /* And put the disk into sleep immediately. */ | 98 | /* And put the disk into sleep immediately. */ |
99 | ata_sleepnow(); | 99 | storage_sleepnow(); |
100 | } | 100 | } |
101 | 101 | ||
102 | sleep(HZ*2); | 102 | sleep(HZ*2); |
@@ -317,7 +317,7 @@ void main(void) | |||
317 | lcd_remote_update(); | 317 | lcd_remote_update(); |
318 | 318 | ||
319 | ide_power_enable(true); | 319 | ide_power_enable(true); |
320 | ata_enable(false); | 320 | storage_enable(false); |
321 | sleep(HZ/20); | 321 | sleep(HZ/20); |
322 | usb_enable(true); | 322 | usb_enable(true); |
323 | cpu_idle_mode(true); | 323 | cpu_idle_mode(true); |
@@ -328,7 +328,7 @@ void main(void) | |||
328 | remote_line = 0; | 328 | remote_line = 0; |
329 | check_battery(); | 329 | check_battery(); |
330 | 330 | ||
331 | ata_spin(); /* Prevent the drive from spinning down */ | 331 | storage_spin(); /* Prevent the drive from spinning down */ |
332 | sleep(HZ); | 332 | sleep(HZ); |
333 | } | 333 | } |
334 | 334 | ||
@@ -339,7 +339,7 @@ void main(void) | |||
339 | lcd_update(); | 339 | lcd_update(); |
340 | } | 340 | } |
341 | 341 | ||
342 | rc = ata_init(); | 342 | rc = storage_init(); |
343 | if(rc) | 343 | if(rc) |
344 | { | 344 | { |
345 | reset_screen(); | 345 | reset_screen(); |
diff --git a/bootloader/main-c240wipe.c b/bootloader/main-c240wipe.c index 1bf3ac21a3..952382eb5b 100644 --- a/bootloader/main-c240wipe.c +++ b/bootloader/main-c240wipe.c | |||
@@ -29,7 +29,7 @@ | |||
29 | #include "kernel.h" | 29 | #include "kernel.h" |
30 | #include "lcd.h" | 30 | #include "lcd.h" |
31 | #include "font.h" | 31 | #include "font.h" |
32 | #include "ata.h" | 32 | #include "storage.h" |
33 | #include "button.h" | 33 | #include "button.h" |
34 | #include "disk.h" | 34 | #include "disk.h" |
35 | #include "crc32-mi4.h" | 35 | #include "crc32-mi4.h" |
@@ -185,14 +185,14 @@ void* main(void) | |||
185 | printf(""); | 185 | printf(""); |
186 | 186 | ||
187 | 187 | ||
188 | i=ata_init(); | 188 | i=storage_init(); |
189 | disk_init(IF_MV(0)); | 189 | disk_init(IF_MV(0)); |
190 | 190 | ||
191 | memset(zero,0,16*1024); | 191 | memset(zero,0,16*1024); |
192 | printf("Zeroing flash"); | 192 | printf("Zeroing flash"); |
193 | for(i=0;i<250816;i++) | 193 | for(i=0;i<250816;i++) |
194 | { | 194 | { |
195 | ata_write_sectors(IF_MV2(0,) i*32,32,zero); | 195 | storage_write_sectors(IF_MV2(0,) i*32,32,zero); |
196 | if(i%64 == 0) | 196 | if(i%64 == 0) |
197 | { | 197 | { |
198 | printf("%d kB left",(250816-i)/2); | 198 | printf("%d kB left",(250816-i)/2); |
@@ -200,13 +200,13 @@ void* main(void) | |||
200 | } | 200 | } |
201 | 201 | ||
202 | printf("Writing MBR"); | 202 | printf("Writing MBR"); |
203 | ata_write_sectors(IF_MV2(0,) 0,1,mbr); | 203 | storage_write_sectors(IF_MV2(0,) 0,1,mbr); |
204 | printf("Writing FAT bootsector"); | 204 | printf("Writing FAT bootsector"); |
205 | ata_write_sectors(IF_MV2(0,) 1023,1,fat); | 205 | storage_write_sectors(IF_MV2(0,) 1023,1,fat); |
206 | printf("Writing more FAT"); | 206 | printf("Writing more FAT"); |
207 | ata_write_sectors(IF_MV2(0,) 1024,1,backupfat); | 207 | storage_write_sectors(IF_MV2(0,) 1024,1,backupfat); |
208 | printf("Writing more FAT"); | 208 | printf("Writing more FAT"); |
209 | ata_write_sectors(IF_MV2(0,) 1264,1,backupfat); | 209 | storage_write_sectors(IF_MV2(0,) 1264,1,backupfat); |
210 | if (button_hold()) | 210 | if (button_hold()) |
211 | printf("Release Hold and"); | 211 | printf("Release Hold and"); |
212 | 212 | ||
diff --git a/bootloader/main-c250wipe.c b/bootloader/main-c250wipe.c index fedabb7275..06a0a5b2b5 100644 --- a/bootloader/main-c250wipe.c +++ b/bootloader/main-c250wipe.c | |||
@@ -29,7 +29,7 @@ | |||
29 | #include "kernel.h" | 29 | #include "kernel.h" |
30 | #include "lcd.h" | 30 | #include "lcd.h" |
31 | #include "font.h" | 31 | #include "font.h" |
32 | #include "ata.h" | 32 | #include "storage.h" |
33 | #include "button.h" | 33 | #include "button.h" |
34 | #include "disk.h" | 34 | #include "disk.h" |
35 | #include "crc32-mi4.h" | 35 | #include "crc32-mi4.h" |
@@ -250,14 +250,14 @@ void* main(void) | |||
250 | printf(""); | 250 | printf(""); |
251 | 251 | ||
252 | 252 | ||
253 | i=ata_init(); | 253 | i=storage_init(); |
254 | disk_init(IF_MV(0)); | 254 | disk_init(IF_MV(0)); |
255 | 255 | ||
256 | memset(zero,0,16*1024); | 256 | memset(zero,0,16*1024); |
257 | printf("Zeroing flash"); | 257 | printf("Zeroing flash"); |
258 | for(i=0;i<250816;i++) | 258 | for(i=0;i<250816;i++) |
259 | { | 259 | { |
260 | ata_write_sectors(IF_MV2(0,) i*32,32,zero); | 260 | storage_write_sectors(IF_MV2(0,) i*32,32,zero); |
261 | if(i%64 == 0) | 261 | if(i%64 == 0) |
262 | { | 262 | { |
263 | printf("%d kB left",(250816-i)/2); | 263 | printf("%d kB left",(250816-i)/2); |
@@ -265,15 +265,15 @@ void* main(void) | |||
265 | } | 265 | } |
266 | 266 | ||
267 | printf("Writing MBR"); | 267 | printf("Writing MBR"); |
268 | ata_write_sectors(IF_MV2(0,) 0,1,mbr); | 268 | storage_write_sectors(IF_MV2(0,) 0,1,mbr); |
269 | printf("Writing FAT bootsector"); | 269 | printf("Writing FAT bootsector"); |
270 | ata_write_sectors(IF_MV2(0,) 1017,2,bootsector); | 270 | storage_write_sectors(IF_MV2(0,) 1017,2,bootsector); |
271 | printf("Writing more FAT"); | 271 | printf("Writing more FAT"); |
272 | ata_write_sectors(IF_MV2(0,) 1023,1,fat); | 272 | storage_write_sectors(IF_MV2(0,) 1023,1,fat); |
273 | printf("Writing more FAT"); | 273 | printf("Writing more FAT"); |
274 | ata_write_sectors(IF_MV2(0,) 1049,1,backupfat); | 274 | storage_write_sectors(IF_MV2(0,) 1049,1,backupfat); |
275 | printf("Writing more FAT"); | 275 | printf("Writing more FAT"); |
276 | ata_write_sectors(IF_MV2(0,) 4920,1,backupfat); | 276 | storage_write_sectors(IF_MV2(0,) 4920,1,backupfat); |
277 | if (button_hold()) | 277 | if (button_hold()) |
278 | printf("Release Hold and"); | 278 | printf("Release Hold and"); |
279 | 279 | ||
diff --git a/bootloader/main-e200r-installer.c b/bootloader/main-e200r-installer.c index b1209e1692..3ac57432a3 100644 --- a/bootloader/main-e200r-installer.c +++ b/bootloader/main-e200r-installer.c | |||
@@ -31,7 +31,7 @@ | |||
31 | #include "kernel.h" | 31 | #include "kernel.h" |
32 | #include "lcd.h" | 32 | #include "lcd.h" |
33 | #include "font.h" | 33 | #include "font.h" |
34 | #include "ata.h" | 34 | #include "storage.h" |
35 | #include "button.h" | 35 | #include "button.h" |
36 | #include "disk.h" | 36 | #include "disk.h" |
37 | #include "crc32-mi4.h" | 37 | #include "crc32-mi4.h" |
@@ -120,7 +120,7 @@ void* main(void) | |||
120 | printf(MODEL_NAME); | 120 | printf(MODEL_NAME); |
121 | printf(""); | 121 | printf(""); |
122 | 122 | ||
123 | i=ata_init(); | 123 | i=storage_init(); |
124 | disk_init(IF_MV(0)); | 124 | disk_init(IF_MV(0)); |
125 | num_partitions = disk_mount_all(); | 125 | num_partitions = disk_mount_all(); |
126 | 126 | ||
@@ -139,7 +139,7 @@ void* main(void) | |||
139 | printf("reading: %x", (START_SECTOR_OF_ROM + ROMSECTOR_TO_HACK)*512); | 139 | printf("reading: %x", (START_SECTOR_OF_ROM + ROMSECTOR_TO_HACK)*512); |
140 | #endif | 140 | #endif |
141 | 141 | ||
142 | ata_read_sectors(IF_MV2(0,) | 142 | storage_read_sectors(IF_MV2(0,) |
143 | pinfo->start + START_SECTOR_OF_ROM + ROMSECTOR_TO_HACK, | 143 | pinfo->start + START_SECTOR_OF_ROM + ROMSECTOR_TO_HACK, |
144 | 1 , sector); | 144 | 1 , sector); |
145 | crc32 = chksum_crc32 (sector, 512); | 145 | crc32 = chksum_crc32 (sector, 512); |
@@ -161,7 +161,7 @@ void* main(void) | |||
161 | /* E200R bootloader detected - patch it */ | 161 | /* E200R bootloader detected - patch it */ |
162 | memcpy(§or[HACK_OFFSET], changedBytes, | 162 | memcpy(§or[HACK_OFFSET], changedBytes, |
163 | sizeof(changedBytes)/sizeof(*changedBytes)); | 163 | sizeof(changedBytes)/sizeof(*changedBytes)); |
164 | ata_write_sectors(IF_MV2(0,) | 164 | storage_write_sectors(IF_MV2(0,) |
165 | pinfo->start + START_SECTOR_OF_ROM + ROMSECTOR_TO_HACK, | 165 | pinfo->start + START_SECTOR_OF_ROM + ROMSECTOR_TO_HACK, |
166 | 1 , sector); | 166 | 1 , sector); |
167 | printf("Firmware unlocked"); | 167 | printf("Firmware unlocked"); |
diff --git a/bootloader/main-pp.c b/bootloader/main-pp.c index c1aad5ce11..09e1c23ed8 100644 --- a/bootloader/main-pp.c +++ b/bootloader/main-pp.c | |||
@@ -30,7 +30,7 @@ | |||
30 | #include "kernel.h" | 30 | #include "kernel.h" |
31 | #include "lcd.h" | 31 | #include "lcd.h" |
32 | #include "font.h" | 32 | #include "font.h" |
33 | #include "ata.h" | 33 | #include "storage.h" |
34 | #include "adc.h" | 34 | #include "adc.h" |
35 | #include "button.h" | 35 | #include "button.h" |
36 | #include "disk.h" | 36 | #include "disk.h" |
@@ -371,7 +371,7 @@ int load_mi4_part(unsigned char* buf, struct partinfo* pinfo, | |||
371 | unsigned long sum; | 371 | unsigned long sum; |
372 | 372 | ||
373 | /* Read header to find out how long the mi4 file is. */ | 373 | /* Read header to find out how long the mi4 file is. */ |
374 | ata_read_sectors(IF_MV2(0,) pinfo->start + PPMI_SECTOR_OFFSET, | 374 | storage_read_sectors(IF_MV2(0,) pinfo->start + PPMI_SECTOR_OFFSET, |
375 | PPMI_SECTORS, &ppmi_header); | 375 | PPMI_SECTORS, &ppmi_header); |
376 | 376 | ||
377 | /* The first four characters at 0x80000 (sector 1024) should be PPMI*/ | 377 | /* The first four characters at 0x80000 (sector 1024) should be PPMI*/ |
@@ -381,7 +381,7 @@ int load_mi4_part(unsigned char* buf, struct partinfo* pinfo, | |||
381 | printf("BL mi4 size: %x", ppmi_header.length); | 381 | printf("BL mi4 size: %x", ppmi_header.length); |
382 | 382 | ||
383 | /* Read mi4 header of the OF */ | 383 | /* Read mi4 header of the OF */ |
384 | ata_read_sectors(IF_MV2(0,) pinfo->start + PPMI_SECTOR_OFFSET + PPMI_SECTORS | 384 | storage_read_sectors(IF_MV2(0,) pinfo->start + PPMI_SECTOR_OFFSET + PPMI_SECTORS |
385 | + (ppmi_header.length/512), MI4_HEADER_SECTORS, &mi4header); | 385 | + (ppmi_header.length/512), MI4_HEADER_SECTORS, &mi4header); |
386 | 386 | ||
387 | /* We don't support encrypted mi4 files yet */ | 387 | /* We don't support encrypted mi4 files yet */ |
@@ -404,7 +404,7 @@ int load_mi4_part(unsigned char* buf, struct partinfo* pinfo, | |||
404 | printf("Binary type: %.4s", mi4header.type); | 404 | printf("Binary type: %.4s", mi4header.type); |
405 | 405 | ||
406 | /* Load firmware */ | 406 | /* Load firmware */ |
407 | ata_read_sectors(IF_MV2(0,) pinfo->start + PPMI_SECTOR_OFFSET + PPMI_SECTORS | 407 | storage_read_sectors(IF_MV2(0,) pinfo->start + PPMI_SECTOR_OFFSET + PPMI_SECTORS |
408 | + (ppmi_header.length/512) + MI4_HEADER_SECTORS, | 408 | + (ppmi_header.length/512) + MI4_HEADER_SECTORS, |
409 | (mi4header.mi4size-MI4_HEADER_SIZE)/512, buf); | 409 | (mi4header.mi4size-MI4_HEADER_SIZE)/512, buf); |
410 | 410 | ||
@@ -423,9 +423,9 @@ int load_mi4_part(unsigned char* buf, struct partinfo* pinfo, | |||
423 | 423 | ||
424 | printf("Disabling database rebuild"); | 424 | printf("Disabling database rebuild"); |
425 | 425 | ||
426 | ata_read_sectors(IF_MV2(0,) pinfo->start + 0x3c08, 1, block); | 426 | storage_read_sectors(IF_MV2(0,) pinfo->start + 0x3c08, 1, block); |
427 | block[0xe1] = 0; | 427 | block[0xe1] = 0; |
428 | ata_write_sectors(IF_MV2(0,) pinfo->start + 0x3c08, 1, block); | 428 | storage_write_sectors(IF_MV2(0,) pinfo->start + 0x3c08, 1, block); |
429 | } | 429 | } |
430 | #else | 430 | #else |
431 | (void) disable_rebuild; | 431 | (void) disable_rebuild; |
@@ -505,7 +505,7 @@ void* main(void) | |||
505 | printf("Version: %s", version); | 505 | printf("Version: %s", version); |
506 | printf(MODEL_NAME); | 506 | printf(MODEL_NAME); |
507 | 507 | ||
508 | i=ata_init(); | 508 | i=storage_init(); |
509 | #if !(CONFIG_STORAGE & STORAGE_SD) | 509 | #if !(CONFIG_STORAGE & STORAGE_SD) |
510 | if (i==0) { | 510 | if (i==0) { |
511 | identify_info=ata_get_identify(); | 511 | identify_info=ata_get_identify(); |
@@ -601,7 +601,7 @@ void* main(void) | |||
601 | { | 601 | { |
602 | printf("dumping sector %d", i); | 602 | printf("dumping sector %d", i); |
603 | } | 603 | } |
604 | ata_read_sectors(IF_MV2(0,) pinfo->start + i, 1, sector); | 604 | storage_read_sectors(IF_MV2(0,) pinfo->start + i, 1, sector); |
605 | write(fd,sector,512); | 605 | write(fd,sector,512); |
606 | } | 606 | } |
607 | close(fd); | 607 | close(fd); |
diff --git a/bootloader/meizu_m3.c b/bootloader/meizu_m3.c index acd07d7c66..940e7ea876 100644 --- a/bootloader/meizu_m3.c +++ b/bootloader/meizu_m3.c | |||
@@ -29,7 +29,7 @@ | |||
29 | #include "lcd.h" | 29 | #include "lcd.h" |
30 | #include "kernel.h" | 30 | #include "kernel.h" |
31 | #include "thread.h" | 31 | #include "thread.h" |
32 | #include "ata.h" | 32 | #include "storage.h" |
33 | #include "fat.h" | 33 | #include "fat.h" |
34 | #include "disk.h" | 34 | #include "disk.h" |
35 | #include "font.h" | 35 | #include "font.h" |
diff --git a/bootloader/meizu_m6sl.c b/bootloader/meizu_m6sl.c index 86c4c5731e..0b335bec8a 100644 --- a/bootloader/meizu_m6sl.c +++ b/bootloader/meizu_m6sl.c | |||
@@ -29,7 +29,7 @@ | |||
29 | #include "lcd.h" | 29 | #include "lcd.h" |
30 | #include "kernel.h" | 30 | #include "kernel.h" |
31 | #include "thread.h" | 31 | #include "thread.h" |
32 | #include "ata.h" | 32 | #include "storage.h" |
33 | #include "fat.h" | 33 | #include "fat.h" |
34 | #include "disk.h" | 34 | #include "disk.h" |
35 | #include "font.h" | 35 | #include "font.h" |
diff --git a/bootloader/meizu_m6sp.c b/bootloader/meizu_m6sp.c index 7608c9bd30..63ade2dbe8 100644 --- a/bootloader/meizu_m6sp.c +++ b/bootloader/meizu_m6sp.c | |||
@@ -29,7 +29,7 @@ | |||
29 | #include "lcd.h" | 29 | #include "lcd.h" |
30 | #include "kernel.h" | 30 | #include "kernel.h" |
31 | #include "thread.h" | 31 | #include "thread.h" |
32 | #include "ata.h" | 32 | #include "storage.h" |
33 | #include "fat.h" | 33 | #include "fat.h" |
34 | #include "disk.h" | 34 | #include "disk.h" |
35 | #include "font.h" | 35 | #include "font.h" |
diff --git a/bootloader/mrobe500.c b/bootloader/mrobe500.c index 8389d11b4b..f92ff4bf84 100644 --- a/bootloader/mrobe500.c +++ b/bootloader/mrobe500.c | |||
@@ -26,7 +26,7 @@ | |||
26 | #include "lcd.h" | 26 | #include "lcd.h" |
27 | #include "kernel.h" | 27 | #include "kernel.h" |
28 | #include "thread.h" | 28 | #include "thread.h" |
29 | #include "ata.h" | 29 | #include "storage.h" |
30 | #include "fat.h" | 30 | #include "fat.h" |
31 | #include "disk.h" | 31 | #include "disk.h" |
32 | #include "font.h" | 32 | #include "font.h" |
@@ -229,13 +229,13 @@ void main(void) | |||
229 | lcd_update(); | 229 | lcd_update(); |
230 | 230 | ||
231 | ide_power_enable(true); | 231 | ide_power_enable(true); |
232 | ata_enable(false); | 232 | storage_enable(false); |
233 | sleep(HZ/20); | 233 | sleep(HZ/20); |
234 | usb_enable(true); | 234 | usb_enable(true); |
235 | 235 | ||
236 | while (usb_detect() == USB_INSERTED) | 236 | while (usb_detect() == USB_INSERTED) |
237 | { | 237 | { |
238 | ata_spin(); /* Prevent the drive from spinning down */ | 238 | storage_spin(); /* Prevent the drive from spinning down */ |
239 | sleep(HZ); | 239 | sleep(HZ); |
240 | } | 240 | } |
241 | 241 | ||
@@ -248,7 +248,7 @@ void main(void) | |||
248 | mrdebug(); | 248 | mrdebug(); |
249 | #endif | 249 | #endif |
250 | printf("ATA"); | 250 | printf("ATA"); |
251 | rc = ata_init(); | 251 | rc = storage_init(); |
252 | if(rc) | 252 | if(rc) |
253 | { | 253 | { |
254 | reset_screen(); | 254 | reset_screen(); |
diff --git a/bootloader/ondavx747.c b/bootloader/ondavx747.c index d8fefd4f48..13c537b9be 100644 --- a/bootloader/ondavx747.c +++ b/bootloader/ondavx747.c | |||
@@ -54,7 +54,7 @@ int main(void) | |||
54 | 54 | ||
55 | backlight_init(); | 55 | backlight_init(); |
56 | 56 | ||
57 | ata_init(); | 57 | storage_init(); |
58 | 58 | ||
59 | int touch, btn; | 59 | int touch, btn; |
60 | char datetime[30]; | 60 | char datetime[30]; |
diff --git a/bootloader/sansa_as3525.c b/bootloader/sansa_as3525.c index df6f789135..aa4d6a9057 100644 --- a/bootloader/sansa_as3525.c +++ b/bootloader/sansa_as3525.c | |||
@@ -30,7 +30,7 @@ | |||
30 | #include "backlight-target.h" | 30 | #include "backlight-target.h" |
31 | #include "as3525-codec.h" | 31 | #include "as3525-codec.h" |
32 | #include "common.h" | 32 | #include "common.h" |
33 | #include "ata.h" | 33 | #include "storage.h" |
34 | 34 | ||
35 | int show_logo(void); | 35 | int show_logo(void); |
36 | void main(void) | 36 | void main(void) |
@@ -54,7 +54,7 @@ void main(void) | |||
54 | } | 54 | } |
55 | printf("ID: %02X%02X%02X%02X%02X%02X%02X%02X", buf[7], buf[6], buf[5], buf[4], buf[3], buf[2], buf[1], buf[0]); | 55 | printf("ID: %02X%02X%02X%02X%02X%02X%02X%02X", buf[7], buf[6], buf[5], buf[4], buf[3], buf[2], buf[1], buf[0]); |
56 | 56 | ||
57 | ata_init(); | 57 | storage_init(); |
58 | 58 | ||
59 | #ifdef SANSA_CLIP | 59 | #ifdef SANSA_CLIP |
60 | /* Use hardware scrolling */ | 60 | /* Use hardware scrolling */ |
diff --git a/bootloader/telechips.c b/bootloader/telechips.c index 7e00e52142..4d64532449 100644 --- a/bootloader/telechips.c +++ b/bootloader/telechips.c | |||
@@ -30,7 +30,7 @@ | |||
30 | #include "lcd.h" | 30 | #include "lcd.h" |
31 | #include "kernel.h" | 31 | #include "kernel.h" |
32 | #include "thread.h" | 32 | #include "thread.h" |
33 | #include "ata.h" | 33 | #include "storage.h" |
34 | #include "fat.h" | 34 | #include "fat.h" |
35 | #include "disk.h" | 35 | #include "disk.h" |
36 | #include "font.h" | 36 | #include "font.h" |
@@ -206,7 +206,7 @@ void* main(void) | |||
206 | printf("Version %s", version); | 206 | printf("Version %s", version); |
207 | 207 | ||
208 | printf("ATA"); | 208 | printf("ATA"); |
209 | rc = ata_init(); | 209 | rc = storage_init(); |
210 | if(rc) | 210 | if(rc) |
211 | { | 211 | { |
212 | reset_screen(); | 212 | reset_screen(); |
diff --git a/bootloader/tpj1022.c b/bootloader/tpj1022.c index 62929cf1aa..aaf6e9fcfd 100644 --- a/bootloader/tpj1022.c +++ b/bootloader/tpj1022.c | |||
@@ -30,7 +30,7 @@ | |||
30 | #include "lcd.h" | 30 | #include "lcd.h" |
31 | #include "kernel.h" | 31 | #include "kernel.h" |
32 | #include "thread.h" | 32 | #include "thread.h" |
33 | #include "ata.h" | 33 | #include "storage.h" |
34 | #include "fat.h" | 34 | #include "fat.h" |
35 | #include "disk.h" | 35 | #include "disk.h" |
36 | #include "font.h" | 36 | #include "font.h" |
@@ -58,7 +58,7 @@ void* main(void) | |||
58 | printf("Hello World!"); | 58 | printf("Hello World!"); |
59 | #endif | 59 | #endif |
60 | 60 | ||
61 | i=ata_init(); | 61 | i=storage_init(); |
62 | 62 | ||
63 | disk_init(); | 63 | disk_init(); |
64 | rc = disk_mount_all(); | 64 | rc = disk_mount_all(); |
diff --git a/firmware/SOURCES b/firmware/SOURCES index 724f0920cf..3bdf089585 100644 --- a/firmware/SOURCES +++ b/firmware/SOURCES | |||
@@ -108,6 +108,7 @@ drivers/serial.c | |||
108 | 108 | ||
109 | 109 | ||
110 | /* Storage */ | 110 | /* Storage */ |
111 | storage.c | ||
111 | #ifndef SIMULATOR | 112 | #ifndef SIMULATOR |
112 | #if (CONFIG_STORAGE & STORAGE_MMC) | 113 | #if (CONFIG_STORAGE & STORAGE_MMC) |
113 | drivers/ata_mmc.c | 114 | drivers/ata_mmc.c |
diff --git a/firmware/ata_idle_notify.c b/firmware/ata_idle_notify.c index 3dde52f391..99b1d4d786 100644 --- a/firmware/ata_idle_notify.c +++ b/firmware/ata_idle_notify.c | |||
@@ -25,9 +25,9 @@ | |||
25 | #include "kernel.h" | 25 | #include "kernel.h" |
26 | #include "string.h" | 26 | #include "string.h" |
27 | 27 | ||
28 | void register_ata_idle_func(ata_idle_notify function) | 28 | void register_storage_idle_func(storage_idle_notify function) |
29 | { | 29 | { |
30 | #if USING_ATA_CALLBACK | 30 | #if USING_STORAGE_CALLBACK |
31 | add_event(DISK_EVENT_SPINUP, true, function); | 31 | add_event(DISK_EVENT_SPINUP, true, function); |
32 | #else | 32 | #else |
33 | function(); /* just call the function now */ | 33 | function(); /* just call the function now */ |
@@ -37,8 +37,8 @@ void register_ata_idle_func(ata_idle_notify function) | |||
37 | #endif | 37 | #endif |
38 | } | 38 | } |
39 | 39 | ||
40 | #if USING_ATA_CALLBACK | 40 | #if USING_STORAGE_CALLBACK |
41 | void unregister_ata_idle_func(ata_idle_notify func, bool run) | 41 | void unregister_storage_idle_func(storage_idle_notify func, bool run) |
42 | { | 42 | { |
43 | remove_event(DISK_EVENT_SPINUP, func); | 43 | remove_event(DISK_EVENT_SPINUP, func); |
44 | 44 | ||
@@ -46,7 +46,7 @@ void unregister_ata_idle_func(ata_idle_notify func, bool run) | |||
46 | func(); | 46 | func(); |
47 | } | 47 | } |
48 | 48 | ||
49 | bool call_ata_idle_notifys(bool force) | 49 | bool call_storage_idle_notifys(bool force) |
50 | { | 50 | { |
51 | static int lock_until = 0; | 51 | static int lock_until = 0; |
52 | 52 | ||
diff --git a/firmware/common/disk.c b/firmware/common/disk.c index 4add5b99df..32b15b8857 100644 --- a/firmware/common/disk.c +++ b/firmware/common/disk.c | |||
@@ -19,7 +19,7 @@ | |||
19 | * | 19 | * |
20 | ****************************************************************************/ | 20 | ****************************************************************************/ |
21 | #include <stdio.h> | 21 | #include <stdio.h> |
22 | #include "ata.h" | 22 | #include "storage.h" |
23 | #include "debug.h" | 23 | #include "debug.h" |
24 | #include "fat.h" | 24 | #include "fat.h" |
25 | #ifdef HAVE_HOTSWAP | 25 | #ifdef HAVE_HOTSWAP |
@@ -80,7 +80,7 @@ struct partinfo* disk_init(IF_MV_NONVOID(int drive)) | |||
80 | struct partinfo* pinfo = part; | 80 | struct partinfo* pinfo = part; |
81 | #endif | 81 | #endif |
82 | 82 | ||
83 | ata_read_sectors(IF_MV2(drive,) 0,1, §or); | 83 | storage_read_sectors(IF_MV2(drive,) 0,1, §or); |
84 | /* check that the boot sector is initialized */ | 84 | /* check that the boot sector is initialized */ |
85 | if ( (sector[510] != 0x55) || | 85 | if ( (sector[510] != 0x55) || |
86 | (sector[511] != 0xaa)) { | 86 | (sector[511] != 0xaa)) { |
diff --git a/firmware/drivers/ata.c b/firmware/drivers/ata.c index b80f615eb3..c2882a5b74 100644 --- a/firmware/drivers/ata.c +++ b/firmware/drivers/ata.c | |||
@@ -32,6 +32,7 @@ | |||
32 | #include "string.h" | 32 | #include "string.h" |
33 | #include "ata_idle_notify.h" | 33 | #include "ata_idle_notify.h" |
34 | #include "ata-target.h" | 34 | #include "ata-target.h" |
35 | #include "storage.h" | ||
35 | 36 | ||
36 | #define SECTOR_SIZE (512) | 37 | #define SECTOR_SIZE (512) |
37 | 38 | ||
@@ -148,7 +149,7 @@ static void ata_lock_unlock(struct ata_lock *l) | |||
148 | static struct mutex ata_mtx SHAREDBSS_ATTR; | 149 | static struct mutex ata_mtx SHAREDBSS_ATTR; |
149 | static int ata_device; /* device 0 (master) or 1 (slave) */ | 150 | static int ata_device; /* device 0 (master) or 1 (slave) */ |
150 | 151 | ||
151 | int ata_spinup_time = 0; | 152 | static int spinup_time = 0; |
152 | #if (CONFIG_LED == LED_REAL) | 153 | #if (CONFIG_LED == LED_REAL) |
153 | static bool ata_led_enabled = true; | 154 | static bool ata_led_enabled = true; |
154 | static bool ata_led_on = false; | 155 | static bool ata_led_on = false; |
@@ -166,7 +167,7 @@ static struct event_queue ata_queue; | |||
166 | static bool initialized = false; | 167 | static bool initialized = false; |
167 | 168 | ||
168 | static long last_user_activity = -1; | 169 | static long last_user_activity = -1; |
169 | long last_disk_activity = -1; | 170 | static long last_disk_activity = -1; |
170 | 171 | ||
171 | static unsigned long total_sectors; | 172 | static unsigned long total_sectors; |
172 | static int multisectors; /* number of supported multisectors */ | 173 | static int multisectors; /* number of supported multisectors */ |
@@ -407,7 +408,7 @@ int ata_read_sectors(IF_MV2(int drive,) | |||
407 | } | 408 | } |
408 | 409 | ||
409 | if (spinup) { | 410 | if (spinup) { |
410 | ata_spinup_time = current_tick - spinup_start; | 411 | spinup_time = current_tick - spinup_start; |
411 | spinup = false; | 412 | spinup = false; |
412 | sleeping = false; | 413 | sleeping = false; |
413 | poweroff = false; | 414 | poweroff = false; |
@@ -584,7 +585,7 @@ int ata_write_sectors(IF_MV2(int drive,) | |||
584 | } | 585 | } |
585 | 586 | ||
586 | if (spinup) { | 587 | if (spinup) { |
587 | ata_spinup_time = current_tick - spinup_start; | 588 | spinup_time = current_tick - spinup_start; |
588 | spinup = false; | 589 | spinup = false; |
589 | sleeping = false; | 590 | sleeping = false; |
590 | poweroff = false; | 591 | poweroff = false; |
@@ -873,7 +874,7 @@ void ata_sleepnow(void) | |||
873 | { | 874 | { |
874 | if (!spinup && !sleeping && !ata_mtx.locked && initialized) | 875 | if (!spinup && !sleeping && !ata_mtx.locked && initialized) |
875 | { | 876 | { |
876 | call_ata_idle_notifys(false); | 877 | call_storage_idle_notifys(false); |
877 | ata_perform_sleep(); | 878 | ata_perform_sleep(); |
878 | } | 879 | } |
879 | } | 880 | } |
@@ -908,7 +909,7 @@ static void ata_thread(void) | |||
908 | #ifdef ALLOW_USB_SPINDOWN | 909 | #ifdef ALLOW_USB_SPINDOWN |
909 | if(!usb_mode) | 910 | if(!usb_mode) |
910 | #endif | 911 | #endif |
911 | call_ata_idle_notifys(false); | 912 | call_storage_idle_notifys(false); |
912 | last_seen_mtx_unlock = 0; | 913 | last_seen_mtx_unlock = 0; |
913 | } | 914 | } |
914 | } | 915 | } |
@@ -921,7 +922,7 @@ static void ata_thread(void) | |||
921 | #ifdef ALLOW_USB_SPINDOWN | 922 | #ifdef ALLOW_USB_SPINDOWN |
922 | if(!usb_mode) | 923 | if(!usb_mode) |
923 | #endif | 924 | #endif |
924 | call_ata_idle_notifys(true); | 925 | call_storage_idle_notifys(true); |
925 | ata_perform_sleep(); | 926 | ata_perform_sleep(); |
926 | last_sleep = current_tick; | 927 | last_sleep = current_tick; |
927 | } | 928 | } |
@@ -974,7 +975,7 @@ static void ata_thread(void) | |||
974 | #ifdef ALLOW_USB_SPINDOWN | 975 | #ifdef ALLOW_USB_SPINDOWN |
975 | if(!usb_mode) | 976 | if(!usb_mode) |
976 | #endif | 977 | #endif |
977 | call_ata_idle_notifys(false); | 978 | call_storage_idle_notifys(false); |
978 | last_disk_activity = current_tick - sleep_timeout + (HZ/2); | 979 | last_disk_activity = current_tick - sleep_timeout + (HZ/2); |
979 | break; | 980 | break; |
980 | 981 | ||
@@ -1391,3 +1392,43 @@ void ata_set_led_enabled(bool enabled) | |||
1391 | led(false); | 1392 | led(false); |
1392 | } | 1393 | } |
1393 | #endif | 1394 | #endif |
1395 | |||
1396 | long ata_last_disk_activity(void) | ||
1397 | { | ||
1398 | return last_disk_activity; | ||
1399 | } | ||
1400 | |||
1401 | int ata_spinup_time(void) | ||
1402 | { | ||
1403 | return spinup_time; | ||
1404 | } | ||
1405 | |||
1406 | void ata_get_info(struct storage_info *info) | ||
1407 | { | ||
1408 | unsigned short *src,*dest; | ||
1409 | static char vendor[8]; | ||
1410 | static char product[16]; | ||
1411 | static char revision[4]; | ||
1412 | int i; | ||
1413 | info->sector_size = SECTOR_SIZE; | ||
1414 | info->num_sectors= ((unsigned long)identify_info[61] << 16 | \ | ||
1415 | (unsigned long)identify_info[60]); | ||
1416 | |||
1417 | src = (unsigned short*)&identify_info[27]; | ||
1418 | dest = (unsigned short*)vendor; | ||
1419 | for (i=0;i<4;i++) | ||
1420 | dest[i] = htobe16(src[i]); | ||
1421 | info->vendor=vendor; | ||
1422 | |||
1423 | src = (unsigned short*)&identify_info[31]; | ||
1424 | dest = (unsigned short*)product; | ||
1425 | for (i=0;i<8;i++) | ||
1426 | dest[i] = htobe16(src[i]); | ||
1427 | info->product=product; | ||
1428 | |||
1429 | src = (unsigned short*)&identify_info[23]; | ||
1430 | dest = (unsigned short*)revision; | ||
1431 | for (i=0;i<2;i++) | ||
1432 | dest[i] = htobe16(src[i]); | ||
1433 | info->revision=revision; | ||
1434 | } | ||
diff --git a/firmware/drivers/ata_flash.c b/firmware/drivers/ata_flash.c index d77e05647b..9b1b64145d 100644 --- a/firmware/drivers/ata_flash.c +++ b/firmware/drivers/ata_flash.c | |||
@@ -19,7 +19,7 @@ | |||
19 | * | 19 | * |
20 | ****************************************************************************/ | 20 | ****************************************************************************/ |
21 | 21 | ||
22 | #include "ata.h" | 22 | #include "storage.h" |
23 | #include <stdbool.h> | 23 | #include <stdbool.h> |
24 | #include <string.h> | 24 | #include <string.h> |
25 | 25 | ||
@@ -42,8 +42,6 @@ | |||
42 | 42 | ||
43 | #define SECTOR_SIZE (512) | 43 | #define SECTOR_SIZE (512) |
44 | 44 | ||
45 | static unsigned short identify_info[SECTOR_SIZE]; | ||
46 | int ata_spinup_time = 0; | ||
47 | long last_disk_activity = -1; | 45 | long last_disk_activity = -1; |
48 | 46 | ||
49 | #if CONFIG_FLASH == FLASH_IFP7XX | 47 | #if CONFIG_FLASH == FLASH_IFP7XX |
@@ -386,7 +384,7 @@ int flash_disk_read_sectors(unsigned long start, | |||
386 | return done; | 384 | return done; |
387 | } | 385 | } |
388 | 386 | ||
389 | int ata_read_sectors(IF_MV2(int drive,) | 387 | int nand_read_sectors(IF_MV2(int drive,) |
390 | unsigned long start, | 388 | unsigned long start, |
391 | int incount, | 389 | int incount, |
392 | void* inbuf) | 390 | void* inbuf) |
@@ -403,7 +401,7 @@ int ata_read_sectors(IF_MV2(int drive,) | |||
403 | return 0; | 401 | return 0; |
404 | } | 402 | } |
405 | 403 | ||
406 | int ata_write_sectors(IF_MV2(int drive,) | 404 | int nand_write_sectors(IF_MV2(int drive,) |
407 | unsigned long start, | 405 | unsigned long start, |
408 | int count, | 406 | int count, |
409 | const void* buf) | 407 | const void* buf) |
@@ -414,60 +412,7 @@ int ata_write_sectors(IF_MV2(int drive,) | |||
414 | return -1; | 412 | return -1; |
415 | } | 413 | } |
416 | 414 | ||
417 | /* schedule a single sector write, executed with the the next spinup | 415 | int nand_init(void) |
418 | (volume 0 only, used for config sector) */ | ||
419 | extern void ata_delayed_write(unsigned long sector, const void* buf) | ||
420 | { | ||
421 | (void)sector; | ||
422 | (void)buf; | ||
423 | } | ||
424 | |||
425 | /* write the delayed sector to volume 0 */ | ||
426 | extern void ata_flush(void) | ||
427 | { | ||
428 | |||
429 | } | ||
430 | |||
431 | void ata_spindown(int seconds) | ||
432 | { | ||
433 | (void)seconds; | ||
434 | } | ||
435 | |||
436 | bool ata_disk_is_active(void) | ||
437 | { | ||
438 | return 0; | ||
439 | } | ||
440 | |||
441 | void ata_sleep(void) | ||
442 | { | ||
443 | } | ||
444 | |||
445 | void ata_spin(void) | ||
446 | { | ||
447 | } | ||
448 | |||
449 | /* Hardware reset protocol as specified in chapter 9.1, ATA spec draft v5 */ | ||
450 | int ata_hard_reset(void) | ||
451 | { | ||
452 | return 0; | ||
453 | } | ||
454 | |||
455 | int ata_soft_reset(void) | ||
456 | { | ||
457 | return 0; | ||
458 | } | ||
459 | |||
460 | void ata_enable(bool on) | ||
461 | { | ||
462 | (void)on; | ||
463 | } | ||
464 | |||
465 | unsigned short* ata_get_identify(void) | ||
466 | { | ||
467 | return identify_info; | ||
468 | } | ||
469 | |||
470 | int ata_init(void) | ||
471 | { | 416 | { |
472 | int i, id, id2; | 417 | int i, id, id2; |
473 | 418 | ||
@@ -499,3 +444,29 @@ int ata_init(void) | |||
499 | 444 | ||
500 | return 0; | 445 | return 0; |
501 | } | 446 | } |
447 | |||
448 | long nand_last_disk_activity(void) | ||
449 | { | ||
450 | return last_disk_activity; | ||
451 | } | ||
452 | |||
453 | void nand_get_info(struct storage_info *info) | ||
454 | { | ||
455 | unsigned long blocks; | ||
456 | int i; | ||
457 | |||
458 | /* firmware version */ | ||
459 | info->revision="0.00"; | ||
460 | |||
461 | /* vendor field, need better name? */ | ||
462 | info->vendor="Rockbox"; | ||
463 | /* model field, need better name? */ | ||
464 | info->product="TNFL"; | ||
465 | |||
466 | /* blocks count */ | ||
467 | info->num_sectors = 0; | ||
468 | info->sector_size=SECTOR_SIZE; | ||
469 | |||
470 | info->serial=0; | ||
471 | } | ||
472 | |||
diff --git a/firmware/drivers/ata_mmc.c b/firmware/drivers/ata_mmc.c index 1040ab067f..953bb90bbc 100644 --- a/firmware/drivers/ata_mmc.c +++ b/firmware/drivers/ata_mmc.c | |||
@@ -19,7 +19,7 @@ | |||
19 | * | 19 | * |
20 | ****************************************************************************/ | 20 | ****************************************************************************/ |
21 | #include <stdbool.h> | 21 | #include <stdbool.h> |
22 | #include "ata.h" | 22 | #include "mmc.h" |
23 | #include "ata_mmc.h" | 23 | #include "ata_mmc.h" |
24 | #include "ata_idle_notify.h" | 24 | #include "ata_idle_notify.h" |
25 | #include "kernel.h" | 25 | #include "kernel.h" |
@@ -36,6 +36,7 @@ | |||
36 | #include "adc.h" | 36 | #include "adc.h" |
37 | #include "bitswap.h" | 37 | #include "bitswap.h" |
38 | #include "disk.h" /* for mount/unmount */ | 38 | #include "disk.h" /* for mount/unmount */ |
39 | #include "storage.h" | ||
39 | 40 | ||
40 | #define BLOCK_SIZE 512 /* fixed */ | 41 | #define BLOCK_SIZE 512 /* fixed */ |
41 | 42 | ||
@@ -84,8 +85,7 @@ | |||
84 | #define DT_STOP_TRAN 0xfd | 85 | #define DT_STOP_TRAN 0xfd |
85 | 86 | ||
86 | /* for compatibility */ | 87 | /* for compatibility */ |
87 | int ata_spinup_time = 0; | 88 | static long last_disk_activity = -1; |
88 | long last_disk_activity = -1; | ||
89 | 89 | ||
90 | /* private variables */ | 90 | /* private variables */ |
91 | 91 | ||
@@ -601,7 +601,7 @@ static int send_block_send(unsigned char start_token, long timeout, | |||
601 | return rc; | 601 | return rc; |
602 | } | 602 | } |
603 | 603 | ||
604 | int ata_read_sectors(IF_MV2(int drive,) | 604 | int mmc_read_sectors(IF_MV2(int drive,) |
605 | unsigned long start, | 605 | unsigned long start, |
606 | int incount, | 606 | int incount, |
607 | void* inbuf) | 607 | void* inbuf) |
@@ -687,7 +687,7 @@ int ata_read_sectors(IF_MV2(int drive,) | |||
687 | return rc; | 687 | return rc; |
688 | } | 688 | } |
689 | 689 | ||
690 | int ata_write_sectors(IF_MV2(int drive,) | 690 | int mmc_write_sectors(IF_MV2(int drive,) |
691 | unsigned long start, | 691 | unsigned long start, |
692 | int count, | 692 | int count, |
693 | const void* buf) | 693 | const void* buf) |
@@ -755,25 +755,12 @@ int ata_write_sectors(IF_MV2(int drive,) | |||
755 | return rc; | 755 | return rc; |
756 | } | 756 | } |
757 | 757 | ||
758 | void ata_spindown(int seconds) | 758 | bool mmc_disk_is_active(void) |
759 | { | ||
760 | (void)seconds; | ||
761 | } | ||
762 | |||
763 | bool ata_disk_is_active(void) | ||
764 | { | 759 | { |
765 | /* this is correct unless early return from write gets implemented */ | 760 | /* this is correct unless early return from write gets implemented */ |
766 | return mmc_mutex.locked; | 761 | return mmc_mutex.locked; |
767 | } | 762 | } |
768 | 763 | ||
769 | void ata_sleep(void) | ||
770 | { | ||
771 | } | ||
772 | |||
773 | void ata_spin(void) | ||
774 | { | ||
775 | } | ||
776 | |||
777 | static void mmc_thread(void) | 764 | static void mmc_thread(void) |
778 | { | 765 | { |
779 | struct queue_event ev; | 766 | struct queue_event ev; |
@@ -810,7 +797,7 @@ static void mmc_thread(void) | |||
810 | { | 797 | { |
811 | if (!idle_notified) | 798 | if (!idle_notified) |
812 | { | 799 | { |
813 | call_ata_idle_notifys(false); | 800 | call_storage_idle_notifys(false); |
814 | idle_notified = true; | 801 | idle_notified = true; |
815 | } | 802 | } |
816 | } | 803 | } |
@@ -904,12 +891,7 @@ static void mmc_tick(void) | |||
904 | } | 891 | } |
905 | } | 892 | } |
906 | 893 | ||
907 | int ata_soft_reset(void) | 894 | void mmc_enable(bool on) |
908 | { | ||
909 | return 0; | ||
910 | } | ||
911 | |||
912 | void ata_enable(bool on) | ||
913 | { | 895 | { |
914 | PBCR1 &= ~0x0CF0; /* PB13, PB11 and PB10 become GPIO, | 896 | PBCR1 &= ~0x0CF0; /* PB13, PB11 and PB10 become GPIO, |
915 | * if not modified below */ | 897 | * if not modified below */ |
@@ -924,7 +906,7 @@ void ata_enable(bool on) | |||
924 | card_info[1].initialized = false; | 906 | card_info[1].initialized = false; |
925 | } | 907 | } |
926 | 908 | ||
927 | int ata_init(void) | 909 | int mmc_init(void) |
928 | { | 910 | { |
929 | int rc = 0; | 911 | int rc = 0; |
930 | 912 | ||
@@ -970,9 +952,51 @@ int ata_init(void) | |||
970 | tick_add_task(mmc_tick); | 952 | tick_add_task(mmc_tick); |
971 | initialized = true; | 953 | initialized = true; |
972 | } | 954 | } |
973 | ata_enable(true); | 955 | mmc_enable(true); |
974 | 956 | ||
975 | mutex_unlock(&mmc_mutex); | 957 | mutex_unlock(&mmc_mutex); |
976 | return rc; | 958 | return rc; |
977 | } | 959 | } |
978 | 960 | ||
961 | long mmc_last_disk_activity(void) | ||
962 | { | ||
963 | return last_disk_activity; | ||
964 | } | ||
965 | |||
966 | void mmc_get_info(IF_MV2(int drive,) struct storage_info *info) | ||
967 | { | ||
968 | #ifndef HAVE_MULTIVOLUME | ||
969 | const int drive=0; | ||
970 | #endif | ||
971 | info->sector_size=card_info[drive].blocksize; | ||
972 | info->num_sectors=card_info[drive].numblocks; | ||
973 | info->vendor="Rockbox"; | ||
974 | if(drive==0) | ||
975 | { | ||
976 | info->product="Internal Storage"; | ||
977 | } | ||
978 | else | ||
979 | { | ||
980 | info->product="MMC Card Slot"; | ||
981 | } | ||
982 | info->revision="0.00"; | ||
983 | } | ||
984 | |||
985 | #ifdef HAVE_HOTSWAP | ||
986 | bool mmc_removable(IF_MV_NONVOID(int drive)) | ||
987 | { | ||
988 | #ifndef HAVE_MULTIVOLUME | ||
989 | const int drive=0; | ||
990 | #endif | ||
991 | return (drive==1); | ||
992 | } | ||
993 | |||
994 | bool mmc_present(IF_MV_NONVOID(int drive)) | ||
995 | { | ||
996 | #ifndef HAVE_MULTIVOLUME | ||
997 | const int drive=0; | ||
998 | #endif | ||
999 | return (card_info[drive].initialized && card_info[drive].numblocks > 0); | ||
1000 | } | ||
1001 | #endif | ||
1002 | |||
diff --git a/firmware/drivers/fat.c b/firmware/drivers/fat.c index 90be93f4f4..4317b70766 100644 --- a/firmware/drivers/fat.c +++ b/firmware/drivers/fat.c | |||
@@ -24,7 +24,7 @@ | |||
24 | #include <ctype.h> | 24 | #include <ctype.h> |
25 | #include <stdbool.h> | 25 | #include <stdbool.h> |
26 | #include "fat.h" | 26 | #include "fat.h" |
27 | #include "ata.h" | 27 | #include "storage.h" |
28 | #include "debug.h" | 28 | #include "debug.h" |
29 | #include "panic.h" | 29 | #include "panic.h" |
30 | #include "system.h" | 30 | #include "system.h" |
@@ -300,7 +300,7 @@ int fat_mount(IF_MV2(int volume,) IF_MV2(int drive,) long startsector) | |||
300 | #endif | 300 | #endif |
301 | 301 | ||
302 | /* Read the sector */ | 302 | /* Read the sector */ |
303 | rc = ata_read_sectors(IF_MV2(drive,) startsector,1,buf); | 303 | rc = storage_read_sectors(IF_MV2(drive,) startsector,1,buf); |
304 | if(rc) | 304 | if(rc) |
305 | { | 305 | { |
306 | DEBUGF( "fat_mount() - Couldn't read BPB (error code %d)\n", rc); | 306 | DEBUGF( "fat_mount() - Couldn't read BPB (error code %d)\n", rc); |
@@ -422,7 +422,7 @@ int fat_mount(IF_MV2(int volume,) IF_MV2(int drive,) long startsector) | |||
422 | #endif /* #ifdef HAVE_FAT16SUPPORT */ | 422 | #endif /* #ifdef HAVE_FAT16SUPPORT */ |
423 | { | 423 | { |
424 | /* Read the fsinfo sector */ | 424 | /* Read the fsinfo sector */ |
425 | rc = ata_read_sectors(IF_MV2(drive,) | 425 | rc = storage_read_sectors(IF_MV2(drive,) |
426 | startsector + fat_bpb->bpb_fsinfo, 1, buf); | 426 | startsector + fat_bpb->bpb_fsinfo, 1, buf); |
427 | if (rc < 0) | 427 | if (rc < 0) |
428 | { | 428 | { |
@@ -597,7 +597,7 @@ static void flush_fat_sector(struct fat_cache_entry *fce, | |||
597 | #endif | 597 | #endif |
598 | 598 | ||
599 | /* Write to the first FAT */ | 599 | /* Write to the first FAT */ |
600 | rc = ata_write_sectors(IF_MV2(fce->fat_vol->drive,) | 600 | rc = storage_write_sectors(IF_MV2(fce->fat_vol->drive,) |
601 | secnum, 1, | 601 | secnum, 1, |
602 | sectorbuf); | 602 | sectorbuf); |
603 | if(rc < 0) | 603 | if(rc < 0) |
@@ -618,7 +618,7 @@ static void flush_fat_sector(struct fat_cache_entry *fce, | |||
618 | #else | 618 | #else |
619 | secnum += fat_bpbs[0].fatsize; | 619 | secnum += fat_bpbs[0].fatsize; |
620 | #endif | 620 | #endif |
621 | rc = ata_write_sectors(IF_MV2(fce->fat_vol->drive,) | 621 | rc = storage_write_sectors(IF_MV2(fce->fat_vol->drive,) |
622 | secnum, 1, sectorbuf); | 622 | secnum, 1, sectorbuf); |
623 | if(rc < 0) | 623 | if(rc < 0) |
624 | { | 624 | { |
@@ -664,7 +664,7 @@ static void *cache_fat_sector(IF_MV2(struct bpb* fat_bpb,) | |||
664 | /* Load the sector if it is not cached */ | 664 | /* Load the sector if it is not cached */ |
665 | if(!fce->inuse) | 665 | if(!fce->inuse) |
666 | { | 666 | { |
667 | rc = ata_read_sectors(IF_MV2(fat_bpb->drive,) | 667 | rc = storage_read_sectors(IF_MV2(fat_bpb->drive,) |
668 | secnum + fat_bpb->startsector,1, | 668 | secnum + fat_bpb->startsector,1, |
669 | sectorbuf); | 669 | sectorbuf); |
670 | if(rc < 0) | 670 | if(rc < 0) |
@@ -923,7 +923,7 @@ static int update_fsinfo(IF_MV_NONVOID(struct bpb* fat_bpb)) | |||
923 | #endif /* #ifdef HAVE_FAT16SUPPORT */ | 923 | #endif /* #ifdef HAVE_FAT16SUPPORT */ |
924 | 924 | ||
925 | /* update fsinfo */ | 925 | /* update fsinfo */ |
926 | rc = ata_read_sectors(IF_MV2(fat_bpb->drive,) | 926 | rc = storage_read_sectors(IF_MV2(fat_bpb->drive,) |
927 | fat_bpb->startsector + fat_bpb->bpb_fsinfo, 1,fsinfo); | 927 | fat_bpb->startsector + fat_bpb->bpb_fsinfo, 1,fsinfo); |
928 | if (rc < 0) | 928 | if (rc < 0) |
929 | { | 929 | { |
@@ -936,7 +936,7 @@ static int update_fsinfo(IF_MV_NONVOID(struct bpb* fat_bpb)) | |||
936 | intptr = (long*)&(fsinfo[FSINFO_NEXTFREE]); | 936 | intptr = (long*)&(fsinfo[FSINFO_NEXTFREE]); |
937 | *intptr = htole32(fat_bpb->fsinfo.nextfree); | 937 | *intptr = htole32(fat_bpb->fsinfo.nextfree); |
938 | 938 | ||
939 | rc = ata_write_sectors(IF_MV2(fat_bpb->drive,) | 939 | rc = storage_write_sectors(IF_MV2(fat_bpb->drive,) |
940 | fat_bpb->startsector + fat_bpb->bpb_fsinfo,1,fsinfo); | 940 | fat_bpb->startsector + fat_bpb->bpb_fsinfo,1,fsinfo); |
941 | if (rc < 0) | 941 | if (rc < 0) |
942 | { | 942 | { |
@@ -2077,11 +2077,11 @@ static int transfer(IF_MV2(struct bpb* fat_bpb,) | |||
2077 | if (start + count > fat_bpb->totalsectors) | 2077 | if (start + count > fat_bpb->totalsectors) |
2078 | panicf("Write %ld after data\n", | 2078 | panicf("Write %ld after data\n", |
2079 | start + count - fat_bpb->totalsectors); | 2079 | start + count - fat_bpb->totalsectors); |
2080 | rc = ata_write_sectors(IF_MV2(fat_bpb->drive,) | 2080 | rc = storage_write_sectors(IF_MV2(fat_bpb->drive,) |
2081 | start + fat_bpb->startsector, count, buf); | 2081 | start + fat_bpb->startsector, count, buf); |
2082 | } | 2082 | } |
2083 | else | 2083 | else |
2084 | rc = ata_read_sectors(IF_MV2(fat_bpb->drive,) | 2084 | rc = storage_read_sectors(IF_MV2(fat_bpb->drive,) |
2085 | start + fat_bpb->startsector, count, buf); | 2085 | start + fat_bpb->startsector, count, buf); |
2086 | if (rc < 0) { | 2086 | if (rc < 0) { |
2087 | DEBUGF( "transfer() - Couldn't %s sector %lx" | 2087 | DEBUGF( "transfer() - Couldn't %s sector %lx" |
diff --git a/firmware/export/ata.h b/firmware/export/ata.h index 164261a40a..f09a4630d3 100644 --- a/firmware/export/ata.h +++ b/firmware/export/ata.h | |||
@@ -23,43 +23,40 @@ | |||
23 | 23 | ||
24 | #include <stdbool.h> | 24 | #include <stdbool.h> |
25 | #include "config.h" /* for HAVE_MULTIVOLUME or not */ | 25 | #include "config.h" /* for HAVE_MULTIVOLUME or not */ |
26 | #include "mv.h" /* for IF_MV() and friends */ | ||
26 | 27 | ||
27 | /* FixMe: These macros are a bit nasty and perhaps misplaced here. | 28 | struct storage_info; |
28 | We'll get rid of them once decided on how to proceed with multivolume. */ | ||
29 | #ifdef HAVE_MULTIVOLUME | ||
30 | #define IF_MV(x) x /* optional volume/drive parameter */ | ||
31 | #define IF_MV2(x,y) x,y /* same, for a list of arguments */ | ||
32 | #define IF_MV_NONVOID(x) x /* for prototype with sole volume parameter */ | ||
33 | #define NUM_VOLUMES 2 | ||
34 | #else /* empty definitions if no multi-volume */ | ||
35 | #define IF_MV(x) | ||
36 | #define IF_MV2(x,y) | ||
37 | #define IF_MV_NONVOID(x) void | ||
38 | #define NUM_VOLUMES 1 | ||
39 | #endif | ||
40 | 29 | ||
41 | extern void ata_enable(bool on); | 30 | void ata_enable(bool on); |
42 | extern void ata_spindown(int seconds); | 31 | void ata_spindown(int seconds); |
43 | extern void ata_sleep(void); | 32 | void ata_sleep(void); |
44 | extern void ata_sleepnow(void); | 33 | void ata_sleepnow(void); |
45 | /* NOTE: DO NOT use this to poll for disk activity. | 34 | /* NOTE: DO NOT use this to poll for disk activity. |
46 | If you are waiting for the disk to become active before | 35 | If you are waiting for the disk to become active before |
47 | doing something use ata_idle_notify.h | 36 | doing something use ata_idle_notify.h |
48 | */ | 37 | */ |
49 | extern bool ata_disk_is_active(void); | 38 | bool ata_disk_is_active(void); |
50 | extern int ata_hard_reset(void); | 39 | int ata_hard_reset(void); |
51 | extern int ata_soft_reset(void); | 40 | int ata_soft_reset(void); |
52 | extern int ata_init(void); | 41 | int ata_init(void); |
53 | extern void ata_close(void); | 42 | void ata_close(void); |
54 | extern int ata_read_sectors(IF_MV2(int drive,) unsigned long start, int count, void* buf); | 43 | int ata_read_sectors(IF_MV2(int drive,) unsigned long start, int count, void* buf); |
55 | extern int ata_write_sectors(IF_MV2(int drive,) unsigned long start, int count, const void* buf); | 44 | int ata_write_sectors(IF_MV2(int drive,) unsigned long start, int count, const void* buf); |
56 | extern void ata_spin(void); | 45 | void ata_spin(void); |
57 | #if (CONFIG_LED == LED_REAL) | 46 | #if (CONFIG_LED == LED_REAL) |
58 | extern void ata_set_led_enabled(bool enabled); | 47 | void ata_set_led_enabled(bool enabled); |
48 | #endif | ||
49 | unsigned short* ata_get_identify(void); | ||
50 | void ata_get_info(IF_MV2(int drive,) struct storage_info *info); | ||
51 | #ifdef HAVE_HOTSWAP | ||
52 | bool ata_removable(IF_MV_NONVOID(int drive)); | ||
53 | bool ata_present(IF_MV_NONVOID(int drive)); | ||
59 | #endif | 54 | #endif |
60 | extern unsigned short* ata_get_identify(void); | ||
61 | 55 | ||
62 | extern long last_disk_activity; | 56 | |
63 | extern int ata_spinup_time; /* ticks */ | 57 | |
58 | long ata_last_disk_activity(void); | ||
59 | int ata_spinup_time(void); /* ticks */ | ||
60 | |||
64 | 61 | ||
65 | #endif | 62 | #endif |
diff --git a/firmware/export/ata_idle_notify.h b/firmware/export/ata_idle_notify.h index aea2c92b06..ceba2eeda4 100644 --- a/firmware/export/ata_idle_notify.h +++ b/firmware/export/ata_idle_notify.h | |||
@@ -26,15 +26,15 @@ | |||
26 | #include "events.h" | 26 | #include "events.h" |
27 | 27 | ||
28 | /* | 28 | /* |
29 | NOTE: ata_idle_notify usage notes.. | 29 | NOTE: storage_idle_notify usage notes.. |
30 | 30 | ||
31 | 1) The callbacks are called in the ata thread, not main/your thread. | 31 | 1) The callbacks are called in the ata thread, not main/your thread. |
32 | 2) Asynchronous callbacks (like the buffer refill) should be avoided. | 32 | 2) Asynchronous callbacks (like the buffer refill) should be avoided. |
33 | If you must use an async callback, remember to check ata_is_active() before | 33 | If you must use an async callback, remember to check storage_is_active() before |
34 | accessing the disk, and do not call any functions between that check and the | 34 | accessing the disk, and do not call any functions between that check and the |
35 | disk access which may cause a yield (lcd_update() does this!). | 35 | disk access which may cause a yield (lcd_update() does this!). |
36 | 3) Do not call any yielding functions in the callback. | 36 | 3) Do not call any yielding functions in the callback. |
37 | 4) Do not call ata_sleep in the callbacks. | 37 | 4) Do not call storage_sleep in the callbacks. |
38 | 5) Don't Panic! | 38 | 5) Don't Panic! |
39 | 39 | ||
40 | */ | 40 | */ |
@@ -43,21 +43,21 @@ enum { | |||
43 | DISK_EVENT_SPINUP = (EVENT_CLASS_DISK|1), | 43 | DISK_EVENT_SPINUP = (EVENT_CLASS_DISK|1), |
44 | }; | 44 | }; |
45 | 45 | ||
46 | #define USING_ATA_CALLBACK !defined(SIMULATOR) \ | 46 | #define USING_STORAGE_CALLBACK !defined(SIMULATOR) \ |
47 | && ! ((CONFIG_STORAGE & STORAGE_NAND) \ | 47 | && ! ((CONFIG_STORAGE & STORAGE_NAND) \ |
48 | && (CONFIG_NAND & NAND_IFP7XX)) \ | 48 | && (CONFIG_NAND & NAND_IFP7XX)) \ |
49 | && !defined(BOOTLOADER) | 49 | && !defined(BOOTLOADER) |
50 | 50 | ||
51 | typedef bool (*ata_idle_notify)(void); | 51 | typedef bool (*storage_idle_notify)(void); |
52 | 52 | ||
53 | extern void register_ata_idle_func(ata_idle_notify function); | 53 | extern void register_storage_idle_func(storage_idle_notify function); |
54 | #if USING_ATA_CALLBACK | 54 | #if USING_STORAGE_CALLBACK |
55 | extern void unregister_ata_idle_func(ata_idle_notify function, bool run); | 55 | extern void unregister_storage_idle_func(storage_idle_notify function, bool run); |
56 | extern bool call_ata_idle_notifys(bool force); | 56 | extern bool call_storage_idle_notifys(bool force); |
57 | #else | 57 | #else |
58 | #define unregister_ata_idle_func(f,r) | 58 | #define unregister_storage_idle_func(f,r) |
59 | #define call_ata_idle_notifys(f) | 59 | #define call_storage_idle_notifys(f) |
60 | #define ata_idle_notify_init(s) | 60 | #define storage_idle_notify_init(s) |
61 | #endif | 61 | #endif |
62 | 62 | ||
63 | #endif /* __ATACALLBACK_H__ */ | 63 | #endif /* __ATACALLBACK_H__ */ |
diff --git a/firmware/export/disk.h b/firmware/export/disk.h index 8d440befaf..cec9bfa3fc 100644 --- a/firmware/export/disk.h +++ b/firmware/export/disk.h | |||
@@ -21,7 +21,7 @@ | |||
21 | #ifndef _DISK_H_ | 21 | #ifndef _DISK_H_ |
22 | #define _DISK_H_ | 22 | #define _DISK_H_ |
23 | 23 | ||
24 | #include "ata.h" /* for volume definitions */ | 24 | #include "mv.h" /* for volume definitions */ |
25 | 25 | ||
26 | struct partinfo { | 26 | struct partinfo { |
27 | unsigned long start; /* first sector (LBA) */ | 27 | unsigned long start; /* first sector (LBA) */ |
diff --git a/firmware/export/fat.h b/firmware/export/fat.h index 0e83ca8b4d..c99a1a75f8 100644 --- a/firmware/export/fat.h +++ b/firmware/export/fat.h | |||
@@ -23,7 +23,7 @@ | |||
23 | #define FAT_H | 23 | #define FAT_H |
24 | 24 | ||
25 | #include <stdbool.h> | 25 | #include <stdbool.h> |
26 | #include "ata.h" /* for volume definitions */ | 26 | #include "mv.h" /* for volume definitions */ |
27 | #include "config.h" | 27 | #include "config.h" |
28 | 28 | ||
29 | #define SECTOR_SIZE 512 | 29 | #define SECTOR_SIZE 512 |
diff --git a/firmware/export/nand_id.h b/firmware/export/nand_id.h index a47a38eea2..188b6c161a 100644 --- a/firmware/export/nand_id.h +++ b/firmware/export/nand_id.h | |||
@@ -5,7 +5,7 @@ | |||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | 5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < |
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | 6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ |
7 | * \/ \/ \/ \/ \/ | 7 | * \/ \/ \/ \/ \/ |
8 | * $Id: ata.h 17847 2008-06-28 18:10:04Z bagder $ | 8 | * $Id: $ |
9 | * | 9 | * |
10 | * Copyright (C) 2002 by Alan Korr | 10 | * Copyright (C) 2002 by Alan Korr |
11 | * | 11 | * |
diff --git a/firmware/powermgmt.c b/firmware/powermgmt.c index 6e0c03c94a..6f0c37b3c7 100644 --- a/firmware/powermgmt.c +++ b/firmware/powermgmt.c | |||
@@ -29,7 +29,7 @@ | |||
29 | #include "adc.h" | 29 | #include "adc.h" |
30 | #include "string.h" | 30 | #include "string.h" |
31 | #include "sprintf.h" | 31 | #include "sprintf.h" |
32 | #include "ata.h" | 32 | #include "storage.h" |
33 | #include "power.h" | 33 | #include "power.h" |
34 | #include "button.h" | 34 | #include "button.h" |
35 | #include "audio.h" | 35 | #include "audio.h" |
@@ -451,7 +451,7 @@ static void handle_auto_poweroff(void) | |||
451 | !sleeptimer_active))) | 451 | !sleeptimer_active))) |
452 | { | 452 | { |
453 | if(TIME_AFTER(current_tick, last_event_tick + timeout) && | 453 | if(TIME_AFTER(current_tick, last_event_tick + timeout) && |
454 | TIME_AFTER(current_tick, last_disk_activity + timeout)) | 454 | TIME_AFTER(current_tick, storage_last_disk_activity() + timeout)) |
455 | { | 455 | { |
456 | sys_poweroff(); | 456 | sys_poweroff(); |
457 | } | 457 | } |
@@ -579,7 +579,7 @@ int pid_i = 0; /* PID integral term */ | |||
579 | 579 | ||
580 | static inline void charging_algorithm_small_step(void) | 580 | static inline void charging_algorithm_small_step(void) |
581 | { | 581 | { |
582 | if (ata_disk_is_active()) { | 582 | if (storage_disk_is_active()) { |
583 | /* flag hdd use for charging calculation */ | 583 | /* flag hdd use for charging calculation */ |
584 | disk_activity_last_cycle = true; | 584 | disk_activity_last_cycle = true; |
585 | } | 585 | } |
@@ -589,7 +589,7 @@ static inline void charging_algorithm_small_step(void) | |||
589 | * If we have a lot of pending writes or if the disk is spining, | 589 | * If we have a lot of pending writes or if the disk is spining, |
590 | * fsync the debug log file. | 590 | * fsync the debug log file. |
591 | */ | 591 | */ |
592 | if((wrcount > 10) || ((wrcount > 0) && ata_disk_is_active())) { | 592 | if((wrcount > 10) || ((wrcount > 0) && storage_disk_is_active())) { |
593 | fsync(fd); | 593 | fsync(fd); |
594 | wrcount = 0; | 594 | wrcount = 0; |
595 | } | 595 | } |
@@ -1014,7 +1014,7 @@ static void power_thread_sleep(int ticks) | |||
1014 | * the disk is spinning unless we are in USB mode (the disk will most | 1014 | * the disk is spinning unless we are in USB mode (the disk will most |
1015 | * likely always be spinning in USB mode). | 1015 | * likely always be spinning in USB mode). |
1016 | */ | 1016 | */ |
1017 | if (!ata_disk_is_active() || usb_inserted()) { | 1017 | if (!storage_disk_is_active() || usb_inserted()) { |
1018 | avgbat += battery_adc_voltage() - (avgbat / BATT_AVE_SAMPLES); | 1018 | avgbat += battery_adc_voltage() - (avgbat / BATT_AVE_SAMPLES); |
1019 | /* | 1019 | /* |
1020 | * battery_millivolts is the millivolt-scaled filtered battery value. | 1020 | * battery_millivolts is the millivolt-scaled filtered battery value. |
@@ -1152,10 +1152,10 @@ void shutdown_hw(void) | |||
1152 | #ifdef HAVE_LCD_BITMAP | 1152 | #ifdef HAVE_LCD_BITMAP |
1153 | glyph_cache_save(); | 1153 | glyph_cache_save(); |
1154 | #endif | 1154 | #endif |
1155 | if(ata_disk_is_active()) | 1155 | if(storage_disk_is_active()) |
1156 | ata_spindown(1); | 1156 | storage_spindown(1); |
1157 | } | 1157 | } |
1158 | while(ata_disk_is_active()) | 1158 | while(storage_disk_is_active()) |
1159 | sleep(HZ/10); | 1159 | sleep(HZ/10); |
1160 | 1160 | ||
1161 | #if CONFIG_CODEC != SWCODEC | 1161 | #if CONFIG_CODEC != SWCODEC |
@@ -1166,7 +1166,7 @@ void shutdown_hw(void) | |||
1166 | 1166 | ||
1167 | /* If HD is still active we try to wait for spindown, otherwise the | 1167 | /* If HD is still active we try to wait for spindown, otherwise the |
1168 | shutdown_timeout in power_thread_sleep will force a power off */ | 1168 | shutdown_timeout in power_thread_sleep will force a power off */ |
1169 | while(ata_disk_is_active()) | 1169 | while(storage_disk_is_active()) |
1170 | sleep(HZ/10); | 1170 | sleep(HZ/10); |
1171 | #ifndef IAUDIO_X5 | 1171 | #ifndef IAUDIO_X5 |
1172 | lcd_set_contrast(0); | 1172 | lcd_set_contrast(0); |
diff --git a/firmware/target/arm/ata-nand-telechips.c b/firmware/target/arm/ata-nand-telechips.c index 1c135650f1..4276c10d64 100644 --- a/firmware/target/arm/ata-nand-telechips.c +++ b/firmware/target/arm/ata-nand-telechips.c | |||
@@ -18,7 +18,7 @@ | |||
18 | * KIND, either express or implied. | 18 | * KIND, either express or implied. |
19 | * | 19 | * |
20 | ****************************************************************************/ | 20 | ****************************************************************************/ |
21 | #include "ata.h" | 21 | #include "nand.h" |
22 | #include "ata-nand-target.h" | 22 | #include "ata-nand-target.h" |
23 | #include "system.h" | 23 | #include "system.h" |
24 | #include <string.h> | 24 | #include <string.h> |
@@ -31,6 +31,7 @@ | |||
31 | #include "lcd.h" | 31 | #include "lcd.h" |
32 | #include "font.h" | 32 | #include "font.h" |
33 | #include "button.h" | 33 | #include "button.h" |
34 | #include "storage.h" | ||
34 | #include <sprintf.h> | 35 | #include <sprintf.h> |
35 | 36 | ||
36 | #define SECTOR_SIZE 512 | 37 | #define SECTOR_SIZE 512 |
@@ -43,9 +44,6 @@ int ata_spinup_time = 0; | |||
43 | 44 | ||
44 | long last_disk_activity = -1; | 45 | long last_disk_activity = -1; |
45 | 46 | ||
46 | /* as we aren't actually ata manually fill some fields */ | ||
47 | static unsigned short ata_identify[SECTOR_SIZE/2]; | ||
48 | |||
49 | /** static, private data **/ | 47 | /** static, private data **/ |
50 | static bool initialized = false; | 48 | static bool initialized = false; |
51 | 49 | ||
@@ -662,7 +660,7 @@ static void read_write_cache_segment(int bank, int phys_segment) | |||
662 | } | 660 | } |
663 | 661 | ||
664 | 662 | ||
665 | int ata_read_sectors(IF_MV2(int drive,) unsigned long start, int incount, | 663 | int nand_read_sectors(IF_MV2(int drive,) unsigned long start, int incount, |
666 | void* inbuf) | 664 | void* inbuf) |
667 | { | 665 | { |
668 | #ifdef HAVE_MULTIVOLUME | 666 | #ifdef HAVE_MULTIVOLUME |
@@ -702,7 +700,7 @@ int ata_read_sectors(IF_MV2(int drive,) unsigned long start, int incount, | |||
702 | return 0; | 700 | return 0; |
703 | } | 701 | } |
704 | 702 | ||
705 | int ata_write_sectors(IF_MV2(int drive,) unsigned long start, int count, | 703 | int nand_write_sectors(IF_MV2(int drive,) unsigned long start, int count, |
706 | const void* outbuf) | 704 | const void* outbuf) |
707 | { | 705 | { |
708 | #ifdef HAVE_MULTIVOLUME | 706 | #ifdef HAVE_MULTIVOLUME |
@@ -716,83 +714,21 @@ int ata_write_sectors(IF_MV2(int drive,) unsigned long start, int count, | |||
716 | return -1; | 714 | return -1; |
717 | } | 715 | } |
718 | 716 | ||
719 | void ata_spindown(int seconds) | 717 | void nand_get_info(struct storage_info *info) |
720 | { | ||
721 | /* null */ | ||
722 | (void)seconds; | ||
723 | } | ||
724 | |||
725 | bool ata_disk_is_active(void) | ||
726 | { | ||
727 | /* null */ | ||
728 | return 0; | ||
729 | } | ||
730 | |||
731 | void ata_sleep(void) | ||
732 | { | 718 | { |
733 | /* null */ | ||
734 | } | ||
735 | |||
736 | void ata_spin(void) | ||
737 | { | ||
738 | /* null */ | ||
739 | } | ||
740 | |||
741 | /* Hardware reset protocol as specified in chapter 9.1, ATA spec draft v5 */ | ||
742 | int ata_hard_reset(void) | ||
743 | { | ||
744 | /* null */ | ||
745 | return 0; | ||
746 | } | ||
747 | |||
748 | int ata_soft_reset(void) | ||
749 | { | ||
750 | /* null */ | ||
751 | return 0; | ||
752 | } | ||
753 | |||
754 | void ata_enable(bool on) | ||
755 | { | ||
756 | /* null - flash controller is enabled/disabled as needed. */ | ||
757 | (void)on; | ||
758 | } | ||
759 | |||
760 | static void fill_identify(void) | ||
761 | { | ||
762 | char buf[80]; | ||
763 | unsigned short *wbuf = (unsigned short *) buf; | ||
764 | unsigned long blocks; | ||
765 | int i; | ||
766 | |||
767 | memset(ata_identify, 0, sizeof(ata_identify)); | ||
768 | |||
769 | /* firmware version */ | 719 | /* firmware version */ |
770 | memset(buf, ' ', 8); | 720 | info->revision="0.00"; |
771 | memcpy(buf, "0.00", 4); | ||
772 | 721 | ||
773 | for (i = 0; i < 4; i++) | 722 | info->vendor="Rockbox"; |
774 | ata_identify[23 + i] = betoh16(wbuf[i]); | 723 | info->product="Internal Storage"; |
775 | |||
776 | /* model field, need better name? */ | ||
777 | memset(buf, ' ', 80); | ||
778 | memcpy(buf, "TNFL", 4); | ||
779 | |||
780 | for (i = 0; i < 40; i++) | ||
781 | ata_identify[27 + i] = betoh16(wbuf[i]); | ||
782 | 724 | ||
783 | /* blocks count */ | 725 | /* blocks count */ |
784 | blocks = (pages_per_block * blocks_per_bank / SECTOR_SIZE) | 726 | info->num_sectors = (pages_per_block * blocks_per_bank / SECTOR_SIZE) |
785 | * page_size * total_banks; | 727 | * page_size * total_banks; |
786 | ata_identify[60] = blocks & 0xffff; | 728 | info->sector_size=SECTOR_SIZE; |
787 | ata_identify[61] = blocks >> 16; | ||
788 | |||
789 | /* TODO: discover where is s/n in TNFL */ | ||
790 | for (i = 10; i < 20; i++) { | ||
791 | ata_identify[i] = 0; | ||
792 | } | ||
793 | } | 729 | } |
794 | 730 | ||
795 | int ata_init(void) | 731 | int nand_init(void) |
796 | { | 732 | { |
797 | int i, bank, phys_segment; | 733 | int i, bank, phys_segment; |
798 | unsigned char spare_buf[16]; | 734 | unsigned char spare_buf[16]; |
@@ -909,13 +845,12 @@ int ata_init(void) | |||
909 | } | 845 | } |
910 | #endif | 846 | #endif |
911 | 847 | ||
912 | fill_identify(); | ||
913 | initialized = true; | 848 | initialized = true; |
914 | 849 | ||
915 | return 0; | 850 | return 0; |
916 | } | 851 | } |
917 | 852 | ||
918 | unsigned short* ata_get_identify(void) | 853 | long nand_last_disk_activity(void) |
919 | { | 854 | { |
920 | return ata_identify; | 855 | return last_disk_activity; |
921 | } | 856 | } |
diff --git a/firmware/target/arm/ata-sd-pp.c b/firmware/target/arm/ata-sd-pp.c index b15b3634d8..a12aafc718 100644 --- a/firmware/target/arm/ata-sd-pp.c +++ b/firmware/target/arm/ata-sd-pp.c | |||
@@ -30,6 +30,8 @@ | |||
30 | #include "cpu.h" | 30 | #include "cpu.h" |
31 | #include "panic.h" | 31 | #include "panic.h" |
32 | #include "usb.h" | 32 | #include "usb.h" |
33 | #include "sd.h" | ||
34 | #include "storage.h" | ||
33 | 35 | ||
34 | #define BLOCK_SIZE 512 | 36 | #define BLOCK_SIZE 512 |
35 | #define SECTOR_SIZE 512 | 37 | #define SECTOR_SIZE 512 |
@@ -128,15 +130,13 @@ | |||
128 | 130 | ||
129 | /** global, exported variables **/ | 131 | /** global, exported variables **/ |
130 | #ifdef HAVE_MULTIVOLUME | 132 | #ifdef HAVE_MULTIVOLUME |
131 | #define NUM_VOLUMES 2 | 133 | #define NUM_DRIVES 2 |
132 | #else | 134 | #else |
133 | #define NUM_VOLUMES 1 | 135 | #define NUM_DRIVES 1 |
134 | #endif | 136 | #endif |
135 | 137 | ||
136 | /* for compatibility */ | 138 | /* for compatibility */ |
137 | int ata_spinup_time = 0; | 139 | static long last_disk_activity = -1; |
138 | |||
139 | long last_disk_activity = -1; | ||
140 | 140 | ||
141 | /** static, private data **/ | 141 | /** static, private data **/ |
142 | static bool initialized = false; | 142 | static bool initialized = false; |
@@ -153,7 +153,7 @@ struct sd_card_status | |||
153 | int retry_max; | 153 | int retry_max; |
154 | }; | 154 | }; |
155 | 155 | ||
156 | static struct sd_card_status sd_status[NUM_VOLUMES] = | 156 | static struct sd_card_status sd_status[NUM_DRIVES] = |
157 | { | 157 | { |
158 | { 0, 1 }, | 158 | { 0, 1 }, |
159 | #ifdef HAVE_MULTIVOLUME | 159 | #ifdef HAVE_MULTIVOLUME |
@@ -786,12 +786,12 @@ static void sd_select_device(int card_no) | |||
786 | 786 | ||
787 | /* API Functions */ | 787 | /* API Functions */ |
788 | 788 | ||
789 | static void ata_led(bool onoff) | 789 | static void sd_led(bool onoff) |
790 | { | 790 | { |
791 | led(onoff); | 791 | led(onoff); |
792 | } | 792 | } |
793 | 793 | ||
794 | int ata_read_sectors(IF_MV2(int drive,) unsigned long start, int incount, | 794 | int sd_read_sectors(IF_MV2(int drive,) unsigned long start, int incount, |
795 | void* inbuf) | 795 | void* inbuf) |
796 | { | 796 | { |
797 | #ifndef HAVE_MULTIVOLUME | 797 | #ifndef HAVE_MULTIVOLUME |
@@ -805,14 +805,14 @@ int ata_read_sectors(IF_MV2(int drive,) unsigned long start, int incount, | |||
805 | 805 | ||
806 | mutex_lock(&sd_mtx); | 806 | mutex_lock(&sd_mtx); |
807 | 807 | ||
808 | ata_led(true); | 808 | sd_led(true); |
809 | 809 | ||
810 | ata_read_retry: | 810 | sd_read_retry: |
811 | if (drive != 0 && !card_detect_target()) | 811 | if (drive != 0 && !card_detect_target()) |
812 | { | 812 | { |
813 | /* no external sd-card inserted */ | 813 | /* no external sd-card inserted */ |
814 | ret = -EC_NOCARD; | 814 | ret = -EC_NOCARD; |
815 | goto ata_read_error; | 815 | goto sd_read_error; |
816 | } | 816 | } |
817 | 817 | ||
818 | sd_select_device(drive); | 818 | sd_select_device(drive); |
@@ -820,7 +820,7 @@ ata_read_retry: | |||
820 | if (currcard->initialized < 0) | 820 | if (currcard->initialized < 0) |
821 | { | 821 | { |
822 | ret = currcard->initialized; | 822 | ret = currcard->initialized; |
823 | goto ata_read_error; | 823 | goto sd_read_error; |
824 | } | 824 | } |
825 | 825 | ||
826 | last_disk_activity = current_tick; | 826 | last_disk_activity = current_tick; |
@@ -834,7 +834,7 @@ ata_read_retry: | |||
834 | { | 834 | { |
835 | ret = sd_select_bank(bank); | 835 | ret = sd_select_bank(bank); |
836 | if (ret < 0) | 836 | if (ret < 0) |
837 | goto ata_read_error; | 837 | goto sd_read_error; |
838 | } | 838 | } |
839 | 839 | ||
840 | start -= bank * BLOCKS_PER_BANK; | 840 | start -= bank * BLOCKS_PER_BANK; |
@@ -842,7 +842,7 @@ ata_read_retry: | |||
842 | 842 | ||
843 | ret = sd_wait_for_state(TRAN, EC_TRAN_READ_ENTRY); | 843 | ret = sd_wait_for_state(TRAN, EC_TRAN_READ_ENTRY); |
844 | if (ret < 0) | 844 | if (ret < 0) |
845 | goto ata_read_error; | 845 | goto sd_read_error; |
846 | 846 | ||
847 | BLOCK_COUNT_REG = incount; | 847 | BLOCK_COUNT_REG = incount; |
848 | 848 | ||
@@ -858,7 +858,7 @@ ata_read_retry: | |||
858 | ret = sd_command(READ_MULTIPLE_BLOCK, start * BLOCK_SIZE, NULL, 0x1c25); | 858 | ret = sd_command(READ_MULTIPLE_BLOCK, start * BLOCK_SIZE, NULL, 0x1c25); |
859 | } | 859 | } |
860 | if (ret < 0) | 860 | if (ret < 0) |
861 | goto ata_read_error; | 861 | goto sd_read_error; |
862 | 862 | ||
863 | /* TODO: Don't assume BLOCK_SIZE == SECTOR_SIZE */ | 863 | /* TODO: Don't assume BLOCK_SIZE == SECTOR_SIZE */ |
864 | 864 | ||
@@ -874,38 +874,38 @@ ata_read_retry: | |||
874 | } | 874 | } |
875 | 875 | ||
876 | ret = -EC_FIFO_READ_FULL; | 876 | ret = -EC_FIFO_READ_FULL; |
877 | goto ata_read_error; | 877 | goto sd_read_error; |
878 | } | 878 | } |
879 | 879 | ||
880 | last_disk_activity = current_tick; | 880 | last_disk_activity = current_tick; |
881 | 881 | ||
882 | ret = sd_command(STOP_TRANSMISSION, 0, NULL, 1); | 882 | ret = sd_command(STOP_TRANSMISSION, 0, NULL, 1); |
883 | if (ret < 0) | 883 | if (ret < 0) |
884 | goto ata_read_error; | 884 | goto sd_read_error; |
885 | 885 | ||
886 | ret = sd_wait_for_state(TRAN, EC_TRAN_READ_EXIT); | 886 | ret = sd_wait_for_state(TRAN, EC_TRAN_READ_EXIT); |
887 | if (ret < 0) | 887 | if (ret < 0) |
888 | goto ata_read_error; | 888 | goto sd_read_error; |
889 | 889 | ||
890 | while (1) | 890 | while (1) |
891 | { | 891 | { |
892 | ata_led(false); | 892 | sd_led(false); |
893 | mutex_unlock(&sd_mtx); | 893 | mutex_unlock(&sd_mtx); |
894 | 894 | ||
895 | return ret; | 895 | return ret; |
896 | 896 | ||
897 | ata_read_error: | 897 | sd_read_error: |
898 | if (sd_status[drive].retry < sd_status[drive].retry_max | 898 | if (sd_status[drive].retry < sd_status[drive].retry_max |
899 | && ret != -EC_NOCARD) | 899 | && ret != -EC_NOCARD) |
900 | { | 900 | { |
901 | sd_status[drive].retry++; | 901 | sd_status[drive].retry++; |
902 | currcard->initialized = 0; | 902 | currcard->initialized = 0; |
903 | goto ata_read_retry; | 903 | goto sd_read_retry; |
904 | } | 904 | } |
905 | } | 905 | } |
906 | } | 906 | } |
907 | 907 | ||
908 | int ata_write_sectors(IF_MV2(int drive,) unsigned long start, int count, | 908 | int sd_write_sectors(IF_MV2(int drive,) unsigned long start, int count, |
909 | const void* outbuf) | 909 | const void* outbuf) |
910 | { | 910 | { |
911 | /* Write support is not finished yet */ | 911 | /* Write support is not finished yet */ |
@@ -920,14 +920,14 @@ int ata_write_sectors(IF_MV2(int drive,) unsigned long start, int count, | |||
920 | 920 | ||
921 | mutex_lock(&sd_mtx); | 921 | mutex_lock(&sd_mtx); |
922 | 922 | ||
923 | ata_led(true); | 923 | sd_led(true); |
924 | 924 | ||
925 | ata_write_retry: | 925 | sd_write_retry: |
926 | if (drive != 0 && !card_detect_target()) | 926 | if (drive != 0 && !card_detect_target()) |
927 | { | 927 | { |
928 | /* no external sd-card inserted */ | 928 | /* no external sd-card inserted */ |
929 | ret = -EC_NOCARD; | 929 | ret = -EC_NOCARD; |
930 | goto ata_write_error; | 930 | goto sd_write_error; |
931 | } | 931 | } |
932 | 932 | ||
933 | sd_select_device(drive); | 933 | sd_select_device(drive); |
@@ -935,7 +935,7 @@ ata_write_retry: | |||
935 | if (currcard->initialized < 0) | 935 | if (currcard->initialized < 0) |
936 | { | 936 | { |
937 | ret = currcard->initialized; | 937 | ret = currcard->initialized; |
938 | goto ata_write_error; | 938 | goto sd_write_error; |
939 | } | 939 | } |
940 | 940 | ||
941 | /* Only switch banks with non-SDHC cards */ | 941 | /* Only switch banks with non-SDHC cards */ |
@@ -947,7 +947,7 @@ ata_write_retry: | |||
947 | { | 947 | { |
948 | ret = sd_select_bank(bank); | 948 | ret = sd_select_bank(bank); |
949 | if (ret < 0) | 949 | if (ret < 0) |
950 | goto ata_write_error; | 950 | goto sd_write_error; |
951 | } | 951 | } |
952 | 952 | ||
953 | start -= bank * BLOCKS_PER_BANK; | 953 | start -= bank * BLOCKS_PER_BANK; |
@@ -957,7 +957,7 @@ ata_write_retry: | |||
957 | 957 | ||
958 | ret = sd_wait_for_state(TRAN, EC_TRAN_WRITE_ENTRY); | 958 | ret = sd_wait_for_state(TRAN, EC_TRAN_WRITE_ENTRY); |
959 | if (ret < 0) | 959 | if (ret < 0) |
960 | goto ata_write_error; | 960 | goto sd_write_error; |
961 | 961 | ||
962 | BLOCK_COUNT_REG = count; | 962 | BLOCK_COUNT_REG = count; |
963 | 963 | ||
@@ -973,7 +973,7 @@ ata_write_retry: | |||
973 | ret = sd_command(WRITE_MULTIPLE_BLOCK, start*BLOCK_SIZE, NULL, 0x1c2d); | 973 | ret = sd_command(WRITE_MULTIPLE_BLOCK, start*BLOCK_SIZE, NULL, 0x1c2d); |
974 | } | 974 | } |
975 | if (ret < 0) | 975 | if (ret < 0) |
976 | goto ata_write_error; | 976 | goto sd_write_error; |
977 | 977 | ||
978 | buf_end = outbuf + count * currcard->block_size - 2*FIFO_LEN; | 978 | buf_end = outbuf + count * currcard->block_size - 2*FIFO_LEN; |
979 | 979 | ||
@@ -996,7 +996,7 @@ ata_write_retry: | |||
996 | } | 996 | } |
997 | 997 | ||
998 | ret = -EC_FIFO_WR_EMPTY; | 998 | ret = -EC_FIFO_WR_EMPTY; |
999 | goto ata_write_error; | 999 | goto sd_write_error; |
1000 | } | 1000 | } |
1001 | 1001 | ||
1002 | last_disk_activity = current_tick; | 1002 | last_disk_activity = current_tick; |
@@ -1004,31 +1004,31 @@ ata_write_retry: | |||
1004 | if (!sd_poll_status(DATA_DONE, 0x80000)) | 1004 | if (!sd_poll_status(DATA_DONE, 0x80000)) |
1005 | { | 1005 | { |
1006 | ret = -EC_FIFO_WR_DONE; | 1006 | ret = -EC_FIFO_WR_DONE; |
1007 | goto ata_write_error; | 1007 | goto sd_write_error; |
1008 | } | 1008 | } |
1009 | 1009 | ||
1010 | ret = sd_command(STOP_TRANSMISSION, 0, NULL, 1); | 1010 | ret = sd_command(STOP_TRANSMISSION, 0, NULL, 1); |
1011 | if (ret < 0) | 1011 | if (ret < 0) |
1012 | goto ata_write_error; | 1012 | goto sd_write_error; |
1013 | 1013 | ||
1014 | ret = sd_wait_for_state(TRAN, EC_TRAN_WRITE_EXIT); | 1014 | ret = sd_wait_for_state(TRAN, EC_TRAN_WRITE_EXIT); |
1015 | if (ret < 0) | 1015 | if (ret < 0) |
1016 | goto ata_write_error; | 1016 | goto sd_write_error; |
1017 | 1017 | ||
1018 | while (1) | 1018 | while (1) |
1019 | { | 1019 | { |
1020 | ata_led(false); | 1020 | sd_led(false); |
1021 | mutex_unlock(&sd_mtx); | 1021 | mutex_unlock(&sd_mtx); |
1022 | 1022 | ||
1023 | return ret; | 1023 | return ret; |
1024 | 1024 | ||
1025 | ata_write_error: | 1025 | sd_write_error: |
1026 | if (sd_status[drive].retry < sd_status[drive].retry_max | 1026 | if (sd_status[drive].retry < sd_status[drive].retry_max |
1027 | && ret != -EC_NOCARD) | 1027 | && ret != -EC_NOCARD) |
1028 | { | 1028 | { |
1029 | sd_status[drive].retry++; | 1029 | sd_status[drive].retry++; |
1030 | currcard->initialized = 0; | 1030 | currcard->initialized = 0; |
1031 | goto ata_write_retry; | 1031 | goto sd_write_retry; |
1032 | } | 1032 | } |
1033 | } | 1033 | } |
1034 | } | 1034 | } |
@@ -1088,7 +1088,7 @@ static void sd_thread(void) | |||
1088 | 1088 | ||
1089 | if (!idle_notified) | 1089 | if (!idle_notified) |
1090 | { | 1090 | { |
1091 | call_ata_idle_notifys(false); | 1091 | call_storage_idle_notifys(false); |
1092 | idle_notified = true; | 1092 | idle_notified = true; |
1093 | } | 1093 | } |
1094 | } | 1094 | } |
@@ -1106,37 +1106,7 @@ static void sd_thread(void) | |||
1106 | } | 1106 | } |
1107 | } | 1107 | } |
1108 | 1108 | ||
1109 | 1109 | void sd_enable(bool on) | |
1110 | void ata_spindown(int seconds) | ||
1111 | { | ||
1112 | (void)seconds; | ||
1113 | } | ||
1114 | |||
1115 | bool ata_disk_is_active(void) | ||
1116 | { | ||
1117 | return 0; | ||
1118 | } | ||
1119 | |||
1120 | void ata_sleep(void) | ||
1121 | { | ||
1122 | } | ||
1123 | |||
1124 | void ata_spin(void) | ||
1125 | { | ||
1126 | } | ||
1127 | |||
1128 | /* Hardware reset protocol as specified in chapter 9.1, ATA spec draft v5 */ | ||
1129 | int ata_hard_reset(void) | ||
1130 | { | ||
1131 | return 0; | ||
1132 | } | ||
1133 | |||
1134 | int ata_soft_reset(void) | ||
1135 | { | ||
1136 | return 0; | ||
1137 | } | ||
1138 | |||
1139 | void ata_enable(bool on) | ||
1140 | { | 1110 | { |
1141 | if(on) | 1111 | if(on) |
1142 | { | 1112 | { |
@@ -1170,7 +1140,7 @@ void card_enable_monitoring_target(bool on) | |||
1170 | } | 1140 | } |
1171 | #endif | 1141 | #endif |
1172 | 1142 | ||
1173 | int ata_init(void) | 1143 | int sd_init(void) |
1174 | { | 1144 | { |
1175 | int ret = 0; | 1145 | int ret = 0; |
1176 | 1146 | ||
@@ -1179,7 +1149,7 @@ int ata_init(void) | |||
1179 | 1149 | ||
1180 | mutex_lock(&sd_mtx); | 1150 | mutex_lock(&sd_mtx); |
1181 | 1151 | ||
1182 | ata_led(false); | 1152 | sd_led(false); |
1183 | 1153 | ||
1184 | if (!initialized) | 1154 | if (!initialized) |
1185 | { | 1155 | { |
@@ -1324,3 +1294,46 @@ void microsd_int(void) | |||
1324 | 1294 | ||
1325 | } | 1295 | } |
1326 | #endif /* HAVE_HOTSWAP */ | 1296 | #endif /* HAVE_HOTSWAP */ |
1297 | |||
1298 | long sd_last_disk_activity(void) | ||
1299 | { | ||
1300 | return last_disk_activity; | ||
1301 | } | ||
1302 | |||
1303 | void sd_get_info(IF_MV2(int drive,) struct storage_info *info) | ||
1304 | { | ||
1305 | #ifndef HAVE_MULTIVOLUME | ||
1306 | const int drive=0; | ||
1307 | #endif | ||
1308 | info->sector_size=card_info[drive].block_size; | ||
1309 | info->num_sectors=card_info[drive].numblocks; | ||
1310 | info->vendor="Rockbox"; | ||
1311 | if(drive==0) | ||
1312 | { | ||
1313 | info->product="Internal Storage"; | ||
1314 | } | ||
1315 | else | ||
1316 | { | ||
1317 | info->product="SD Card Slot"; | ||
1318 | } | ||
1319 | info->revision="0.00"; | ||
1320 | } | ||
1321 | |||
1322 | #ifdef HAVE_HOTSWAP | ||
1323 | bool sd_removable(IF_MV_NONVOID(int drive)) | ||
1324 | { | ||
1325 | #ifndef HAVE_MULTIVOLUME | ||
1326 | const int drive=0; | ||
1327 | #endif | ||
1328 | return (drive==1); | ||
1329 | } | ||
1330 | |||
1331 | bool sd_present(IF_MV_NONVOID(int drive)) | ||
1332 | { | ||
1333 | #ifndef HAVE_MULTIVOLUME | ||
1334 | const int drive=0; | ||
1335 | #endif | ||
1336 | return (card_info[drive].initialized && card_info[drive].numblocks > 0); | ||
1337 | } | ||
1338 | #endif | ||
1339 | |||
diff --git a/firmware/usb.c b/firmware/usb.c index 9064987ed1..bfb99e0607 100644 --- a/firmware/usb.c +++ b/firmware/usb.c | |||
@@ -29,7 +29,7 @@ | |||
29 | #include "thread.h" | 29 | #include "thread.h" |
30 | #include "system.h" | 30 | #include "system.h" |
31 | #include "debug.h" | 31 | #include "debug.h" |
32 | #include "ata.h" | 32 | #include "storage.h" |
33 | #include "fat.h" | 33 | #include "fat.h" |
34 | #include "disk.h" | 34 | #include "disk.h" |
35 | #include "panic.h" | 35 | #include "panic.h" |
@@ -86,7 +86,7 @@ static struct event_queue usb_queue; | |||
86 | static int last_usb_status; | 86 | static int last_usb_status; |
87 | static bool usb_monitor_enabled; | 87 | static bool usb_monitor_enabled; |
88 | #ifdef HAVE_USBSTACK | 88 | #ifdef HAVE_USBSTACK |
89 | static bool exclusive_ata_access; | 89 | static bool exclusive_storage_access; |
90 | #endif | 90 | #endif |
91 | 91 | ||
92 | 92 | ||
@@ -105,9 +105,9 @@ static void usb_slave_mode(bool on) | |||
105 | if(on) | 105 | if(on) |
106 | { | 106 | { |
107 | DEBUGF("Entering USB slave mode\n"); | 107 | DEBUGF("Entering USB slave mode\n"); |
108 | ata_soft_reset(); | 108 | storage_soft_reset(); |
109 | ata_init(); | 109 | storage_init(); |
110 | ata_enable(false); | 110 | storage_enable(false); |
111 | usb_enable(true); | 111 | usb_enable(true); |
112 | } | 112 | } |
113 | else | 113 | else |
@@ -119,9 +119,9 @@ static void usb_slave_mode(bool on) | |||
119 | 119 | ||
120 | usb_enable(false); | 120 | usb_enable(false); |
121 | 121 | ||
122 | rc = ata_init(); | 122 | rc = storage_init(); |
123 | if(rc) | 123 | if(rc) |
124 | panicf("ata: %d",rc); | 124 | panicf("storage: %d",rc); |
125 | 125 | ||
126 | rc = disk_mount_all(); | 126 | rc = disk_mount_all(); |
127 | if (rc <= 0) /* no partition */ | 127 | if (rc <= 0) /* no partition */ |
@@ -134,7 +134,7 @@ static void usb_slave_mode(bool on) | |||
134 | static void try_reboot(void) | 134 | static void try_reboot(void) |
135 | { | 135 | { |
136 | #ifdef HAVE_DISK_STORAGE | 136 | #ifdef HAVE_DISK_STORAGE |
137 | ata_sleepnow(); /* Immediately spindown the disk. */ | 137 | storage_sleepnow(); /* Immediately spindown the disk. */ |
138 | sleep(HZ*2); | 138 | sleep(HZ*2); |
139 | #endif | 139 | #endif |
140 | 140 | ||
@@ -262,7 +262,7 @@ static void usb_thread(void) | |||
262 | #ifdef HAVE_PRIORITY_SCHEDULING | 262 | #ifdef HAVE_PRIORITY_SCHEDULING |
263 | thread_set_priority(usb_thread_entry,PRIORITY_REALTIME); | 263 | thread_set_priority(usb_thread_entry,PRIORITY_REALTIME); |
264 | #endif | 264 | #endif |
265 | exclusive_ata_access = true; | 265 | exclusive_storage_access = true; |
266 | 266 | ||
267 | #else | 267 | #else |
268 | usb_slave_mode(true); | 268 | usb_slave_mode(true); |
@@ -310,12 +310,12 @@ static void usb_thread(void) | |||
310 | 310 | ||
311 | usb_state = USB_EXTRACTED; | 311 | usb_state = USB_EXTRACTED; |
312 | #ifdef HAVE_USBSTACK | 312 | #ifdef HAVE_USBSTACK |
313 | if(exclusive_ata_access) | 313 | if(exclusive_storage_access) |
314 | { | 314 | { |
315 | int rc = disk_mount_all(); | 315 | int rc = disk_mount_all(); |
316 | if (rc <= 0) /* no partition */ | 316 | if (rc <= 0) /* no partition */ |
317 | panicf("mount: %d",rc); | 317 | panicf("mount: %d",rc); |
318 | exclusive_ata_access = false; | 318 | exclusive_storage_access = false; |
319 | #endif | 319 | #endif |
320 | /* Tell all threads that we are back in business */ | 320 | /* Tell all threads that we are back in business */ |
321 | num_acks_to_expect = | 321 | num_acks_to_expect = |
@@ -455,7 +455,7 @@ void usb_init(void) | |||
455 | { | 455 | { |
456 | usb_state = USB_EXTRACTED; | 456 | usb_state = USB_EXTRACTED; |
457 | #ifdef HAVE_USBSTACK | 457 | #ifdef HAVE_USBSTACK |
458 | exclusive_ata_access = false; | 458 | exclusive_storage_access = false; |
459 | #endif | 459 | #endif |
460 | usb_monitor_enabled = false; | 460 | usb_monitor_enabled = false; |
461 | countdown = -1; | 461 | countdown = -1; |
@@ -561,7 +561,7 @@ void usb_request_exclusive_ata(void) | |||
561 | * currently the best one. We want to get rid of having to boost the cpu | 561 | * currently the best one. We want to get rid of having to boost the cpu |
562 | * for usb anyway */ | 562 | * for usb anyway */ |
563 | trigger_cpu_boost(); | 563 | trigger_cpu_boost(); |
564 | if(!exclusive_ata_access) { | 564 | if(!exclusive_storage_access) { |
565 | queue_post(&usb_queue, USB_REQUEST_DISK, 0); | 565 | queue_post(&usb_queue, USB_REQUEST_DISK, 0); |
566 | } | 566 | } |
567 | } | 567 | } |
@@ -569,15 +569,15 @@ void usb_request_exclusive_ata(void) | |||
569 | void usb_release_exclusive_ata(void) | 569 | void usb_release_exclusive_ata(void) |
570 | { | 570 | { |
571 | cancel_cpu_boost(); | 571 | cancel_cpu_boost(); |
572 | if(exclusive_ata_access) { | 572 | if(exclusive_storage_access) { |
573 | queue_post(&usb_queue, USB_RELEASE_DISK, 0); | 573 | queue_post(&usb_queue, USB_RELEASE_DISK, 0); |
574 | exclusive_ata_access = false; | 574 | exclusive_storage_access = false; |
575 | } | 575 | } |
576 | } | 576 | } |
577 | 577 | ||
578 | bool usb_exclusive_ata(void) | 578 | bool usb_exclusive_ata(void) |
579 | { | 579 | { |
580 | return exclusive_ata_access; | 580 | return exclusive_storage_access; |
581 | } | 581 | } |
582 | #endif | 582 | #endif |
583 | 583 | ||
diff --git a/firmware/usbstack/usb_core.c b/firmware/usbstack/usb_core.c index fa0ff5ea04..7724049415 100644 --- a/firmware/usbstack/usb_core.c +++ b/firmware/usbstack/usb_core.c | |||
@@ -50,7 +50,7 @@ | |||
50 | #include "as3514.h" | 50 | #include "as3514.h" |
51 | #endif | 51 | #endif |
52 | 52 | ||
53 | #if !defined(HAVE_AS3514) && !defined(IPOD_ARCH) | 53 | #if !defined(HAVE_AS3514) && !defined(IPOD_ARCH) && (CONFIG_STORAGE & STORAGE_ATA) |
54 | #include "ata.h" | 54 | #include "ata.h" |
55 | #endif | 55 | #endif |
56 | 56 | ||
@@ -281,7 +281,7 @@ static void set_serial_descriptor(void) | |||
281 | } | 281 | } |
282 | usb_string_iSerial.bLength=68; | 282 | usb_string_iSerial.bLength=68; |
283 | } | 283 | } |
284 | #else | 284 | #elif (CONFIG_STORAGE & STORAGE_ATA) |
285 | /* If we don't know the device serial number, use the one | 285 | /* If we don't know the device serial number, use the one |
286 | * from the disk */ | 286 | * from the disk */ |
287 | static void set_serial_descriptor(void) | 287 | static void set_serial_descriptor(void) |
@@ -300,6 +300,8 @@ static void set_serial_descriptor(void) | |||
300 | } | 300 | } |
301 | usb_string_iSerial.bLength=84; | 301 | usb_string_iSerial.bLength=84; |
302 | } | 302 | } |
303 | #else | ||
304 | #error No set_serial_descriptor() implementation for this target | ||
303 | #endif | 305 | #endif |
304 | 306 | ||
305 | void usb_core_init(void) | 307 | void usb_core_init(void) |
diff --git a/firmware/usbstack/usb_storage.c b/firmware/usbstack/usb_storage.c index 198ff46a56..24ac00138d 100644 --- a/firmware/usbstack/usb_storage.c +++ b/firmware/usbstack/usb_storage.c | |||
@@ -24,7 +24,7 @@ | |||
24 | #include "usb_drv.h" | 24 | #include "usb_drv.h" |
25 | //#define LOGF_ENABLE | 25 | //#define LOGF_ENABLE |
26 | #include "logf.h" | 26 | #include "logf.h" |
27 | #include "ata.h" | 27 | #include "storage.h" |
28 | #include "hotswap.h" | 28 | #include "hotswap.h" |
29 | #include "disk.h" | 29 | #include "disk.h" |
30 | /* Needed to get at the audio buffer */ | 30 | /* Needed to get at the audio buffer */ |
@@ -36,7 +36,7 @@ | |||
36 | 36 | ||
37 | /* The SD card driver on Sansa c200 and e200 can cause write corruption, | 37 | /* The SD card driver on Sansa c200 and e200 can cause write corruption, |
38 | * often triggered by simultaneous USB activity. This can be largely avoided | 38 | * often triggered by simultaneous USB activity. This can be largely avoided |
39 | * by not overlapping ata_write_sector() with USB transfers. This does reduce | 39 | * by not overlapping storage_write_sector() with USB transfers. This does reduce |
40 | * write performance, so we only do it for the affected DAPs | 40 | * write performance, so we only do it for the affected DAPs |
41 | */ | 41 | */ |
42 | #if (CONFIG_STORAGE & STORAGE_SD) | 42 | #if (CONFIG_STORAGE & STORAGE_SD) |
@@ -147,10 +147,8 @@ struct inquiry_data { | |||
147 | struct report_lun_data { | 147 | struct report_lun_data { |
148 | unsigned int lun_list_length; | 148 | unsigned int lun_list_length; |
149 | unsigned int reserved1; | 149 | unsigned int reserved1; |
150 | unsigned char lun0[8]; | 150 | // TODO this should be cleaned up with the VOLUMES vs DRIVES mess |
151 | #ifdef HAVE_HOTSWAP | 151 | unsigned char luns[NUM_VOLUMES][8]; |
152 | unsigned char lun1[8]; | ||
153 | #endif | ||
154 | } __attribute__ ((packed)); | 152 | } __attribute__ ((packed)); |
155 | 153 | ||
156 | struct sense_data { | 154 | struct sense_data { |
@@ -263,7 +261,7 @@ static void send_command_result(void *data,int size); | |||
263 | static void send_command_failed_result(void); | 261 | static void send_command_failed_result(void); |
264 | static void send_block_data(void *data,int size); | 262 | static void send_block_data(void *data,int size); |
265 | static void receive_block_data(void *data,int size); | 263 | static void receive_block_data(void *data,int size); |
266 | static void identify2inquiry(int lun); | 264 | static void fill_inquiry(IF_MV_NONVOID(int lun)); |
267 | static void send_and_read_next(void); | 265 | static void send_and_read_next(void); |
268 | static bool ejected[NUM_VOLUMES]; | 266 | static bool ejected[NUM_VOLUMES]; |
269 | 267 | ||
@@ -289,7 +287,7 @@ static bool check_disk_present(IF_MV_NONVOID(int volume)) | |||
289 | return true; | 287 | return true; |
290 | #else | 288 | #else |
291 | unsigned char sector[512]; | 289 | unsigned char sector[512]; |
292 | return ata_read_sectors(IF_MV2(volume,)0,1,sector) == 0; | 290 | return storage_read_sectors(IF_MV2(volume,)0,1,sector) == 0; |
293 | #endif | 291 | #endif |
294 | } | 292 | } |
295 | 293 | ||
@@ -460,7 +458,7 @@ void usb_storage_transfer_complete(int ep,int dir,int status,int length) | |||
460 | cur_cmd.data[cur_cmd.data_select], | 458 | cur_cmd.data[cur_cmd.data_select], |
461 | MIN(BUFFER_SIZE/SECTOR_SIZE, cur_cmd.count)*SECTOR_SIZE); | 459 | MIN(BUFFER_SIZE/SECTOR_SIZE, cur_cmd.count)*SECTOR_SIZE); |
462 | #else | 460 | #else |
463 | int result = ata_write_sectors(IF_MV2(cur_cmd.lun,) | 461 | int result = storage_write_sectors(IF_MV2(cur_cmd.lun,) |
464 | cur_cmd.sector, | 462 | cur_cmd.sector, |
465 | MIN(BUFFER_SIZE/SECTOR_SIZE, | 463 | MIN(BUFFER_SIZE/SECTOR_SIZE, |
466 | cur_cmd.count), | 464 | cur_cmd.count), |
@@ -639,7 +637,7 @@ static void send_and_read_next(void) | |||
639 | ramdisk_buffer + cur_cmd.sector*SECTOR_SIZE, | 637 | ramdisk_buffer + cur_cmd.sector*SECTOR_SIZE, |
640 | MIN(BUFFER_SIZE/SECTOR_SIZE, cur_cmd.count)*SECTOR_SIZE); | 638 | MIN(BUFFER_SIZE/SECTOR_SIZE, cur_cmd.count)*SECTOR_SIZE); |
641 | #else | 639 | #else |
642 | cur_cmd.last_result = ata_read_sectors(IF_MV2(cur_cmd.lun,) | 640 | cur_cmd.last_result = storage_read_sectors(IF_MV2(cur_cmd.lun,) |
643 | cur_cmd.sector, | 641 | cur_cmd.sector, |
644 | MIN(BUFFER_SIZE/SECTOR_SIZE, | 642 | MIN(BUFFER_SIZE/SECTOR_SIZE, |
645 | cur_cmd.count), | 643 | cur_cmd.count), |
@@ -654,6 +652,7 @@ static void handle_scsi(struct command_block_wrapper* cbw) | |||
654 | /* USB Mass Storage assumes LBA capability. | 652 | /* USB Mass Storage assumes LBA capability. |
655 | TODO: support 48-bit LBA */ | 653 | TODO: support 48-bit LBA */ |
656 | 654 | ||
655 | struct storage_info info; | ||
657 | unsigned int length = cbw->data_transfer_length; | 656 | unsigned int length = cbw->data_transfer_length; |
658 | unsigned int block_size = 0; | 657 | unsigned int block_size = 0; |
659 | unsigned int block_count = 0; | 658 | unsigned int block_count = 0; |
@@ -664,25 +663,20 @@ static void handle_scsi(struct command_block_wrapper* cbw) | |||
664 | unsigned char lun = cbw->lun; | 663 | unsigned char lun = cbw->lun; |
665 | #endif | 664 | #endif |
666 | unsigned int block_size_mult = 1; | 665 | unsigned int block_size_mult = 1; |
666 | storage_get_info(IF_MV2(lun,)&info); | ||
667 | #ifdef USB_USE_RAMDISK | 667 | #ifdef USB_USE_RAMDISK |
668 | block_size = SECTOR_SIZE; | 668 | block_size = SECTOR_SIZE; |
669 | block_count = RAMDISK_SIZE; | 669 | block_count = RAMDISK_SIZE; |
670 | #else | 670 | #else |
671 | #if (CONFIG_STORAGE & STORAGE_SD) || defined(HAVE_HOTSWAP) | 671 | block_size=info.sector_size; |
672 | tCardInfo* cinfo = card_get_info(lun); | 672 | block_count=info.num_sectors; |
673 | if(cinfo->initialized && cinfo->numblocks > 0) { | 673 | #endif |
674 | block_size = cinfo->blocksize; | 674 | |
675 | block_count = cinfo->numblocks; | 675 | #ifdef HAVE_HOTSWAP |
676 | } | 676 | if(storage_removable(IF_MV(lun)) && !storage_present(IF_MV(lun))) { |
677 | else { | ||
678 | ejected[lun] = true; | 677 | ejected[lun] = true; |
679 | try_release_ata(); | 678 | try_release_ata(); |
680 | } | 679 | } |
681 | #else | ||
682 | unsigned short* identify = ata_get_identify(); | ||
683 | block_size = SECTOR_SIZE; | ||
684 | block_count = (identify[61] << 16 | identify[60]); | ||
685 | #endif | ||
686 | #endif | 680 | #endif |
687 | 681 | ||
688 | if(ejected[lun]) | 682 | if(ejected[lun]) |
@@ -719,19 +713,22 @@ static void handle_scsi(struct command_block_wrapper* cbw) | |||
719 | case SCSI_REPORT_LUNS: { | 713 | case SCSI_REPORT_LUNS: { |
720 | logf("scsi inquiry %d",lun); | 714 | logf("scsi inquiry %d",lun); |
721 | int allocation_length=0; | 715 | int allocation_length=0; |
716 | int i; | ||
722 | allocation_length|=(cbw->command_block[6]<<24); | 717 | allocation_length|=(cbw->command_block[6]<<24); |
723 | allocation_length|=(cbw->command_block[7]<<16); | 718 | allocation_length|=(cbw->command_block[7]<<16); |
724 | allocation_length|=(cbw->command_block[8]<<8); | 719 | allocation_length|=(cbw->command_block[8]<<8); |
725 | allocation_length|=(cbw->command_block[9]); | 720 | allocation_length|=(cbw->command_block[9]); |
726 | memset(tb.lun_data,0,sizeof(struct report_lun_data)); | 721 | memset(tb.lun_data,0,sizeof(struct report_lun_data)); |
722 | tb.lun_data->lun_list_length=htobe32(8*NUM_VOLUMES); | ||
723 | for(i=0;i<NUM_VOLUMES;i++) | ||
724 | { | ||
727 | #ifdef HAVE_HOTSWAP | 725 | #ifdef HAVE_HOTSWAP |
728 | tb.lun_data->lun_list_length=htobe32(16); | 726 | if(storage_removable(IF_MV(i))) |
729 | tb.lun_data->lun1[1]=1; | 727 | tb.lun_data->luns[i][1]=1; |
730 | #else | 728 | else |
731 | tb.lun_data->lun_list_length=htobe32(8); | ||
732 | #endif | 729 | #endif |
733 | tb.lun_data->lun0[1]=0; | 730 | tb.lun_data->luns[i][1]=0; |
734 | 731 | } | |
735 | send_command_result(tb.lun_data, | 732 | send_command_result(tb.lun_data, |
736 | MIN(sizeof(struct report_lun_data), length)); | 733 | MIN(sizeof(struct report_lun_data), length)); |
737 | break; | 734 | break; |
@@ -739,7 +736,7 @@ static void handle_scsi(struct command_block_wrapper* cbw) | |||
739 | 736 | ||
740 | case SCSI_INQUIRY: | 737 | case SCSI_INQUIRY: |
741 | logf("scsi inquiry %d",lun); | 738 | logf("scsi inquiry %d",lun); |
742 | identify2inquiry(lun); | 739 | fill_inquiry(IF_MV(lun)); |
743 | length = MIN(length, cbw->command_block[4]); | 740 | length = MIN(length, cbw->command_block[4]); |
744 | send_command_result(tb.inquiry, | 741 | send_command_result(tb.inquiry, |
745 | MIN(sizeof(struct inquiry_data), length)); | 742 | MIN(sizeof(struct inquiry_data), length)); |
@@ -975,7 +972,7 @@ static void handle_scsi(struct command_block_wrapper* cbw) | |||
975 | ramdisk_buffer + cur_cmd.sector*SECTOR_SIZE, | 972 | ramdisk_buffer + cur_cmd.sector*SECTOR_SIZE, |
976 | MIN(BUFFER_SIZE/SECTOR_SIZE, cur_cmd.count)*SECTOR_SIZE); | 973 | MIN(BUFFER_SIZE/SECTOR_SIZE, cur_cmd.count)*SECTOR_SIZE); |
977 | #else | 974 | #else |
978 | cur_cmd.last_result = ata_read_sectors(IF_MV2(cur_cmd.lun,) | 975 | cur_cmd.last_result = storage_read_sectors(IF_MV2(cur_cmd.lun,) |
979 | cur_cmd.sector, | 976 | cur_cmd.sector, |
980 | MIN(BUFFER_SIZE/SECTOR_SIZE, | 977 | MIN(BUFFER_SIZE/SECTOR_SIZE, |
981 | cur_cmd.count), | 978 | cur_cmd.count), |
@@ -1072,46 +1069,30 @@ static void send_csw(int status) | |||
1072 | } | 1069 | } |
1073 | } | 1070 | } |
1074 | 1071 | ||
1075 | /* convert ATA IDENTIFY to SCSI INQUIRY */ | 1072 | static void copy_padded(char *dest, char *src, int len) |
1076 | static void identify2inquiry(int lun) | ||
1077 | { | 1073 | { |
1078 | #ifdef HAVE_FLASH_STORAGE | 1074 | int i=0; |
1079 | if(lun==0) { | 1075 | while(src[i]!=0 && i<len) |
1080 | memcpy(&tb.inquiry->VendorId,"Rockbox ",8); | 1076 | { |
1081 | memcpy(&tb.inquiry->ProductId,"Internal Storage",16); | 1077 | dest[i]=src[i]; |
1082 | memcpy(&tb.inquiry->ProductRevisionLevel,"0.00",4); | 1078 | i++; |
1083 | } | 1079 | } |
1084 | else { | 1080 | while(i<len) |
1085 | memcpy(&tb.inquiry->VendorId,"Rockbox ",8); | 1081 | { |
1086 | memcpy(&tb.inquiry->ProductId,"SD Card Slot ",16); | 1082 | dest[i]=' '; |
1087 | memcpy(&tb.inquiry->ProductRevisionLevel,"0.00",4); | 1083 | i++; |
1088 | } | 1084 | } |
1089 | #else | 1085 | } |
1090 | unsigned int i; | ||
1091 | unsigned short* dest; | ||
1092 | unsigned short* src; | ||
1093 | unsigned short* identify = ata_get_identify(); | ||
1094 | (void)lun; | ||
1095 | memset(tb.inquiry, 0, sizeof(struct inquiry_data)); | ||
1096 | |||
1097 | #if 0 | ||
1098 | if (identify[82] & 4) | ||
1099 | tb.inquiry->DeviceTypeModifier = DEVICE_REMOVABLE; | ||
1100 | #endif | ||
1101 | 1086 | ||
1102 | /* ATA only has a 'model' field, so we copy the | 1087 | /* build SCSI INQUIRY */ |
1103 | first 8 bytes to 'vendor' and the rest to 'product' (they are | 1088 | static void fill_inquiry(IF_MV_NONVOID(int lun)) |
1104 | consecutive in the inquiry struct) */ | 1089 | { |
1105 | src = (unsigned short*)&identify[27]; | 1090 | memset(tb.inquiry, 0, sizeof(struct inquiry_data)); |
1106 | dest = (unsigned short*)&tb.inquiry->VendorId; | 1091 | struct storage_info info; |
1107 | for (i=0;i<12;i++) | 1092 | storage_get_info(IF_MV2(lun,)&info); |
1108 | dest[i] = htobe16(src[i]); | 1093 | copy_padded(tb.inquiry->VendorId,info.vendor,sizeof(tb.inquiry->VendorId)); |
1109 | 1094 | copy_padded(tb.inquiry->ProductId,info.product,sizeof(tb.inquiry->ProductId)); | |
1110 | src = (unsigned short*)&identify[23]; | 1095 | copy_padded(tb.inquiry->ProductRevisionLevel,info.revision,sizeof(tb.inquiry->ProductRevisionLevel)); |
1111 | dest = (unsigned short*)&tb.inquiry->ProductRevisionLevel; | ||
1112 | for (i=0;i<2;i++) | ||
1113 | dest[i] = htobe16(src[i]); | ||
1114 | #endif | ||
1115 | 1096 | ||
1116 | tb.inquiry->DeviceType = DIRECT_ACCESS_DEVICE; | 1097 | tb.inquiry->DeviceType = DIRECT_ACCESS_DEVICE; |
1117 | tb.inquiry->AdditionalLength = 0x1f; | 1098 | tb.inquiry->AdditionalLength = 0x1f; |
@@ -1119,14 +1100,6 @@ static void identify2inquiry(int lun) | |||
1119 | tb.inquiry->Versions = 4; /* SPC-2 */ | 1100 | tb.inquiry->Versions = 4; /* SPC-2 */ |
1120 | tb.inquiry->Format = 2; /* SPC-2/3 inquiry format */ | 1101 | tb.inquiry->Format = 2; /* SPC-2/3 inquiry format */ |
1121 | 1102 | ||
1122 | #if 0 | ||
1123 | #ifdef HAVE_HOTSWAP | ||
1124 | if(lun>0) | ||
1125 | tb.inquiry->DeviceTypeModifier = DEVICE_REMOVABLE; | ||
1126 | #endif | ||
1127 | #endif | ||
1128 | /* Mac OSX 10.5 doesn't like this driver if DEVICE_REMOVABLE is not set. | ||
1129 | TODO : this can probably be solved by providing caching mode page */ | ||
1130 | #ifdef TOSHIBA_GIGABEAT_S | 1103 | #ifdef TOSHIBA_GIGABEAT_S |
1131 | tb.inquiry->DeviceTypeModifier = 0; | 1104 | tb.inquiry->DeviceTypeModifier = 0; |
1132 | #else | 1105 | #else |
diff --git a/flash/bootbox/main.c b/flash/bootbox/main.c index 2bd3fea115..f53a5edda2 100644 --- a/flash/bootbox/main.c +++ b/flash/bootbox/main.c | |||
@@ -31,7 +31,7 @@ | |||
31 | #include "lcd.h" | 31 | #include "lcd.h" |
32 | #include "kernel.h" | 32 | #include "kernel.h" |
33 | #include "thread.h" | 33 | #include "thread.h" |
34 | #include "ata.h" | 34 | #include "storage.h" |
35 | #include "disk.h" | 35 | #include "disk.h" |
36 | #include "font.h" | 36 | #include "font.h" |
37 | #include "adc.h" | 37 | #include "adc.h" |
@@ -168,7 +168,7 @@ void main(void) | |||
168 | } | 168 | } |
169 | #endif | 169 | #endif |
170 | 170 | ||
171 | rc = ata_init(); | 171 | rc = storage_init(); |
172 | if(rc) | 172 | if(rc) |
173 | { | 173 | { |
174 | #ifdef HAVE_LCD_BITMAP | 174 | #ifdef HAVE_LCD_BITMAP |
@@ -179,7 +179,7 @@ void main(void) | |||
179 | lcd_update(); | 179 | lcd_update(); |
180 | while(!(button_get(true) & BUTTON_REL)); | 180 | while(!(button_get(true) & BUTTON_REL)); |
181 | #endif | 181 | #endif |
182 | panicf("ata: %d", rc); | 182 | panicf("storage: %d", rc); |
183 | } | 183 | } |
184 | 184 | ||
185 | usb_start_monitoring(); | 185 | usb_start_monitoring(); |