summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBjörn Stenberg <bjorn@haxx.se>2002-08-15 12:42:37 +0000
committerBjörn Stenberg <bjorn@haxx.se>2002-08-15 12:42:37 +0000
commitc9d98ca9271d1e2045a1ca21215701f3fb2aaa37 (patch)
tree80715a6a9c47cba88001ade5a5ca0557a7a4dc69
parent5917e8157a40e018e99086cb9328add9249f0264 (diff)
downloadrockbox-c9d98ca9271d1e2045a1ca21215701f3fb2aaa37.tar.gz
rockbox-c9d98ca9271d1e2045a1ca21215701f3fb2aaa37.zip
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.c2
-rw-r--r--firmware/drivers/ata.c28
-rw-r--r--firmware/drivers/ata.h10
-rw-r--r--uisimulator/common/stubs.c5
4 files changed, 38 insertions, 7 deletions
diff --git a/apps/settings.c b/apps/settings.c
index 85bd41a55f..f8b6870863 100644
--- a/apps/settings.c
+++ b/apps/settings.c
@@ -158,7 +158,7 @@ static int save_config_buffer( void )
158#else 158#else
159 159
160 if(battery_level_safe() && (fat_startsector()!=0)) 160 if(battery_level_safe() && (fat_startsector()!=0))
161 return !ata_write_sectors( 61, 1, rtc_config_block); 161 ata_delayed_write( 61, rtc_config_block);
162 else 162 else
163 return -1; 163 return -1;
164 164
diff --git a/firmware/drivers/ata.c b/firmware/drivers/ata.c
index ebe9602f01..0795eaf1f8 100644
--- a/firmware/drivers/ata.c
+++ b/firmware/drivers/ata.c
@@ -89,6 +89,9 @@ static char ata_stack[DEFAULT_STACK_SIZE];
89static char ata_thread_name[] = "ata"; 89static char ata_thread_name[] = "ata";
90static struct event_queue ata_queue; 90static struct event_queue ata_queue;
91static bool initialized = false; 91static bool initialized = false;
92static bool delayed_write = false;
93static unsigned char delayed_sector[SECTOR_SIZE];
94static int delayed_sector_num;
92 95
93#ifdef USE_POWEROFF 96#ifdef USE_POWEROFF
94static int ata_power_on(void); 97static int ata_power_on(void);
@@ -215,6 +218,10 @@ int ata_read_sectors(unsigned long start,
215 ret = -1; 218 ret = -1;
216 219
217 mutex_unlock(&ata_mtx); 220 mutex_unlock(&ata_mtx);
221
222 if ( delayed_write )
223 ata_flush();
224
218 return ret; 225 return ret;
219} 226}
220 227
@@ -279,9 +286,30 @@ int ata_write_sectors(unsigned long start,
279 i = wait_for_end_of_transfer(); 286 i = wait_for_end_of_transfer();
280 287
281 mutex_unlock(&ata_mtx); 288 mutex_unlock(&ata_mtx);
289
290 if ( delayed_write )
291 ata_flush();
292
282 return i; 293 return i;
283} 294}
284 295
296extern void ata_delayed_write(unsigned long sector, void* buf)
297{
298 memcpy(delayed_sector, buf, SECTOR_SIZE);
299 delayed_sector_num = sector;
300 delayed_write = true;
301}
302
303extern void ata_flush(void)
304{
305 if ( delayed_write ) {
306 delayed_write = false;
307 ata_write_sectors(delayed_sector_num, 1, delayed_sector);
308 }
309}
310
311
312
285static int check_registers(void) 313static int check_registers(void)
286{ 314{
287 if ( ATA_STATUS & STATUS_BSY ) 315 if ( ATA_STATUS & STATUS_BSY )
diff --git a/firmware/drivers/ata.h b/firmware/drivers/ata.h
index 4209fdcd1e..244ec63777 100644
--- a/firmware/drivers/ata.h
+++ b/firmware/drivers/ata.h
@@ -39,11 +39,9 @@ extern bool ata_disk_is_active(void);
39extern int ata_hard_reset(void); 39extern int ata_hard_reset(void);
40extern int ata_soft_reset(void); 40extern int ata_soft_reset(void);
41extern int ata_init(void); 41extern int ata_init(void);
42extern int ata_read_sectors(unsigned long start, 42extern int ata_read_sectors(unsigned long start, int count, void* buf);
43 int count, 43extern int ata_write_sectors(unsigned long start, int count, void* buf);
44 void* buf); 44extern void ata_delayed_write(unsigned long sector, void* buf);
45extern int ata_write_sectors(unsigned long start, 45extern void ata_flush(void);
46 int count,
47 void* buf);
48 46
49#endif 47#endif
diff --git a/uisimulator/common/stubs.c b/uisimulator/common/stubs.c
index aacd277cb2..22623dcb5e 100644
--- a/uisimulator/common/stubs.c
+++ b/uisimulator/common/stubs.c
@@ -75,3 +75,8 @@ int ata_read_sectors(unsigned long start,
75 } 75 }
76 return 1; 76 return 1;
77} 77}
78
79void ata_delayed_write(unsigned long sector, void* buf)
80{
81 ata_write_sectors(sector,1,buf);
82}