diff options
| author | Björn Stenberg <bjorn@haxx.se> | 2002-08-15 12:42:37 +0000 |
|---|---|---|
| committer | Björn Stenberg <bjorn@haxx.se> | 2002-08-15 12:42:37 +0000 |
| commit | c9d98ca9271d1e2045a1ca21215701f3fb2aaa37 (patch) | |
| tree | 80715a6a9c47cba88001ade5a5ca0557a7a4dc69 | |
| parent | 5917e8157a40e018e99086cb9328add9249f0264 (diff) | |
| download | rockbox-c9d98ca9271d1e2045a1ca21215701f3fb2aaa37.zip rockbox-c9d98ca9271d1e2045a1ca21215701f3fb2aaa37.tar.gz rockbox-c9d98ca9271d1e2045a1ca21215701f3fb2aaa37.tar.bz2 rockbox-c9d98ca9271d1e2045a1ca21215701f3fb2aaa37.tar.xz | |
Added delayed write for settings. Doesn't write until someone else accesses the disk.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@1762 a1c6a512-1295-4272-9138-f99709370657
| -rw-r--r-- | apps/settings.c | 2 | ||||
| -rw-r--r-- | firmware/drivers/ata.c | 28 | ||||
| -rw-r--r-- | firmware/drivers/ata.h | 10 | ||||
| -rw-r--r-- | uisimulator/common/stubs.c | 5 |
4 files changed, 38 insertions, 7 deletions
diff --git a/apps/settings.c b/apps/settings.c index 85bd41a..f8b6870 100644 --- a/apps/settings.c +++ b/apps/settings.c @@ -158,7 +158,7 @@ static int save_config_buffer( void ) #else if(battery_level_safe() && (fat_startsector()!=0)) - return !ata_write_sectors( 61, 1, rtc_config_block); + ata_delayed_write( 61, rtc_config_block); else return -1; diff --git a/firmware/drivers/ata.c b/firmware/drivers/ata.c index ebe9602..0795eaf 100644 --- a/firmware/drivers/ata.c +++ b/firmware/drivers/ata.c @@ -89,6 +89,9 @@ static char ata_stack[DEFAULT_STACK_SIZE]; static char ata_thread_name[] = "ata"; static struct event_queue ata_queue; static bool initialized = false; +static bool delayed_write = false; +static unsigned char delayed_sector[SECTOR_SIZE]; +static int delayed_sector_num; #ifdef USE_POWEROFF static int ata_power_on(void); @@ -215,6 +218,10 @@ int ata_read_sectors(unsigned long start, ret = -1; mutex_unlock(&ata_mtx); + + if ( delayed_write ) + ata_flush(); + return ret; } @@ -279,9 +286,30 @@ int ata_write_sectors(unsigned long start, i = wait_for_end_of_transfer(); mutex_unlock(&ata_mtx); + + if ( delayed_write ) + ata_flush(); + return i; } +extern void ata_delayed_write(unsigned long sector, void* buf) +{ + memcpy(delayed_sector, buf, SECTOR_SIZE); + delayed_sector_num = sector; + delayed_write = true; +} + +extern void ata_flush(void) +{ + if ( delayed_write ) { + delayed_write = false; + ata_write_sectors(delayed_sector_num, 1, delayed_sector); + } +} + + + static int check_registers(void) { if ( ATA_STATUS & STATUS_BSY ) diff --git a/firmware/drivers/ata.h b/firmware/drivers/ata.h index 4209fdc..244ec63 100644 --- a/firmware/drivers/ata.h +++ b/firmware/drivers/ata.h @@ -39,11 +39,9 @@ extern bool ata_disk_is_active(void); extern int ata_hard_reset(void); extern int ata_soft_reset(void); extern int ata_init(void); -extern int ata_read_sectors(unsigned long start, - int count, - void* buf); -extern int ata_write_sectors(unsigned long start, - int count, - void* buf); +extern int ata_read_sectors(unsigned long start, int count, void* buf); +extern int ata_write_sectors(unsigned long start, int count, void* buf); +extern void ata_delayed_write(unsigned long sector, void* buf); +extern void ata_flush(void); #endif diff --git a/uisimulator/common/stubs.c b/uisimulator/common/stubs.c index aacd277..22623dc 100644 --- a/uisimulator/common/stubs.c +++ b/uisimulator/common/stubs.c @@ -75,3 +75,8 @@ int ata_read_sectors(unsigned long start, } return 1; } + +void ata_delayed_write(unsigned long sector, void* buf) +{ + ata_write_sectors(sector,1,buf); +} |