diff --git a/apps/buffering.c b/apps/buffering.c index d963a98..534a82d 100644 --- a/apps/buffering.c +++ b/apps/buffering.c @@ -26,7 +26,7 @@ #include #include "buffering.h" -#include "ata.h" +#include "storage.h" #include "system.h" #include "thread.h" #include "file.h" @@ -832,7 +832,7 @@ static bool fill_buffer(void) { /* only spin the disk down if the filling wasn't interrupted by an event arriving in the queue. */ - ata_sleep(); + storage_sleep(); return false; } } @@ -1408,7 +1408,7 @@ void buffering_thread(void) * for simplicity until its done right */ #if MEM > 8 /* If the disk is spinning, take advantage by filling the buffer */ - else if (ata_disk_is_active() && queue_empty(&buffering_queue)) + else if (storage_disk_is_active() && queue_empty(&buffering_queue)) { if (num_handles > 0 && data_counters.useful <= high_watermark) send_event(BUFFER_EVENT_BUFFER_LOW, 0); diff --git a/apps/codecs.c b/apps/codecs.c index 8e9e55a..6d5fe48 100644 --- a/apps/codecs.c +++ b/apps/codecs.c @@ -43,7 +43,7 @@ #include "buffering.h" #include "mp3_playback.h" #include "backlight.h" -#include "ata.h" +#include "storage.h" #include "talk.h" #include "mp3data.h" #include "powermgmt.h" diff --git a/apps/debug_menu.c b/apps/debug_menu.c index ad19c3a..69284f0 100644 --- a/apps/debug_menu.c +++ b/apps/debug_menu.c @@ -59,11 +59,11 @@ #include "power.h" #include "usb.h" #include "rtc.h" -#include "ata.h" +#include "storage.h" #include "fat.h" #include "mas.h" #include "eeprom_24cxx.h" -#if defined(HAVE_MMC) || defined(HAVE_ATA_SD) +#if defined(HAVE_STORAGE_MMC) || defined(HAVE_STORAGE_SD) #include "hotswap.h" #endif #if CONFIG_TUNER @@ -1728,8 +1728,8 @@ static bool view_battery(void) #endif #ifndef SIMULATOR -#if defined(HAVE_MMC) || defined(HAVE_ATA_SD) -#if defined(HAVE_MMC) +#if defined(HAVE_STORAGE_MMC) || defined(HAVE_STORAGE_SD) +#if defined(HAVE_STORAGE_MMC) #define CARDTYPE "MMC" #else #define CARDTYPE "microSD" @@ -1810,7 +1810,7 @@ static int disk_callback(int btn, struct gui_synclist *lists) { simplelist_addline(SIMPLELIST_ADD_LINE, "Not Found!"); } -#ifndef HAVE_MMC +#ifndef HAVE_STORAGE_MMC else /* card->initialized < 0 */ { simplelist_addline(SIMPLELIST_ADD_LINE, "Init Error! (%d)", card->initialized); @@ -1824,13 +1824,13 @@ static int disk_callback(int btn, struct gui_synclist *lists) } return btn; } -#else /* !defined(HAVE_MMC) && !defined(HAVE_ATA_SD) */ +#else /* !defined(HAVE_STORAGE_MMC) && !defined(HAVE_STORAGE_SD) */ static int disk_callback(int btn, struct gui_synclist *lists) { (void)lists; int i; char buf[128]; - unsigned short* identify_info = ata_get_identify(); + unsigned short* identify_info = storage_get_identify(); bool timing_info_present = false; (void)btn; @@ -1858,7 +1858,7 @@ static int disk_callback(int btn, struct gui_synclist *lists) simplelist_addline(SIMPLELIST_ADD_LINE, "Free: %ld MB", free / 1024); simplelist_addline(SIMPLELIST_ADD_LINE, - "Spinup time: %d ms", ata_spinup_time * (1000/HZ)); + "Spinup time: %d ms", storage_spinup_time() * (1000/HZ)); i = identify_info[83] & (1<<3); simplelist_addline(SIMPLELIST_ADD_LINE, "Power mgmt: %s", i ? "enabled" : "unsupported"); @@ -1950,21 +1950,21 @@ static bool dbg_identify_info(void) if(fd >= 0) { #ifdef ROCKBOX_LITTLE_ENDIAN - ecwrite(fd, ata_get_identify(), SECTOR_SIZE/2, "s", true); + ecwrite(fd, storage_get_identify(), SECTOR_SIZE/2, "s", true); #else - write(fd, ata_get_identify(), SECTOR_SIZE); + write(fd, storage_get_identify(), SECTOR_SIZE); #endif close(fd); } return false; } -#endif /* !defined(HAVE_MMC) && !defined(HAVE_ATA_SD) */ +#endif /* !defined(HAVE_STORAGE_MMC) && !defined(HAVE_STORAGE_SD) */ static bool dbg_disk_info(void) { struct simplelist_info info; simplelist_info_init(&info, "Disk Info", 1, NULL); -#if defined(HAVE_MMC) || defined(HAVE_ATA_SD) +#if defined(HAVE_STORAGE_MMC) || defined(HAVE_STORAGE_SD) char title[16]; int card = 0; info.callback_data = (void*)&card; @@ -2144,7 +2144,7 @@ static bool dbg_save_roms(void) return false; } -#elif defined(CPU_PP) && !defined(HAVE_ATA_SD) +#elif defined(CPU_PP) && !defined(HAVE_STORAGE_SD) static bool dbg_save_roms(void) { int fd; @@ -2465,7 +2465,7 @@ struct the_menu_item { }; static const struct the_menu_item menuitems[] = { #if CONFIG_CPU == SH7034 || defined(CPU_COLDFIRE) || \ - (defined(CPU_PP) && !defined(HAVE_ATA_SD)) + (defined(CPU_PP) && !defined(HAVE_STORAGE_SD)) { "Dump ROM contents", dbg_save_roms }, #endif #if CONFIG_CPU == SH7034 || defined(CPU_COLDFIRE) || defined(CPU_PP) \ @@ -2502,7 +2502,7 @@ static const struct the_menu_item menuitems[] = { #endif #ifndef SIMULATOR { "View disk info", dbg_disk_info }, -#if !defined(HAVE_MMC) && !defined(HAVE_ATA_SD) +#if !defined(HAVE_STORAGE_MMC) && !defined(HAVE_STORAGE_SD) { "Dump ATA identify info", dbg_identify_info}, #endif #endif diff --git a/apps/gui/gwps.c b/apps/gui/gwps.c index 4d50740..9b6d6b5 100644 --- a/apps/gui/gwps.c +++ b/apps/gui/gwps.c @@ -39,7 +39,7 @@ #include "audio.h" #include "usb.h" #include "status.h" -#include "ata.h" +#include "storage.h" #include "screens.h" #include "playlist.h" #ifdef HAVE_LCD_BITMAP @@ -184,7 +184,7 @@ long gui_wps_show(void) if (wps_state.paused) { settings_save(); #if !defined(HAVE_RTC_RAM) && !defined(HAVE_SW_POWEROFF) - call_ata_idle_notifys(true); + call_storage_idle_notifys(true); #endif } } @@ -322,7 +322,7 @@ long gui_wps_show(void) audio_pause(); settings_save(); #if !defined(HAVE_RTC_RAM) && !defined(HAVE_SW_POWEROFF) - call_ata_idle_notifys(true); /* make sure resume info is saved */ + call_storage_idle_notifys(true); /* make sure resume info is saved */ #endif } break; @@ -701,7 +701,7 @@ long gui_wps_show(void) } if ( button ) - ata_spin(); + storage_spin(); } return GO_TO_ROOT; /* unreachable - just to reduce compiler warnings */ } diff --git a/apps/main.c b/apps/main.c index bacaa51..9942f35 100644 --- a/apps/main.c +++ b/apps/main.c @@ -20,7 +20,7 @@ ****************************************************************************/ #include "config.h" -#include "ata.h" +#include "storage.h" #include "disk.h" #include "fat.h" #include "lcd.h" @@ -89,7 +89,7 @@ #if CONFIG_TUNER #include "radio.h" #endif -#ifdef HAVE_MMC +#ifdef HAVE_STORAGE_MMC #include "ata_mmc.h" #endif @@ -289,7 +289,7 @@ static void init(void) #endif /* Must be done before any code uses the multi-screen APi */ gui_syncstatusbar_init(&statusbars); - ata_init(); + storage_init(); settings_reset(); settings_load(SETTINGS_ALL); gui_sync_wps_init(); @@ -377,7 +377,7 @@ static void init(void) #ifdef DEBUG debug_init(); #else -#if !defined(HAVE_FMADC) && !defined(HAVE_MMC) +#if !defined(HAVE_FMADC) && !defined(HAVE_STORAGE_MMC) serial_setup(); #endif #endif @@ -427,7 +427,7 @@ static void init(void) } #endif - rc = ata_init(); + rc = storage_init(); if(rc) { #ifdef HAVE_LCD_BITMAP @@ -456,7 +456,7 @@ static void init(void) #endif /* enter USB mode early, before trying to mount */ if (button_get_w_tmo(HZ/10) == SYS_USB_CONNECTED) -#ifdef HAVE_MMC +#ifdef HAVE_STORAGE_MMC if (!mmc_touched() || (mmc_remove_request() == SYS_HOTSWAP_EXTRACTED)) #endif diff --git a/apps/misc.c b/apps/misc.c index cd59dbc..cab80f3 100644 --- a/apps/misc.c +++ b/apps/misc.c @@ -46,7 +46,7 @@ #include "audio.h" #include "mp3_playback.h" #include "settings.h" -#include "ata.h" +#include "storage.h" #include "ata_idle_notify.h" #include "kernel.h" #include "power.h" @@ -61,7 +61,7 @@ #include "playlist.h" #include "yesno.h" -#ifdef HAVE_MMC +#ifdef HAVE_STORAGE_MMC #include "ata_mmc.h" #endif #include "tree.h" @@ -621,7 +621,7 @@ bool settings_parseline(char* line, char** name, char** value) static void system_flush(void) { tree_flush(); - call_ata_idle_notifys(true); /*doesnt work on usb and shutdown from ata thread */ + call_storage_idle_notifys(true); /*doesnt work on usb and shutdown from ata thread */ } static void system_restore(void) @@ -635,7 +635,7 @@ static bool clean_shutdown(void (*callback)(void *), void *parameter) (void)callback; (void)parameter; bookmark_autobookmark(); - call_ata_idle_notifys(true); + call_storage_idle_notifys(true); exit(0); #else long msg_id = -1; @@ -910,7 +910,7 @@ long default_event_handler_ex(long event, void (*callback)(void *), void *parame case SYS_USB_CONNECTED: if (callback != NULL) callback(parameter); -#ifdef HAVE_MMC +#ifdef HAVE_STORAGE_MMC if (!mmc_touched() || (mmc_remove_request() == SYS_HOTSWAP_EXTRACTED)) #endif diff --git a/apps/mpeg.c b/apps/mpeg.c index 713915d..436cc74 100644 --- a/apps/mpeg.c +++ b/apps/mpeg.c @@ -29,7 +29,7 @@ #include "metadata.h" #include "mpeg.h" #include "audio.h" -#include "ata.h" +#include "storage.h" #include "string.h" #include #include "thread.h" @@ -509,7 +509,7 @@ static void generate_postbuffer_events(void) static void recalculate_watermark(int bitrate) { int bytes_per_sec; - int time = ata_spinup_time; + int time = storage_spinup_time; /* A bitrate of 0 probably means empty VBR header. We play safe and set a high threshold */ @@ -1589,7 +1589,7 @@ static void mpeg_thread(void) DEBUGF("0\n"); filling = false; generate_postbuffer_events(); - ata_sleep(); + storage_sleep(); break; } @@ -1603,7 +1603,7 @@ static void mpeg_thread(void) /* Don't read more than until the end of the buffer */ amount_to_read = MIN(audiobuflen - audiobuf_write, amount_to_read); -#ifdef HAVE_MMC /* MMC is slow, so don't read too large chunks */ +#ifdef HAVE_STORAGE_MMC /* MMC is slow, so don't read too large chunks */ amount_to_read = MIN(0x40000, amount_to_read); #elif MEM == 8 amount_to_read = MIN(0x100000, amount_to_read); @@ -1912,7 +1912,7 @@ static void mpeg_thread(void) amount_to_save = MIN(amount_to_save, audiobuflen - audiobuf_read); -#ifdef HAVE_MMC /* MMC is slow, so don't save too large chunks at once */ +#ifdef HAVE_STORAGE_MMC /* MMC is slow, so don't save too large chunks at once */ amount_to_save = MIN(0x40000, amount_to_save); #elif MEM == 8 amount_to_save = MIN(0x100000, amount_to_save); @@ -1945,7 +1945,7 @@ static void mpeg_thread(void) rc = fsync(mpeg_file); if (rc < 0) panicf("rec fls: %d", rc); - ata_sleep(); + storage_sleep(); break; case NEW_FILE: @@ -1955,7 +1955,7 @@ static void mpeg_thread(void) panicf("rec cls: %d", rc); mpeg_file = -1; update_header(); - ata_sleep(); + storage_sleep(); /* copy new filename */ strcpy(delayed_filename, recording_filename); diff --git a/apps/mpeg.h b/apps/mpeg.h index f5ce613..d32b514 100644 --- a/apps/mpeg.h +++ b/apps/mpeg.h @@ -32,7 +32,7 @@ #define MPEG_RECORDING_LOW_WATER 0x80000 #define MPEG_LOW_WATER_CHUNKSIZE 0x40000 #define MPEG_LOW_WATER_SWAP_CHUNKSIZE 0x10000 -#ifdef HAVE_MMC +#ifdef HAVE_STORAGE_MMC #define MPEG_PLAY_PENDING_THRESHOLD 0x20000 #define MPEG_PLAY_PENDING_SWAPSIZE 0x20000 #else diff --git a/apps/playback.c b/apps/playback.c index bfad1a2..5c74ac0 100644 --- a/apps/playback.c +++ b/apps/playback.c @@ -49,7 +49,7 @@ #include "mp3_playback.h" #include "usb.h" #include "status.h" -#include "ata.h" +#include "storage.h" #include "screens.h" #include "playlist.h" #include "playback.h" diff --git a/apps/playlist.c b/apps/playlist.c index cdcc059..95e1b82 100644 --- a/apps/playlist.c +++ b/apps/playlist.c @@ -1266,7 +1266,7 @@ static void playlist_thread(void) if (playlist->control_fd >= 0) { if (playlist->num_cached > 0) - register_ata_idle_func(playlist_flush_callback); + register_storage_idle_func(playlist_flush_callback); } if (!dirty_pointers) diff --git a/apps/plugin.c b/apps/plugin.c index 4ba1396..1dd439c 100644 --- a/apps/plugin.c +++ b/apps/plugin.c @@ -38,6 +38,7 @@ #include "option_select.h" #include "talk.h" #include "version.h" +#include "storage.h" #if CONFIG_CHARGING #include "power.h" @@ -265,12 +266,12 @@ static const struct plugin_api rockbox_api = { fdprintf, read_line, settings_parseline, - ata_sleep, - ata_spin, - ata_spindown, -#if USING_ATA_CALLBACK - register_ata_idle_func, - unregister_ata_idle_func, + storage_sleep, + storage_spin, + storage_spindown, +#if USING_STORAGE_CALLBACK + register_storage_idle_func, + unregister_storage_idle_func, #endif /* USING_ATA_CALLBACK */ reload_directory, create_numbered_filename, diff --git a/apps/plugin.h b/apps/plugin.h index 1029431..89feae4 100644 --- a/apps/plugin.h +++ b/apps/plugin.h @@ -371,13 +371,13 @@ struct plugin_api { int (*fdprintf)(int fd, const char *fmt, ...) ATTRIBUTE_PRINTF(2, 3); int (*read_line)(int fd, char* buffer, int buffer_size); bool (*settings_parseline)(char* line, char** name, char** value); - void (*ata_sleep)(void); - void (*ata_spin)(void); - void (*ata_spindown)(int seconds); -#if USING_ATA_CALLBACK - void (*register_ata_idle_func)(ata_idle_notify function); - void (*unregister_ata_idle_func)(ata_idle_notify function, bool run); -#endif /* USING_ATA_CALLBACK */ + void (*storage_sleep)(void); + void (*storage_spin)(void); + void (*storage_spindown)(int seconds); +#if USING_STORAGE_CALLBACK + void (*register_storage_idle_func)(storage_idle_notify function); + void (*unregister_storage_idle_func)(storage_idle_notify function, bool run); +#endif /* USING_STORAGE_CALLBACK */ void (*reload_directory)(void); char *(*create_numbered_filename)(char *buffer, const char *path, const char *prefix, const char *suffix, diff --git a/apps/plugins/SOURCES b/apps/plugins/SOURCES index 4bcc144..c9547cc 100644 --- a/apps/plugins/SOURCES +++ b/apps/plugins/SOURCES @@ -127,7 +127,7 @@ nim.c mp3_encoder.c wav2wv.c #else /* hardware codec platforms */ -#ifndef HAVE_MMC /* not for Ondio, has no remote control pin */ +#ifndef HAVE_STORAGE_MMC /* not for Ondio, has no remote control pin */ alpine_cdc.c #endif splitedit.c diff --git a/apps/plugins/alpine_cdc.c b/apps/plugins/alpine_cdc.c index f23255a..2dae9c0 100644 --- a/apps/plugins/alpine_cdc.c +++ b/apps/plugins/alpine_cdc.c @@ -34,7 +34,7 @@ #include "plugin.h" /* Only build for (correct) target */ -#if CONFIG_CPU==SH7034 && !defined(HAVE_MMC) +#if CONFIG_CPU==SH7034 && !defined(HAVE_STORAGE_MMC) PLUGIN_HEADER @@ -1199,4 +1199,4 @@ enum plugin_status plugin_start(const struct plugin_api* api, const void* parame return (main(parameter)==0) ? PLUGIN_OK : PLUGIN_ERROR; } -#endif /* CONFIG_CPU==SH7034 && !defined(HAVE_MMC) */ +#endif /* CONFIG_CPU==SH7034 && !defined(HAVE_STORAGE_MMC) */ diff --git a/apps/plugins/battery_bench.c b/apps/plugins/battery_bench.c index ef4795a..fff93b2 100644 --- a/apps/plugins/battery_bench.c +++ b/apps/plugins/battery_bench.c @@ -344,7 +344,7 @@ void thread(void) bat[buf_idx].flags = charge_state(); #endif buf_idx++; - rb->register_ata_idle_func(flush_buffer); + rb->register_storage_idle_func(flush_buffer); } /* What to do when the measurement buffer is full: @@ -386,7 +386,7 @@ void thread(void) } /* unregister flush callback and flush to disk */ - rb->unregister_ata_idle_func(flush_buffer, true); + rb->unregister_storage_idle_func(flush_buffer, true); /* log end of bench and exit reason */ 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 44a6f16..1147055 100644 --- a/apps/plugins/clock/clock_settings.c +++ b/apps/plugins/clock/clock_settings.c @@ -173,7 +173,7 @@ void load_settings(void){ draw_message(display, MESSAGE_ERRLOAD, 1); display->update(); } - rb->ata_sleep(); + rb->storage_sleep(); rb->sleep(HZ); } diff --git a/apps/plugins/jpeg.c b/apps/plugins/jpeg.c index 397fab7..1c6b602 100644 --- a/apps/plugins/jpeg.c +++ b/apps/plugins/jpeg.c @@ -304,7 +304,7 @@ MEM_FUNCTION_WRAPPERS(rb); static int slideshow_enabled = false; /* run slideshow */ static int running_slideshow = false; /* loading image because of slideshw */ #ifndef SIMULATOR -static int immediate_ata_off = false; /* power down disk after loading */ +static int immediate_storage_off = false; /* power down disk after loading */ #endif /* Persistent configuration */ @@ -2635,20 +2635,20 @@ int show_menu(void) /* return 1 to quit */ #if !defined(SIMULATOR) && defined(HAVE_DISK_STORAGE) /* change ata spindown time based on slideshow time setting */ - immediate_ata_off = false; - rb->ata_spindown(rb->global_settings->disk_spindown); + immediate_storage_off = false; + rb->storage_spindown(rb->global_settings->disk_spindown); if (slideshow_enabled) { if(jpeg_settings.ss_timeout < 10) { /* slideshow times < 10s keep disk spinning */ - rb->ata_spindown(0); + rb->storage_spindown(0); } else if (!rb->mp3_is_playing()) { - /* slideshow times > 10s and not playing: ata_off after load */ - immediate_ata_off = true; + /* slideshow times > 10s and not playing: storage_off after load */ + immediate_storage_off = true; } } #endif @@ -3210,10 +3210,10 @@ int load_and_show(char* filename) rb->lcd_update(); } #ifndef SIMULATOR - else if(immediate_ata_off) + else if(immediate_storage_off) { /* running slideshow and time is long enough: power down disk */ - rb->ata_sleep(); + rb->storage_sleep(); } #endif @@ -3414,7 +3414,7 @@ enum plugin_status plugin_start(const struct plugin_api* api, const void* parame #if !defined(SIMULATOR) && defined(HAVE_DISK_STORAGE) /* set back ata spindown time in case we changed it */ - rb->ata_spindown(rb->global_settings->disk_spindown); + rb->storage_spindown(rb->global_settings->disk_spindown); #endif /* Turn on backlight timeout (revert to settings) */ diff --git a/apps/plugins/mpegplayer/disk_buf.c b/apps/plugins/mpegplayer/disk_buf.c index 7ba4025..df5e005 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) if (!stream_get_window(&sw)) { disk_buf.state = TSTATE_DATA; - rb->ata_sleep(); + rb->storage_sleep(); break; } @@ -186,7 +186,7 @@ static inline void disk_buf_buffer(void) /* Free space is less than one page */ disk_buf.state = TSTATE_DATA; disk_buf.low_wm = DISK_BUF_LOW_WATERMARK; - rb->ata_sleep(); + rb->storage_sleep(); break; } @@ -208,7 +208,7 @@ static inline void disk_buf_buffer(void) { /* Error or end of stream */ disk_buf.state = TSTATE_EOS; - rb->ata_sleep(); + rb->storage_sleep(); break; } diff --git a/apps/plugins/mpegplayer/stream_mgr.h b/apps/plugins/mpegplayer/stream_mgr.h index c94fa84..e3ea920 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) static inline void stream_keep_disk_active(void) { #ifdef HAVE_DISK_STORAGE - rb->ata_spin(); + rb->storage_spin(); #endif } diff --git a/apps/plugins/splitedit.c b/apps/plugins/splitedit.c index 8de6a74..e979cdb 100644 --- a/apps/plugins/splitedit.c +++ b/apps/plugins/splitedit.c @@ -1044,7 +1044,7 @@ unsigned long splitedit_editor(struct mp3entry * mp3_to_split, case LOOP_MODE_TO: rb->audio_pause(); rb->audio_ff_rewind(range_start); -#ifdef HAVE_MMC +#ifdef HAVE_STORAGE_MMC /* MMC is slow - wait some time to allow track reload to finish */ rb->sleep(HZ/20); if (mp3->elapsed > play_end) /* reload in progress */ @@ -1056,7 +1056,7 @@ unsigned long splitedit_editor(struct mp3entry * mp3_to_split, case LOOP_MODE_FROM: rb->audio_pause(); rb->audio_ff_rewind(xpos_to_time(split_x)); -#ifdef HAVE_MMC +#ifdef HAVE_STORAGE_MMC /* MMC is slow - wait some time to allow track reload to finish */ rb->sleep(HZ/20); if (mp3->elapsed > play_end) /* reload in progress */ diff --git a/apps/plugins/test_disk.c b/apps/plugins/test_disk.c index 7638fbf..a4c9de1 100644 --- a/apps/plugins/test_disk.c +++ b/apps/plugins/test_disk.c @@ -29,7 +29,7 @@ PLUGIN_HEADER #define TEST_FILE TESTBASEDIR "/test_disk.tmp" #define FRND_SEED 0x78C3 /* arbirary */ -#ifdef HAVE_MMC +#ifdef HAVE_STORAGE_MMC #define TEST_SIZE (20*1024*1024) #else #define TEST_SIZE (300*1024*1024) diff --git a/apps/plugins/video.c b/apps/plugins/video.c index 6a380b8..1ba2b89 100644 --- a/apps/plugins/video.c +++ b/apps/plugins/video.c @@ -661,7 +661,7 @@ int PlayTick(int fd) #endif ) { - rb->ata_sleep(); /* no point in leaving the disk run til timeout */ + rb->storage_sleep(); /* no point in leaving the disk run til timeout */ gPlay.bDiskSleep = true; } diff --git a/apps/plugins/wavplay.c b/apps/plugins/wavplay.c index 333d161..b4fe2e6 100644 --- a/apps/plugins/wavplay.c +++ b/apps/plugins/wavplay.c @@ -3574,7 +3574,7 @@ int play_file(char* filename) while (!(SSR0 & SCI_TEND)); /* wait for end of transfer */ BRR0 = 0; /* maximum speed, ~3 MBit/s */ -#ifndef HAVE_MMC +#ifndef HAVE_STORAGE_MMC low_water = 5 /* seconds */ * 2 /* bytes per sample */ * channels @@ -3598,12 +3598,12 @@ int play_file(char* filename) if (free_space <= 0) { filling = false; - rb->ata_sleep(); + rb->storage_sleep(); } else { wanted = MIN(free_space, aud_size - aud_write); -#ifdef HAVE_MMC +#ifdef HAVE_STORAGE_MMC wanted = MIN(wanted, 256*1024); #elif MEM == 8 wanted = MIN(wanted, 1024*1024); diff --git a/apps/plugins/wavrecord.c b/apps/plugins/wavrecord.c index d57a61a..61a14f7 100644 --- a/apps/plugins/wavrecord.c +++ b/apps/plugins/wavrecord.c @@ -3587,7 +3587,7 @@ static int record_file(char *filename) if (to_save > aud_size) { rec_tick_enable(false); -#ifdef HAVE_MMC +#ifdef HAVE_STORAGE_MMC rb->splash(HZ, "Data overrun (slow MMC)"); #else rb->splash(HZ, "Data overrun"); @@ -3597,7 +3597,7 @@ static int record_file(char *filename) break; } write_now = MIN(to_save, aud_size - aud_read); -#ifdef HAVE_MMC +#ifdef HAVE_STORAGE_MMC write_now = MIN(write_now, 256*1024); #else write_now = MIN(write_now, 1024*1024); @@ -3802,7 +3802,7 @@ enum plugin_status plugin_start(const struct plugin_api* api, const void* parame return rc; #if 0 -#ifdef HAVE_MMC +#ifdef HAVE_STORAGE_MMC return record_file("//test.wav"); #else return record_file("/test.wav"); diff --git a/apps/recorder/pcm_record.c b/apps/recorder/pcm_record.c index da4e9b7..82d4e4d 100644 --- a/apps/recorder/pcm_record.c +++ b/apps/recorder/pcm_record.c @@ -24,7 +24,7 @@ #include "logf.h" #include "thread.h" #include -#include "ata.h" +#include "storage.h" #include "usb.h" #include "buffer.h" #include "general.h" @@ -162,7 +162,7 @@ static bool pcm_buffer_empty; /* all pcm chunks processed? */ static int low_watermark; /* Low watermark to stop flush */ static int high_watermark; /* max chunk limit for data flush */ static unsigned long spinup_time = 35*HZ/10; /* Fudged spinup time */ -static int last_ata_spinup_time = -1;/* previous spin time used */ +static int last_storage_spinup_time = -1;/* previous spin time used */ #ifdef HAVE_PRIORITY_SCHEDULING static int flood_watermark; /* boost thread priority when here */ #endif @@ -731,7 +731,7 @@ static void pcmrec_end_file(void) */ static void pcmrec_refresh_watermarks(void) { - logf("ata spinup: %d", ata_spinup_time); + logf("ata spinup: %d", storage_spinup_time); /* set the low mark for when flushing stops if automatic */ low_watermark = (LOW_SECONDS*4*sample_rate + (enc_chunk_size-1)) @@ -755,7 +755,7 @@ static void pcmrec_refresh_watermarks(void) logf("flood at: %d", flood_watermark); #endif - spinup_time = last_ata_spinup_time = ata_spinup_time; + spinup_time = last_storage_spinup_time = storage_spinup_time(); /* write at 8s + st remaining in enc_buffer - range 12s to 20s total - default to 3.5s spinup. */ @@ -816,7 +816,7 @@ static void pcmrec_flush(unsigned flush_num) if (!is_recording) return; - if (ata_spinup_time != last_ata_spinup_time) + if (storage_spinup_time() != last_storage_spinup_time) pcmrec_refresh_watermarks(); /* enough available? no? then leave */ diff --git a/apps/recorder/peakmeter.c b/apps/recorder/peakmeter.c index ce0974a..422b138 100644 --- a/apps/recorder/peakmeter.c +++ b/apps/recorder/peakmeter.c @@ -26,7 +26,7 @@ #include "thread.h" #include "kernel.h" #include "settings.h" -#include "ata.h" +#include "storage.h" #include "lcd.h" #include "scrollbar.h" #include "gwps.h" @@ -1343,7 +1343,7 @@ int peak_meter_draw_get_btn(int action_context, int x[], int y[], * is active, it must not draw too much CPU power or a buffer overrun can * happen when saving a recording. As a compromise, poll only once per tick * when the disk is active, otherwise spin around as fast as possible. */ - bool highperf = !ata_disk_is_active(); + bool highperf = !storage_disk_is_active(); #endif bool dopeek = true; diff --git a/apps/recorder/recording.c b/apps/recorder/recording.c index d29db39..5a2aa09 100644 --- a/apps/recorder/recording.c +++ b/apps/recorder/recording.c @@ -65,7 +65,7 @@ #include "errno.h" #include "talk.h" #include "sound.h" -#include "ata.h" +#include "storage.h" #include "splash.h" #include "screen_access.h" #include "action.h" @@ -298,7 +298,7 @@ static bool read_peak_levels(int *peak_l, int *peak_r, int *balance) peak_valid_mem[peak_time % 3] = *peak_l; if (((peak_valid_mem[0] == peak_valid_mem[1]) && (peak_valid_mem[1] == peak_valid_mem[2])) && - ((*peak_l < 32767) || ata_disk_is_active())) + ((*peak_l < 32767) || storage_disk_is_active())) return false; if (*peak_r > *peak_l) @@ -1034,7 +1034,7 @@ bool recording_screen(bool no_source) rec_status = RCSTAT_IN_RECSCREEN; #if (CONFIG_LED == LED_REAL) && !defined(SIMULATOR) - ata_set_led_enabled(false); + storage_set_led_enabled(false); #endif #if CONFIG_CODEC == SWCODEC @@ -1905,7 +1905,7 @@ rec_abort: reload_directory(); #if (CONFIG_LED == LED_REAL) && !defined(SIMULATOR) - ata_set_led_enabled(true); + storage_set_led_enabled(true); #endif #if CONFIG_TUNER diff --git a/apps/screens.c b/apps/screens.c index d8ce695..86169d1 100644 --- a/apps/screens.c +++ b/apps/screens.c @@ -68,7 +68,7 @@ #include #endif -#ifdef HAVE_MMC +#ifdef HAVE_STORAGE_MMC #include "ata_mmc.h" #endif #if CONFIG_CODEC == SWCODEC @@ -145,9 +145,9 @@ void usb_screen(void) usb_acknowledge(SYS_USB_CONNECTED_ACK); while(usb_wait_for_disconnect_w_tmo(&button_queue, HZ)) { if(usb_inserted()) { -#ifdef HAVE_MMC /* USB-MMC bridge can report activity */ +#ifdef HAVE_STORAGE_MMC /* USB-MMC bridge can report activity */ led(mmc_usb_active(HZ)); -#endif /* HAVE_MMC */ +#endif /* HAVE_STORAGE_MMC */ gui_syncstatusbar_draw(&statusbars, false); } } @@ -161,7 +161,7 @@ void usb_screen(void) #endif /* USB_NONE */ } -#ifdef HAVE_MMC +#ifdef HAVE_STORAGE_MMC int mmc_remove_request(void) { struct queue_event ev; diff --git a/apps/screens.h b/apps/screens.h index d024cc5..10dd155 100644 --- a/apps/screens.h +++ b/apps/screens.h @@ -34,7 +34,7 @@ int charging_screen(void); void charging_splash(void); #endif -#ifdef HAVE_MMC +#ifdef HAVE_STORAGE_MMC int mmc_remove_request(void); #endif diff --git a/apps/scrobbler.c b/apps/scrobbler.c index acf1e9e..b0f6515 100644 --- a/apps/scrobbler.c +++ b/apps/scrobbler.c @@ -180,7 +180,7 @@ static void add_to_cache(unsigned long play_length) logf("SCROBBLER: %s", scrobbler_entry.path); } else { cache_pos++; - register_ata_idle_func(scrobbler_flush_callback); + register_storage_idle_func(scrobbler_flush_callback); } } diff --git a/apps/settings.c b/apps/settings.c index 709e05e..e15bfc8 100644 --- a/apps/settings.c +++ b/apps/settings.c @@ -38,6 +38,7 @@ #include "rtc.h" #include "power.h" #include "ata_idle_notify.h" +#include "storage.h" #include "screens.h" #include "ctype.h" #include "file.h" @@ -582,11 +583,11 @@ void status_save(void) { update_runtime(); #ifdef HAVE_RTC_RAM - /* this will be done in the ata_callback if + /* this will be done in the storage_callback if target doesnt have rtc ram */ write_nvram_data(nvram_buffer,NVRAM_BLOCK_SIZE); #else - register_ata_idle_func(flush_global_status_callback); + register_storage_idle_func(flush_global_status_callback); #endif } @@ -594,11 +595,11 @@ int settings_save(void) { update_runtime(); #ifdef HAVE_RTC_RAM - /* this will be done in the ata_callback if + /* this will be done in the storage_callback if target doesnt have rtc ram */ write_nvram_data(nvram_buffer,NVRAM_BLOCK_SIZE); #endif - register_ata_idle_func(flush_config_block_callback); + register_storage_idle_func(flush_config_block_callback); return 0; } @@ -768,7 +769,7 @@ void settings_apply(bool read_disk) buttonlight_set_timeout(global_settings.buttonlight_timeout); #endif #ifdef HAVE_DISK_STORAGE - ata_spindown(global_settings.disk_spindown); + storage_spindown(global_settings.disk_spindown); #endif #if (CONFIG_CODEC == MAS3507D) && !defined(SIMULATOR) dac_line_in(global_settings.line_in); diff --git a/apps/settings_list.c b/apps/settings_list.c index 4c26507..67d3091 100644 --- a/apps/settings_list.c +++ b/apps/settings_list.c @@ -23,7 +23,7 @@ #include #include #include "system.h" -#include "ata.h" +#include "storage.h" #include "lang.h" #include "talk.h" #include "lcd.h" @@ -709,7 +709,7 @@ const struct settings_list settings[] = { /* disk */ #ifdef HAVE_DISK_STORAGE INT_SETTING(0, disk_spindown, LANG_SPINDOWN, 5, "disk spindown", - UNIT_SEC, 3, 254, 1, NULL, NULL, ata_spindown), + UNIT_SEC, 3, 254, 1, NULL, NULL, storage_spindown), #endif /* HAVE_DISK_STORAGE */ /* browser */ CHOICE_SETTING(0, dirfilter, LANG_FILTER, SHOW_SUPPORTED, "show files", diff --git a/apps/tagcache.c b/apps/tagcache.c index 19469cd..b6cfcd5 100644 --- a/apps/tagcache.c +++ b/apps/tagcache.c @@ -3094,7 +3094,7 @@ static void run_command_queue(bool force) if (force || command_queue_is_full()) command_queue_sync_callback(); else - register_ata_idle_func(command_queue_sync_callback); + register_storage_idle_func(command_queue_sync_callback); } static void queue_command(int cmd, long idx_id, int tag, long data) diff --git a/apps/tagtree.c b/apps/tagtree.c index 7b05391..7777a9f 100644 --- a/apps/tagtree.c +++ b/apps/tagtree.c @@ -48,6 +48,7 @@ #include "filetypes.h" #include "audio.h" #include "appevents.h" +#include "storage.h" #define FILE_SEARCH_INSTRUCTIONS ROCKBOX_DIR "/tagnavi.config" @@ -1057,7 +1058,7 @@ static int retrieve_entries(struct tree_context *c, struct tagcache_search *tcs, otherwise show it after the normal 1/2 second delay */ show_search_progress( #ifdef HAVE_DISK_STORAGE - ata_disk_is_active() + storage_disk_is_active() #else true #endif diff --git a/apps/talk.c b/apps/talk.c index 2da4cd5..c140153 100644 --- a/apps/talk.c +++ b/apps/talk.c @@ -187,7 +187,7 @@ static unsigned char* get_clip(long id, long* p_size) return NULL; clipbuf = (unsigned char *) p_voicefile + p_voicefile->index[id].offset; -#ifdef HAVE_MMC /* dynamic loading, on demand */ +#ifdef HAVE_STORAGE_MMC /* dynamic loading, on demand */ if (!(clipsize & LOADED_MASK)) { /* clip used for the first time, needs loading */ lseek(filehandle, p_voicefile->index[id].offset, SEEK_SET); @@ -225,7 +225,7 @@ static void load_voicefile(void) if (file_size > audiobufend - audiobuf) /* won't fit? */ goto load_err; -#ifdef HAVE_MMC /* load only the header for now */ +#ifdef HAVE_STORAGE_MMC /* load only the header for now */ load_size = offsetof(struct voicefile, index); #else /* load the full file */ load_size = file_size; @@ -266,7 +266,7 @@ static void load_voicefile(void) structec_convert(&p_voicefile->index[i], "ll", 1, true); #endif -#ifdef HAVE_MMC +#ifdef HAVE_STORAGE_MMC /* load the index table, now that we know its size from the header */ load_size = (p_voicefile->id1_max + p_voicefile->id2_max) * sizeof(struct clip_entry); @@ -520,7 +520,7 @@ void talk_init(void) return; } -#ifdef HAVE_MMC +#ifdef HAVE_STORAGE_MMC if (filehandle >= 0) /* MMC: An old voice file might still be open */ { close(filehandle); @@ -577,7 +577,7 @@ void talk_buffer_steal(void) #if CONFIG_CODEC != SWCODEC mp3_play_stop(); #endif -#ifdef HAVE_MMC +#ifdef HAVE_STORAGE_MMC if (filehandle >= 0) /* only relevant for MMC */ { close(filehandle); diff --git a/apps/tree.c b/apps/tree.c index 768223e..dbc47e3 100644 --- a/apps/tree.c +++ b/apps/tree.c @@ -41,7 +41,7 @@ #include "settings.h" #include "status.h" #include "debug.h" -#include "ata.h" +#include "storage.h" #include "rolo.h" #include "icons.h" #include "lang.h" @@ -828,7 +828,7 @@ static int dirbrowse() return GO_TO_WPS; if (button) { - ata_spin(); + storage_spin(); } diff --git a/bootloader/main-pp.c b/bootloader/main-pp.c index 5e20142..4177c30 100644 --- a/bootloader/main-pp.c +++ b/bootloader/main-pp.c @@ -80,7 +80,7 @@ unsigned char *loadbuffer = (unsigned char *)DRAM_START; char version[] = APPSVERSION; /* Locations and sizes in hidden partition on Sansa */ -#if defined(HAVE_ATA_SD) +#if defined(HAVE_STORAGE_SD) #define PPMI_SECTOR_OFFSET 1024 #define PPMI_SECTORS 1 #define MI4_HEADER_SECTORS 1 @@ -361,7 +361,7 @@ int load_mi4(unsigned char* buf, char* firmware, unsigned int buffer_size) return EOK; } -#if defined(HAVE_ATA_SD) +#if defined(HAVE_STORAGE_SD) /* Load mi4 firmware from a hidden disk partition */ int load_mi4_part(unsigned char* buf, struct partinfo* pinfo, unsigned int buffer_size, bool disable_rebuild) @@ -506,7 +506,7 @@ void* main(void) printf(MODEL_NAME); i=ata_init(); -#if !defined(HAVE_ATA_SD) +#if !defined(HAVE_STORAGE_SD) if (i==0) { identify_info=ata_get_identify(); /* Show model */ @@ -550,7 +550,7 @@ void* main(void) */ printf("Loading original firmware..."); -#if defined(HAVE_ATA_SD) +#if defined(HAVE_STORAGE_SD) /* First try a (hidden) firmware partition */ printf("Trying firmware partition"); pinfo = disk_partinfo(1); diff --git a/firmware/SOURCES b/firmware/SOURCES index 65bb2eb..0e4965f 100644 --- a/firmware/SOURCES +++ b/firmware/SOURCES @@ -109,15 +109,22 @@ drivers/serial.c /* Storage */ #ifndef SIMULATOR -#ifdef HAVE_MMC +storage.c +#ifdef HAVE_STORAGE_MMC drivers/ata_mmc.c -#elif defined(HAVE_FLASH_DISK) +#endif +#ifdef HAVE_STORAGE_FLASH_DISK drivers/ata_flash.c -#elif defined(HAVE_ATA) +#endif +#ifdef HAVE_STORAGE_ATA drivers/ata.c -#endif /* HAVE_MMC */ +#endif +#if defined(HAVE_STORAGE_SD) && (defined(PP5022) || defined(PP5024)) +target/arm/ata-sd-pp.c +#endif + drivers/fat.c -#if defined(HAVE_MMC) || defined(HAVE_ATA_SD) +#if defined(HAVE_HOTSWAP) hotswap.c #endif #endif /* SIMULATOR */ @@ -456,7 +463,6 @@ target/sh/archos/ondio/fmradio_i2c-ondio.c #ifdef SANSA_E200 #ifndef SIMULATOR target/arm/lcd-as-memframe.S -target/arm/ata-sd-pp.c target/arm/sandisk/sansa-e200/lcd-e200.c target/arm/adc-as3514.c target/arm/sandisk/backlight-c200_e200.c @@ -473,7 +479,6 @@ target/arm/sandisk/audio-c200_e200.c #ifdef SANSA_C200 #ifndef SIMULATOR -target/arm/ata-sd-pp.c target/arm/sandisk/sansa-c200/lcd-c200.c target/arm/sandisk/sansa-c200/lcd-as-c200.S target/arm/adc-as3514.c @@ -491,7 +496,6 @@ target/arm/sandisk/audio-c200_e200.c #ifdef PHILIPS_SA9200 #ifndef SIMULATOR -target/arm/ata-sd-pp.c target/arm/philips/sa9200/lcd-sa9200.c target/arm/adc-as3514.c target/arm/philips/sa9200/backlight-sa9200.c diff --git a/firmware/ata_idle_notify.c b/firmware/ata_idle_notify.c index 3dde52f..99b1d4d 100644 --- a/firmware/ata_idle_notify.c +++ b/firmware/ata_idle_notify.c @@ -25,9 +25,9 @@ #include "kernel.h" #include "string.h" -void register_ata_idle_func(ata_idle_notify function) +void register_storage_idle_func(storage_idle_notify function) { -#if USING_ATA_CALLBACK +#if USING_STORAGE_CALLBACK add_event(DISK_EVENT_SPINUP, true, function); #else function(); /* just call the function now */ @@ -37,8 +37,8 @@ void register_ata_idle_func(ata_idle_notify function) #endif } -#if USING_ATA_CALLBACK -void unregister_ata_idle_func(ata_idle_notify func, bool run) +#if USING_STORAGE_CALLBACK +void unregister_storage_idle_func(storage_idle_notify func, bool run) { remove_event(DISK_EVENT_SPINUP, func); @@ -46,7 +46,7 @@ void unregister_ata_idle_func(ata_idle_notify func, bool run) func(); } -bool call_ata_idle_notifys(bool force) +bool call_storage_idle_notifys(bool force) { static int lock_until = 0; diff --git a/firmware/common/disk.c b/firmware/common/disk.c index 4add5b9..32b15b8 100644 --- a/firmware/common/disk.c +++ b/firmware/common/disk.c @@ -19,7 +19,7 @@ * ****************************************************************************/ #include -#include "ata.h" +#include "storage.h" #include "debug.h" #include "fat.h" #ifdef HAVE_HOTSWAP @@ -80,7 +80,7 @@ struct partinfo* disk_init(IF_MV_NONVOID(int drive)) struct partinfo* pinfo = part; #endif - ata_read_sectors(IF_MV2(drive,) 0,1, §or); + storage_read_sectors(IF_MV2(drive,) 0,1, §or); /* check that the boot sector is initialized */ if ( (sector[510] != 0x55) || (sector[511] != 0xaa)) { diff --git a/firmware/drivers/ata.c b/firmware/drivers/ata.c index b80f615..62b9be9 100644 --- a/firmware/drivers/ata.c +++ b/firmware/drivers/ata.c @@ -148,7 +148,7 @@ static void ata_lock_unlock(struct ata_lock *l) static struct mutex ata_mtx SHAREDBSS_ATTR; static int ata_device; /* device 0 (master) or 1 (slave) */ -int ata_spinup_time = 0; +static int spinup_time = 0; #if (CONFIG_LED == LED_REAL) static bool ata_led_enabled = true; static bool ata_led_on = false; @@ -166,7 +166,7 @@ static struct event_queue ata_queue; static bool initialized = false; static long last_user_activity = -1; -long last_disk_activity = -1; +static long last_disk_activity = -1; static unsigned long total_sectors; static int multisectors; /* number of supported multisectors */ @@ -407,7 +407,7 @@ int ata_read_sectors(IF_MV2(int drive,) } if (spinup) { - ata_spinup_time = current_tick - spinup_start; + spinup_time = current_tick - spinup_start; spinup = false; sleeping = false; poweroff = false; @@ -584,7 +584,7 @@ int ata_write_sectors(IF_MV2(int drive,) } if (spinup) { - ata_spinup_time = current_tick - spinup_start; + spinup_time = current_tick - spinup_start; spinup = false; sleeping = false; poweroff = false; @@ -873,7 +873,7 @@ void ata_sleepnow(void) { if (!spinup && !sleeping && !ata_mtx.locked && initialized) { - call_ata_idle_notifys(false); + call_storage_idle_notifys(false); ata_perform_sleep(); } } @@ -908,7 +908,7 @@ static void ata_thread(void) #ifdef ALLOW_USB_SPINDOWN if(!usb_mode) #endif - call_ata_idle_notifys(false); + call_storage_idle_notifys(false); last_seen_mtx_unlock = 0; } } @@ -921,7 +921,7 @@ static void ata_thread(void) #ifdef ALLOW_USB_SPINDOWN if(!usb_mode) #endif - call_ata_idle_notifys(true); + call_storage_idle_notifys(true); ata_perform_sleep(); last_sleep = current_tick; } @@ -974,7 +974,7 @@ static void ata_thread(void) #ifdef ALLOW_USB_SPINDOWN if(!usb_mode) #endif - call_ata_idle_notifys(false); + call_storage_idle_notifys(false); last_disk_activity = current_tick - sleep_timeout + (HZ/2); break; @@ -1391,3 +1391,14 @@ void ata_set_led_enabled(bool enabled) led(false); } #endif + +long ata_last_disk_activity(void) +{ + return last_disk_activity; +} + +int ata_spinup_time(void) +{ + return spinup_time; +} + diff --git a/firmware/drivers/ata_flash.c b/firmware/drivers/ata_flash.c index d77e056..8eaa033 100644 --- a/firmware/drivers/ata_flash.c +++ b/firmware/drivers/ata_flash.c @@ -19,7 +19,7 @@ * ****************************************************************************/ -#include "ata.h" +#include "flash.h" #include #include @@ -43,7 +43,6 @@ #define SECTOR_SIZE (512) static unsigned short identify_info[SECTOR_SIZE]; -int ata_spinup_time = 0; long last_disk_activity = -1; #if CONFIG_FLASH == FLASH_IFP7XX @@ -386,7 +385,7 @@ int flash_disk_read_sectors(unsigned long start, return done; } -int ata_read_sectors(IF_MV2(int drive,) +int flash_read_sectors(IF_MV2(int drive,) unsigned long start, int incount, void* inbuf) @@ -403,7 +402,7 @@ int ata_read_sectors(IF_MV2(int drive,) return 0; } -int ata_write_sectors(IF_MV2(int drive,) +int flash_write_sectors(IF_MV2(int drive,) unsigned long start, int count, const void* buf) @@ -416,58 +415,58 @@ int ata_write_sectors(IF_MV2(int drive,) /* schedule a single sector write, executed with the the next spinup (volume 0 only, used for config sector) */ -extern void ata_delayed_write(unsigned long sector, const void* buf) +extern void flash_delayed_write(unsigned long sector, const void* buf) { (void)sector; (void)buf; } /* write the delayed sector to volume 0 */ -extern void ata_flush(void) +extern void flash_flush(void) { } -void ata_spindown(int seconds) +void flash_spindown(int seconds) { (void)seconds; } -bool ata_disk_is_active(void) +bool flash_disk_is_active(void) { return 0; } -void ata_sleep(void) +void flash_sleep(void) { } -void ata_spin(void) +void flash_spin(void) { } /* Hardware reset protocol as specified in chapter 9.1, ATA spec draft v5 */ -int ata_hard_reset(void) +int flash_hard_reset(void) { return 0; } -int ata_soft_reset(void) +int flash_soft_reset(void) { return 0; } -void ata_enable(bool on) +void flash_enable(bool on) { (void)on; } -unsigned short* ata_get_identify(void) +unsigned short* flash_get_identify(void) { return identify_info; } -int ata_init(void) +int flash_init(void) { int i, id, id2; @@ -499,3 +498,8 @@ int ata_init(void) return 0; } + +long flash_last_disk_activity(void) +{ + return last_disk_activity; +} diff --git a/firmware/drivers/ata_mmc.c b/firmware/drivers/ata_mmc.c index 1040ab0..93edd11 100644 --- a/firmware/drivers/ata_mmc.c +++ b/firmware/drivers/ata_mmc.c @@ -19,7 +19,7 @@ * ****************************************************************************/ #include -#include "ata.h" +#include "mmc.h" #include "ata_mmc.h" #include "ata_idle_notify.h" #include "kernel.h" @@ -84,8 +84,7 @@ #define DT_STOP_TRAN 0xfd /* for compatibility */ -int ata_spinup_time = 0; -long last_disk_activity = -1; +static long last_disk_activity = -1; /* private variables */ @@ -601,7 +600,7 @@ static int send_block_send(unsigned char start_token, long timeout, return rc; } -int ata_read_sectors(IF_MV2(int drive,) +int mmc_read_sectors(IF_MV2(int drive,) unsigned long start, int incount, void* inbuf) @@ -687,7 +686,7 @@ int ata_read_sectors(IF_MV2(int drive,) return rc; } -int ata_write_sectors(IF_MV2(int drive,) +int mmc_write_sectors(IF_MV2(int drive,) unsigned long start, int count, const void* buf) @@ -755,22 +754,22 @@ int ata_write_sectors(IF_MV2(int drive,) return rc; } -void ata_spindown(int seconds) +void mmc_spindown(int seconds) { (void)seconds; } -bool ata_disk_is_active(void) +bool mmc_disk_is_active(void) { /* this is correct unless early return from write gets implemented */ return mmc_mutex.locked; } -void ata_sleep(void) +void mmc_sleep(void) { } -void ata_spin(void) +void mmc_spin(void) { } @@ -810,7 +809,7 @@ static void mmc_thread(void) { if (!idle_notified) { - call_ata_idle_notifys(false); + call_storage_idle_notifys(false); idle_notified = true; } } @@ -904,12 +903,12 @@ static void mmc_tick(void) } } -int ata_soft_reset(void) +int mmc_soft_reset(void) { return 0; } -void ata_enable(bool on) +void mmc_enable(bool on) { PBCR1 &= ~0x0CF0; /* PB13, PB11 and PB10 become GPIO, * if not modified below */ @@ -924,7 +923,7 @@ void ata_enable(bool on) card_info[1].initialized = false; } -int ata_init(void) +int mmc_init(void) { int rc = 0; @@ -970,9 +969,13 @@ int ata_init(void) tick_add_task(mmc_tick); initialized = true; } - ata_enable(true); + mmc_enable(true); mutex_unlock(&mmc_mutex); return rc; } +long mmc_last_disk_activity(void) +{ + return last_disk_activity; +} diff --git a/firmware/drivers/fat.c b/firmware/drivers/fat.c index 3130a3e..c2ecced 100644 --- a/firmware/drivers/fat.c +++ b/firmware/drivers/fat.c @@ -24,7 +24,7 @@ #include #include #include "fat.h" -#include "ata.h" +#include "storage.h" #include "debug.h" #include "panic.h" #include "system.h" @@ -204,7 +204,7 @@ static char fat_cache_sectors[FAT_CACHE_SIZE][SECTOR_SIZE]; static struct fat_cache_entry fat_cache[FAT_CACHE_SIZE]; static struct mutex cache_mutex SHAREDBSS_ATTR; -#if defined(HAVE_HOTSWAP) && !defined(HAVE_MMC) /* A better condition ?? */ +#if defined(HAVE_HOTSWAP) && !defined(HAVE_STORAGE_MMC) /* A better condition ?? */ void fat_lock(void) { mutex_lock(&cache_mutex); @@ -300,7 +300,7 @@ int fat_mount(IF_MV2(int volume,) IF_MV2(int drive,) long startsector) #endif /* Read the sector */ - rc = ata_read_sectors(IF_MV2(drive,) startsector,1,buf); + rc = storage_read_sectors(IF_MV2(drive,) startsector,1,buf); if(rc) { 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) #endif /* #ifdef HAVE_FAT16SUPPORT */ { /* Read the fsinfo sector */ - rc = ata_read_sectors(IF_MV2(drive,) + rc = storage_read_sectors(IF_MV2(drive,) startsector + fat_bpb->bpb_fsinfo, 1, buf); if (rc < 0) { @@ -597,7 +597,7 @@ static void flush_fat_sector(struct fat_cache_entry *fce, #endif /* Write to the first FAT */ - rc = ata_write_sectors(IF_MV2(fce->fat_vol->drive,) + rc = storage_write_sectors(IF_MV2(fce->fat_vol->drive,) secnum, 1, sectorbuf); if(rc < 0) @@ -618,7 +618,7 @@ static void flush_fat_sector(struct fat_cache_entry *fce, #else secnum += fat_bpbs[0].fatsize; #endif - rc = ata_write_sectors(IF_MV2(fce->fat_vol->drive,) + rc = storage_write_sectors(IF_MV2(fce->fat_vol->drive,) secnum, 1, sectorbuf); if(rc < 0) { @@ -664,7 +664,7 @@ static void *cache_fat_sector(IF_MV2(struct bpb* fat_bpb,) /* Load the sector if it is not cached */ if(!fce->inuse) { - rc = ata_read_sectors(IF_MV2(fat_bpb->drive,) + rc = storage_read_sectors(IF_MV2(fat_bpb->drive,) secnum + fat_bpb->startsector,1, sectorbuf); if(rc < 0) @@ -923,7 +923,7 @@ static int update_fsinfo(IF_MV_NONVOID(struct bpb* fat_bpb)) #endif /* #ifdef HAVE_FAT16SUPPORT */ /* update fsinfo */ - rc = ata_read_sectors(IF_MV2(fat_bpb->drive,) + rc = storage_read_sectors(IF_MV2(fat_bpb->drive,) fat_bpb->startsector + fat_bpb->bpb_fsinfo, 1,fsinfo); if (rc < 0) { @@ -936,7 +936,7 @@ static int update_fsinfo(IF_MV_NONVOID(struct bpb* fat_bpb)) intptr = (long*)&(fsinfo[FSINFO_NEXTFREE]); *intptr = htole32(fat_bpb->fsinfo.nextfree); - rc = ata_write_sectors(IF_MV2(fat_bpb->drive,) + rc = storage_write_sectors(IF_MV2(fat_bpb->drive,) fat_bpb->startsector + fat_bpb->bpb_fsinfo,1,fsinfo); if (rc < 0) { @@ -2077,11 +2077,11 @@ static int transfer(IF_MV2(struct bpb* fat_bpb,) if (start + count > fat_bpb->totalsectors) panicf("Write %ld after data\n", start + count - fat_bpb->totalsectors); - rc = ata_write_sectors(IF_MV2(fat_bpb->drive,) + rc = storage_write_sectors(IF_MV2(fat_bpb->drive,) start + fat_bpb->startsector, count, buf); } else - rc = ata_read_sectors(IF_MV2(fat_bpb->drive,) + rc = storage_read_sectors(IF_MV2(fat_bpb->drive,) start + fat_bpb->startsector, count, buf); if (rc < 0) { DEBUGF( "transfer() - Couldn't %s sector %lx" diff --git a/firmware/drivers/serial.c b/firmware/drivers/serial.c index 961974e..c161585 100644 --- a/firmware/drivers/serial.c +++ b/firmware/drivers/serial.c @@ -39,7 +39,7 @@ /* iFP7xx has no remote */ #if !defined(HAVE_FMADC) /* Recorder FM/V2 has no remote control pin */ \ - && !defined(HAVE_MMC) /* MMC takes serial port 1, so don't mess with it */ + && !defined(HAVE_STORAGE_MMC) /* MMC takes serial port 1, so don't mess with it */ /* Received byte identifiers */ #define PLAY 0xC1 @@ -146,7 +146,7 @@ int remote_control_rx(void) return ret; } -#endif /* !HAVE_FMADC && !HAVE_MMC */ +#endif /* !HAVE_FMADC && !HAVE_STORAGE_MMC */ #elif defined(CPU_COLDFIRE) && defined(HAVE_SERIAL) void serial_tx(const unsigned char *buf) diff --git a/firmware/export/ata.h b/firmware/export/ata.h index 164261a..c8fcfd3 100644 --- a/firmware/export/ata.h +++ b/firmware/export/ata.h @@ -23,20 +23,7 @@ #include #include "config.h" /* for HAVE_MULTIVOLUME or not */ - -/* FixMe: These macros are a bit nasty and perhaps misplaced here. - We'll get rid of them once decided on how to proceed with multivolume. */ -#ifdef HAVE_MULTIVOLUME -#define IF_MV(x) x /* optional volume/drive parameter */ -#define IF_MV2(x,y) x,y /* same, for a list of arguments */ -#define IF_MV_NONVOID(x) x /* for prototype with sole volume parameter */ -#define NUM_VOLUMES 2 -#else /* empty definitions if no multi-volume */ -#define IF_MV(x) -#define IF_MV2(x,y) -#define IF_MV_NONVOID(x) void -#define NUM_VOLUMES 1 -#endif +#include "mv.h" /* for IF_MV() and friends */ extern void ata_enable(bool on); extern void ata_spindown(int seconds); @@ -59,7 +46,8 @@ extern void ata_set_led_enabled(bool enabled); #endif extern unsigned short* ata_get_identify(void); -extern long last_disk_activity; -extern int ata_spinup_time; /* ticks */ +extern long ata_last_disk_activity(void); +extern int ata_spinup_time(void); /* ticks */ + #endif diff --git a/firmware/export/ata_idle_notify.h b/firmware/export/ata_idle_notify.h index cfbba6f..401e386 100644 --- a/firmware/export/ata_idle_notify.h +++ b/firmware/export/ata_idle_notify.h @@ -26,15 +26,15 @@ #include "events.h" /* - NOTE: ata_idle_notify usage notes.. + NOTE: storage_idle_notify usage notes.. 1) The callbacks are called in the ata thread, not main/your thread. 2) Asynchronous callbacks (like the buffer refill) should be avoided. - If you must use an async callback, remember to check ata_is_active() before + If you must use an async callback, remember to check storage_is_active() before accessing the disk, and do not call any functions between that check and the disk access which may cause a yield (lcd_update() does this!). 3) Do not call any yielding functions in the callback. -4) Do not call ata_sleep in the callbacks. +4) Do not call storage_sleep in the callbacks. 5) Don't Panic! */ @@ -43,20 +43,20 @@ enum { DISK_EVENT_SPINUP = (EVENT_CLASS_DISK|1), }; -#define USING_ATA_CALLBACK !defined(SIMULATOR) \ - && !defined(HAVE_FLASH_DISK) \ - && !defined(BOOTLOADER) +#define USING_STORAGE_CALLBACK !defined(SIMULATOR) \ + && !defined(HAVE_STORAGE_FLASH_DISK) \ + && !defined(BOOTLOADER) -typedef bool (*ata_idle_notify)(void); +typedef bool (*storage_idle_notify)(void); -extern void register_ata_idle_func(ata_idle_notify function); -#if USING_ATA_CALLBACK -extern void unregister_ata_idle_func(ata_idle_notify function, bool run); -extern bool call_ata_idle_notifys(bool force); +extern void register_storage_idle_func(storage_idle_notify function); +#if USING_STORAGE_CALLBACK +extern void unregister_storage_idle_func(storage_idle_notify function, bool run); +extern bool call_storage_idle_notifys(bool force); #else -#define unregister_ata_idle_func(f,r) -#define call_ata_idle_notifys(f) -#define ata_idle_notify_init(s) +#define unregister_storage_idle_func(f,r) +#define call_storage_idle_notifys(f) +#define storage_idle_notify_init(s) #endif #endif /* __ATACALLBACK_H__ */ diff --git a/firmware/export/config-c100.h b/firmware/export/config-c100.h index 5bf0fc8..44ff1cc 100644 --- a/firmware/export/config-c100.h +++ b/firmware/export/config-c100.h @@ -120,4 +120,6 @@ #define BOOTFILE "rockbox." BOOTFILE_EXT #define BOOTDIR "/" +#define HAVE_STORAGE_NAND + #endif /* SIMULATOR */ diff --git a/firmware/export/config-c200.h b/firmware/export/config-c200.h index 9a9198e..5bd15e2 100644 --- a/firmware/export/config-c200.h +++ b/firmware/export/config-c200.h @@ -115,7 +115,7 @@ #define HAVE_FLASH_STORAGE /* define this if the flash memory uses the SecureDigital Memory Card protocol */ -#define HAVE_ATA_SD +#define HAVE_STORAGE_SD #define BATTERY_CAPACITY_DEFAULT 530 /* default battery capacity */ #define BATTERY_CAPACITY_MIN 530 /* min. capacity selectable */ diff --git a/firmware/export/config-cowond2.h b/firmware/export/config-cowond2.h index d136cae..9a9d0d6 100644 --- a/firmware/export/config-cowond2.h +++ b/firmware/export/config-cowond2.h @@ -145,4 +145,6 @@ #define BOOTFILE "rockbox." BOOTFILE_EXT #define BOOTDIR "/.rockbox" +#define HAVE_STORAGE_NAND + #endif /* SIMULATOR */ diff --git a/firmware/export/config-creativezv.h b/firmware/export/config-creativezv.h index e9cc268..b31df13 100644 --- a/firmware/export/config-creativezv.h +++ b/firmware/export/config-creativezv.h @@ -37,7 +37,7 @@ #define MODEL_NUMBER 28 /* define this if you use an ATA controller */ -#define HAVE_ATA +#define HAVE_STORAGE_ATA /* define this if you have a bitmap LCD display */ #define HAVE_LCD_BITMAP diff --git a/firmware/export/config-creativezvm.h b/firmware/export/config-creativezvm.h index ec21500..1deb03d 100644 --- a/firmware/export/config-creativezvm.h +++ b/firmware/export/config-creativezvm.h @@ -37,7 +37,7 @@ #define MODEL_NUMBER 26 /* define this if you use an ATA controller */ -#define HAVE_ATA +#define HAVE_STORAGE_ATA /* define this if you have a bitmap LCD display */ #define HAVE_LCD_BITMAP diff --git a/firmware/export/config-creativezvm60gb.h b/firmware/export/config-creativezvm60gb.h index d1e1d80..1ccbf0b 100644 --- a/firmware/export/config-creativezvm60gb.h +++ b/firmware/export/config-creativezvm60gb.h @@ -37,7 +37,7 @@ #define MODEL_NUMBER 27 /* define this if you use an ATA controller */ -#define HAVE_ATA +#define HAVE_STORAGE_ATA /* define this if you have a bitmap LCD display */ #define HAVE_LCD_BITMAP diff --git a/firmware/export/config-e200.h b/firmware/export/config-e200.h index 745aa71..78b1057 100644 --- a/firmware/export/config-e200.h +++ b/firmware/export/config-e200.h @@ -112,7 +112,7 @@ #define HAVE_FLASH_STORAGE /* define this if the flash memory uses the SecureDigital Memory Card protocol */ -#define HAVE_ATA_SD +#define HAVE_STORAGE_SD #define BATTERY_CAPACITY_DEFAULT 750 /* default battery capacity */ #define BATTERY_CAPACITY_MIN 750 /* min. capacity selectable */ diff --git a/firmware/export/config-fmrecorder.h b/firmware/export/config-fmrecorder.h index 1908f6a..6c9702b 100644 --- a/firmware/export/config-fmrecorder.h +++ b/firmware/export/config-fmrecorder.h @@ -1,5 +1,5 @@ /* define this if you use an ATA controller */ -#define HAVE_ATA +#define HAVE_STORAGE_ATA #define MODEL_NAME "Archos FM Recorder" diff --git a/firmware/export/config-gigabeat-s.h b/firmware/export/config-gigabeat-s.h index 7f36bce..a94bc57 100644 --- a/firmware/export/config-gigabeat-s.h +++ b/firmware/export/config-gigabeat-s.h @@ -13,7 +13,7 @@ #define MODEL_NUMBER 21 /* define this if you use an ATA controller */ -#define HAVE_ATA +#define HAVE_STORAGE_ATA /* define this if you have a bitmap LCD display */ #define HAVE_LCD_BITMAP diff --git a/firmware/export/config-gigabeat.h b/firmware/export/config-gigabeat.h index f4910bf..d4436c0 100644 --- a/firmware/export/config-gigabeat.h +++ b/firmware/export/config-gigabeat.h @@ -11,7 +11,7 @@ #define MODEL_NUMBER 18 /* define this if you use an ATA controller */ -#define HAVE_ATA +#define HAVE_STORAGE_ATA /* define this if you have a bitmap LCD display */ #define HAVE_LCD_BITMAP diff --git a/firmware/export/config-h10.h b/firmware/export/config-h10.h index 8504ffd..19e59bb 100644 --- a/firmware/export/config-h10.h +++ b/firmware/export/config-h10.h @@ -9,7 +9,7 @@ #define MODEL_NAME "iriver H10 20GB" /* define this if you use an ATA controller */ -#define HAVE_ATA +#define HAVE_STORAGE_ATA /* define this if you have recording possibility */ #define HAVE_RECORDING diff --git a/firmware/export/config-h100.h b/firmware/export/config-h100.h index 641709f..aac42d0 100644 --- a/firmware/export/config-h100.h +++ b/firmware/export/config-h100.h @@ -15,7 +15,7 @@ #define MODEL_NUMBER 1 /* define this if you use an ATA controller */ -#define HAVE_ATA +#define HAVE_STORAGE_ATA /* define this if you have a bitmap LCD display */ #define HAVE_LCD_BITMAP diff --git a/firmware/export/config-h10_5gb.h b/firmware/export/config-h10_5gb.h index fa1e372..02e50f3 100644 --- a/firmware/export/config-h10_5gb.h +++ b/firmware/export/config-h10_5gb.h @@ -9,7 +9,7 @@ #define MODEL_NAME "iriver H10 5/6GB" /* define this if you use an ATA controller */ -#define HAVE_ATA +#define HAVE_STORAGE_ATA /* define this if you have recording possibility */ #define HAVE_RECORDING diff --git a/firmware/export/config-h120.h b/firmware/export/config-h120.h index 6177347..0a674b7 100644 --- a/firmware/export/config-h120.h +++ b/firmware/export/config-h120.h @@ -10,7 +10,7 @@ #define MODEL_NUMBER 0 /* define this if you use an ATA controller */ -#define HAVE_ATA +#define HAVE_STORAGE_ATA /* define this if you have a bitmap LCD display */ #define HAVE_LCD_BITMAP diff --git a/firmware/export/config-h300.h b/firmware/export/config-h300.h index 0b30574..8d64ded 100644 --- a/firmware/export/config-h300.h +++ b/firmware/export/config-h300.h @@ -10,7 +10,7 @@ #define MODEL_NUMBER 2 /* define this if you use an ATA controller */ -#define HAVE_ATA +#define HAVE_STORAGE_ATA /* define this if you have a bitmap LCD display */ #define HAVE_LCD_BITMAP diff --git a/firmware/export/config-hdd1630.h b/firmware/export/config-hdd1630.h index 810902e..f9598d5 100755 --- a/firmware/export/config-hdd1630.h +++ b/firmware/export/config-hdd1630.h @@ -9,7 +9,7 @@ #define MODEL_NAME "Philips GoGear HDD1630" /* define this if you use an ATA controller */ -#define HAVE_ATA +#define HAVE_STORAGE_ATA /* define this if you have recording possibility */ /* #define HAVE_RECORDING */ diff --git a/firmware/export/config-iaudio7.h b/firmware/export/config-iaudio7.h index 8934470..bac2697 100644 --- a/firmware/export/config-iaudio7.h +++ b/firmware/export/config-iaudio7.h @@ -155,6 +155,8 @@ #define BOOTFILE "rockbox." BOOTFILE_EXT #define BOOTDIR "/" +#define HAVE_STORAGE_NAND + #ifdef BOOTLOADER #define TCCBOOT #endif diff --git a/firmware/export/config-iaudiom3.h b/firmware/export/config-iaudiom3.h index 8ebd5cb..d8d8a09 100644 --- a/firmware/export/config-iaudiom3.h +++ b/firmware/export/config-iaudiom3.h @@ -9,7 +9,7 @@ #define MODEL_NAME "iAudio M3" /* define this if you use an ATA controller */ -#define HAVE_ATA +#define HAVE_STORAGE_ATA /* define this if you have recording possibility */ #define HAVE_RECORDING diff --git a/firmware/export/config-iaudiom5.h b/firmware/export/config-iaudiom5.h index 027ffb6..d67d58b 100644 --- a/firmware/export/config-iaudiom5.h +++ b/firmware/export/config-iaudiom5.h @@ -9,7 +9,7 @@ #define MODEL_NAME "iAudio M5" /* define this if you use an ATA controller */ -#define HAVE_ATA +#define HAVE_STORAGE_ATA /* define this if you have recording possibility */ #define HAVE_RECORDING diff --git a/firmware/export/config-iaudiox5.h b/firmware/export/config-iaudiox5.h index 5ea3dcd..f2153ca 100644 --- a/firmware/export/config-iaudiox5.h +++ b/firmware/export/config-iaudiox5.h @@ -9,7 +9,7 @@ #define MODEL_NAME "iAudio X5" /* define this if you use an ATA controller */ -#define HAVE_ATA +#define HAVE_STORAGE_ATA /* define this if you have recording possibility */ #define HAVE_RECORDING diff --git a/firmware/export/config-ifp7xx.h b/firmware/export/config-ifp7xx.h index 6e6f9f4..02174ae 100644 --- a/firmware/export/config-ifp7xx.h +++ b/firmware/export/config-ifp7xx.h @@ -50,7 +50,7 @@ /* Define this if you have the WM8975 audio codec */ /* #define HAVE_WM8975 */ -#define HAVE_FLASH_DISK +#define HAVE_STORAGE_FLASH_DISK /* Virtual LED (icon) */ #define CONFIG_LED LED_VIRTUAL diff --git a/firmware/export/config-ipod1g2g.h b/firmware/export/config-ipod1g2g.h index ae810b1..b96864f 100644 --- a/firmware/export/config-ipod1g2g.h +++ b/firmware/export/config-ipod1g2g.h @@ -11,7 +11,7 @@ #define MODEL_NUMBER 19 /* define this if you use an ATA controller */ -#define HAVE_ATA +#define HAVE_STORAGE_ATA /* define this if you have recording possibility #define HAVE_RECORDING */ diff --git a/firmware/export/config-ipod3g.h b/firmware/export/config-ipod3g.h index 3ca95c3..9459ddb 100644 --- a/firmware/export/config-ipod3g.h +++ b/firmware/export/config-ipod3g.h @@ -12,7 +12,7 @@ #define MODEL_NUMBER 7 /* define this if you use an ATA controller */ -#define HAVE_ATA +#define HAVE_STORAGE_ATA /* define this if you have recording possibility */ /*#define HAVE_RECORDING*/ diff --git a/firmware/export/config-ipod4g.h b/firmware/export/config-ipod4g.h index 4f0045f..7fa4737 100644 --- a/firmware/export/config-ipod4g.h +++ b/firmware/export/config-ipod4g.h @@ -11,7 +11,7 @@ #define MODEL_NUMBER 8 /* define this if you use an ATA controller */ -#define HAVE_ATA +#define HAVE_STORAGE_ATA /* define this if you have recording possibility */ #define HAVE_RECORDING diff --git a/firmware/export/config-ipodcolor.h b/firmware/export/config-ipodcolor.h index d23a03a..2af571e 100644 --- a/firmware/export/config-ipodcolor.h +++ b/firmware/export/config-ipodcolor.h @@ -11,7 +11,7 @@ #define MODEL_NUMBER 3 /* define this if you use an ATA controller */ -#define HAVE_ATA +#define HAVE_STORAGE_ATA /* define this if you have recording possibility */ #define HAVE_RECORDING diff --git a/firmware/export/config-ipodmini.h b/firmware/export/config-ipodmini.h index 8477e49..80aca3d 100644 --- a/firmware/export/config-ipodmini.h +++ b/firmware/export/config-ipodmini.h @@ -11,7 +11,7 @@ #define MODEL_NUMBER 9 /* define this if you use an ATA controller */ -#define HAVE_ATA +#define HAVE_STORAGE_ATA /* define this if you have recording possibility */ /*#define HAVE_RECORDING*/ diff --git a/firmware/export/config-ipodmini2g.h b/firmware/export/config-ipodmini2g.h index 5e7bdb0..76773d1 100644 --- a/firmware/export/config-ipodmini2g.h +++ b/firmware/export/config-ipodmini2g.h @@ -11,7 +11,7 @@ #define MODEL_NUMBER 11 /* define this if you use an ATA controller */ -#define HAVE_ATA +#define HAVE_STORAGE_ATA /* define this if you have recording possibility */ /*#define HAVE_RECORDING*/ diff --git a/firmware/export/config-ipodnano.h b/firmware/export/config-ipodnano.h index 0750d55..0cde72d 100644 --- a/firmware/export/config-ipodnano.h +++ b/firmware/export/config-ipodnano.h @@ -11,7 +11,7 @@ #define MODEL_NUMBER 4 /* define this if you use an ATA controller */ -#define HAVE_ATA +#define HAVE_STORAGE_ATA /* define this if you have recording possibility */ #define HAVE_RECORDING diff --git a/firmware/export/config-ipodvideo.h b/firmware/export/config-ipodvideo.h index c7a248e..a79d076 100644 --- a/firmware/export/config-ipodvideo.h +++ b/firmware/export/config-ipodvideo.h @@ -11,7 +11,7 @@ #define MODEL_NUMBER 5 /* define this if you use an ATA controller */ -#define HAVE_ATA +#define HAVE_STORAGE_ATA /* define this if you have recording possibility */ #define HAVE_RECORDING diff --git a/firmware/export/config-logikdax.h b/firmware/export/config-logikdax.h index f1787b1..10779b6 100644 --- a/firmware/export/config-logikdax.h +++ b/firmware/export/config-logikdax.h @@ -131,4 +131,6 @@ #define ICODE_ATTR_ALAC #define IBSS_ATTR_SHORTEN_DECODED0 +#define HAVE_STORAGE_NAND + #endif /* SIMULATOR */ diff --git a/firmware/export/config-m200.h b/firmware/export/config-m200.h index 2733ad5..999deab 100644 --- a/firmware/export/config-m200.h +++ b/firmware/export/config-m200.h @@ -124,4 +124,6 @@ #define ICODE_ATTR_ALAC #define IBSS_ATTR_SHORTEN_DECODED0 +#define HAVE_STORAGE_NAND + #endif /* SIMULATOR */ diff --git a/firmware/export/config-mrobe100.h b/firmware/export/config-mrobe100.h index 99e7757..730bcdc 100644 --- a/firmware/export/config-mrobe100.h +++ b/firmware/export/config-mrobe100.h @@ -9,7 +9,7 @@ #define MODEL_NAME "Olympus m:robe MR-100" /* define this if you use an ATA controller */ -#define HAVE_ATA +#define HAVE_STORAGE_ATA /* define this if you have a bitmap LCD display */ #define HAVE_LCD_BITMAP diff --git a/firmware/export/config-mrobe500.h b/firmware/export/config-mrobe500.h index 8e20c94..18377dd 100644 --- a/firmware/export/config-mrobe500.h +++ b/firmware/export/config-mrobe500.h @@ -33,7 +33,7 @@ #define MODEL_NUMBER 22 /* define this if you use an ATA controller */ -#define HAVE_ATA +#define HAVE_STORAGE_ATA /* define this if you have a bitmap LCD display */ #define HAVE_LCD_BITMAP diff --git a/firmware/export/config-ondavx747.h b/firmware/export/config-ondavx747.h index 12deb9c..681dd60 100644 --- a/firmware/export/config-ondavx747.h +++ b/firmware/export/config-ondavx747.h @@ -34,7 +34,7 @@ #define MODEL_NUMBER 35 /* define this if you use an ATA controller */ -//#define HAVE_ATA +//#define HAVE_STORAGE_ATA /* define this if you have a bitmap LCD display */ #define HAVE_LCD_BITMAP diff --git a/firmware/export/config-ondavx767.h b/firmware/export/config-ondavx767.h index 9c2d237..fe0b3aa 100644 --- a/firmware/export/config-ondavx767.h +++ b/firmware/export/config-ondavx767.h @@ -34,7 +34,7 @@ #define MODEL_NUMBER 36 /* define this if you use an ATA controller */ -//#define HAVE_ATA +//#define HAVE_STORAGE_ATA /* define this if you have a bitmap LCD display */ #define HAVE_LCD_BITMAP diff --git a/firmware/export/config-ondiofm.h b/firmware/export/config-ondiofm.h index 8d3b040..a620f39 100644 --- a/firmware/export/config-ondiofm.h +++ b/firmware/export/config-ondiofm.h @@ -106,7 +106,7 @@ #define HAVE_ONDIO_ADC /* Define this for MMC support instead of ATA harddisk */ -#define HAVE_MMC +#define HAVE_STORAGE_MMC /* Define this to support mounting FAT16 partitions */ #define HAVE_FAT16SUPPORT diff --git a/firmware/export/config-ondiosp.h b/firmware/export/config-ondiosp.h index fc99bf4..087919a 100644 --- a/firmware/export/config-ondiosp.h +++ b/firmware/export/config-ondiosp.h @@ -89,7 +89,7 @@ #define HAVE_ONDIO_ADC /* Define this for MMC support instead of ATA harddisk */ -#define HAVE_MMC +#define HAVE_STORAGE_MMC /* Define this to support mounting FAT16 partitions */ #define HAVE_FAT16SUPPORT diff --git a/firmware/export/config-player.h b/firmware/export/config-player.h index d94ca82..70b1f38 100644 --- a/firmware/export/config-player.h +++ b/firmware/export/config-player.h @@ -1,5 +1,5 @@ /* define this if you use an ATA controller */ -#define HAVE_ATA +#define HAVE_STORAGE_ATA #define MODEL_NAME "Archos Player/Studio" diff --git a/firmware/export/config-recorder.h b/firmware/export/config-recorder.h index f6ddb88..1228792 100644 --- a/firmware/export/config-recorder.h +++ b/firmware/export/config-recorder.h @@ -1,5 +1,5 @@ /* define this if you use an ATA controller */ -#define HAVE_ATA +#define HAVE_STORAGE_ATA #define MODEL_NAME "Archos Recorder" diff --git a/firmware/export/config-recorderv2.h b/firmware/export/config-recorderv2.h index 5d62ec4..7187d42 100644 --- a/firmware/export/config-recorderv2.h +++ b/firmware/export/config-recorderv2.h @@ -1,5 +1,5 @@ /* define this if you use an ATA controller */ -#define HAVE_ATA +#define HAVE_STORAGE_ATA #define MODEL_NAME "Archos Recorder v2" diff --git a/firmware/export/config-sa9200.h b/firmware/export/config-sa9200.h index 433e28d..f14b01e 100755 --- a/firmware/export/config-sa9200.h +++ b/firmware/export/config-sa9200.h @@ -94,7 +94,7 @@ #define HAVE_FLASH_STORAGE /* define this if the flash memory uses the SecureDigital Memory Card protocol */ -#define HAVE_ATA_SD +#define HAVE_STORAGE_SD #define BATTERY_CAPACITY_DEFAULT 750 /* default battery capacity */ #define BATTERY_CAPACITY_MIN 750 /* min. capacity selectable */ diff --git a/firmware/export/config-tpj1022.h b/firmware/export/config-tpj1022.h index 1b49e0e..7f964ae 100644 --- a/firmware/export/config-tpj1022.h +++ b/firmware/export/config-tpj1022.h @@ -10,7 +10,7 @@ #define MODEL_NUMBER 15 /* define this if you use an ATA controller */ -#define HAVE_ATA +#define HAVE_STORAGE_ATA /* define this if you have recording possibility */ /*#define HAVE_RECORDING*/ /* TODO: add support for this */ diff --git a/firmware/export/disk.h b/firmware/export/disk.h index 8d440be..cec9bfa 100644 --- a/firmware/export/disk.h +++ b/firmware/export/disk.h @@ -21,7 +21,7 @@ #ifndef _DISK_H_ #define _DISK_H_ -#include "ata.h" /* for volume definitions */ +#include "mv.h" /* for volume definitions */ struct partinfo { unsigned long start; /* first sector (LBA) */ diff --git a/firmware/export/fat.h b/firmware/export/fat.h index 0e83ca8..c99a1a7 100644 --- a/firmware/export/fat.h +++ b/firmware/export/fat.h @@ -23,7 +23,7 @@ #define FAT_H #include -#include "ata.h" /* for volume definitions */ +#include "mv.h" /* for volume definitions */ #include "config.h" #define SECTOR_SIZE 512 diff --git a/firmware/export/flash.h b/firmware/export/flash.h new file mode 100644 index 0000000..572de74 --- /dev/null +++ b/firmware/export/flash.h @@ -0,0 +1,48 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id$ + * + * Copyright (C) 2002 by Alan Korr + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + ****************************************************************************/ +#ifndef __MMC_H__ +#define __MMC_H__ + +#include +#include "mv.h" /* for HAVE_MULTIVOLUME or not */ + +extern void flash_enable(bool on); +extern void flash_spindown(int seconds); +extern void flash_sleep(void); +extern void flash_sleepnow(void); +extern bool flash_disk_is_active(void); +extern int flash_hard_reset(void); +extern int flash_soft_reset(void); +extern int flash_init(void); +extern void flash_close(void); +extern int flash_read_sectors(IF_MV2(int drive,) unsigned long start, int count, void* buf); +extern int flash_write_sectors(IF_MV2(int drive,) unsigned long start, int count, const void* buf); +extern void flash_spin(void); + +#if (CONFIG_LED == LED_REAL) +extern void flash_set_led_enabled(bool enabled); +#endif + +extern unsigned short* flash_get_identify(void); + +extern long flash_last_disk_activity(void); + +#endif diff --git a/firmware/export/hotswap.h b/firmware/export/hotswap.h index d01c467..e5e52a9 100644 --- a/firmware/export/hotswap.h +++ b/firmware/export/hotswap.h @@ -41,14 +41,14 @@ typedef struct unsigned int blocksize; /* block size in bytes */ } tCardInfo; -#ifdef HAVE_ATA_SD +#ifdef HAVE_STORAGE_SD #include "ata-sd-target.h" #define card_detect card_detect_target #define card_get_info card_get_info_target #ifdef HAVE_HOTSWAP #define card_enable_monitoring card_enable_monitoring_target #endif -#else /* HAVE_MMC */ +#else /* HAVE_STORAGE_MMC */ #include "ata_mmc.h" #define card_detect mmc_detect #define card_get_info mmc_card_info diff --git a/firmware/export/mmc.h b/firmware/export/mmc.h new file mode 100644 index 0000000..fd19202 --- /dev/null +++ b/firmware/export/mmc.h @@ -0,0 +1,48 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id$ + * + * Copyright (C) 2002 by Alan Korr + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + ****************************************************************************/ +#ifndef __MMC_H__ +#define __MMC_H__ + +#include +#include "mv.h" /* for HAVE_MULTIVOLUME or not */ + +extern void mmc_enable(bool on); +extern void mmc_spindown(int seconds); +extern void mmc_sleep(void); +extern void mmc_sleepnow(void); +extern bool mmc_disk_is_active(void); +extern int mmc_hard_reset(void); +extern int mmc_soft_reset(void); +extern int mmc_init(void); +extern void mmc_close(void); +extern int mmc_read_sectors(IF_MV2(int drive,) unsigned long start, int count, void* buf); +extern int mmc_write_sectors(IF_MV2(int drive,) unsigned long start, int count, const void* buf); +extern void mmc_spin(void); + +#if (CONFIG_LED == LED_REAL) +extern void mmc_set_led_enabled(bool enabled); +#endif + +extern unsigned short* mmc_get_identify(void); + +extern long mmc_last_disk_activity(void); + +#endif diff --git a/firmware/export/mv.h b/firmware/export/mv.h new file mode 100644 index 0000000..fda650c --- /dev/null +++ b/firmware/export/mv.h @@ -0,0 +1,41 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id$ + * + * Copyright (C) 2008 by Frank Gevaerts + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + ****************************************************************************/ + +#ifndef __MV_H__ +#define __MV_H__ + +#include "config.h" + +/* FixMe: These macros are a bit nasty and perhaps misplaced here. + We'll get rid of them once decided on how to proceed with multivolume. */ +#ifdef HAVE_MULTIVOLUME +#define IF_MV(x) x /* optional volume/drive parameter */ +#define IF_MV2(x,y) x,y /* same, for a list of arguments */ +#define IF_MV_NONVOID(x) x /* for prototype with sole volume parameter */ +#define NUM_VOLUMES 2 +#else /* empty definitions if no multi-volume */ +#define IF_MV(x) +#define IF_MV2(x,y) +#define IF_MV_NONVOID(x) void +#define NUM_VOLUMES 1 +#endif + +#endif diff --git a/firmware/export/nand.h b/firmware/export/nand.h new file mode 100644 index 0000000..11fa0a0 --- /dev/null +++ b/firmware/export/nand.h @@ -0,0 +1,47 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id$ + * + * Copyright (C) 2002 by Alan Korr + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + ****************************************************************************/ +#ifndef __NAND_H__ +#define __NAND_H__ + +#include +#include "mv.h" /* for HAVE_MULTIVOLUME or not */ + +extern void nand_enable(bool on); +extern void nand_spindown(int seconds); +extern void nand_sleep(void); +extern bool nand_disk_is_active(void); +extern int nand_hard_reset(void); +extern int nand_soft_reset(void); +extern int nand_init(void); +extern void nand_close(void); +extern int nand_read_sectors(IF_MV2(int drive,) unsigned long start, int count, void* buf); +extern int nand_write_sectors(IF_MV2(int drive,) unsigned long start, int count, const void* buf); +extern void nand_spin(void); + +#if (CONFIG_LED == LED_REAL) +extern void nand_set_led_enabled(bool enabled); +#endif + +extern unsigned short* nand_get_identify(void); + +extern long nand_last_disk_activity(void); + +#endif diff --git a/firmware/export/nand_id.h b/firmware/export/nand_id.h index a47a38e..188b6c1 100644 --- a/firmware/export/nand_id.h +++ b/firmware/export/nand_id.h @@ -5,7 +5,7 @@ * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ * \/ \/ \/ \/ \/ - * $Id: ata.h 17847 2008-06-28 18:10:04Z bagder $ + * $Id: $ * * Copyright (C) 2002 by Alan Korr * diff --git a/firmware/export/powermgmt.h b/firmware/export/powermgmt.h index 5a2f936..44b6843 100644 --- a/firmware/export/powermgmt.h +++ b/firmware/export/powermgmt.h @@ -92,7 +92,7 @@ extern int trickle_sec; /* trickle charge: How many seconds per minute #endif /* CONFIG_CHARGING == CHARGING_CONTROL */ -#ifdef HAVE_MMC /* Values for Ondio */ +#ifdef HAVE_STORAGE_MMC /* Values for Ondio */ # define CURRENT_NORMAL 95 /* average, nearly proportional to 1/U */ # define CURRENT_USB 1 /* host powered in USB mode; avoid zero-div */ # define CURRENT_BACKLIGHT 0 /* no backlight */ @@ -142,7 +142,7 @@ extern int trickle_sec; /* trickle charge: How many seconds per minute #define CURRENT_USB 500 /* usual current in mA in USB mode */ #ifdef HAVE_REMOTE_LCD # define CURRENT_REMOTE 8 /* add. current when H100-remote connected */ -#endif /* HAVE_MMC */ +#endif /* HAVE_STORAGE_MMC */ # define CURRENT_MIN_CHG 70 /* minimum charge current */ # define MIN_CHG_V 8500 /* at 8.5v charger voltage get CURRENT_MIN_CHG */ @@ -152,7 +152,7 @@ extern int trickle_sec; /* trickle charge: How many seconds per minute # define CURRENT_MAX_CHG 350 /* maximum charging current */ # endif # define MAX_CHG_V 10250 /* anything over 10.25v gives CURRENT_MAX_CHG */ -#endif /* not HAVE_MMC */ +#endif /* not HAVE_STORAGE_MMC */ extern unsigned short power_history[POWER_HISTORY_LEN]; extern const unsigned short battery_level_dangerous[BATTERY_TYPES_COUNT]; diff --git a/firmware/export/sd.h b/firmware/export/sd.h new file mode 100644 index 0000000..244bbd4 --- /dev/null +++ b/firmware/export/sd.h @@ -0,0 +1,47 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id$ + * + * Copyright (C) 2002 by Alan Korr + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + ****************************************************************************/ +#ifndef __SD_H__ +#define __SD_H__ + +#include +#include "mv.h" /* for HAVE_MULTIVOLUME or not */ + +extern void sd_enable(bool on); +extern void sd_spindown(int seconds); +extern void sd_sleep(void); +extern bool sd_disk_is_active(void); +extern int sd_hard_reset(void); +extern int sd_soft_reset(void); +extern int sd_init(void); +extern void sd_close(void); +extern int sd_read_sectors(IF_MV2(int drive,) unsigned long start, int count, void* buf); +extern int sd_write_sectors(IF_MV2(int drive,) unsigned long start, int count, const void* buf); +extern void sd_spin(void); + +#if (CONFIG_LED == LED_REAL) +extern void sd_set_led_enabled(bool enabled); +#endif + +extern unsigned short* sd_get_identify(void); + +extern long sd_last_disk_activity(void); + +#endif diff --git a/firmware/export/storage.h b/firmware/export/storage.h new file mode 100644 index 0000000..83022d0 --- /dev/null +++ b/firmware/export/storage.h @@ -0,0 +1,49 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id$ + * + * Copyright (C) 2002 by Alan Korr + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + ****************************************************************************/ +#ifndef __STORAGE_H__ +#define __STORAGE_H__ + +#include +#include "config.h" /* for HAVE_MULTIVOLUME or not */ +#include "mv.h" + +extern void storage_enable(bool on); +extern void storage_spindown(int seconds); +extern void storage_sleep(void); +extern void storage_sleepnow(void); +extern bool storage_disk_is_active(void); +extern int storage_hard_reset(void); +extern int storage_soft_reset(void); +extern int storage_init(void); +extern int storage_read_sectors(IF_MV2(int drive,) unsigned long start, int count, void* buf); +extern int storage_write_sectors(IF_MV2(int drive,) unsigned long start, int count, const void* buf); +extern void storage_spin(void); + +#if (CONFIG_LED == LED_REAL) +extern void storage_set_led_enabled(bool enabled); +#endif + +extern unsigned short* storage_get_identify(void); + +/* These should really be drive-dependent */ +long storage_last_disk_activity(void); +int storage_spinup_time(void); /* ticks */ +#endif diff --git a/firmware/hotswap.c b/firmware/hotswap.c index cb8a539..8ac49c9 100644 --- a/firmware/hotswap.c +++ b/firmware/hotswap.c @@ -20,7 +20,7 @@ ****************************************************************************/ #include #include "config.h" -#ifdef HAVE_MMC +#ifdef HAVE_STORAGE_MMC #include "ata_mmc.h" #else #include "hotswap.h" diff --git a/firmware/include/dir.h b/firmware/include/dir.h index 69403a7..27a1f55 100644 --- a/firmware/include/dir.h +++ b/firmware/include/dir.h @@ -28,7 +28,7 @@ /* how to name volumes, first char must be outside of legal file names, a number gets appended to enumerate, if applicable */ -#ifdef HAVE_MMC +#ifdef HAVE_STORAGE_MMC #define VOL_NAMES "" #define VOL_ENUM_POS 4 /* position of %d, to avoid runtime calculation */ #elif defined(HAVE_HOTSWAP) diff --git a/firmware/powermgmt.c b/firmware/powermgmt.c index 86fadff..4a88308 100644 --- a/firmware/powermgmt.c +++ b/firmware/powermgmt.c @@ -29,7 +29,7 @@ #include "adc.h" #include "string.h" #include "sprintf.h" -#include "ata.h" +#include "storage.h" #include "power.h" #include "button.h" #include "audio.h" @@ -451,7 +451,7 @@ static void handle_auto_poweroff(void) !sleeptimer_active))) { if(TIME_AFTER(current_tick, last_event_tick + timeout) && - TIME_AFTER(current_tick, last_disk_activity + timeout)) + TIME_AFTER(current_tick, storage_last_disk_activity() + timeout)) { sys_poweroff(); } @@ -492,7 +492,7 @@ static int runcurrent(void) { int current; -#if MEM == 8 && !defined(HAVE_MMC) +#if MEM == 8 && !defined(HAVE_STORAGE_MMC) /* assuming 192 kbps, the running time is 22% longer with 8MB */ current = (CURRENT_NORMAL*100/122); #else @@ -579,7 +579,7 @@ int pid_i = 0; /* PID integral term */ static inline void charging_algorithm_small_step(void) { - if (ata_disk_is_active()) { + if (storage_disk_is_active()) { /* flag hdd use for charging calculation */ disk_activity_last_cycle = true; } @@ -589,7 +589,7 @@ static inline void charging_algorithm_small_step(void) * If we have a lot of pending writes or if the disk is spining, * fsync the debug log file. */ - if((wrcount > 10) || ((wrcount > 0) && ata_disk_is_active())) { + if((wrcount > 10) || ((wrcount > 0) && storage_disk_is_active())) { fsync(fd); wrcount = 0; } @@ -1014,7 +1014,7 @@ static void power_thread_sleep(int ticks) * the disk is spinning unless we are in USB mode (the disk will most * likely always be spinning in USB mode). */ - if (!ata_disk_is_active() || usb_inserted()) { + if (!storage_disk_is_active() || usb_inserted()) { avgbat += battery_adc_voltage() - (avgbat / BATT_AVE_SAMPLES); /* * battery_millivolts is the millivolt-scaled filtered battery value. @@ -1059,7 +1059,7 @@ static void power_thread(void) /* initialize the voltages for the exponential filter */ avgbat = battery_adc_voltage() + 15; -#ifndef HAVE_MMC /* this adjustment is only needed for HD based */ +#ifndef HAVE_STORAGE_MMC /* this adjustment is only needed for HD based */ /* The battery voltage is usually a little lower directly after turning on, because the disk was used heavily. Raise it by 5% */ #ifdef HAVE_CHARGING @@ -1067,7 +1067,7 @@ static void power_thread(void) #endif avgbat += (percent_to_volt_discharge[battery_type][6] - percent_to_volt_discharge[battery_type][5]) / 2; -#endif /* not HAVE_MMC */ +#endif /* not HAVE_STORAGE_MMC */ avgbat = avgbat * BATT_AVE_SAMPLES; battery_millivolts = avgbat / BATT_AVE_SAMPLES; @@ -1152,10 +1152,10 @@ void shutdown_hw(void) #ifdef HAVE_LCD_BITMAP glyph_cache_save(); #endif - if(ata_disk_is_active()) - ata_spindown(1); + if(storage_disk_is_active()) + storage_spindown(1); } - while(ata_disk_is_active()) + while(storage_disk_is_active()) sleep(HZ/10); #if CONFIG_CODEC != SWCODEC @@ -1166,7 +1166,7 @@ void shutdown_hw(void) /* If HD is still active we try to wait for spindown, otherwise the shutdown_timeout in power_thread_sleep will force a power off */ - while(ata_disk_is_active()) + while(storage_disk_is_active()) sleep(HZ/10); #ifndef IAUDIO_X5 lcd_set_contrast(0); diff --git a/firmware/storage.c b/firmware/storage.c new file mode 100644 index 0000000..92626d0 --- /dev/null +++ b/firmware/storage.c @@ -0,0 +1,266 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id: $ + * + * Copyright (C) 2008 by Frank Gevaerts + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + ****************************************************************************/ +#include "config.h" /* for HAVE_MULTIVOLUME or not */ +#include "storage.h" + +#ifdef HAVE_STORAGE_SD +#include "sd.h" +#endif +#ifdef HAVE_STORAGE_MMC +#include "mmc.h" +#endif +#ifdef HAVE_STORAGE_ATA +#include "ata.h" +#endif +#ifdef HAVE_STORAGE_NAND +#include "nand.h" +#endif +#ifdef HAVE_STORAGE_FLASH_DISK +#include "flash.h" +#endif + +void storage_enable(bool on) +{ +#ifdef HAVE_STORAGE_ATA + ata_enable(on); +#elif defined(HAVE_STORAGE_SD) + sd_enable(on); +#elif defined(HAVE_STORAGE_NAND) + nand_enable(on); +#elif defined(HAVE_STORAGE_FLASH_DISK) + flash_enable(on); +#elif defined(HAVE_STORAGE_MMC) + mmc_enable(on); +#else + #error No storage driver! +#endif +} +void storage_spindown(int seconds) +{ +#ifdef HAVE_STORAGE_ATA + ata_spindown(seconds); +#elif defined(HAVE_STORAGE_SD) + sd_spindown(seconds); +#elif defined(HAVE_STORAGE_NAND) + nand_spindown(seconds); +#elif defined(HAVE_STORAGE_FLASH_DISK) + flash_spindown(seconds); +#elif defined(HAVE_STORAGE_MMC) + mmc_spindown(seconds); +#else + #error No storage driver! +#endif +} +void storage_sleep(void) +{ +#ifdef HAVE_STORAGE_ATA + ata_sleep(); +#elif defined(HAVE_STORAGE_SD) + sd_sleep(); +#elif defined(HAVE_STORAGE_NAND) + nand_sleep(); +#elif defined(HAVE_STORAGE_FLASH_DISK) + flash_sleep(); +#elif defined(HAVE_STORAGE_MMC) + mmc_sleep(); +#else + #error No storage driver! +#endif +} +void storage_sleepnow(void) +{ +#ifdef HAVE_STORAGE_ATA + ata_sleepnow(); +#endif +} +bool storage_disk_is_active(void) +{ +#ifdef HAVE_STORAGE_ATA + return ata_disk_is_active(); +#elif defined(HAVE_STORAGE_SD) + return sd_disk_is_active(); +#elif defined(HAVE_STORAGE_NAND) + return nand_disk_is_active(); +#elif defined(HAVE_STORAGE_FLASH_DISK) + return flash_disk_is_active(); +#elif defined(HAVE_STORAGE_MMC) + return mmc_disk_is_active(); +#else + #error No storage driver! +#endif +} +int storage_hard_reset(void) +{ +#ifdef HAVE_STORAGE_ATA + return ata_hard_reset(); +#elif defined(HAVE_STORAGE_SD) + return sd_hard_reset(); +#elif defined(HAVE_STORAGE_NAND) + return nand_hard_reset(); +#elif defined(HAVE_STORAGE_FLASH_DISK) + return flash_hard_reset(); +#elif defined(HAVE_STORAGE_MMC) + //return mmc_hard_reset(); +#else + #error No storage driver! +#endif +} +int storage_soft_reset(void) +{ +#ifdef HAVE_STORAGE_ATA + return ata_soft_reset(); +#elif defined(HAVE_STORAGE_SD) + return sd_soft_reset(); +#elif defined(HAVE_STORAGE_NAND) + return nand_soft_reset(); +#elif defined(HAVE_STORAGE_FLASH_DISK) + return flash_soft_reset(); +#elif defined(HAVE_STORAGE_MMC) + return mmc_soft_reset(); +#else + #error No storage driver! +#endif +} +int storage_init(void) +{ +#ifdef HAVE_STORAGE_ATA + return ata_init(); +#elif defined(HAVE_STORAGE_SD) + return sd_init(); +#elif defined(HAVE_STORAGE_NAND) + return nand_init(); +#elif defined(HAVE_STORAGE_FLASH_DISK) + return flash_init(); +#elif defined(HAVE_STORAGE_MMC) + return mmc_init(); +#else + #error No storage driver! +#endif +} +int storage_read_sectors(IF_MV2(int drive,) unsigned long start, int count, void* buf) +{ +#ifdef HAVE_STORAGE_ATA + return ata_read_sectors(IF_MV2(drive,) start, count, buf); +#elif defined(HAVE_STORAGE_SD) + return sd_read_sectors(IF_MV2(drive,) start, count, buf); +#elif defined(HAVE_STORAGE_NAND) + return nand_read_sectors(IF_MV2(drive,) start, count, buf); +#elif defined(HAVE_STORAGE_FLASH_DISK) + return flash_read_sectors(IF_MV2(drive,) start, count, buf); +#elif defined(HAVE_STORAGE_MMC) + return mmc_read_sectors(IF_MV2(drive,) start, count, buf); +#else + #error No storage driver! +#endif +} +int storage_write_sectors(IF_MV2(int drive,) unsigned long start, int count, const void* buf) +{ +#ifdef HAVE_STORAGE_ATA + return ata_write_sectors(IF_MV2(drive,) start, count, buf); +#elif defined(HAVE_STORAGE_SD) + return sd_write_sectors(IF_MV2(drive,) start, count, buf); +#elif defined(HAVE_STORAGE_NAND) + return nand_write_sectors(IF_MV2(drive,) start, count, buf); +#elif defined(HAVE_STORAGE_FLASH_DISK) + return flash_write_sectors(IF_MV2(drive,) start, count, buf); +#elif defined(HAVE_STORAGE_MMC) + return mmc_write_sectors(IF_MV2(drive,) start, count, buf); +#else + #error No storage driver! +#endif +} +void storage_spin(void) +{ +#ifdef HAVE_STORAGE_ATA + ata_spin(); +#elif defined(HAVE_STORAGE_SD) + sd_spin(); +#elif defined(HAVE_STORAGE_NAND) + nand_spin(); +#elif defined(HAVE_STORAGE_FLASH_DISK) + flash_spin(); +#elif defined(HAVE_STORAGE_MMC) + mmc_spin(); +#else + #error No storage driver! +#endif +} + +#if (CONFIG_LED == LED_REAL) +void storage_set_led_enabled(bool enabled) +{ +#ifdef HAVE_STORAGE_ATA + ata_set_led_enabled(enabled); +#elif defined(HAVE_STORAGE_SD) + sd_set_led_enabled(enabled); +#elif defined(HAVE_STORAGE_NAND) + nand_set_led_enabled(enabled); +#elif defined(HAVE_STORAGE_FLASH_DISK) + flash_set_led_enabled(enabled); +#elif defined(HAVE_STORAGE_MMC) + mmc_set_led_enabled(enabled); +#else + #error No storage driver! +#endif +} +#endif + +unsigned short* storage_get_identify(void) +{ +#ifdef HAVE_STORAGE_ATA + return ata_get_identify(); +#elif defined(HAVE_STORAGE_NAND) + return nand_get_identify(); +#elif defined(HAVE_STORAGE_FLASH_DISK) + return flash_get_identify(); +#elif defined(HAVE_STORAGE_SD) + //return sd_get_identify(); +#elif defined(HAVE_STORAGE_MMC) + //return mmc_get_identify(); +#else + #error No storage driver! +#endif +} + +long storage_last_disk_activity(void) +{ +#ifdef HAVE_STORAGE_ATA + return ata_last_disk_activity(); +#elif defined(HAVE_STORAGE_SD) + return sd_last_disk_activity(); +#elif defined(HAVE_STORAGE_NAND) + return nand_last_disk_activity(); +#elif defined(HAVE_STORAGE_FLASH_DISK) + return flash_last_disk_activity(); +#elif defined(HAVE_STORAGE_MMC) + return mmc_last_disk_activity(); +#else + #error No storage driver! +#endif +} +int storage_spinup_time(void) +{ +#ifdef HAVE_STORAGE_ATA + return ata_spinup_time(); +#else + return 0; +#endif +} diff --git a/firmware/target/arm/ata-nand-telechips.c b/firmware/target/arm/ata-nand-telechips.c index 1c13565..71ad5e7 100644 --- a/firmware/target/arm/ata-nand-telechips.c +++ b/firmware/target/arm/ata-nand-telechips.c @@ -18,7 +18,7 @@ * KIND, either express or implied. * ****************************************************************************/ -#include "ata.h" +#include "nand.h" #include "ata-nand-target.h" #include "system.h" #include @@ -662,7 +662,7 @@ static void read_write_cache_segment(int bank, int phys_segment) } -int ata_read_sectors(IF_MV2(int drive,) unsigned long start, int incount, +int nand_read_sectors(IF_MV2(int drive,) unsigned long start, int incount, void* inbuf) { #ifdef HAVE_MULTIVOLUME @@ -702,7 +702,7 @@ int ata_read_sectors(IF_MV2(int drive,) unsigned long start, int incount, return 0; } -int ata_write_sectors(IF_MV2(int drive,) unsigned long start, int count, +int nand_write_sectors(IF_MV2(int drive,) unsigned long start, int count, const void* outbuf) { #ifdef HAVE_MULTIVOLUME @@ -716,42 +716,42 @@ int ata_write_sectors(IF_MV2(int drive,) unsigned long start, int count, return -1; } -void ata_spindown(int seconds) +void nand_spindown(int seconds) { /* null */ (void)seconds; } -bool ata_disk_is_active(void) +bool nand_disk_is_active(void) { /* null */ return 0; } -void ata_sleep(void) +void nand_sleep(void) { /* null */ } -void ata_spin(void) +void nand_spin(void) { /* null */ } /* Hardware reset protocol as specified in chapter 9.1, ATA spec draft v5 */ -int ata_hard_reset(void) +int nand_hard_reset(void) { /* null */ return 0; } -int ata_soft_reset(void) +int nand_soft_reset(void) { /* null */ return 0; } -void ata_enable(bool on) +void nand_enable(bool on) { /* null - flash controller is enabled/disabled as needed. */ (void)on; @@ -792,7 +792,7 @@ static void fill_identify(void) } } -int ata_init(void) +int nand_init(void) { int i, bank, phys_segment; unsigned char spare_buf[16]; @@ -915,7 +915,12 @@ int ata_init(void) return 0; } -unsigned short* ata_get_identify(void) +unsigned short* nand_get_identify(void) { return ata_identify; } + +long nand_last_disk_activity(void) +{ + return last_disk_activity; +} diff --git a/firmware/target/arm/ata-sd-pp.c b/firmware/target/arm/ata-sd-pp.c index fbbaf09..10766f1 100644 --- a/firmware/target/arm/ata-sd-pp.c +++ b/firmware/target/arm/ata-sd-pp.c @@ -128,15 +128,13 @@ /** global, exported variables **/ #ifdef HAVE_HOTSWAP -#define NUM_VOLUMES 2 +#define NUM_DRIVES 2 #else -#define NUM_VOLUMES 1 +#define NUM_DRIVES 1 #endif /* for compatibility */ -int ata_spinup_time = 0; - -long last_disk_activity = -1; +static long last_disk_activity = -1; /** static, private data **/ static bool initialized = false; @@ -153,7 +151,7 @@ struct sd_card_status int retry_max; }; -static struct sd_card_status sd_status[NUM_VOLUMES] = +static struct sd_card_status sd_status[NUM_DRIVES] = { { 0, 1 }, #ifdef HAVE_HOTSWAP @@ -786,12 +784,12 @@ static void sd_select_device(int card_no) /* API Functions */ -static void ata_led(bool onoff) +static void sd_led(bool onoff) { led(onoff); } -int ata_read_sectors(IF_MV2(int drive,) unsigned long start, int incount, +int sd_read_sectors(IF_MV2(int drive,) unsigned long start, int incount, void* inbuf) { #ifndef HAVE_HOTSWAP @@ -805,14 +803,14 @@ int ata_read_sectors(IF_MV2(int drive,) unsigned long start, int incount, mutex_lock(&sd_mtx); - ata_led(true); + sd_led(true); -ata_read_retry: +sd_read_retry: if (drive != 0 && !card_detect_target()) { /* no external sd-card inserted */ ret = -EC_NOCARD; - goto ata_read_error; + goto sd_read_error; } sd_select_device(drive); @@ -820,7 +818,7 @@ ata_read_retry: if (currcard->initialized < 0) { ret = currcard->initialized; - goto ata_read_error; + goto sd_read_error; } last_disk_activity = current_tick; @@ -834,7 +832,7 @@ ata_read_retry: { ret = sd_select_bank(bank); if (ret < 0) - goto ata_read_error; + goto sd_read_error; } start -= bank * BLOCKS_PER_BANK; @@ -842,7 +840,7 @@ ata_read_retry: ret = sd_wait_for_state(TRAN, EC_TRAN_READ_ENTRY); if (ret < 0) - goto ata_read_error; + goto sd_read_error; BLOCK_COUNT_REG = incount; @@ -858,7 +856,7 @@ ata_read_retry: ret = sd_command(READ_MULTIPLE_BLOCK, start * BLOCK_SIZE, NULL, 0x1c25); } if (ret < 0) - goto ata_read_error; + goto sd_read_error; /* TODO: Don't assume BLOCK_SIZE == SECTOR_SIZE */ @@ -874,38 +872,38 @@ ata_read_retry: } ret = -EC_FIFO_READ_FULL; - goto ata_read_error; + goto sd_read_error; } last_disk_activity = current_tick; ret = sd_command(STOP_TRANSMISSION, 0, NULL, 1); if (ret < 0) - goto ata_read_error; + goto sd_read_error; ret = sd_wait_for_state(TRAN, EC_TRAN_READ_EXIT); if (ret < 0) - goto ata_read_error; + goto sd_read_error; while (1) { - ata_led(false); + sd_led(false); mutex_unlock(&sd_mtx); return ret; -ata_read_error: +sd_read_error: if (sd_status[drive].retry < sd_status[drive].retry_max && ret != -EC_NOCARD) { sd_status[drive].retry++; currcard->initialized = 0; - goto ata_read_retry; + goto sd_read_retry; } } } -int ata_write_sectors(IF_MV2(int drive,) unsigned long start, int count, +int sd_write_sectors(IF_MV2(int drive,) unsigned long start, int count, const void* outbuf) { /* Write support is not finished yet */ @@ -920,14 +918,14 @@ int ata_write_sectors(IF_MV2(int drive,) unsigned long start, int count, mutex_lock(&sd_mtx); - ata_led(true); + sd_led(true); -ata_write_retry: +sd_write_retry: if (drive != 0 && !card_detect_target()) { /* no external sd-card inserted */ ret = -EC_NOCARD; - goto ata_write_error; + goto sd_write_error; } sd_select_device(drive); @@ -935,7 +933,7 @@ ata_write_retry: if (currcard->initialized < 0) { ret = currcard->initialized; - goto ata_write_error; + goto sd_write_error; } /* Only switch banks with non-SDHC cards */ @@ -947,7 +945,7 @@ ata_write_retry: { ret = sd_select_bank(bank); if (ret < 0) - goto ata_write_error; + goto sd_write_error; } start -= bank * BLOCKS_PER_BANK; @@ -957,7 +955,7 @@ ata_write_retry: ret = sd_wait_for_state(TRAN, EC_TRAN_WRITE_ENTRY); if (ret < 0) - goto ata_write_error; + goto sd_write_error; BLOCK_COUNT_REG = count; @@ -973,7 +971,7 @@ ata_write_retry: ret = sd_command(WRITE_MULTIPLE_BLOCK, start*BLOCK_SIZE, NULL, 0x1c2d); } if (ret < 0) - goto ata_write_error; + goto sd_write_error; buf_end = outbuf + count * currcard->block_size - 2*FIFO_LEN; @@ -996,7 +994,7 @@ ata_write_retry: } ret = -EC_FIFO_WR_EMPTY; - goto ata_write_error; + goto sd_write_error; } last_disk_activity = current_tick; @@ -1004,31 +1002,31 @@ ata_write_retry: if (!sd_poll_status(DATA_DONE, 0x80000)) { ret = -EC_FIFO_WR_DONE; - goto ata_write_error; + goto sd_write_error; } ret = sd_command(STOP_TRANSMISSION, 0, NULL, 1); if (ret < 0) - goto ata_write_error; + goto sd_write_error; ret = sd_wait_for_state(TRAN, EC_TRAN_WRITE_EXIT); if (ret < 0) - goto ata_write_error; + goto sd_write_error; while (1) { - ata_led(false); + sd_led(false); mutex_unlock(&sd_mtx); return ret; -ata_write_error: +sd_write_error: if (sd_status[drive].retry < sd_status[drive].retry_max && ret != -EC_NOCARD) { sd_status[drive].retry++; currcard->initialized = 0; - goto ata_write_retry; + goto sd_write_retry; } } } @@ -1088,7 +1086,7 @@ static void sd_thread(void) if (!idle_notified) { - call_ata_idle_notifys(false); + call_storage_idle_notifys(false); idle_notified = true; } } @@ -1107,36 +1105,36 @@ static void sd_thread(void) } -void ata_spindown(int seconds) +void sd_spindown(int seconds) { (void)seconds; } -bool ata_disk_is_active(void) +bool sd_disk_is_active(void) { return 0; } -void ata_sleep(void) +void sd_sleep(void) { } -void ata_spin(void) +void sd_spin(void) { } /* Hardware reset protocol as specified in chapter 9.1, ATA spec draft v5 */ -int ata_hard_reset(void) +int sd_hard_reset(void) { return 0; } -int ata_soft_reset(void) +int sd_soft_reset(void) { return 0; } -void ata_enable(bool on) +void sd_enable(bool on) { if(on) { @@ -1170,7 +1168,7 @@ void card_enable_monitoring_target(bool on) } #endif -int ata_init(void) +int sd_init(void) { int ret = 0; @@ -1179,7 +1177,7 @@ int ata_init(void) mutex_lock(&sd_mtx); - ata_led(false); + sd_led(false); if (!initialized) { @@ -1324,3 +1322,8 @@ void microsd_int(void) } #endif /* HAVE_HOTSWAP */ + +long sd_last_disk_activity(void) +{ + return last_disk_activity; +} diff --git a/firmware/usb.c b/firmware/usb.c index e5c7565..4430491 100644 --- a/firmware/usb.c +++ b/firmware/usb.c @@ -29,7 +29,7 @@ #include "thread.h" #include "system.h" #include "debug.h" -#include "ata.h" +#include "storage.h" #include "fat.h" #include "disk.h" #include "panic.h" @@ -71,7 +71,7 @@ static int countdown; static int usb_state; -#if defined(HAVE_MMC) && defined(USB_FULL_INIT) +#if defined(HAVE_STORAGE_MMC) && defined(USB_FULL_INIT) static int usb_mmc_countdown = 0; #endif @@ -86,7 +86,7 @@ static struct event_queue usb_queue; static int last_usb_status; static bool usb_monitor_enabled; #ifdef HAVE_USBSTACK -static bool exclusive_ata_access; +static bool exclusive_storage_access; #endif @@ -105,9 +105,9 @@ static void usb_slave_mode(bool on) if(on) { DEBUGF("Entering USB slave mode\n"); - ata_soft_reset(); - ata_init(); - ata_enable(false); + storage_soft_reset(); + storage_init(); + storage_enable(false); usb_enable(true); } else @@ -119,9 +119,9 @@ static void usb_slave_mode(bool on) usb_enable(false); - rc = ata_init(); + rc = storage_init(); if(rc) - panicf("ata: %d",rc); + panicf("storage: %d",rc); rc = disk_mount_all(); if (rc <= 0) /* no partition */ @@ -134,7 +134,7 @@ static void usb_slave_mode(bool on) static void try_reboot(void) { #ifdef HAVE_DISK_STORAGE - ata_sleepnow(); /* Immediately spindown the disk. */ + storage_sleepnow(); /* Immediately spindown the disk. */ sleep(HZ*2); #endif @@ -262,7 +262,7 @@ static void usb_thread(void) #ifdef HAVE_PRIORITY_SCHEDULING thread_set_priority(usb_thread_entry,PRIORITY_REALTIME); #endif - exclusive_ata_access = true; + exclusive_storage_access = true; #else usb_slave_mode(true); @@ -310,12 +310,12 @@ static void usb_thread(void) usb_state = USB_EXTRACTED; #ifdef HAVE_USBSTACK - if(exclusive_ata_access) + if(exclusive_storage_access) { int rc = disk_mount_all(); if (rc <= 0) /* no partition */ panicf("mount: %d",rc); - exclusive_ata_access = false; + exclusive_storage_access = false; #endif /* Tell all threads that we are back in business */ num_acks_to_expect = @@ -435,7 +435,7 @@ static void usb_tick(void) } } } -#ifdef HAVE_MMC +#ifdef HAVE_STORAGE_MMC if(usb_mmc_countdown > 0) { usb_mmc_countdown--; @@ -455,7 +455,7 @@ void usb_init(void) { usb_state = USB_EXTRACTED; #ifdef HAVE_USBSTACK - exclusive_ata_access = false; + exclusive_storage_access = false; #endif usb_monitor_enabled = false; countdown = -1; @@ -561,7 +561,7 @@ void usb_request_exclusive_ata(void) * currently the best one. We want to get rid of having to boost the cpu * for usb anyway */ trigger_cpu_boost(); - if(!exclusive_ata_access) { + if(!exclusive_storage_access) { queue_post(&usb_queue, USB_REQUEST_DISK, 0); } } @@ -569,15 +569,15 @@ void usb_request_exclusive_ata(void) void usb_release_exclusive_ata(void) { cancel_cpu_boost(); - if(exclusive_ata_access) { + if(exclusive_storage_access) { queue_post(&usb_queue, USB_RELEASE_DISK, 0); - exclusive_ata_access = false; + exclusive_storage_access = false; } } bool usb_exclusive_ata(void) { - return exclusive_ata_access; + return exclusive_storage_access; } #endif diff --git a/firmware/usbstack/usb_core.c b/firmware/usbstack/usb_core.c index d5e33f1..e6d67fd 100644 --- a/firmware/usbstack/usb_core.c +++ b/firmware/usbstack/usb_core.c @@ -51,7 +51,7 @@ #endif #if !defined(HAVE_AS3514) && !defined(IPOD_ARCH) -#include "ata.h" +#include "storage.h" #endif @@ -287,7 +287,7 @@ static void set_serial_descriptor(void) static void set_serial_descriptor(void) { short* p = &usb_string_iSerial.wString[1]; - unsigned short* identify = ata_get_identify(); + unsigned short* identify = storage_get_identify(); unsigned short x; int i; diff --git a/firmware/usbstack/usb_storage.c b/firmware/usbstack/usb_storage.c index 6d9a5b9..50ef178 100644 --- a/firmware/usbstack/usb_storage.c +++ b/firmware/usbstack/usb_storage.c @@ -24,7 +24,7 @@ #include "usb_drv.h" //#define LOGF_ENABLE #include "logf.h" -#include "ata.h" +#include "storage.h" #include "hotswap.h" #include "disk.h" /* Needed to get at the audio buffer */ @@ -36,10 +36,10 @@ /* The SD card driver on Sansa c200 and e200 can cause write corruption, * often triggered by simultaneous USB activity. This can be largely avoided - * by not overlapping ata_write_sector() with USB transfers. This does reduce + * by not overlapping storage_write_sector() with USB transfers. This does reduce * write performance, so we only do it for the affected DAPs */ -#ifdef HAVE_ATA_SD +#ifdef HAVE_STORAGE_SD #define SERIALIZE_WRITES #endif /* Enable the following define to export only the SD card slot. This @@ -278,7 +278,7 @@ static enum { static bool check_disk_present(IF_MV_NONVOID(int volume)) { unsigned char sector[512]; - return ata_read_sectors(IF_MV2(volume,)0,1,sector) == 0; + return storage_read_sectors(IF_MV2(volume,)0,1,sector) == 0; } static void try_release_ata(void) @@ -440,7 +440,7 @@ void usb_storage_transfer_complete(int ep,int dir,int status,int length) /* Now write the data that just came in, while the host is sending the next bit */ - int result = ata_write_sectors(IF_MV2(cur_cmd.lun,) + int result = storage_write_sectors(IF_MV2(cur_cmd.lun,) cur_cmd.sector, MIN(BUFFER_SIZE/SECTOR_SIZE, cur_cmd.count), @@ -613,7 +613,7 @@ static void send_and_read_next(void) if(cur_cmd.count!=0){ /* already read the next bit, so we can send it out immediately when the * current transfer completes. */ - cur_cmd.last_result = ata_read_sectors(IF_MV2(cur_cmd.lun,) + cur_cmd.last_result = storage_read_sectors(IF_MV2(cur_cmd.lun,) cur_cmd.sector, MIN(BUFFER_SIZE/SECTOR_SIZE, cur_cmd.count), @@ -637,7 +637,7 @@ static void handle_scsi(struct command_block_wrapper* cbw) unsigned char lun = cbw->lun; #endif unsigned int block_size_mult = 1; -#if defined(HAVE_ATA_SD) || defined(HAVE_HOTSWAP) +#if defined(HAVE_STORAGE_SD) || defined(HAVE_HOTSWAP) tCardInfo* cinfo = card_get_info(lun); if(cinfo->initialized && cinfo->numblocks > 0) { block_size = cinfo->blocksize; @@ -648,7 +648,7 @@ static void handle_scsi(struct command_block_wrapper* cbw) try_release_ata(); } #else - unsigned short* identify = ata_get_identify(); + unsigned short* identify = storage_get_identify(); block_size = SECTOR_SIZE; block_count = (identify[61] << 16 | identify[60]); #endif @@ -938,7 +938,7 @@ static void handle_scsi(struct command_block_wrapper* cbw) cur_sense_data.ascq=0; } else { - cur_cmd.last_result = ata_read_sectors(IF_MV2(cur_cmd.lun,) + cur_cmd.last_result = storage_read_sectors(IF_MV2(cur_cmd.lun,) cur_cmd.sector, MIN(BUFFER_SIZE/SECTOR_SIZE, cur_cmd.count), @@ -1052,7 +1052,7 @@ static void identify2inquiry(int lun) unsigned int i; unsigned short* dest; unsigned short* src; - unsigned short* identify = ata_get_identify(); + unsigned short* identify = storage_get_identify(); (void)lun; memset(tb.inquiry, 0, sizeof(struct inquiry_data));